@recoillink/cli 0.0.0-stage → 45.0.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.
Files changed (81) hide show
  1. package/LICENSE.md +193 -0
  2. package/README.md +149 -2
  3. package/bundle/154.index.js +462 -0
  4. package/bundle/230.index.js +569 -0
  5. package/bundle/25.index.js +9569 -0
  6. package/bundle/267.index.js +1386 -0
  7. package/bundle/308.index.js +5121 -0
  8. package/bundle/367.index.js +4 -0
  9. package/bundle/369.index.js +3443 -0
  10. package/bundle/529.index.js +3596 -0
  11. package/bundle/576.index.js +36 -0
  12. package/bundle/610.index.js +86 -0
  13. package/bundle/617.index.js +1612 -0
  14. package/bundle/628.index.js +152 -0
  15. package/bundle/633.index.js +86 -0
  16. package/bundle/697.index.js +410 -0
  17. package/bundle/7183ea1c1bf0a5da980d.js +214 -0
  18. package/bundle/748.index.js +672 -0
  19. package/bundle/78.index.js +372 -0
  20. package/bundle/841.index.js +2093 -0
  21. package/bundle/868.index.js +290 -0
  22. package/bundle/902.index.js +173 -0
  23. package/bundle/956.index.js +9901 -0
  24. package/bundle/aleo_wasm.wasm +0 -0
  25. package/bundle/aleo_wasm1.wasm +0 -0
  26. package/bundle/build/Release/bigint_buffer.node +0 -0
  27. package/bundle/file.js +12 -0
  28. package/bundle/index.js +4 -0
  29. package/bundle/package.json +3 -0
  30. package/bundle/worker-pipeline.js +38 -0
  31. package/bundle/worker.js +54 -0
  32. package/bundle/worker1.js +171 -0
  33. package/bundle/worker2.js +19834 -0
  34. package/bundle/worker3.js +19834 -0
  35. package/examples/aleo/core-config.yaml +19 -0
  36. package/examples/ccip/ccip-warp-route.yaml +26 -0
  37. package/examples/ccip/multi-chain-ccip-warp-route.yaml +81 -0
  38. package/examples/chain-config.yaml +42 -0
  39. package/examples/contract-artifacts.yaml +20 -0
  40. package/examples/core-config.yaml +19 -0
  41. package/examples/cosmosnative/core-config.yaml +20 -0
  42. package/examples/cosmosnative/warp-route-deployment.yaml +21 -0
  43. package/examples/crosschain/README.md +31 -0
  44. package/examples/crosschain/cosmosnative/core-config.yaml +69 -0
  45. package/examples/crosschain/ethereum/core-config.yaml +70 -0
  46. package/examples/crosschain/radix/core-config.yaml +96 -0
  47. package/examples/fork/file-transactions.yaml +5 -0
  48. package/examples/fork/timelock-testing.yaml +36 -0
  49. package/examples/fork/warp-route-update.yaml +100 -0
  50. package/examples/hooks.yaml +70 -0
  51. package/examples/ism-advanced.yaml +33 -0
  52. package/examples/ism.yaml +13 -0
  53. package/examples/radix/core-config.yaml +29 -0
  54. package/examples/sealevel/core-config-apply.yaml +7 -0
  55. package/examples/sealevel/core-config-composite-ism.yaml +21 -0
  56. package/examples/sealevel/core-config.yaml +12 -0
  57. package/examples/sealevel/igp-hook-config.yaml +13 -0
  58. package/examples/sealevel/warp-config-routing-message-id-multisig-ism.yaml +21 -0
  59. package/examples/starknet/core-config.yaml +20 -0
  60. package/examples/submit/strategy/file-strategy.yaml +8 -0
  61. package/examples/submit/strategy/gnosis-chain-strategy.yaml +10 -0
  62. package/examples/submit/strategy/gnosis-chain-tx-builder-strategy.yaml +6 -0
  63. package/examples/submit/strategy/gnosis-strategy-avalanche.yaml +4 -0
  64. package/examples/submit/strategy/gnosis-tx-builder-ica-strategy.yaml +20 -0
  65. package/examples/submit/strategy/ica-timelock-strategy.yaml +15 -0
  66. package/examples/submit/strategy/impersonated-account-strategy.yaml +4 -0
  67. package/examples/submit/strategy/json-rpc-chain-strategy.yaml +8 -0
  68. package/examples/submit/strategy/json-rpc-ica-strategy.yaml +13 -0
  69. package/examples/submit/strategy/json-rpc-strategy.yaml +3 -0
  70. package/examples/submit/strategy/json-rpc-timelock-strategy.yaml +17 -0
  71. package/examples/submit/strategy/starknet-json-rpc-chain-strategy.yaml +11 -0
  72. package/examples/submit/transactions/anvil-transactions.yaml +10 -0
  73. package/examples/submit/transactions/avalanche-transactions.json +8 -0
  74. package/examples/submit/transactions/sepolia-transactions.json +8 -0
  75. package/examples/tron-core-config.yaml +18 -0
  76. package/examples/warp-base.yaml +24 -0
  77. package/examples/warp-config-predicate-mainnet.yaml +14 -0
  78. package/examples/warp-deployed-predicate-mainnet.yaml +19 -0
  79. package/examples/warp-ethereum.yaml +19 -0
  80. package/examples/warp-route-deployment.yaml +21 -0
  81. package/package.json +117 -3
