@veilgroup/sdk-woro 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/dist/index.js ADDED
@@ -0,0 +1,2300 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ try {
15
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
+ } catch (e) {
17
+ throw mod = 0, e;
18
+ }
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+
37
+ // node_modules/crypto-js/core.js
38
+ var require_core = __commonJS({
39
+ "node_modules/crypto-js/core.js"(exports, module) {
40
+ (function(root, factory) {
41
+ if (typeof exports === "object") {
42
+ module.exports = exports = factory();
43
+ } else if (typeof define === "function" && define.amd) {
44
+ define([], factory);
45
+ } else {
46
+ root.CryptoJS = factory();
47
+ }
48
+ })(exports, function() {
49
+ var CryptoJS = CryptoJS || (function(Math2, undefined2) {
50
+ var crypto3;
51
+ if (typeof globalThis !== "undefined" && globalThis.crypto) {
52
+ crypto3 = globalThis.crypto;
53
+ }
54
+ if (typeof self !== "undefined" && self.crypto) {
55
+ crypto3 = self.crypto;
56
+ }
57
+ if (typeof globalThis !== "undefined" && globalThis.crypto) {
58
+ crypto3 = globalThis.crypto;
59
+ }
60
+ if (!crypto3 && typeof globalThis !== "undefined" && globalThis.msCrypto) {
61
+ crypto3 = globalThis.msCrypto;
62
+ }
63
+ if (!crypto3 && typeof global !== "undefined" && global.crypto) {
64
+ crypto3 = global.crypto;
65
+ }
66
+ if (!crypto3 && typeof __require === "function") {
67
+ try {
68
+ crypto3 = __require("crypto");
69
+ } catch (err) {
70
+ }
71
+ }
72
+ var cryptoSecureRandomInt = function() {
73
+ if (crypto3) {
74
+ if (typeof crypto3.getRandomValues === "function") {
75
+ try {
76
+ return crypto3.getRandomValues(new Uint32Array(1))[0];
77
+ } catch (err) {
78
+ }
79
+ }
80
+ if (typeof crypto3.randomBytes === "function") {
81
+ try {
82
+ return crypto3.randomBytes(4).readInt32LE();
83
+ } catch (err) {
84
+ }
85
+ }
86
+ }
87
+ throw new Error("Native crypto module could not be used to get secure random number.");
88
+ };
89
+ var create = Object.create || /* @__PURE__ */ (function() {
90
+ function F() {
91
+ }
92
+ return function(obj) {
93
+ var subtype;
94
+ F.prototype = obj;
95
+ subtype = new F();
96
+ F.prototype = null;
97
+ return subtype;
98
+ };
99
+ })();
100
+ var C = {};
101
+ var C_lib = C.lib = {};
102
+ var Base = C_lib.Base = /* @__PURE__ */ (function() {
103
+ return {
104
+ /**
105
+ * Creates a new object that inherits from this object.
106
+ *
107
+ * @param {Object} overrides Properties to copy into the new object.
108
+ *
109
+ * @return {Object} The new object.
110
+ *
111
+ * @static
112
+ *
113
+ * @example
114
+ *
115
+ * var MyType = CryptoJS.lib.Base.extend({
116
+ * field: 'value',
117
+ *
118
+ * method: function () {
119
+ * }
120
+ * });
121
+ */
122
+ extend: function(overrides) {
123
+ var subtype = create(this);
124
+ if (overrides) {
125
+ subtype.mixIn(overrides);
126
+ }
127
+ if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
128
+ subtype.init = function() {
129
+ subtype.$super.init.apply(this, arguments);
130
+ };
131
+ }
132
+ subtype.init.prototype = subtype;
133
+ subtype.$super = this;
134
+ return subtype;
135
+ },
136
+ /**
137
+ * Extends this object and runs the init method.
138
+ * Arguments to create() will be passed to init().
139
+ *
140
+ * @return {Object} The new object.
141
+ *
142
+ * @static
143
+ *
144
+ * @example
145
+ *
146
+ * var instance = MyType.create();
147
+ */
148
+ create: function() {
149
+ var instance = this.extend();
150
+ instance.init.apply(instance, arguments);
151
+ return instance;
152
+ },
153
+ /**
154
+ * Initializes a newly created object.
155
+ * Override this method to add some logic when your objects are created.
156
+ *
157
+ * @example
158
+ *
159
+ * var MyType = CryptoJS.lib.Base.extend({
160
+ * init: function () {
161
+ * // ...
162
+ * }
163
+ * });
164
+ */
165
+ init: function() {
166
+ },
167
+ /**
168
+ * Copies properties into this object.
169
+ *
170
+ * @param {Object} properties The properties to mix in.
171
+ *
172
+ * @example
173
+ *
174
+ * MyType.mixIn({
175
+ * field: 'value'
176
+ * });
177
+ */
178
+ mixIn: function(properties) {
179
+ for (var propertyName in properties) {
180
+ if (properties.hasOwnProperty(propertyName)) {
181
+ this[propertyName] = properties[propertyName];
182
+ }
183
+ }
184
+ if (properties.hasOwnProperty("toString")) {
185
+ this.toString = properties.toString;
186
+ }
187
+ },
188
+ /**
189
+ * Creates a copy of this object.
190
+ *
191
+ * @return {Object} The clone.
192
+ *
193
+ * @example
194
+ *
195
+ * var clone = instance.clone();
196
+ */
197
+ clone: function() {
198
+ return this.init.prototype.extend(this);
199
+ }
200
+ };
201
+ })();
202
+ var WordArray = C_lib.WordArray = Base.extend({
203
+ /**
204
+ * Initializes a newly created word array.
205
+ *
206
+ * @param {Array} words (Optional) An array of 32-bit words.
207
+ * @param {number} sigBytes (Optional) The number of significant bytes in the words.
208
+ *
209
+ * @example
210
+ *
211
+ * var wordArray = CryptoJS.lib.WordArray.create();
212
+ * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
213
+ * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
214
+ */
215
+ init: function(words, sigBytes) {
216
+ words = this.words = words || [];
217
+ if (sigBytes != undefined2) {
218
+ this.sigBytes = sigBytes;
219
+ } else {
220
+ this.sigBytes = words.length * 4;
221
+ }
222
+ },
223
+ /**
224
+ * Converts this word array to a string.
225
+ *
226
+ * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
227
+ *
228
+ * @return {string} The stringified word array.
229
+ *
230
+ * @example
231
+ *
232
+ * var string = wordArray + '';
233
+ * var string = wordArray.toString();
234
+ * var string = wordArray.toString(CryptoJS.enc.Utf8);
235
+ */
236
+ toString: function(encoder) {
237
+ return (encoder || Hex).stringify(this);
238
+ },
239
+ /**
240
+ * Concatenates a word array to this word array.
241
+ *
242
+ * @param {WordArray} wordArray The word array to append.
243
+ *
244
+ * @return {WordArray} This word array.
245
+ *
246
+ * @example
247
+ *
248
+ * wordArray1.concat(wordArray2);
249
+ */
250
+ concat: function(wordArray) {
251
+ var thisWords = this.words;
252
+ var thatWords = wordArray.words;
253
+ var thisSigBytes = this.sigBytes;
254
+ var thatSigBytes = wordArray.sigBytes;
255
+ this.clamp();
256
+ if (thisSigBytes % 4) {
257
+ for (var i = 0; i < thatSigBytes; i++) {
258
+ var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
259
+ thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
260
+ }
261
+ } else {
262
+ for (var j = 0; j < thatSigBytes; j += 4) {
263
+ thisWords[thisSigBytes + j >>> 2] = thatWords[j >>> 2];
264
+ }
265
+ }
266
+ this.sigBytes += thatSigBytes;
267
+ return this;
268
+ },
269
+ /**
270
+ * Removes insignificant bits.
271
+ *
272
+ * @example
273
+ *
274
+ * wordArray.clamp();
275
+ */
276
+ clamp: function() {
277
+ var words = this.words;
278
+ var sigBytes = this.sigBytes;
279
+ words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
280
+ words.length = Math2.ceil(sigBytes / 4);
281
+ },
282
+ /**
283
+ * Creates a copy of this word array.
284
+ *
285
+ * @return {WordArray} The clone.
286
+ *
287
+ * @example
288
+ *
289
+ * var clone = wordArray.clone();
290
+ */
291
+ clone: function() {
292
+ var clone = Base.clone.call(this);
293
+ clone.words = this.words.slice(0);
294
+ return clone;
295
+ },
296
+ /**
297
+ * Creates a word array filled with random bytes.
298
+ *
299
+ * @param {number} nBytes The number of random bytes to generate.
300
+ *
301
+ * @return {WordArray} The random word array.
302
+ *
303
+ * @static
304
+ *
305
+ * @example
306
+ *
307
+ * var wordArray = CryptoJS.lib.WordArray.random(16);
308
+ */
309
+ random: function(nBytes) {
310
+ var words = [];
311
+ for (var i = 0; i < nBytes; i += 4) {
312
+ words.push(cryptoSecureRandomInt());
313
+ }
314
+ return new WordArray.init(words, nBytes);
315
+ }
316
+ });
317
+ var C_enc = C.enc = {};
318
+ var Hex = C_enc.Hex = {
319
+ /**
320
+ * Converts a word array to a hex string.
321
+ *
322
+ * @param {WordArray} wordArray The word array.
323
+ *
324
+ * @return {string} The hex string.
325
+ *
326
+ * @static
327
+ *
328
+ * @example
329
+ *
330
+ * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
331
+ */
332
+ stringify: function(wordArray) {
333
+ var words = wordArray.words;
334
+ var sigBytes = wordArray.sigBytes;
335
+ var hexChars = [];
336
+ for (var i = 0; i < sigBytes; i++) {
337
+ var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
338
+ hexChars.push((bite >>> 4).toString(16));
339
+ hexChars.push((bite & 15).toString(16));
340
+ }
341
+ return hexChars.join("");
342
+ },
343
+ /**
344
+ * Converts a hex string to a word array.
345
+ *
346
+ * @param {string} hexStr The hex string.
347
+ *
348
+ * @return {WordArray} The word array.
349
+ *
350
+ * @static
351
+ *
352
+ * @example
353
+ *
354
+ * var wordArray = CryptoJS.enc.Hex.parse(hexString);
355
+ */
356
+ parse: function(hexStr) {
357
+ var hexStrLength = hexStr.length;
358
+ var words = [];
359
+ for (var i = 0; i < hexStrLength; i += 2) {
360
+ words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
361
+ }
362
+ return new WordArray.init(words, hexStrLength / 2);
363
+ }
364
+ };
365
+ var Latin1 = C_enc.Latin1 = {
366
+ /**
367
+ * Converts a word array to a Latin1 string.
368
+ *
369
+ * @param {WordArray} wordArray The word array.
370
+ *
371
+ * @return {string} The Latin1 string.
372
+ *
373
+ * @static
374
+ *
375
+ * @example
376
+ *
377
+ * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
378
+ */
379
+ stringify: function(wordArray) {
380
+ var words = wordArray.words;
381
+ var sigBytes = wordArray.sigBytes;
382
+ var latin1Chars = [];
383
+ for (var i = 0; i < sigBytes; i++) {
384
+ var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
385
+ latin1Chars.push(String.fromCharCode(bite));
386
+ }
387
+ return latin1Chars.join("");
388
+ },
389
+ /**
390
+ * Converts a Latin1 string to a word array.
391
+ *
392
+ * @param {string} latin1Str The Latin1 string.
393
+ *
394
+ * @return {WordArray} The word array.
395
+ *
396
+ * @static
397
+ *
398
+ * @example
399
+ *
400
+ * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
401
+ */
402
+ parse: function(latin1Str) {
403
+ var latin1StrLength = latin1Str.length;
404
+ var words = [];
405
+ for (var i = 0; i < latin1StrLength; i++) {
406
+ words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
407
+ }
408
+ return new WordArray.init(words, latin1StrLength);
409
+ }
410
+ };
411
+ var Utf8 = C_enc.Utf8 = {
412
+ /**
413
+ * Converts a word array to a UTF-8 string.
414
+ *
415
+ * @param {WordArray} wordArray The word array.
416
+ *
417
+ * @return {string} The UTF-8 string.
418
+ *
419
+ * @static
420
+ *
421
+ * @example
422
+ *
423
+ * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
424
+ */
425
+ stringify: function(wordArray) {
426
+ try {
427
+ return decodeURIComponent(escape(Latin1.stringify(wordArray)));
428
+ } catch (e) {
429
+ throw new Error("Malformed UTF-8 data");
430
+ }
431
+ },
432
+ /**
433
+ * Converts a UTF-8 string to a word array.
434
+ *
435
+ * @param {string} utf8Str The UTF-8 string.
436
+ *
437
+ * @return {WordArray} The word array.
438
+ *
439
+ * @static
440
+ *
441
+ * @example
442
+ *
443
+ * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
444
+ */
445
+ parse: function(utf8Str) {
446
+ return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
447
+ }
448
+ };
449
+ var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
450
+ /**
451
+ * Resets this block algorithm's data buffer to its initial state.
452
+ *
453
+ * @example
454
+ *
455
+ * bufferedBlockAlgorithm.reset();
456
+ */
457
+ reset: function() {
458
+ this._data = new WordArray.init();
459
+ this._nDataBytes = 0;
460
+ },
461
+ /**
462
+ * Adds new data to this block algorithm's buffer.
463
+ *
464
+ * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
465
+ *
466
+ * @example
467
+ *
468
+ * bufferedBlockAlgorithm._append('data');
469
+ * bufferedBlockAlgorithm._append(wordArray);
470
+ */
471
+ _append: function(data) {
472
+ if (typeof data == "string") {
473
+ data = Utf8.parse(data);
474
+ }
475
+ this._data.concat(data);
476
+ this._nDataBytes += data.sigBytes;
477
+ },
478
+ /**
479
+ * Processes available data blocks.
480
+ *
481
+ * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
482
+ *
483
+ * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
484
+ *
485
+ * @return {WordArray} The processed data.
486
+ *
487
+ * @example
488
+ *
489
+ * var processedData = bufferedBlockAlgorithm._process();
490
+ * var processedData = bufferedBlockAlgorithm._process(!!'flush');
491
+ */
492
+ _process: function(doFlush) {
493
+ var processedWords;
494
+ var data = this._data;
495
+ var dataWords = data.words;
496
+ var dataSigBytes = data.sigBytes;
497
+ var blockSize = this.blockSize;
498
+ var blockSizeBytes = blockSize * 4;
499
+ var nBlocksReady = dataSigBytes / blockSizeBytes;
500
+ if (doFlush) {
501
+ nBlocksReady = Math2.ceil(nBlocksReady);
502
+ } else {
503
+ nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
504
+ }
505
+ var nWordsReady = nBlocksReady * blockSize;
506
+ var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
507
+ if (nWordsReady) {
508
+ for (var offset = 0; offset < nWordsReady; offset += blockSize) {
509
+ this._doProcessBlock(dataWords, offset);
510
+ }
511
+ processedWords = dataWords.splice(0, nWordsReady);
512
+ data.sigBytes -= nBytesReady;
513
+ }
514
+ return new WordArray.init(processedWords, nBytesReady);
515
+ },
516
+ /**
517
+ * Creates a copy of this object.
518
+ *
519
+ * @return {Object} The clone.
520
+ *
521
+ * @example
522
+ *
523
+ * var clone = bufferedBlockAlgorithm.clone();
524
+ */
525
+ clone: function() {
526
+ var clone = Base.clone.call(this);
527
+ clone._data = this._data.clone();
528
+ return clone;
529
+ },
530
+ _minBufferSize: 0
531
+ });
532
+ var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
533
+ /**
534
+ * Configuration options.
535
+ */
536
+ cfg: Base.extend(),
537
+ /**
538
+ * Initializes a newly created hasher.
539
+ *
540
+ * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
541
+ *
542
+ * @example
543
+ *
544
+ * var hasher = CryptoJS.algo.SHA256.create();
545
+ */
546
+ init: function(cfg) {
547
+ this.cfg = this.cfg.extend(cfg);
548
+ this.reset();
549
+ },
550
+ /**
551
+ * Resets this hasher to its initial state.
552
+ *
553
+ * @example
554
+ *
555
+ * hasher.reset();
556
+ */
557
+ reset: function() {
558
+ BufferedBlockAlgorithm.reset.call(this);
559
+ this._doReset();
560
+ },
561
+ /**
562
+ * Updates this hasher with a message.
563
+ *
564
+ * @param {WordArray|string} messageUpdate The message to append.
565
+ *
566
+ * @return {Hasher} This hasher.
567
+ *
568
+ * @example
569
+ *
570
+ * hasher.update('message');
571
+ * hasher.update(wordArray);
572
+ */
573
+ update: function(messageUpdate) {
574
+ this._append(messageUpdate);
575
+ this._process();
576
+ return this;
577
+ },
578
+ /**
579
+ * Finalizes the hash computation.
580
+ * Note that the finalize operation is effectively a destructive, read-once operation.
581
+ *
582
+ * @param {WordArray|string} messageUpdate (Optional) A final message update.
583
+ *
584
+ * @return {WordArray} The hash.
585
+ *
586
+ * @example
587
+ *
588
+ * var hash = hasher.finalize();
589
+ * var hash = hasher.finalize('message');
590
+ * var hash = hasher.finalize(wordArray);
591
+ */
592
+ finalize: function(messageUpdate) {
593
+ if (messageUpdate) {
594
+ this._append(messageUpdate);
595
+ }
596
+ var hash2 = this._doFinalize();
597
+ return hash2;
598
+ },
599
+ blockSize: 512 / 32,
600
+ /**
601
+ * Creates a shortcut function to a hasher's object interface.
602
+ *
603
+ * @param {Hasher} hasher The hasher to create a helper for.
604
+ *
605
+ * @return {Function} The shortcut function.
606
+ *
607
+ * @static
608
+ *
609
+ * @example
610
+ *
611
+ * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
612
+ */
613
+ _createHelper: function(hasher) {
614
+ return function(message, cfg) {
615
+ return new hasher.init(cfg).finalize(message);
616
+ };
617
+ },
618
+ /**
619
+ * Creates a shortcut function to the HMAC's object interface.
620
+ *
621
+ * @param {Hasher} hasher The hasher to use in this HMAC helper.
622
+ *
623
+ * @return {Function} The shortcut function.
624
+ *
625
+ * @static
626
+ *
627
+ * @example
628
+ *
629
+ * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
630
+ */
631
+ _createHmacHelper: function(hasher) {
632
+ return function(message, key) {
633
+ return new C_algo.HMAC.init(hasher, key).finalize(message);
634
+ };
635
+ }
636
+ });
637
+ var C_algo = C.algo = {};
638
+ return C;
639
+ })(Math);
640
+ return CryptoJS;
641
+ });
642
+ }
643
+ });
644
+
645
+ // node_modules/crypto-js/sha256.js
646
+ var require_sha256 = __commonJS({
647
+ "node_modules/crypto-js/sha256.js"(exports, module) {
648
+ (function(root, factory) {
649
+ if (typeof exports === "object") {
650
+ module.exports = exports = factory(require_core());
651
+ } else if (typeof define === "function" && define.amd) {
652
+ define(["./core"], factory);
653
+ } else {
654
+ factory(root.CryptoJS);
655
+ }
656
+ })(exports, function(CryptoJS) {
657
+ (function(Math2) {
658
+ var C = CryptoJS;
659
+ var C_lib = C.lib;
660
+ var WordArray = C_lib.WordArray;
661
+ var Hasher = C_lib.Hasher;
662
+ var C_algo = C.algo;
663
+ var H = [];
664
+ var K = [];
665
+ (function() {
666
+ function isPrime(n2) {
667
+ var sqrtN = Math2.sqrt(n2);
668
+ for (var factor = 2; factor <= sqrtN; factor++) {
669
+ if (!(n2 % factor)) {
670
+ return false;
671
+ }
672
+ }
673
+ return true;
674
+ }
675
+ function getFractionalBits(n2) {
676
+ return (n2 - (n2 | 0)) * 4294967296 | 0;
677
+ }
678
+ var n = 2;
679
+ var nPrime = 0;
680
+ while (nPrime < 64) {
681
+ if (isPrime(n)) {
682
+ if (nPrime < 8) {
683
+ H[nPrime] = getFractionalBits(Math2.pow(n, 1 / 2));
684
+ }
685
+ K[nPrime] = getFractionalBits(Math2.pow(n, 1 / 3));
686
+ nPrime++;
687
+ }
688
+ n++;
689
+ }
690
+ })();
691
+ var W = [];
692
+ var SHA256 = C_algo.SHA256 = Hasher.extend({
693
+ _doReset: function() {
694
+ this._hash = new WordArray.init(H.slice(0));
695
+ },
696
+ _doProcessBlock: function(M, offset) {
697
+ var H2 = this._hash.words;
698
+ var a = H2[0];
699
+ var b = H2[1];
700
+ var c = H2[2];
701
+ var d = H2[3];
702
+ var e = H2[4];
703
+ var f = H2[5];
704
+ var g = H2[6];
705
+ var h = H2[7];
706
+ for (var i = 0; i < 64; i++) {
707
+ if (i < 16) {
708
+ W[i] = M[offset + i] | 0;
709
+ } else {
710
+ var gamma0x = W[i - 15];
711
+ var gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
712
+ var gamma1x = W[i - 2];
713
+ var gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
714
+ W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
715
+ }
716
+ var ch = e & f ^ ~e & g;
717
+ var maj = a & b ^ a & c ^ b & c;
718
+ var sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
719
+ var sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
720
+ var t1 = h + sigma1 + ch + K[i] + W[i];
721
+ var t2 = sigma0 + maj;
722
+ h = g;
723
+ g = f;
724
+ f = e;
725
+ e = d + t1 | 0;
726
+ d = c;
727
+ c = b;
728
+ b = a;
729
+ a = t1 + t2 | 0;
730
+ }
731
+ H2[0] = H2[0] + a | 0;
732
+ H2[1] = H2[1] + b | 0;
733
+ H2[2] = H2[2] + c | 0;
734
+ H2[3] = H2[3] + d | 0;
735
+ H2[4] = H2[4] + e | 0;
736
+ H2[5] = H2[5] + f | 0;
737
+ H2[6] = H2[6] + g | 0;
738
+ H2[7] = H2[7] + h | 0;
739
+ },
740
+ _doFinalize: function() {
741
+ var data = this._data;
742
+ var dataWords = data.words;
743
+ var nBitsTotal = this._nDataBytes * 8;
744
+ var nBitsLeft = data.sigBytes * 8;
745
+ dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
746
+ dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math2.floor(nBitsTotal / 4294967296);
747
+ dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
748
+ data.sigBytes = dataWords.length * 4;
749
+ this._process();
750
+ return this._hash;
751
+ },
752
+ clone: function() {
753
+ var clone = Hasher.clone.call(this);
754
+ clone._hash = this._hash.clone();
755
+ return clone;
756
+ }
757
+ });
758
+ C.SHA256 = Hasher._createHelper(SHA256);
759
+ C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
760
+ })(Math);
761
+ return CryptoJS.SHA256;
762
+ });
763
+ }
764
+ });
765
+
766
+ // node_modules/crypto-js/hmac.js
767
+ var require_hmac = __commonJS({
768
+ "node_modules/crypto-js/hmac.js"(exports, module) {
769
+ (function(root, factory) {
770
+ if (typeof exports === "object") {
771
+ module.exports = exports = factory(require_core());
772
+ } else if (typeof define === "function" && define.amd) {
773
+ define(["./core"], factory);
774
+ } else {
775
+ factory(root.CryptoJS);
776
+ }
777
+ })(exports, function(CryptoJS) {
778
+ (function() {
779
+ var C = CryptoJS;
780
+ var C_lib = C.lib;
781
+ var Base = C_lib.Base;
782
+ var C_enc = C.enc;
783
+ var Utf8 = C_enc.Utf8;
784
+ var C_algo = C.algo;
785
+ var HMAC = C_algo.HMAC = Base.extend({
786
+ /**
787
+ * Initializes a newly created HMAC.
788
+ *
789
+ * @param {Hasher} hasher The hash algorithm to use.
790
+ * @param {WordArray|string} key The secret key.
791
+ *
792
+ * @example
793
+ *
794
+ * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
795
+ */
796
+ init: function(hasher, key) {
797
+ hasher = this._hasher = new hasher.init();
798
+ if (typeof key == "string") {
799
+ key = Utf8.parse(key);
800
+ }
801
+ var hasherBlockSize = hasher.blockSize;
802
+ var hasherBlockSizeBytes = hasherBlockSize * 4;
803
+ if (key.sigBytes > hasherBlockSizeBytes) {
804
+ key = hasher.finalize(key);
805
+ }
806
+ key.clamp();
807
+ var oKey = this._oKey = key.clone();
808
+ var iKey = this._iKey = key.clone();
809
+ var oKeyWords = oKey.words;
810
+ var iKeyWords = iKey.words;
811
+ for (var i = 0; i < hasherBlockSize; i++) {
812
+ oKeyWords[i] ^= 1549556828;
813
+ iKeyWords[i] ^= 909522486;
814
+ }
815
+ oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
816
+ this.reset();
817
+ },
818
+ /**
819
+ * Resets this HMAC to its initial state.
820
+ *
821
+ * @example
822
+ *
823
+ * hmacHasher.reset();
824
+ */
825
+ reset: function() {
826
+ var hasher = this._hasher;
827
+ hasher.reset();
828
+ hasher.update(this._iKey);
829
+ },
830
+ /**
831
+ * Updates this HMAC with a message.
832
+ *
833
+ * @param {WordArray|string} messageUpdate The message to append.
834
+ *
835
+ * @return {HMAC} This HMAC instance.
836
+ *
837
+ * @example
838
+ *
839
+ * hmacHasher.update('message');
840
+ * hmacHasher.update(wordArray);
841
+ */
842
+ update: function(messageUpdate) {
843
+ this._hasher.update(messageUpdate);
844
+ return this;
845
+ },
846
+ /**
847
+ * Finalizes the HMAC computation.
848
+ * Note that the finalize operation is effectively a destructive, read-once operation.
849
+ *
850
+ * @param {WordArray|string} messageUpdate (Optional) A final message update.
851
+ *
852
+ * @return {WordArray} The HMAC.
853
+ *
854
+ * @example
855
+ *
856
+ * var hmac = hmacHasher.finalize();
857
+ * var hmac = hmacHasher.finalize('message');
858
+ * var hmac = hmacHasher.finalize(wordArray);
859
+ */
860
+ finalize: function(messageUpdate) {
861
+ var hasher = this._hasher;
862
+ var innerHash = hasher.finalize(messageUpdate);
863
+ hasher.reset();
864
+ var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
865
+ return hmac;
866
+ }
867
+ });
868
+ })();
869
+ });
870
+ }
871
+ });
872
+
873
+ // node_modules/crypto-js/hmac-sha256.js
874
+ var require_hmac_sha256 = __commonJS({
875
+ "node_modules/crypto-js/hmac-sha256.js"(exports, module) {
876
+ (function(root, factory, undef) {
877
+ if (typeof exports === "object") {
878
+ module.exports = exports = factory(require_core(), require_sha256(), require_hmac());
879
+ } else if (typeof define === "function" && define.amd) {
880
+ define(["./core", "./sha256", "./hmac"], factory);
881
+ } else {
882
+ factory(root.CryptoJS);
883
+ }
884
+ })(exports, function(CryptoJS) {
885
+ return CryptoJS.HmacSHA256;
886
+ });
887
+ }
888
+ });
889
+
890
+ // node_modules/crypto-js/enc-base64.js
891
+ var require_enc_base64 = __commonJS({
892
+ "node_modules/crypto-js/enc-base64.js"(exports, module) {
893
+ (function(root, factory) {
894
+ if (typeof exports === "object") {
895
+ module.exports = exports = factory(require_core());
896
+ } else if (typeof define === "function" && define.amd) {
897
+ define(["./core"], factory);
898
+ } else {
899
+ factory(root.CryptoJS);
900
+ }
901
+ })(exports, function(CryptoJS) {
902
+ (function() {
903
+ var C = CryptoJS;
904
+ var C_lib = C.lib;
905
+ var WordArray = C_lib.WordArray;
906
+ var C_enc = C.enc;
907
+ var Base64 = C_enc.Base64 = {
908
+ /**
909
+ * Converts a word array to a Base64 string.
910
+ *
911
+ * @param {WordArray} wordArray The word array.
912
+ *
913
+ * @return {string} The Base64 string.
914
+ *
915
+ * @static
916
+ *
917
+ * @example
918
+ *
919
+ * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
920
+ */
921
+ stringify: function(wordArray) {
922
+ var words = wordArray.words;
923
+ var sigBytes = wordArray.sigBytes;
924
+ var map = this._map;
925
+ wordArray.clamp();
926
+ var base64Chars = [];
927
+ for (var i = 0; i < sigBytes; i += 3) {
928
+ var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
929
+ var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
930
+ var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
931
+ var triplet = byte1 << 16 | byte2 << 8 | byte3;
932
+ for (var j = 0; j < 4 && i + j * 0.75 < sigBytes; j++) {
933
+ base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63));
934
+ }
935
+ }
936
+ var paddingChar = map.charAt(64);
937
+ if (paddingChar) {
938
+ while (base64Chars.length % 4) {
939
+ base64Chars.push(paddingChar);
940
+ }
941
+ }
942
+ return base64Chars.join("");
943
+ },
944
+ /**
945
+ * Converts a Base64 string to a word array.
946
+ *
947
+ * @param {string} base64Str The Base64 string.
948
+ *
949
+ * @return {WordArray} The word array.
950
+ *
951
+ * @static
952
+ *
953
+ * @example
954
+ *
955
+ * var wordArray = CryptoJS.enc.Base64.parse(base64String);
956
+ */
957
+ parse: function(base64Str) {
958
+ var base64StrLength = base64Str.length;
959
+ var map = this._map;
960
+ var reverseMap = this._reverseMap;
961
+ if (!reverseMap) {
962
+ reverseMap = this._reverseMap = [];
963
+ for (var j = 0; j < map.length; j++) {
964
+ reverseMap[map.charCodeAt(j)] = j;
965
+ }
966
+ }
967
+ var paddingChar = map.charAt(64);
968
+ if (paddingChar) {
969
+ var paddingIndex = base64Str.indexOf(paddingChar);
970
+ if (paddingIndex !== -1) {
971
+ base64StrLength = paddingIndex;
972
+ }
973
+ }
974
+ return parseLoop(base64Str, base64StrLength, reverseMap);
975
+ },
976
+ _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
977
+ };
978
+ function parseLoop(base64Str, base64StrLength, reverseMap) {
979
+ var words = [];
980
+ var nBytes = 0;
981
+ for (var i = 0; i < base64StrLength; i++) {
982
+ if (i % 4) {
983
+ var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2;
984
+ var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2;
985
+ var bitsCombined = bits1 | bits2;
986
+ words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8;
987
+ nBytes++;
988
+ }
989
+ }
990
+ return WordArray.create(words, nBytes);
991
+ }
992
+ })();
993
+ return CryptoJS.enc.Base64;
994
+ });
995
+ }
996
+ });
997
+
998
+ // node_modules/crypto-js/enc-hex.js
999
+ var require_enc_hex = __commonJS({
1000
+ "node_modules/crypto-js/enc-hex.js"(exports, module) {
1001
+ (function(root, factory) {
1002
+ if (typeof exports === "object") {
1003
+ module.exports = exports = factory(require_core());
1004
+ } else if (typeof define === "function" && define.amd) {
1005
+ define(["./core"], factory);
1006
+ } else {
1007
+ factory(root.CryptoJS);
1008
+ }
1009
+ })(exports, function(CryptoJS) {
1010
+ return CryptoJS.enc.Hex;
1011
+ });
1012
+ }
1013
+ });
1014
+
1015
+ // node_modules/crypto-js/enc-utf8.js
1016
+ var require_enc_utf8 = __commonJS({
1017
+ "node_modules/crypto-js/enc-utf8.js"(exports, module) {
1018
+ (function(root, factory) {
1019
+ if (typeof exports === "object") {
1020
+ module.exports = exports = factory(require_core());
1021
+ } else if (typeof define === "function" && define.amd) {
1022
+ define(["./core"], factory);
1023
+ } else {
1024
+ factory(root.CryptoJS);
1025
+ }
1026
+ })(exports, function(CryptoJS) {
1027
+ return CryptoJS.enc.Utf8;
1028
+ });
1029
+ }
1030
+ });
1031
+
1032
+ // node_modules/aws-cognito-srp-client/dist/bigInteger.js
1033
+ function BigInteger(a, b) {
1034
+ if (a != null)
1035
+ this.fromString(a, b);
1036
+ }
1037
+ function nbi() {
1038
+ return new BigInteger(null);
1039
+ }
1040
+ var dbits;
1041
+ var canary = 244837814094590;
1042
+ var j_lm = (canary & 16777215) == 15715070;
1043
+ function am1(i, x, w, j, c, n) {
1044
+ while (--n >= 0) {
1045
+ var v = x * this[i++] + w[j] + c;
1046
+ c = Math.floor(v / 67108864);
1047
+ w[j++] = v & 67108863;
1048
+ }
1049
+ return c;
1050
+ }
1051
+ function am2(i, x, w, j, c, n) {
1052
+ var xl = x & 32767, xh = x >> 15;
1053
+ while (--n >= 0) {
1054
+ var l = this[i] & 32767;
1055
+ var h = this[i++] >> 15;
1056
+ var m = xh * l + h * xl;
1057
+ l = xl * l + ((m & 32767) << 15) + w[j] + (c & 1073741823);
1058
+ c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
1059
+ w[j++] = l & 1073741823;
1060
+ }
1061
+ return c;
1062
+ }
1063
+ function am3(i, x, w, j, c, n) {
1064
+ var xl = x & 16383, xh = x >> 14;
1065
+ while (--n >= 0) {
1066
+ var l = this[i] & 16383;
1067
+ var h = this[i++] >> 14;
1068
+ var m = xh * l + h * xl;
1069
+ l = xl * l + ((m & 16383) << 14) + w[j] + c;
1070
+ c = (l >> 28) + (m >> 14) + xh * h;
1071
+ w[j++] = l & 268435455;
1072
+ }
1073
+ return c;
1074
+ }
1075
+ var inBrowser = typeof navigator !== "undefined";
1076
+ if (inBrowser && j_lm && navigator.appName == "Microsoft Internet Explorer") {
1077
+ BigInteger.prototype.am = am2;
1078
+ dbits = 30;
1079
+ } else if (inBrowser && j_lm && navigator.appName != "Netscape") {
1080
+ BigInteger.prototype.am = am1;
1081
+ dbits = 26;
1082
+ } else {
1083
+ BigInteger.prototype.am = am3;
1084
+ dbits = 28;
1085
+ }
1086
+ BigInteger.prototype.DB = dbits;
1087
+ BigInteger.prototype.DM = (1 << dbits) - 1;
1088
+ BigInteger.prototype.DV = 1 << dbits;
1089
+ var BI_FP = 52;
1090
+ BigInteger.prototype.FV = Math.pow(2, BI_FP);
1091
+ BigInteger.prototype.F1 = BI_FP - dbits;
1092
+ BigInteger.prototype.F2 = 2 * dbits - BI_FP;
1093
+ var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
1094
+ var BI_RC = [];
1095
+ var rr;
1096
+ var vv;
1097
+ rr = "0".charCodeAt(0);
1098
+ for (vv = 0; vv <= 9; ++vv)
1099
+ BI_RC[rr++] = vv;
1100
+ rr = "a".charCodeAt(0);
1101
+ for (vv = 10; vv < 36; ++vv)
1102
+ BI_RC[rr++] = vv;
1103
+ rr = "A".charCodeAt(0);
1104
+ for (vv = 10; vv < 36; ++vv)
1105
+ BI_RC[rr++] = vv;
1106
+ function int2char(n) {
1107
+ return BI_RM.charAt(n);
1108
+ }
1109
+ function intAt(s, i) {
1110
+ var c = BI_RC[s.charCodeAt(i)];
1111
+ return c == null ? -1 : c;
1112
+ }
1113
+ function copyTo(r) {
1114
+ for (var i = this.t - 1; i >= 0; --i)
1115
+ r[i] = this[i];
1116
+ r.t = this.t;
1117
+ r.s = this.s;
1118
+ }
1119
+ function fromInt(x) {
1120
+ this.t = 1;
1121
+ this.s = x < 0 ? -1 : 0;
1122
+ if (x > 0)
1123
+ this[0] = x;
1124
+ else if (x < -1)
1125
+ this[0] = x + this.DV;
1126
+ else
1127
+ this.t = 0;
1128
+ }
1129
+ function nbv(i) {
1130
+ var r = nbi();
1131
+ r.fromInt(i);
1132
+ return r;
1133
+ }
1134
+ function fromString(s, b) {
1135
+ var k;
1136
+ if (b == 16)
1137
+ k = 4;
1138
+ else if (b == 8)
1139
+ k = 3;
1140
+ else if (b == 2)
1141
+ k = 1;
1142
+ else if (b == 32)
1143
+ k = 5;
1144
+ else if (b == 4)
1145
+ k = 2;
1146
+ else
1147
+ throw new Error("Only radix 2, 4, 8, 16, 32 are supported");
1148
+ this.t = 0;
1149
+ this.s = 0;
1150
+ var i = s.length, mi = false, sh = 0;
1151
+ while (--i >= 0) {
1152
+ var x = intAt(s, i);
1153
+ if (x < 0) {
1154
+ if (s.charAt(i) == "-")
1155
+ mi = true;
1156
+ continue;
1157
+ }
1158
+ mi = false;
1159
+ if (sh == 0)
1160
+ this[this.t++] = x;
1161
+ else if (sh + k > this.DB) {
1162
+ this[this.t - 1] |= (x & (1 << this.DB - sh) - 1) << sh;
1163
+ this[this.t++] = x >> this.DB - sh;
1164
+ } else
1165
+ this[this.t - 1] |= x << sh;
1166
+ sh += k;
1167
+ if (sh >= this.DB)
1168
+ sh -= this.DB;
1169
+ }
1170
+ this.clamp();
1171
+ if (mi)
1172
+ BigInteger.ZERO.subTo(this, this);
1173
+ }
1174
+ function clamp() {
1175
+ var c = this.s & this.DM;
1176
+ while (this.t > 0 && this[this.t - 1] == c)
1177
+ --this.t;
1178
+ }
1179
+ function bnToString(b) {
1180
+ if (this.s < 0)
1181
+ return "-" + this.negate().toString(b);
1182
+ var k;
1183
+ if (b == 16)
1184
+ k = 4;
1185
+ else if (b == 8)
1186
+ k = 3;
1187
+ else if (b == 2)
1188
+ k = 1;
1189
+ else if (b == 32)
1190
+ k = 5;
1191
+ else if (b == 4)
1192
+ k = 2;
1193
+ else
1194
+ throw new Error("Only radix 2, 4, 8, 16, 32 are supported");
1195
+ var km = (1 << k) - 1;
1196
+ var d, m = false, r = "", i = this.t;
1197
+ var p = this.DB - i * this.DB % k;
1198
+ if (i-- > 0) {
1199
+ if (p < this.DB && (d = this[i] >> p) > 0) {
1200
+ m = true;
1201
+ r = int2char(d);
1202
+ }
1203
+ while (i >= 0) {
1204
+ if (p < k) {
1205
+ d = (this[i] & (1 << p) - 1) << k - p;
1206
+ d |= this[--i] >> (p += this.DB - k);
1207
+ } else {
1208
+ d = this[i] >> (p -= k) & km;
1209
+ if (p <= 0) {
1210
+ p += this.DB;
1211
+ --i;
1212
+ }
1213
+ }
1214
+ if (d > 0)
1215
+ m = true;
1216
+ if (m)
1217
+ r += int2char(d);
1218
+ }
1219
+ }
1220
+ return m ? r : "0";
1221
+ }
1222
+ function bnNegate() {
1223
+ var r = nbi();
1224
+ BigInteger.ZERO.subTo(this, r);
1225
+ return r;
1226
+ }
1227
+ function bnAbs() {
1228
+ return this.s < 0 ? this.negate() : this;
1229
+ }
1230
+ function bnCompareTo(a) {
1231
+ var r = this.s - a.s;
1232
+ if (r != 0)
1233
+ return r;
1234
+ var i = this.t;
1235
+ r = i - a.t;
1236
+ if (r != 0)
1237
+ return this.s < 0 ? -r : r;
1238
+ while (--i >= 0)
1239
+ if ((r = this[i] - a[i]) != 0)
1240
+ return r;
1241
+ return 0;
1242
+ }
1243
+ function nbits(x) {
1244
+ var r = 1, t;
1245
+ if ((t = x >>> 16) != 0) {
1246
+ x = t;
1247
+ r += 16;
1248
+ }
1249
+ if ((t = x >> 8) != 0) {
1250
+ x = t;
1251
+ r += 8;
1252
+ }
1253
+ if ((t = x >> 4) != 0) {
1254
+ x = t;
1255
+ r += 4;
1256
+ }
1257
+ if ((t = x >> 2) != 0) {
1258
+ x = t;
1259
+ r += 2;
1260
+ }
1261
+ if ((t = x >> 1) != 0) {
1262
+ x = t;
1263
+ r += 1;
1264
+ }
1265
+ return r;
1266
+ }
1267
+ function bnBitLength() {
1268
+ if (this.t <= 0)
1269
+ return 0;
1270
+ return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);
1271
+ }
1272
+ function dlShiftTo(n, r) {
1273
+ var i;
1274
+ for (i = this.t - 1; i >= 0; --i)
1275
+ r[i + n] = this[i];
1276
+ for (i = n - 1; i >= 0; --i)
1277
+ r[i] = 0;
1278
+ r.t = this.t + n;
1279
+ r.s = this.s;
1280
+ }
1281
+ function drShiftTo(n, r) {
1282
+ for (var i = n; i < this.t; ++i)
1283
+ r[i - n] = this[i];
1284
+ r.t = Math.max(this.t - n, 0);
1285
+ r.s = this.s;
1286
+ }
1287
+ function lShiftTo(n, r) {
1288
+ var bs = n % this.DB;
1289
+ var cbs = this.DB - bs;
1290
+ var bm = (1 << cbs) - 1;
1291
+ var ds = Math.floor(n / this.DB);
1292
+ var c = this.s << bs & this.DM, i;
1293
+ for (i = this.t - 1; i >= 0; --i) {
1294
+ r[i + ds + 1] = this[i] >> cbs | c;
1295
+ c = (this[i] & bm) << bs;
1296
+ }
1297
+ for (i = ds - 1; i >= 0; --i)
1298
+ r[i] = 0;
1299
+ r[ds] = c;
1300
+ r.t = this.t + ds + 1;
1301
+ r.s = this.s;
1302
+ r.clamp();
1303
+ }
1304
+ function rShiftTo(n, r) {
1305
+ r.s = this.s;
1306
+ var ds = Math.floor(n / this.DB);
1307
+ if (ds >= this.t) {
1308
+ r.t = 0;
1309
+ return;
1310
+ }
1311
+ var bs = n % this.DB;
1312
+ var cbs = this.DB - bs;
1313
+ var bm = (1 << bs) - 1;
1314
+ r[0] = this[ds] >> bs;
1315
+ for (var i = ds + 1; i < this.t; ++i) {
1316
+ r[i - ds - 1] |= (this[i] & bm) << cbs;
1317
+ r[i - ds] = this[i] >> bs;
1318
+ }
1319
+ if (bs > 0)
1320
+ r[this.t - ds - 1] |= (this.s & bm) << cbs;
1321
+ r.t = this.t - ds;
1322
+ r.clamp();
1323
+ }
1324
+ function subTo(a, r) {
1325
+ var i = 0, c = 0;
1326
+ var m = Math.min(a.t, this.t);
1327
+ while (i < m) {
1328
+ c += this[i] - a[i];
1329
+ r[i++] = c & this.DM;
1330
+ c >>= this.DB;
1331
+ }
1332
+ if (a.t < this.t) {
1333
+ c -= a.s;
1334
+ while (i < this.t) {
1335
+ c += this[i];
1336
+ r[i++] = c & this.DM;
1337
+ c >>= this.DB;
1338
+ }
1339
+ c += this.s;
1340
+ } else {
1341
+ c += this.s;
1342
+ while (i < a.t) {
1343
+ c -= a[i];
1344
+ r[i++] = c & this.DM;
1345
+ c >>= this.DB;
1346
+ }
1347
+ c -= a.s;
1348
+ }
1349
+ r.s = c < 0 ? -1 : 0;
1350
+ if (c < -1)
1351
+ r[i++] = this.DV + c;
1352
+ else if (c > 0)
1353
+ r[i++] = c;
1354
+ r.t = i;
1355
+ r.clamp();
1356
+ }
1357
+ function multiplyTo(a, r) {
1358
+ var x = this.abs(), y = a.abs();
1359
+ var i = x.t;
1360
+ r.t = i + y.t;
1361
+ while (--i >= 0)
1362
+ r[i] = 0;
1363
+ for (i = 0; i < y.t; ++i)
1364
+ r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
1365
+ r.s = 0;
1366
+ r.clamp();
1367
+ if (this.s != a.s)
1368
+ BigInteger.ZERO.subTo(r, r);
1369
+ }
1370
+ function squareTo(r) {
1371
+ var x = this.abs();
1372
+ var i = r.t = 2 * x.t;
1373
+ while (--i >= 0)
1374
+ r[i] = 0;
1375
+ for (i = 0; i < x.t - 1; ++i) {
1376
+ var c = x.am(i, x[i], r, 2 * i, 0, 1);
1377
+ if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
1378
+ r[i + x.t] -= x.DV;
1379
+ r[i + x.t + 1] = 1;
1380
+ }
1381
+ }
1382
+ if (r.t > 0)
1383
+ r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
1384
+ r.s = 0;
1385
+ r.clamp();
1386
+ }
1387
+ function divRemTo(m, q, r) {
1388
+ var pm = m.abs();
1389
+ if (pm.t <= 0)
1390
+ return;
1391
+ var pt = this.abs();
1392
+ if (pt.t < pm.t) {
1393
+ if (q != null)
1394
+ q.fromInt(0);
1395
+ if (r != null)
1396
+ this.copyTo(r);
1397
+ return;
1398
+ }
1399
+ if (r == null)
1400
+ r = nbi();
1401
+ var y = nbi(), ts = this.s, ms = m.s;
1402
+ var nsh = this.DB - nbits(pm[pm.t - 1]);
1403
+ if (nsh > 0) {
1404
+ pm.lShiftTo(nsh, y);
1405
+ pt.lShiftTo(nsh, r);
1406
+ } else {
1407
+ pm.copyTo(y);
1408
+ pt.copyTo(r);
1409
+ }
1410
+ var ys = y.t;
1411
+ var y0 = y[ys - 1];
1412
+ if (y0 == 0)
1413
+ return;
1414
+ var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0);
1415
+ var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;
1416
+ var i = r.t, j = i - ys;
1417
+ var t = q == null ? nbi() : q;
1418
+ y.dlShiftTo(j, t);
1419
+ if (r.compareTo(t) >= 0) {
1420
+ r[r.t++] = 1;
1421
+ r.subTo(t, r);
1422
+ }
1423
+ BigInteger.ONE.dlShiftTo(ys, t);
1424
+ t.subTo(y, y);
1425
+ while (y.t < ys)
1426
+ y[y.t++] = 0;
1427
+ while (--j >= 0) {
1428
+ var qd = r[--i] == y0 ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
1429
+ if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {
1430
+ y.dlShiftTo(j, t);
1431
+ r.subTo(t, r);
1432
+ while (r[i] < --qd)
1433
+ r.subTo(t, r);
1434
+ }
1435
+ }
1436
+ if (q != null) {
1437
+ r.drShiftTo(ys, q);
1438
+ if (ts != ms)
1439
+ BigInteger.ZERO.subTo(q, q);
1440
+ }
1441
+ r.t = ys;
1442
+ r.clamp();
1443
+ if (nsh > 0)
1444
+ r.rShiftTo(nsh, r);
1445
+ if (ts < 0)
1446
+ BigInteger.ZERO.subTo(r, r);
1447
+ }
1448
+ function bnMod(a) {
1449
+ var r = nbi();
1450
+ this.abs().divRemTo(a, null, r);
1451
+ if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0)
1452
+ a.subTo(r, r);
1453
+ return r;
1454
+ }
1455
+ function invDigit() {
1456
+ if (this.t < 1)
1457
+ return 0;
1458
+ var x = this[0];
1459
+ if ((x & 1) == 0)
1460
+ return 0;
1461
+ var y = x & 3;
1462
+ y = y * (2 - (x & 15) * y) & 15;
1463
+ y = y * (2 - (x & 255) * y) & 255;
1464
+ y = y * (2 - ((x & 65535) * y & 65535)) & 65535;
1465
+ y = y * (2 - x * y % this.DV) % this.DV;
1466
+ return y > 0 ? this.DV - y : -y;
1467
+ }
1468
+ function bnEquals(a) {
1469
+ return this.compareTo(a) == 0;
1470
+ }
1471
+ function addTo(a, r) {
1472
+ var i = 0, c = 0;
1473
+ var m = Math.min(a.t, this.t);
1474
+ while (i < m) {
1475
+ c += this[i] + a[i];
1476
+ r[i++] = c & this.DM;
1477
+ c >>= this.DB;
1478
+ }
1479
+ if (a.t < this.t) {
1480
+ c += a.s;
1481
+ while (i < this.t) {
1482
+ c += this[i];
1483
+ r[i++] = c & this.DM;
1484
+ c >>= this.DB;
1485
+ }
1486
+ c += this.s;
1487
+ } else {
1488
+ c += this.s;
1489
+ while (i < a.t) {
1490
+ c += a[i];
1491
+ r[i++] = c & this.DM;
1492
+ c >>= this.DB;
1493
+ }
1494
+ c += a.s;
1495
+ }
1496
+ r.s = c < 0 ? -1 : 0;
1497
+ if (c > 0)
1498
+ r[i++] = c;
1499
+ else if (c < -1)
1500
+ r[i++] = this.DV + c;
1501
+ r.t = i;
1502
+ r.clamp();
1503
+ }
1504
+ function bnAdd(a) {
1505
+ var r = nbi();
1506
+ this.addTo(a, r);
1507
+ return r;
1508
+ }
1509
+ function bnSubtract(a) {
1510
+ var r = nbi();
1511
+ this.subTo(a, r);
1512
+ return r;
1513
+ }
1514
+ function bnMultiply(a) {
1515
+ var r = nbi();
1516
+ this.multiplyTo(a, r);
1517
+ return r;
1518
+ }
1519
+ function bnDivide(a) {
1520
+ var r = nbi();
1521
+ this.divRemTo(a, r, null);
1522
+ return r;
1523
+ }
1524
+ function Montgomery(m) {
1525
+ this.m = m;
1526
+ this.mp = m.invDigit();
1527
+ this.mpl = this.mp & 32767;
1528
+ this.mph = this.mp >> 15;
1529
+ this.um = (1 << m.DB - 15) - 1;
1530
+ this.mt2 = 2 * m.t;
1531
+ }
1532
+ function montConvert(x) {
1533
+ var r = nbi();
1534
+ x.abs().dlShiftTo(this.m.t, r);
1535
+ r.divRemTo(this.m, null, r);
1536
+ if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0)
1537
+ this.m.subTo(r, r);
1538
+ return r;
1539
+ }
1540
+ function montRevert(x) {
1541
+ var r = nbi();
1542
+ x.copyTo(r);
1543
+ this.reduce(r);
1544
+ return r;
1545
+ }
1546
+ function montReduce(x) {
1547
+ while (x.t <= this.mt2)
1548
+ x[x.t++] = 0;
1549
+ for (var i = 0; i < this.m.t; ++i) {
1550
+ var j = x[i] & 32767;
1551
+ var u0 = j * this.mpl + ((j * this.mph + (x[i] >> 15) * this.mpl & this.um) << 15) & x.DM;
1552
+ j = i + this.m.t;
1553
+ x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
1554
+ while (x[j] >= x.DV) {
1555
+ x[j] -= x.DV;
1556
+ x[++j]++;
1557
+ }
1558
+ }
1559
+ x.clamp();
1560
+ x.drShiftTo(this.m.t, x);
1561
+ if (x.compareTo(this.m) >= 0)
1562
+ x.subTo(this.m, x);
1563
+ }
1564
+ function montSqrTo(x, r) {
1565
+ x.squareTo(r);
1566
+ this.reduce(r);
1567
+ }
1568
+ function montMulTo(x, y, r) {
1569
+ x.multiplyTo(y, r);
1570
+ this.reduce(r);
1571
+ }
1572
+ Montgomery.prototype.convert = montConvert;
1573
+ Montgomery.prototype.revert = montRevert;
1574
+ Montgomery.prototype.reduce = montReduce;
1575
+ Montgomery.prototype.mulTo = montMulTo;
1576
+ Montgomery.prototype.sqrTo = montSqrTo;
1577
+ function bnModPow(e, m, callback) {
1578
+ var i = e.bitLength(), r = nbv(1);
1579
+ var z = new Montgomery(m);
1580
+ var k;
1581
+ if (i <= 0)
1582
+ return r;
1583
+ else if (i < 18)
1584
+ k = 1;
1585
+ else if (i < 48)
1586
+ k = 3;
1587
+ else if (i < 144)
1588
+ k = 4;
1589
+ else if (i < 768)
1590
+ k = 5;
1591
+ else
1592
+ k = 6;
1593
+ var g = [], k1 = k - 1, km = (1 << k) - 1;
1594
+ var n = 3;
1595
+ g[1] = z.convert(this);
1596
+ if (k > 1) {
1597
+ var g2 = nbi();
1598
+ z.sqrTo(g[1], g2);
1599
+ while (n <= km) {
1600
+ g[n] = nbi();
1601
+ z.mulTo(g2, g[n - 2], g[n]);
1602
+ n += 2;
1603
+ }
1604
+ }
1605
+ var j = e.t - 1, w, is1 = true, r2 = nbi(), t;
1606
+ i = nbits(e[j]) - 1;
1607
+ while (j >= 0) {
1608
+ if (i >= k1)
1609
+ w = e[j] >> i - k1 & km;
1610
+ else {
1611
+ w = (e[j] & (1 << i + 1) - 1) << k1 - i;
1612
+ if (j > 0)
1613
+ w |= e[j - 1] >> this.DB + i - k1;
1614
+ }
1615
+ n = k;
1616
+ while ((w & 1) == 0) {
1617
+ w >>= 1;
1618
+ --n;
1619
+ }
1620
+ if ((i -= n) < 0) {
1621
+ i += this.DB;
1622
+ --j;
1623
+ }
1624
+ if (is1) {
1625
+ g[w].copyTo(r);
1626
+ is1 = false;
1627
+ } else {
1628
+ while (n > 1) {
1629
+ z.sqrTo(r, r2);
1630
+ z.sqrTo(r2, r);
1631
+ n -= 2;
1632
+ }
1633
+ if (n > 0)
1634
+ z.sqrTo(r, r2);
1635
+ else {
1636
+ t = r;
1637
+ r = r2;
1638
+ r2 = t;
1639
+ }
1640
+ z.mulTo(r2, g[w], r);
1641
+ }
1642
+ while (j >= 0 && (e[j] & 1 << i) == 0) {
1643
+ z.sqrTo(r, r2);
1644
+ t = r;
1645
+ r = r2;
1646
+ r2 = t;
1647
+ if (--i < 0) {
1648
+ i = this.DB - 1;
1649
+ --j;
1650
+ }
1651
+ }
1652
+ }
1653
+ var result = z.revert(r);
1654
+ if (callback) {
1655
+ callback(null, result);
1656
+ }
1657
+ return result;
1658
+ }
1659
+ function bnIsZero() {
1660
+ return this.compareTo(BigInteger.ZERO) == 0;
1661
+ }
1662
+ BigInteger.prototype.copyTo = copyTo;
1663
+ BigInteger.prototype.fromInt = fromInt;
1664
+ BigInteger.prototype.fromString = fromString;
1665
+ BigInteger.prototype.clamp = clamp;
1666
+ BigInteger.prototype.dlShiftTo = dlShiftTo;
1667
+ BigInteger.prototype.drShiftTo = drShiftTo;
1668
+ BigInteger.prototype.lShiftTo = lShiftTo;
1669
+ BigInteger.prototype.rShiftTo = rShiftTo;
1670
+ BigInteger.prototype.subTo = subTo;
1671
+ BigInteger.prototype.multiplyTo = multiplyTo;
1672
+ BigInteger.prototype.squareTo = squareTo;
1673
+ BigInteger.prototype.divRemTo = divRemTo;
1674
+ BigInteger.prototype.invDigit = invDigit;
1675
+ BigInteger.prototype.addTo = addTo;
1676
+ BigInteger.prototype.toString = bnToString;
1677
+ BigInteger.prototype.abs = bnAbs;
1678
+ BigInteger.prototype.negate = bnNegate;
1679
+ BigInteger.prototype.compareTo = bnCompareTo;
1680
+ BigInteger.prototype.bitLength = bnBitLength;
1681
+ BigInteger.prototype.mod = bnMod;
1682
+ BigInteger.prototype.equals = bnEquals;
1683
+ BigInteger.prototype.add = bnAdd;
1684
+ BigInteger.prototype.subtract = bnSubtract;
1685
+ BigInteger.prototype.multiply = bnMultiply;
1686
+ BigInteger.prototype.divide = bnDivide;
1687
+ BigInteger.prototype.modPow = bnModPow;
1688
+ BigInteger.prototype.isZero = bnIsZero;
1689
+ BigInteger.ZERO = nbv(0);
1690
+ BigInteger.ONE = nbv(1);
1691
+ var bigInt = function(str, radix) {
1692
+ return new BigInteger(str, radix);
1693
+ };
1694
+ var bigInteger_default = bigInt;
1695
+
1696
+ // node_modules/aws-cognito-srp-client/dist/cryptoUtils.js
1697
+ var import_sha256 = __toESM(require_sha256());
1698
+ var import_hmac_sha256 = __toESM(require_hmac_sha256());
1699
+ var import_enc_base64 = __toESM(require_enc_base64());
1700
+ var import_enc_hex = __toESM(require_enc_hex());
1701
+ var import_enc_utf8 = __toESM(require_enc_utf8());
1702
+ var polyFillCrypto = function() {
1703
+ if (typeof globalThis !== "undefined" && globalThis.crypto) {
1704
+ return globalThis.crypto;
1705
+ }
1706
+ if (typeof globalThis !== "undefined" && globalThis.msCrypto) {
1707
+ return globalThis.msCrypto;
1708
+ }
1709
+ if (typeof __require === "function") {
1710
+ return __require("crypto").webcrypto;
1711
+ }
1712
+ };
1713
+ var crypto2 = polyFillCrypto();
1714
+ var padHex = function(bigInteger) {
1715
+ var hashStr = bigInteger.toString(16);
1716
+ if (hashStr.length % 2 === 1) {
1717
+ hashStr = "0".concat(hashStr);
1718
+ } else if ("89ABCDEFabcdef".indexOf(hashStr[0]) !== -1) {
1719
+ hashStr = "00".concat(hashStr);
1720
+ }
1721
+ return hashStr;
1722
+ };
1723
+ var hash = function(str) {
1724
+ var hashHex = (0, import_sha256.default)(str).toString();
1725
+ return new Array(64 - hashHex.length).join("0") + hashHex;
1726
+ };
1727
+ var hexHash = function(hexStr) {
1728
+ return hash(import_enc_hex.default.parse(hexStr));
1729
+ };
1730
+ var getRandomIntFromNativeCrypto = function() {
1731
+ if (crypto2) {
1732
+ if (typeof crypto2.getRandomValues === "function") {
1733
+ try {
1734
+ return crypto2.getRandomValues(new Uint32Array(1))[0];
1735
+ } catch (err) {
1736
+ }
1737
+ }
1738
+ if (typeof crypto2.randomBytes === "function") {
1739
+ try {
1740
+ return crypto2.randomBytes(4).readInt32LE();
1741
+ } catch (err) {
1742
+ }
1743
+ }
1744
+ }
1745
+ throw new Error("Native crypto module could not be used to get secure random number.");
1746
+ };
1747
+ var randomValue = function(nBytes) {
1748
+ var words = [];
1749
+ for (var i = 0; i < nBytes; i += 4) {
1750
+ words.push(getRandomIntFromNativeCrypto());
1751
+ }
1752
+ var hexChars = [];
1753
+ for (var i = 0; i < nBytes; i++) {
1754
+ var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
1755
+ hexChars.push((bite >>> 4).toString(16));
1756
+ hexChars.push((bite & 15).toString(16));
1757
+ }
1758
+ var hexRandom = hexChars.join("");
1759
+ var randomInt = bigInteger_default(hexRandom, 16);
1760
+ return randomInt;
1761
+ };
1762
+ var computehkdf = function(ikm, salt) {
1763
+ var infoBits = import_enc_utf8.default.parse("Caldera Derived Key").concat(import_enc_utf8.default.parse(String.fromCharCode(1)));
1764
+ var prk = (0, import_hmac_sha256.default)(ikm, salt);
1765
+ var hmac = (0, import_hmac_sha256.default)(infoBits, prk);
1766
+ return import_enc_hex.default.parse(hmac.toString().slice(0, 32));
1767
+ };
1768
+ var computeSignature = function(message, key) {
1769
+ return import_enc_base64.default.stringify((0, import_hmac_sha256.default)(message, key));
1770
+ };
1771
+
1772
+ // node_modules/aws-cognito-srp-client/dist/index.js
1773
+ var import_enc_base642 = __toESM(require_enc_base64());
1774
+ var import_enc_hex2 = __toESM(require_enc_hex());
1775
+ var import_enc_utf82 = __toESM(require_enc_utf8());
1776
+ var initN = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF";
1777
+ var Srp = (
1778
+ /** @class */
1779
+ (function() {
1780
+ function Srp2(poolId) {
1781
+ this.g = bigInteger_default("2", 16);
1782
+ this.N = bigInteger_default(initN, 16);
1783
+ this.k = bigInteger_default(hexHash(padHex(this.N) + padHex(this.g)), 16);
1784
+ this.poolName = poolId.split("_")[1];
1785
+ }
1786
+ Srp2.prototype.getA = function() {
1787
+ this.a = randomValue(128);
1788
+ this.A = this.g.modPow(this.a, this.N);
1789
+ if (this.A.mod(this.N).isZero()) {
1790
+ new Error("Illegal paramater. A mod N cannot be 0.");
1791
+ }
1792
+ return this.A.toString(16);
1793
+ };
1794
+ Srp2.prototype.getSignature = function(username, strB, strSalt, secretBlock, password) {
1795
+ var B = bigInteger_default(strB, 16);
1796
+ if (B.mod(this.N).isZero()) {
1797
+ new Error("Illegal paramater. B mod N cannot be 0.");
1798
+ }
1799
+ var salt = bigInteger_default(strSalt, 16);
1800
+ var U = bigInteger_default(hexHash(padHex(this.A) + padHex(B)), 16);
1801
+ if (U.isZero()) {
1802
+ throw new Error("U cannot be zero.");
1803
+ }
1804
+ var usernamePasswordHash = hash(import_enc_utf82.default.parse(this.poolName + username + ":" + password));
1805
+ var x = bigInteger_default(hexHash(padHex(salt) + usernamePasswordHash), 16);
1806
+ var S = B.subtract(this.k.multiply(this.g.modPow(x, this.N))).modPow(this.a.add(U.multiply(x)), this.N);
1807
+ var paddedS = padHex(S);
1808
+ var hkdf = computehkdf(import_enc_hex2.default.parse(paddedS), import_enc_hex2.default.parse(padHex(U)));
1809
+ var timestamp = getNowString();
1810
+ var message = import_enc_utf82.default.parse(this.poolName).concat(import_enc_utf82.default.parse(username)).concat(import_enc_base642.default.parse(secretBlock)).concat(import_enc_utf82.default.parse(timestamp));
1811
+ var signature = computeSignature(message, hkdf);
1812
+ return { timestamp, signature };
1813
+ };
1814
+ return Srp2;
1815
+ })()
1816
+ );
1817
+ var dist_default = Srp;
1818
+ var getNowString = function() {
1819
+ var now = /* @__PURE__ */ new Date();
1820
+ var monthNames = [
1821
+ "Jan",
1822
+ "Feb",
1823
+ "Mar",
1824
+ "Apr",
1825
+ "May",
1826
+ "Jun",
1827
+ "Jul",
1828
+ "Aug",
1829
+ "Sep",
1830
+ "Oct",
1831
+ "Nov",
1832
+ "Dec"
1833
+ ];
1834
+ var weekNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
1835
+ var weekDay = weekNames[now.getUTCDay()];
1836
+ var month = monthNames[now.getUTCMonth()];
1837
+ var day = now.getUTCDate();
1838
+ var hours = now.getUTCHours();
1839
+ if (hours < 10) {
1840
+ hours = "0".concat(hours);
1841
+ }
1842
+ var minutes = now.getUTCMinutes();
1843
+ if (minutes < 10) {
1844
+ minutes = "0".concat(minutes);
1845
+ }
1846
+ var seconds = now.getUTCSeconds();
1847
+ if (seconds < 10) {
1848
+ seconds = "0".concat(seconds);
1849
+ }
1850
+ var year = now.getUTCFullYear();
1851
+ var dateNow = "".concat(weekDay, " ").concat(month, " ").concat(day, " ").concat(hours, ":").concat(minutes, ":").concat(seconds, " UTC ").concat(year);
1852
+ return dateNow;
1853
+ };
1854
+
1855
+ // src/errors.ts
1856
+ var WoroApiError = class extends Error {
1857
+ constructor(status, message, code) {
1858
+ super(message);
1859
+ this.status = status;
1860
+ this.code = code;
1861
+ this.name = "WoroApiError";
1862
+ }
1863
+ status;
1864
+ code;
1865
+ };
1866
+ var WoroAuthError = class extends Error {
1867
+ constructor(message, code) {
1868
+ super(message);
1869
+ this.code = code;
1870
+ this.name = "WoroAuthError";
1871
+ }
1872
+ code;
1873
+ };
1874
+ var WoroPayloadError = class extends Error {
1875
+ constructor(message, rawPayload) {
1876
+ super(message);
1877
+ this.rawPayload = rawPayload;
1878
+ this.name = "WoroPayloadError";
1879
+ }
1880
+ rawPayload;
1881
+ };
1882
+
1883
+ // src/payload.ts
1884
+ var WORO_MAX_PAYLOAD_BYTES = 1048576;
1885
+ var WORO_ENVELOPE_CONTENT_TYPE = "application/vnd.woro.sdk-payload";
1886
+ var MAGIC = new Uint8Array([87, 79, 82, 79]);
1887
+ var VERSION = 1;
1888
+ var FLAG_COMPRESSED = 1;
1889
+ var FLAG_ENCRYPTED = 2;
1890
+ var NONCE_BYTES = 12;
1891
+ var TAG_BYTES = 16;
1892
+ async function toBytes(input) {
1893
+ if (typeof input === "string") return new TextEncoder().encode(input);
1894
+ if (input instanceof Blob) return new Uint8Array(await input.arrayBuffer());
1895
+ if (input instanceof ArrayBuffer) return new Uint8Array(input.slice(0));
1896
+ if (ArrayBuffer.isView(input)) {
1897
+ return new Uint8Array(input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength));
1898
+ }
1899
+ throw new TypeError("Payload must be a string, Blob, ArrayBuffer, or typed array.");
1900
+ }
1901
+ async function encodePayload(input, options = {}) {
1902
+ const original = await toBytes(input);
1903
+ if (original.byteLength > WORO_MAX_PAYLOAD_BYTES) {
1904
+ throw new WoroPayloadError(`Original payload exceeds WORO's ${WORO_MAX_PAYLOAD_BYTES}-byte limit.`);
1905
+ }
1906
+ const contentType = options.contentType ?? (input instanceof Blob && input.type ? input.type : typeof input === "string" ? "text/plain; charset=utf-8" : "application/octet-stream");
1907
+ const encryptionKey = options.encryptionKey;
1908
+ if (encryptionKey && encryptionKey.byteLength !== 32) {
1909
+ throw new WoroPayloadError("AES-256-GCM requires a 32-byte encryption key.");
1910
+ }
1911
+ let data = original;
1912
+ let compressed = false;
1913
+ if (options.compress !== false && original.byteLength > 0) {
1914
+ const candidate = await gzip(original);
1915
+ const envelopeBytes = 7 + 2 + new TextEncoder().encode(contentType).byteLength;
1916
+ const savesBytes = encryptionKey ? candidate.byteLength < original.byteLength : candidate.byteLength + envelopeBytes < original.byteLength;
1917
+ if (savesBytes) {
1918
+ data = candidate;
1919
+ compressed = true;
1920
+ }
1921
+ }
1922
+ if (!compressed && !encryptionKey && contentType.split(";", 1)[0]?.trim().toLowerCase() !== WORO_ENVELOPE_CONTENT_TYPE) {
1923
+ return { bytes: original, contentType };
1924
+ }
1925
+ const mediaType = new TextEncoder().encode(contentType);
1926
+ if (mediaType.byteLength > 65535) throw new WoroPayloadError("Content-Type is too long to encode.");
1927
+ const cleartext = new Uint8Array(2 + mediaType.byteLength + data.byteLength);
1928
+ new DataView(cleartext.buffer).setUint16(0, mediaType.byteLength, false);
1929
+ cleartext.set(mediaType, 2);
1930
+ cleartext.set(data, 2 + mediaType.byteLength);
1931
+ const flags = (compressed ? FLAG_COMPRESSED : 0) | (encryptionKey ? FLAG_ENCRYPTED : 0);
1932
+ const nonce = encryptionKey ? crypto.getRandomValues(new Uint8Array(NONCE_BYTES)) : new Uint8Array(0);
1933
+ const header = new Uint8Array(7 + nonce.byteLength);
1934
+ header.set(MAGIC, 0);
1935
+ header[4] = VERSION;
1936
+ header[5] = flags;
1937
+ header[6] = nonce.byteLength;
1938
+ header.set(nonce, 7);
1939
+ const body = encryptionKey ? new Uint8Array(await crypto.subtle.encrypt(
1940
+ { name: "AES-GCM", iv: asArrayBuffer(nonce), additionalData: asArrayBuffer(header), tagLength: TAG_BYTES * 8 },
1941
+ await importAesKey(encryptionKey, ["encrypt"]),
1942
+ asArrayBuffer(cleartext)
1943
+ )) : cleartext;
1944
+ const bytes = new Uint8Array(header.byteLength + body.byteLength);
1945
+ bytes.set(header, 0);
1946
+ bytes.set(body, header.byteLength);
1947
+ return { bytes, contentType: WORO_ENVELOPE_CONTENT_TYPE };
1948
+ }
1949
+ async function decodePayload(bytes, responseContentType, encryptionKey) {
1950
+ if (responseContentType.split(";", 1)[0]?.trim().toLowerCase() !== WORO_ENVELOPE_CONTENT_TYPE) {
1951
+ return { bytes, contentType: responseContentType || "application/octet-stream" };
1952
+ }
1953
+ if (bytes.byteLength < 9 || !MAGIC.every((byte, index) => bytes[index] === byte)) {
1954
+ throw new WoroPayloadError("The WORO package payload envelope is invalid.");
1955
+ }
1956
+ const version = bytes[4];
1957
+ const flags = bytes[5];
1958
+ const nonceLength = bytes[6];
1959
+ if (version !== VERSION || (flags & ~(FLAG_COMPRESSED | FLAG_ENCRYPTED)) !== 0) {
1960
+ throw new WoroPayloadError("The WORO package payload uses an unsupported envelope version or option.");
1961
+ }
1962
+ const encrypted = (flags & FLAG_ENCRYPTED) !== 0;
1963
+ const compressed = (flags & FLAG_COMPRESSED) !== 0;
1964
+ if (encrypted && nonceLength !== NONCE_BYTES || !encrypted && nonceLength !== 0) {
1965
+ throw new WoroPayloadError("The WORO package payload envelope has an invalid nonce.");
1966
+ }
1967
+ const headerLength = 7 + nonceLength;
1968
+ if (bytes.byteLength < headerLength + (encrypted ? TAG_BYTES : 2)) {
1969
+ throw new WoroPayloadError("The WORO package payload envelope is truncated.");
1970
+ }
1971
+ let cleartext = bytes.subarray(headerLength);
1972
+ if (encrypted) {
1973
+ if (!encryptionKey) throw new WoroPayloadError("This payload is encrypted; provide its 32-byte encryption key.", bytes.slice());
1974
+ if (encryptionKey.byteLength !== 32) throw new WoroPayloadError("AES-256-GCM requires a 32-byte encryption key.");
1975
+ try {
1976
+ cleartext = new Uint8Array(await crypto.subtle.decrypt(
1977
+ { name: "AES-GCM", iv: asArrayBuffer(bytes.subarray(7, headerLength)), additionalData: asArrayBuffer(bytes.subarray(0, headerLength)), tagLength: TAG_BYTES * 8 },
1978
+ await importAesKey(encryptionKey, ["decrypt"]),
1979
+ asArrayBuffer(cleartext)
1980
+ ));
1981
+ } catch {
1982
+ throw new WoroPayloadError("Payload decryption failed; the key is wrong or the data was modified.", bytes.slice());
1983
+ }
1984
+ } else if (encryptionKey) {
1985
+ }
1986
+ if (cleartext.byteLength < 2) throw new WoroPayloadError("The WORO package payload metadata is truncated.");
1987
+ const mediaTypeLength = new DataView(cleartext.buffer, cleartext.byteOffset, cleartext.byteLength).getUint16(0, false);
1988
+ if (cleartext.byteLength < 2 + mediaTypeLength) throw new WoroPayloadError("The WORO package payload media type is truncated.");
1989
+ let contentType;
1990
+ try {
1991
+ contentType = new TextDecoder("utf-8", { fatal: true }).decode(cleartext.subarray(2, 2 + mediaTypeLength));
1992
+ } catch {
1993
+ throw new WoroPayloadError("The WORO package payload media type is invalid.");
1994
+ }
1995
+ let payload = cleartext.subarray(2 + mediaTypeLength);
1996
+ if (compressed) {
1997
+ try {
1998
+ payload = await gunzip(payload);
1999
+ } catch (error) {
2000
+ if (error instanceof WoroPayloadError) throw new WoroPayloadError(error.message, bytes.slice());
2001
+ throw error;
2002
+ }
2003
+ if (payload.byteLength > WORO_MAX_PAYLOAD_BYTES) {
2004
+ throw new WoroPayloadError(`Decoded payload exceeds WORO's ${WORO_MAX_PAYLOAD_BYTES}-byte limit.`, bytes.slice());
2005
+ }
2006
+ }
2007
+ return { bytes: payload, contentType: contentType || "application/octet-stream" };
2008
+ }
2009
+ async function importAesKey(key, usages) {
2010
+ return crypto.subtle.importKey("raw", asArrayBuffer(key), { name: "AES-GCM", length: 256 }, false, usages);
2011
+ }
2012
+ async function gzip(bytes) {
2013
+ if (typeof CompressionStream === "undefined") throw new WoroPayloadError("This runtime does not provide gzip compression streams.");
2014
+ const stream = new Blob([asArrayBuffer(bytes)]).stream().pipeThrough(new CompressionStream("gzip"));
2015
+ return await collectStream(stream, WORO_MAX_PAYLOAD_BYTES + 64 * 1024);
2016
+ }
2017
+ async function gunzip(bytes) {
2018
+ if (typeof DecompressionStream === "undefined") throw new WoroPayloadError("This runtime does not provide gzip decompression streams.");
2019
+ try {
2020
+ const stream = new Blob([asArrayBuffer(bytes)]).stream().pipeThrough(new DecompressionStream("gzip"));
2021
+ return await collectStream(stream, WORO_MAX_PAYLOAD_BYTES);
2022
+ } catch (error) {
2023
+ if (error instanceof WoroPayloadError) throw error;
2024
+ throw new WoroPayloadError("The compressed WORO package payload is invalid.");
2025
+ }
2026
+ }
2027
+ async function collectStream(stream, maxBytes) {
2028
+ const reader = stream.getReader();
2029
+ const chunks = [];
2030
+ let total = 0;
2031
+ try {
2032
+ while (true) {
2033
+ const { done, value } = await reader.read();
2034
+ if (done) break;
2035
+ total += value.byteLength;
2036
+ if (total > maxBytes) {
2037
+ await reader.cancel();
2038
+ throw new WoroPayloadError(`Decoded payload exceeds WORO's ${maxBytes}-byte limit.`);
2039
+ }
2040
+ chunks.push(value);
2041
+ }
2042
+ } finally {
2043
+ reader.releaseLock();
2044
+ }
2045
+ const output = new Uint8Array(total);
2046
+ let offset = 0;
2047
+ for (const chunk of chunks) {
2048
+ output.set(chunk, offset);
2049
+ offset += chunk.byteLength;
2050
+ }
2051
+ return output;
2052
+ }
2053
+ function asArrayBuffer(bytes) {
2054
+ return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
2055
+ }
2056
+
2057
+ // src/client.ts
2058
+ var WORO_PRODUCTION_URL = "https://woro.veilgroup.au";
2059
+ var WoroClient = class {
2060
+ baseUrl;
2061
+ fetcher;
2062
+ cognito;
2063
+ writeToken;
2064
+ idToken;
2065
+ idTokenExpiresAt;
2066
+ constructor(options = {}) {
2067
+ this.baseUrl = (options.baseUrl ?? WORO_PRODUCTION_URL).replace(/\/+$/, "");
2068
+ this.writeToken = options.writeToken;
2069
+ this.idToken = options.idToken;
2070
+ this.cognito = options.cognito;
2071
+ this.fetcher = options.fetch ?? fetch;
2072
+ }
2073
+ setWriteToken(token) {
2074
+ this.writeToken = token;
2075
+ }
2076
+ setIdToken(token, expiresInSeconds) {
2077
+ this.idToken = token;
2078
+ this.idTokenExpiresAt = token && expiresInSeconds !== void 0 ? Date.now() + expiresInSeconds * 1e3 : void 0;
2079
+ }
2080
+ signOut() {
2081
+ this.setIdToken(void 0);
2082
+ }
2083
+ async signIn(username, password) {
2084
+ if (!this.cognito) throw new WoroAuthError("Cognito region, userPoolId, and appClientId are required for sign-in.");
2085
+ if (!username || !password) throw new WoroAuthError("A Cognito username and password are required.");
2086
+ const srp = new dist_default(this.cognito.userPoolId);
2087
+ const endpoint = `https://cognito-idp.${this.cognito.region}.amazonaws.com/`;
2088
+ const initialResponse = await this.fetcher(endpoint, {
2089
+ method: "POST",
2090
+ headers: {
2091
+ "content-type": "application/x-amz-json-1.1",
2092
+ "x-amz-target": "AWSCognitoIdentityProviderService.InitiateAuth"
2093
+ },
2094
+ body: JSON.stringify({
2095
+ AuthFlow: "USER_SRP_AUTH",
2096
+ ClientId: this.cognito.appClientId,
2097
+ AuthParameters: { USERNAME: username, SRP_A: srp.getA() }
2098
+ })
2099
+ });
2100
+ const initial = await parseCognitoResponse(initialResponse, "InitiateAuth");
2101
+ if (initial.ChallengeName !== "PASSWORD_VERIFIER") {
2102
+ throw new WoroAuthError(`Cognito requires an unsupported challenge (${String(initial.ChallengeName ?? "unknown")}). This package supports SRP password sign-in without MFA or forced password reset.`);
2103
+ }
2104
+ const challenge = asRecord(initial.ChallengeParameters);
2105
+ const srpUsername = stringField(challenge, "USER_ID_FOR_SRP") ?? username;
2106
+ const srpB = stringField(challenge, "SRP_B");
2107
+ const salt = stringField(challenge, "SALT");
2108
+ const secretBlock = stringField(challenge, "SECRET_BLOCK");
2109
+ const session = stringField(initial, "Session");
2110
+ if (!srpB || !salt || !secretBlock || !session) throw new WoroAuthError("Cognito returned an incomplete SRP challenge.");
2111
+ const proof = srp.getSignature(srpUsername, srpB, salt, secretBlock, password);
2112
+ const finalResponse = await this.fetcher(endpoint, {
2113
+ method: "POST",
2114
+ headers: {
2115
+ "content-type": "application/x-amz-json-1.1",
2116
+ "x-amz-target": "AWSCognitoIdentityProviderService.RespondToAuthChallenge"
2117
+ },
2118
+ body: JSON.stringify({
2119
+ ChallengeName: "PASSWORD_VERIFIER",
2120
+ ClientId: this.cognito.appClientId,
2121
+ Session: session,
2122
+ ChallengeResponses: {
2123
+ USERNAME: srpUsername,
2124
+ PASSWORD_CLAIM_SECRET_BLOCK: secretBlock,
2125
+ PASSWORD_CLAIM_SIGNATURE: proof.signature,
2126
+ TIMESTAMP: proof.timestamp
2127
+ }
2128
+ })
2129
+ });
2130
+ const final = await parseCognitoResponse(finalResponse, "RespondToAuthChallenge");
2131
+ const authResult = asRecord(final.AuthenticationResult);
2132
+ const idToken = stringField(authResult, "IdToken");
2133
+ if (!idToken) throw new WoroAuthError("Cognito sign-in did not return an ID token.");
2134
+ const expiresIn = numberField(authResult, "ExpiresIn") ?? 3600;
2135
+ this.setIdToken(idToken, expiresIn);
2136
+ return { idToken, expiresIn };
2137
+ }
2138
+ async writeSecret(input, options = {}) {
2139
+ const encoded = await encodePayload(input, options);
2140
+ if (encoded.bytes.byteLength === 0) throw new TypeError("An empty payload creates an empty slot in WORO. Use createEmptySlot() explicitly.");
2141
+ this.assertPayloadSize(encoded.bytes);
2142
+ const response = await this.request("/secret", {
2143
+ method: "POST",
2144
+ headers: {
2145
+ "content-type": encoded.contentType,
2146
+ "x-api-key": this.getWriteToken(options.writeToken)
2147
+ },
2148
+ body: new Blob([toArrayBuffer(encoded.bytes)])
2149
+ });
2150
+ return await response.json();
2151
+ }
2152
+ async createEmptySlot(writeToken) {
2153
+ const response = await this.request("/secret", {
2154
+ method: "POST",
2155
+ headers: { "x-api-key": this.getWriteToken(writeToken) }
2156
+ });
2157
+ return await response.json();
2158
+ }
2159
+ async fillSecret(readToken, input, options = {}) {
2160
+ const encoded = await encodePayload(input, options);
2161
+ if (encoded.bytes.byteLength === 0) throw new TypeError("An empty payload cannot fill a WORO slot.");
2162
+ this.assertPayloadSize(encoded.bytes);
2163
+ await this.request(`/secret/${encodeURIComponent(readToken)}`, {
2164
+ method: "PUT",
2165
+ headers: { "content-type": encoded.contentType },
2166
+ body: new Blob([toArrayBuffer(encoded.bytes)])
2167
+ });
2168
+ }
2169
+ async readSecret(readToken, options = {}) {
2170
+ const response = await this.request(`/secret/${encodeURIComponent(readToken)}`, { method: "GET" });
2171
+ const bytes = new Uint8Array(await response.arrayBuffer());
2172
+ const payload = await decodePayload(bytes, response.headers.get("content-type") ?? "application/octet-stream", options.encryptionKey);
2173
+ return { data: payload.bytes, contentType: payload.contentType };
2174
+ }
2175
+ async deleteSecret(readToken) {
2176
+ await this.request(`/secret/${encodeURIComponent(readToken)}`, { method: "DELETE" });
2177
+ }
2178
+ async getSecretStatus(readToken) {
2179
+ const response = await this.request(`/secret/${encodeURIComponent(readToken)}`, {
2180
+ method: "HEAD",
2181
+ headers: this.authorizationHeaders()
2182
+ });
2183
+ return {
2184
+ state: response.headers.get("x-woro-secret-state"),
2185
+ createdAt: response.headers.get("x-woro-secret-created-at"),
2186
+ expiresAt: response.headers.get("x-woro-secret-expires-at"),
2187
+ uploadedAt: response.headers.get("x-woro-secret-uploaded-at"),
2188
+ redeemedAt: response.headers.get("x-woro-secret-redeemed-at"),
2189
+ deletedAt: response.headers.get("x-woro-secret-deleted-at")
2190
+ };
2191
+ }
2192
+ async getAccount() {
2193
+ return await (await this.request("/account", { method: "GET", headers: this.authorizationHeaders() })).json();
2194
+ }
2195
+ async getAccountBalance() {
2196
+ return await (await this.request("/account/balance", { method: "GET", headers: this.authorizationHeaders() })).json();
2197
+ }
2198
+ async listWriteTokens() {
2199
+ const body = await (await this.request("/account/tokens", { method: "GET", headers: this.authorizationHeaders() })).json();
2200
+ if (Array.isArray(body)) return body;
2201
+ const items = asRecord(body).tokens;
2202
+ return Array.isArray(items) ? items : [];
2203
+ }
2204
+ async createWriteToken(label) {
2205
+ const response = await this.request("/account/tokens", {
2206
+ method: "POST",
2207
+ headers: { ...this.authorizationHeaders(), "content-type": "application/json" },
2208
+ body: JSON.stringify({ label })
2209
+ });
2210
+ return await response.json();
2211
+ }
2212
+ async revokeWriteToken(tokenId) {
2213
+ await this.request(`/account/tokens/${encodeURIComponent(tokenId)}`, {
2214
+ method: "DELETE",
2215
+ headers: this.authorizationHeaders()
2216
+ });
2217
+ }
2218
+ async checkWriteToken(writeToken = this.getWriteToken()) {
2219
+ const response = await this.request("/account/token", {
2220
+ method: "HEAD",
2221
+ headers: { ...this.authorizationHeaders(), "x-api-key": writeToken }
2222
+ });
2223
+ return response.headers.get("x-woro-token-state");
2224
+ }
2225
+ getWriteToken(override) {
2226
+ const token = override ?? this.writeToken;
2227
+ if (!token) throw new WoroAuthError("A WORO write token is required for this operation.");
2228
+ return token;
2229
+ }
2230
+ authorizationHeaders() {
2231
+ if (!this.idToken) throw new WoroAuthError("Sign in to the Cognito account before using this operation.");
2232
+ if (this.idTokenExpiresAt !== void 0 && Date.now() >= this.idTokenExpiresAt) {
2233
+ this.signOut();
2234
+ throw new WoroAuthError("The Cognito ID token has expired; sign in again.");
2235
+ }
2236
+ return { authorization: `Bearer ${this.idToken}` };
2237
+ }
2238
+ assertPayloadSize(bytes) {
2239
+ if (bytes.byteLength > WORO_MAX_PAYLOAD_BYTES) {
2240
+ throw new WoroApiError(413, `Encoded payload exceeds WORO's ${WORO_MAX_PAYLOAD_BYTES}-byte limit.`, "secret_too_large");
2241
+ }
2242
+ }
2243
+ async request(path, init) {
2244
+ const response = await this.fetcher(`${this.baseUrl}${path}`, { ...init, cache: "no-store" });
2245
+ if (!response.ok) throw await apiError(response);
2246
+ return response;
2247
+ }
2248
+ };
2249
+ async function parseCognitoResponse(response, operation) {
2250
+ let result;
2251
+ try {
2252
+ result = await response.json();
2253
+ } catch {
2254
+ result = void 0;
2255
+ }
2256
+ if (!response.ok) {
2257
+ const body = asRecord(result);
2258
+ const code = stringField(body, "__type")?.split("#").pop();
2259
+ const message = stringField(body, "message") ?? `Cognito ${operation} failed with HTTP ${response.status}.`;
2260
+ throw new WoroAuthError(message, code);
2261
+ }
2262
+ return asRecord(result);
2263
+ }
2264
+ async function apiError(response) {
2265
+ let code;
2266
+ let message = `WORO request failed with HTTP ${response.status}.`;
2267
+ try {
2268
+ const body = asRecord(await response.json());
2269
+ code = stringField(body, "code") ?? stringField(body, "error");
2270
+ const detail = stringField(body, "error");
2271
+ if (detail && detail.length <= 200) message = detail;
2272
+ } catch {
2273
+ }
2274
+ return new WoroApiError(response.status, message, code);
2275
+ }
2276
+ function asRecord(value) {
2277
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
2278
+ }
2279
+ function stringField(value, key) {
2280
+ return typeof value[key] === "string" ? value[key] : void 0;
2281
+ }
2282
+ function numberField(value, key) {
2283
+ return typeof value[key] === "number" && Number.isFinite(value[key]) ? value[key] : void 0;
2284
+ }
2285
+ function toArrayBuffer(bytes) {
2286
+ return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
2287
+ }
2288
+ export {
2289
+ WORO_ENVELOPE_CONTENT_TYPE,
2290
+ WORO_MAX_PAYLOAD_BYTES,
2291
+ WORO_PRODUCTION_URL,
2292
+ WoroApiError,
2293
+ WoroAuthError,
2294
+ WoroClient,
2295
+ WoroPayloadError,
2296
+ decodePayload,
2297
+ encodePayload,
2298
+ toBytes
2299
+ };
2300
+ //# sourceMappingURL=index.js.map