Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc644e85bf | ||
|
|
c7b8d95097 | ||
|
|
42de7cebe1 | ||
|
|
2e520c933a | ||
|
|
5d1dd0dd27 | ||
|
|
154f9f22f1 | ||
|
|
98e398954e | ||
|
|
3643c2e306 | ||
|
|
80195f6d11 | ||
|
|
6bc648bfe0 | ||
|
|
c29b12d3b5 | ||
|
|
8a5b514944 | ||
|
|
64fd66bd2a | ||
|
|
75aa7ba2c7 |
+4
-1
@@ -20,4 +20,7 @@
|
||||
7.1.2
|
||||
7.8.2
|
||||
7.9.2
|
||||
8.0.2
|
||||
8.0.2
|
||||
8.0.3
|
||||
8.0.4
|
||||
8.0.5
|
||||
+23
-1
@@ -1,6 +1,28 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 8.0.2
|
||||
## 8.0.5 Dec 1, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust sha3 expectation of `BigInt` availability
|
||||
|
||||
|
||||
## 8.0.4 Nov 30, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust `stringCamelCase` with leading `_`
|
||||
|
||||
|
||||
## 8.0.3 Nov 30, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Remove `Buffer` usage in `x-randomvalues`
|
||||
- Adjust `stringCamelCase` for all-caps parts
|
||||
|
||||
|
||||
## 8.0.2 Nov 26, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
"url": "https://github.com/polkadot-js/common.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger-transports', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger-transports', version: '8.0.5' };
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@polkadot/hw-ledger-transports": "8.0.2",
|
||||
"@polkadot/util": "8.0.2",
|
||||
"@polkadot/hw-ledger-transports": "8.0.5",
|
||||
"@polkadot/util": "8.0.5",
|
||||
"@zondax/ledger-substrate": "^0.18.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger', version: '8.0.5' };
|
||||
|
||||
@@ -20,15 +20,15 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@polkadot/util": "8.0.2",
|
||||
"@polkadot/util-crypto": "8.0.2"
|
||||
"@polkadot/util": "8.0.5",
|
||||
"@polkadot/util-crypto": "8.0.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "8.0.2",
|
||||
"@polkadot/util-crypto": "8.0.2"
|
||||
"@polkadot/util": "8.0.5",
|
||||
"@polkadot/util-crypto": "8.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/keyring', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/keyring', version: '8.0.5' };
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "8.0.2",
|
||||
"@polkadot/x-fetch": "8.0.2"
|
||||
"@polkadot/util": "8.0.5",
|
||||
"@polkadot/x-fetch": "8.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/networks', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/networks', version: '8.0.5' };
|
||||
|
||||
@@ -25,15 +25,15 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@noble/hashes": "0.4.1",
|
||||
"@polkadot/networks": "8.0.2",
|
||||
"@polkadot/util": "8.0.2",
|
||||
"@polkadot/networks": "8.0.5",
|
||||
"@polkadot/util": "8.0.5",
|
||||
"@polkadot/wasm-crypto": "^4.4.1",
|
||||
"@polkadot/x-randomvalues": "8.0.2",
|
||||
"@polkadot/x-randomvalues": "8.0.5",
|
||||
"bn.js": "^4.12.0",
|
||||
"ed2curve": "^0.3.0",
|
||||
"elliptic": "^6.5.4",
|
||||
@@ -46,6 +46,6 @@
|
||||
"@types/elliptic": "^6.4.14"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "8.0.2"
|
||||
"@polkadot/util": "8.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,20 +5,20 @@ import { utils } from 'micro-base';
|
||||
|
||||
import { createDecode, createEncode, createIs, createValidate } from './helpers';
|
||||
|
||||
const BASE32_ALPHABET = 'abcdefghijklmnopqrstuvwxyz234567';
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz234567';
|
||||
|
||||
const BASE32_CONFIG = {
|
||||
alphabet: BASE32_ALPHABET,
|
||||
const config = {
|
||||
chars,
|
||||
coder: utils.chain(
|
||||
// We define our own chain, the default base32 has padding
|
||||
utils.radix2(5),
|
||||
utils.alphabet(BASE32_ALPHABET),
|
||||
utils.alphabet(chars),
|
||||
{
|
||||
decode: (input: string) => input.split(''),
|
||||
encode: (input: string[]) => input.join('')
|
||||
}
|
||||
),
|
||||
ipfsChar: 'b',
|
||||
ipfs: 'b',
|
||||
type: 'base32'
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ const BASE32_CONFIG = {
|
||||
* @description
|
||||
* Validates that the supplied value is valid base32, throwing exceptions if not
|
||||
*/
|
||||
export const base32Validate = createValidate(BASE32_CONFIG);
|
||||
export const base32Validate = createValidate(config);
|
||||
|
||||
/**
|
||||
* @name isBase32
|
||||
@@ -42,7 +42,7 @@ export const isBase32 = createIs(base32Validate);
|
||||
* @description
|
||||
* From the provided input, decode the base32 and return the result as an `Uint8Array`.
|
||||
*/
|
||||
export const base32Decode = createDecode(BASE32_CONFIG, base32Validate);
|
||||
export const base32Decode = createDecode(config, base32Validate);
|
||||
|
||||
/**
|
||||
* @name base32Encode
|
||||
@@ -50,4 +50,4 @@ export const base32Decode = createDecode(BASE32_CONFIG, base32Validate);
|
||||
* @description
|
||||
* From the provided input, create the base32 and return the result as a string.
|
||||
*/
|
||||
export const base32Encode = createEncode(BASE32_CONFIG);
|
||||
export const base32Encode = createEncode(config);
|
||||
|
||||
@@ -21,9 +21,9 @@ interface Coder {
|
||||
}
|
||||
|
||||
interface Config {
|
||||
alphabet: string;
|
||||
chars: string;
|
||||
coder: Coder;
|
||||
ipfsChar?: string;
|
||||
ipfs?: string;
|
||||
regex?: RegExp;
|
||||
type: string;
|
||||
}
|
||||
@@ -34,24 +34,24 @@ type EncodeFn = (value: U8aLike, ipfsCompat?: boolean) => string;
|
||||
|
||||
type ValidateFn = (value?: unknown, ipfsCompat?: boolean) => value is string;
|
||||
|
||||
export function createDecode ({ coder, ipfsChar }: Config, validate: ValidateFn): DecodeFn {
|
||||
export function createDecode ({ coder, ipfs }: Config, validate: ValidateFn): DecodeFn {
|
||||
return (value: string, ipfsCompat?: boolean): Uint8Array => {
|
||||
validate(value, ipfsCompat);
|
||||
|
||||
return coder.decode(
|
||||
ipfsChar && ipfsCompat
|
||||
ipfs && ipfsCompat
|
||||
? value.substr(1)
|
||||
: value
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export function createEncode ({ coder, ipfsChar }: Config): EncodeFn {
|
||||
export function createEncode ({ coder, ipfs }: Config): EncodeFn {
|
||||
return (value: U8aLike, ipfsCompat?: boolean): string => {
|
||||
const out = coder.encode(u8aToU8a(value));
|
||||
|
||||
return ipfsChar && ipfsCompat
|
||||
? `${ipfsChar}${out}`
|
||||
return ipfs && ipfsCompat
|
||||
? `${ipfs}${out}`
|
||||
: out;
|
||||
};
|
||||
}
|
||||
@@ -66,20 +66,24 @@ export function createIs (validate: ValidateFn): ValidateFn {
|
||||
};
|
||||
}
|
||||
|
||||
export function createValidate ({ alphabet, ipfsChar, regex, type }: Config): ValidateFn {
|
||||
export function createValidate ({ chars, ipfs, type }: Config): ValidateFn {
|
||||
return (value?: unknown, ipfsCompat?: boolean): value is string => {
|
||||
assert(value && typeof value === 'string', () => `Expected non-null, non-empty ${type} string input`);
|
||||
|
||||
if (ipfsChar && ipfsCompat) {
|
||||
assert(value[0] === ipfsChar, () => `Expected ipfs-compatible ${type} to start with '${ipfsChar}'`);
|
||||
if (ipfs && ipfsCompat) {
|
||||
assert(value[0] === ipfs, () => `Expected ipfs-compatible ${type} to start with '${ipfs}'`);
|
||||
}
|
||||
|
||||
if (regex) {
|
||||
assert(regex.test(value), `Invalid ${type} encoding`);
|
||||
} else {
|
||||
for (let i = (ipfsCompat ? 1 : 0); i < value.length; i++) {
|
||||
assert(alphabet.includes(value[i]), () => `Invalid ${type} character "${value[i]}" (0x${value.charCodeAt(i).toString(16)}) at index ${i}`);
|
||||
}
|
||||
for (let i = (ipfsCompat ? 1 : 0); i < value.length; i++) {
|
||||
assert(
|
||||
chars.includes(value[i]) || (
|
||||
value[i] === '=' && (
|
||||
(i === value.length - 1) ||
|
||||
!chars.includes(value[i + 1])
|
||||
)
|
||||
),
|
||||
() => `Invalid ${type} character "${value[i]}" (0x${value.charCodeAt(i).toString(16)}) at index ${i}`
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -5,10 +5,10 @@ import { base58 } from 'micro-base';
|
||||
|
||||
import { createDecode, createEncode, createIs, createValidate } from '../base32/helpers';
|
||||
|
||||
const BASE58_CONFIG = {
|
||||
alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz',
|
||||
const config = {
|
||||
chars: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz',
|
||||
coder: base58,
|
||||
ipfsChar: 'z',
|
||||
ipfs: 'z',
|
||||
type: 'base58'
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ const BASE58_CONFIG = {
|
||||
* @description
|
||||
* Validates that the supplied value is valid base58, throwing exceptions if not
|
||||
*/
|
||||
export const base58Validate = createValidate(BASE58_CONFIG);
|
||||
export const base58Validate = createValidate(config);
|
||||
|
||||
/**
|
||||
* @name base58Decode
|
||||
@@ -26,7 +26,7 @@ export const base58Validate = createValidate(BASE58_CONFIG);
|
||||
* @description
|
||||
* From the provided input, decode the base58 and return the result as an `Uint8Array`.
|
||||
*/
|
||||
export const base58Decode = createDecode(BASE58_CONFIG, base58Validate);
|
||||
export const base58Decode = createDecode(config, base58Validate);
|
||||
|
||||
/**
|
||||
* @name base58Encode
|
||||
@@ -34,7 +34,7 @@ export const base58Decode = createDecode(BASE58_CONFIG, base58Validate);
|
||||
* @description
|
||||
* From the provided input, create the base58 and return the result as a string.
|
||||
*/
|
||||
export const base58Encode = createEncode(BASE58_CONFIG);
|
||||
export const base58Encode = createEncode(config);
|
||||
|
||||
/**
|
||||
* @name isBase58
|
||||
|
||||
@@ -5,10 +5,9 @@ import { base64 } from 'micro-base';
|
||||
|
||||
import { createDecode, createEncode, createIs, createValidate } from '../base32/helpers';
|
||||
|
||||
const BASE64_CONFIG = {
|
||||
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
|
||||
const config = {
|
||||
chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
|
||||
coder: base64,
|
||||
regex: /^(?:[A-Za-z0-9+/]{2}[A-Za-z0-9+/]{2})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,
|
||||
type: 'base64'
|
||||
};
|
||||
|
||||
@@ -18,7 +17,7 @@ const BASE64_CONFIG = {
|
||||
* @description
|
||||
* Validates that the supplied value is valid base64
|
||||
*/
|
||||
export const base64Validate = createValidate(BASE64_CONFIG);
|
||||
export const base64Validate = createValidate(config);
|
||||
|
||||
/**
|
||||
* @name isBase64
|
||||
@@ -32,7 +31,7 @@ export const isBase64 = createIs(base64Validate);
|
||||
* @description
|
||||
* From the provided input, decode the base64 and return the result as an `Uint8Array`.
|
||||
*/
|
||||
export const base64Decode = createDecode(BASE64_CONFIG, base64Validate);
|
||||
export const base64Decode = createDecode(config, base64Validate);
|
||||
|
||||
/**
|
||||
* @name base64Encode
|
||||
@@ -40,4 +39,4 @@ export const base64Decode = createDecode(BASE64_CONFIG, base64Validate);
|
||||
* @description
|
||||
* From the provided input, create the base64 and return the result as a string.
|
||||
*/
|
||||
export const base64Encode = createEncode(BASE64_CONFIG);
|
||||
export const base64Encode = createEncode(config);
|
||||
|
||||
@@ -6,11 +6,27 @@ import { stringToU8a } from '@polkadot/util';
|
||||
import { base64Decode } from '.';
|
||||
|
||||
describe('base64Decode', (): void => {
|
||||
it('decodes a mixed base64 utf8 string', (): void => {
|
||||
it('decodes a mixed base64 utf8 string (1)', (): void => {
|
||||
expect(
|
||||
base64Decode('aGVsbG8gd29ybGQg0J/RgNC40LLQtdGC0YHRgtCy0YPRjiDQvNC4IOS9oOWlvQ==')
|
||||
).toEqual(
|
||||
stringToU8a('hello world Приветствую ми 你好')
|
||||
);
|
||||
});
|
||||
|
||||
it('decodes a mixed base64 utf8 string (2)', (): void => {
|
||||
expect(
|
||||
base64Decode('4pyTIMOgIGxhIG1vZGU=')
|
||||
).toEqual(
|
||||
stringToU8a('✓ à la mode')
|
||||
);
|
||||
});
|
||||
|
||||
it('decodes a mixed base64 utf8 string (3)', (): void => {
|
||||
expect(
|
||||
base64Decode('SGVsbG8gV29ybGQh')
|
||||
).toEqual(
|
||||
stringToU8a('Hello World!')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,6 +7,6 @@ describe('base64Validate', (): void => {
|
||||
it('validates a mixed base64 utf8 string', (): void => {
|
||||
expect(
|
||||
() => base64Validate('aGVsbG8gd29ybGQg0J/RgNC40LLQtd^GC0YHRgtCy0YPRjiDQvNC4IOS9oOWlvQ==')
|
||||
).toThrow(/Invalid base64 encoding/);
|
||||
).toThrow(/Invalid base64 character "\^" \(0x5e\) at index 30/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
|
||||
let t = _0n;
|
||||
for (let j = 0; j < 7; j++) {
|
||||
R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;
|
||||
if (R & _2n) t ^= _1n << ((_1n << BigInt(j)) - _1n);
|
||||
if (R & _2n) t ^= _1n << ((_1n << _n(j)) - _1n);
|
||||
}
|
||||
_SHA3_IOTA.push(t);
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/util-crypto', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/util-crypto', version: '8.0.5' };
|
||||
|
||||
@@ -34,12 +34,12 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@polkadot/x-textdecoder": "8.0.2",
|
||||
"@polkadot/x-textencoder": "8.0.2",
|
||||
"@polkadot/x-textdecoder": "8.0.5",
|
||||
"@polkadot/x-textencoder": "8.0.5",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.12.0",
|
||||
"ip-regex": "^4.3.0"
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/util', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/util', version: '8.0.5' };
|
||||
|
||||
@@ -43,5 +43,23 @@ describe('stringCamelCase', (): void => {
|
||||
).toBe('fooBarBazTestSpacedExtra');
|
||||
});
|
||||
|
||||
it('adjusts all-uppercase', (): void => {
|
||||
expect(
|
||||
stringCamelCase('DEDUP_KEY_PREFIX')
|
||||
).toEqual('dedupKeyPrefix');
|
||||
});
|
||||
|
||||
it('adjusts with leading _', (): void => {
|
||||
expect(
|
||||
stringCamelCase('_reserved')
|
||||
).toEqual('reserved');
|
||||
});
|
||||
|
||||
it('adjusts with minimal chars per part', (): void => {
|
||||
expect(
|
||||
stringCamelCase('_a_b_c_def')
|
||||
).toEqual('aBCDef');
|
||||
});
|
||||
|
||||
performance('stringCamelCase', 64000, randomWords, stringCamelCase);
|
||||
});
|
||||
|
||||
@@ -3,27 +3,31 @@
|
||||
|
||||
import type { AnyString } from '../types';
|
||||
|
||||
const RE_WHITE = /[-_., ]+/g;
|
||||
const RE_WORDS = /(?:^\w|[A-Z]|\b\w)/g;
|
||||
const RE_JOIN = /\s/g;
|
||||
|
||||
// Adapted from https://stackoverflow.com/a/2970667
|
||||
//
|
||||
// this is not as optimal as the original (we split into multiple), however
|
||||
// it does pass the tests (which the original doesn't) and it is still 10+x
|
||||
// improvement over the original camelcase npm package (at running)
|
||||
// this is not as optimal as the original asnwer (we split into multiple),
|
||||
// however it does pass the tests (which the original doesn't) and it is still
|
||||
// a 10+x improvement over the original camelcase npm package (at running)
|
||||
//
|
||||
// original: 20.88 μs/op
|
||||
// this: 1.67 μs/op
|
||||
// this: 1.75 μs/op
|
||||
//
|
||||
// Caveat of this: only Ascii, but acceptable for the intended usecase
|
||||
function converter (fn: (w: string, i: number) => string): (value: AnyString) => string {
|
||||
return (value: AnyString): string =>
|
||||
value
|
||||
.toString()
|
||||
.replace(RE_WHITE, ' ')
|
||||
.replace(RE_WORDS, fn)
|
||||
.replace(RE_JOIN, '');
|
||||
.replace(/[-_., ]+/g, ' ')
|
||||
.trim()
|
||||
.split(' ')
|
||||
.map((w, i) =>
|
||||
fn(w[0], i) + (
|
||||
w.toUpperCase() === w
|
||||
? w.slice(1).toLowerCase()
|
||||
: w.slice(1)
|
||||
)
|
||||
)
|
||||
.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@polkadot/util": "8.0.2",
|
||||
"@polkadot/util": "8.0.5",
|
||||
"buffer-es6": "^4.9.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-bundle', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/x-bundle', version: '8.0.5' };
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@polkadot/x-global": "8.0.2",
|
||||
"@polkadot/x-global": "8.0.5",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"node-fetch": "^2.6.6"
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-fetch', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/x-fetch', version: '8.0.5' };
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3"
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-global', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/x-global', version: '8.0.5' };
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@polkadot/x-global": "8.0.2"
|
||||
"@polkadot/x-global": "8.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react-native": "^0.66.5"
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { base64Decode } from './base64';
|
||||
|
||||
const TESTS = [
|
||||
{
|
||||
// hello world Приветствую ми 你好
|
||||
base64: 'aGVsbG8gd29ybGQg0J/RgNC40LLQtdGC0YHRgtCy0YPRjiDQvNC4IOS9oOWlvQ==',
|
||||
expect: new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 32, 208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130, 209, 129, 209, 130, 208, 178, 209, 131, 209, 142, 32, 208, 188, 208, 184, 32, 228, 189, 160, 229, 165, 189])
|
||||
},
|
||||
{
|
||||
// ✓ à la mode
|
||||
base64: '4pyTIMOgIGxhIG1vZGU=',
|
||||
expect: new Uint8Array([226, 156, 147, 32, 195, 160, 32, 108, 97, 32, 109, 111, 100, 101])
|
||||
},
|
||||
{
|
||||
// Hello World!
|
||||
base64: 'SGVsbG8gV29ybGQh',
|
||||
expect: new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])
|
||||
},
|
||||
{
|
||||
base64: 'AA==',
|
||||
expect: new Uint8Array([0])
|
||||
},
|
||||
{
|
||||
base64: 'AAA=',
|
||||
expect: new Uint8Array([0, 0])
|
||||
},
|
||||
{
|
||||
base64: 'AAAA',
|
||||
expect: new Uint8Array([0, 0, 0])
|
||||
}
|
||||
];
|
||||
|
||||
describe('base64Decode', (): void => {
|
||||
it.each(TESTS)('%p', (test): void => {
|
||||
expect(
|
||||
base64Decode(test.base64)
|
||||
).toEqual(test.expect);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2017-2021 @polkadot/x-randomvalues authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// A tiny base64 decoder for RN usage when atob is not available.
|
||||
// The alternative would be to rely on Buffer with 'base64'
|
||||
//
|
||||
// Uint8Array.from(Buffer.from(data, 'base64'))
|
||||
//
|
||||
// We provide an own (tiny) decoder to not have Buffer deps
|
||||
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
|
||||
export function base64Decode (data: string): Uint8Array {
|
||||
const bytes = [];
|
||||
let byte = 0;
|
||||
let bits = 0;
|
||||
|
||||
for (let i = 0; i < data.length && data[i] !== '='; i++) {
|
||||
// each character represents 6 bits
|
||||
byte = (byte << 6) | chars.indexOf(data[i]);
|
||||
|
||||
// each byte needs to contain 8 bits
|
||||
if ((bits += 6) >= 8) {
|
||||
bytes.push((byte >>> (bits -= 8)) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
return Uint8Array.from(bytes);
|
||||
}
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-randomvalues', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/x-randomvalues', version: '8.0.5' };
|
||||
|
||||
@@ -9,6 +9,8 @@ import { NativeModules } from 'react-native';
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
import { base64Decode } from './base64';
|
||||
import { getRandomValues as getRandomValuesGlobal } from './browser';
|
||||
import { insecureRandomValues } from './fallback';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
@@ -19,8 +21,14 @@ interface RNExt {
|
||||
}
|
||||
}
|
||||
|
||||
interface GlobalExt extends Window {
|
||||
nativeCallSyncHook: unknown;
|
||||
}
|
||||
|
||||
function getRandomValuesNative <T extends Uint8Array> (output: T): T {
|
||||
const bytes = Buffer.from((NativeModules as RNExt).RNGetRandomValues.getRandomBase64(output.length), 'base64');
|
||||
const bytes = base64Decode(
|
||||
(NativeModules as RNExt).RNGetRandomValues.getRandomBase64(output.length)
|
||||
);
|
||||
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
output[i] = bytes[i];
|
||||
@@ -29,15 +37,10 @@ function getRandomValuesNative <T extends Uint8Array> (output: T): T {
|
||||
return output;
|
||||
}
|
||||
|
||||
function getRandomValuesGlobal <T extends Uint8Array> (output: T): T {
|
||||
return crypto.getRandomValues(output);
|
||||
}
|
||||
|
||||
export const getRandomValues = (
|
||||
typeof xglobal.crypto === 'object' && typeof xglobal.crypto.getRandomValues === 'function'
|
||||
? getRandomValuesGlobal
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any
|
||||
: (typeof (xglobal as any).nativeCallSyncHook === 'undefined' || !NativeModules.ExpoRandom)
|
||||
: (typeof (xglobal as unknown as GlobalExt).nativeCallSyncHook === 'undefined' || !NativeModules.ExpoRandom)
|
||||
? insecureRandomValues
|
||||
: getRandomValuesNative
|
||||
);
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@polkadot/x-global": "8.0.2"
|
||||
"@polkadot/x-global": "8.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-textdecoder', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/x-textdecoder', version: '8.0.5' };
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@polkadot/x-global": "8.0.2"
|
||||
"@polkadot/x-global": "8.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-textencoder', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/x-textencoder', version: '8.0.5' };
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.5",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@polkadot/x-global": "8.0.2",
|
||||
"@polkadot/x-global": "8.0.5",
|
||||
"@types/websocket": "^1.0.4",
|
||||
"websocket": "^1.0.34"
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-ws', version: '8.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/x-ws', version: '8.0.5' };
|
||||
|
||||
@@ -2028,7 +2028,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/hw-ledger-transports@8.0.2, @polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports":
|
||||
"@polkadot/hw-ledger-transports@8.0.5, @polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports"
|
||||
dependencies:
|
||||
@@ -2048,8 +2048,8 @@ __metadata:
|
||||
resolution: "@polkadot/hw-ledger@workspace:packages/hw-ledger"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@polkadot/hw-ledger-transports": 8.0.2
|
||||
"@polkadot/util": 8.0.2
|
||||
"@polkadot/hw-ledger-transports": 8.0.5
|
||||
"@polkadot/util": 8.0.5
|
||||
"@zondax/ledger-substrate": ^0.18.0
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@@ -2059,21 +2059,21 @@ __metadata:
|
||||
resolution: "@polkadot/keyring@workspace:packages/keyring"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@polkadot/util": 8.0.2
|
||||
"@polkadot/util-crypto": 8.0.2
|
||||
"@polkadot/util": 8.0.5
|
||||
"@polkadot/util-crypto": 8.0.5
|
||||
peerDependencies:
|
||||
"@polkadot/util": 8.0.2
|
||||
"@polkadot/util-crypto": 8.0.2
|
||||
"@polkadot/util": 8.0.5
|
||||
"@polkadot/util-crypto": 8.0.5
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/networks@8.0.2, @polkadot/networks@workspace:packages/networks":
|
||||
"@polkadot/networks@8.0.5, @polkadot/networks@workspace:packages/networks":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/networks@workspace:packages/networks"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@polkadot/util": 8.0.2
|
||||
"@polkadot/x-fetch": 8.0.2
|
||||
"@polkadot/util": 8.0.5
|
||||
"@polkadot/x-fetch": 8.0.5
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@@ -2086,16 +2086,16 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/util-crypto@8.0.2, @polkadot/util-crypto@workspace:packages/util-crypto":
|
||||
"@polkadot/util-crypto@8.0.5, @polkadot/util-crypto@workspace:packages/util-crypto":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/util-crypto@workspace:packages/util-crypto"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@noble/hashes": 0.4.1
|
||||
"@polkadot/networks": 8.0.2
|
||||
"@polkadot/util": 8.0.2
|
||||
"@polkadot/networks": 8.0.5
|
||||
"@polkadot/util": 8.0.5
|
||||
"@polkadot/wasm-crypto": ^4.4.1
|
||||
"@polkadot/x-randomvalues": 8.0.2
|
||||
"@polkadot/x-randomvalues": 8.0.5
|
||||
"@types/bn.js": ^4.11.6
|
||||
"@types/ed2curve": ^0.2.2
|
||||
"@types/elliptic": ^6.4.14
|
||||
@@ -2105,17 +2105,17 @@ __metadata:
|
||||
micro-base: ^0.9.0
|
||||
tweetnacl: ^1.0.3
|
||||
peerDependencies:
|
||||
"@polkadot/util": 8.0.2
|
||||
"@polkadot/util": 8.0.5
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/util@8.0.2, @polkadot/util@workspace:packages/util":
|
||||
"@polkadot/util@8.0.5, @polkadot/util@workspace:packages/util":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/util@workspace:packages/util"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@polkadot/x-textdecoder": 8.0.2
|
||||
"@polkadot/x-textencoder": 8.0.2
|
||||
"@polkadot/x-textdecoder": 8.0.5
|
||||
"@polkadot/x-textencoder": 8.0.5
|
||||
"@types/bn.js": ^4.11.6
|
||||
bn.js: ^4.12.0
|
||||
ip-regex: ^4.3.0
|
||||
@@ -2159,23 +2159,23 @@ __metadata:
|
||||
resolution: "@polkadot/x-bundle@workspace:packages/x-bundle"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@polkadot/util": 8.0.2
|
||||
"@polkadot/util": 8.0.5
|
||||
buffer-es6: ^4.9.3
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/x-fetch@8.0.2, @polkadot/x-fetch@workspace:packages/x-fetch":
|
||||
"@polkadot/x-fetch@8.0.5, @polkadot/x-fetch@workspace:packages/x-fetch":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/x-fetch@workspace:packages/x-fetch"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@polkadot/x-global": 8.0.2
|
||||
"@polkadot/x-global": 8.0.5
|
||||
"@types/node-fetch": ^2.5.12
|
||||
node-fetch: ^2.6.6
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/x-global@8.0.2, @polkadot/x-global@workspace:packages/x-global":
|
||||
"@polkadot/x-global@8.0.5, @polkadot/x-global@workspace:packages/x-global":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/x-global@workspace:packages/x-global"
|
||||
dependencies:
|
||||
@@ -2183,31 +2183,31 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/x-randomvalues@8.0.2, @polkadot/x-randomvalues@workspace:packages/x-randomvalues":
|
||||
"@polkadot/x-randomvalues@8.0.5, @polkadot/x-randomvalues@workspace:packages/x-randomvalues":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/x-randomvalues@workspace:packages/x-randomvalues"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@polkadot/x-global": 8.0.2
|
||||
"@polkadot/x-global": 8.0.5
|
||||
"@types/react-native": ^0.66.5
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/x-textdecoder@8.0.2, @polkadot/x-textdecoder@workspace:packages/x-textdecoder":
|
||||
"@polkadot/x-textdecoder@8.0.5, @polkadot/x-textdecoder@workspace:packages/x-textdecoder":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/x-textdecoder@workspace:packages/x-textdecoder"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@polkadot/x-global": 8.0.2
|
||||
"@polkadot/x-global": 8.0.5
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/x-textencoder@8.0.2, @polkadot/x-textencoder@workspace:packages/x-textencoder":
|
||||
"@polkadot/x-textencoder@8.0.5, @polkadot/x-textencoder@workspace:packages/x-textencoder":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/x-textencoder@workspace:packages/x-textencoder"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@polkadot/x-global": 8.0.2
|
||||
"@polkadot/x-global": 8.0.5
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@@ -2216,7 +2216,7 @@ __metadata:
|
||||
resolution: "@polkadot/x-ws@workspace:packages/x-ws"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.16.3
|
||||
"@polkadot/x-global": 8.0.2
|
||||
"@polkadot/x-global": 8.0.5
|
||||
"@types/websocket": ^1.0.4
|
||||
websocket: ^1.0.34
|
||||
languageName: unknown
|
||||
|
||||
Reference in New Issue
Block a user