@pezkuwi/util-crypto 14.0.4 → 14.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./cjs/packageDetect.js"
21
21
  ],
22
22
  "type": "module",
23
- "version": "14.0.4",
23
+ "version": "14.0.5",
24
24
  "main": "./cjs/index.js",
25
25
  "module": "./index.js",
26
26
  "browser": {
@@ -2041,17 +2041,17 @@
2041
2041
  "dependencies": {
2042
2042
  "@noble/curves": "^1.3.0",
2043
2043
  "@noble/hashes": "^1.3.3",
2044
- "@pezkuwi/networks": "14.0.1",
2045
- "@pezkuwi/util": "14.0.1",
2044
+ "@pezkuwi/networks": "14.0.5",
2045
+ "@pezkuwi/util": "14.0.5",
2046
2046
  "@pezkuwi/wasm-crypto": "^7.5.3",
2047
2047
  "@pezkuwi/wasm-util": "^7.5.3",
2048
- "@pezkuwi/x-bigint": "14.0.1",
2049
- "@pezkuwi/x-randomvalues": "14.0.1",
2048
+ "@pezkuwi/x-bigint": "14.0.5",
2049
+ "@pezkuwi/x-randomvalues": "14.0.5",
2050
2050
  "@scure/base": "^1.1.7",
2051
2051
  "@scure/sr25519": "^0.2.0",
2052
2052
  "tslib": "^2.8.0"
2053
2053
  },
2054
2054
  "peerDependencies": {
2055
- "@pezkuwi/util": "14.0.1"
2055
+ "@pezkuwi/util": "14.0.5"
2056
2056
  }
2057
2057
  }