@@ -0,0 +1,462 @@
1
+ export const id = 154;
2
+ export const ids = [154];
3
+ export const modules = {
4
+
5
+ /***/ 93880:
6
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
+
8
+
9
+ // EXPORTS
10
+ __webpack_require__.d(__webpack_exports__, {
11
+ S: () => (/* binding */ convertTurnkeyApiKeyToJwk)
12
+ });
13
+
14
+ ;// CONCATENATED MODULE: ../../node_modules/.pnpm/@turnkey+api-key-stamper@0.5.0/node_modules/@turnkey/api-key-stamper/dist/tink/bytes.mjs
15
+ /**
16
+ * Code modified from https://github.com/google/tink/blob/6f74b99a2bfe6677e3670799116a57268fd067fa/javascript/subtle/bytes.ts
17
+ *
18
+ * @license
19
+ * Copyright 2020 Google LLC
20
+ * SPDX-License-Identifier: Apache-2.0
21
+ */
22
+ /**
23
+ * Converts the hex string to a byte array.
24
+ *
25
+ * @param hex the input
26
+ * @return the byte array output
27
+ * @throws {!Error}
28
+ * @static
29
+ */
30
+ function fromHex(hex) {
31
+ if (hex.length % 2 != 0) {
32
+ throw new Error("Hex string length must be multiple of 2");
33
+ }
34
+ const arr = new Uint8Array(hex.length / 2);
35
+ for (let i = 0; i < hex.length; i += 2) {
36
+ arr[i / 2] = parseInt(hex.substring(i, i + 2), 16);
37
+ }
38
+ return arr;
39
+ }
40
+ /**
41
+ * Converts a byte array to hex.
42
+ *
43
+ * @param bytes the byte array input
44
+ * @return hex the output
45
+ * @static
46
+ */
47
+ function toHex(bytes) {
48
+ let result = "";
49
+ for (let i = 0; i < bytes.length; i++) {
50
+ const hexByte = bytes[i].toString(16);
51
+ result += hexByte.length > 1 ? hexByte : "0" + hexByte;
52
+ }
53
+ return result;
54
+ }
55
+ /**
56
+ * Base64 encode a byte array.
57
+ *
58
+ * @param bytes the byte array input
59
+ * @param opt_webSafe True indicates we should use the alternative
60
+ * alphabet, which does not require escaping for use in URLs.
61
+ * @return base64 output
62
+ * @static
63
+ */
64
+ function toBase64(bytes, opt_webSafe) {
65
+ const encoded = btoa(
66
+ /* padding */
67
+ toByteString(bytes)).replace(/=/g, "");
68
+ {
69
+ return encoded.replace(/\+/g, "-").replace(/\//g, "_");
70
+ }
71
+ }
72
+ /**
73
+ * Turns a byte array into the string given by the concatenation of the
74
+ * characters to which the numbers correspond. Each byte is corresponding to a
75
+ * character. Does not support multi-byte characters.
76
+ *
77
+ * @param bytes Array of numbers representing
78
+ * characters.
79
+ * @return Stringification of the array.
80
+ */
81
+ function toByteString(bytes) {
82
+ let str = "";
83
+ for (let i = 0; i < bytes.length; i += 1) {
84
+ str += String.fromCharCode(bytes[i]);
85
+ }
86
+ return str;
87
+ }
88
+
89
+
90
+ //# sourceMappingURL=bytes.mjs.map
91
+
92
+ ;// CONCATENATED MODULE: ../../node_modules/.pnpm/@turnkey+api-key-stamper@0.5.0/node_modules/@turnkey/api-key-stamper/dist/tink/elliptic_curves.mjs
93
+
94
+
95
+ /**
96
+ * Code modified from https://github.com/google/tink/blob/6f74b99a2bfe6677e3670799116a57268fd067fa/javascript/subtle/elliptic_curves.ts
97
+ * - The implementation of integerToByteArray has been modified to augment the resulting byte array to a certain length.
98
+ * - The implementation of PointDecode has been modified to decode both compressed and uncompressed points by checking for correct format
99
+ * - Method isP256CurvePoint added to check whether an uncompressed point is valid
100
+ *
101
+ * @license
102
+ * Copyright 2020 Google LLC
103
+ * SPDX-License-Identifier: Apache-2.0
104
+ */
105
+ /**
106
+ * P-256 only
107
+ */
108
+ function getModulus() {
109
+ // https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf (Appendix D).
110
+ return BigInt("115792089210356248762697446949407573530086143415290314195533631308" +
111
+ "867097853951");
112
+ }
113
+ /**
114
+ * P-256 only
115
+ */
116
+ function getB() {
117
+ // https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf (Appendix D).
118
+ return BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");
119
+ }
120
+ /** Converts byte array to bigint. */
121
+ function byteArrayToInteger(bytes) {
122
+ return BigInt("0x" + toHex(bytes));
123
+ }
124
+ /** Converts bigint to byte array. */
125
+ function integerToByteArray(i, length) {
126
+ const input = i.toString(16);
127
+ const numHexChars = length * 2;
128
+ let padding = "";
129
+ if (numHexChars < input.length) {
130
+ throw new Error(`cannot pack integer with ${input.length} hex chars into ${length} bytes`);
131
+ }
132
+ else {
133
+ padding = "0".repeat(numHexChars - input.length);
134
+ }
135
+ return fromHex(padding + input);
136
+ }
137
+ /** Returns true iff the ith bit (in lsb order) of n is set. */
138
+ function testBit(n, i) {
139
+ const m = BigInt(1) << BigInt(i);
140
+ return (n & m) !== BigInt(0);
141
+ }
142
+ /**
143
+ * Computes a modular exponent. Since JavaScript BigInt operations are not
144
+ * constant-time, information about the inputs could leak. Therefore, THIS
145
+ * METHOD SHOULD ONLY BE USED FOR POINT DECOMPRESSION.
146
+ *
147
+ * @param b base
148
+ * @param exp exponent
149
+ * @param p modulus
150
+ * @return b^exp modulo p
151
+ */
152
+ function modPow(b, exp, p) {
153
+ if (exp === BigInt(0)) {
154
+ return BigInt(1);
155
+ }
156
+ let result = b;
157
+ const exponentBitString = exp.toString(2);
158
+ for (let i = 1; i < exponentBitString.length; ++i) {
159
+ result = (result * result) % p;
160
+ if (exponentBitString[i] === "1") {
161
+ result = (result * b) % p;
162
+ }
163
+ }
164
+ return result;
165
+ }
166
+ /**
167
+ * Computes a square root modulo an odd prime. Since timing and exceptions can
168
+ * leak information about the inputs, THIS METHOD SHOULD ONLY BE USED FOR
169
+ * POINT DECOMPRESSION.
170
+ *
171
+ * @param x square
172
+ * @param p prime modulus
173
+ * @return square root of x modulo p
174
+ */
175
+ function modSqrt(x, p) {
176
+ if (p <= BigInt(0)) {
177
+ throw new Error("p must be positive");
178
+ }
179
+ const base = x % p;
180
+ // The currently supported NIST curves P-256, P-384, and P-521 all satisfy
181
+ // p % 4 == 3. However, although currently a no-op, the following check
182
+ // should be left in place in case other curves are supported in the future.
183
+ if (testBit(p, 0) && /* istanbul ignore next */ testBit(p, 1)) {
184
+ // Case p % 4 == 3 (applies to NIST curves P-256, P-384, and P-521)
185
+ // q = (p + 1) / 4
186
+ const q = (p + BigInt(1)) >> BigInt(2);
187
+ const squareRoot = modPow(base, q, p);
188
+ if ((squareRoot * squareRoot) % p !== base) {
189
+ throw new Error("could not find a modular square root");
190
+ }
191
+ return squareRoot;
192
+ }
193
+ // Skipping other elliptic curve types that require Cipolla's algorithm.
194
+ throw new Error("unsupported modulus value");
195
+ }
196
+ /**
197
+ * Computes the y-coordinate of a point on an elliptic curve given its
198
+ * x-coordinate. Since timing and exceptions can leak information about the
199
+ * inputs, THIS METHOD SHOULD ONLY BE USED FOR POINT DECOMPRESSION.
200
+ *
201
+ * P-256 only
202
+ *
203
+ * @param x x-coordinate
204
+ * @param lsb least significant bit of the y-coordinate
205
+ * @return y-coordinate
206
+ */
207
+ function getY(x, lsb) {
208
+ const p = getModulus();
209
+ const a = p - BigInt(3);
210
+ const b = getB();
211
+ const rhs = ((x * x + a) * x + b) % p;
212
+ let y = modSqrt(rhs, p);
213
+ if (lsb !== testBit(y, 0)) {
214
+ y = (p - y) % p;
215
+ }
216
+ return y;
217
+ }
218
+ /**
219
+ *
220
+ * Given x and y coordinates of a JWK, checks whether these are valid points on
221
+ * the P-256 elliptic curve.
222
+ *
223
+ * P-256 only
224
+ *
225
+ * @param x x-coordinate
226
+ * @param y y-coordinate
227
+ * @return boolean validity
228
+ */
229
+ function isP256CurvePoint(x, y) {
230
+ const p = getModulus();
231
+ const a = p - BigInt(3);
232
+ const b = getB();
233
+ const rhs = ((x * x + a) * x + b) % p;
234
+ const lhs = y ** BigInt(2) % p;
235
+ return lhs === rhs;
236
+ }
237
+ /**
238
+ * Decodes a public key in _compressed_ OR _uncompressed_ format.
239
+ * Augmented to ensure that the x and y components are padded to fit 32 bytes.
240
+ *
241
+ * P-256 only
242
+ */
243
+ function pointDecode(point) {
244
+ const fieldSize = fieldSizeInBytes();
245
+ const compressedLength = fieldSize + 1;
246
+ const uncompressedLength = 2 * fieldSize + 1;
247
+ if (point.length !== compressedLength &&
248
+ point.length !== uncompressedLength) {
249
+ throw new Error("Invalid length: point is not in compressed or uncompressed format");
250
+ }
251
+ // Decodes point if its length and first bit match the compressed format
252
+ if ((point[0] === 2 || point[0] === 3) && point.length == compressedLength) {
253
+ const lsb = point[0] === 3; // point[0] must be 2 (false) or 3 (true).
254
+ const x = byteArrayToInteger(point.subarray(1, point.length));
255
+ const p = getModulus();
256
+ if (x < BigInt(0) || x >= p) {
257
+ throw new Error("x is out of range");
258
+ }
259
+ const y = getY(x, lsb);
260
+ const result = {
261
+ kty: "EC",
262
+ crv: "P-256",
263
+ x: toBase64(integerToByteArray(x, 32)),
264
+ y: toBase64(integerToByteArray(y, 32)),
265
+ ext: true,
266
+ };
267
+ return result;
268
+ // Decodes point if its length and first bit match the uncompressed format
269
+ }
270
+ else if (point[0] === 4 && point.length == uncompressedLength) {
271
+ const x = byteArrayToInteger(point.subarray(1, fieldSize + 1));
272
+ const y = byteArrayToInteger(point.subarray(fieldSize + 1, 2 * fieldSize + 1));
273
+ const p = getModulus();
274
+ if (x < BigInt(0) ||
275
+ x >= p ||
276
+ y < BigInt(0) ||
277
+ y >= p ||
278
+ !isP256CurvePoint(x, y)) {
279
+ throw new Error("invalid uncompressed x and y coordinates");
280
+ }
281
+ const result = {
282
+ kty: "EC",
283
+ crv: "P-256",
284
+ x: toBase64(integerToByteArray(x, 32)),
285
+ y: toBase64(integerToByteArray(y, 32)),
286
+ ext: true,
287
+ };
288
+ return result;
289
+ }
290
+ throw new Error("invalid format");
291
+ }
292
+ /**
293
+ * P-256 only
294
+ */
295
+ function fieldSizeInBytes() {
296
+ return 32;
297
+ }
298
+
299
+
300
+ //# sourceMappingURL=elliptic_curves.mjs.map
301
+
302
+ // EXTERNAL MODULE: ../../node_modules/.pnpm/@turnkey+encoding@0.6.0/node_modules/@turnkey/encoding/dist/index.mjs + 6 modules
303
+ var dist = __webpack_require__(56390);
304
+ ;// CONCATENATED MODULE: ../../node_modules/.pnpm/@turnkey+api-key-stamper@0.5.0/node_modules/@turnkey/api-key-stamper/dist/utils.mjs
305
+
306
+
307
+
308
+ /**
309
+ * Converts a Turnkey API key pair into a JSON Web Key (JWK) format.
310
+ * This function accepts P-256 API keys only.
311
+ *
312
+ * @param {Object} input - The Turnkey API key components.
313
+ * @param {string} input.uncompressedPrivateKeyHex - Hexadecimal-encoded uncompressed private key (32-byte scalar).
314
+ * @param {string} input.compressedPublicKeyHex - Hexadecimal-encoded compressed public key (33 bytes).
315
+ * @returns {JsonWebKey} A JSON Web Key object representing the EC P-256 key.
316
+ */
317
+ function convertTurnkeyApiKeyToJwk(input) {
318
+ const { uncompressedPrivateKeyHex, compressedPublicKeyHex } = input;
319
+ let jwk;
320
+ try {
321
+ jwk = pointDecode((0,dist/* uint8ArrayFromHexString */.Ks)(compressedPublicKeyHex));
322
+ }
323
+ catch (e) {
324
+ throw new Error(`unable to load API key: invalid public key. Did you switch your public and private key by accident? Is your public key a valid, compressed P-256 public key?`);
325
+ }
326
+ // Ensure that d is sufficiently padded
327
+ jwk.d = (0,dist/* hexStringToBase64url */.el)(uncompressedPrivateKeyHex, dist/* DEFAULT_JWK_MEMBER_BYTE_LENGTH */.Ev);
328
+ return jwk;
329
+ }
330
+
331
+
332
+ //# sourceMappingURL=utils.mjs.map
333
+
334
+
335
+ /***/ }),
336
+
337
+ /***/ 30154:
338
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
339
+
340
+ __webpack_require__.r(__webpack_exports__);
341
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
342
+ /* harmony export */ signWithApiKey: () => (/* binding */ signWithApiKey)
343
+ /* harmony export */ });
344
+ /* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(93880);
345
+ /* harmony import */ var _turnkey_encoding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(56390);
346
+
347
+
348
+
349
+ /// <reference lib="dom" />
350
+ const signWithApiKey = async (input) => {
351
+ const { content, publicKey, privateKey } = input;
352
+ const key = await importTurnkeyApiKey({
353
+ uncompressedPrivateKeyHex: privateKey,
354
+ compressedPublicKeyHex: publicKey,
355
+ });
356
+ return await signMessage({ key, content });
357
+ };
358
+ /**
359
+ * Imports a P-256 Turnkey API key into a WebCrypto `CryptoKey`.
360
+ *
361
+ * @param {Object} input - The Turnkey API key components.
362
+ * @param {string} input.uncompressedPrivateKeyHex - Hexadecimal-encoded uncompressed private key (32-byte scalar).
363
+ * @param {string} input.compressedPublicKeyHex - Hexadecimal-encoded compressed public key (33 bytes).
364
+ * @returns {Promise<CryptoKey>} A `CryptoKey` object representing a P-256 key.
365
+ */
366
+ async function importTurnkeyApiKey(input) {
367
+ const { uncompressedPrivateKeyHex, compressedPublicKeyHex } = input;
368
+ const jwk = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_0__/* .convertTurnkeyApiKeyToJwk */ .S)({
369
+ uncompressedPrivateKeyHex,
370
+ compressedPublicKeyHex,
371
+ });
372
+ return await crypto.subtle.importKey("jwk", jwk, {
373
+ name: "ECDSA",
374
+ namedCurve: "P-256",
375
+ }, false, // not extractable
376
+ ["sign"]);
377
+ }
378
+ async function signMessage(input) {
379
+ const { key, content } = input;
380
+ const signatureIeee1363 = await crypto.subtle.sign({
381
+ name: "ECDSA",
382
+ hash: "SHA-256",
383
+ }, key, new TextEncoder().encode(content));
384
+ const signatureDer = convertEcdsaIeee1363ToDer(new Uint8Array(signatureIeee1363));
385
+ return (0,_turnkey_encoding__WEBPACK_IMPORTED_MODULE_1__/* .uint8ArrayToHexString */ .pD)(signatureDer);
386
+ }
387
+ /**
388
+ * `SubtleCrypto.sign(...)` outputs signature in IEEE P1363 format:
389
+ * - https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/sign#ecdsa
390
+ *
391
+ * Turnkey expects the signature encoding to be DER-encoded ASN.1:
392
+ * - https://github.com/tkhq/tkcli/blob/7f0159af5a73387ff050647180d1db4d3a3aa033/src/internal/apikey/apikey.go#L149
393
+ *
394
+ * Code modified from https://github.com/google/tink/blob/6f74b99a2bfe6677e3670799116a57268fd067fa/javascript/subtle/elliptic_curves.ts#L114
395
+ *
396
+ * Transform an ECDSA signature in IEEE 1363 encoding to DER encoding.
397
+ *
398
+ * @param ieee the ECDSA signature in IEEE encoding
399
+ * @return ECDSA signature in DER encoding
400
+ */
401
+ function convertEcdsaIeee1363ToDer(ieee) {
402
+ if (ieee.length % 2 != 0 || ieee.length == 0 || ieee.length > 132) {
403
+ throw new Error("Invalid IEEE P1363 signature encoding. Length: " + ieee.length);
404
+ }
405
+ const r = toUnsignedBigNum(ieee.subarray(0, ieee.length / 2));
406
+ const s = toUnsignedBigNum(ieee.subarray(ieee.length / 2, ieee.length));
407
+ let offset = 0;
408
+ const length = 1 + 1 + r.length + 1 + 1 + s.length;
409
+ let der;
410
+ if (length >= 128) {
411
+ der = new Uint8Array(length + 3);
412
+ der[offset++] = 48;
413
+ der[offset++] = 128 + 1;
414
+ der[offset++] = length;
415
+ }
416
+ else {
417
+ der = new Uint8Array(length + 2);
418
+ der[offset++] = 48;
419
+ der[offset++] = length;
420
+ }
421
+ der[offset++] = 2;
422
+ der[offset++] = r.length;
423
+ der.set(r, offset);
424
+ offset += r.length;
425
+ der[offset++] = 2;
426
+ der[offset++] = s.length;
427
+ der.set(s, offset);
428
+ return der;
429
+ }
430
+ /**
431
+ * Code modified from https://github.com/google/tink/blob/6f74b99a2bfe6677e3670799116a57268fd067fa/javascript/subtle/elliptic_curves.ts#L311
432
+ *
433
+ * Transform a big integer in big endian to minimal unsigned form which has
434
+ * no extra zero at the beginning except when the highest bit is set.
435
+ */
436
+ function toUnsignedBigNum(bytes) {
437
+ // Remove zero prefixes.
438
+ let start = 0;
439
+ while (start < bytes.length && bytes[start] == 0) {
440
+ start++;
441
+ }
442
+ if (start == bytes.length) {
443
+ start = bytes.length - 1;
444
+ }
445
+ let extraZero = 0;
446
+ // If the 1st bit is not zero, add 1 zero byte.
447
+ if ((bytes[start] & 128) == 128) {
448
+ // Add extra zero.
449
+ extraZero = 1;
450
+ }
451
+ const res = new Uint8Array(bytes.length - start + extraZero);
452
+ res.set(bytes.subarray(start), extraZero);
453
+ return res;
454
+ }
455
+
456
+
457
+ //# sourceMappingURL=webcrypto.mjs.map
458
+
459
+
460
+ /***/ })
461
+
462
+ };