@gnufoo/envlp 0.1.1
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/envlp_wasm.d.ts +323 -0
- package/envlp_wasm.js +751 -0
- package/envlp_wasm_bg.wasm +0 -0
- package/envlp_wasm_bg.wasm.d.ts +24 -0
- package/init.d.ts +11 -0
- package/init.js +24 -0
- package/meta.d.ts +85 -0
- package/meta.js +129 -0
- package/package.json +45 -0
- package/tool.d.ts +8 -0
- package/tool.js +169 -0
package/envlp_wasm.js
ADDED
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
/* @ts-self-types="./envlp_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns the key size in bytes (32 = 256 bits).
|
|
5
|
+
* @returns {number}
|
|
6
|
+
*/
|
|
7
|
+
export function KEY_SIZE() {
|
|
8
|
+
const ret = wasm.KEY_SIZE();
|
|
9
|
+
return ret >>> 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns the nonce size in bytes (24 = 192 bits).
|
|
14
|
+
* @returns {number}
|
|
15
|
+
*/
|
|
16
|
+
export function NONCE_SIZE() {
|
|
17
|
+
const ret = wasm.NONCE_SIZE();
|
|
18
|
+
return ret >>> 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns the current envelope format version.
|
|
23
|
+
*
|
|
24
|
+
* Per AAED spec, current version is 1.
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
export function SPEC_VERSION() {
|
|
28
|
+
const ret = wasm.SPEC_VERSION();
|
|
29
|
+
return ret >>> 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns the authentication tag size in bytes (16 = 128 bits).
|
|
34
|
+
* @returns {number}
|
|
35
|
+
*/
|
|
36
|
+
export function TAG_SIZE() {
|
|
37
|
+
const ret = wasm.TAG_SIZE();
|
|
38
|
+
return ret >>> 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Checks if bytes start with the envelope magic prefix.
|
|
43
|
+
*
|
|
44
|
+
* Magic bytes are `0x454E5601` ("ENV" + version byte).
|
|
45
|
+
* This can be used for quick format detection without full CBOR parsing.
|
|
46
|
+
*
|
|
47
|
+
* # Arguments
|
|
48
|
+
*
|
|
49
|
+
* * `bytes` - Bytes to check (Uint8Array)
|
|
50
|
+
*
|
|
51
|
+
* # Returns
|
|
52
|
+
*
|
|
53
|
+
* `true` if bytes start with magic prefix, `false` otherwise.
|
|
54
|
+
*
|
|
55
|
+
* # Example (JavaScript)
|
|
56
|
+
*
|
|
57
|
+
* ```javascript
|
|
58
|
+
* const envelope = seal(key, plaintext, aad, "my-key");
|
|
59
|
+
* console.log(hasMagicPrefix(envelope)); // true
|
|
60
|
+
*
|
|
61
|
+
* const noMagic = seal(key, plaintext, aad, "my-key", true, false);
|
|
62
|
+
* console.log(hasMagicPrefix(noMagic)); // false
|
|
63
|
+
* ```
|
|
64
|
+
* @param {Uint8Array} bytes
|
|
65
|
+
* @returns {boolean}
|
|
66
|
+
*/
|
|
67
|
+
export function hasMagicPrefix(bytes) {
|
|
68
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
69
|
+
const len0 = WASM_VECTOR_LEN;
|
|
70
|
+
const ret = wasm.hasMagicPrefix(ptr0, len0);
|
|
71
|
+
return ret !== 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Inspects envelope metadata without decryption.
|
|
76
|
+
*
|
|
77
|
+
* Returns information about the envelope that can be extracted without
|
|
78
|
+
* decryption. Useful for logging, debugging, and routing decisions
|
|
79
|
+
* (e.g., selecting the correct key based on key_id).
|
|
80
|
+
*
|
|
81
|
+
* # Arguments
|
|
82
|
+
*
|
|
83
|
+
* * `envelope_bytes` - CBOR-encoded envelope (Uint8Array)
|
|
84
|
+
*
|
|
85
|
+
* # Returns
|
|
86
|
+
*
|
|
87
|
+
* JavaScript object with envelope metadata:
|
|
88
|
+
* - `version`: Envelope format version (number)
|
|
89
|
+
* - `algorithm`: Algorithm name (string, e.g., "XChaCha20Poly1305")
|
|
90
|
+
* - `algorithmId`: Algorithm ID (number, 1=XChaCha20, 2=GCM-SIV, 3=GCM)
|
|
91
|
+
* - `keyId`: Key identifier from header (string)
|
|
92
|
+
* - `nonceHex`: Nonce as hexadecimal string
|
|
93
|
+
* - `ciphertextLen`: Ciphertext length in bytes (number)
|
|
94
|
+
* - `hasAad`: Whether AAD is included in envelope (boolean)
|
|
95
|
+
* - `aadLen`: AAD length in bytes (number or null)
|
|
96
|
+
* - `isWrappedMode`: Whether envelope uses wrapped mode (boolean)
|
|
97
|
+
*
|
|
98
|
+
* # Errors
|
|
99
|
+
*
|
|
100
|
+
* Throws a JavaScript error if envelope parsing fails.
|
|
101
|
+
*
|
|
102
|
+
* # Example (JavaScript)
|
|
103
|
+
*
|
|
104
|
+
* ```javascript
|
|
105
|
+
* const meta = inspect(envelope);
|
|
106
|
+
* console.log(`Key: ${meta.keyId}, Algorithm: ${meta.algorithm}`);
|
|
107
|
+
* if (meta.hasAad) {
|
|
108
|
+
* console.log(`AAD size: ${meta.aadLen} bytes`);
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
* @param {Uint8Array} envelope_bytes
|
|
112
|
+
* @returns {any}
|
|
113
|
+
*/
|
|
114
|
+
export function inspect(envelope_bytes) {
|
|
115
|
+
const ptr0 = passArray8ToWasm0(envelope_bytes, wasm.__wbindgen_malloc);
|
|
116
|
+
const len0 = WASM_VECTOR_LEN;
|
|
117
|
+
const ret = wasm.inspect(ptr0, len0);
|
|
118
|
+
if (ret[2]) {
|
|
119
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
120
|
+
}
|
|
121
|
+
return takeFromExternrefTable0(ret[0]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Generates a new 256-bit encryption key.
|
|
126
|
+
*
|
|
127
|
+
* Uses a cryptographically secure random number generator.
|
|
128
|
+
*
|
|
129
|
+
* # Returns
|
|
130
|
+
*
|
|
131
|
+
* A 32-byte `Uint8Array` containing the random key.
|
|
132
|
+
*
|
|
133
|
+
* # Example (JavaScript)
|
|
134
|
+
*
|
|
135
|
+
* ```javascript
|
|
136
|
+
* const key = keygen();
|
|
137
|
+
* console.log(key.length); // 32
|
|
138
|
+
* ```
|
|
139
|
+
* @returns {Uint8Array}
|
|
140
|
+
*/
|
|
141
|
+
export function keygen() {
|
|
142
|
+
const ret = wasm.keygen();
|
|
143
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
144
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
145
|
+
return v1;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns the magic bytes as Uint8Array.
|
|
150
|
+
*
|
|
151
|
+
* Magic bytes are `0x454E5601` ("ENV" + version byte) for format detection.
|
|
152
|
+
* @returns {Uint8Array}
|
|
153
|
+
*/
|
|
154
|
+
export function magicBytes() {
|
|
155
|
+
const ret = wasm.magicBytes();
|
|
156
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
157
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
158
|
+
return v1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Decrypts an envelope using reconstructed AAD.
|
|
163
|
+
*
|
|
164
|
+
* Use this when AAD was not included in the envelope (reconstructed mode).
|
|
165
|
+
* The provided AAD JSON will be canonicalized before verification.
|
|
166
|
+
*
|
|
167
|
+
* # Arguments
|
|
168
|
+
*
|
|
169
|
+
* * `key` - 256-bit decryption key (Uint8Array, 32 bytes)
|
|
170
|
+
* * `envelope_bytes` - CBOR-encoded envelope (Uint8Array)
|
|
171
|
+
* * `aad_json` - AAD as JSON string (must match AAD used during encryption)
|
|
172
|
+
*
|
|
173
|
+
* # Returns
|
|
174
|
+
*
|
|
175
|
+
* Decrypted plaintext as `Uint8Array`.
|
|
176
|
+
*
|
|
177
|
+
* # Errors
|
|
178
|
+
*
|
|
179
|
+
* Throws a JavaScript error with message "DECRYPTION_FAILED" for ANY failure.
|
|
180
|
+
*
|
|
181
|
+
* # Warning
|
|
182
|
+
*
|
|
183
|
+
* Reconstructed AAD requires bit-perfect reproduction of all context values.
|
|
184
|
+
* Unicode normalization differences between systems can cause decryption to fail.
|
|
185
|
+
* Use transmitted AAD for cross-platform deployments.
|
|
186
|
+
*
|
|
187
|
+
* # Example (JavaScript)
|
|
188
|
+
*
|
|
189
|
+
* ```javascript
|
|
190
|
+
* const key = keygen();
|
|
191
|
+
* const aad = '{"v":1,"tenant":"org","resource":"res","purpose":"enc"}';
|
|
192
|
+
*
|
|
193
|
+
* // Seal without AAD in envelope
|
|
194
|
+
* const envelope = seal(key, plaintext, aad, "my-key", false, true);
|
|
195
|
+
*
|
|
196
|
+
* // Reconstruct AAD at decryption time
|
|
197
|
+
* const decrypted = openReconstructed(key, envelope, aad);
|
|
198
|
+
* ```
|
|
199
|
+
* @param {Uint8Array} key
|
|
200
|
+
* @param {Uint8Array} envelope_bytes
|
|
201
|
+
* @param {string} aad_json
|
|
202
|
+
* @returns {Uint8Array}
|
|
203
|
+
*/
|
|
204
|
+
export function openReconstructed(key, envelope_bytes, aad_json) {
|
|
205
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
206
|
+
const len0 = WASM_VECTOR_LEN;
|
|
207
|
+
const ptr1 = passArray8ToWasm0(envelope_bytes, wasm.__wbindgen_malloc);
|
|
208
|
+
const len1 = WASM_VECTOR_LEN;
|
|
209
|
+
const ptr2 = passStringToWasm0(aad_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
210
|
+
const len2 = WASM_VECTOR_LEN;
|
|
211
|
+
const ret = wasm.openReconstructed(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
212
|
+
if (ret[3]) {
|
|
213
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
214
|
+
}
|
|
215
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
216
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
217
|
+
return v4;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Decrypts an envelope using transmitted AAD.
|
|
222
|
+
*
|
|
223
|
+
* This is the common case where AAD is stored in the envelope.
|
|
224
|
+
*
|
|
225
|
+
* # Arguments
|
|
226
|
+
*
|
|
227
|
+
* * `key` - 256-bit decryption key (Uint8Array, 32 bytes)
|
|
228
|
+
* * `envelope_bytes` - CBOR-encoded envelope (Uint8Array)
|
|
229
|
+
*
|
|
230
|
+
* # Returns
|
|
231
|
+
*
|
|
232
|
+
* Decrypted plaintext as `Uint8Array`.
|
|
233
|
+
*
|
|
234
|
+
* # Errors
|
|
235
|
+
*
|
|
236
|
+
* Throws a JavaScript error with message "DECRYPTION_FAILED" for ANY failure:
|
|
237
|
+
* - Invalid envelope format
|
|
238
|
+
* - No transmitted AAD in envelope
|
|
239
|
+
* - Wrong key
|
|
240
|
+
* - Corrupted ciphertext
|
|
241
|
+
* - Mismatched AAD
|
|
242
|
+
*
|
|
243
|
+
* Per AAED spec Section 10, errors are intentionally generic to prevent
|
|
244
|
+
* information leakage.
|
|
245
|
+
*
|
|
246
|
+
* # Example (JavaScript)
|
|
247
|
+
*
|
|
248
|
+
* ```javascript
|
|
249
|
+
* const key = keygen();
|
|
250
|
+
* const envelope = seal(key, plaintext, aad, "my-key");
|
|
251
|
+
*
|
|
252
|
+
* const decrypted = openTransmitted(key, envelope);
|
|
253
|
+
* console.log(new TextDecoder().decode(decrypted));
|
|
254
|
+
* ```
|
|
255
|
+
* @param {Uint8Array} key
|
|
256
|
+
* @param {Uint8Array} envelope_bytes
|
|
257
|
+
* @returns {Uint8Array}
|
|
258
|
+
*/
|
|
259
|
+
export function openTransmitted(key, envelope_bytes) {
|
|
260
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
261
|
+
const len0 = WASM_VECTOR_LEN;
|
|
262
|
+
const ptr1 = passArray8ToWasm0(envelope_bytes, wasm.__wbindgen_malloc);
|
|
263
|
+
const len1 = WASM_VECTOR_LEN;
|
|
264
|
+
const ret = wasm.openTransmitted(ptr0, len0, ptr1, len1);
|
|
265
|
+
if (ret[3]) {
|
|
266
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
267
|
+
}
|
|
268
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
269
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
270
|
+
return v3;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Encrypts plaintext into an envelope.
|
|
275
|
+
*
|
|
276
|
+
* # Arguments
|
|
277
|
+
*
|
|
278
|
+
* * `key` - 256-bit encryption key (Uint8Array, 32 bytes)
|
|
279
|
+
* * `plaintext` - Data to encrypt (Uint8Array)
|
|
280
|
+
* * `aad_json` - AAD as JSON string (will be canonicalized via canaad)
|
|
281
|
+
* * `key_id` - Key identifier string for the envelope header
|
|
282
|
+
* * `include_aad` - Whether to include AAD in envelope (default: true)
|
|
283
|
+
* * `emit_magic` - Whether to emit magic bytes prefix (default: true)
|
|
284
|
+
*
|
|
285
|
+
* # Returns
|
|
286
|
+
*
|
|
287
|
+
* Envelope as `Uint8Array` (CBOR-encoded, optionally with magic prefix).
|
|
288
|
+
*
|
|
289
|
+
* # Errors
|
|
290
|
+
*
|
|
291
|
+
* Throws a JavaScript error if:
|
|
292
|
+
* - Key size is invalid (must be 32 bytes)
|
|
293
|
+
* - AAD JSON canonicalization fails
|
|
294
|
+
* - Key ID exceeds 256 bytes
|
|
295
|
+
*
|
|
296
|
+
* # Example (JavaScript)
|
|
297
|
+
*
|
|
298
|
+
* ```javascript
|
|
299
|
+
* const key = keygen();
|
|
300
|
+
* const plaintext = new TextEncoder().encode("Hello, World!");
|
|
301
|
+
* const aad = '{"v":1,"tenant":"org","resource":"res","purpose":"enc"}';
|
|
302
|
+
*
|
|
303
|
+
* // Default options (include AAD, emit magic)
|
|
304
|
+
* const envelope = seal(key, plaintext, aad, "my-key");
|
|
305
|
+
*
|
|
306
|
+
* // Without AAD in envelope (reconstructed mode)
|
|
307
|
+
* const envelope2 = seal(key, plaintext, aad, "my-key", false, true);
|
|
308
|
+
* ```
|
|
309
|
+
* @param {Uint8Array} key
|
|
310
|
+
* @param {Uint8Array} plaintext
|
|
311
|
+
* @param {string} aad_json
|
|
312
|
+
* @param {string} key_id
|
|
313
|
+
* @param {boolean | null} [include_aad]
|
|
314
|
+
* @param {boolean | null} [emit_magic]
|
|
315
|
+
* @returns {Uint8Array}
|
|
316
|
+
*/
|
|
317
|
+
export function seal(key, plaintext, aad_json, key_id, include_aad, emit_magic) {
|
|
318
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
319
|
+
const len0 = WASM_VECTOR_LEN;
|
|
320
|
+
const ptr1 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
321
|
+
const len1 = WASM_VECTOR_LEN;
|
|
322
|
+
const ptr2 = passStringToWasm0(aad_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
323
|
+
const len2 = WASM_VECTOR_LEN;
|
|
324
|
+
const ptr3 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
325
|
+
const len3 = WASM_VECTOR_LEN;
|
|
326
|
+
const ret = wasm.seal(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, isLikeNone(include_aad) ? 0xFFFFFF : include_aad ? 1 : 0, isLikeNone(emit_magic) ? 0xFFFFFF : emit_magic ? 1 : 0);
|
|
327
|
+
if (ret[3]) {
|
|
328
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
329
|
+
}
|
|
330
|
+
var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
331
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
332
|
+
return v5;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Validates envelope structure without decryption.
|
|
337
|
+
*
|
|
338
|
+
* Checks structural integrity, not cryptographic validity. This is useful
|
|
339
|
+
* for fail-fast validation before attempting expensive operations.
|
|
340
|
+
*
|
|
341
|
+
* # Checks Performed
|
|
342
|
+
*
|
|
343
|
+
* - Envelope version is supported
|
|
344
|
+
* - Algorithm is known
|
|
345
|
+
* - AES-256-GCM has wrapped mode requirement
|
|
346
|
+
* - Ciphertext is at least tag size
|
|
347
|
+
*
|
|
348
|
+
* # Arguments
|
|
349
|
+
*
|
|
350
|
+
* * `envelope_bytes` - CBOR-encoded envelope (Uint8Array)
|
|
351
|
+
*
|
|
352
|
+
* # Returns
|
|
353
|
+
*
|
|
354
|
+
* JavaScript object with validation result:
|
|
355
|
+
* - `valid`: Whether the envelope passed all checks (boolean)
|
|
356
|
+
* - `errors`: Array of error messages (string[])
|
|
357
|
+
*
|
|
358
|
+
* # Example (JavaScript)
|
|
359
|
+
*
|
|
360
|
+
* ```javascript
|
|
361
|
+
* const result = validate(envelope);
|
|
362
|
+
* if (result.valid) {
|
|
363
|
+
* console.log("Envelope is valid");
|
|
364
|
+
* } else {
|
|
365
|
+
* console.error("Validation errors:", result.errors);
|
|
366
|
+
* }
|
|
367
|
+
* ```
|
|
368
|
+
* @param {Uint8Array} envelope_bytes
|
|
369
|
+
* @returns {any}
|
|
370
|
+
*/
|
|
371
|
+
export function validate(envelope_bytes) {
|
|
372
|
+
const ptr0 = passArray8ToWasm0(envelope_bytes, wasm.__wbindgen_malloc);
|
|
373
|
+
const len0 = WASM_VECTOR_LEN;
|
|
374
|
+
const ret = wasm.validate(ptr0, len0);
|
|
375
|
+
if (ret[2]) {
|
|
376
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
377
|
+
}
|
|
378
|
+
return takeFromExternrefTable0(ret[0]);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Returns the library version.
|
|
383
|
+
* @returns {string}
|
|
384
|
+
*/
|
|
385
|
+
export function version() {
|
|
386
|
+
let deferred1_0;
|
|
387
|
+
let deferred1_1;
|
|
388
|
+
try {
|
|
389
|
+
const ret = wasm.version();
|
|
390
|
+
deferred1_0 = ret[0];
|
|
391
|
+
deferred1_1 = ret[1];
|
|
392
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
393
|
+
} finally {
|
|
394
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function __wbg_get_imports() {
|
|
399
|
+
const import0 = {
|
|
400
|
+
__proto__: null,
|
|
401
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
402
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
403
|
+
return ret;
|
|
404
|
+
},
|
|
405
|
+
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
406
|
+
const ret = typeof(arg0) === 'function';
|
|
407
|
+
return ret;
|
|
408
|
+
},
|
|
409
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
410
|
+
const val = arg0;
|
|
411
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
412
|
+
return ret;
|
|
413
|
+
},
|
|
414
|
+
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
|
|
415
|
+
const ret = typeof(arg0) === 'string';
|
|
416
|
+
return ret;
|
|
417
|
+
},
|
|
418
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
419
|
+
const ret = arg0 === undefined;
|
|
420
|
+
return ret;
|
|
421
|
+
},
|
|
422
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
423
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
424
|
+
},
|
|
425
|
+
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
|
|
426
|
+
const ret = arg0.call(arg1);
|
|
427
|
+
return ret;
|
|
428
|
+
}, arguments); },
|
|
429
|
+
__wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
|
|
430
|
+
const ret = arg0.call(arg1, arg2);
|
|
431
|
+
return ret;
|
|
432
|
+
}, arguments); },
|
|
433
|
+
__wbg_crypto_86f2631e91b51511: function(arg0) {
|
|
434
|
+
const ret = arg0.crypto;
|
|
435
|
+
return ret;
|
|
436
|
+
},
|
|
437
|
+
__wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
|
|
438
|
+
arg0.getRandomValues(arg1);
|
|
439
|
+
}, arguments); },
|
|
440
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
441
|
+
const ret = arg0.length;
|
|
442
|
+
return ret;
|
|
443
|
+
},
|
|
444
|
+
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
445
|
+
const ret = arg0.msCrypto;
|
|
446
|
+
return ret;
|
|
447
|
+
},
|
|
448
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
449
|
+
const ret = new Object();
|
|
450
|
+
return ret;
|
|
451
|
+
},
|
|
452
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
453
|
+
const ret = new Array();
|
|
454
|
+
return ret;
|
|
455
|
+
},
|
|
456
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
457
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
458
|
+
return ret;
|
|
459
|
+
},
|
|
460
|
+
__wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
|
|
461
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
462
|
+
return ret;
|
|
463
|
+
},
|
|
464
|
+
__wbg_node_e1f24f89a7336c2e: function(arg0) {
|
|
465
|
+
const ret = arg0.node;
|
|
466
|
+
return ret;
|
|
467
|
+
},
|
|
468
|
+
__wbg_process_3975fd6c72f520aa: function(arg0) {
|
|
469
|
+
const ret = arg0.process;
|
|
470
|
+
return ret;
|
|
471
|
+
},
|
|
472
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
473
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
474
|
+
},
|
|
475
|
+
__wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
|
|
476
|
+
const ret = arg0.push(arg1);
|
|
477
|
+
return ret;
|
|
478
|
+
},
|
|
479
|
+
__wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
|
|
480
|
+
arg0.randomFillSync(arg1);
|
|
481
|
+
}, arguments); },
|
|
482
|
+
__wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
|
|
483
|
+
const ret = module.require;
|
|
484
|
+
return ret;
|
|
485
|
+
}, arguments); },
|
|
486
|
+
__wbg_set_6cb8631f80447a67: function() { return handleError(function (arg0, arg1, arg2) {
|
|
487
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
488
|
+
return ret;
|
|
489
|
+
}, arguments); },
|
|
490
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
491
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
492
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
493
|
+
},
|
|
494
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
495
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
496
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
497
|
+
},
|
|
498
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
499
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
500
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
501
|
+
},
|
|
502
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
503
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
504
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
505
|
+
},
|
|
506
|
+
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
|
|
507
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
508
|
+
return ret;
|
|
509
|
+
},
|
|
510
|
+
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
511
|
+
const ret = arg0.versions;
|
|
512
|
+
return ret;
|
|
513
|
+
},
|
|
514
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
515
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
516
|
+
const ret = arg0;
|
|
517
|
+
return ret;
|
|
518
|
+
},
|
|
519
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
520
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
521
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
522
|
+
return ret;
|
|
523
|
+
},
|
|
524
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
525
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
526
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
527
|
+
return ret;
|
|
528
|
+
},
|
|
529
|
+
__wbindgen_init_externref_table: function() {
|
|
530
|
+
const table = wasm.__wbindgen_externrefs;
|
|
531
|
+
const offset = table.grow(4);
|
|
532
|
+
table.set(0, undefined);
|
|
533
|
+
table.set(offset + 0, undefined);
|
|
534
|
+
table.set(offset + 1, null);
|
|
535
|
+
table.set(offset + 2, true);
|
|
536
|
+
table.set(offset + 3, false);
|
|
537
|
+
},
|
|
538
|
+
};
|
|
539
|
+
return {
|
|
540
|
+
__proto__: null,
|
|
541
|
+
"./envlp_wasm_bg.js": import0,
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function addToExternrefTable0(obj) {
|
|
546
|
+
const idx = wasm.__externref_table_alloc();
|
|
547
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
548
|
+
return idx;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
552
|
+
ptr = ptr >>> 0;
|
|
553
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function getStringFromWasm0(ptr, len) {
|
|
557
|
+
ptr = ptr >>> 0;
|
|
558
|
+
return decodeText(ptr, len);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
let cachedUint8ArrayMemory0 = null;
|
|
562
|
+
function getUint8ArrayMemory0() {
|
|
563
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
564
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
565
|
+
}
|
|
566
|
+
return cachedUint8ArrayMemory0;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function handleError(f, args) {
|
|
570
|
+
try {
|
|
571
|
+
return f.apply(this, args);
|
|
572
|
+
} catch (e) {
|
|
573
|
+
const idx = addToExternrefTable0(e);
|
|
574
|
+
wasm.__wbindgen_exn_store(idx);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function isLikeNone(x) {
|
|
579
|
+
return x === undefined || x === null;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
583
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
584
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
585
|
+
WASM_VECTOR_LEN = arg.length;
|
|
586
|
+
return ptr;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
590
|
+
if (realloc === undefined) {
|
|
591
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
592
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
593
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
594
|
+
WASM_VECTOR_LEN = buf.length;
|
|
595
|
+
return ptr;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
let len = arg.length;
|
|
599
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
600
|
+
|
|
601
|
+
const mem = getUint8ArrayMemory0();
|
|
602
|
+
|
|
603
|
+
let offset = 0;
|
|
604
|
+
|
|
605
|
+
for (; offset < len; offset++) {
|
|
606
|
+
const code = arg.charCodeAt(offset);
|
|
607
|
+
if (code > 0x7F) break;
|
|
608
|
+
mem[ptr + offset] = code;
|
|
609
|
+
}
|
|
610
|
+
if (offset !== len) {
|
|
611
|
+
if (offset !== 0) {
|
|
612
|
+
arg = arg.slice(offset);
|
|
613
|
+
}
|
|
614
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
615
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
616
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
617
|
+
|
|
618
|
+
offset += ret.written;
|
|
619
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
WASM_VECTOR_LEN = offset;
|
|
623
|
+
return ptr;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function takeFromExternrefTable0(idx) {
|
|
627
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
628
|
+
wasm.__externref_table_dealloc(idx);
|
|
629
|
+
return value;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
633
|
+
cachedTextDecoder.decode();
|
|
634
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
635
|
+
let numBytesDecoded = 0;
|
|
636
|
+
function decodeText(ptr, len) {
|
|
637
|
+
numBytesDecoded += len;
|
|
638
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
639
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
640
|
+
cachedTextDecoder.decode();
|
|
641
|
+
numBytesDecoded = len;
|
|
642
|
+
}
|
|
643
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
const cachedTextEncoder = new TextEncoder();
|
|
647
|
+
|
|
648
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
649
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
650
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
651
|
+
view.set(buf);
|
|
652
|
+
return {
|
|
653
|
+
read: arg.length,
|
|
654
|
+
written: buf.length
|
|
655
|
+
};
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
let WASM_VECTOR_LEN = 0;
|
|
660
|
+
|
|
661
|
+
let wasmModule, wasm;
|
|
662
|
+
function __wbg_finalize_init(instance, module) {
|
|
663
|
+
wasm = instance.exports;
|
|
664
|
+
wasmModule = module;
|
|
665
|
+
cachedUint8ArrayMemory0 = null;
|
|
666
|
+
wasm.__wbindgen_start();
|
|
667
|
+
return wasm;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
async function __wbg_load(module, imports) {
|
|
671
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
672
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
673
|
+
try {
|
|
674
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
675
|
+
} catch (e) {
|
|
676
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
677
|
+
|
|
678
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
679
|
+
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);
|
|
680
|
+
|
|
681
|
+
} else { throw e; }
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
const bytes = await module.arrayBuffer();
|
|
686
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
687
|
+
} else {
|
|
688
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
689
|
+
|
|
690
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
691
|
+
return { instance, module };
|
|
692
|
+
} else {
|
|
693
|
+
return instance;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
function expectedResponseType(type) {
|
|
698
|
+
switch (type) {
|
|
699
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
700
|
+
}
|
|
701
|
+
return false;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function initSync(module) {
|
|
706
|
+
if (wasm !== undefined) return wasm;
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
if (module !== undefined) {
|
|
710
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
711
|
+
({module} = module)
|
|
712
|
+
} else {
|
|
713
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
const imports = __wbg_get_imports();
|
|
718
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
719
|
+
module = new WebAssembly.Module(module);
|
|
720
|
+
}
|
|
721
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
722
|
+
return __wbg_finalize_init(instance, module);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
async function __wbg_init(module_or_path) {
|
|
726
|
+
if (wasm !== undefined) return wasm;
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
if (module_or_path !== undefined) {
|
|
730
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
731
|
+
({module_or_path} = module_or_path)
|
|
732
|
+
} else {
|
|
733
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
if (module_or_path === undefined) {
|
|
738
|
+
module_or_path = new URL('envlp_wasm_bg.wasm', import.meta.url);
|
|
739
|
+
}
|
|
740
|
+
const imports = __wbg_get_imports();
|
|
741
|
+
|
|
742
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
743
|
+
module_or_path = fetch(module_or_path);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
747
|
+
|
|
748
|
+
return __wbg_finalize_init(instance, module);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
export { initSync, __wbg_init as default };
|