Compare commits

...
92 Commits
Author SHA1 Message Date
github-actions[bot] e28a5ffd4b [CI Skip] release/stable 7.2.2
skip-checks: true
2023-08-17 07:42:59 +00:00
Jaco 7f3ca3159d 7.2.2 (#535)
* 7.2.2

* CHANGELOG typo

* Adjust root dependencies
2023-08-17 10:37:26 +03:00
github-actions[bot] 3a3214e602 [CI Skip] bump/beta 7.2.2-12-x
skip-checks: true
2023-08-16 08:21:33 +00:00
Jaco 319f33bec1 Bump dev (#534)
* Bump dev

* Adjust linting
2023-08-16 11:14:44 +03:00
github-actions[bot] a8f5189252 [CI Skip] bump/beta 7.2.2-11-x
skip-checks: true
2023-08-16 06:22:41 +00:00
Jaco ee26a6ef98 Bump deps (w/ eslint updates) (#533) 2023-08-16 09:17:00 +03:00
github-actions[bot] 71291442bb [CI Skip] bump/beta 7.2.2-10-x
skip-checks: true
2023-07-06 07:27:43 +00:00
Jaco f26f855942 Bump deps (#532) 2023-07-06 10:22:27 +03:00
github-actions[bot] 3a06871f82 [CI Skip] bump/beta 7.2.2-9-x
skip-checks: true
2023-06-12 06:04:02 +00:00
Jaco 279da24ca1 Bump util (#531) 2023-06-12 08:57:00 +03:00
github-actions[bot] af81a69ba6 [CI Skip] bump/beta 7.2.2-8-x
skip-checks: true
2023-06-11 07:08:14 +00:00
Jaco 0b39c9d2f1 Bump common (#530) 2023-06-11 10:02:36 +03:00
github-actions[bot] 7d2de26fdb [CI Skip] bump/beta 7.2.2-7-x
skip-checks: true
2023-06-04 14:48:02 +00:00
Jaco fc370eedb2 Bump common (#529) 2023-06-04 17:42:36 +03:00
github-actions[bot] 792baf352c [CI Skip] bump/beta 7.2.2-6-x
skip-checks: true
2023-06-02 10:29:57 +00:00
Jaco a79d6ded77 Bump deps (w/ TS 5.1) (#528) 2023-06-02 13:24:22 +03:00
github-actions[bot] 51b45133d9 [CI Skip] bump/beta 7.2.2-5-x
skip-checks: true
2023-05-25 07:32:56 +00:00
Jaco b3c934d602 Bump dev deps (#527) 2023-05-25 10:27:24 +03:00
github-actions[bot] 25cd084f30 [CI Skip] bump/beta 7.2.2-4-x
skip-checks: true
2023-05-21 09:48:55 +00:00
Jaco 9df575ad7b Bump dev (w/ eslint config adj) (#526) 2023-05-21 12:43:14 +03:00
github-actions[bot] 0175ac56a7 [CI Skip] bump/beta 7.2.2-3-x
skip-checks: true
2023-05-18 09:04:24 +00:00
Jaco e589fba3b1 Adjust tsconfig usage (w/ latest dev) (#525) 2023-05-18 11:59:20 +03:00
github-actions[bot] 570c46e889 [CI Skip] bump/beta 7.2.2-2-x
skip-checks: true
2023-05-18 05:28:27 +00:00
Jaco 4d002c7563 Bump dev deps (#524) 2023-05-18 08:22:56 +03:00
github-actions[bot] 6aeaa69a8b [CI Skip] bump/beta 7.2.2-1-x
skip-checks: true
2023-05-16 06:36:58 +00:00
Jaco 4565f85077 CJS export cleanups (#523) 2023-05-16 09:31:41 +03:00
github-actions[bot] 0d0dcbf005 [CI Skip] bump/beta 7.2.2-0-x
skip-checks: true
2023-05-13 08:49:41 +00:00
Jaco 7e38ff8faf Bump util (#522) 2023-05-13 11:43:56 +03:00
github-actions[bot] 5640651945 [CI Skip] release/stable 7.2.1
skip-checks: true
2023-05-13 08:07:05 +00:00
Jaco 657ac95ad9 7.2.1 (#521) 2023-05-13 11:00:42 +03:00
github-actions[bot] 23441ec34d [CI Skip] bump/beta 7.1.3-3-x
skip-checks: true
2023-05-08 13:40:53 +00:00
Jaco b7768c369c cjs/bytes.js generation adjustment (#520) 2023-05-08 16:36:00 +03:00
github-actions[bot] 646eabf516 [CI Skip] bump/beta 7.1.3-2-x
skip-checks: true
2023-05-06 08:54:15 +00:00
Jaco ac36b68a5e Bump dev (#519) 2023-05-06 11:49:24 +03:00
github-actions[bot] 390edd8b6d [CI Skip] bump/beta 7.1.3-1-x
skip-checks: true
2023-05-05 08:25:04 +00:00
Jaco 083eba1d8f Bump dev (w/ dev loader order fix) (#518) 2023-05-05 11:19:59 +03:00
Jaco 0a70cc7cfb Bump common (#517) 2023-05-01 20:12:38 +03:00
github-actions[bot] 034f625118 [CI Skip] bump/beta 7.1.3-0-x
skip-checks: true
2023-04-29 06:10:29 +00:00
Jaco 919c4aa7d4 Bump common (#516) 2023-04-29 09:04:19 +03:00
github-actions[bot] 85350b15d2 [CI Skip] release/stable 7.1.2
skip-checks: true
2023-04-28 05:44:41 +00:00
Jaco fcc48bf20a 7.1.2 (#515) 2023-04-28 08:40:05 +03:00
github-actions[bot] c408836bc6 [CI Skip] bump/beta 7.1.2-0-x
skip-checks: true
2023-04-22 08:06:12 +00:00
Jaco 194d1a6cd4 Bump common (#514) 2023-04-22 11:01:26 +03:00
github-actions[bot] fbb7d77f06 [CI Skip] release/stable 7.1.1
skip-checks: true
2023-04-22 07:06:48 +00:00
Jaco 1536cd9b48 7.1.1 (#513) 2023-04-22 10:01:26 +03:00
github-actions[bot] 695ccae218 [CI Skip] bump/beta 7.0.4-15-x
skip-checks: true
2023-04-13 11:32:52 +00:00
Jaco bd8d729765 Add util tests for (small) base64 decoder (#512) 2023-04-13 14:28:08 +03:00
github-actions[bot] 2453c8728b [CI Skip] bump/beta 7.0.4-14-x
skip-checks: true
2023-04-08 07:09:53 +00:00
Jaco f39f0d72f2 Bump TypeScript (#511) 2023-04-08 10:04:03 +03:00
github-actions[bot] 89739683f5 [CI Skip] bump/beta 7.0.4-13-x
skip-checks: true
2023-04-04 05:33:47 +00:00
Jaco 7f0c60b4f0 Update lock wf (#510) 2023-04-04 08:27:30 +03:00
github-actions[bot] 6ee5b6da86 [CI Skip] bump/beta 7.0.4-12-x
skip-checks: true
2023-04-01 07:31:39 +00:00
Jaco 68575449f1 Bump deps (#509) 2023-04-01 10:25:56 +03:00
github-actions[bot] ea7035a484 [CI Skip] bump/beta 7.0.4-11-x
skip-checks: true
2023-03-25 15:52:26 +00:00
Jaco cbb7cd94f7 Add repo dev req. for Node.js (#508) 2023-03-25 17:46:17 +02:00
github-actions[bot] d0af71031f [CI Skip] bump/beta 7.0.4-10-x
skip-checks: true
2023-03-25 10:58:53 +00:00
Jaco 929401b8b6 Bump dev (w/ some node:test adjustments) (#507) 2023-03-25 12:51:41 +02:00
github-actions[bot] 778879b1c1 [CI Skip] bump/beta 7.0.4-9-x
skip-checks: true
2023-03-25 07:35:59 +00:00
Jaco cadb0d9123 Bump util (#506) 2023-03-25 09:29:43 +02:00
github-actions[bot] 4e505bbe29 [CI Skip] bump/beta 7.0.4-8-x
skip-checks: true
2023-03-19 08:10:28 +00:00
Jaco 72cbdf6eaa Bump common deps (#505) 2023-03-19 10:05:23 +02:00
github-actions[bot] a032cbce6e [CI Skip] bump/beta 7.0.4-7-x
skip-checks: true
2023-03-18 10:02:53 +00:00
Jaco 12a5b0da0f Bump deps (& remove unused overrides) (#504) 2023-03-18 11:57:41 +02:00
github-actions[bot] f1129ddcbb [CI Skip] bump/beta 7.0.4-6-x
skip-checks: true
2023-03-17 06:05:27 +00:00
Jaco 7d2a29d231 Bump to TS 5.0 (#503) 2023-03-17 07:59:57 +02:00
github-actions[bot] c5550ad559 [CI Skip] bump/beta 7.0.4-5-x
skip-checks: true
2023-03-17 05:25:08 +00:00
Jaco d1fd2a74a4 Bump dev deps (#502) 2023-03-17 07:18:36 +02:00
github-actions[bot] f1d678132a [CI Skip] bump/beta 7.0.4-4-x
skip-checks: true
2023-03-15 16:39:54 +00:00
Jaco 784422a129 Bump dev (w/ /src/ caching only) (#501) 2023-03-15 18:34:19 +02:00
Jaco 0a6b25fbdd Bump dev (#500) 2023-03-15 17:42:17 +02:00
github-actions[bot] 6bc249181b [CI Skip] bump/beta 7.0.4-3-x
skip-checks: true
2023-03-15 14:55:48 +00:00
Jaco a47fb3bff9 Bump dev (#499) 2023-03-15 16:50:05 +02:00
github-actions[bot] d21c3fc639 [CI Skip] bump/beta 7.0.4-2-x
skip-checks: true
2023-03-14 11:01:52 +00:00
Jaco 7da2f705dc Remove stale workflow (#498) 2023-03-14 12:56:26 +02:00
github-actions[bot] 69278851bc [CI Skip] bump/beta 7.0.4-1-x
skip-checks: true
2023-03-12 09:44:54 +00:00
Jaco 41dbf12257 Bump dev (#497) 2023-03-12 11:39:33 +02:00
github-actions[bot] 7a8ce5ea3a [CI Skip] bump/beta 7.0.4-0-x
skip-checks: true
2023-03-11 07:22:45 +00:00
Jaco 7d24e46947 Bump util (#496) 2023-03-11 09:16:35 +02:00
github-actions[bot] 2bd507af55 [CI Skip] release/stable 7.0.3
skip-checks: true
2023-03-11 06:25:47 +00:00
Jaco 7232fd88b5 7.0.3 (#495) 2023-03-11 08:20:24 +02:00
github-actions[bot] dbfd08942a [CI Skip] bump/beta 7.0.3-5-x
skip-checks: true
2023-03-10 06:29:35 +00:00
Jaco 5d7a167d19 Update GH actions (#494) 2023-03-10 08:24:17 +02:00
github-actions[bot] b5478b52b4 [CI Skip] bump/beta 7.0.3-4-x
skip-checks: true
2023-03-09 11:27:31 +00:00
Jaco 66f4af6dda Align tsconfig to allow moduleResolution: nodenext (#493) 2023-03-09 13:21:53 +02:00
github-actions[bot] 74344c862c [CI Skip] bump/beta 7.0.3-3-x
skip-checks: true
2023-03-09 08:44:52 +00:00
Jaco 783476fd8d Use .js imports in src (#492)
* Use .js imports in src

* Bump dev
2023-03-09 10:39:39 +02:00
github-actions[bot] 0a7af910e1 [CI Skip] bump/beta 7.0.3-2-x
skip-checks: true
2023-03-06 12:18:06 +00:00
Jaco 478cd6ffcf Bump dev deps (#491) 2023-03-06 14:11:50 +02:00
github-actions[bot] df61ff95ca [CI Skip] bump/beta 7.0.3-1-x
skip-checks: true
2023-03-05 11:49:20 +00:00
Jaco 9137bd9848 jg-rm-babel-config (#490) 2023-03-05 13:44:14 +02:00
github-actions[bot] 3479d7f63b [CI Skip] bump/beta 7.0.3-0-x
skip-checks: true
2023-03-04 15:50:45 +00:00
Jaco a718bcbb0c Bump common deps (#489) 2023-03-04 17:45:40 +02:00
93 changed files with 1829 additions and 3074 deletions
-19
View File
@@ -1,19 +0,0 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
const base = require('@polkadot/dev/config/eslint.cjs');
module.exports = {
...base,
ignorePatterns: [
...base.ignorePatterns,
'**/target/*',
'**/test/*.ts'
],
parserOptions: {
...base.parserOptions,
project: [
'./tsconfig.eslint.json'
]
}
};
+5 -5
View File
@@ -10,16 +10,16 @@ jobs:
env:
YARN_ENABLE_SCRIPTS: false
steps:
- uses: dessant/lock-threads@f1a42f0f44eb83361d617a014663e1a76cf282d2
- uses: dessant/lock-threads@c1b35aecc5cdb1a34539d14196df55838bb2f836
with:
github-token: ${{ secrets.GH_PAT_BOT }}
issue-lock-inactive-days: '7'
issue-lock-comment: >
issue-inactive-days: '7'
issue-comment: >
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue
if you think you have a related problem or query.
pr-lock-inactive-days: '2'
pr-lock-comment: >
pr-inactive-days: '2'
pr-comment: >
This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
+1 -1
View File
@@ -22,7 +22,7 @@ jobs:
if: always()
continue-on-error: true
run: |
yarn install --immutable | grep -v 'YN0013'
yarn install --immutable
if [ "${{ matrix.step }}" != "lint" ]; then
./scripts/install-build-deps.sh
fi
+1 -1
View File
@@ -27,6 +27,6 @@ jobs:
node-version: 'lts/*'
- name: build
run: |
yarn install --immutable | grep -v 'YN0013'
yarn install --immutable
./scripts/install-build-deps.sh
yarn ${{ matrix.step }}
-19
View File
@@ -1,19 +0,0 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '35 1/3 * * *'
jobs:
stale:
runs-on: ubuntu-latest
env:
YARN_ENABLE_SCRIPTS: false
steps:
- uses: actions/stale@98ed4cb500039dbcccf4bd9bedada4d0187f2757
with:
repo-token: ${{ secrets.GH_PAT_BOT }}
stale-issue-message: 'This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.'
stale-issue-label: 'stale'
exempt-issue-labels: '-size-l,-size-m,-size-s,-size-xl,-size-xs,[bug]'
days-before-stale: 21
days-before-close: 7
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/dev authors & contributors
// Copyright 2017-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
module.exports = require('@polkadot/dev/config/prettier.cjs');
+4
View File
@@ -0,0 +1,4 @@
{
"eslint.enable": true,
"eslint.experimental.useFlatConfig": true
}
+5
View File
@@ -2,6 +2,11 @@ enableImmutableInstalls: false
enableProgressBars: false
logFilters:
# Discard any "cannot be found in cache" messages
- code: YN0013
level: discard
nodeLinker: node-modules
plugins:
+39
View File
@@ -1,5 +1,44 @@
# CHANGELOG
## 7.2.2 Aug 17, 2023
Changes:
- Adjust cjs exports for consistency
- Adjust usage of `?.` as per (latest) linting rules
## 7.2.1 May 13, 2023
Changes:
- Adjust `cjs/bytes.js` generation to follow `export.<var> = ...` form
- Add `module` to `package.json` export map (ESM-only)
## 7.1.2 Apr 28, 2023
Changes:
- Apply `readonly` specifiers to private class fields where applicable
- Adjust compilation output for `__internal__` class fields
## 7.1.1 Apr 22, 2023
Changes:
- Add `wasm-util` as dependency where `x-randomvalues` is a peer
- Drop support for Node 14 (EOL 30 Apr 2023)
## 7.0.3 Mar 11, 2023
Changes:
- Use consistent `.js` imports in source files (TS moduleResolution)
## 7.0.2 Mar 4, 2023
Changes:
+1 -1
View File
@@ -1,4 +1,4 @@
550 Jaco 7.0.2 (#488)
597 Jaco 7.2.2 (#535)
1 Evgeny Fixed type (#121)
1 Shunfan Zhou Support sr25519 agreement (#209)
1 Steve Degosserie Expose Schnorrkel's VRF capabilities (#170)
-4
View File
@@ -1,4 +0,0 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
module.exports = require('@polkadot/dev/config/babel-config-cjs.cjs');
+8
View File
@@ -0,0 +1,8 @@
// Copyright 2017-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import baseConfig from '@polkadot/dev/config/eslint';
export default [
...baseConfig
];
+12 -11
View File
@@ -1,6 +1,9 @@
{
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/wasm/issues",
"engines": {
"node": ">=18.14"
},
"homepage": "https://github.com/polkadot-js/wasm#readme",
"license": "Apache-2.0",
"packageManager": "yarn@3.2.0",
@@ -11,10 +14,10 @@
},
"sideEffects": false,
"type": "module",
"version": "7.0.2",
"version": "7.2.2",
"versions": {
"git": "7.0.2",
"npm": "7.0.2"
"git": "7.2.2",
"npm": "7.2.2"
},
"workspaces": [
"packages/*"
@@ -36,19 +39,17 @@
"test:js": "yarn test:wasm-crypto:js",
"test:wasm-crypto:deno": "deno test --allow-read --import-map=import_map.json packages/wasm-crypto/test/deno.ts",
"test:wasm-crypto:js": "yarn test:wasm-crypto:js:jest && yarn test:wasm-crypto:js:node",
"test:wasm-crypto:js:jest": "polkadot-dev-run-test --env node --loader ./packages/wasm-crypto/test/loader-build.js test/jest.spec.ts",
"test:wasm-crypto:js:jest": "polkadot-dev-run-test --env node --loader ./packages/wasm-crypto/test/loader-build.js",
"test:wasm-crypto:js:node": "node --no-warnings --loader ./packages/wasm-crypto/test/loader-build.js ./packages/wasm-crypto/test/wasm.js && node --no-warnings --loader ./packages/wasm-crypto/test/loader-build.js ./packages/wasm-crypto/test/asm.js",
"test:wasm-crypto:rust": "cd packages/wasm-crypto && RUST_BACKTRACE=full cargo test --release -- --test-threads=1 --nocapture"
},
"devDependencies": {
"@babel/core": "^7.21.0",
"@polkadot/dev": "^0.69.27",
"@polkadot/util": "^10.4.2",
"@polkadot/x-randomvalues": "^10.4.2",
"@types/node": "^18.14.6",
"fflate": "^0.7.4"
"@polkadot/dev": "^0.76.15",
"@polkadot/util": "^12.3.2",
"@types/node": "^20.5.0",
"fflate": "^0.8.0"
},
"resolutions": {
"typescript": "^4.9.5"
"typescript": "^5.1.6"
}
}
+6 -7
View File
@@ -1,14 +1,12 @@
{
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/wasm/issues",
"contributors": [],
"description": "A bridge layer between JS and Wasm",
"engines": {
"node": ">=14.0.0"
"node": ">=16"
},
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-bridge#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/wasm-bridge",
"repository": {
"directory": "packages/wasm-bridge",
@@ -20,14 +18,15 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "7.0.2",
"version": "7.2.2",
"main": "index.js",
"dependencies": {
"tslib": "^2.5.0"
"@polkadot/wasm-util": "7.2.2",
"tslib": "^2.6.1"
},
"devDependencies": {
"@polkadot/util": "^10.4.2",
"@polkadot/x-randomvalues": "^10.4.2"
"@polkadot/util": "^12.3.2",
"@polkadot/x-randomvalues": "^12.3.2"
},
"peerDependencies": {
"@polkadot/util": "*",
+7 -6
View File
@@ -7,31 +7,32 @@
// then ensures that the internal wasm instance here is available
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import type { BridgeBase, InitFn, InitPromise, WasmBaseInstance, WasmImports } from './types';
import type { BridgeBase, InitFn, InitPromise, WasmBaseInstance, WasmImports } from './types.js';
import { stringToU8a, u8aToString } from '@polkadot/util';
import { Wbg } from './wbg';
import { Wbg } from './wbg.js';
/**
* @name Bridge
* @description
* Creates a bridge between the JS and WASM environments.
*
* For any bridge it is passed an function white is then called internally at the
* For any bridge it is passed an function which is then called internally at the
* time of initialization. This affectively implements the layer between WASM and
* the native environment, providing all the plumbing needed for the Wbg classes.
*/
export class Bridge<C extends WasmBaseInstance> implements BridgeBase<C> {
readonly #createWasm: InitFn<C>;
readonly #heap: unknown[];
readonly #wbg: WasmImports;
#cachegetInt32: Int32Array | null;
#cachegetUint8: Uint8Array | null;
#createWasm: InitFn<C>;
#heap: unknown[];
#heapNext: number;
#wasm: C | null;
#wasmError: string | null;
#wasmPromise: InitPromise<C> | null;
#wbg: WasmImports;
#type: 'asm' | 'wasm' | 'none';
constructor (createWasm: InitFn<C>) {
+2 -2
View File
@@ -1,5 +1,5 @@
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './bridge';
export * from './init';
export * from './bridge.js';
export * from './init.js';
+2 -2
View File
@@ -5,7 +5,7 @@
import { detectPackage } from '@polkadot/util';
import others from './detectOther';
import { packageInfo } from './packageInfo';
import others from './detectOther.js';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, others);
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
// SPDX-License-Identifier: Apache-2.0
import './detectPackage';
import './detectPackage.js';
export * from './bundle';
export * from './bundle.js';
+4 -4
View File
@@ -1,7 +1,7 @@
// Copyright 2019-2023 @polkadot/wasm-bundle authors & contributors
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { InitFn, InitPromise, InitResult, WasmBaseInstance, WasmImports } from './types';
import type { InitFn, InitPromise, InitResult, WasmBaseInstance, WasmImports } from './types.js';
/**
* @name createWasmFn
@@ -11,7 +11,7 @@ import type { InitFn, InitPromise, InitResult, WasmBaseInstance, WasmImports } f
* It will attempt to create a WASM interface first and if this fails or is not available in
* the environment, will fallback to attempting to create an ASM.js interface.
*/
export function createWasmFn <C extends WasmBaseInstance> (root: string, wasmBytes: null | Uint8Array, asmFn: null | ((wbg: WasmImports) => C)): InitFn<C> {
export function createWasmFn <C extends WasmBaseInstance> (root: 'crypto', wasmBytes: null | Uint8Array, asmFn: null | ((wbg: WasmImports) => C)): InitFn<C> {
return async (wbg: WasmImports): InitPromise<C> => {
const result: InitResult<C> = {
error: null,
@@ -20,7 +20,7 @@ export function createWasmFn <C extends WasmBaseInstance> (root: string, wasmByt
};
try {
if (!wasmBytes || !wasmBytes.length) {
if (!wasmBytes?.length) {
throw new Error('No WebAssembly provided for initialization');
} else if (typeof WebAssembly !== 'object' || typeof WebAssembly.instantiate !== 'function') {
throw new Error('WebAssembly is not available in your environment');
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './index';
export * from './index.js';
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-bridge', path: 'auto', type: 'auto', version: '7.0.2' };
export const packageInfo = { name: '@polkadot/wasm-bridge', path: 'auto', type: 'auto', version: '7.2.2' };
+6 -6
View File
@@ -7,7 +7,7 @@ export type WasmImports = Record<string, (...args: never[]) => unknown>;
// Use non-strong types instead of WebAssembly.Memory which may not
// be available as part of the TS environment types (it needs dom)
export type WasmMemory = { buffer: ArrayBuffer };
export interface WasmMemory { buffer: ArrayBuffer }
export declare interface InitResult<C extends WasmBaseInstance> {
error: string | null;
@@ -35,13 +35,13 @@ export interface BridgeBase<C extends WasmBaseInstance> extends InitResult<C> {
resultString (): string;
}
export interface WasmBaseInstance {
memory: WasmMemory;
// wbindgen functions (required and used internally)
export interface WasmBindGen {
__wbindgen_exn_store (a: number): void;
__wbindgen_free (a: number, b: number): void;
__wbindgen_malloc (a: number): number;
__wbindgen_realloc (a: number, b: number, c: number): number;
}
export interface WasmBaseInstance extends WasmBindGen {
memory: WasmMemory;
}
+2 -6
View File
@@ -1,7 +1,7 @@
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { BridgeBase, WasmBaseInstance } from './types';
import type { BridgeBase, WasmBaseInstance } from './types.js';
import { getRandomValues } from '@polkadot/x-randomvalues';
@@ -20,7 +20,7 @@ const DEFAULT_SELF = { crypto: DEFAULT_CRYPTO };
* Internally the implementation does a thin layer into the supplied bridge.
*/
export class Wbg<C extends WasmBaseInstance> {
#bridge: BridgeBase<C>;
readonly #bridge: BridgeBase<C>;
constructor (bridge: BridgeBase<C>) {
this.#bridge = bridge;
@@ -52,25 +52,21 @@ export class Wbg<C extends WasmBaseInstance> {
};
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
__wbg_crypto_968f1772287e2df0 = (_idx: number): number => {
return this.#bridge.addObject(DEFAULT_CRYPTO);
};
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
__wbg_getRandomValues_a3d34b4fee3c2869 = (_idx: number): number => {
return this.#bridge.addObject(DEFAULT_CRYPTO.getRandomValues);
};
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
__wbg_getRandomValues_f5e14ab7ac8e995d = (_arg0: number, ptr: number, len: number): void => {
DEFAULT_CRYPTO.getRandomValues(this.#bridge.getU8a(ptr, len));
};
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
__wbg_randomFillSync_d5bd2d655fdf256a = (_idx: number, _ptr: number, _len: number): never => {
throw new Error('randomFillsync is not available');
+4 -2
View File
@@ -5,6 +5,8 @@
"outDir": "./build",
"rootDir": "./src"
},
"references": [
]
"exclude": [
"**/mod.ts"
],
"references": []
}
+4 -6
View File
@@ -1,14 +1,12 @@
{
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/wasm/issues",
"contributors": [],
"description": "Asm.js content for wasm-crypto",
"engines": {
"node": ">=14.0.0"
"node": ">=16"
},
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-asmjs#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/wasm-crypto-asmjs",
"repository": {
"directory": "packages/wasm-crypto-asmjs",
@@ -17,13 +15,13 @@
},
"sideEffects": false,
"type": "module",
"version": "7.0.2",
"version": "7.2.2",
"main": "index.js",
"dependencies": {
"tslib": "^2.5.0"
"tslib": "^2.6.1"
},
"devDependencies": {
"@polkadot/util": "^10.4.2"
"@polkadot/util": "^12.3.2"
},
"peerDependencies": {
"@polkadot/util": "*"
+1 -1
View File
@@ -2,4 +2,4 @@
// SPDX-License-Identifier: Apache-2.0
export { asmJsInit } from './cjs/data.js';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
@@ -1,6 +1,6 @@
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
// SPDX-License-Identifier: Apache-2.0
const data = require('../data');
const data = require('../data.js');
module.exports = data;
+1 -1
View File
@@ -3,4 +3,4 @@
const asmJsInit = null;
module.exports.asmJsInit = asmJsInit;
exports.asmJsInit = asmJsInit;
@@ -5,7 +5,7 @@
import { detectPackage } from '@polkadot/util';
import others from './detectOther';
import { packageInfo } from './packageInfo';
import others from './detectOther.js';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, others);
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
// SPDX-License-Identifier: Apache-2.0
import './detectPackage';
import './detectPackage.js';
export * from './bundle';
export * from './bundle.js';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './index';
export * from './index.js';
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', path: 'auto', type: 'auto', version: '7.0.2' };
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', path: 'auto', type: 'auto', version: '7.2.2' };
@@ -5,5 +5,8 @@
"outDir": "./build",
"rootDir": "./src"
},
"exclude": [
"**/mod.ts"
],
"references": []
}
+9 -10
View File
@@ -1,14 +1,12 @@
{
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/wasm/issues",
"contributors": [],
"description": "Init handlers for wasm-crypto",
"engines": {
"node": ">=14.0.0"
"node": ">=16"
},
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-init#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/wasm-crypto-init",
"repository": {
"directory": "packages/wasm-crypto-init",
@@ -20,19 +18,20 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "7.0.2",
"version": "7.2.2",
"browser": "wasm.js",
"main": "wasm.js",
"react-native": "asm.js",
"dependencies": {
"@polkadot/wasm-bridge": "7.0.2",
"@polkadot/wasm-crypto-asmjs": "7.0.2",
"@polkadot/wasm-crypto-wasm": "7.0.2",
"tslib": "^2.5.0"
"@polkadot/wasm-bridge": "7.2.2",
"@polkadot/wasm-crypto-asmjs": "7.2.2",
"@polkadot/wasm-crypto-wasm": "7.2.2",
"@polkadot/wasm-util": "7.2.2",
"tslib": "^2.6.1"
},
"devDependencies": {
"@polkadot/util": "^10.4.2",
"@polkadot/x-randomvalues": "^10.4.2"
"@polkadot/util": "^12.3.2",
"@polkadot/x-randomvalues": "^12.3.2"
},
"peerDependencies": {
"@polkadot/util": "*",
+2 -2
View File
@@ -2,12 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
import type { InitFn } from '@polkadot/wasm-bridge/types';
import type { WasmCryptoInstance } from './types';
import type { WasmCryptoInstance } from './types.js';
import { createWasmFn } from '@polkadot/wasm-bridge';
import { asmJsInit } from '@polkadot/wasm-crypto-asmjs';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
/**
* @name createWasm
+2 -2
View File
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
import type { InitFn } from '@polkadot/wasm-bridge/types';
import type { WasmCryptoInstance } from './types';
import type { WasmCryptoInstance } from './types.js';
import { createWasmFn } from '@polkadot/wasm-bridge';
import { asmJsInit } from '@polkadot/wasm-crypto-asmjs';
import { wasmBytes } from '@polkadot/wasm-crypto-wasm';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
/**
* @name createWasm
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './wasm';
export * from './wasm.js';
@@ -5,7 +5,7 @@
import { detectPackage } from '@polkadot/util';
import others from './detectOther';
import { packageInfo } from './packageInfo';
import others from './detectOther.js';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, others);
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './wasm';
export * from './wasm.js';
+2 -2
View File
@@ -2,11 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
import type { InitFn } from '@polkadot/wasm-bridge/types';
import type { WasmCryptoInstance } from './types';
import type { WasmCryptoInstance } from './types.js';
import { createWasmFn } from '@polkadot/wasm-bridge';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
/**
* @name createWasm
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-crypto-init', path: 'auto', type: 'auto', version: '7.0.2' };
export const packageInfo = { name: '@polkadot/wasm-crypto-init', path: 'auto', type: 'auto', version: '7.2.2' };
+2 -2
View File
@@ -2,12 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
import type { InitFn } from '@polkadot/wasm-bridge/types';
import type { WasmCryptoInstance } from './types';
import type { WasmCryptoInstance } from './types.js';
import { createWasmFn } from '@polkadot/wasm-bridge';
import { wasmBytes } from '@polkadot/wasm-crypto-wasm';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
/**
* @name createWasm
@@ -5,6 +5,9 @@
"outDir": "./build",
"rootDir": "./src"
},
"exclude": [
"**/mod.ts"
],
"references": [
{ "path": "../wasm-bridge/tsconfig.build.json" },
{ "path": "../wasm-crypto-asmjs/tsconfig.build.json" },
+5 -7
View File
@@ -1,14 +1,12 @@
{
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/wasm/issues",
"contributors": [],
"description": "Wasm content for wasm-crypto",
"engines": {
"node": ">=14.0.0"
"node": ">=16"
},
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-wasm#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/wasm-crypto-wasm",
"repository": {
"directory": "packages/wasm-crypto-wasm",
@@ -17,14 +15,14 @@
},
"sideEffects": false,
"type": "module",
"version": "7.0.2",
"version": "7.2.2",
"main": "index.js",
"dependencies": {
"@polkadot/wasm-util": "7.0.2",
"tslib": "^2.5.0"
"@polkadot/wasm-util": "7.2.2",
"tslib": "^2.6.1"
},
"devDependencies": {
"@polkadot/util": "^10.4.2"
"@polkadot/util": "^12.3.2"
},
"peerDependencies": {
"@polkadot/util": "*"
+1 -1
View File
@@ -5,7 +5,7 @@ import { base64Decode, unzlibSync } from '@polkadot/wasm-util';
import { bytes, lenIn, lenOut } from './cjs/bytes.js';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
/**
* @name wasmBytes
+3 -3
View File
@@ -1,8 +1,8 @@
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
// SPDX-License-Identifier: Apache-2.0
module.exports.bytes = '';
exports.lenIn = 0;
module.exports.lenIn = 0;
exports.lenOut = 0;
module.exports.lenOut = 0;
exports.bytes = '';
@@ -1,6 +1,6 @@
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
// SPDX-License-Identifier: Apache-2.0
const bytes = require('../bytes');
const bytes = require('../bytes.js');
module.exports = bytes;
@@ -5,7 +5,7 @@
import { detectPackage } from '@polkadot/util';
import others from './detectOther';
import { packageInfo } from './packageInfo';
import others from './detectOther.js';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, others);
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
// SPDX-License-Identifier: Apache-2.0
import './detectPackage';
import './detectPackage.js';
export * from './bundle';
export * from './bundle.js';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './index';
export * from './index.js';
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', path: 'auto', type: 'auto', version: '7.0.2' };
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', path: 'auto', type: 'auto', version: '7.2.2' };
@@ -5,6 +5,9 @@
"outDir": "./build",
"rootDir": "./src"
},
"exclude": [
"**/mod.ts"
],
"references": [
{ "path": "../wasm-util/tsconfig.build.json" }
]
+10 -12
View File
@@ -1,14 +1,12 @@
{
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/wasm/issues",
"contributors": [],
"description": "A wasm interface layer for use by @polkadot/util-crypto",
"engines": {
"node": ">=14.0.0"
"node": ">=16"
},
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/wasm-crypto",
"repository": {
"directory": "packages/wasm-crypto",
@@ -28,19 +26,19 @@
"./initWasmAsm.cjs"
],
"type": "module",
"version": "7.0.2",
"version": "7.2.2",
"main": "index.js",
"dependencies": {
"@polkadot/wasm-bridge": "7.0.2",
"@polkadot/wasm-crypto-asmjs": "7.0.2",
"@polkadot/wasm-crypto-init": "7.0.2",
"@polkadot/wasm-crypto-wasm": "7.0.2",
"@polkadot/wasm-util": "7.0.2",
"tslib": "^2.5.0"
"@polkadot/wasm-bridge": "7.2.2",
"@polkadot/wasm-crypto-asmjs": "7.2.2",
"@polkadot/wasm-crypto-init": "7.2.2",
"@polkadot/wasm-crypto-wasm": "7.2.2",
"@polkadot/wasm-util": "7.2.2",
"tslib": "^2.6.1"
},
"devDependencies": {
"@polkadot/util": "^10.4.2",
"@polkadot/x-randomvalues": "^10.4.2"
"@polkadot/util": "^12.3.2",
"@polkadot/x-randomvalues": "^12.3.2"
},
"peerDependencies": {
"@polkadot/util": "*",
+2 -2
View File
@@ -3,9 +3,9 @@
import type { WasmCryptoInstance } from '@polkadot/wasm-crypto-init/types';
import { bridge, initBridge } from './init';
import { bridge, initBridge } from './init.js';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
export { bridge };
// Removes the first parameter (expected as WasmCryptoInstance) and leaves the
+2 -2
View File
@@ -5,7 +5,7 @@
import { detectPackage } from '@polkadot/util';
import others from './detectOther';
import { packageInfo } from './packageInfo';
import others from './detectOther.js';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, others);
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import './detectPackage';
import './detectPackage.js';
export * from './bundle';
export * from './bundle.js';
+1 -1
View File
@@ -3,7 +3,7 @@
import { createWasm } from '@polkadot/wasm-crypto-init/none';
import { initBridge } from './init';
import { initBridge } from './init.js';
/**
* @name initWasm
+1 -1
View File
@@ -3,7 +3,7 @@
import { createWasm } from '@polkadot/wasm-crypto-init/asm';
import { initBridge } from './init';
import { initBridge } from './init.js';
/**
* @name initWasm
+1 -1
View File
@@ -3,7 +3,7 @@
import { createWasm } from '@polkadot/wasm-crypto-init/wasm';
import { initBridge } from './init';
import { initBridge } from './init.js';
/**
* @name initWasm
+1 -1
View File
@@ -3,7 +3,7 @@
import { createWasm } from '@polkadot/wasm-crypto-init/both';
import { initBridge } from './init';
import { initBridge } from './init.js';
/**
* @name initWasm
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './index';
export * from './index.js';
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-crypto', path: 'auto', type: 'auto', version: '7.0.2' };
export const packageInfo = { name: '@polkadot/wasm-crypto', path: 'auto', type: 'auto', version: '7.2.2' };
+20
View File
@@ -1,8 +1,13 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global it */
import { assert, u8aToHex } from '@polkadot/util';
/**
* @param {*} wasm
*/
export function bip39Generate (wasm) {
it('generates a bip39 phrase', () => {
const res = wasm.bip39Generate(21);
@@ -13,6 +18,9 @@ export function bip39Generate (wasm) {
});
}
/**
* @param {*} wasm
*/
export function bip39GenerateSubsequent (wasm) {
it('generates different subsequent mnemonics', () => {
const val1 = wasm.bip39Generate(24);
@@ -25,6 +33,9 @@ export function bip39GenerateSubsequent (wasm) {
});
}
/**
* @param {*} wasm
*/
export function bip39Validate (wasm) {
it('validates a created mnemonic', () => {
const res = wasm.bip39Validate(wasm.bip39Generate(12));
@@ -35,6 +46,9 @@ export function bip39Validate (wasm) {
});
}
/**
* @param {*} wasm
*/
export function bip39ToEntropy (wasm) {
it('creates correct entropy for a known mnemonic', () => {
const res = u8aToHex(wasm.bip39ToEntropy('legal winner thank year wave sausage worth useful legal winner thank yellow'));
@@ -45,6 +59,9 @@ export function bip39ToEntropy (wasm) {
});
}
/**
* @param {*} wasm
*/
export function bip39ToMiniSecret (wasm) {
it('creates the correct minisecret from a mnemonic', () => {
const res = u8aToHex(wasm.bip39ToMiniSecret('legal winner thank year wave sausage worth useful legal winner thank yellow', 'Substrate'));
@@ -55,6 +72,9 @@ export function bip39ToMiniSecret (wasm) {
});
}
/**
* @param {*} wasm
*/
export function bip39ToSeed (wasm) {
it('creates the correct seed for a mnemonic', () => {
const res = u8aToHex(wasm.bip39ToSeed('seed sock milk update focus rotate barely fade car face mechanic mercy', ''));
+24 -4
View File
@@ -1,20 +1,31 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global it */
import crypto from 'crypto';
import { assert, hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';
/** @internal */
/**
* @internal
* @param {*} pair
*/
function extractKeys (pair) {
return [pair, pair.slice(32), pair.slice(0, 32)];
}
/** @internal */
/**
* @internal
* @param {*} wasm
*/
function randomPair (wasm) {
return extractKeys(wasm.ed25519KeypairFromSeed(crypto.randomBytes(32)));
}
/**
* @param {*} wasm
*/
export function ed25519PairFromSeed (wasm) {
it('creates a known pair from a known seed', () => {
const [pair, pk, sk] = extractKeys(wasm.ed25519KeypairFromSeed(stringToU8a('12345678901234567890123456789012')));
@@ -22,12 +33,15 @@ export function ed25519PairFromSeed (wasm) {
// console.log('\tSEC', u8aToHex(sk));
// console.log('\tPUB', u8aToHex(pk));
assert(u8aToHex(sk) === '0x3132333435363738393031323334353637383930313233343536373839303132');
assert(u8aToHex(pk) === '0x2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee');
assert(u8aToHex(sk) === '0x3132333435363738393031323334353637383930313233343536373839303132', 'Secretkey does not match');
assert(u8aToHex(pk) === '0x2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee', 'Public key does not match');
assert(u8aToHex(pair) === '0x31323334353637383930313233343536373839303132333435363738393031322f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee', 'ERROR: pairFromSeed() does not match');
});
}
/**
* @param {*} wasm
*/
export function ed25519SignAndVerify (wasm) {
it('signs and verifies', () => {
const [, pk, sk] = randomPair(wasm);
@@ -41,6 +55,9 @@ export function ed25519SignAndVerify (wasm) {
});
}
/**
* @param {*} wasm
*/
export function ed25519VerifyExisting (wasm) {
it('verifies a known signature', () => {
const isValid = wasm.ed25519Verify(hexToU8a('0x90588f3f512496f2dd40571d162e8182860081c74e2085316e7c4396918f07da412ee029978e4dd714057fe973bd9e7d645148bf7b66680d67c93227cde95202'), stringToU8a('this is a message'), hexToU8a('0x2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee'));
@@ -51,6 +68,9 @@ export function ed25519VerifyExisting (wasm) {
});
}
/**
* @param {*} wasm
*/
export function ed25519Benchmark (wasm) {
it('runs a verification benchamark', () => {
const MESSAGE = stringToU8a('this is a message');
+32
View File
@@ -1,8 +1,13 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global it */
import { assert, stringToU8a, u8aToHex } from '@polkadot/util';
/**
* @param {*} wasm
*/
export function blake2bHash (wasm) {
it('creates a known blake2b hash', () => {
const hash = u8aToHex(wasm.blake2b(stringToU8a('abc'), new Uint8Array(), 64));
@@ -13,6 +18,9 @@ export function blake2bHash (wasm) {
});
}
/**
* @param {*} wasm
*/
export function hmacSha256 (wasm) {
it('creates a known hmacSha256', () => {
const hash = u8aToHex(wasm.hmacSha256(stringToU8a('secret'), stringToU8a('some message')));
@@ -23,6 +31,9 @@ export function hmacSha256 (wasm) {
});
}
/**
* @param {*} wasm
*/
export function hmacSha512 (wasm) {
it('creates a known hmacSha512', () => {
const hash = u8aToHex(wasm.hmacSha512(stringToU8a('secret'), stringToU8a('some message')));
@@ -33,6 +44,9 @@ export function hmacSha512 (wasm) {
});
}
/**
* @param {*} wasm
*/
export function keccak256 (wasm) {
it('creates a known keccak256 hash', () => {
const hash = u8aToHex(wasm.keccak256(stringToU8a('test value')));
@@ -43,6 +57,9 @@ export function keccak256 (wasm) {
});
}
/**
* @param {*} wasm
*/
export function keccak512 (wasm) {
it('creates a known keccak512 hash', () => {
const hash = u8aToHex(wasm.keccak512(stringToU8a('test')));
@@ -53,6 +70,9 @@ export function keccak512 (wasm) {
});
}
/**
* @param {*} wasm
*/
export function pbkdf2Hash (wasm) {
it('creates a known pbkdf2 hash', () => {
const hash = u8aToHex(wasm.pbkdf2(stringToU8a('hello world'), stringToU8a('this is a salt'), 2048));
@@ -63,6 +83,9 @@ export function pbkdf2Hash (wasm) {
});
}
/**
* @param {*} wasm
*/
export function scryptHash (wasm) {
it('creates a known scrypt hash', () => {
const hash = u8aToHex(wasm.scrypt(stringToU8a('password'), stringToU8a('salt'), 14, 8, 1));
@@ -73,6 +96,9 @@ export function scryptHash (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sha256Hash (wasm) {
it('creates a known sha256 hash', () => {
const hash = u8aToHex(wasm.sha256(stringToU8a('hello world')));
@@ -83,6 +109,9 @@ export function sha256Hash (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sha512Hash (wasm) {
it('creates a known sha512 hash', () => {
const hash = u8aToHex(wasm.sha512(stringToU8a('hello world')));
@@ -93,6 +122,9 @@ export function sha512Hash (wasm) {
});
}
/**
* @param {*} wasm
*/
export function twoxHash (wasm) {
it('creates a known twox hash', () => {
const hash64 = u8aToHex(wasm.twox(stringToU8a('abc'), 1));
+20 -2
View File
@@ -1,6 +1,8 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global describe */
import { assert } from '@polkadot/util';
import * as bip39 from './bip39.js';
@@ -23,6 +25,10 @@ export const tests = {
vrf
};
/**
* @param {string} name
* @param {*} wasm
*/
export async function initRun (name, wasm) {
const result = await wasm.waitReady();
@@ -33,7 +39,12 @@ export async function initRun (name, wasm) {
return result;
}
/**
* @param {string} name
* @param {*} wasm
*/
export function runAll (name, wasm) {
/** @type {string[]} */
const failed = [];
let count = 0;
@@ -51,7 +62,6 @@ export function runAll (name, wasm) {
try {
console.time(timerId);
console.log();
// console.log(timerId);
test(wasm);
@@ -71,20 +81,28 @@ export function runAll (name, wasm) {
}
}
/**
* @param {string} type
* @param {*} wasm
*/
export function runUnassisted (type, wasm) {
console.log(`\n*** ${type}: Running tests`);
// for these we are pass-through describe and it handlers
// For these we are pass-through describe and it handlers
// @ts-expect-error We are hacking this, so expect TS to be unhappy...
globalThis.describe = (name, fn) => {
console.log('\n', name);
// We expect this to be handled top-level, in the test itself
// eslint-disable-next-line @typescript-eslint/no-floating-promises
fn();
};
// @ts-expect-error We are hacking this, so expect TS to be unhappy...
globalThis.it = (name, fn) => {
console.log(`\t${name}`);
// We expect this to be handled top-level, in the test itself
// eslint-disable-next-line @typescript-eslint/no-floating-promises
fn();
};
@@ -1,8 +1,13 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global it */
import { assert, hexToU8a, u8aToHex } from '@polkadot/util';
/**
* @param {*} wasm
*/
export function secp256k1Compress (wasm) {
it('compresses a known publicKey', () => {
const pubkey = '0x04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af';
@@ -14,6 +19,9 @@ export function secp256k1Compress (wasm) {
});
}
/**
* @param {*} wasm
*/
export function secp256k1Expand (wasm) {
it('expands a known compressed key', () => {
const pubkey = '0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077';
@@ -25,6 +33,9 @@ export function secp256k1Expand (wasm) {
});
}
/**
* @param {*} wasm
*/
export function secp256k1FromSeed1 (wasm) {
it('creates a known pair from seed (1)', () => {
const seckey = '0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae';
@@ -36,6 +47,9 @@ export function secp256k1FromSeed1 (wasm) {
});
}
/**
* @param {*} wasm
*/
export function secp256k1FromSeed2 (wasm) {
it('creates a known pair from seed (2)', () => {
// https://github.com/polkadot-js/wasm/issues/307
@@ -60,6 +74,9 @@ export function secp256k1FromSeed2 (wasm) {
});
}
/**
* @param {*} wasm
*/
export function secp256k1Recover (wasm) {
it('recovers a publicKey from signature', () => {
const sig = '0x7505f2880114da51b3f5d535f8687953c0ab9af4ab81e592eaebebf53b728d2b6dfd9b5bcd70fee412b1f31360e7c2774009305cb84fc50c1d0ff8034dfa5fff';
@@ -72,6 +89,9 @@ export function secp256k1Recover (wasm) {
});
}
/**
* @param {*} wasm
*/
export function secp256k1Sign (wasm) {
it('creates a known signature', () => {
const sec = '0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae';
+48 -4
View File
@@ -1,20 +1,31 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global it */
import crypto from 'crypto';
import { assert, hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';
/** @internal */
/**
* @internal
* @param {*} pair
*/
function extractKeys (pair) {
return [pair, pair.slice(64), pair.slice(0, 64)];
}
/** @internal */
/**
* @internal
* @param {*} wasm
*/
function randomPair (wasm) {
return extractKeys(wasm.sr25519KeypairFromSeed(crypto.randomBytes(32)));
}
/**
* @param {*} wasm
*/
export function sr25519PairFromSeed (wasm) {
it('creates a known pair from a known seed', () => {
const pair = wasm.sr25519KeypairFromSeed(stringToU8a('12345678901234567890123456789012'));
@@ -26,6 +37,9 @@ export function sr25519PairFromSeed (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sr25519DevFromSeed (wasm) {
it('creates a known development pair', () => {
const pair = wasm.sr25519KeypairFromSeed(hexToU8a('0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e'));
@@ -37,6 +51,9 @@ export function sr25519DevFromSeed (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sr25519VerifyExisting (wasm) {
it('verifies a known signature', () => {
const PK = hexToU8a('0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d');
@@ -51,6 +68,9 @@ export function sr25519VerifyExisting (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sr25519SignDeterministic (wasm) {
it('creates non-deterministic signatures', () => {
const [, pk, sk] = randomPair(wasm);
@@ -64,6 +84,9 @@ export function sr25519SignDeterministic (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sr25519SignAndVerify (wasm) {
it('verifies a created signature', () => {
const [, pk, sk] = randomPair(wasm);
@@ -77,6 +100,9 @@ export function sr25519SignAndVerify (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sr25519DeriveHard (wasm) {
it('derives using a hard path', () => {
const [pair] = randomPair(wasm);
@@ -85,10 +111,13 @@ export function sr25519DeriveHard (wasm) {
// console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
// console.log('\tPUB', u8aToHex(derived.slice(64)));
assert(derived.length === 96);
assert(derived.length === 96, 'Derived key length mismatch');
});
}
/**
* @param {*} wasm
*/
export function sr25519DeriveHardKnown (wasm) {
it('derives a known hard key', () => {
const derived = wasm.sr25519DeriveKeypairHard(hexToU8a('0x28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca3446ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x14416c6963650000000000000000000000000000000000000000000000000000'));
@@ -101,6 +130,9 @@ export function sr25519DeriveHardKnown (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sr25519DeriveSoft (wasm) {
it('derives using a soft path', () => {
const [pair] = randomPair(wasm);
@@ -109,10 +141,13 @@ export function sr25519DeriveSoft (wasm) {
// console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
// console.log('\tPUB', u8aToHex(derived.slice(64)));
assert(derived.length === 96);
assert(derived.length === 96, 'Derived key length mismatch');
});
}
/**
* @param {*} wasm
*/
export function sr25519DeriveSoftKnown (wasm) {
it('derives a known soft key', () => {
const derived = wasm.sr25519DeriveKeypairSoft(hexToU8a('0x28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca3446ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000'));
@@ -125,6 +160,9 @@ export function sr25519DeriveSoftKnown (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sr25519DeriveSoftPubkey (wasm) {
it('derives a known soft publicKey', () => {
const derived = u8aToHex(wasm.sr25519DerivePublicSoft(hexToU8a('0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000')));
@@ -135,6 +173,9 @@ export function sr25519DeriveSoftPubkey (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sr25519KeyAgreement (wasm) {
it('allows for agreements', () => {
const pair1 = wasm.sr25519KeypairFromSeed(hexToU8a('0x3b44c558f9a8f3dc9690d53088558c1ba2529b677e316c6054d1852595b004af'));
@@ -154,6 +195,9 @@ export function sr25519KeyAgreement (wasm) {
});
}
/**
* @param {*} wasm
*/
export function sr25519Benchmark (wasm) {
it('runs a verification benchmark', () => {
const MESSAGE = stringToU8a('this is a message');
+19
View File
@@ -1,18 +1,31 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global it */
import crypto from 'crypto';
import { assert, stringToU8a, u8aToHex } from '@polkadot/util';
/**
* @internal
* @param {*} pair
*/
function extractKeys (pair) {
return [pair, pair.slice(64), pair.slice(0, 64)];
}
/**
* @internal
* @param {*} wasm
*/
function randomPair (wasm) {
return extractKeys(wasm.sr25519KeypairFromSeed(crypto.randomBytes(32)));
}
/**
* @param {*} wasm
*/
export function vrfSignAndVerifyCompat (wasm) {
it('can sign and verify (1)', () => {
const [, pk, sk] = randomPair(wasm);
@@ -26,6 +39,9 @@ export function vrfSignAndVerifyCompat (wasm) {
});
}
/**
* @param {*} wasm
*/
export function vrfSignAndVerify (wasm) {
it('can sign and verify (2)', () => {
const [, pk, sk] = randomPair(wasm);
@@ -39,6 +55,9 @@ export function vrfSignAndVerify (wasm) {
});
}
/**
* @param {*} wasm
*/
export function vrfSignAndVerifyDeterministic (wasm) {
it('has non-deterministic outputs', () => {
const [,, sk] = randomPair(wasm);
+15 -3
View File
@@ -1,13 +1,25 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
// This is a Deno file, so we can allow .ts imports
/* eslint-disable import/extensions */
// NOTE We don't use ts-expect-error here since the build folder may or may
// not exist (so the error may or may not be there)
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore This should only run against the compiled ouput, where this should exist
import * as wasm from '../build-deno/mod.ts';
import { initRun, tests } from './all/index.js';
declare const globalThis;
type Tests = Record<string, (wasm: unknown) => void>;
declare const globalThis: {
it: (name: string, fn: () => void) => unknown;
};
declare const Deno: {
test: (name: string, test: () => unknown) => unknown;
}
};
await initRun('wasm', wasm);
@@ -15,7 +27,7 @@ await initRun('wasm', wasm);
globalThis.it = (name: string, fn: () => void) => Deno.test(name, () => fn());
Object
.entries<{ [key: string]: (wasm: unknown) => void }>(tests)
.entries<Tests>(tests)
.forEach(([describeName, tests]) => {
console.log('***', describeName);
+8 -4
View File
@@ -1,9 +1,13 @@
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
// eslint-disable-next-line spaced-comment
/// <reference types="@polkadot/dev/node/test/node" />
/// <reference types="@polkadot/dev-test/globals.d.ts" />
// NOTE We don't use ts-expect-error here since the build folder may or may
// not exist (so the error may or may not be there)
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore This should only run against the compiled ouput, where this should exist
import * as wasm from '../build/index.js';
import { initRun, tests } from './all/index.js';
@@ -11,9 +15,9 @@ describe('wasm-crypto', (): void => {
beforeAll(() => initRun('wasm', wasm));
for (const name of Object.keys(tests)) {
describe(name, (): void => {
describe(`${name}`, (): void => {
Object
.values<(wasm: unknown) => void>(tests[name])
.values<(wasm: unknown) => void>(tests[name as keyof typeof tests])
.forEach((fn) => fn(wasm));
});
}
+9 -2
View File
@@ -5,9 +5,16 @@ import path from 'node:path';
import process from 'node:process';
import { pathToFileURL } from 'node:url';
// Adjusts the resolver to point to the build output
/**
* Adjusts the resolver to point to the build output
*
* @param {*} specifier
* @param {*} context
* @param {*} nextResolve
* @returns {*}
*/
export function resolve (specifier, context, nextResolve) {
if (/^@polkadot\/wasm-/.test(specifier)) {
if (specifier.startsWith('@polkadot/wasm-')) {
const parts = specifier.split(/[\\/]/);
return {
+2 -1
View File
@@ -6,7 +6,8 @@
"rootDir": "./src"
},
"exclude": [
"**/test/*.ts"
"**/mod.ts",
"**/test/**/*"
],
"references": [
{ "path": "../wasm-bridge/tsconfig.build.json" },
+16
View File
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "..",
"outDir": "./build",
"rootDir": "./test",
"emitDeclarationOnly": false,
"noEmit": true
},
"include": [
"**/test/**/*"
],
"references": [
{ "path": "../wasm-crypto/tsconfig.build.json" }
]
}
+4 -6
View File
@@ -1,14 +1,12 @@
{
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/wasm/issues",
"contributors": [],
"description": "Utilities used exclusively inside Wasm decoding",
"engines": {
"node": ">=14.0.0"
"node": ">=16"
},
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-util#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/wasm-util",
"repository": {
"directory": "packages/wasm-util",
@@ -20,13 +18,13 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "7.0.2",
"version": "7.2.2",
"main": "index.js",
"dependencies": {
"tslib": "^2.5.0"
"tslib": "^2.6.1"
},
"devDependencies": {
"@polkadot/util": "^10.4.2"
"@polkadot/util": "^12.3.2"
},
"peerDependencies": {
"@polkadot/util": "*"
+46
View File
@@ -0,0 +1,46 @@
// Copyright 2019-2023 @polkadot/wasm-util authors & contributors
// SPDX-License-Identifier: Apache-2.0
/// <reference types="@polkadot/dev-test/globals.d.ts" />
import { base64Decode } from './base64.js';
const TESTS = [
{
// hello world Приветствую ми 你好
base64: 'aGVsbG8gd29ybGQg0J/RgNC40LLQtdGC0YHRgtCy0YPRjiDQvNC4IOS9oOWlvQ==',
output: 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=',
output: new Uint8Array([226, 156, 147, 32, 195, 160, 32, 108, 97, 32, 109, 111, 100, 101])
},
{
// Hello World!
base64: 'SGVsbG8gV29ybGQh',
output: new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])
},
{
base64: 'AA==',
output: new Uint8Array([0])
},
{
base64: 'AAA=',
output: new Uint8Array([0, 0])
},
{
base64: 'AAAA',
output: new Uint8Array([0, 0, 0])
}
];
describe('base64Decode', (): void => {
for (const { base64, output } of TESTS) {
it(`decodes ${base64}`, (): void => {
expect(
base64Decode(base64, new Uint8Array(output.length))
).toEqual(output);
});
}
});
+2 -3
View File
@@ -9,7 +9,7 @@ const map = new Array<number>(256);
// We use charCodeAt for access here and in the decoder loop - this is faster
// on lookups (array + numbers) and also faster than accessing the specific
// character via data[i]
for (let i = 0; i < chr.length; i++) {
for (let i = 0, count = chr.length; i < count; i++) {
map[chr.charCodeAt(i)] = i;
}
@@ -25,12 +25,11 @@ for (let i = 0; i < chr.length; i++) {
* of optimizations based on this - checking output position instead of chars.
*/
export function base64Decode (data: string, out: Uint8Array): Uint8Array {
const len = out.length;
let byte = 0;
let bits = 0;
let pos = -1;
for (let i = 0; pos < len; i++) {
for (let i = 0, count = out.length; pos < count; i++) {
// each character represents 6 bits
byte = (byte << 6) | map[data.charCodeAt(i)];
+3 -3
View File
@@ -1,6 +1,6 @@
// Copyright 2019-2023 @polkadot/wasm-util authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { base64Decode } from './base64';
export { unzlibSync } from './fflate';
export { packageInfo } from './packageInfo';
export { base64Decode } from './base64.js';
export { unzlibSync } from './fflate.js';
export { packageInfo } from './packageInfo.js';
+2 -2
View File
@@ -5,7 +5,7 @@
import { detectPackage } from '@polkadot/util';
import others from './detectOther';
import { packageInfo } from './packageInfo';
import others from './detectOther.js';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, others);
+8 -7
View File
@@ -12,21 +12,22 @@
// - https://github.com/polkadot-js/api/issues/2963
// - https://github.com/101arrowz/fflate/issues/17
//
// Only tweaks make here are some TS adjustments (we use strict null checks), the code is otherwise as-is with
// only the single required function provided (compression is still being done in the build with fflate)
// Only tweaks made here are some TS adjustments (we use strict null checks),
// the code is otherwise as-is with only the single required function provided
// (compression is still being done in the build with fflate)
/* eslint-disable */
// inflate state
type InflateState = {
// lmap
l?: Uint16Array;
l?: Uint16Array | undefined;
// dmap
d?: Uint16Array;
d?: Uint16Array | undefined;
// lbits
m?: number;
m?: number | undefined;
// dbits
n?: number;
n?: number | undefined;
// final
f?: number;
// pos
@@ -170,7 +171,7 @@ const slc = <T extends Uint8Array | Uint16Array | Uint32Array>(v: T, s: number,
// find max of array
const max = (a: Uint8Array | number[]) => {
let m = a[0];
for (let i = 1; i < a.length; ++i) {
for (let i = 1, count = a.length; i < count; ++i) {
if (a[i] > m) m = a[i];
}
return m;
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2019-2023 @polkadot/wasm-util authors & contributors
// SPDX-License-Identifier: Apache-2.0
import './detectPackage';
import './detectPackage.js';
export * from './bundle';
export * from './bundle.js';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2019-2023 @polkadot/wasm-util authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './index';
export * from './index.js';
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-util', path: 'auto', type: 'auto', version: '7.0.2' };
export const packageInfo = { name: '@polkadot/wasm-util', path: 'auto', type: 'auto', version: '7.2.2' };
+4
View File
@@ -5,5 +5,9 @@
"outDir": "./build",
"rootDir": "./src"
},
"exclude": [
"**/mod.ts",
"**/*.spec.ts",
],
"references": []
}
+16
View File
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "..",
"outDir": "./build",
"rootDir": "./src",
"emitDeclarationOnly": false,
"noEmit": true
},
"include": [
"**/*.spec.ts"
],
"references": [
{ "path": "../wasm-util/tsconfig.build.json" }
]
}
+1 -1
View File
@@ -45,7 +45,7 @@ cp $ASM $DENO_ASM
# cleanup the generated asm, converting to cjs
sed -i -e '/import {/d' $ASM
sed -i -e '1,/var retasmFunc = /!d' $ASM
sed -i -e 's/var retasmFunc = .*/const asmJsInit = (wbg) => asmFunc(wbg);\n\nmodule.exports = { asmJsInit };/g' $ASM
sed -i -e 's/var retasmFunc = .*/exports.asmJsInit = (wbg) => asmFunc(wbg);/g' $ASM
# same as the cjs version, this time for deno
sed -i -e '/import {/d' $DENO_ASM
+11 -10
View File
@@ -1,16 +1,17 @@
// Copyright 2019-2023 @polkadot/wasm authors & contributors
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { zlibSync } from 'fflate/node';
import fs from 'fs';
import fs from 'node:fs';
import { formatNumber } from '@polkadot/util';
const DIR_DENO = `./${process.env.PKG_NAME}-wasm/build-deno/deno`;
const DIR_CJS = `./${process.env.PKG_NAME}-wasm/build/cjs`;
const HDR = `// Copyright 2019-${new Date().getFullYear()} @polkadot/${process.env.PKG_NAME}-wasm authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\n// Generated as part of the build, do not edit\n`;
const PKG_NAME = process.env['PKG_NAME'];
const DIR_DENO = `./${PKG_NAME}-wasm/build-deno/deno`;
const DIR_CJS = `./${PKG_NAME}-wasm/build/cjs`;
const HDR = `// Copyright 2019-${new Date().getFullYear()} @polkadot/${PKG_NAME}-wasm authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\n// Generated as part of the build, do not edit\n`;
const data = fs.readFileSync(`./${process.env.PKG_NAME}/build-wasm/wasm_opt.wasm`);
const data = fs.readFileSync(`./${PKG_NAME}/build-wasm/wasm_opt.wasm`);
const compressed = Buffer.from(zlibSync(data, { level: 9 }));
const base64 = compressed.toString('base64');
@@ -19,11 +20,11 @@ console.log(`*** Compressed WASM: in=${formatNumber(data.length)}, out=${formatN
fs.mkdirSync(DIR_DENO, { recursive: true });
fs.writeFileSync(`${DIR_CJS}/bytes.js`, `${HDR}
const lenIn = ${compressed.length};
const lenOut = ${data.length};
const bytes = '${base64}';
exports.lenIn = ${compressed.length};
module.exports = { bytes, lenIn, lenOut };
exports.lenOut = ${data.length};
exports.bytes = '${base64}';
`);
fs.writeFileSync(`${DIR_DENO}/bytes.js`, `${HDR}
+13 -14
View File
@@ -3,19 +3,18 @@
"compilerOptions": {
"composite": true,
"paths": {
"@polkadot/wasm-bridge": ["wasm-bridge/src"],
"@polkadot/wasm-bridge/*": ["wasm-bridge/src/*"],
"@polkadot/wasm-crypto-asmjs": ["wasm-crypto-asmjs/src"],
"@polkadot/wasm-crypto-asmjs/*": ["wasm-crypto-asmjs/src/*"],
"@polkadot/wasm-crypto-wasm": ["wasm-crypto-wasm/src"],
"@polkadot/wasm-crypto-wasm/*": ["wasm-crypto-wasm/src/*"],
"@polkadot/wasm-crypto-init": ["wasm-crypto-init/src/wasm"],
"@polkadot/wasm-crypto-init/*": ["wasm-crypto-init/src/*"],
"@polkadot/wasm-crypto": ["wasm-crypto/src"],
"@polkadot/wasm-util": ["wasm-util/src"],
"@polkadot/wasm-util/*": ["wasm-util/src/*"],
},
"skipLibCheck": true,
"target": "es2020"
"@polkadot/wasm-bridge": ["wasm-bridge/src/index.ts"],
"@polkadot/wasm-bridge/*": ["wasm-bridge/src/*.ts"],
"@polkadot/wasm-crypto-asmjs": ["wasm-crypto-asmjs/src/index.ts"],
"@polkadot/wasm-crypto-asmjs/*": ["wasm-crypto-asmjs/src/*.ts"],
"@polkadot/wasm-crypto-wasm": ["wasm-crypto-wasm/src/index.ts"],
"@polkadot/wasm-crypto-wasm/*": ["wasm-crypto-wasm/src/*.ts"],
"@polkadot/wasm-crypto-init": ["wasm-crypto-init/src/wasm.ts"],
"@polkadot/wasm-crypto-init/*": ["wasm-crypto-init/src/*.ts"],
"@polkadot/wasm-crypto": ["wasm-crypto/src/index.ts"],
"@polkadot/wasm-crypto/*": ["wasm-crypto/src/*.ts"],
"@polkadot/wasm-util": ["wasm-util/src/index.ts"],
"@polkadot/wasm-util/*": ["wasm-util/src/*.ts"]
}
}
}
+4 -1
View File
@@ -4,10 +4,13 @@
},
"files": [],
"references": [
{ "path": "./packages/wasm-bridge/tsconfig.build.json" },
{ "path": "./packages/wasm-crypto/tsconfig.build.json" },
{ "path": "./packages/wasm-crypto/tsconfig.spec.json" },
{ "path": "./packages/wasm-crypto-init/tsconfig.build.json" },
{ "path": "./packages/wasm-crypto-asmjs/tsconfig.build.json" },
{ "path": "./packages/wasm-crypto-wasm/tsconfig.build.json" },
{ "path": "./packages/wasm-util/tsconfig.build.json" }
{ "path": "./packages/wasm-util/tsconfig.build.json" },
{ "path": "./packages/wasm-util/tsconfig.spec.json" }
]
}
+4 -1
View File
@@ -7,7 +7,10 @@
"include": [
"packages/**/src/**/*",
"packages/**/test/**/*",
"scripts/**/*"
"scripts/**/*",
".prettierrc.cjs",
"eslint.config.js",
"rollup.config.js"
],
"exclude": [
"**/node_modules/**/*"
+3 -1
View File
@@ -5,7 +5,9 @@
"composite": false
},
"include": [
"packages/**/src/**/*"
"packages/**/src/**/*",
"packages/**/test/**/*",
"scripts/**/*"
],
"exclude": [
"**/node_modules/**/*"
+1275 -2820
View File
File diff suppressed because it is too large Load Diff