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