xwing-wasm 0.3.0 → 0.3.2
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/bundler/xwing.d.ts +4 -2
- package/bundler/xwing.js +1 -1
- package/bundler/xwing_bg.js +61 -36
- package/bundler/xwing_bg.wasm.d.ts +3 -2
- package/node/xwing.d.ts +4 -2
- package/node/xwing.js +59 -33
- package/node/xwing_bg.wasm.d.ts +3 -2
- package/package.json +1 -1
- package/web/xwing.d.ts +7 -4
- package/web/xwing.js +74 -37
- package/web/xwing_bg.wasm.d.ts +3 -2
- package/xwing_bg.js +61 -36
- package/xwing_bg.wasm +0 -0
package/bundler/xwing.d.ts
CHANGED
|
@@ -11,8 +11,10 @@ export interface GenerateKeypairResult {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export function decapsulate(sk: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
14
|
+
export function decapsulate(sk: Uint8Array | number[], ciphertext: Uint8Array | number[]): Uint8Array;
|
|
15
15
|
|
|
16
|
-
export function encapsulate(pk: Uint8Array): EncapsulateResult;
|
|
16
|
+
export function encapsulate(pk: Uint8Array | number[]): EncapsulateResult;
|
|
17
17
|
|
|
18
18
|
export function generateKeypair(): GenerateKeypairResult;
|
|
19
|
+
|
|
20
|
+
export function generateKeypairFromSeed(seed: Uint8Array | number[]): GenerateKeypairResult;
|
package/bundler/xwing.js
CHANGED
package/bundler/xwing_bg.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {Uint8Array} sk
|
|
3
|
-
* @param {Uint8Array} ciphertext
|
|
2
|
+
* @param {Uint8Array | number[]} sk
|
|
3
|
+
* @param {Uint8Array | number[]} ciphertext
|
|
4
4
|
* @returns {Uint8Array}
|
|
5
5
|
*/
|
|
6
6
|
export function decapsulate(sk, ciphertext) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
let ptr0, len0, ptr1, len1;
|
|
8
|
+
try {
|
|
9
|
+
ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
10
|
+
len0 = WASM_VECTOR_LEN;
|
|
11
|
+
ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
12
|
+
len1 = WASM_VECTOR_LEN;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
15
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
11
18
|
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
12
19
|
if (ret[3]) {
|
|
13
20
|
throw takeFromExternrefTable0(ret[2]);
|
|
@@ -18,7 +25,7 @@ export function decapsulate(sk, ciphertext) {
|
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
/**
|
|
21
|
-
* @param {Uint8Array} pk
|
|
28
|
+
* @param {Uint8Array | number[]} pk
|
|
22
29
|
* @returns {EncapsulateResult}
|
|
23
30
|
*/
|
|
24
31
|
export function encapsulate(pk) {
|
|
@@ -36,9 +43,26 @@ export function encapsulate(pk) {
|
|
|
36
43
|
*/
|
|
37
44
|
export function generateKeypair() {
|
|
38
45
|
const ret = wasm.generateKeypair();
|
|
39
|
-
|
|
46
|
+
if (ret[2]) {
|
|
47
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
48
|
+
}
|
|
49
|
+
return takeFromExternrefTable0(ret[0]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {Uint8Array | number[]} seed
|
|
54
|
+
* @returns {GenerateKeypairResult}
|
|
55
|
+
*/
|
|
56
|
+
export function generateKeypairFromSeed(seed) {
|
|
57
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
58
|
+
const len0 = WASM_VECTOR_LEN;
|
|
59
|
+
const ret = wasm.generateKeypairFromSeed(ptr0, len0);
|
|
60
|
+
if (ret[2]) {
|
|
61
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
62
|
+
}
|
|
63
|
+
return takeFromExternrefTable0(ret[0]);
|
|
40
64
|
}
|
|
41
|
-
export function
|
|
65
|
+
export function __wbg_Error_208446807d0d1e30(arg0, arg1) {
|
|
42
66
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
43
67
|
return ret;
|
|
44
68
|
}
|
|
@@ -46,47 +70,47 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
46
70
|
const ret = String(arg1);
|
|
47
71
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
48
72
|
const len1 = WASM_VECTOR_LEN;
|
|
49
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
50
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
73
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
|
|
74
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
|
|
51
75
|
}
|
|
52
|
-
export function
|
|
76
|
+
export function __wbg___wbindgen_throw_4c88d8bf264fd984(arg0, arg1) {
|
|
53
77
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
54
78
|
}
|
|
55
|
-
export function
|
|
79
|
+
export function __wbg_from_eac91875c8a5ffa4(arg0) {
|
|
80
|
+
const ret = Array.from(arg0);
|
|
81
|
+
return ret;
|
|
82
|
+
}
|
|
83
|
+
export function __wbg_getRandomValues_8b6f1f663e6f188d() { return handleError(function (arg0, arg1) {
|
|
56
84
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
57
85
|
}, arguments); }
|
|
58
|
-
export function
|
|
59
|
-
const ret = new
|
|
86
|
+
export function __wbg_new_13de428334042d26(arg0) {
|
|
87
|
+
const ret = new Uint8Array(arg0);
|
|
60
88
|
return ret;
|
|
61
89
|
}
|
|
62
|
-
export function
|
|
90
|
+
export function __wbg_new_cd4348290afae586() {
|
|
63
91
|
const ret = new Object();
|
|
64
92
|
return ret;
|
|
65
93
|
}
|
|
66
|
-
export function
|
|
94
|
+
export function __wbg_set_e4b9a833d288759a(arg0, arg1, arg2) {
|
|
67
95
|
arg0[arg1] = arg2;
|
|
68
96
|
}
|
|
69
|
-
export function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
73
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
74
|
-
const ret = arg0;
|
|
97
|
+
export function __wbindgen_generic_0000000000000001(arg0, arg1) {
|
|
98
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
99
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
75
100
|
return ret;
|
|
76
101
|
}
|
|
77
|
-
export function
|
|
102
|
+
export function __wbindgen_generic_0000000000000002(arg0, arg1) {
|
|
78
103
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
79
104
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
80
105
|
return ret;
|
|
81
106
|
}
|
|
82
107
|
export function __wbindgen_init_externref_table() {
|
|
83
108
|
const table = wasm.__wbindgen_externrefs;
|
|
84
|
-
const offset = table.grow(4);
|
|
85
109
|
table.set(0, undefined);
|
|
86
|
-
table.set(
|
|
87
|
-
table.set(
|
|
88
|
-
table.set(
|
|
89
|
-
table.set(
|
|
110
|
+
table.set(1024, undefined);
|
|
111
|
+
table.set(1025, null);
|
|
112
|
+
table.set(1026, true);
|
|
113
|
+
table.set(1027, false);
|
|
90
114
|
}
|
|
91
115
|
function addToExternrefTable0(obj) {
|
|
92
116
|
const idx = wasm.__externref_table_alloc();
|
|
@@ -108,7 +132,8 @@ function getDataViewMemory0() {
|
|
|
108
132
|
}
|
|
109
133
|
|
|
110
134
|
function getStringFromWasm0(ptr, len) {
|
|
111
|
-
|
|
135
|
+
ptr = ptr >>> 0;
|
|
136
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
112
137
|
}
|
|
113
138
|
|
|
114
139
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -178,18 +203,18 @@ function takeFromExternrefTable0(idx) {
|
|
|
178
203
|
return value;
|
|
179
204
|
}
|
|
180
205
|
|
|
181
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
206
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
182
207
|
cachedTextDecoder.decode();
|
|
183
208
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
184
209
|
let numBytesDecoded = 0;
|
|
185
|
-
function decodeText(
|
|
186
|
-
numBytesDecoded +=
|
|
210
|
+
function decodeText(bytes) {
|
|
211
|
+
numBytesDecoded += bytes.length;
|
|
187
212
|
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
188
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
213
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
189
214
|
cachedTextDecoder.decode();
|
|
190
|
-
numBytesDecoded =
|
|
215
|
+
numBytesDecoded = bytes.length;
|
|
191
216
|
}
|
|
192
|
-
return cachedTextDecoder.decode(
|
|
217
|
+
return cachedTextDecoder.decode(bytes);
|
|
193
218
|
}
|
|
194
219
|
|
|
195
220
|
const cachedTextEncoder = new TextEncoder();
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
5
5
|
export const encapsulate: (a: number, b: number) => [number, number, number];
|
|
6
|
-
export const generateKeypair: () =>
|
|
6
|
+
export const generateKeypair: () => [number, number, number];
|
|
7
|
+
export const generateKeypairFromSeed: (a: number, b: number) => [number, number, number];
|
|
7
8
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
8
9
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
9
11
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
10
12
|
export const __externref_table_alloc: () => number;
|
|
11
13
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
12
14
|
export const __externref_table_dealloc: (a: number) => void;
|
|
13
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
14
15
|
export const __wbindgen_start: () => void;
|
package/node/xwing.d.ts
CHANGED
|
@@ -11,8 +11,10 @@ export interface GenerateKeypairResult {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export function decapsulate(sk: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
14
|
+
export function decapsulate(sk: Uint8Array | number[], ciphertext: Uint8Array | number[]): Uint8Array;
|
|
15
15
|
|
|
16
|
-
export function encapsulate(pk: Uint8Array): EncapsulateResult;
|
|
16
|
+
export function encapsulate(pk: Uint8Array | number[]): EncapsulateResult;
|
|
17
17
|
|
|
18
18
|
export function generateKeypair(): GenerateKeypairResult;
|
|
19
|
+
|
|
20
|
+
export function generateKeypairFromSeed(seed: Uint8Array | number[]): GenerateKeypairResult;
|
package/node/xwing.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
/* @ts-self-types="./xwing.d.ts" */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @param {Uint8Array} sk
|
|
5
|
-
* @param {Uint8Array} ciphertext
|
|
4
|
+
* @param {Uint8Array | number[]} sk
|
|
5
|
+
* @param {Uint8Array | number[]} ciphertext
|
|
6
6
|
* @returns {Uint8Array}
|
|
7
7
|
*/
|
|
8
8
|
function decapsulate(sk, ciphertext) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
let ptr0, len0, ptr1, len1;
|
|
10
|
+
try {
|
|
11
|
+
ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
12
|
+
len0 = WASM_VECTOR_LEN;
|
|
13
|
+
ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
14
|
+
len1 = WASM_VECTOR_LEN;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
17
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
13
20
|
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
14
21
|
if (ret[3]) {
|
|
15
22
|
throw takeFromExternrefTable0(ret[2]);
|
|
@@ -21,7 +28,7 @@ function decapsulate(sk, ciphertext) {
|
|
|
21
28
|
exports.decapsulate = decapsulate;
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
|
-
* @param {Uint8Array} pk
|
|
31
|
+
* @param {Uint8Array | number[]} pk
|
|
25
32
|
* @returns {EncapsulateResult}
|
|
26
33
|
*/
|
|
27
34
|
function encapsulate(pk) {
|
|
@@ -40,13 +47,31 @@ exports.encapsulate = encapsulate;
|
|
|
40
47
|
*/
|
|
41
48
|
function generateKeypair() {
|
|
42
49
|
const ret = wasm.generateKeypair();
|
|
43
|
-
|
|
50
|
+
if (ret[2]) {
|
|
51
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
52
|
+
}
|
|
53
|
+
return takeFromExternrefTable0(ret[0]);
|
|
44
54
|
}
|
|
45
55
|
exports.generateKeypair = generateKeypair;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {Uint8Array | number[]} seed
|
|
59
|
+
* @returns {GenerateKeypairResult}
|
|
60
|
+
*/
|
|
61
|
+
function generateKeypairFromSeed(seed) {
|
|
62
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
63
|
+
const len0 = WASM_VECTOR_LEN;
|
|
64
|
+
const ret = wasm.generateKeypairFromSeed(ptr0, len0);
|
|
65
|
+
if (ret[2]) {
|
|
66
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
67
|
+
}
|
|
68
|
+
return takeFromExternrefTable0(ret[0]);
|
|
69
|
+
}
|
|
70
|
+
exports.generateKeypairFromSeed = generateKeypairFromSeed;
|
|
46
71
|
function __wbg_get_imports() {
|
|
47
72
|
const import0 = {
|
|
48
73
|
__proto__: null,
|
|
49
|
-
|
|
74
|
+
__wbg_Error_208446807d0d1e30: function(arg0, arg1) {
|
|
50
75
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
51
76
|
return ret;
|
|
52
77
|
},
|
|
@@ -54,47 +79,47 @@ function __wbg_get_imports() {
|
|
|
54
79
|
const ret = String(arg1);
|
|
55
80
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
56
81
|
const len1 = WASM_VECTOR_LEN;
|
|
57
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
58
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
82
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
|
|
83
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
|
|
59
84
|
},
|
|
60
|
-
|
|
85
|
+
__wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
|
|
61
86
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
62
87
|
},
|
|
63
|
-
|
|
88
|
+
__wbg_from_eac91875c8a5ffa4: function(arg0) {
|
|
89
|
+
const ret = Array.from(arg0);
|
|
90
|
+
return ret;
|
|
91
|
+
},
|
|
92
|
+
__wbg_getRandomValues_8b6f1f663e6f188d: function() { return handleError(function (arg0, arg1) {
|
|
64
93
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
65
94
|
}, arguments); },
|
|
66
|
-
|
|
67
|
-
const ret = new
|
|
95
|
+
__wbg_new_13de428334042d26: function(arg0) {
|
|
96
|
+
const ret = new Uint8Array(arg0);
|
|
68
97
|
return ret;
|
|
69
98
|
},
|
|
70
|
-
|
|
99
|
+
__wbg_new_cd4348290afae586: function() {
|
|
71
100
|
const ret = new Object();
|
|
72
101
|
return ret;
|
|
73
102
|
},
|
|
74
|
-
|
|
103
|
+
__wbg_set_e4b9a833d288759a: function(arg0, arg1, arg2) {
|
|
75
104
|
arg0[arg1] = arg2;
|
|
76
105
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
81
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
82
|
-
const ret = arg0;
|
|
106
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
107
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
108
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
83
109
|
return ret;
|
|
84
110
|
},
|
|
85
|
-
|
|
111
|
+
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
86
112
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
87
113
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
88
114
|
return ret;
|
|
89
115
|
},
|
|
90
116
|
__wbindgen_init_externref_table: function() {
|
|
91
117
|
const table = wasm.__wbindgen_externrefs;
|
|
92
|
-
const offset = table.grow(4);
|
|
93
118
|
table.set(0, undefined);
|
|
94
|
-
table.set(
|
|
95
|
-
table.set(
|
|
96
|
-
table.set(
|
|
97
|
-
table.set(
|
|
119
|
+
table.set(1024, undefined);
|
|
120
|
+
table.set(1025, null);
|
|
121
|
+
table.set(1026, true);
|
|
122
|
+
table.set(1027, false);
|
|
98
123
|
},
|
|
99
124
|
};
|
|
100
125
|
return {
|
|
@@ -123,7 +148,8 @@ function getDataViewMemory0() {
|
|
|
123
148
|
}
|
|
124
149
|
|
|
125
150
|
function getStringFromWasm0(ptr, len) {
|
|
126
|
-
|
|
151
|
+
ptr = ptr >>> 0;
|
|
152
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
127
153
|
}
|
|
128
154
|
|
|
129
155
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -193,10 +219,10 @@ function takeFromExternrefTable0(idx) {
|
|
|
193
219
|
return value;
|
|
194
220
|
}
|
|
195
221
|
|
|
196
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
222
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
197
223
|
cachedTextDecoder.decode();
|
|
198
|
-
function decodeText(
|
|
199
|
-
return cachedTextDecoder.decode(
|
|
224
|
+
function decodeText(bytes) {
|
|
225
|
+
return cachedTextDecoder.decode(bytes);
|
|
200
226
|
}
|
|
201
227
|
|
|
202
228
|
const cachedTextEncoder = new TextEncoder();
|
package/node/xwing_bg.wasm.d.ts
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
5
5
|
export const encapsulate: (a: number, b: number) => [number, number, number];
|
|
6
|
-
export const generateKeypair: () =>
|
|
6
|
+
export const generateKeypair: () => [number, number, number];
|
|
7
|
+
export const generateKeypairFromSeed: (a: number, b: number) => [number, number, number];
|
|
7
8
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
8
9
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
9
11
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
10
12
|
export const __externref_table_alloc: () => number;
|
|
11
13
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
12
14
|
export const __externref_table_dealloc: (a: number) => void;
|
|
13
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
14
15
|
export const __wbindgen_start: () => void;
|
package/package.json
CHANGED
package/web/xwing.d.ts
CHANGED
|
@@ -11,26 +11,29 @@ export interface GenerateKeypairResult {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export function decapsulate(sk: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
14
|
+
export function decapsulate(sk: Uint8Array | number[], ciphertext: Uint8Array | number[]): Uint8Array;
|
|
15
15
|
|
|
16
|
-
export function encapsulate(pk: Uint8Array): EncapsulateResult;
|
|
16
|
+
export function encapsulate(pk: Uint8Array | number[]): EncapsulateResult;
|
|
17
17
|
|
|
18
18
|
export function generateKeypair(): GenerateKeypairResult;
|
|
19
19
|
|
|
20
|
+
export function generateKeypairFromSeed(seed: Uint8Array | number[]): GenerateKeypairResult;
|
|
21
|
+
|
|
20
22
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
21
23
|
|
|
22
24
|
export interface InitOutput {
|
|
23
25
|
readonly memory: WebAssembly.Memory;
|
|
24
26
|
readonly decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
25
27
|
readonly encapsulate: (a: number, b: number) => [number, number, number];
|
|
26
|
-
readonly generateKeypair: () =>
|
|
28
|
+
readonly generateKeypair: () => [number, number, number];
|
|
29
|
+
readonly generateKeypairFromSeed: (a: number, b: number) => [number, number, number];
|
|
27
30
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
28
31
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
32
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
29
33
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
30
34
|
readonly __externref_table_alloc: () => number;
|
|
31
35
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
32
36
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
33
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
34
37
|
readonly __wbindgen_start: () => void;
|
|
35
38
|
}
|
|
36
39
|
|
package/web/xwing.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
/* @ts-self-types="./xwing.d.ts" */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @param {Uint8Array} sk
|
|
5
|
-
* @param {Uint8Array} ciphertext
|
|
4
|
+
* @param {Uint8Array | number[]} sk
|
|
5
|
+
* @param {Uint8Array | number[]} ciphertext
|
|
6
6
|
* @returns {Uint8Array}
|
|
7
7
|
*/
|
|
8
8
|
export function decapsulate(sk, ciphertext) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
let ptr0, len0, ptr1, len1;
|
|
10
|
+
try {
|
|
11
|
+
ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
12
|
+
len0 = WASM_VECTOR_LEN;
|
|
13
|
+
ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
14
|
+
len1 = WASM_VECTOR_LEN;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
17
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
13
20
|
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
14
21
|
if (ret[3]) {
|
|
15
22
|
throw takeFromExternrefTable0(ret[2]);
|
|
@@ -20,7 +27,7 @@ export function decapsulate(sk, ciphertext) {
|
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
|
-
* @param {Uint8Array} pk
|
|
30
|
+
* @param {Uint8Array | number[]} pk
|
|
24
31
|
* @returns {EncapsulateResult}
|
|
25
32
|
*/
|
|
26
33
|
export function encapsulate(pk) {
|
|
@@ -38,12 +45,29 @@ export function encapsulate(pk) {
|
|
|
38
45
|
*/
|
|
39
46
|
export function generateKeypair() {
|
|
40
47
|
const ret = wasm.generateKeypair();
|
|
41
|
-
|
|
48
|
+
if (ret[2]) {
|
|
49
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
50
|
+
}
|
|
51
|
+
return takeFromExternrefTable0(ret[0]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {Uint8Array | number[]} seed
|
|
56
|
+
* @returns {GenerateKeypairResult}
|
|
57
|
+
*/
|
|
58
|
+
export function generateKeypairFromSeed(seed) {
|
|
59
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
60
|
+
const len0 = WASM_VECTOR_LEN;
|
|
61
|
+
const ret = wasm.generateKeypairFromSeed(ptr0, len0);
|
|
62
|
+
if (ret[2]) {
|
|
63
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
64
|
+
}
|
|
65
|
+
return takeFromExternrefTable0(ret[0]);
|
|
42
66
|
}
|
|
43
67
|
function __wbg_get_imports() {
|
|
44
68
|
const import0 = {
|
|
45
69
|
__proto__: null,
|
|
46
|
-
|
|
70
|
+
__wbg_Error_208446807d0d1e30: function(arg0, arg1) {
|
|
47
71
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
48
72
|
return ret;
|
|
49
73
|
},
|
|
@@ -51,47 +75,47 @@ function __wbg_get_imports() {
|
|
|
51
75
|
const ret = String(arg1);
|
|
52
76
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
53
77
|
const len1 = WASM_VECTOR_LEN;
|
|
54
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
55
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
78
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
|
|
79
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
|
|
56
80
|
},
|
|
57
|
-
|
|
81
|
+
__wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
|
|
58
82
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
59
83
|
},
|
|
60
|
-
|
|
84
|
+
__wbg_from_eac91875c8a5ffa4: function(arg0) {
|
|
85
|
+
const ret = Array.from(arg0);
|
|
86
|
+
return ret;
|
|
87
|
+
},
|
|
88
|
+
__wbg_getRandomValues_8b6f1f663e6f188d: function() { return handleError(function (arg0, arg1) {
|
|
61
89
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
62
90
|
}, arguments); },
|
|
63
|
-
|
|
64
|
-
const ret = new
|
|
91
|
+
__wbg_new_13de428334042d26: function(arg0) {
|
|
92
|
+
const ret = new Uint8Array(arg0);
|
|
65
93
|
return ret;
|
|
66
94
|
},
|
|
67
|
-
|
|
95
|
+
__wbg_new_cd4348290afae586: function() {
|
|
68
96
|
const ret = new Object();
|
|
69
97
|
return ret;
|
|
70
98
|
},
|
|
71
|
-
|
|
99
|
+
__wbg_set_e4b9a833d288759a: function(arg0, arg1, arg2) {
|
|
72
100
|
arg0[arg1] = arg2;
|
|
73
101
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
78
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
79
|
-
const ret = arg0;
|
|
102
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
103
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
104
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
80
105
|
return ret;
|
|
81
106
|
},
|
|
82
|
-
|
|
107
|
+
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
83
108
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
84
109
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
85
110
|
return ret;
|
|
86
111
|
},
|
|
87
112
|
__wbindgen_init_externref_table: function() {
|
|
88
113
|
const table = wasm.__wbindgen_externrefs;
|
|
89
|
-
const offset = table.grow(4);
|
|
90
114
|
table.set(0, undefined);
|
|
91
|
-
table.set(
|
|
92
|
-
table.set(
|
|
93
|
-
table.set(
|
|
94
|
-
table.set(
|
|
115
|
+
table.set(1024, undefined);
|
|
116
|
+
table.set(1025, null);
|
|
117
|
+
table.set(1026, true);
|
|
118
|
+
table.set(1027, false);
|
|
95
119
|
},
|
|
96
120
|
};
|
|
97
121
|
return {
|
|
@@ -120,7 +144,8 @@ function getDataViewMemory0() {
|
|
|
120
144
|
}
|
|
121
145
|
|
|
122
146
|
function getStringFromWasm0(ptr, len) {
|
|
123
|
-
|
|
147
|
+
ptr = ptr >>> 0;
|
|
148
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
124
149
|
}
|
|
125
150
|
|
|
126
151
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -190,18 +215,18 @@ function takeFromExternrefTable0(idx) {
|
|
|
190
215
|
return value;
|
|
191
216
|
}
|
|
192
217
|
|
|
193
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
218
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
194
219
|
cachedTextDecoder.decode();
|
|
195
220
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
196
221
|
let numBytesDecoded = 0;
|
|
197
|
-
function decodeText(
|
|
198
|
-
numBytesDecoded +=
|
|
222
|
+
function decodeText(bytes) {
|
|
223
|
+
numBytesDecoded += bytes.length;
|
|
199
224
|
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
200
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
225
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
201
226
|
cachedTextDecoder.decode();
|
|
202
|
-
numBytesDecoded =
|
|
227
|
+
numBytesDecoded = bytes.length;
|
|
203
228
|
}
|
|
204
|
-
return cachedTextDecoder.decode(
|
|
229
|
+
return cachedTextDecoder.decode(bytes);
|
|
205
230
|
}
|
|
206
231
|
|
|
207
232
|
const cachedTextEncoder = new TextEncoder();
|
|
@@ -232,11 +257,15 @@ function __wbg_finalize_init(instance, module) {
|
|
|
232
257
|
|
|
233
258
|
async function __wbg_load(module, imports) {
|
|
234
259
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
260
|
+
if (!module.ok) {
|
|
261
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
262
|
+
}
|
|
263
|
+
|
|
235
264
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
236
265
|
try {
|
|
237
266
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
238
267
|
} catch (e) {
|
|
239
|
-
const validResponse =
|
|
268
|
+
const validResponse = expectedResponseType(module.type);
|
|
240
269
|
|
|
241
270
|
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
242
271
|
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
@@ -285,9 +314,17 @@ function initSync(module) {
|
|
|
285
314
|
return __wbg_finalize_init(instance, module);
|
|
286
315
|
}
|
|
287
316
|
|
|
317
|
+
let __wbg_init_promise;
|
|
288
318
|
async function __wbg_init(module_or_path) {
|
|
289
319
|
if (wasm !== undefined) return wasm;
|
|
320
|
+
if (__wbg_init_promise === undefined) {
|
|
321
|
+
__wbg_init_promise = __wbg_init_once(module_or_path);
|
|
322
|
+
__wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
|
|
323
|
+
}
|
|
324
|
+
return __wbg_init_promise;
|
|
325
|
+
}
|
|
290
326
|
|
|
327
|
+
async function __wbg_init_once(module_or_path) {
|
|
291
328
|
|
|
292
329
|
if (module_or_path !== undefined) {
|
|
293
330
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
package/web/xwing_bg.wasm.d.ts
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
5
5
|
export const encapsulate: (a: number, b: number) => [number, number, number];
|
|
6
|
-
export const generateKeypair: () =>
|
|
6
|
+
export const generateKeypair: () => [number, number, number];
|
|
7
|
+
export const generateKeypairFromSeed: (a: number, b: number) => [number, number, number];
|
|
7
8
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
8
9
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
9
11
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
10
12
|
export const __externref_table_alloc: () => number;
|
|
11
13
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
12
14
|
export const __externref_table_dealloc: (a: number) => void;
|
|
13
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
14
15
|
export const __wbindgen_start: () => void;
|
package/xwing_bg.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {Uint8Array} sk
|
|
3
|
-
* @param {Uint8Array} ciphertext
|
|
2
|
+
* @param {Uint8Array | number[]} sk
|
|
3
|
+
* @param {Uint8Array | number[]} ciphertext
|
|
4
4
|
* @returns {Uint8Array}
|
|
5
5
|
*/
|
|
6
6
|
export function decapsulate(sk, ciphertext) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
let ptr0, len0, ptr1, len1;
|
|
8
|
+
try {
|
|
9
|
+
ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
10
|
+
len0 = WASM_VECTOR_LEN;
|
|
11
|
+
ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
12
|
+
len1 = WASM_VECTOR_LEN;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
15
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
11
18
|
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
12
19
|
if (ret[3]) {
|
|
13
20
|
throw takeFromExternrefTable0(ret[2]);
|
|
@@ -18,7 +25,7 @@ export function decapsulate(sk, ciphertext) {
|
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
/**
|
|
21
|
-
* @param {Uint8Array} pk
|
|
28
|
+
* @param {Uint8Array | number[]} pk
|
|
22
29
|
* @returns {EncapsulateResult}
|
|
23
30
|
*/
|
|
24
31
|
export function encapsulate(pk) {
|
|
@@ -36,9 +43,26 @@ export function encapsulate(pk) {
|
|
|
36
43
|
*/
|
|
37
44
|
export function generateKeypair() {
|
|
38
45
|
const ret = wasm.generateKeypair();
|
|
39
|
-
|
|
46
|
+
if (ret[2]) {
|
|
47
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
48
|
+
}
|
|
49
|
+
return takeFromExternrefTable0(ret[0]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {Uint8Array | number[]} seed
|
|
54
|
+
* @returns {GenerateKeypairResult}
|
|
55
|
+
*/
|
|
56
|
+
export function generateKeypairFromSeed(seed) {
|
|
57
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
58
|
+
const len0 = WASM_VECTOR_LEN;
|
|
59
|
+
const ret = wasm.generateKeypairFromSeed(ptr0, len0);
|
|
60
|
+
if (ret[2]) {
|
|
61
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
62
|
+
}
|
|
63
|
+
return takeFromExternrefTable0(ret[0]);
|
|
40
64
|
}
|
|
41
|
-
export function
|
|
65
|
+
export function __wbg_Error_208446807d0d1e30(arg0, arg1) {
|
|
42
66
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
43
67
|
return ret;
|
|
44
68
|
}
|
|
@@ -46,47 +70,47 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
46
70
|
const ret = String(arg1);
|
|
47
71
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
48
72
|
const len1 = WASM_VECTOR_LEN;
|
|
49
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
50
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
73
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
|
|
74
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
|
|
51
75
|
}
|
|
52
|
-
export function
|
|
76
|
+
export function __wbg___wbindgen_throw_4c88d8bf264fd984(arg0, arg1) {
|
|
53
77
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
54
78
|
}
|
|
55
|
-
export function
|
|
79
|
+
export function __wbg_from_eac91875c8a5ffa4(arg0) {
|
|
80
|
+
const ret = Array.from(arg0);
|
|
81
|
+
return ret;
|
|
82
|
+
}
|
|
83
|
+
export function __wbg_getRandomValues_8b6f1f663e6f188d() { return handleError(function (arg0, arg1) {
|
|
56
84
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
57
85
|
}, arguments); }
|
|
58
|
-
export function
|
|
59
|
-
const ret = new
|
|
86
|
+
export function __wbg_new_13de428334042d26(arg0) {
|
|
87
|
+
const ret = new Uint8Array(arg0);
|
|
60
88
|
return ret;
|
|
61
89
|
}
|
|
62
|
-
export function
|
|
90
|
+
export function __wbg_new_cd4348290afae586() {
|
|
63
91
|
const ret = new Object();
|
|
64
92
|
return ret;
|
|
65
93
|
}
|
|
66
|
-
export function
|
|
94
|
+
export function __wbg_set_e4b9a833d288759a(arg0, arg1, arg2) {
|
|
67
95
|
arg0[arg1] = arg2;
|
|
68
96
|
}
|
|
69
|
-
export function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
73
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
74
|
-
const ret = arg0;
|
|
97
|
+
export function __wbindgen_generic_0000000000000001(arg0, arg1) {
|
|
98
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
99
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
75
100
|
return ret;
|
|
76
101
|
}
|
|
77
|
-
export function
|
|
102
|
+
export function __wbindgen_generic_0000000000000002(arg0, arg1) {
|
|
78
103
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
79
104
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
80
105
|
return ret;
|
|
81
106
|
}
|
|
82
107
|
export function __wbindgen_init_externref_table() {
|
|
83
108
|
const table = wasm.__wbindgen_externrefs;
|
|
84
|
-
const offset = table.grow(4);
|
|
85
109
|
table.set(0, undefined);
|
|
86
|
-
table.set(
|
|
87
|
-
table.set(
|
|
88
|
-
table.set(
|
|
89
|
-
table.set(
|
|
110
|
+
table.set(1024, undefined);
|
|
111
|
+
table.set(1025, null);
|
|
112
|
+
table.set(1026, true);
|
|
113
|
+
table.set(1027, false);
|
|
90
114
|
}
|
|
91
115
|
function addToExternrefTable0(obj) {
|
|
92
116
|
const idx = wasm.__externref_table_alloc();
|
|
@@ -108,7 +132,8 @@ function getDataViewMemory0() {
|
|
|
108
132
|
}
|
|
109
133
|
|
|
110
134
|
function getStringFromWasm0(ptr, len) {
|
|
111
|
-
|
|
135
|
+
ptr = ptr >>> 0;
|
|
136
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
112
137
|
}
|
|
113
138
|
|
|
114
139
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -178,18 +203,18 @@ function takeFromExternrefTable0(idx) {
|
|
|
178
203
|
return value;
|
|
179
204
|
}
|
|
180
205
|
|
|
181
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
206
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
182
207
|
cachedTextDecoder.decode();
|
|
183
208
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
184
209
|
let numBytesDecoded = 0;
|
|
185
|
-
function decodeText(
|
|
186
|
-
numBytesDecoded +=
|
|
210
|
+
function decodeText(bytes) {
|
|
211
|
+
numBytesDecoded += bytes.length;
|
|
187
212
|
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
188
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
213
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
189
214
|
cachedTextDecoder.decode();
|
|
190
|
-
numBytesDecoded =
|
|
215
|
+
numBytesDecoded = bytes.length;
|
|
191
216
|
}
|
|
192
|
-
return cachedTextDecoder.decode(
|
|
217
|
+
return cachedTextDecoder.decode(bytes);
|
|
193
218
|
}
|
|
194
219
|
|
|
195
220
|
const cachedTextEncoder = new TextEncoder();
|
package/xwing_bg.wasm
CHANGED
|
Binary file
|