@rabbitlock/runtime 0.1.0
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/LICENSE +21 -0
- package/README.md +38 -0
- package/package.json +25 -0
- package/pkg/package.json +14 -0
- package/pkg/rabbitlock_crypto.d.ts +133 -0
- package/pkg/rabbitlock_crypto.js +971 -0
- package/pkg/rabbitlock_crypto_bg.js +849 -0
- package/pkg/rabbitlock_crypto_bg.wasm +0 -0
- package/pkg/rabbitlock_crypto_bg.wasm.d.ts +30 -0
- package/rabbitlock-env.mjs +163 -0
- package/rabbitlock_env.py +83 -0
- package/runtime.test.mjs +110 -0
|
@@ -0,0 +1,971 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
function addToExternrefTable0(obj) {
|
|
4
|
+
const idx = wasm.__externref_table_alloc();
|
|
5
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
6
|
+
return idx;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function debugString(val) {
|
|
10
|
+
// primitive types
|
|
11
|
+
const type = typeof val;
|
|
12
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
13
|
+
return `${val}`;
|
|
14
|
+
}
|
|
15
|
+
if (type == 'string') {
|
|
16
|
+
return `"${val}"`;
|
|
17
|
+
}
|
|
18
|
+
if (type == 'symbol') {
|
|
19
|
+
const description = val.description;
|
|
20
|
+
if (description == null) {
|
|
21
|
+
return 'Symbol';
|
|
22
|
+
} else {
|
|
23
|
+
return `Symbol(${description})`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (type == 'function') {
|
|
27
|
+
const name = val.name;
|
|
28
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
29
|
+
return `Function(${name})`;
|
|
30
|
+
} else {
|
|
31
|
+
return 'Function';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// objects
|
|
35
|
+
if (Array.isArray(val)) {
|
|
36
|
+
const length = val.length;
|
|
37
|
+
let debug = '[';
|
|
38
|
+
if (length > 0) {
|
|
39
|
+
debug += debugString(val[0]);
|
|
40
|
+
}
|
|
41
|
+
for(let i = 1; i < length; i++) {
|
|
42
|
+
debug += ', ' + debugString(val[i]);
|
|
43
|
+
}
|
|
44
|
+
debug += ']';
|
|
45
|
+
return debug;
|
|
46
|
+
}
|
|
47
|
+
// Test for built-in
|
|
48
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
49
|
+
let className;
|
|
50
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
51
|
+
className = builtInMatches[1];
|
|
52
|
+
} else {
|
|
53
|
+
// Failed to match the standard '[object ClassName]'
|
|
54
|
+
return toString.call(val);
|
|
55
|
+
}
|
|
56
|
+
if (className == 'Object') {
|
|
57
|
+
// we're a user defined class or Object
|
|
58
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
59
|
+
// easier than looping through ownProperties of `val`.
|
|
60
|
+
try {
|
|
61
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
62
|
+
} catch (_) {
|
|
63
|
+
return 'Object';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// errors
|
|
67
|
+
if (val instanceof Error) {
|
|
68
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
69
|
+
}
|
|
70
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
71
|
+
return className;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
75
|
+
ptr = ptr >>> 0;
|
|
76
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let cachedDataViewMemory0 = null;
|
|
80
|
+
function getDataViewMemory0() {
|
|
81
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
82
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
83
|
+
}
|
|
84
|
+
return cachedDataViewMemory0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getStringFromWasm0(ptr, len) {
|
|
88
|
+
ptr = ptr >>> 0;
|
|
89
|
+
return decodeText(ptr, len);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let cachedUint8ArrayMemory0 = null;
|
|
93
|
+
function getUint8ArrayMemory0() {
|
|
94
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
95
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
96
|
+
}
|
|
97
|
+
return cachedUint8ArrayMemory0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function handleError(f, args) {
|
|
101
|
+
try {
|
|
102
|
+
return f.apply(this, args);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
const idx = addToExternrefTable0(e);
|
|
105
|
+
wasm.__wbindgen_exn_store(idx);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isLikeNone(x) {
|
|
110
|
+
return x === undefined || x === null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
114
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
115
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
116
|
+
WASM_VECTOR_LEN = arg.length;
|
|
117
|
+
return ptr;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
121
|
+
if (realloc === undefined) {
|
|
122
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
123
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
124
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
125
|
+
WASM_VECTOR_LEN = buf.length;
|
|
126
|
+
return ptr;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let len = arg.length;
|
|
130
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
131
|
+
|
|
132
|
+
const mem = getUint8ArrayMemory0();
|
|
133
|
+
|
|
134
|
+
let offset = 0;
|
|
135
|
+
|
|
136
|
+
for (; offset < len; offset++) {
|
|
137
|
+
const code = arg.charCodeAt(offset);
|
|
138
|
+
if (code > 0x7F) break;
|
|
139
|
+
mem[ptr + offset] = code;
|
|
140
|
+
}
|
|
141
|
+
if (offset !== len) {
|
|
142
|
+
if (offset !== 0) {
|
|
143
|
+
arg = arg.slice(offset);
|
|
144
|
+
}
|
|
145
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
146
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
147
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
148
|
+
|
|
149
|
+
offset += ret.written;
|
|
150
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
WASM_VECTOR_LEN = offset;
|
|
154
|
+
return ptr;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function takeFromExternrefTable0(idx) {
|
|
158
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
159
|
+
wasm.__externref_table_dealloc(idx);
|
|
160
|
+
return value;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
164
|
+
cachedTextDecoder.decode();
|
|
165
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
166
|
+
let numBytesDecoded = 0;
|
|
167
|
+
function decodeText(ptr, len) {
|
|
168
|
+
numBytesDecoded += len;
|
|
169
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
170
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
171
|
+
cachedTextDecoder.decode();
|
|
172
|
+
numBytesDecoded = len;
|
|
173
|
+
}
|
|
174
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const cachedTextEncoder = new TextEncoder();
|
|
178
|
+
|
|
179
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
180
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
181
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
182
|
+
view.set(buf);
|
|
183
|
+
return {
|
|
184
|
+
read: arg.length,
|
|
185
|
+
written: buf.length
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let WASM_VECTOR_LEN = 0;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @param {any} files_js
|
|
194
|
+
* @returns {Uint8Array}
|
|
195
|
+
*/
|
|
196
|
+
export function create_zip_archive(files_js) {
|
|
197
|
+
const ret = wasm.create_zip_archive(files_js);
|
|
198
|
+
if (ret[3]) {
|
|
199
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
200
|
+
}
|
|
201
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
202
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
203
|
+
return v1;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @param {string} json_input
|
|
208
|
+
* @param {string} private_key
|
|
209
|
+
* @returns {string}
|
|
210
|
+
*/
|
|
211
|
+
export function decrypt_and_verify_sops(json_input, private_key) {
|
|
212
|
+
let deferred4_0;
|
|
213
|
+
let deferred4_1;
|
|
214
|
+
try {
|
|
215
|
+
const ptr0 = passStringToWasm0(json_input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
216
|
+
const len0 = WASM_VECTOR_LEN;
|
|
217
|
+
const ptr1 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
218
|
+
const len1 = WASM_VECTOR_LEN;
|
|
219
|
+
const ret = wasm.decrypt_and_verify_sops(ptr0, len0, ptr1, len1);
|
|
220
|
+
var ptr3 = ret[0];
|
|
221
|
+
var len3 = ret[1];
|
|
222
|
+
if (ret[3]) {
|
|
223
|
+
ptr3 = 0; len3 = 0;
|
|
224
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
225
|
+
}
|
|
226
|
+
deferred4_0 = ptr3;
|
|
227
|
+
deferred4_1 = len3;
|
|
228
|
+
return getStringFromWasm0(ptr3, len3);
|
|
229
|
+
} finally {
|
|
230
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @param {Uint8Array} data
|
|
236
|
+
* @param {string} secret_key_hex
|
|
237
|
+
* @returns {Uint8Array}
|
|
238
|
+
*/
|
|
239
|
+
export function decrypt_binary_hybrid(data, secret_key_hex) {
|
|
240
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
241
|
+
const len0 = WASM_VECTOR_LEN;
|
|
242
|
+
const ptr1 = passStringToWasm0(secret_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
243
|
+
const len1 = WASM_VECTOR_LEN;
|
|
244
|
+
const ret = wasm.decrypt_binary_hybrid(ptr0, len0, ptr1, len1);
|
|
245
|
+
if (ret[3]) {
|
|
246
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
247
|
+
}
|
|
248
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
249
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
250
|
+
return v3;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @param {string} json_input
|
|
255
|
+
* @param {string} private_key
|
|
256
|
+
* @returns {string}
|
|
257
|
+
*/
|
|
258
|
+
export function decrypt_data_key(json_input, private_key) {
|
|
259
|
+
let deferred4_0;
|
|
260
|
+
let deferred4_1;
|
|
261
|
+
try {
|
|
262
|
+
const ptr0 = passStringToWasm0(json_input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
263
|
+
const len0 = WASM_VECTOR_LEN;
|
|
264
|
+
const ptr1 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
265
|
+
const len1 = WASM_VECTOR_LEN;
|
|
266
|
+
const ret = wasm.decrypt_data_key(ptr0, len0, ptr1, len1);
|
|
267
|
+
var ptr3 = ret[0];
|
|
268
|
+
var len3 = ret[1];
|
|
269
|
+
if (ret[3]) {
|
|
270
|
+
ptr3 = 0; len3 = 0;
|
|
271
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
272
|
+
}
|
|
273
|
+
deferred4_0 = ptr3;
|
|
274
|
+
deferred4_1 = len3;
|
|
275
|
+
return getStringFromWasm0(ptr3, len3);
|
|
276
|
+
} finally {
|
|
277
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Decrypt and return the full decrypted SOPS file as JSON string
|
|
283
|
+
* Returns: JSON string with decrypted values (sops metadata still encrypted)
|
|
284
|
+
* @param {string} json_input
|
|
285
|
+
* @param {string} private_key
|
|
286
|
+
* @returns {string}
|
|
287
|
+
*/
|
|
288
|
+
export function decrypt_sops_content(json_input, private_key) {
|
|
289
|
+
let deferred4_0;
|
|
290
|
+
let deferred4_1;
|
|
291
|
+
try {
|
|
292
|
+
const ptr0 = passStringToWasm0(json_input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
293
|
+
const len0 = WASM_VECTOR_LEN;
|
|
294
|
+
const ptr1 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
295
|
+
const len1 = WASM_VECTOR_LEN;
|
|
296
|
+
const ret = wasm.decrypt_sops_content(ptr0, len0, ptr1, len1);
|
|
297
|
+
var ptr3 = ret[0];
|
|
298
|
+
var len3 = ret[1];
|
|
299
|
+
if (ret[3]) {
|
|
300
|
+
ptr3 = 0; len3 = 0;
|
|
301
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
302
|
+
}
|
|
303
|
+
deferred4_0 = ptr3;
|
|
304
|
+
deferred4_1 = len3;
|
|
305
|
+
return getStringFromWasm0(ptr3, len3);
|
|
306
|
+
} finally {
|
|
307
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @param {string} seed_hex
|
|
313
|
+
* @returns {string}
|
|
314
|
+
*/
|
|
315
|
+
export function derive_hybrid_keypair(seed_hex) {
|
|
316
|
+
let deferred3_0;
|
|
317
|
+
let deferred3_1;
|
|
318
|
+
try {
|
|
319
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
320
|
+
const len0 = WASM_VECTOR_LEN;
|
|
321
|
+
const ret = wasm.derive_hybrid_keypair(ptr0, len0);
|
|
322
|
+
var ptr2 = ret[0];
|
|
323
|
+
var len2 = ret[1];
|
|
324
|
+
if (ret[3]) {
|
|
325
|
+
ptr2 = 0; len2 = 0;
|
|
326
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
327
|
+
}
|
|
328
|
+
deferred3_0 = ptr2;
|
|
329
|
+
deferred3_1 = len2;
|
|
330
|
+
return getStringFromWasm0(ptr2, len2);
|
|
331
|
+
} finally {
|
|
332
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* @param {Uint8Array} data
|
|
338
|
+
* @param {string} recipient_pubkey_hex
|
|
339
|
+
* @returns {Uint8Array}
|
|
340
|
+
*/
|
|
341
|
+
export function encrypt_binary_hybrid(data, recipient_pubkey_hex) {
|
|
342
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
343
|
+
const len0 = WASM_VECTOR_LEN;
|
|
344
|
+
const ptr1 = passStringToWasm0(recipient_pubkey_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
345
|
+
const len1 = WASM_VECTOR_LEN;
|
|
346
|
+
const ret = wasm.encrypt_binary_hybrid(ptr0, len0, ptr1, len1);
|
|
347
|
+
if (ret[3]) {
|
|
348
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
349
|
+
}
|
|
350
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
351
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
352
|
+
return v3;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* @param {string} plain_json
|
|
357
|
+
* @param {string} data_key_hex
|
|
358
|
+
* @returns {string}
|
|
359
|
+
*/
|
|
360
|
+
export function encrypt_sops_json(plain_json, data_key_hex) {
|
|
361
|
+
let deferred4_0;
|
|
362
|
+
let deferred4_1;
|
|
363
|
+
try {
|
|
364
|
+
const ptr0 = passStringToWasm0(plain_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
365
|
+
const len0 = WASM_VECTOR_LEN;
|
|
366
|
+
const ptr1 = passStringToWasm0(data_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
367
|
+
const len1 = WASM_VECTOR_LEN;
|
|
368
|
+
const ret = wasm.encrypt_sops_json(ptr0, len0, ptr1, len1);
|
|
369
|
+
var ptr3 = ret[0];
|
|
370
|
+
var len3 = ret[1];
|
|
371
|
+
if (ret[3]) {
|
|
372
|
+
ptr3 = 0; len3 = 0;
|
|
373
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
374
|
+
}
|
|
375
|
+
deferred4_0 = ptr3;
|
|
376
|
+
deferred4_1 = len3;
|
|
377
|
+
return getStringFromWasm0(ptr3, len3);
|
|
378
|
+
} finally {
|
|
379
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @param {string} plain_json
|
|
385
|
+
* @param {string} recipient_pubkey_hex
|
|
386
|
+
* @returns {string}
|
|
387
|
+
*/
|
|
388
|
+
export function encrypt_sops_json_for_recipient(plain_json, recipient_pubkey_hex) {
|
|
389
|
+
let deferred4_0;
|
|
390
|
+
let deferred4_1;
|
|
391
|
+
try {
|
|
392
|
+
const ptr0 = passStringToWasm0(plain_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
393
|
+
const len0 = WASM_VECTOR_LEN;
|
|
394
|
+
const ptr1 = passStringToWasm0(recipient_pubkey_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
395
|
+
const len1 = WASM_VECTOR_LEN;
|
|
396
|
+
const ret = wasm.encrypt_sops_json_for_recipient(ptr0, len0, ptr1, len1);
|
|
397
|
+
var ptr3 = ret[0];
|
|
398
|
+
var len3 = ret[1];
|
|
399
|
+
if (ret[3]) {
|
|
400
|
+
ptr3 = 0; len3 = 0;
|
|
401
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
402
|
+
}
|
|
403
|
+
deferred4_0 = ptr3;
|
|
404
|
+
deferred4_1 = len3;
|
|
405
|
+
return getStringFromWasm0(ptr3, len3);
|
|
406
|
+
} finally {
|
|
407
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* @param {string} name
|
|
413
|
+
* @returns {string}
|
|
414
|
+
*/
|
|
415
|
+
export function greet(name) {
|
|
416
|
+
let deferred2_0;
|
|
417
|
+
let deferred2_1;
|
|
418
|
+
try {
|
|
419
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
420
|
+
const len0 = WASM_VECTOR_LEN;
|
|
421
|
+
const ret = wasm.greet(ptr0, len0);
|
|
422
|
+
deferred2_0 = ret[0];
|
|
423
|
+
deferred2_1 = ret[1];
|
|
424
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
425
|
+
} finally {
|
|
426
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* @param {string} json_input
|
|
432
|
+
* @returns {string}
|
|
433
|
+
*/
|
|
434
|
+
export function parse_and_verify_sops(json_input) {
|
|
435
|
+
let deferred2_0;
|
|
436
|
+
let deferred2_1;
|
|
437
|
+
try {
|
|
438
|
+
const ptr0 = passStringToWasm0(json_input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
439
|
+
const len0 = WASM_VECTOR_LEN;
|
|
440
|
+
const ret = wasm.parse_and_verify_sops(ptr0, len0);
|
|
441
|
+
deferred2_0 = ret[0];
|
|
442
|
+
deferred2_1 = ret[1];
|
|
443
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
444
|
+
} finally {
|
|
445
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Decapsulate a shared secret using your private key
|
|
451
|
+
* secret_key_hex: 2432 bytes as hex
|
|
452
|
+
* ciphertext_hex: 1120 bytes as hex
|
|
453
|
+
* Returns: shared_secret_hex (64 hex chars = 32 bytes)
|
|
454
|
+
* @param {string} secret_key_hex
|
|
455
|
+
* @param {string} ciphertext_hex
|
|
456
|
+
* @returns {string}
|
|
457
|
+
*/
|
|
458
|
+
export function pq_decapsulate(secret_key_hex, ciphertext_hex) {
|
|
459
|
+
let deferred4_0;
|
|
460
|
+
let deferred4_1;
|
|
461
|
+
try {
|
|
462
|
+
const ptr0 = passStringToWasm0(secret_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
463
|
+
const len0 = WASM_VECTOR_LEN;
|
|
464
|
+
const ptr1 = passStringToWasm0(ciphertext_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
465
|
+
const len1 = WASM_VECTOR_LEN;
|
|
466
|
+
const ret = wasm.pq_decapsulate(ptr0, len0, ptr1, len1);
|
|
467
|
+
var ptr3 = ret[0];
|
|
468
|
+
var len3 = ret[1];
|
|
469
|
+
if (ret[3]) {
|
|
470
|
+
ptr3 = 0; len3 = 0;
|
|
471
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
472
|
+
}
|
|
473
|
+
deferred4_0 = ptr3;
|
|
474
|
+
deferred4_1 = len3;
|
|
475
|
+
return getStringFromWasm0(ptr3, len3);
|
|
476
|
+
} finally {
|
|
477
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Encapsulate a shared secret for a recipient's hybrid public key
|
|
483
|
+
* pub_key_hex: 1216 bytes (32 X25519 + 1184 ML-KEM) as hex
|
|
484
|
+
* Returns: "shared_secret_hex:ciphertext_hex"
|
|
485
|
+
* @param {string} pub_key_hex
|
|
486
|
+
* @returns {string}
|
|
487
|
+
*/
|
|
488
|
+
export function pq_encapsulate(pub_key_hex) {
|
|
489
|
+
let deferred3_0;
|
|
490
|
+
let deferred3_1;
|
|
491
|
+
try {
|
|
492
|
+
const ptr0 = passStringToWasm0(pub_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
493
|
+
const len0 = WASM_VECTOR_LEN;
|
|
494
|
+
const ret = wasm.pq_encapsulate(ptr0, len0);
|
|
495
|
+
var ptr2 = ret[0];
|
|
496
|
+
var len2 = ret[1];
|
|
497
|
+
if (ret[3]) {
|
|
498
|
+
ptr2 = 0; len2 = 0;
|
|
499
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
500
|
+
}
|
|
501
|
+
deferred3_0 = ptr2;
|
|
502
|
+
deferred3_1 = len2;
|
|
503
|
+
return getStringFromWasm0(ptr2, len2);
|
|
504
|
+
} finally {
|
|
505
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Generate a new hybrid keypair (X25519 + ML-KEM-768)
|
|
511
|
+
* Returns: "secret_key_hex:public_key_hex"
|
|
512
|
+
* @returns {string}
|
|
513
|
+
*/
|
|
514
|
+
export function pq_generate_keypair() {
|
|
515
|
+
let deferred1_0;
|
|
516
|
+
let deferred1_1;
|
|
517
|
+
try {
|
|
518
|
+
const ret = wasm.pq_generate_keypair();
|
|
519
|
+
deferred1_0 = ret[0];
|
|
520
|
+
deferred1_1 = ret[1];
|
|
521
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
522
|
+
} finally {
|
|
523
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Get the size constants for documentation
|
|
529
|
+
* Get the size constants for documentation
|
|
530
|
+
* @returns {string}
|
|
531
|
+
*/
|
|
532
|
+
export function pq_get_sizes() {
|
|
533
|
+
let deferred1_0;
|
|
534
|
+
let deferred1_1;
|
|
535
|
+
try {
|
|
536
|
+
const ret = wasm.pq_get_sizes();
|
|
537
|
+
deferred1_0 = ret[0];
|
|
538
|
+
deferred1_1 = ret[1];
|
|
539
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
540
|
+
} finally {
|
|
541
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Decapsulate a shared secret using an ML-KEM-768 secret key (PQ-only)
|
|
547
|
+
* secret_key_hex: 2400 bytes as hex
|
|
548
|
+
* ciphertext_hex: 1088 bytes as hex
|
|
549
|
+
* Returns: shared_secret_hex (64 hex chars = 32 bytes)
|
|
550
|
+
* @param {string} secret_key_hex
|
|
551
|
+
* @param {string} ciphertext_hex
|
|
552
|
+
* @returns {string}
|
|
553
|
+
*/
|
|
554
|
+
export function pq_mlkem_decapsulate(secret_key_hex, ciphertext_hex) {
|
|
555
|
+
let deferred4_0;
|
|
556
|
+
let deferred4_1;
|
|
557
|
+
try {
|
|
558
|
+
const ptr0 = passStringToWasm0(secret_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
559
|
+
const len0 = WASM_VECTOR_LEN;
|
|
560
|
+
const ptr1 = passStringToWasm0(ciphertext_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
561
|
+
const len1 = WASM_VECTOR_LEN;
|
|
562
|
+
const ret = wasm.pq_mlkem_decapsulate(ptr0, len0, ptr1, len1);
|
|
563
|
+
var ptr3 = ret[0];
|
|
564
|
+
var len3 = ret[1];
|
|
565
|
+
if (ret[3]) {
|
|
566
|
+
ptr3 = 0; len3 = 0;
|
|
567
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
568
|
+
}
|
|
569
|
+
deferred4_0 = ptr3;
|
|
570
|
+
deferred4_1 = len3;
|
|
571
|
+
return getStringFromWasm0(ptr3, len3);
|
|
572
|
+
} finally {
|
|
573
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Encapsulate a shared secret for an ML-KEM-768 public key (PQ-only)
|
|
579
|
+
* pub_key_hex: 1184 bytes as hex
|
|
580
|
+
* Returns: "shared_secret_hex:ciphertext_hex"
|
|
581
|
+
* @param {string} pub_key_hex
|
|
582
|
+
* @returns {string}
|
|
583
|
+
*/
|
|
584
|
+
export function pq_mlkem_encapsulate(pub_key_hex) {
|
|
585
|
+
let deferred3_0;
|
|
586
|
+
let deferred3_1;
|
|
587
|
+
try {
|
|
588
|
+
const ptr0 = passStringToWasm0(pub_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
589
|
+
const len0 = WASM_VECTOR_LEN;
|
|
590
|
+
const ret = wasm.pq_mlkem_encapsulate(ptr0, len0);
|
|
591
|
+
var ptr2 = ret[0];
|
|
592
|
+
var len2 = ret[1];
|
|
593
|
+
if (ret[3]) {
|
|
594
|
+
ptr2 = 0; len2 = 0;
|
|
595
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
596
|
+
}
|
|
597
|
+
deferred3_0 = ptr2;
|
|
598
|
+
deferred3_1 = len2;
|
|
599
|
+
return getStringFromWasm0(ptr2, len2);
|
|
600
|
+
} finally {
|
|
601
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Generate a new ML-KEM-768 keypair (PQ-only)
|
|
607
|
+
* Returns: "secret_key_hex:public_key_hex"
|
|
608
|
+
* @returns {string}
|
|
609
|
+
*/
|
|
610
|
+
export function pq_mlkem_generate_keypair() {
|
|
611
|
+
let deferred1_0;
|
|
612
|
+
let deferred1_1;
|
|
613
|
+
try {
|
|
614
|
+
const ret = wasm.pq_mlkem_generate_keypair();
|
|
615
|
+
deferred1_0 = ret[0];
|
|
616
|
+
deferred1_1 = ret[1];
|
|
617
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
618
|
+
} finally {
|
|
619
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* @param {string} json_input
|
|
625
|
+
* @param {string} data_key_hex
|
|
626
|
+
* @returns {string}
|
|
627
|
+
*/
|
|
628
|
+
export function verify_sops_integrity(json_input, data_key_hex) {
|
|
629
|
+
let deferred3_0;
|
|
630
|
+
let deferred3_1;
|
|
631
|
+
try {
|
|
632
|
+
const ptr0 = passStringToWasm0(json_input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
633
|
+
const len0 = WASM_VECTOR_LEN;
|
|
634
|
+
const ptr1 = passStringToWasm0(data_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
635
|
+
const len1 = WASM_VECTOR_LEN;
|
|
636
|
+
const ret = wasm.verify_sops_integrity(ptr0, len0, ptr1, len1);
|
|
637
|
+
deferred3_0 = ret[0];
|
|
638
|
+
deferred3_1 = ret[1];
|
|
639
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
640
|
+
} finally {
|
|
641
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
646
|
+
|
|
647
|
+
async function __wbg_load(module, imports) {
|
|
648
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
649
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
650
|
+
try {
|
|
651
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
652
|
+
} catch (e) {
|
|
653
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
654
|
+
|
|
655
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
656
|
+
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);
|
|
657
|
+
|
|
658
|
+
} else {
|
|
659
|
+
throw e;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
const bytes = await module.arrayBuffer();
|
|
665
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
666
|
+
} else {
|
|
667
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
668
|
+
|
|
669
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
670
|
+
return { instance, module };
|
|
671
|
+
} else {
|
|
672
|
+
return instance;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
function __wbg_get_imports() {
|
|
678
|
+
const imports = {};
|
|
679
|
+
imports.wbg = {};
|
|
680
|
+
imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
|
|
681
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
682
|
+
return ret;
|
|
683
|
+
};
|
|
684
|
+
imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
|
|
685
|
+
const ret = Number(arg0);
|
|
686
|
+
return ret;
|
|
687
|
+
};
|
|
688
|
+
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
689
|
+
const ret = String(arg1);
|
|
690
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
691
|
+
const len1 = WASM_VECTOR_LEN;
|
|
692
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
693
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
694
|
+
};
|
|
695
|
+
imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
|
|
696
|
+
const v = arg0;
|
|
697
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
698
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
699
|
+
};
|
|
700
|
+
imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
|
|
701
|
+
const ret = debugString(arg1);
|
|
702
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
703
|
+
const len1 = WASM_VECTOR_LEN;
|
|
704
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
705
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
706
|
+
};
|
|
707
|
+
imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
|
|
708
|
+
const ret = arg0 in arg1;
|
|
709
|
+
return ret;
|
|
710
|
+
};
|
|
711
|
+
imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
|
|
712
|
+
const ret = typeof(arg0) === 'function';
|
|
713
|
+
return ret;
|
|
714
|
+
};
|
|
715
|
+
imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
|
|
716
|
+
const val = arg0;
|
|
717
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
718
|
+
return ret;
|
|
719
|
+
};
|
|
720
|
+
imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
|
|
721
|
+
const ret = typeof(arg0) === 'string';
|
|
722
|
+
return ret;
|
|
723
|
+
};
|
|
724
|
+
imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
|
|
725
|
+
const ret = arg0 === undefined;
|
|
726
|
+
return ret;
|
|
727
|
+
};
|
|
728
|
+
imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
|
|
729
|
+
const ret = arg0 == arg1;
|
|
730
|
+
return ret;
|
|
731
|
+
};
|
|
732
|
+
imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
|
|
733
|
+
const obj = arg1;
|
|
734
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
735
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
736
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
737
|
+
};
|
|
738
|
+
imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
|
739
|
+
const obj = arg1;
|
|
740
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
741
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
742
|
+
var len1 = WASM_VECTOR_LEN;
|
|
743
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
744
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
745
|
+
};
|
|
746
|
+
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
747
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
748
|
+
};
|
|
749
|
+
imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
750
|
+
const ret = arg0.call(arg1, arg2);
|
|
751
|
+
return ret;
|
|
752
|
+
}, arguments) };
|
|
753
|
+
imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
|
|
754
|
+
const ret = arg0.call(arg1);
|
|
755
|
+
return ret;
|
|
756
|
+
}, arguments) };
|
|
757
|
+
imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
|
758
|
+
const ret = arg0.crypto;
|
|
759
|
+
return ret;
|
|
760
|
+
};
|
|
761
|
+
imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
|
|
762
|
+
const ret = arg0.done;
|
|
763
|
+
return ret;
|
|
764
|
+
};
|
|
765
|
+
imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
766
|
+
arg0.getRandomValues(arg1);
|
|
767
|
+
}, arguments) };
|
|
768
|
+
imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
|
|
769
|
+
const ret = arg0[arg1 >>> 0];
|
|
770
|
+
return ret;
|
|
771
|
+
};
|
|
772
|
+
imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
|
|
773
|
+
const ret = Reflect.get(arg0, arg1);
|
|
774
|
+
return ret;
|
|
775
|
+
}, arguments) };
|
|
776
|
+
imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
|
|
777
|
+
const ret = arg0[arg1];
|
|
778
|
+
return ret;
|
|
779
|
+
};
|
|
780
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
|
|
781
|
+
let result;
|
|
782
|
+
try {
|
|
783
|
+
result = arg0 instanceof ArrayBuffer;
|
|
784
|
+
} catch (_) {
|
|
785
|
+
result = false;
|
|
786
|
+
}
|
|
787
|
+
const ret = result;
|
|
788
|
+
return ret;
|
|
789
|
+
};
|
|
790
|
+
imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
|
|
791
|
+
let result;
|
|
792
|
+
try {
|
|
793
|
+
result = arg0 instanceof Uint8Array;
|
|
794
|
+
} catch (_) {
|
|
795
|
+
result = false;
|
|
796
|
+
}
|
|
797
|
+
const ret = result;
|
|
798
|
+
return ret;
|
|
799
|
+
};
|
|
800
|
+
imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
|
|
801
|
+
const ret = Array.isArray(arg0);
|
|
802
|
+
return ret;
|
|
803
|
+
};
|
|
804
|
+
imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
|
|
805
|
+
const ret = Number.isSafeInteger(arg0);
|
|
806
|
+
return ret;
|
|
807
|
+
};
|
|
808
|
+
imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
|
|
809
|
+
const ret = Symbol.iterator;
|
|
810
|
+
return ret;
|
|
811
|
+
};
|
|
812
|
+
imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
|
|
813
|
+
const ret = arg0.length;
|
|
814
|
+
return ret;
|
|
815
|
+
};
|
|
816
|
+
imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
|
|
817
|
+
const ret = arg0.length;
|
|
818
|
+
return ret;
|
|
819
|
+
};
|
|
820
|
+
imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
|
821
|
+
const ret = arg0.msCrypto;
|
|
822
|
+
return ret;
|
|
823
|
+
};
|
|
824
|
+
imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
|
|
825
|
+
const ret = new Uint8Array(arg0);
|
|
826
|
+
return ret;
|
|
827
|
+
};
|
|
828
|
+
imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
|
|
829
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
830
|
+
return ret;
|
|
831
|
+
};
|
|
832
|
+
imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
|
|
833
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
834
|
+
return ret;
|
|
835
|
+
};
|
|
836
|
+
imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
|
|
837
|
+
const ret = arg0.next;
|
|
838
|
+
return ret;
|
|
839
|
+
};
|
|
840
|
+
imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
|
|
841
|
+
const ret = arg0.next();
|
|
842
|
+
return ret;
|
|
843
|
+
}, arguments) };
|
|
844
|
+
imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
|
|
845
|
+
const ret = arg0.node;
|
|
846
|
+
return ret;
|
|
847
|
+
};
|
|
848
|
+
imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
|
|
849
|
+
const ret = arg0.process;
|
|
850
|
+
return ret;
|
|
851
|
+
};
|
|
852
|
+
imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
|
|
853
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
854
|
+
};
|
|
855
|
+
imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
|
|
856
|
+
arg0.randomFillSync(arg1);
|
|
857
|
+
}, arguments) };
|
|
858
|
+
imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
|
|
859
|
+
const ret = module.require;
|
|
860
|
+
return ret;
|
|
861
|
+
}, arguments) };
|
|
862
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
|
|
863
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
864
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
865
|
+
};
|
|
866
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
|
|
867
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
868
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
869
|
+
};
|
|
870
|
+
imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
|
|
871
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
872
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
873
|
+
};
|
|
874
|
+
imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
|
|
875
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
876
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
877
|
+
};
|
|
878
|
+
imports.wbg.__wbg_subarray_845f2f5bce7d061a = function(arg0, arg1, arg2) {
|
|
879
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
880
|
+
return ret;
|
|
881
|
+
};
|
|
882
|
+
imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
|
|
883
|
+
const ret = arg0.value;
|
|
884
|
+
return ret;
|
|
885
|
+
};
|
|
886
|
+
imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
|
|
887
|
+
const ret = arg0.versions;
|
|
888
|
+
return ret;
|
|
889
|
+
};
|
|
890
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
891
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
892
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
893
|
+
return ret;
|
|
894
|
+
};
|
|
895
|
+
imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
|
|
896
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
897
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
898
|
+
return ret;
|
|
899
|
+
};
|
|
900
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
901
|
+
const table = wasm.__wbindgen_externrefs;
|
|
902
|
+
const offset = table.grow(4);
|
|
903
|
+
table.set(0, undefined);
|
|
904
|
+
table.set(offset + 0, undefined);
|
|
905
|
+
table.set(offset + 1, null);
|
|
906
|
+
table.set(offset + 2, true);
|
|
907
|
+
table.set(offset + 3, false);
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
return imports;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
function __wbg_finalize_init(instance, module) {
|
|
914
|
+
wasm = instance.exports;
|
|
915
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
916
|
+
cachedDataViewMemory0 = null;
|
|
917
|
+
cachedUint8ArrayMemory0 = null;
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
wasm.__wbindgen_start();
|
|
921
|
+
return wasm;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
function initSync(module) {
|
|
925
|
+
if (wasm !== undefined) return wasm;
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
if (typeof module !== 'undefined') {
|
|
929
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
930
|
+
({module} = module)
|
|
931
|
+
} else {
|
|
932
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
const imports = __wbg_get_imports();
|
|
937
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
938
|
+
module = new WebAssembly.Module(module);
|
|
939
|
+
}
|
|
940
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
941
|
+
return __wbg_finalize_init(instance, module);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
async function __wbg_init(module_or_path) {
|
|
945
|
+
if (wasm !== undefined) return wasm;
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
if (typeof module_or_path !== 'undefined') {
|
|
949
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
950
|
+
({module_or_path} = module_or_path)
|
|
951
|
+
} else {
|
|
952
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
if (typeof module_or_path === 'undefined') {
|
|
957
|
+
module_or_path = new URL('rabbitlock_crypto_bg.wasm', import.meta.url);
|
|
958
|
+
}
|
|
959
|
+
const imports = __wbg_get_imports();
|
|
960
|
+
|
|
961
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
962
|
+
module_or_path = fetch(module_or_path);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
966
|
+
|
|
967
|
+
return __wbg_finalize_init(instance, module);
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
export { initSync };
|
|
971
|
+
export default __wbg_init;
|