package/bridge.d.ts DELETED
@@ -1,82 +0,0 @@
1
- import type { BridgeBase, InitFn, WasmBaseInstance } from './types.js';
2
- /**
3
- * @name Bridge
4
- * @description
5
- * Creates a bridge between the JS and WASM environments.
6
- *
7
- * For any bridge it is passed an function which is then called internally at the
8
- * time of initialization. This affectively implements the layer between WASM and
9
- * the native environment, providing all the plumbing needed for the Wbg classes.
10
- */
11
- export declare class Bridge<C extends WasmBaseInstance> implements BridgeBase<C> {
12
- #private;
13
- constructor(createWasm: InitFn<C>);
14
- /** @description Returns the init error */
15
- get error(): string | null;
16
- /** @description Returns the init type */
17
- get type(): 'asm' | 'wasm' | 'none';
18
- /** @description Returns the created wasm interface */
19
- get wasm(): C | null;
20
- /** @description Performs the wasm initialization */
21
- init(createWasm?: InitFn<C>): Promise<C | null>;
22
- /**
23
- * @internal
24
- * @description Gets an object from the heap
25
- */
26
- getObject(idx: number): unknown;
27
- /**
28
- * @internal
29
- * @description Removes an object from the heap
30
- */
31
- dropObject(idx: number): void;
32
- /**
33
- * @internal
34
- * @description Retrieves and removes an object to the heap
35
- */
36
- takeObject(idx: number): unknown;
37
- /**
38
- * @internal
39
- * @description Adds an object to the heap
40
- */
41
- addObject(obj: unknown): number;
42
- /**
43
- * @internal
44
- * @description Retrieve an Int32 in the WASM interface
45
- */
46
- getInt32(): Int32Array;
47
- /**
48
- * @internal
49
- * @description Retrieve an Uint8Array in the WASM interface
50
- */
51
- getUint8(): Uint8Array;
52
- /**
53
- * @internal
54
- * @description Retrieves an Uint8Array in the WASM interface
55
- */
56
- getU8a(ptr: number, len: number): Uint8Array;
57
- /**
58
- * @internal
59
- * @description Retrieves a string in the WASM interface
60
- */
61
- getString(ptr: number, len: number): string;
62
- /**
63
- * @internal
64
- * @description Allocates an Uint8Array in the WASM interface
65
- */
66
- allocU8a(arg: Uint8Array): [number, number];
67
- /**
68
- * @internal
69
- * @description Allocates a string in the WASM interface
70
- */
71
- allocString(arg: string): [number, number];
72
- /**
73
- * @internal
74
- * @description Retrieves an Uint8Array from the WASM interface
75
- */
76
- resultU8a(): Uint8Array;
77
- /**
78
- * @internal
79
- * @description Retrieve a string from the WASM interface
80
- */
81
- resultString(): string;
82
- }
package/bridge.js DELETED
@@ -1,168 +0,0 @@
1
- import { stringToU8a, u8aToString } from '@pezkuwi/util';
2
- import { Wbg } from './wbg.js';
3
- /**
4
- * @name Bridge
5
- * @description
6
- * Creates a bridge between the JS and WASM environments.
7
- *
8
- * For any bridge it is passed an function which is then called internally at the
9
- * time of initialization. This affectively implements the layer between WASM and
10
- * the native environment, providing all the plumbing needed for the Wbg classes.
11
- */
12
- export class Bridge {
13
- #createWasm;
14
- #heap;
15
- #wbg;
16
- #cachegetInt32;
17
- #cachegetUint8;
18
- #heapNext;
19
- #wasm;
20
- #wasmError;
21
- #wasmPromise;
22
- #type;
23
- constructor(createWasm) {
24
- this.#createWasm = createWasm;
25
- this.#cachegetInt32 = null;
26
- this.#cachegetUint8 = null;
27
- this.#heap = new Array(32)
28
- .fill(undefined)
29
- .concat(undefined, null, true, false);
30
- this.#heapNext = this.#heap.length;
31
- this.#type = 'none';
32
- this.#wasm = null;
33
- this.#wasmError = null;
34
- this.#wasmPromise = null;
35
- this.#wbg = { ...new Wbg(this) };
36
- }
37
- /** @description Returns the init error */
38
- get error() {
39
- return this.#wasmError;
40
- }
41
- /** @description Returns the init type */
42
- get type() {
43
- return this.#type;
44
- }
45
- /** @description Returns the created wasm interface */
46
- get wasm() {
47
- return this.#wasm;
48
- }
49
- /** @description Performs the wasm initialization */
50
- async init(createWasm) {
51
- if (!this.#wasmPromise || createWasm) {
52
- this.#wasmPromise = (createWasm || this.#createWasm)(this.#wbg);
53
- }
54
- const { error, type, wasm } = await this.#wasmPromise;
55
- this.#type = type;
56
- this.#wasm = wasm;
57
- this.#wasmError = error;
58
- return this.#wasm;
59
- }
60
- /**
61
- * @internal
62
- * @description Gets an object from the heap
63
- */
64
- getObject(idx) {
65
- return this.#heap[idx];
66
- }
67
- /**
68
- * @internal
69
- * @description Removes an object from the heap
70
- */
71
- dropObject(idx) {
72
- if (idx < 36) {
73
- return;
74
- }
75
- this.#heap[idx] = this.#heapNext;
76
- this.#heapNext = idx;
77
- }
78
- /**
79
- * @internal
80
- * @description Retrieves and removes an object to the heap
81
- */
82
- takeObject(idx) {
83
- const ret = this.getObject(idx);
84
- this.dropObject(idx);
85
- return ret;
86
- }
87
- /**
88
- * @internal
89
- * @description Adds an object to the heap
90
- */
91
- addObject(obj) {
92
- if (this.#heapNext === this.#heap.length) {
93
- this.#heap.push(this.#heap.length + 1);
94
- }
95
- const idx = this.#heapNext;
96
- this.#heapNext = this.#heap[idx];
97
- this.#heap[idx] = obj;
98
- return idx;
99
- }
100
- /**
101
- * @internal
102
- * @description Retrieve an Int32 in the WASM interface
103
- */
104
- getInt32() {
105
- if (this.#cachegetInt32 === null || this.#cachegetInt32.buffer !== this.#wasm.memory.buffer) {
106
- this.#cachegetInt32 = new Int32Array(this.#wasm.memory.buffer);
107
- }
108
- return this.#cachegetInt32;
109
- }
110
- /**
111
- * @internal
112
- * @description Retrieve an Uint8Array in the WASM interface
113
- */
114
- getUint8() {
115
- if (this.#cachegetUint8 === null || this.#cachegetUint8.buffer !== this.#wasm.memory.buffer) {
116
- this.#cachegetUint8 = new Uint8Array(this.#wasm.memory.buffer);
117
- }
118
- return this.#cachegetUint8;
119
- }
120
- /**
121
- * @internal
122
- * @description Retrieves an Uint8Array in the WASM interface
123
- */
124
- getU8a(ptr, len) {
125
- return this.getUint8().subarray(ptr / 1, ptr / 1 + len);
126
- }
127
- /**
128
- * @internal
129
- * @description Retrieves a string in the WASM interface
130
- */
131
- getString(ptr, len) {
132
- return u8aToString(this.getU8a(ptr, len));
133
- }
134
- /**
135
- * @internal
136
- * @description Allocates an Uint8Array in the WASM interface
137
- */
138
- allocU8a(arg) {
139
- const ptr = this.#wasm.__wbindgen_malloc(arg.length * 1);
140
- this.getUint8().set(arg, ptr / 1);
141
- return [ptr, arg.length];
142
- }
143
- /**
144
- * @internal
145
- * @description Allocates a string in the WASM interface
146
- */
147
- allocString(arg) {
148
- return this.allocU8a(stringToU8a(arg));
149
- }
150
- /**
151
- * @internal
152
- * @description Retrieves an Uint8Array from the WASM interface
153
- */
154
- resultU8a() {
155
- const r0 = this.getInt32()[8 / 4 + 0];
156
- const r1 = this.getInt32()[8 / 4 + 1];
157
- const ret = this.getU8a(r0, r1).slice();
158
- this.#wasm.__wbindgen_free(r0, r1 * 1);
159
- return ret;
160
- }
161
- /**
162
- * @internal
163
- * @description Retrieve a string from the WASM interface
164
- */
165
- resultString() {
166
- return u8aToString(this.resultU8a());
167
- }
168
- }
package/cjs/bridge.d.ts DELETED
@@ -1,82 +0,0 @@
1
- import type { BridgeBase, InitFn, WasmBaseInstance } from './types.js';
2
- /**
3
- * @name Bridge
4
- * @description
5
- * Creates a bridge between the JS and WASM environments.
6
- *
7
- * For any bridge it is passed an function which is then called internally at the
8
- * time of initialization. This affectively implements the layer between WASM and
9
- * the native environment, providing all the plumbing needed for the Wbg classes.
10
- */
11
- export declare class Bridge<C extends WasmBaseInstance> implements BridgeBase<C> {
12
- #private;
13
- constructor(createWasm: InitFn<C>);
14
- /** @description Returns the init error */
15
- get error(): string | null;
16
- /** @description Returns the init type */
17
- get type(): 'asm' | 'wasm' | 'none';
18
- /** @description Returns the created wasm interface */
19
- get wasm(): C | null;
20
- /** @description Performs the wasm initialization */
21
- init(createWasm?: InitFn<C>): Promise<C | null>;
22
- /**
23
- * @internal
24
- * @description Gets an object from the heap
25
- */
26
- getObject(idx: number): unknown;
27
- /**
28
- * @internal
29
- * @description Removes an object from the heap
30
- */
31
- dropObject(idx: number): void;
32
- /**
33
- * @internal
34
- * @description Retrieves and removes an object to the heap
35
- */
36
- takeObject(idx: number): unknown;
37
- /**
38
- * @internal
39
- * @description Adds an object to the heap
40
- */
41
- addObject(obj: unknown): number;
42
- /**
43
- * @internal
44
- * @description Retrieve an Int32 in the WASM interface
45
- */
46
- getInt32(): Int32Array;
47
- /**
48
- * @internal
49
- * @description Retrieve an Uint8Array in the WASM interface
50
- */
51
- getUint8(): Uint8Array;
52
- /**
53
- * @internal
54
- * @description Retrieves an Uint8Array in the WASM interface
55
- */
56
- getU8a(ptr: number, len: number): Uint8Array;
57
- /**
58
- * @internal
59
- * @description Retrieves a string in the WASM interface
60
- */
61
- getString(ptr: number, len: number): string;
62
- /**
63
- * @internal
64
- * @description Allocates an Uint8Array in the WASM interface
65
- */
66
- allocU8a(arg: Uint8Array): [number, number];
67
- /**
68
- * @internal
69
- * @description Allocates a string in the WASM interface
70
- */
71
- allocString(arg: string): [number, number];
72
- /**
73
- * @internal
74
- * @description Retrieves an Uint8Array from the WASM interface
75
- */
76
- resultU8a(): Uint8Array;
77
- /**
78
- * @internal
79
- * @description Retrieve a string from the WASM interface
80
- */
81
- resultString(): string;
82
- }
package/cjs/bridge.js DELETED
@@ -1,172 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Bridge = void 0;
4
- const util_1 = require("@pezkuwi/util");
5
- const wbg_js_1 = require("./wbg.js");
6
- /**
7
- * @name Bridge
8
- * @description
9
- * Creates a bridge between the JS and WASM environments.
10
- *
11
- * For any bridge it is passed an function which is then called internally at the
12
- * time of initialization. This affectively implements the layer between WASM and
13
- * the native environment, providing all the plumbing needed for the Wbg classes.
14
- */
15
- class Bridge {
16
- #createWasm;
17
- #heap;
18
- #wbg;
19
- #cachegetInt32;
20
- #cachegetUint8;
21
- #heapNext;
22
- #wasm;
23
- #wasmError;
24
- #wasmPromise;
25
- #type;
26
- constructor(createWasm) {
27
- this.#createWasm = createWasm;
28
- this.#cachegetInt32 = null;
29
- this.#cachegetUint8 = null;
30
- this.#heap = new Array(32)
31
- .fill(undefined)
32
- .concat(undefined, null, true, false);
33
- this.#heapNext = this.#heap.length;
34
- this.#type = 'none';
35
- this.#wasm = null;
36
- this.#wasmError = null;
37
- this.#wasmPromise = null;
38
- this.#wbg = { ...new wbg_js_1.Wbg(this) };
39
- }
40
- /** @description Returns the init error */
41
- get error() {
42
- return this.#wasmError;
43
- }
44
- /** @description Returns the init type */
45
- get type() {
46
- return this.#type;
47
- }
48
- /** @description Returns the created wasm interface */
49
- get wasm() {
50
- return this.#wasm;
51
- }
52
- /** @description Performs the wasm initialization */
53
- async init(createWasm) {
54
- if (!this.#wasmPromise || createWasm) {
55
- this.#wasmPromise = (createWasm || this.#createWasm)(this.#wbg);
56
- }
57
- const { error, type, wasm } = await this.#wasmPromise;
58
- this.#type = type;
59
- this.#wasm = wasm;
60
- this.#wasmError = error;
61
- return this.#wasm;
62
- }
63
- /**
64
- * @internal
65
- * @description Gets an object from the heap
66
- */
67
- getObject(idx) {
68
- return this.#heap[idx];
69
- }
70
- /**
71
- * @internal
72
- * @description Removes an object from the heap
73
- */
74
- dropObject(idx) {
75
- if (idx < 36) {
76
- return;
77
- }
78
- this.#heap[idx] = this.#heapNext;
79
- this.#heapNext = idx;
80
- }
81
- /**
82
- * @internal
83
- * @description Retrieves and removes an object to the heap
84
- */
85
- takeObject(idx) {
86
- const ret = this.getObject(idx);
87
- this.dropObject(idx);
88
- return ret;
89
- }
90
- /**
91
- * @internal
92
- * @description Adds an object to the heap
93
- */
94
- addObject(obj) {
95
- if (this.#heapNext === this.#heap.length) {
96
- this.#heap.push(this.#heap.length + 1);
97
- }
98
- const idx = this.#heapNext;
99
- this.#heapNext = this.#heap[idx];
100
- this.#heap[idx] = obj;
101
- return idx;
102
- }
103
- /**
104
- * @internal
105
- * @description Retrieve an Int32 in the WASM interface
106
- */
107
- getInt32() {
108
- if (this.#cachegetInt32 === null || this.#cachegetInt32.buffer !== this.#wasm.memory.buffer) {
109
- this.#cachegetInt32 = new Int32Array(this.#wasm.memory.buffer);
110
- }
111
- return this.#cachegetInt32;
112
- }
113
- /**
114
- * @internal
115
- * @description Retrieve an Uint8Array in the WASM interface
116
- */
117
- getUint8() {
118
- if (this.#cachegetUint8 === null || this.#cachegetUint8.buffer !== this.#wasm.memory.buffer) {
119
- this.#cachegetUint8 = new Uint8Array(this.#wasm.memory.buffer);
120
- }
121
- return this.#cachegetUint8;
122
- }
123
- /**
124
- * @internal
125
- * @description Retrieves an Uint8Array in the WASM interface
126
- */
127
- getU8a(ptr, len) {
128
- return this.getUint8().subarray(ptr / 1, ptr / 1 + len);
129
- }
130
- /**
131
- * @internal
132
- * @description Retrieves a string in the WASM interface
133
- */
134
- getString(ptr, len) {
135
- return (0, util_1.u8aToString)(this.getU8a(ptr, len));
136
- }
137
- /**
138
- * @internal
139
- * @description Allocates an Uint8Array in the WASM interface
140
- */
141
- allocU8a(arg) {
142
- const ptr = this.#wasm.__wbindgen_malloc(arg.length * 1);
143
- this.getUint8().set(arg, ptr / 1);
144
- return [ptr, arg.length];
145
- }
146
- /**
147
- * @internal
148
- * @description Allocates a string in the WASM interface
149
- */
150
- allocString(arg) {
151
- return this.allocU8a((0, util_1.stringToU8a)(arg));
152
- }
153
- /**
154
- * @internal
155
- * @description Retrieves an Uint8Array from the WASM interface
156
- */
157
- resultU8a() {
158
- const r0 = this.getInt32()[8 / 4 + 0];
159
- const r1 = this.getInt32()[8 / 4 + 1];
160
- const ret = this.getU8a(r0, r1).slice();
161
- this.#wasm.__wbindgen_free(r0, r1 * 1);
162
- return ret;
163
- }
164
- /**
165
- * @internal
166
- * @description Retrieve a string from the WASM interface
167
- */
168
- resultString() {
169
- return (0, util_1.u8aToString)(this.resultU8a());
170
- }
171
- }
172
- exports.Bridge = Bridge;
package/cjs/init.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { InitFn, WasmBaseInstance, WasmImports } from './types.js';
2
- /**
3
- * @name createWasmFn
4
- * @description
5
- * Create a WASM (or ASM.js) creator interface based on the supplied information.
6
- *
7
- * It will attempt to create a WASM interface first and if this fails or is not available in
8
- * the environment, will fallback to attempting to create an ASM.js interface.
9
- */
10
- export declare function createWasmFn<C extends WasmBaseInstance>(root: 'crypto', wasmBytes: null | Uint8Array, asmFn: null | ((wbg: WasmImports) => C)): InitFn<C>;
package/cjs/init.js DELETED
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createWasmFn = createWasmFn;
4
- /**
5
- * @name createWasmFn
6
- * @description
7
- * Create a WASM (or ASM.js) creator interface based on the supplied information.
8
- *
9
- * It will attempt to create a WASM interface first and if this fails or is not available in
10
- * the environment, will fallback to attempting to create an ASM.js interface.
11
- */
12
- function createWasmFn(root, wasmBytes, asmFn) {
13
- return async (wbg) => {
14
- const result = {
15
- error: null,
16
- type: 'none',
17
- wasm: null
18
- };
19
- try {
20
- if (!wasmBytes?.length) {
21
- throw new Error('No WebAssembly provided for initialization');
22
- }
23
- else if (typeof WebAssembly !== 'object' || typeof WebAssembly.instantiate !== 'function') {
24
- throw new Error('WebAssembly is not available in your environment');
25
- }
26
- const source = await WebAssembly.instantiate(wasmBytes, { wbg });
27
- result.wasm = source.instance.exports;
28
- result.type = 'wasm';
29
- }
30
- catch (error) {
31
- // if we have a valid supplied asm.js, return that
32
- if (typeof asmFn === 'function') {
33
- result.wasm = asmFn(wbg);
34
- result.type = 'asm';
35
- }
36
- else {
37
- result.error = `FATAL: Unable to initialize @pezkuwi/wasm-${root}:: ${error.message}`;
38
- console.error(result.error);
39
- }
40
- }
41
- return result;
42
- };
43
- }
package/cjs/wbg.d.ts DELETED
@@ -1,36 +0,0 @@
1
- import type { BridgeBase, WasmBaseInstance } from './types.js';
2
- /**
3
- * @name Wbg
4
- * @description
5
- * This defines the internal interfaces that wasm-bindgen used to communicate
6
- * with the host layer. None of these functions are available to the user, rather
7
- * they are called internally from the WASM code itself.
8
- *
9
- * The interfaces here are exposed in the imports on the created WASM interfaces.
10
- *
11
- * Internally the implementation does a thin layer into the supplied bridge.
12
- */
13
- export declare class Wbg<C extends WasmBaseInstance> {
14
- #private;
15
- constructor(bridge: BridgeBase<C>);
16
- /** @internal */
17
- abort: () => never;
18
- /** @internal */
19
- __wbindgen_is_undefined: (idx: number) => boolean;
20
- /** @internal */
21
- __wbindgen_throw: (ptr: number, len: number) => boolean;
22
- /** @internal */
23
- __wbg_self_1b7a39e3a92c949c: () => number;
24
- /** @internal */
25
- __wbg_require_604837428532a733: (ptr: number, len: number) => never;
26
- /** @internal */
27
- __wbg_crypto_968f1772287e2df0: (_idx: number) => number;
28
- /** @internal */
29
- __wbg_getRandomValues_a3d34b4fee3c2869: (_idx: number) => number;
30
- /** @internal */
31
- __wbg_getRandomValues_f5e14ab7ac8e995d: (_arg0: number, ptr: number, len: number) => void;
32
- /** @internal */
33
- __wbg_randomFillSync_d5bd2d655fdf256a: (_idx: number, _ptr: number, _len: number) => never;
34
- /** @internal */
35
- __wbindgen_object_drop_ref: (idx: number) => void;
36
- }
package/cjs/wbg.js DELETED
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Wbg = void 0;
4
- const x_randomvalues_1 = require("@pezkuwi/x-randomvalues");
5
- const DEFAULT_CRYPTO = { getRandomValues: x_randomvalues_1.getRandomValues };
6
- const DEFAULT_SELF = { crypto: DEFAULT_CRYPTO };
7
- /**
8
- * @name Wbg
9
- * @description
10
- * This defines the internal interfaces that wasm-bindgen used to communicate
11
- * with the host layer. None of these functions are available to the user, rather
12
- * they are called internally from the WASM code itself.
13
- *
14
- * The interfaces here are exposed in the imports on the created WASM interfaces.
15
- *
16
- * Internally the implementation does a thin layer into the supplied bridge.
17
- */
18
- class Wbg {
19
- #bridge;
20
- constructor(bridge) {
21
- this.#bridge = bridge;
22
- }
23
- /** @internal */
24
- abort = () => {
25
- throw new Error('abort');
26
- };
27
- /** @internal */
28
- __wbindgen_is_undefined = (idx) => {
29
- return this.#bridge.getObject(idx) === undefined;
30
- };
31
- /** @internal */
32
- __wbindgen_throw = (ptr, len) => {
33
- throw new Error(this.#bridge.getString(ptr, len));
34
- };
35
- /** @internal */
36
- __wbg_self_1b7a39e3a92c949c = () => {
37
- return this.#bridge.addObject(DEFAULT_SELF);
38
- };
39
- /** @internal */
40
- __wbg_require_604837428532a733 = (ptr, len) => {
41
- throw new Error(`Unable to require ${this.#bridge.getString(ptr, len)}`);
42
- };
43
- /** @internal */
44
- __wbg_crypto_968f1772287e2df0 = (_idx) => {
45
- return this.#bridge.addObject(DEFAULT_CRYPTO);
46
- };
47
- /** @internal */
48
- __wbg_getRandomValues_a3d34b4fee3c2869 = (_idx) => {
49
- return this.#bridge.addObject(DEFAULT_CRYPTO.getRandomValues);
50
- };
51
- /** @internal */
52
- __wbg_getRandomValues_f5e14ab7ac8e995d = (_arg0, ptr, len) => {
53
- DEFAULT_CRYPTO.getRandomValues(this.#bridge.getU8a(ptr, len));
54
- };
55
- /** @internal */
56
- __wbg_randomFillSync_d5bd2d655fdf256a = (_idx, _ptr, _len) => {
57
- throw new Error('randomFillsync is not available');
58
- // getObject(idx).randomFillSync(getU8a(ptr, len));
59
- };
60
- /** @internal */
61
- __wbindgen_object_drop_ref = (idx) => {
62
- this.#bridge.takeObject(idx);
63
- };
64
- }
65
- exports.Wbg = Wbg;
package/init.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { InitFn, WasmBaseInstance, WasmImports } from './types.js';
2
- /**
3
- * @name createWasmFn
4
- * @description
5
- * Create a WASM (or ASM.js) creator interface based on the supplied information.
6
- *
7
- * It will attempt to create a WASM interface first and if this fails or is not available in
8
- * the environment, will fallback to attempting to create an ASM.js interface.
9
- */
10
- export declare function createWasmFn<C extends WasmBaseInstance>(root: 'crypto', wasmBytes: null | Uint8Array, asmFn: null | ((wbg: WasmImports) => C)): InitFn<C>;
package/init.js DELETED
@@ -1,40 +0,0 @@
1
- /**
2
- * @name createWasmFn
3
- * @description
4
- * Create a WASM (or ASM.js) creator interface based on the supplied information.
5
- *
6
- * It will attempt to create a WASM interface first and if this fails or is not available in
7
- * the environment, will fallback to attempting to create an ASM.js interface.
8
- */
9
- export function createWasmFn(root, wasmBytes, asmFn) {
10
- return async (wbg) => {
11
- const result = {
12
- error: null,
13
- type: 'none',
14
- wasm: null
15
- };
16
- try {
17
- if (!wasmBytes?.length) {
18
- throw new Error('No WebAssembly provided for initialization');
19
- }
20
- else if (typeof WebAssembly !== 'object' || typeof WebAssembly.instantiate !== 'function') {
21
- throw new Error('WebAssembly is not available in your environment');
22
- }
23
- const source = await WebAssembly.instantiate(wasmBytes, { wbg });
24
- result.wasm = source.instance.exports;
25
- result.type = 'wasm';
26
- }
27
- catch (error) {
28
- // if we have a valid supplied asm.js, return that
29
- if (typeof asmFn === 'function') {
30
- result.wasm = asmFn(wbg);
31
- result.type = 'asm';
32
- }
33
- else {
34
- result.error = `FATAL: Unable to initialize @pezkuwi/wasm-${root}:: ${error.message}`;
35
- console.error(result.error);
36
- }
37
- }
38
- return result;
39
- };
40
- }
package/wbg.d.ts DELETED
@@ -1,36 +0,0 @@
1
- import type { BridgeBase, WasmBaseInstance } from './types.js';
2
- /**
3
- * @name Wbg
4
- * @description
5
- * This defines the internal interfaces that wasm-bindgen used to communicate
6
- * with the host layer. None of these functions are available to the user, rather
7
- * they are called internally from the WASM code itself.
8
- *
9
- * The interfaces here are exposed in the imports on the created WASM interfaces.
10
- *
11
- * Internally the implementation does a thin layer into the supplied bridge.
12
- */
13
- export declare class Wbg<C extends WasmBaseInstance> {
14
- #private;
15
- constructor(bridge: BridgeBase<C>);
16
- /** @internal */
17
- abort: () => never;
18
- /** @internal */
19
- __wbindgen_is_undefined: (idx: number) => boolean;
20
- /** @internal */
21
- __wbindgen_throw: (ptr: number, len: number) => boolean;
22
- /** @internal */
23
- __wbg_self_1b7a39e3a92c949c: () => number;
24
- /** @internal */
25
- __wbg_require_604837428532a733: (ptr: number, len: number) => never;
26
- /** @internal */
27
- __wbg_crypto_968f1772287e2df0: (_idx: number) => number;
28
- /** @internal */
29
- __wbg_getRandomValues_a3d34b4fee3c2869: (_idx: number) => number;
30
- /** @internal */
31
- __wbg_getRandomValues_f5e14ab7ac8e995d: (_arg0: number, ptr: number, len: number) => void;
32
- /** @internal */
33
- __wbg_randomFillSync_d5bd2d655fdf256a: (_idx: number, _ptr: number, _len: number) => never;
34
- /** @internal */
35
- __wbindgen_object_drop_ref: (idx: number) => void;
36
- }
package/wbg.js DELETED
@@ -1,61 +0,0 @@
1
- import { getRandomValues } from '@pezkuwi/x-randomvalues';
2
- const DEFAULT_CRYPTO = { getRandomValues };
3
- const DEFAULT_SELF = { crypto: DEFAULT_CRYPTO };
4
- /**
5
- * @name Wbg
6
- * @description
7
- * This defines the internal interfaces that wasm-bindgen used to communicate
8
- * with the host layer. None of these functions are available to the user, rather
9
- * they are called internally from the WASM code itself.
10
- *
11
- * The interfaces here are exposed in the imports on the created WASM interfaces.
12
- *
13
- * Internally the implementation does a thin layer into the supplied bridge.
14
- */
15
- export class Wbg {
16
- #bridge;
17
- constructor(bridge) {
18
- this.#bridge = bridge;
19
- }
20
- /** @internal */
21
- abort = () => {
22
- throw new Error('abort');
23
- };
24
- /** @internal */
25
- __wbindgen_is_undefined = (idx) => {
26
- return this.#bridge.getObject(idx) === undefined;
27
- };
28
- /** @internal */
29
- __wbindgen_throw = (ptr, len) => {
30
- throw new Error(this.#bridge.getString(ptr, len));
31
- };
32
- /** @internal */
33
- __wbg_self_1b7a39e3a92c949c = () => {
34
- return this.#bridge.addObject(DEFAULT_SELF);
35
- };
36
- /** @internal */
37
- __wbg_require_604837428532a733 = (ptr, len) => {
38
- throw new Error(`Unable to require ${this.#bridge.getString(ptr, len)}`);
39
- };
40
- /** @internal */
41
- __wbg_crypto_968f1772287e2df0 = (_idx) => {
42
- return this.#bridge.addObject(DEFAULT_CRYPTO);
43
- };
44
- /** @internal */
45
- __wbg_getRandomValues_a3d34b4fee3c2869 = (_idx) => {
46
- return this.#bridge.addObject(DEFAULT_CRYPTO.getRandomValues);
47
- };
48
- /** @internal */
49
- __wbg_getRandomValues_f5e14ab7ac8e995d = (_arg0, ptr, len) => {
50
- DEFAULT_CRYPTO.getRandomValues(this.#bridge.getU8a(ptr, len));
51
- };
52
- /** @internal */
53
- __wbg_randomFillSync_d5bd2d655fdf256a = (_idx, _ptr, _len) => {
54
- throw new Error('randomFillsync is not available');
55
- // getObject(idx).randomFillSync(getU8a(ptr, len));
56
- };
57
- /** @internal */
58
- __wbindgen_object_drop_ref = (idx) => {
59
- this.#bridge.takeObject(idx);
60
- };
61
- }