Compare commits

...
35 Commits
Author SHA1 Message Date
Github Actions 54e6b61972 [CI Skip] release/stable 5.5.1
skip-checks: true
2021-01-31 07:57:36 +00:00
Jaco Greeff c52a7b1e64 5.5 (#862)
* 5.5

* Remove extra arg from mnemonicToLegacySeed
2021-01-31 08:51:43 +01:00
Github Actions 749cd2e381 [CI Skip] release/beta 5.4.5-1
skip-checks: true
2021-01-30 19:07:49 +00:00
Jaco Greeff 24b1790c99 Add hmac{Sha256, 512} (#861)
* Add hmac{Sha256, 512}

* Adjust

* private hmac
2021-01-30 20:02:21 +01:00
Github Actions 62823635b0 [CI Skip] release/beta 5.4.5-0
skip-checks: true
2021-01-30 17:38:17 +00:00
Jaco Greeff bc84220108 Add Ledger-compatible derivation (#860)
* Add Ledger-compatible derivation

* Export hd from root

* Renames
2021-01-30 18:33:15 +01:00
Jaco Greeff 5158951326 Give bot permissions to post issues 2021-01-26 16:36:49 +01:00
Github Actions 500b739ddd [CI Skip] release/stable 5.4.4
skip-checks: true
2021-01-24 15:44:51 +00:00
Jaco Greeff b741d228ac Use xglobal everywhere 2021-01-24 16:40:04 +01:00
Jaco Greeff 437ff8b51d Use x-gobal in node polyfills 2021-01-24 16:39:22 +01:00
Github Actions 354dd0a7a4 [CI Skip] release/stable 5.4.3
skip-checks: true
2021-01-24 15:03:21 +00:00
Jaco Greeff 3804123ca6 Remove browser.ts global reference (#856)
* Remove browser.ts global reference

* fallback text

* formatting

* Additional formatting

* global > self > window > this

* Add x-global package

* Update tests

* Correct jest mapping
2021-01-24 15:58:42 +01:00
Github Actions bbc752e475 [CI Skip] release/stable 5.4.2
skip-checks: true
2021-01-24 11:13:49 +00:00
Jaco Greeff 80f69b88b2 5.4.2 (#855) 2021-01-24 12:09:14 +01:00
Github Actions a02eab478e [CI Skip] release/stable 5.4.1
skip-checks: true
2021-01-24 07:58:18 +00:00
Jaco Greeff 22fdb9a1f9 5.4 (#854) 2021-01-24 08:53:32 +01:00
Github Actions 496d2123ed [CI Skip] release/beta 5.3.2-8
skip-checks: true
2021-01-23 08:38:47 +00:00
Jaco Greeff 15a2e6c6cf Allow formatBalance to take array defaults (#853) 2021-01-23 09:34:04 +01:00
Github Actions 62a9a7aeb5 [CI Skip] release/beta 5.3.2-7
skip-checks: true
2021-01-22 09:34:00 +00:00
Jaco Greeff 8541088893 Bump wasm (#851) 2021-01-22 10:28:34 +01:00
Github Actions e558cf8f7f [CI Skip] release/beta 5.3.2-6
skip-checks: true
2021-01-21 19:30:31 +00:00
Jaco Greeff 01827deaf5 EDCSA derive test (#850) 2021-01-21 20:24:48 +01:00
Github Actions 6d71677c17 [CI Skip] release/beta 5.3.2-5
skip-checks: true
2021-01-21 12:35:26 +00:00
Jaco Greeff ee42a717aa Bump wasm (#848) 2021-01-21 13:30:39 +01:00
Github Actions cfa8ab7ab6 [CI Skip] release/beta 5.3.2-4
skip-checks: true
2021-01-21 10:39:31 +00:00
Adam DossaandAdam Dossa 4ecd14c187 Update ledger key to polymesh (from polymath) (#847)
Co-authored-by: Adam Dossa <adamdossa@Adams-MacBook-Pro.local>
2021-01-21 11:34:17 +01:00
Github Actions d9318bc917 [CI Skip] release/beta 5.3.2-3
skip-checks: true
2021-01-20 13:17:28 +00:00
Jaco Greeff 6f6db63580 Add vrf{Sign, Verify} to kering interface (#846) 2021-01-20 14:11:50 +01:00
Github Actions ebd1e64694 [CI Skip] release/beta 5.3.2-2
skip-checks: true
2021-01-20 11:59:45 +00:00
Jaco Greeff f12aa92383 Add schnorrkelVrf{Sign, Verify} functions (#845)
* Add schnorrkelVrf{Sign, Verify} functions

* Apply suggestions from code review
2021-01-20 12:54:59 +01:00
Github Actions 2df0638b19 [CI Skip] release/beta 5.3.2-1
skip-checks: true
2021-01-19 20:36:18 +00:00
Jaco Greeff 542f484703 Move x-rxjs from @polkadot/api (#844)
* Move x-rxjs from @polkadot/api

* yarn

* x-rxjs bump

* jest config
2021-01-19 21:30:42 +01:00
Github Actions f9dbedb93a [CI Skip] release/beta 5.3.2-0
skip-checks: true
2021-01-19 20:16:43 +00:00
Jaco Greeff 2492ae5d60 Update ss58 (#843) 2021-01-19 21:11:05 +01:00
Jaco Greeff c5ab1c0e1a Update CHANGELOG.md 2021-01-17 15:57:20 +01:00
69 changed files with 1189 additions and 245 deletions
+4
View File
@@ -3,3 +3,7 @@
2.12.2
5.2.2
5.2.3
5.4.2
5.4.3
5.4.4
+1 -1
View File
@@ -19,6 +19,6 @@ jobs:
if: ${{ failure() }}
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GH_PAT_BOT }}
with:
filename: .github/ss58-check.md
+30
View File
@@ -1,11 +1,41 @@
# CHANGELOG
## 5.5.1 Jan 31, 2021
Changes:
- Added `hdLedger` to util-crypto for Ledger-compatible bip32+ed25519 derivation
- Added `hmac{Sha256, 512}` to util-crypto
- Add `slip44` indices for Ledger into `@polkadot/networks`
- Remove `module` entry in `package.json` (only rely on exports map)
- Remove direct references to `global` object, use `@polkadot/x-global`
- Update `@ledgerhq` dependencies to latest
## 5.4.1 Jan 24, 2021
Contributed:
- Adjust Ledger app lookup for Polymesh (Thanks to https://github.com/adamdossa)
Changes:
- Allow decimals as `number[]` & symbol as `string[]` in balanceFormat defaults
- Add `schnorrkelVrf{Sign, Verify}` to `@polkadot/util-crypto`
- Export `vrf{Sign, Verify}` on keyring interface
- Move `@polkadot/x-rxjs` packages from the api repo
- Align `@polkadot/networks` with Substrate master
- Explicit edcsa tests for derivation
- `@polkadot/wasm-crypto` 3.2.1
## 5.3.1 Jan 17, 2021
**Important** For users of the `@polkadot/ledger` package, it is now included in this repo (since it is a general utility) and renamed to `@polkadot/hw-ledger`
Contributed:
- Add Dock Ledger integration (Thanks to https://github.com/lovesh)
- Add Polymesh Ledger integration (Thanks to https://github.com/adamdossa)
- Add flag for Ledger capabilities on networks (Thanks to https://github.com/Tbaut)
+5 -1
View File
@@ -13,7 +13,9 @@ module.exports = Object.assign({}, config, {
'@polkadot/util-(crypto)(.*)$': '<rootDir>/packages/util-$1/src/$2',
// eslint-disable-next-line sort-keys
'@polkadot/util(.*)$': '<rootDir>/packages/util/src/$1',
'@polkadot/x-(fetch|randomvalues|textdecoder|textencoder|ws)(.*)$': '<rootDir>/packages/x-$1/src/node'
'@polkadot/x-(fetch|randomvalues|textdecoder|textencoder|ws)(.*)$': '<rootDir>/packages/x-$1/src/node',
'@polkadot/x-global(.*)$': '<rootDir>/packages/x-global/src/$1',
'@polkadot/x-rxjs(.*)$': '<rootDir>/packages/x-rxjs/src/$1'
},
modulePathIgnorePatterns: [
'<rootDir>/packages/hw-ledger/build',
@@ -23,7 +25,9 @@ module.exports = Object.assign({}, config, {
'<rootDir>/packages/util/build',
'<rootDir>/packages/util-crypto/build',
'<rootDir>/packages/x-fetch/build',
'<rootDir>/packages/x-global/build',
'<rootDir>/packages/x-randomvalues/build',
'<rootDir>/packages/x-rxjs/build',
'<rootDir>/packages/x-textdecoder/build',
'<rootDir>/packages/x-textencoder/build',
'<rootDir>/packages/x-ws/build'
+1 -1
View File
@@ -25,5 +25,5 @@
"@polkadot/ts": "^0.3.59",
"@types/jest": "^26.0.20"
},
"version": "5.3.1"
"version": "5.5.1"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/hw-ledger-transports",
"version": "5.3.1",
"version": "5.5.1",
"repository": "github:polkadot-js/common",
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
@@ -12,13 +12,13 @@
"sideEffects": false,
"dependencies": {
"@babel/runtime": "^7.12.5",
"@ledgerhq/hw-transport-webusb": "^5.39.0"
"@ledgerhq/hw-transport-webusb": "^5.41.0"
},
"devDependencies": {
"@types/ledgerhq__hw-transport-node-hid": "^4.22.2",
"@types/ledgerhq__hw-transport-webusb": "^4.70.1"
},
"optionalDependencies": {
"@ledgerhq/hw-transport-node-hid-singleton": "^5.39.0"
"@ledgerhq/hw-transport-node-hid-singleton": "^5.41.0"
}
}
+3 -4
View File
@@ -1,18 +1,17 @@
{
"name": "@polkadot/hw-ledger",
"version": "5.3.1",
"version": "5.5.1",
"repository": "github:polkadot-js/common",
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"main": "index.js",
"module": "index.mjs",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/hw-ledger-transports": "5.3.1",
"@polkadot/util": "^5.3.1",
"@polkadot/hw-ledger-transports": "5.5.1",
"@polkadot/util": "^5.5.1",
"@zondax/ledger-polkadot": "^0.13.0"
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ const APPS: Record<string, (transport: Transport) => SubstrateApp> = {
dock: newDockApp,
kusama: newKusamaApp,
polkadot: newPolkadotApp,
polymath: newPolymeshApp
polymesh: newPolymeshApp
};
type Chain = keyof typeof APPS;
+5 -6
View File
@@ -1,13 +1,12 @@
{
"name": "@polkadot/keyring",
"version": "5.3.1",
"version": "5.5.1",
"description": "Keyring management",
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"main": "index.js",
"module": "index.mjs",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
@@ -17,11 +16,11 @@
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/util": "5.3.1",
"@polkadot/util-crypto": "5.3.1"
"@polkadot/util": "5.5.1",
"@polkadot/util-crypto": "5.5.1"
},
"peerDependencies": {
"@polkadot/util": "5.3.1",
"@polkadot/util-crypto": "5.3.1"
"@polkadot/util": "5.5.1",
"@polkadot/util-crypto": "5.5.1"
}
}
+11
View File
@@ -56,6 +56,17 @@ describe('pair', (): void => {
).toEqual(false);
});
it('allows vrf sign and verify', (): void => {
const message = new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]);
expect(
keyring.alice.vrfVerify(
message,
keyring.alice.vrfSign(message)
)
).toBe(true);
});
it('allows setting/getting of meta', (): void => {
keyring.bob.setMeta({ foo: 'bar', something: 'else' });
+24 -3
View File
@@ -5,8 +5,8 @@ import type { Keypair, KeypairType } from '@polkadot/util-crypto/types';
import type { KeyringPair, KeyringPair$Json, KeyringPair$JsonEncodingTypes, KeyringPair$Meta, SignOptions } from '../types';
import type { PairInfo } from './types';
import { assert, u8aConcat, u8aToHex } from '@polkadot/util';
import { blake2AsU8a, ethereumEncode, keccakAsU8a, keyExtractPath, keyFromPath, naclKeypairFromSeed as naclFromSeed, naclSign, schnorrkelKeypairFromSeed as schnorrkelFromSeed, schnorrkelSign, secp256k1Compress, secp256k1Expand, secp256k1KeypairFromSeed as secp256k1FromSeed, secp256k1Sign, signatureVerify } from '@polkadot/util-crypto';
import { assert, u8aConcat, u8aEq, u8aToHex } from '@polkadot/util';
import { blake2AsU8a, ethereumEncode, keccakAsU8a, keyExtractPath, keyFromPath, naclKeypairFromSeed as naclFromSeed, naclSign, schnorrkelKeypairFromSeed as schnorrkelFromSeed, schnorrkelSign, schnorrkelVrfSign, schnorrkelVrfVerify, secp256k1Compress, secp256k1Expand, secp256k1KeypairFromSeed as secp256k1FromSeed, secp256k1Sign, signatureVerify } from '@polkadot/util-crypto';
import { decodePair } from './decode';
import { encodePair } from './encode';
@@ -178,6 +178,27 @@ export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: P
return pairToJson(type, { address, meta }, recode(passphrase), !!passphrase);
},
verify: (message: Uint8Array, signature: Uint8Array): boolean =>
signatureVerify(message, signature, TYPE_ADDRESS[type](publicKey)).isValid
signatureVerify(message, signature, TYPE_ADDRESS[type](publicKey)).isValid,
vrfSign: (message: Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array => {
assert(!isLocked(secretKey), 'Cannot sign with a locked key pair');
if (type === 'sr25519') {
return schnorrkelVrfSign(message, { secretKey }, context, extra);
}
const proof = TYPE_SIGNATURE[type](message, { publicKey, secretKey });
return u8aConcat(
blake2AsU8a(u8aConcat(context || '', extra || '', proof)),
proof
);
},
vrfVerify: (message: Uint8Array, vrfResult: Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): boolean =>
type === 'sr25519'
? schnorrkelVrfVerify(message, vrfResult, publicKey, context, extra)
: (
signatureVerify(message, vrfResult.subarray(32), TYPE_ADDRESS[type](publicKey)).isValid &&
u8aEq(vrfResult.subarray(0, 32), blake2AsU8a(u8aConcat(context || '', extra || '', vrfResult.subarray(32))))
)
};
}
+6
View File
@@ -53,6 +53,12 @@ export function nobody (): KeyringPair {
type: 'ed25519',
// eslint-disable-next-line @typescript-eslint/no-unused-vars
verify: (message: Uint8Array, signature: Uint8Array): boolean =>
false,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
vrfSign: (message: Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array =>
new Uint8Array(96),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
vrfVerify: (message: Uint8Array, vrfResult: Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): boolean =>
false
};
+65 -52
View File
@@ -10,53 +10,62 @@ import Keyring from '.';
const PHRASE = 'bottom drive obey lake curtain smoke basket hold race lonely fit walk';
const TESTS = [
{
pk: '0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a',
ss: '5DfhGyQdFobKM8NsWvEeAKk5EQQgYe9AydgJ7rMB6E1EqRzV',
uri: PHRASE
},
{
pk: '0xb69355deefa7a8f33e9297f5af22e680f03597a99d4f4b1c44be47e7a2275802',
ss: '5GC6LfpV352HtJPySfAecb5JdePtf4R9Vq49NUU8RhzgBqgq',
uri: `${PHRASE}///password`
},
{
pk: '0x40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a',
ss: '5DXZzrDxHbkQov4QBAY4TjpwnHCMrKXkomTnKSw8UArBEY5v',
uri: `${PHRASE}/foo`
},
{
pk: '0x547d4a55642ec7ebadc0bd29b6e570b8c926059b3c0655d4948075e9a7e6f31e',
ss: '5DyV6fZuvPemWrUqBgWwTSgoV86w6xms3KhkFU6cQcWxU8eP',
uri: `${PHRASE}//foo`
},
{
pk: '0x3841947ffcde6f5fef26fb68b59bb8665637e30e32ec2051f99cf6b9c674fe09',
ss: '5DLU27is5iViNopQb2KxsTyPx6j4vCu8X3sk3j3NNLkPCqKM',
uri: `${PHRASE}//foo/bar`
},
{
pk: '0xdc142f7476a7b0aa262aeccf207f1d18daa90762db393006741e8a31f39dbc53',
ss: '5H3GPTqDSpjkfDwbHy12PD6BWm8jvGSX4xYC8UMprHpTPcRg',
uri: `${PHRASE}/foo//bar`
},
{
pk: '0xa2e56b06407a6d1e819d2fc33fa0ec604b29c2e868b70b3696bb049b8725934b',
ss: '5FkHmNgbg64MwStgCyDi2Uw3ufFu11mqQgmWT9uwK4Lghvpv',
uri: `${PHRASE}//foo/bar//42/69`
},
{
pk: '0x0e0d24e3e1ff2c07f269c99e2e0df8681fda1851ac42fc846ca2daaa90cd8f14',
ss: '5CP8S23JBNXYNpJsL7ESPJBNnUZE6itcfM4EnDxEhaVEU6dT',
uri: `${PHRASE}//foo/bar//42/69///password`
},
{
pk: '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d',
ss: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
uri: `${PHRASE}//Alice`
}
];
const TESTS = {
ecdsa: [
{
pk: '0x020a1091341fe5664bfa1782d5e04779689068c916b04cb365ec3153755684d9a1',
ss: '5C7C2Z5sWbytvHpuLTvzKunnnRwQxft1jiqrLD5rhucQ5S9X',
uri: `${PHRASE}//Alice`
}
],
sr25519: [
{
pk: '0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a',
ss: '5DfhGyQdFobKM8NsWvEeAKk5EQQgYe9AydgJ7rMB6E1EqRzV',
uri: PHRASE
},
{
pk: '0xb69355deefa7a8f33e9297f5af22e680f03597a99d4f4b1c44be47e7a2275802',
ss: '5GC6LfpV352HtJPySfAecb5JdePtf4R9Vq49NUU8RhzgBqgq',
uri: `${PHRASE}///password`
},
{
pk: '0x40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a',
ss: '5DXZzrDxHbkQov4QBAY4TjpwnHCMrKXkomTnKSw8UArBEY5v',
uri: `${PHRASE}/foo`
},
{
pk: '0x547d4a55642ec7ebadc0bd29b6e570b8c926059b3c0655d4948075e9a7e6f31e',
ss: '5DyV6fZuvPemWrUqBgWwTSgoV86w6xms3KhkFU6cQcWxU8eP',
uri: `${PHRASE}//foo`
},
{
pk: '0x3841947ffcde6f5fef26fb68b59bb8665637e30e32ec2051f99cf6b9c674fe09',
ss: '5DLU27is5iViNopQb2KxsTyPx6j4vCu8X3sk3j3NNLkPCqKM',
uri: `${PHRASE}//foo/bar`
},
{
pk: '0xdc142f7476a7b0aa262aeccf207f1d18daa90762db393006741e8a31f39dbc53',
ss: '5H3GPTqDSpjkfDwbHy12PD6BWm8jvGSX4xYC8UMprHpTPcRg',
uri: `${PHRASE}/foo//bar`
},
{
pk: '0xa2e56b06407a6d1e819d2fc33fa0ec604b29c2e868b70b3696bb049b8725934b',
ss: '5FkHmNgbg64MwStgCyDi2Uw3ufFu11mqQgmWT9uwK4Lghvpv',
uri: `${PHRASE}//foo/bar//42/69`
},
{
pk: '0x0e0d24e3e1ff2c07f269c99e2e0df8681fda1851ac42fc846ca2daaa90cd8f14',
ss: '5CP8S23JBNXYNpJsL7ESPJBNnUZE6itcfM4EnDxEhaVEU6dT',
uri: `${PHRASE}//foo/bar//42/69///password`
},
{
pk: '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d',
ss: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
uri: `${PHRASE}//Alice`
}
]
};
describe('keyring.addFromUri', (): void => {
const keyring = new Keyring({ type: 'sr25519' });
@@ -65,12 +74,16 @@ describe('keyring.addFromUri', (): void => {
await cryptoWaitReady();
});
TESTS.forEach(({ pk, ss, uri }): void => {
it(`creates ${uri}`, (): void => {
const pair = keyring.addFromUri(uri);
Object.entries(TESTS).forEach(([type, tests]): void => {
describe(type, (): void => {
tests.forEach(({ pk, ss, uri }): void => {
it(`creates ${uri}`, (): void => {
const pair = keyring.addFromUri(uri, {}, type as 'sr25519');
expect(u8aToHex(pair.publicKey)).toEqual(pk);
expect(pair.address).toEqual(ss);
expect(u8aToHex(pair.publicKey)).toEqual(pk);
expect(pair.address).toEqual(ss);
});
});
});
});
});
+2
View File
@@ -48,6 +48,8 @@ export interface KeyringPair {
sign (message: Uint8Array, options?: SignOptions): Uint8Array;
toJson (passphrase?: string): KeyringPair$Json;
verify (message: Uint8Array, signature: Uint8Array): boolean;
vrfSign (message: Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array;
vrfVerify (message: Uint8Array, vrfResult: Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): boolean;
}
export interface KeyringPairs {
+3 -4
View File
@@ -1,9 +1,8 @@
{
"name": "@polkadot/networks",
"version": "5.3.1",
"version": "5.5.1",
"description": "A list of all available Substrate networks and their applicable prefixes",
"main": "index.js",
"module": "index.mjs",
"sideEffects": false,
"repository": "github:polkadot-js/common",
"author": "Jaco Greeff <jacogr@gmail.com>",
@@ -16,7 +15,7 @@
"@babel/runtime": "^7.12.5"
},
"devDependencies": {
"@polkadot/util": "5.3.1",
"@polkadot/x-fetch": "5.3.1"
"@polkadot/util": "5.5.1",
"@polkadot/x-fetch": "5.5.1"
}
}
+22 -9
View File
@@ -36,6 +36,7 @@ const all: NetworkFromSubstrate[] = [
icon: 'polkadot',
network: 'polkadot',
prefix: 0,
slip44: 0x00000162,
standardAccount: '*25519',
symbols: ['DOT'],
website: 'https://polkadot.network'
@@ -53,6 +54,7 @@ const all: NetworkFromSubstrate[] = [
icon: 'polkadot',
network: 'kusama',
prefix: 2,
slip44: 0x000001b2,
standardAccount: '*25519',
symbols: ['KSM'],
website: 'https://kusama.network'
@@ -133,15 +135,16 @@ const all: NetworkFromSubstrate[] = [
website: 'http://laminar.network/'
},
{
decimals: null,
displayName: 'Polymath',
decimals: [6],
displayName: 'Polymesh',
genesisHash: ['0x12fddc9e2128b3fe571e4e5427addcb87fcaf08493867a68dd6ae44b406b39c7'],
hasLedgerSupport: true,
network: 'polymath',
network: 'polymesh',
prefix: 12,
slip44: 0x00000253,
standardAccount: '*25519',
symbols: null,
website: null
symbols: ['POLYX'],
website: 'https://polymath.network/'
},
{
decimals: null,
@@ -234,6 +237,7 @@ const all: NetworkFromSubstrate[] = [
hasLedgerSupport: true,
network: 'dock-mainnet',
prefix: 22,
slip44: 0x00000252,
standardAccount: '*25519',
symbols: ['DCK'],
website: 'https://dock.io'
@@ -314,13 +318,22 @@ const all: NetworkFromSubstrate[] = [
website: 'https://phala.network'
},
{
decimals: null,
displayName: 'Robonomics Network',
decimals: [12],
displayName: 'Litentry Network',
network: 'litentry',
prefix: 31,
standardAccount: '*25519',
symbols: ['LIT'],
website: 'https://litentry.com/'
},
{
decimals: [9],
displayName: 'Robonomics',
network: 'robonomics',
prefix: 32,
standardAccount: '*25519',
symbols: null,
website: null
symbols: ['XRT'],
website: 'https://robonomics.network'
},
{
decimals: null,
+1
View File
@@ -12,6 +12,7 @@ export interface NetworkFromSubstrate {
hasLedgerSupport?: boolean;
icon?: Icon | null;
isIgnored?: boolean;
slip44?: number;
standardAccount: '*25519' | null;
symbols: string[] | null;
website: string | null;
+6 -7
View File
@@ -1,9 +1,8 @@
{
"name": "@polkadot/util-crypto",
"version": "5.3.1",
"version": "5.5.1",
"description": "A collection of useful crypto utilities for @polkadot",
"main": "index.js",
"module": "index.mjs",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
@@ -17,10 +16,10 @@
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/networks": "5.3.1",
"@polkadot/util": "5.3.1",
"@polkadot/wasm-crypto": "^3.1.1",
"@polkadot/x-randomvalues": "5.3.1",
"@polkadot/networks": "5.5.1",
"@polkadot/util": "5.5.1",
"@polkadot/wasm-crypto": "^3.2.2",
"@polkadot/x-randomvalues": "5.5.1",
"base-x": "^3.0.8",
"blakejs": "^1.1.0",
"bn.js": "^4.11.9",
@@ -40,6 +39,6 @@
"@types/xxhashjs": "^0.2.2"
},
"peerDependencies": {
"@polkadot/util": "5.3.1"
"@polkadot/util": "5.5.1"
}
}
+4
View File
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { hdLedger } from './ledger';
@@ -0,0 +1,34 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import BN from 'bn.js';
import { bnToU8a, u8aConcat } from '@polkadot/util';
import { hmacSha512 } from '../../hmac';
// performs hard-only derivation on the xprv
export function ledgerDerivePrivate (xprv: Uint8Array, index: number): Uint8Array {
const kl = xprv.slice(0, 32);
const kr = xprv.slice(32, 64);
const cc = xprv.slice(64, 96);
const data = new Uint8Array(1 + 64 + 4);
data.set(bnToU8a(index, { bitLength: 32, isLe: true }), 1 + 64);
data.set(kl, 1);
data.set(kr, 1 + 32);
data[0] = 0x00;
const z = hmacSha512(cc, data);
data[0] = 0x01;
const chainCode = hmacSha512(cc, data).slice(32, 64);
const zl = z.slice(0, 32);
const zr = z.slice(32, 64);
const left = bnToU8a(new BN(kl, 16, 'le').add(new BN(zl.slice(0, 28), 16, 'le').mul(new BN(8))), { bitLength: 512, isLe: true }).slice(0, 32);
const right = bnToU8a(new BN(kr, 16, 'le').add(new BN(zr, 16, 'le')), { bitLength: 512, isLe: true }).slice(0, 32);
return u8aConcat(left, right, chainCode);
}
@@ -0,0 +1,24 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { u8aToHex } from '@polkadot/util';
import { hdLedger } from '..';
describe('ledgerDerive', (): void => {
it('derives a known private key for Kusama', (): void => {
expect(u8aToHex(
hdLedger('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about', `m/44'/${0x01b2}'/0'/0'/0'`)
.secretKey
.slice(0, 32)
)).toEqual('0x98cb4e14e0e08ea876f88d728545ea7572dc07dbbe69f1731c418fb827e69d41');
});
it('derives a known private key for Polkadot', (): void => {
expect(u8aToHex(
hdLedger('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about', `m/44'/${0x80000162}/0'/0'/0'`)
.secretKey
.slice(0, 32)
)).toEqual('0xe8c68348586d53e4e8d1a864b0e4e17c75e4eb06e0c63c1432bef2ba29e69d41');
});
});
@@ -0,0 +1,29 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Keypair } from '../../types';
import { assert } from '@polkadot/util';
import { mnemonicValidate } from '../../mnemonic';
import { naclKeypairFromSeed } from '../../nacl';
import { ledgerDerivePrivate } from './derivePrivate';
import { ledgerMaster } from './master';
import { ledgerValidatePath } from './validatePath';
const HARDENED = 0x80000000;
export function hdLedger (mnemonic: string, path: string): Keypair {
assert(mnemonicValidate(mnemonic), 'Invalid mnemonic passed to ledger derivation');
assert(ledgerValidatePath(path), 'Invalid derivation path');
return naclKeypairFromSeed(
path
.split('/')
.slice(1)
.map((n) => parseInt(n.replace("'", ''), 10))
.map((n) => (n < HARDENED) ? (n + HARDENED) : n)
.reduce((x, n) => ledgerDerivePrivate(x, n), ledgerMaster(mnemonic))
.slice(0, 32)
);
}
@@ -0,0 +1,17 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { u8aToHex } from '@polkadot/util';
import { ledgerMaster } from './master';
const MNEMONIC = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
const XPRV = '0x402b03cd9c8bed9ba9f9bd6cd9c315ce9fcc59c7c25d37c85a36096617e69d418e35cb4a3b737afd007f0688618f21a8831643c0e6c77fc33c06026d2a0fc93832596435e70647d7d98ef102a32ea40319ca8fb6c851d7346d3bd8f9d1492658';
describe('ledgerDerive', (): void => {
it('derives a known master xprv', (): void => {
expect(u8aToHex(
ledgerMaster(MNEMONIC)
)).toEqual(XPRV);
});
});
@@ -0,0 +1,31 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { u8aConcat } from '@polkadot/util';
import { hmacSha256, hmacSha512 } from '../../hmac';
import { mnemonicToSeedSync } from '../../mnemonic/bip39';
const ED25519_CRYPTO = 'ed25519 seed';
// gets an xprv from a mnemonic
export function ledgerMaster (mnemonic: string): Uint8Array {
const seed = mnemonicToSeedSync(mnemonic);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const chainCode = hmacSha256(ED25519_CRYPTO, new Uint8Array([1, ...seed]));
let priv;
while (!priv || (priv[31] & 0b0010_0000)) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
priv = hmacSha512(ED25519_CRYPTO, priv || seed);
}
priv[0] &= 0b1111_1000;
priv[31] &= 0b0111_1111;
priv[31] |= 0b0100_0000;
return u8aConcat(priv, chainCode);
}
@@ -0,0 +1,14 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
export function ledgerValidatePath (path: string): boolean {
if (!path.startsWith('m/')) {
return false;
}
return !path
.split('/')
.slice(1)
.map((n) => parseInt(n.replace("'", ''), 10))
.some((n) => isNaN(n));
}
+5
View File
@@ -0,0 +1,5 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { hmacSha256 } from './sha256';
export { hmacSha512 } from './sha512';
+14
View File
@@ -0,0 +1,14 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import hash from 'hash.js';
export function hmacSha256 (key: Uint8Array | string, data: Uint8Array): Uint8Array {
return Uint8Array.from(
hash
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.hmac(hash.sha256, key)
.update(data)
.digest());
}
+14
View File
@@ -0,0 +1,14 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import hash from 'hash.js';
export function hmacSha512 (key: Uint8Array | string, data: Uint8Array): Uint8Array {
return Uint8Array.from(
hash
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.hmac(hash.sha512, key)
.update(data)
.digest());
}
+2
View File
@@ -12,6 +12,8 @@ export * from './base64';
export * from './blake2';
export * from './crypto';
export * from './ethereum';
export * from './hd';
export * from './hmac';
export * from './keccak';
export * from './key';
export * from './mnemonic';
+4 -8
View File
@@ -3,10 +3,10 @@
// Adapted from https://gist.github.com/calvinmetcalf/91e8e84dc63c75f2aa53
import hash from 'hash.js';
import { u8aConcat } from '@polkadot/util';
import { hmacSha512 } from '../hmac';
export function pbkdf2Sync (password: Uint8Array, salt: Uint8Array, rounds: number, len = 64): Uint8Array {
let out = new Uint8Array();
let num = 0;
@@ -16,16 +16,12 @@ export function pbkdf2Sync (password: Uint8Array, salt: Uint8Array, rounds: numb
num++;
block.writeUInt32BE(num, salt.length);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
let prev = hash.hmac(hash.sha512, password).update(block).digest();
let prev = hmacSha512(password, block);
const md = prev;
let i = 0;
while (++i < rounds) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
prev = hash.hmac(hash.sha512, password).update(prev).digest();
prev = hmacSha512(password, prev);
let j = -1;
@@ -7,3 +7,5 @@ export { schnorrkelDeriveSoft } from './deriveSoft';
export { schnorrkelKeypairFromSeed } from './keypair/fromSeed';
export { schnorrkelSign } from './sign';
export { schnorrkelVerify } from './verify';
export { schnorrkelVrfSign } from './vrfSign';
export { schnorrkelVrfVerify } from './vrfVerify';
+1 -3
View File
@@ -14,7 +14,5 @@ export function schnorrkelSign (message: Uint8Array | string, { publicKey, secre
assert(publicKey?.length === 32, 'Expected a valid publicKey, 32-bytes');
assert(secretKey?.length === 64, 'Expected a valid secretKey, 64-bytes');
const messageU8a = u8aToU8a(message);
return sr25519Sign(publicKey, secretKey, messageU8a);
return sr25519Sign(publicKey, secretKey, u8aToU8a(message));
}
@@ -9,12 +9,11 @@ import { sr25519Verify } from '@polkadot/wasm-crypto';
* @description Verifies the signature of `message`, using the supplied pair
*/
export function schnorrkelVerify (message: Uint8Array | string, signature: Uint8Array | string, publicKey: Uint8Array | string): boolean {
const messageU8a = u8aToU8a(message);
const publicKeyU8a = u8aToU8a(publicKey);
const signatureU8a = u8aToU8a(signature);
assert(publicKeyU8a.length === 32, `Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
assert(signatureU8a.length === 64, `Invalid signature, received ${signatureU8a.length} bytes, expected 64`);
return sr25519Verify(signatureU8a, messageU8a, publicKeyU8a);
return sr25519Verify(signatureU8a, u8aToU8a(message), publicKeyU8a);
}
@@ -0,0 +1,19 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Keypair } from '../types';
import { assert, u8aToU8a } from '@polkadot/util';
import { vrfSign } from '@polkadot/wasm-crypto';
const EMPTY_U8A = new Uint8Array();
/**
* @name schnorrkelVrfSign
* @description Sign with sr25519 vrf signing (deterministic)
*/
export function schnorrkelVrfSign (message: Uint8Array | string, { secretKey }: Partial<Keypair>, context: string | Uint8Array = EMPTY_U8A, extra: string | Uint8Array = EMPTY_U8A): Uint8Array {
assert(secretKey?.length === 64, 'Invalid secretKey, expected 64-bytes');
return vrfSign(secretKey, u8aToU8a(context), u8aToU8a(message), u8aToU8a(extra));
}
@@ -0,0 +1,76 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { stringToU8a, u8aEq } from '@polkadot/util';
import { waitReady } from '@polkadot/wasm-crypto';
import { randomAsU8a } from '../random/asU8a';
import { schnorrkelKeypairFromSeed } from './keypair/fromSeed';
import { schnorrkelVrfSign } from './vrfSign';
import { schnorrkelVrfVerify } from './vrfVerify';
const MESSAGE = stringToU8a('this is a message');
describe('vrf sign and verify', (): void => {
beforeEach(async (): Promise<void> => {
await waitReady();
});
it('has 96-byte proofs', (): void => {
const pair = schnorrkelKeypairFromSeed(randomAsU8a());
expect(schnorrkelVrfSign(MESSAGE, pair)).toHaveLength(96);
});
it('signing is deterministic', (): void => {
const pair = schnorrkelKeypairFromSeed(randomAsU8a());
const proof1 = schnorrkelVrfSign(MESSAGE, pair);
const proof2 = schnorrkelVrfSign(MESSAGE, pair);
expect(u8aEq(proof1.subarray(0, 32), proof2.subarray(0, 32))).toBe(true);
});
it('can sign and verify a message', (): void => {
const pair = schnorrkelKeypairFromSeed(randomAsU8a());
const proof = schnorrkelVrfSign(MESSAGE, pair);
expect(schnorrkelVrfVerify(MESSAGE, proof, pair.publicKey)).toBe(true);
});
it('can sign and verify a message (with context)', (): void => {
const context = 'my context';
const pair = schnorrkelKeypairFromSeed(randomAsU8a());
const proof = schnorrkelVrfSign(MESSAGE, pair, context);
expect(schnorrkelVrfVerify(MESSAGE, proof, pair.publicKey, context)).toBe(true);
});
it('can sign and verify a message (with context & extra)', (): void => {
const context = 'my context';
const extra = 'some extra transcript data';
const pair = schnorrkelKeypairFromSeed(randomAsU8a());
const proof = schnorrkelVrfSign(MESSAGE, pair, context, extra);
expect(schnorrkelVrfVerify(MESSAGE, proof, pair.publicKey, context, extra)).toBe(true);
});
it('throws error when publicKey lengths do not match', (): void => {
expect(
() => schnorrkelVrfVerify(
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
new Uint8Array(96),
new Uint8Array(31)
)
).toThrow(/Invalid publicKey/);
});
it('throws error when proof lengths do not match', (): void => {
expect(
() => schnorrkelVrfVerify(
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
new Uint8Array(99),
new Uint8Array(32)
)
).toThrow(/Invalid vrfSign/);
});
});
@@ -0,0 +1,21 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { assert, u8aToU8a } from '@polkadot/util';
import { vrfVerify } from '@polkadot/wasm-crypto';
const EMPTY_U8A = new Uint8Array();
/**
* @name schnorrkelVrfVerify
* @description Verify with sr25519 vrf verification
*/
export function schnorrkelVrfVerify (message: Uint8Array | string, signOutput: string | Uint8Array, publicKey: Uint8Array | string, context: string | Uint8Array = EMPTY_U8A, extra: string | Uint8Array = EMPTY_U8A): boolean {
const publicKeyU8a = u8aToU8a(publicKey);
const proofU8a = u8aToU8a(signOutput);
assert(publicKeyU8a.length === 32, 'Invalid publicKey, expected 32-bytes');
assert(proofU8a.length === 96, 'Invalid vrfSign output, expected 96 bytes');
return vrfVerify(publicKeyU8a, u8aToU8a(context), u8aToU8a(message), u8aToU8a(extra), proofU8a);
}
+4 -5
View File
@@ -1,9 +1,8 @@
{
"name": "@polkadot/util",
"version": "5.3.1",
"version": "5.5.1",
"description": "A collection of useful utilities for @polkadot",
"main": "index.js",
"module": "index.mjs",
"sideEffects": false,
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
@@ -14,11 +13,11 @@
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/x-textdecoder": "5.3.1",
"@polkadot/x-textencoder": "5.3.1",
"@polkadot/x-textdecoder": "5.5.1",
"@polkadot/x-textencoder": "5.5.1",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9",
"camelcase": "^5.3.1",
"ip-regex": "^4.2.0"
"ip-regex": "^4.3.0"
}
}
+4 -5
View File
@@ -1,6 +1,8 @@
// Copyright 2017-2021 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { xglobal } from '@polkadot/x-global';
import { isFunction } from './is/function';
import { isString } from './is/string';
import { assert } from './assert';
@@ -22,8 +24,7 @@ interface PjsChecks extends This {
__polkadotjs: Record<string, VersionPath[]>;
}
type PjsGlobal = NodeJS.Global & PjsChecks;
type PjsWindow = Window & PjsChecks;
type PjsWindow = (Window & This) & PjsChecks;
type FnString = () => string | undefined;
/** @internal */
@@ -33,9 +34,7 @@ function expandPath (path?: string): string {
/** @internal */
function getEntry (name: string): VersionPath[] {
const _global = typeof window !== 'undefined'
? window as PjsWindow
: global as PjsGlobal;
const _global = xglobal as PjsWindow;
if (!_global.__polkadotjs) {
_global.__polkadotjs = {};
@@ -237,4 +237,12 @@ describe('formatBalance', (): void => {
{ power: 24, text: 'Yotta', value: 'Y' }
]);
});
it('can set defaults from array values', (): void => {
formatBalance.setDefaults({ decimals: [12, 24], unit: ['Multi', 'Unit'] });
expect(
formatBalance(TESTVAL)
).toEqual('123.4567 mMulti');
});
});
+17 -4
View File
@@ -15,6 +15,11 @@ interface Defaults {
unit: string;
}
interface SetDefaults {
decimals?: number[] | number;
unit?: string[] | string;
}
interface Options {
decimals?: number;
forceUnit?: string;
@@ -29,7 +34,7 @@ interface BalanceFormatter {
findSi (type: string): SiDef;
getDefaults (): Defaults;
getOptions (decimals?: number): SiDef[];
setDefaults (defaults: Partial<Defaults>): void;
setDefaults (defaults: SetDefaults): void;
}
const DEFAULT_DECIMALS = 0;
@@ -107,9 +112,17 @@ formatBalance.getOptions = (decimals: number = defaultDecimals): SiDef[] => {
// Sets the default decimals to use for formatting (ui-wide)
// eslint-disable-next-line @typescript-eslint/unbound-method
formatBalance.setDefaults = ({ decimals, unit }: Partial<Defaults>): void => {
defaultDecimals = isUndefined(decimals) ? defaultDecimals : decimals;
defaultUnit = isUndefined(unit) ? defaultUnit : unit;
formatBalance.setDefaults = ({ decimals, unit }: SetDefaults): void => {
defaultDecimals = isUndefined(decimals)
? defaultDecimals
: Array.isArray(decimals)
? decimals[0]
: decimals;
defaultUnit = isUndefined(unit)
? defaultUnit
: Array.isArray(unit)
? unit[0]
: unit;
SI[SI_MID].text = defaultUnit;
};
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-fetch",
"version": "5.3.1",
"version": "5.5.1",
"description": "A cross-environment fetch replacement",
"browser": "browser.js",
"main": "node.js",
@@ -15,6 +15,7 @@
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-fetch#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/x-global": "5.5.1",
"@types/node-fetch": "^2.5.8",
"node-fetch": "^2.6.1"
}
+3 -1
View File
@@ -1,4 +1,6 @@
// Copyright 2017-2021 @polkadot/x-fetch authors & contributors
// SPDX-License-Identifier: Apache-2.0
export const fetch = global.fetch;
import { xglobal } from '@polkadot/x-global';
export const fetch = xglobal.fetch;
+4 -2
View File
@@ -3,6 +3,8 @@
import nodeFetch from 'node-fetch';
export const fetch = typeof global.fetch === 'undefined'
import { xglobal } from '@polkadot/x-global';
export const fetch = typeof xglobal.fetch === 'undefined'
? nodeFetch as unknown as typeof global.fetch
: global.fetch;
: xglobal.fetch;
+11
View File
@@ -0,0 +1,11 @@
# @polkadot/x-global
A cross-environment global object. checks for global > self > window > this.
Install it via `yarn add @polkadot/x-fetch`
```js
import { xglobal } from '@polkadot/x-global';
console.log(typeof xglobal.TextEncoder);
```
+19
View File
@@ -0,0 +1,19 @@
{
"name": "@polkadot/x-global",
"version": "5.5.1",
"description": "A cross-environment global replacement",
"main": "index.js",
"sideEffects": false,
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"repository": "github:polkadot-js/common",
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-global#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@types/node-fetch": "^2.5.8",
"node-fetch": "^2.6.1"
}
}
+10
View File
@@ -0,0 +1,10 @@
// Copyright 2017-2021 @polkadot/x-fetch authors & contributors
// SPDX-License-Identifier: Apache-2.0
export const xglobal = typeof global !== 'undefined'
? global
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: this as unknown as (Window & typeof globalThis);
+4 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-randomvalues",
"version": "5.3.1",
"version": "5.5.1",
"description": "A cross-environment window.crypto.getRandomValues replacement",
"browser": "browser.js",
"main": "node.js",
@@ -14,9 +14,10 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-randomvalues#readme",
"dependencies": {
"@babel/runtime": "^7.12.5"
"@babel/runtime": "^7.12.5",
"@polkadot/x-global": "5.5.1"
},
"devDependencies": {
"@types/react-native": "^0.63.45"
"@types/react-native": "^0.63.46"
}
}
+1 -1
View File
@@ -9,7 +9,7 @@ let warned = false;
export function insecureRandomValues <T extends Uint8Array> (arr: T): T {
if (!warned) {
console.warn('Using an insecure random number generator, this should only happen when running in a debugger without support for crypto.getRandomValues');
console.warn('Using an insecure random number generator, this should only happen when running in a debugger without support for crypto');
warned = true;
}
+4 -2
View File
@@ -7,6 +7,8 @@
import { NativeModules } from 'react-native';
import { xglobal } from '@polkadot/x-global';
import { insecureRandomValues } from './fallback';
interface RNExt {
@@ -29,9 +31,9 @@ function getRandomValuesGlobal <T extends Uint8Array> (arr: T): T {
return crypto.getRandomValues(arr);
}
export const getRandomValues = typeof global.crypto === 'object' && typeof global.crypto.getRandomValues === 'function'
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 (global as any).nativeCallSyncHook === 'undefined' || !NativeModules.ExpoRandom)
: (typeof (xglobal as any).nativeCallSyncHook === 'undefined' || !NativeModules.ExpoRandom)
? insecureRandomValues
: getRandomValuesNative;
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+5
View File
@@ -0,0 +1,5 @@
# @polkadot/x-rxjs
This is a small wrapper around rjx to make it friendly to both Node.js (from .mjs as well as .cjs) as well as bundlers using both esm and cjs modules.
This need wil disappear, once rxjs supports export maps.
+18
View File
@@ -0,0 +1,18 @@
{
"name": "@polkadot/x-rxjs",
"version": "5.5.1",
"description": "A pass-through interface for RxJs (allowing node + mjs usage)",
"main": "index.js",
"sideEffects": false,
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"repository": "github:polkadot-js/common",
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-rxjs#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"rxjs": "^6.6.3"
}
}
+4
View File
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from 'rxjs';
+74
View File
@@ -0,0 +1,74 @@
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
// SPDX-License-Identifier: Apache-2.0
// This is not great, but while having esm files, rxjs doesn't quite play nicely with
// Node.js mjs files. (Hopefully this improves in 7.0, although no exports map as of yet)
//
// Generated via s/export \{ (.*) \} from .*/exports.$1 = rxjs.$1;/ on rxjs/_esm
// This is or our builder
// @polkadot/dev: exports-node
const rxjs = require('rxjs');
exports.Observable = rxjs.Observable;
exports.ConnectableObservable = rxjs.ConnectableObservable;
exports.GroupedObservable = rxjs.GroupedObservable;
exports.observable = rxjs.observable;
exports.Subject = rxjs.Subject;
exports.BehaviorSubject = rxjs.BehaviorSubject;
exports.ReplaySubject = rxjs.ReplaySubject;
exports.AsyncSubject = rxjs.AsyncSubject;
exports.asap = rxjs.asap;
exports.asapScheduler = rxjs.asapScheduler;
exports.async = rxjs.async;
exports.asyncScheduler = rxjs.asyncScheduler;
exports.queue = rxjs.queue;
exports.queueScheduler = rxjs.queueScheduler;
exports.animationFrame = rxjs.animationFrame;
exports.animationFrameScheduler = rxjs.animationFrameScheduler;
exports.VirtualTimeScheduler = rxjs.VirtualTimeScheduler;
exports.VirtualAction = rxjs.VirtualAction;
exports.Scheduler = rxjs.Scheduler;
exports.Subscription = rxjs.Subscription;
exports.Subscriber = rxjs.Subscriber;
exports.Notification = rxjs.Notification;
exports.NotificationKind = rxjs.NotificationKind;
exports.pipe = rxjs.pipe;
exports.noop = rxjs.noop;
exports.identity = rxjs.identity;
exports.isObservable = rxjs.isObservable;
exports.ArgumentOutOfRangeError = rxjs.ArgumentOutOfRangeError;
exports.EmptyError = rxjs.EmptyError;
exports.ObjectUnsubscribedError = rxjs.ObjectUnsubscribedError;
exports.UnsubscriptionError = rxjs.UnsubscriptionError;
exports.TimeoutError = rxjs.TimeoutError;
exports.bindCallback = rxjs.bindCallback;
exports.bindNodeCallback = rxjs.bindNodeCallback;
exports.combineLatest = rxjs.combineLatest;
exports.concat = rxjs.concat;
exports.defer = rxjs.defer;
exports.empty = rxjs.empty;
exports.forkJoin = rxjs.forkJoin;
exports.from = rxjs.from;
exports.fromEvent = rxjs.fromEvent;
exports.fromEventPattern = rxjs.fromEventPattern;
exports.generate = rxjs.generate;
exports.iif = rxjs.iif;
exports.interval = rxjs.interval;
exports.merge = rxjs.merge;
exports.never = rxjs.never;
exports.of = rxjs.of;
exports.onErrorResumeNext = rxjs.onErrorResumeNext;
exports.pairs = rxjs.pairs;
exports.partition = rxjs.partition;
exports.race = rxjs.race;
exports.range = rxjs.range;
exports.throwError = rxjs.throwError;
exports.timer = rxjs.timer;
exports.using = rxjs.using;
exports.zip = rxjs.zip;
exports.scheduled = rxjs.scheduled;
exports.EMPTY = rxjs.EMPTY;
exports.NEVER = rxjs.NEVER;
exports.config = rxjs.config;
+4
View File
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { animationFrame, animationFrameScheduler, ArgumentOutOfRangeError, asap, asapScheduler, async, asyncScheduler, AsyncSubject, BehaviorSubject, bindCallback, bindNodeCallback, combineLatest, concat, config, ConnectableObservable, defer, EMPTY, empty, EmptyError, forkJoin, from, fromEvent, fromEventPattern, generate, GroupedObservable, identity, iif, interval, isObservable, merge, NEVER, never, noop, Notification, NotificationKind, ObjectUnsubscribedError, Observable, observable, of, onErrorResumeNext, pairs, partition, pipe, queue, queueScheduler, race, range, ReplaySubject, scheduled, Scheduler, Subject, Subscriber, Subscription, throwError, TimeoutError, timer, UnsubscriptionError, using, VirtualAction, VirtualTimeScheduler, zip } from 'rxjs/_esm5/index.js';
+4
View File
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from 'rxjs/operators';
+117
View File
@@ -0,0 +1,117 @@
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
// SPDX-License-Identifier: Apache-2.0
// This is not great, but while having esm files, rxjs doesn't quite play nicely with
// Node.js mjs files. (Hopefully this improves in 7.0, although no exports map as of yet)
//
// Generated via s/export \{ (.*) \} from .*/exports.$1 = rxjs.$1;/ on rxjs/_esm
// This is or our builder, to add the correct exports entry
// @polkadot/dev: exports-node
const operators = require('rxjs/operators');
exports.audit = operators.audit;
exports.auditTime = operators.auditTime;
exports.buffer = operators.buffer;
exports.bufferCount = operators.bufferCount;
exports.bufferTime = operators.bufferTime;
exports.bufferToggle = operators.bufferToggle;
exports.bufferWhen = operators.bufferWhen;
exports.catchError = operators.catchError;
exports.combineAll = operators.combineAll;
exports.combineLatest = operators.combineLatest;
exports.concat = operators.concat;
exports.concatAll = operators.concatAll;
exports.concatMap = operators.concatMap;
exports.concatMapTo = operators.concatMapTo;
exports.count = operators.count;
exports.debounce = operators.debounce;
exports.debounceTime = operators.debounceTime;
exports.defaultIfEmpty = operators.defaultIfEmpty;
exports.delay = operators.delay;
exports.delayWhen = operators.delayWhen;
exports.dematerialize = operators.dematerialize;
exports.distinct = operators.distinct;
exports.distinctUntilChanged = operators.distinctUntilChanged;
exports.distinctUntilKeyChanged = operators.distinctUntilKeyChanged;
exports.elementAt = operators.elementAt;
exports.endWith = operators.endWith;
exports.every = operators.every;
exports.exhaust = operators.exhaust;
exports.exhaustMap = operators.exhaustMap;
exports.expand = operators.expand;
exports.filter = operators.filter;
exports.finalize = operators.finalize;
exports.find = operators.find;
exports.findIndex = operators.findIndex;
exports.first = operators.first;
exports.groupBy = operators.groupBy;
exports.ignoreElements = operators.ignoreElements;
exports.isEmpty = operators.isEmpty;
exports.last = operators.last;
exports.map = operators.map;
exports.mapTo = operators.mapTo;
exports.materialize = operators.materialize;
exports.max = operators.max;
exports.merge = operators.merge;
exports.mergeAll = operators.mergeAll;
exports.mergeMap = operators.mergeMap;
exports.flatMap = operators.flatMap;
exports.mergeMapTo = operators.mergeMapTo;
exports.mergeScan = operators.mergeScan;
exports.min = operators.min;
exports.multicast = operators.multicast;
exports.observeOn = operators.observeOn;
exports.onErrorResumeNext = operators.onErrorResumeNext;
exports.pairwise = operators.pairwise;
exports.partition = operators.partition;
exports.pluck = operators.pluck;
exports.publish = operators.publish;
exports.publishBehavior = operators.publishBehavior;
exports.publishLast = operators.publishLast;
exports.publishReplay = operators.publishReplay;
exports.race = operators.race;
exports.reduce = operators.reduce;
exports.repeat = operators.repeat;
exports.repeatWhen = operators.repeatWhen;
exports.retry = operators.retry;
exports.retryWhen = operators.retryWhen;
exports.refCount = operators.refCount;
exports.sample = operators.sample;
exports.sampleTime = operators.sampleTime;
exports.scan = operators.scan;
exports.sequenceEqual = operators.sequenceEqual;
exports.share = operators.share;
exports.shareReplay = operators.shareReplay;
exports.single = operators.single;
exports.skip = operators.skip;
exports.skipLast = operators.skipLast;
exports.skipUntil = operators.skipUntil;
exports.skipWhile = operators.skipWhile;
exports.startWith = operators.startWith;
exports.subscribeOn = operators.subscribeOn;
exports.switchAll = operators.switchAll;
exports.switchMap = operators.switchMap;
exports.switchMapTo = operators.switchMapTo;
exports.take = operators.take;
exports.takeLast = operators.takeLast;
exports.takeUntil = operators.takeUntil;
exports.takeWhile = operators.takeWhile;
exports.tap = operators.tap;
exports.throttle = operators.throttle;
exports.throttleTime = operators.throttleTime;
exports.throwIfEmpty = operators.throwIfEmpty;
exports.timeInterval = operators.timeInterval;
exports.timeout = operators.timeout;
exports.timeoutWith = operators.timeoutWith;
exports.timestamp = operators.timestamp;
exports.toArray = operators.toArray;
exports.window = operators.window;
exports.windowCount = operators.windowCount;
exports.windowTime = operators.windowTime;
exports.windowToggle = operators.windowToggle;
exports.windowWhen = operators.windowWhen;
exports.withLatestFrom = operators.withLatestFrom;
exports.zip = operators.zip;
exports.zipAll = operators.zipAll;
+4
View File
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { audit, auditTime, buffer, bufferCount, bufferTime, bufferToggle, bufferWhen, catchError, combineAll, combineLatest, concat, concatAll, concatMap, concatMapTo, count, debounce, debounceTime, defaultIfEmpty, delay, delayWhen, dematerialize, distinct, distinctUntilChanged, distinctUntilKeyChanged, elementAt, endWith, every, exhaust, exhaustMap, expand, filter, finalize, find, findIndex, first, flatMap, groupBy, ignoreElements, isEmpty, last, map, mapTo, materialize, max, merge, mergeAll, mergeMap, mergeMapTo, mergeScan, min, multicast, observeOn, onErrorResumeNext, pairwise, partition, pluck, publish, publishBehavior, publishLast, publishReplay, race, reduce, refCount, repeat, repeatWhen, retry, retryWhen, sample, sampleTime, scan, sequenceEqual, share, shareReplay, single, skip, skipLast, skipUntil, skipWhile, startWith, subscribeOn, switchAll, switchMap, switchMapTo, take, takeLast, takeUntil, takeWhile, tap, throttle, throttleTime, throwIfEmpty, timeInterval, timeout, timeoutWith, timestamp, toArray, window, windowCount, windowTime, windowToggle, windowWhen, withLatestFrom, zip, zipAll } from 'rxjs/_esm5/operators/index.js';
+3 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-textdecoder",
"version": "5.3.1",
"version": "5.5.1",
"description": "A TextDecoder replacement",
"browser": "browser.js",
"main": "node.js",
@@ -14,6 +14,7 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-textdecoder#readme",
"dependencies": {
"@babel/runtime": "^7.12.5"
"@babel/runtime": "^7.12.5",
"@polkadot/x-global": "5.5.1"
}
}
+5 -3
View File
@@ -1,8 +1,10 @@
// Copyright 2017-2021 @polkadot/x-textencoder authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { xglobal } from '@polkadot/x-global';
import { TextDecoder as Fallback } from './fallback';
export const TextDecoder = typeof global.TextDecoder === 'undefined'
? Fallback as unknown as typeof global.TextDecoder
: global.TextDecoder;
export const TextDecoder = typeof xglobal.TextDecoder === 'undefined'
? Fallback as unknown as typeof xglobal.TextDecoder
: xglobal.TextDecoder;
+5 -3
View File
@@ -3,6 +3,8 @@
import util from 'util';
export const TextDecoder = typeof global.TextDecoder === 'undefined'
? util.TextDecoder as unknown as typeof global.TextDecoder
: global.TextDecoder;
import { xglobal } from '@polkadot/x-global';
export const TextDecoder = typeof xglobal.TextDecoder === 'undefined'
? util.TextDecoder as unknown as typeof xglobal.TextDecoder
: xglobal.TextDecoder;
+3 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-textencoder",
"version": "5.3.1",
"version": "5.5.1",
"description": "A TextDecoder replacement",
"browser": "browser.js",
"main": "node.js",
@@ -14,6 +14,7 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-textencoder#readme",
"dependencies": {
"@babel/runtime": "^7.12.5"
"@babel/runtime": "^7.12.5",
"@polkadot/x-global": "5.5.1"
}
}
+5 -3
View File
@@ -1,8 +1,10 @@
// Copyright 2017-2021 @polkadot/x-textencoder authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { xglobal } from '@polkadot/x-global';
import { TextEncoder as Fallback } from './fallback';
export const TextEncoder = typeof global.TextEncoder === 'undefined'
? Fallback as unknown as typeof global.TextEncoder
: global.TextEncoder;
export const TextEncoder = typeof xglobal.TextEncoder === 'undefined'
? Fallback as unknown as typeof xglobal.TextEncoder
: xglobal.TextEncoder;
+5 -3
View File
@@ -3,6 +3,8 @@
import util from 'util';
import { xglobal } from '@polkadot/x-global';
class NodeFallback {
#encoder: util.TextEncoder;
@@ -18,6 +20,6 @@ class NodeFallback {
}
}
export const TextEncoder = typeof global.TextEncoder === 'undefined'
? NodeFallback as unknown as typeof global.TextEncoder
: global.TextEncoder;
export const TextEncoder = typeof xglobal.TextEncoder === 'undefined'
? NodeFallback as unknown as typeof xglobal.TextEncoder
: xglobal.TextEncoder;
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-ws",
"version": "5.3.1",
"version": "5.5.1",
"description": "A cross-environment WebSocket replacement",
"browser": "browser.js",
"main": "node.js",
@@ -15,6 +15,7 @@
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-ws#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/x-global": "5.5.1",
"@types/websocket": "^1.0.1",
"websocket": "^1.0.33"
}
+3 -1
View File
@@ -1,4 +1,6 @@
// Copyright 2017-2021 @polkadot/x-ws authors & contributors
// SPDX-License-Identifier: Apache-2.0
export const WebSocket = global.WebSocket;
import { xglobal } from '@polkadot/x-global';
export const WebSocket = xglobal.WebSocket;
+5 -3
View File
@@ -3,6 +3,8 @@
import ws from 'websocket';
export const WebSocket = typeof global.WebSocket === 'undefined'
? ws.w3cwebsocket as unknown as typeof global.WebSocket
: global.WebSocket;
import { xglobal } from '@polkadot/x-global';
export const WebSocket = typeof xglobal.WebSocket === 'undefined'
? ws.w3cwebsocket as unknown as typeof xglobal.WebSocket
: xglobal.WebSocket;
+8 -1
View File
@@ -19,7 +19,14 @@
"@polkadot/util-crypto/*": [ "packages/util-crypto/src/*" ],
"@polkadot/util": [ "packages/util/src" ],
"@polkadot/util/*": [ "packages/util/src/*" ],
"@polkadot/x-*": [ "packages/x-*/src/browser" ]
"@polkadot/x-fetch": [ "packages/x-fetch/src/browser" ],
"@polkadot/x-global": [ "packages/x-global/src" ],
"@polkadot/x-randomvalues": [ "packages/x-randomvalues/src/browser" ],
"@polkadot/x-rxjs": ["packages/x-rxjs/src"],
"@polkadot/x-rxjs/*": ["packages/x-rxjs/src/*"],
"@polkadot/x-textdecoder": [ "packages/x-textdecoder/src/browser" ],
"@polkadot/x-textencoder": [ "packages/x-textencoder/src/browser" ],
"@polkadot/x-ws": [ "packages/x-ws/src/browser" ]
},
"skipLibCheck": true,
"typeRoots": [
+118 -94
View File
@@ -1571,81 +1571,81 @@ __metadata:
languageName: node
linkType: hard
"@ledgerhq/devices@npm:^5.39.0":
version: 5.39.0
resolution: "@ledgerhq/devices@npm:5.39.0"
"@ledgerhq/devices@npm:^5.41.0":
version: 5.41.0
resolution: "@ledgerhq/devices@npm:5.41.0"
dependencies:
"@ledgerhq/errors": ^5.39.0
"@ledgerhq/logs": ^5.39.0
"@ledgerhq/errors": ^5.41.0
"@ledgerhq/logs": ^5.41.0
rxjs: ^6.6.3
semver: ^7.3.4
checksum: abaa35fe1f08a28969ff0827a29a2657428e2437f5cc507e93e36017e6ee3d5066fa0167c8a1fa558781353b3afd5a19c9151929f98404046fd5925e6e996206
checksum: 5f1ff31df030b86789d746d1c6db7bb884b8ca8b884353b56322915a432e5ec24d8f3f0285ee046f7d6b914c7f9d1272e7875de8985add7010d4244b81cb99b5
languageName: node
linkType: hard
"@ledgerhq/errors@npm:^5.39.0":
version: 5.39.0
resolution: "@ledgerhq/errors@npm:5.39.0"
checksum: 61d17b826c1fc5ffd2d3bf238c0842afc5f168a0e119ffefab289956ca861456f5a87bdd8e128dc9f03506665cb8a63cdd1c15e9d439af7815f8c55151745e83
"@ledgerhq/errors@npm:^5.41.0":
version: 5.41.0
resolution: "@ledgerhq/errors@npm:5.41.0"
checksum: f06e63e1f96fcb89f718ae617b31ec4d0ea83d82dafc92125beebcee0759dfe1fd32b7a72f6b7e656d57a93637f2417743b04adf77a84d2a27f4cd75ac158c25
languageName: node
linkType: hard
"@ledgerhq/hw-transport-node-hid-noevents@npm:^5.39.0":
version: 5.39.0
resolution: "@ledgerhq/hw-transport-node-hid-noevents@npm:5.39.0"
"@ledgerhq/hw-transport-node-hid-noevents@npm:^5.41.0":
version: 5.41.0
resolution: "@ledgerhq/hw-transport-node-hid-noevents@npm:5.41.0"
dependencies:
"@ledgerhq/devices": ^5.39.0
"@ledgerhq/errors": ^5.39.0
"@ledgerhq/hw-transport": ^5.39.0
"@ledgerhq/logs": ^5.39.0
"@ledgerhq/devices": ^5.41.0
"@ledgerhq/errors": ^5.41.0
"@ledgerhq/hw-transport": ^5.41.0
"@ledgerhq/logs": ^5.41.0
node-hid: 2.1.1
checksum: 3f42736842e72caaf4bbdf513fa50728f93e5c681103004fece4f9a8c71bafb626e185d4b56e59a37616111ac3a3509f775390f5fb4bd0c07b6b54dd061cc41b
checksum: 791d7bac6e76d26cb47959addf2ab6228f4d9c52777a18509552ff3aca71bf63bdf98dd43f73b545b64b368c6bf297d7ed74207cf26c8aecce6344bf3aeb9c01
languageName: node
linkType: hard
"@ledgerhq/hw-transport-node-hid-singleton@npm:^5.39.0":
version: 5.39.0
resolution: "@ledgerhq/hw-transport-node-hid-singleton@npm:5.39.0"
"@ledgerhq/hw-transport-node-hid-singleton@npm:^5.41.0":
version: 5.41.0
resolution: "@ledgerhq/hw-transport-node-hid-singleton@npm:5.41.0"
dependencies:
"@ledgerhq/devices": ^5.39.0
"@ledgerhq/errors": ^5.39.0
"@ledgerhq/hw-transport": ^5.39.0
"@ledgerhq/hw-transport-node-hid-noevents": ^5.39.0
"@ledgerhq/logs": ^5.39.0
"@ledgerhq/devices": ^5.41.0
"@ledgerhq/errors": ^5.41.0
"@ledgerhq/hw-transport": ^5.41.0
"@ledgerhq/hw-transport-node-hid-noevents": ^5.41.0
"@ledgerhq/logs": ^5.41.0
lodash: ^4.17.20
node-hid: 2.1.1
usb-detection: ^4.10.0
checksum: e169865e176203097c09fb1267f2befe2fbbb92d636b2dfa6c3e8dae2ede71eac76429f31206191ebbd0786de50bb3c64df57eee91ace05c4a63891fac7df201
checksum: 2775d1dc3463dab6c13c57eb11830e6dbe1507c20793cc9f499d09a948d82efcfb0f3b2fb695d7885a9f2553390c6ea21c2fe9dcd7c930a2ed3d82792d647a15
languageName: node
linkType: hard
"@ledgerhq/hw-transport-webusb@npm:^5.39.0":
version: 5.39.0
resolution: "@ledgerhq/hw-transport-webusb@npm:5.39.0"
"@ledgerhq/hw-transport-webusb@npm:^5.41.0":
version: 5.41.0
resolution: "@ledgerhq/hw-transport-webusb@npm:5.41.0"
dependencies:
"@ledgerhq/devices": ^5.39.0
"@ledgerhq/errors": ^5.39.0
"@ledgerhq/hw-transport": ^5.39.0
"@ledgerhq/logs": ^5.39.0
checksum: 39b0af5c1625e227603ed3c1b4a3de96dee0d311e3b8054979496dec65797371feb874ae1423eaec79f5e032d35565f941c5b4ab6d1537c9a60add842a1cef8a
"@ledgerhq/devices": ^5.41.0
"@ledgerhq/errors": ^5.41.0
"@ledgerhq/hw-transport": ^5.41.0
"@ledgerhq/logs": ^5.41.0
checksum: 9ab9c689068b1c4e7fae600bf4b98f786eb5ca37daad6e6c25911bde57c532cc965d897fa6922b6e7cf8e37610c363515a9db4c7631e3ed5d33a00b1e1c86121
languageName: node
linkType: hard
"@ledgerhq/hw-transport@npm:^5.38.0, @ledgerhq/hw-transport@npm:^5.39.0":
version: 5.39.0
resolution: "@ledgerhq/hw-transport@npm:5.39.0"
"@ledgerhq/hw-transport@npm:^5.38.0, @ledgerhq/hw-transport@npm:^5.41.0":
version: 5.41.0
resolution: "@ledgerhq/hw-transport@npm:5.41.0"
dependencies:
"@ledgerhq/devices": ^5.39.0
"@ledgerhq/errors": ^5.39.0
"@ledgerhq/devices": ^5.41.0
"@ledgerhq/errors": ^5.41.0
events: ^3.2.0
checksum: abab2dda170888d5faa85f5dc4306b98977c53d8f39da4b4cafccc0bab7e93d81f94d9d8dc119cdb502647ee5491c41477aa7749e47c376cf614fe95c6bc1e98
checksum: 46dbc86686dd70ea29b6fb46a8c6dd5cd308ebdd02bc6065302f39471fc7b966f69d2b1ced42a2c759fc11d30f85fc64401681b569ce99720102df418bf045bd
languageName: node
linkType: hard
"@ledgerhq/logs@npm:^5.39.0":
version: 5.39.0
resolution: "@ledgerhq/logs@npm:5.39.0"
checksum: 2cb2edb98987d0da3db0e99d84766b0f1391a1798658710dac048f265aa6955d121621ed0e2faa1788c3d1fa0aa7cdcfe461b4284453f835043aa77eb49e6247
"@ledgerhq/logs@npm:^5.41.0":
version: 5.41.0
resolution: "@ledgerhq/logs@npm:5.41.0"
checksum: 83de45a01f5b35b2fdbf23971ce5f5b86553aa44f1fe8a4c186bbef48d1964b4d71a04c5d35d4f583e6923c4d46cb031745dd2277b16c20cd8d06f7a86233b0a
languageName: node
linkType: hard
@@ -1786,13 +1786,13 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/hw-ledger-transports@5.3.1, @polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports":
"@polkadot/hw-ledger-transports@5.5.1, @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:
"@babel/runtime": ^7.12.5
"@ledgerhq/hw-transport-node-hid-singleton": ^5.39.0
"@ledgerhq/hw-transport-webusb": ^5.39.0
"@ledgerhq/hw-transport-node-hid-singleton": ^5.41.0
"@ledgerhq/hw-transport-webusb": ^5.41.0
"@types/ledgerhq__hw-transport-node-hid": ^4.22.2
"@types/ledgerhq__hw-transport-webusb": ^4.70.1
dependenciesMeta:
@@ -1806,8 +1806,8 @@ __metadata:
resolution: "@polkadot/hw-ledger@workspace:packages/hw-ledger"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/hw-ledger-transports": 5.3.1
"@polkadot/util": ^5.3.1
"@polkadot/hw-ledger-transports": 5.5.1
"@polkadot/util": ^5.5.1
"@zondax/ledger-polkadot": ^0.13.0
languageName: unknown
linkType: soft
@@ -1817,21 +1817,21 @@ __metadata:
resolution: "@polkadot/keyring@workspace:packages/keyring"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/util": 5.3.1
"@polkadot/util-crypto": 5.3.1
"@polkadot/util": 5.5.1
"@polkadot/util-crypto": 5.5.1
peerDependencies:
"@polkadot/util": 5.3.1
"@polkadot/util-crypto": 5.3.1
"@polkadot/util": 5.5.1
"@polkadot/util-crypto": 5.5.1
languageName: unknown
linkType: soft
"@polkadot/networks@5.3.1, @polkadot/networks@workspace:packages/networks":
"@polkadot/networks@5.5.1, @polkadot/networks@workspace:packages/networks":
version: 0.0.0-use.local
resolution: "@polkadot/networks@workspace:packages/networks"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/util": 5.3.1
"@polkadot/x-fetch": 5.3.1
"@polkadot/util": 5.5.1
"@polkadot/x-fetch": 5.5.1
languageName: unknown
linkType: soft
@@ -1844,15 +1844,15 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/util-crypto@5.3.1, @polkadot/util-crypto@workspace:packages/util-crypto":
"@polkadot/util-crypto@5.5.1, @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.12.5
"@polkadot/networks": 5.3.1
"@polkadot/util": 5.3.1
"@polkadot/wasm-crypto": ^3.1.1
"@polkadot/x-randomvalues": 5.3.1
"@polkadot/networks": 5.5.1
"@polkadot/util": 5.5.1
"@polkadot/wasm-crypto": ^3.2.2
"@polkadot/x-randomvalues": 5.5.1
"@types/bn.js": ^4.11.6
"@types/create-hash": ^1.2.2
"@types/elliptic": ^6.4.12
@@ -1869,59 +1869,70 @@ __metadata:
tweetnacl: ^1.0.3
xxhashjs: ^0.2.2
peerDependencies:
"@polkadot/util": 5.3.1
"@polkadot/util": 5.5.1
languageName: unknown
linkType: soft
"@polkadot/util@5.3.1, @polkadot/util@^5.3.1, @polkadot/util@workspace:packages/util":
"@polkadot/util@5.5.1, @polkadot/util@^5.5.1, @polkadot/util@workspace:packages/util":
version: 0.0.0-use.local
resolution: "@polkadot/util@workspace:packages/util"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/x-textdecoder": 5.3.1
"@polkadot/x-textencoder": 5.3.1
"@polkadot/x-textdecoder": 5.5.1
"@polkadot/x-textencoder": 5.5.1
"@types/bn.js": ^4.11.6
bn.js: ^4.11.9
camelcase: ^5.3.1
ip-regex: ^4.2.0
ip-regex: ^4.3.0
languageName: unknown
linkType: soft
"@polkadot/wasm-crypto-asmjs@npm:^3.1.1":
version: 3.1.1
resolution: "@polkadot/wasm-crypto-asmjs@npm:3.1.1"
"@polkadot/wasm-crypto-asmjs@npm:^3.2.2":
version: 3.2.2
resolution: "@polkadot/wasm-crypto-asmjs@npm:3.2.2"
dependencies:
"@babel/runtime": ^7.12.5
checksum: 6f8f10452e89ba7e3cabbd38f521cd379180c6efec644a79b7e39c04eb00dbba50a121a695cfc02578ec123c3139ce2aa128b193f11ed49e1e9f624685350e8a
checksum: ddeaf412f1312ee4a045d2c94046af3b800330ee8b64e6c89f9a40abb93270a4d7fa19141107a45b84f7f24c93d1ed3c16d3c552c2e3ecdea7662dd0348a46e5
languageName: node
linkType: hard
"@polkadot/wasm-crypto-wasm@npm:^3.1.1":
version: 3.1.1
resolution: "@polkadot/wasm-crypto-wasm@npm:3.1.1"
"@polkadot/wasm-crypto-wasm@npm:^3.2.2":
version: 3.2.2
resolution: "@polkadot/wasm-crypto-wasm@npm:3.2.2"
dependencies:
"@babel/runtime": ^7.12.5
checksum: f96eda239fa4632359983ef12d776268ed2f16a12cc888e594f3ca43f09b42cc389ad248bbccb99b801b59ad672e2961a9e3dff9377ede067588d4de541df6fa
checksum: 12ff0ea3c30c731269a1428e92a2e9d9f34ff2cbc5bc5d97a1d762c9fa85acc2027fe44eadc293971976137bd79c508de68b465fffe728d4e557d8f4221efb9e
languageName: node
linkType: hard
"@polkadot/wasm-crypto@npm:^3.1.1":
version: 3.1.1
resolution: "@polkadot/wasm-crypto@npm:3.1.1"
"@polkadot/wasm-crypto@npm:^3.2.2":
version: 3.2.2
resolution: "@polkadot/wasm-crypto@npm:3.2.2"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/wasm-crypto-asmjs": ^3.1.1
"@polkadot/wasm-crypto-wasm": ^3.1.1
"@polkadot/wasm-crypto-asmjs": ^3.2.2
"@polkadot/wasm-crypto-wasm": ^3.2.2
peerDependencies:
"@polkadot/util": "*"
"@polkadot/x-randomvalues": "*"
checksum: a7b3d029d88669ea9775c8cfe166a44a06ba243283c03fa0547bf4c6144c5440260a0bd1a6acc9c67b57ab707c406d681a2e52af5e7da3ebe8bb4fdeff071c66
checksum: 9940cff288e7f027566b16531f92dce560e7f18f6abdae5f1ca41e752aa5c05b7fd1208900c6ee5032d7f0822ee8f425107b84ed9f4c647aa17d1268f27ce30d
languageName: node
linkType: hard
"@polkadot/x-fetch@5.3.1, @polkadot/x-fetch@workspace:packages/x-fetch":
"@polkadot/x-fetch@5.5.1, @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.12.5
"@polkadot/x-global": 5.5.1
"@types/node-fetch": ^2.5.8
node-fetch: ^2.6.1
languageName: unknown
linkType: soft
"@polkadot/x-global@5.5.1, @polkadot/x-global@workspace:packages/x-global":
version: 0.0.0-use.local
resolution: "@polkadot/x-global@workspace:packages/x-global"
dependencies:
"@babel/runtime": ^7.12.5
"@types/node-fetch": ^2.5.8
@@ -1929,28 +1940,40 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/x-randomvalues@5.3.1, @polkadot/x-randomvalues@workspace:packages/x-randomvalues":
"@polkadot/x-randomvalues@5.5.1, @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.12.5
"@types/react-native": ^0.63.45
"@polkadot/x-global": 5.5.1
"@types/react-native": ^0.63.46
languageName: unknown
linkType: soft
"@polkadot/x-textdecoder@5.3.1, @polkadot/x-textdecoder@workspace:packages/x-textdecoder":
"@polkadot/x-rxjs@workspace:packages/x-rxjs":
version: 0.0.0-use.local
resolution: "@polkadot/x-rxjs@workspace:packages/x-rxjs"
dependencies:
"@babel/runtime": ^7.12.5
rxjs: ^6.6.3
languageName: unknown
linkType: soft
"@polkadot/x-textdecoder@5.5.1, @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.12.5
"@polkadot/x-global": 5.5.1
languageName: unknown
linkType: soft
"@polkadot/x-textencoder@5.3.1, @polkadot/x-textencoder@workspace:packages/x-textencoder":
"@polkadot/x-textencoder@5.5.1, @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.12.5
"@polkadot/x-global": 5.5.1
languageName: unknown
linkType: soft
@@ -1959,6 +1982,7 @@ __metadata:
resolution: "@polkadot/x-ws@workspace:packages/x-ws"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/x-global": 5.5.1
"@types/websocket": ^1.0.1
websocket: ^1.0.33
languageName: unknown
@@ -2250,12 +2274,12 @@ __metadata:
languageName: node
linkType: hard
"@types/react-native@npm:^0.63.45":
version: 0.63.45
resolution: "@types/react-native@npm:0.63.45"
"@types/react-native@npm:^0.63.46":
version: 0.63.46
resolution: "@types/react-native@npm:0.63.46"
dependencies:
"@types/react": "*"
checksum: 1fe4bc616bd2864eeff0cdce793aedbe25090d04550b3b4365f9d4153b46ad7af6641c5637015da328fff0fece2e1f3c52e28bdef2b3a802bfdd23c8286353cb
checksum: 0aa7975a232905af4243b990314e1bc54fdcaea5a402a3cd4ce390d42cd3af283b1998ac028689b6a346c5bc8be4dd73da4a70a58723a046c62c94bb820a7948
languageName: node
linkType: hard
@@ -5975,10 +5999,10 @@ fsevents@~2.1.2:
languageName: node
linkType: hard
"ip-regex@npm:^4.2.0":
version: 4.2.0
resolution: "ip-regex@npm:4.2.0"
checksum: 9e376018e64da89756e27d3f1b3313abc85291b5d1b5b9878f26b3934ecb04fa512116bf66b6dcd9553ba0b88af4feaaedbccd86f0ba6c05e464642ccb8504c5
"ip-regex@npm:^4.3.0":
version: 4.3.0
resolution: "ip-regex@npm:4.3.0"
checksum: 4f44f34dcfe5cfae3b79bac4b25bec81ea007c24a66a30a3a17d01eebde4fa98bb531f207590ee16e1e4721b4f8ad12f6a64ed9f49bcb4587ff13ebb7cc984a5
languageName: node
linkType: hard