@dodopayments/convex 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component/lib.js +1 -1
- package/dist/index.cjs +790 -813
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +790 -813
- package/dist/index.js.map +1 -1
- package/dist/packages/core/dist/{chunk-7ICTY2GO.js → chunk-BVTJMX2W.js} +13 -2
- package/dist/packages/core/dist/chunk-BVTJMX2W.js.map +1 -0
- package/package.json +7 -3
- package/dist/packages/core/dist/chunk-7ICTY2GO.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -417,8 +417,8 @@ function convexOrUndefinedToJson(value) {
|
|
|
417
417
|
return convexOrUndefinedToJsonInternal(value, value, "");
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
-
var __defProp$
|
|
421
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$
|
|
420
|
+
var __defProp$4 = Object.defineProperty;
|
|
421
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
422
422
|
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
423
423
|
var _a, _b;
|
|
424
424
|
const IDENTIFYING_FIELD = Symbol.for("ConvexError");
|
|
@@ -533,8 +533,8 @@ function setupActionCalls(requestId) {
|
|
|
533
533
|
};
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
-
var __defProp$
|
|
537
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$
|
|
536
|
+
var __defProp$3 = Object.defineProperty;
|
|
537
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
538
538
|
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
539
539
|
class FilterExpression {
|
|
540
540
|
/**
|
|
@@ -556,8 +556,8 @@ function validateArg(arg, idx, method, argName) {
|
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
var __defProp$
|
|
560
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$
|
|
559
|
+
var __defProp$2 = Object.defineProperty;
|
|
560
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
561
561
|
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
562
562
|
function setupActionVectorSearch(requestId) {
|
|
563
563
|
return async (tableName, indexName, query) => {
|
|
@@ -834,8 +834,8 @@ const httpActionGeneric = (func) => {
|
|
|
834
834
|
return q;
|
|
835
835
|
};
|
|
836
836
|
|
|
837
|
-
var __defProp = Object.defineProperty;
|
|
838
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
837
|
+
var __defProp$1 = Object.defineProperty;
|
|
838
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
839
839
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
840
840
|
class InstalledComponent {
|
|
841
841
|
constructor(definition, name) {
|
|
@@ -5270,6 +5270,12 @@ var SubscriptionExpiredPayloadSchema = objectType({
|
|
|
5270
5270
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
5271
5271
|
data: SubscriptionSchema
|
|
5272
5272
|
});
|
|
5273
|
+
var SubscriptionUpdatedPayloadSchema = objectType({
|
|
5274
|
+
business_id: stringType(),
|
|
5275
|
+
type: literalType("subscription.updated"),
|
|
5276
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
5277
|
+
data: SubscriptionSchema
|
|
5278
|
+
});
|
|
5273
5279
|
var LicenseKeyCreatedPayloadSchema = objectType({
|
|
5274
5280
|
business_id: stringType(),
|
|
5275
5281
|
type: literalType("license_key.created"),
|
|
@@ -5298,860 +5304,828 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
|
5298
5304
|
SubscriptionCancelledPayloadSchema,
|
|
5299
5305
|
SubscriptionFailedPayloadSchema,
|
|
5300
5306
|
SubscriptionExpiredPayloadSchema,
|
|
5307
|
+
SubscriptionUpdatedPayloadSchema,
|
|
5301
5308
|
LicenseKeyCreatedPayloadSchema
|
|
5302
5309
|
]);
|
|
5303
5310
|
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
var dist = {};
|
|
5307
|
-
|
|
5308
|
-
var timing_safe_equal = {};
|
|
5309
|
-
|
|
5310
|
-
Object.defineProperty(timing_safe_equal, "__esModule", { value: true });
|
|
5311
|
-
timing_safe_equal.timingSafeEqual = void 0;
|
|
5311
|
+
// src/webhook/vendor/timing_safe_equal.ts
|
|
5312
5312
|
function assert(expr, msg = "") {
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5313
|
+
if (!expr) {
|
|
5314
|
+
throw new Error(msg);
|
|
5315
|
+
}
|
|
5316
5316
|
}
|
|
5317
5317
|
function timingSafeEqual(a, b) {
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5318
|
+
if (a.byteLength !== b.byteLength) {
|
|
5319
|
+
return false;
|
|
5320
|
+
}
|
|
5321
|
+
if (!(a instanceof DataView)) {
|
|
5322
|
+
a = new DataView(ArrayBuffer.isView(a) ? a.buffer : a);
|
|
5323
|
+
}
|
|
5324
|
+
if (!(b instanceof DataView)) {
|
|
5325
|
+
b = new DataView(ArrayBuffer.isView(b) ? b.buffer : b);
|
|
5326
|
+
}
|
|
5327
|
+
assert(a instanceof DataView);
|
|
5328
|
+
assert(b instanceof DataView);
|
|
5329
|
+
const length = a.byteLength;
|
|
5330
|
+
let out = 0;
|
|
5331
|
+
let i = -1;
|
|
5332
|
+
while (++i < length) {
|
|
5333
|
+
out |= a.getUint8(i) ^ b.getUint8(i);
|
|
5334
|
+
}
|
|
5335
|
+
return out === 0;
|
|
5336
5336
|
}
|
|
5337
|
-
timing_safe_equal.timingSafeEqual = timingSafeEqual;
|
|
5338
5337
|
|
|
5339
|
-
var
|
|
5338
|
+
var __create = Object.create;
|
|
5339
|
+
var __defProp = Object.defineProperty;
|
|
5340
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5341
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5342
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5343
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5344
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
5345
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5346
|
+
};
|
|
5347
|
+
var __copyProps = (to, from, except, desc) => {
|
|
5348
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
5349
|
+
for (let key of __getOwnPropNames(from))
|
|
5350
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
5351
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
5352
|
+
}
|
|
5353
|
+
return to;
|
|
5354
|
+
};
|
|
5355
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
5356
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
5357
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
5358
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
5359
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
5360
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
5361
|
+
mod
|
|
5362
|
+
));
|
|
5340
5363
|
|
|
5341
|
-
//
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
var
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5364
|
+
// ../../node_modules/@stablelib/base64/lib/base64.js
|
|
5365
|
+
var require_base64 = __commonJS({
|
|
5366
|
+
"../../node_modules/@stablelib/base64/lib/base64.js"(exports) {
|
|
5367
|
+
var __extends = exports && exports.__extends || /* @__PURE__ */ function() {
|
|
5368
|
+
var extendStatics = function(d, b) {
|
|
5369
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
5370
|
+
d2.__proto__ = b2;
|
|
5371
|
+
} || function(d2, b2) {
|
|
5372
|
+
for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
|
|
5373
|
+
};
|
|
5348
5374
|
return extendStatics(d, b);
|
|
5349
|
-
|
|
5350
|
-
|
|
5375
|
+
};
|
|
5376
|
+
return function(d, b) {
|
|
5351
5377
|
extendStatics(d, b);
|
|
5352
|
-
function __() {
|
|
5378
|
+
function __() {
|
|
5379
|
+
this.constructor = d;
|
|
5380
|
+
}
|
|
5353
5381
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
5354
|
-
|
|
5355
|
-
}
|
|
5356
|
-
Object.defineProperty(
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
*/
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
var Coder = /** @class */ (function () {
|
|
5370
|
-
// TODO(dchest): methods to encode chunk-by-chunk.
|
|
5371
|
-
function Coder(_paddingCharacter) {
|
|
5372
|
-
if (_paddingCharacter === void 0) { _paddingCharacter = "="; }
|
|
5373
|
-
this._paddingCharacter = _paddingCharacter;
|
|
5374
|
-
}
|
|
5375
|
-
Coder.prototype.encodedLength = function (length) {
|
|
5376
|
-
if (!this._paddingCharacter) {
|
|
5382
|
+
};
|
|
5383
|
+
}();
|
|
5384
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5385
|
+
var INVALID_BYTE = 256;
|
|
5386
|
+
var Coder = (
|
|
5387
|
+
/** @class */
|
|
5388
|
+
function() {
|
|
5389
|
+
function Coder2(_paddingCharacter) {
|
|
5390
|
+
if (_paddingCharacter === void 0) {
|
|
5391
|
+
_paddingCharacter = "=";
|
|
5392
|
+
}
|
|
5393
|
+
this._paddingCharacter = _paddingCharacter;
|
|
5394
|
+
}
|
|
5395
|
+
Coder2.prototype.encodedLength = function(length) {
|
|
5396
|
+
if (!this._paddingCharacter) {
|
|
5377
5397
|
return (length * 8 + 5) / 6 | 0;
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
var c =
|
|
5386
|
-
out += this._encodeByte(
|
|
5387
|
-
out += this._encodeByte(
|
|
5388
|
-
out += this._encodeByte(
|
|
5389
|
-
out += this._encodeByte(
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
var c =
|
|
5394
|
-
out += this._encodeByte(
|
|
5395
|
-
out += this._encodeByte(
|
|
5398
|
+
}
|
|
5399
|
+
return (length + 2) / 3 * 4 | 0;
|
|
5400
|
+
};
|
|
5401
|
+
Coder2.prototype.encode = function(data) {
|
|
5402
|
+
var out = "";
|
|
5403
|
+
var i = 0;
|
|
5404
|
+
for (; i < data.length - 2; i += 3) {
|
|
5405
|
+
var c = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
|
|
5406
|
+
out += this._encodeByte(c >>> 3 * 6 & 63);
|
|
5407
|
+
out += this._encodeByte(c >>> 2 * 6 & 63);
|
|
5408
|
+
out += this._encodeByte(c >>> 1 * 6 & 63);
|
|
5409
|
+
out += this._encodeByte(c >>> 0 * 6 & 63);
|
|
5410
|
+
}
|
|
5411
|
+
var left = data.length - i;
|
|
5412
|
+
if (left > 0) {
|
|
5413
|
+
var c = data[i] << 16 | (left === 2 ? data[i + 1] << 8 : 0);
|
|
5414
|
+
out += this._encodeByte(c >>> 3 * 6 & 63);
|
|
5415
|
+
out += this._encodeByte(c >>> 2 * 6 & 63);
|
|
5396
5416
|
if (left === 2) {
|
|
5397
|
-
|
|
5398
|
-
}
|
|
5399
|
-
|
|
5400
|
-
out += this._paddingCharacter || "";
|
|
5417
|
+
out += this._encodeByte(c >>> 1 * 6 & 63);
|
|
5418
|
+
} else {
|
|
5419
|
+
out += this._paddingCharacter || "";
|
|
5401
5420
|
}
|
|
5402
5421
|
out += this._paddingCharacter || "";
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5422
|
+
}
|
|
5423
|
+
return out;
|
|
5424
|
+
};
|
|
5425
|
+
Coder2.prototype.maxDecodedLength = function(length) {
|
|
5426
|
+
if (!this._paddingCharacter) {
|
|
5408
5427
|
return (length * 6 + 7) / 8 | 0;
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5428
|
+
}
|
|
5429
|
+
return length / 4 * 3 | 0;
|
|
5430
|
+
};
|
|
5431
|
+
Coder2.prototype.decodedLength = function(s) {
|
|
5432
|
+
return this.maxDecodedLength(s.length - this._getPaddingLength(s));
|
|
5433
|
+
};
|
|
5434
|
+
Coder2.prototype.decode = function(s) {
|
|
5435
|
+
if (s.length === 0) {
|
|
5417
5436
|
return new Uint8Array(0);
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5437
|
+
}
|
|
5438
|
+
var paddingLength = this._getPaddingLength(s);
|
|
5439
|
+
var length = s.length - paddingLength;
|
|
5440
|
+
var out = new Uint8Array(this.maxDecodedLength(length));
|
|
5441
|
+
var op = 0;
|
|
5442
|
+
var i = 0;
|
|
5443
|
+
var haveBad = 0;
|
|
5444
|
+
var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
|
|
5445
|
+
for (; i < length - 4; i += 4) {
|
|
5427
5446
|
v0 = this._decodeChar(s.charCodeAt(i + 0));
|
|
5428
5447
|
v1 = this._decodeChar(s.charCodeAt(i + 1));
|
|
5429
5448
|
v2 = this._decodeChar(s.charCodeAt(i + 2));
|
|
5430
5449
|
v3 = this._decodeChar(s.charCodeAt(i + 3));
|
|
5431
|
-
out[op++] =
|
|
5432
|
-
out[op++] =
|
|
5433
|
-
out[op++] =
|
|
5450
|
+
out[op++] = v0 << 2 | v1 >>> 4;
|
|
5451
|
+
out[op++] = v1 << 4 | v2 >>> 2;
|
|
5452
|
+
out[op++] = v2 << 6 | v3;
|
|
5434
5453
|
haveBad |= v0 & INVALID_BYTE;
|
|
5435
5454
|
haveBad |= v1 & INVALID_BYTE;
|
|
5436
5455
|
haveBad |= v2 & INVALID_BYTE;
|
|
5437
5456
|
haveBad |= v3 & INVALID_BYTE;
|
|
5438
|
-
|
|
5439
|
-
|
|
5457
|
+
}
|
|
5458
|
+
if (i < length - 1) {
|
|
5440
5459
|
v0 = this._decodeChar(s.charCodeAt(i));
|
|
5441
5460
|
v1 = this._decodeChar(s.charCodeAt(i + 1));
|
|
5442
|
-
out[op++] =
|
|
5461
|
+
out[op++] = v0 << 2 | v1 >>> 4;
|
|
5443
5462
|
haveBad |= v0 & INVALID_BYTE;
|
|
5444
5463
|
haveBad |= v1 & INVALID_BYTE;
|
|
5445
|
-
|
|
5446
|
-
|
|
5464
|
+
}
|
|
5465
|
+
if (i < length - 2) {
|
|
5447
5466
|
v2 = this._decodeChar(s.charCodeAt(i + 2));
|
|
5448
|
-
out[op++] =
|
|
5467
|
+
out[op++] = v1 << 4 | v2 >>> 2;
|
|
5449
5468
|
haveBad |= v2 & INVALID_BYTE;
|
|
5450
|
-
|
|
5451
|
-
|
|
5469
|
+
}
|
|
5470
|
+
if (i < length - 3) {
|
|
5452
5471
|
v3 = this._decodeChar(s.charCodeAt(i + 3));
|
|
5453
|
-
out[op++] =
|
|
5472
|
+
out[op++] = v2 << 6 | v3;
|
|
5454
5473
|
haveBad |= v3 & INVALID_BYTE;
|
|
5455
|
-
|
|
5456
|
-
|
|
5474
|
+
}
|
|
5475
|
+
if (haveBad !== 0) {
|
|
5457
5476
|
throw new Error("Base64Coder: incorrect characters for decoding");
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
//
|
|
5483
|
-
// 4. Continue comparing b to higher ASCII values, and selecting
|
|
5484
|
-
// zero if comparison isn't true, otherwise selecting a value
|
|
5485
|
-
// to add to result, which:
|
|
5486
|
-
//
|
|
5487
|
-
// a) undoes the previous addition
|
|
5488
|
-
// b) provides new value to add
|
|
5489
|
-
//
|
|
5490
|
-
var result = b;
|
|
5491
|
-
// b >= 0
|
|
5492
|
-
result += 65;
|
|
5493
|
-
// b > 25
|
|
5494
|
-
result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);
|
|
5495
|
-
// b > 51
|
|
5496
|
-
result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);
|
|
5497
|
-
// b > 61
|
|
5498
|
-
result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);
|
|
5499
|
-
// b > 62
|
|
5500
|
-
result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);
|
|
5501
|
-
return String.fromCharCode(result);
|
|
5502
|
-
};
|
|
5503
|
-
// Decode a character code into a byte.
|
|
5504
|
-
// Must return 256 if character is out of alphabet range.
|
|
5505
|
-
Coder.prototype._decodeChar = function (c) {
|
|
5506
|
-
// Decoding works similar to encoding: using the same comparison
|
|
5507
|
-
// function, but now it works on ranges: result is always incremented
|
|
5508
|
-
// by value, but this value becomes zero if the range is not
|
|
5509
|
-
// satisfied.
|
|
5510
|
-
//
|
|
5511
|
-
// Decoding starts with invalid value, 256, which is then
|
|
5512
|
-
// subtracted when the range is satisfied. If none of the ranges
|
|
5513
|
-
// apply, the function returns 256, which is then checked by
|
|
5514
|
-
// the caller to throw error.
|
|
5515
|
-
var result = INVALID_BYTE; // start with invalid character
|
|
5516
|
-
// c == 43 (c > 42 and c < 44)
|
|
5517
|
-
result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);
|
|
5518
|
-
// c == 47 (c > 46 and c < 48)
|
|
5519
|
-
result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);
|
|
5520
|
-
// c > 47 and c < 58
|
|
5521
|
-
result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);
|
|
5522
|
-
// c > 64 and c < 91
|
|
5523
|
-
result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);
|
|
5524
|
-
// c > 96 and c < 123
|
|
5525
|
-
result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);
|
|
5526
|
-
return result;
|
|
5527
|
-
};
|
|
5528
|
-
Coder.prototype._getPaddingLength = function (s) {
|
|
5529
|
-
var paddingLength = 0;
|
|
5530
|
-
if (this._paddingCharacter) {
|
|
5477
|
+
}
|
|
5478
|
+
return out;
|
|
5479
|
+
};
|
|
5480
|
+
Coder2.prototype._encodeByte = function(b) {
|
|
5481
|
+
var result = b;
|
|
5482
|
+
result += 65;
|
|
5483
|
+
result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
|
|
5484
|
+
result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
|
|
5485
|
+
result += 61 - b >>> 8 & 52 - 48 - 62 + 43;
|
|
5486
|
+
result += 62 - b >>> 8 & 62 - 43 - 63 + 47;
|
|
5487
|
+
return String.fromCharCode(result);
|
|
5488
|
+
};
|
|
5489
|
+
Coder2.prototype._decodeChar = function(c) {
|
|
5490
|
+
var result = INVALID_BYTE;
|
|
5491
|
+
result += (42 - c & c - 44) >>> 8 & -INVALID_BYTE + c - 43 + 62;
|
|
5492
|
+
result += (46 - c & c - 48) >>> 8 & -INVALID_BYTE + c - 47 + 63;
|
|
5493
|
+
result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
|
|
5494
|
+
result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
|
|
5495
|
+
result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
|
|
5496
|
+
return result;
|
|
5497
|
+
};
|
|
5498
|
+
Coder2.prototype._getPaddingLength = function(s) {
|
|
5499
|
+
var paddingLength = 0;
|
|
5500
|
+
if (this._paddingCharacter) {
|
|
5531
5501
|
for (var i = s.length - 1; i >= 0; i--) {
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5502
|
+
if (s[i] !== this._paddingCharacter) {
|
|
5503
|
+
break;
|
|
5504
|
+
}
|
|
5505
|
+
paddingLength++;
|
|
5536
5506
|
}
|
|
5537
5507
|
if (s.length < 4 || paddingLength > 2) {
|
|
5538
|
-
|
|
5508
|
+
throw new Error("Base64Coder: incorrect padding");
|
|
5539
5509
|
}
|
|
5540
|
-
|
|
5541
|
-
|
|
5510
|
+
}
|
|
5511
|
+
return paddingLength;
|
|
5512
|
+
};
|
|
5513
|
+
return Coder2;
|
|
5514
|
+
}()
|
|
5515
|
+
);
|
|
5516
|
+
exports.Coder = Coder;
|
|
5517
|
+
var stdCoder = new Coder();
|
|
5518
|
+
function encode2(data) {
|
|
5519
|
+
return stdCoder.encode(data);
|
|
5520
|
+
}
|
|
5521
|
+
exports.encode = encode2;
|
|
5522
|
+
function decode2(s) {
|
|
5523
|
+
return stdCoder.decode(s);
|
|
5524
|
+
}
|
|
5525
|
+
exports.decode = decode2;
|
|
5526
|
+
var URLSafeCoder = (
|
|
5527
|
+
/** @class */
|
|
5528
|
+
function(_super) {
|
|
5529
|
+
__extends(URLSafeCoder2, _super);
|
|
5530
|
+
function URLSafeCoder2() {
|
|
5531
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
5532
|
+
}
|
|
5533
|
+
URLSafeCoder2.prototype._encodeByte = function(b) {
|
|
5534
|
+
var result = b;
|
|
5535
|
+
result += 65;
|
|
5536
|
+
result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
|
|
5537
|
+
result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
|
|
5538
|
+
result += 61 - b >>> 8 & 52 - 48 - 62 + 45;
|
|
5539
|
+
result += 62 - b >>> 8 & 62 - 45 - 63 + 95;
|
|
5540
|
+
return String.fromCharCode(result);
|
|
5541
|
+
};
|
|
5542
|
+
URLSafeCoder2.prototype._decodeChar = function(c) {
|
|
5543
|
+
var result = INVALID_BYTE;
|
|
5544
|
+
result += (44 - c & c - 46) >>> 8 & -INVALID_BYTE + c - 45 + 62;
|
|
5545
|
+
result += (94 - c & c - 96) >>> 8 & -INVALID_BYTE + c - 95 + 63;
|
|
5546
|
+
result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
|
|
5547
|
+
result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
|
|
5548
|
+
result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
|
|
5549
|
+
return result;
|
|
5550
|
+
};
|
|
5551
|
+
return URLSafeCoder2;
|
|
5552
|
+
}(Coder)
|
|
5553
|
+
);
|
|
5554
|
+
exports.URLSafeCoder = URLSafeCoder;
|
|
5555
|
+
var urlSafeCoder = new URLSafeCoder();
|
|
5556
|
+
function encodeURLSafe(data) {
|
|
5557
|
+
return urlSafeCoder.encode(data);
|
|
5558
|
+
}
|
|
5559
|
+
exports.encodeURLSafe = encodeURLSafe;
|
|
5560
|
+
function decodeURLSafe(s) {
|
|
5561
|
+
return urlSafeCoder.decode(s);
|
|
5562
|
+
}
|
|
5563
|
+
exports.decodeURLSafe = decodeURLSafe;
|
|
5564
|
+
exports.encodedLength = function(length) {
|
|
5565
|
+
return stdCoder.encodedLength(length);
|
|
5542
5566
|
};
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
base64$1.Coder = Coder;
|
|
5546
|
-
var stdCoder = new Coder();
|
|
5547
|
-
function encode(data) {
|
|
5548
|
-
return stdCoder.encode(data);
|
|
5549
|
-
}
|
|
5550
|
-
base64$1.encode = encode;
|
|
5551
|
-
function decode(s) {
|
|
5552
|
-
return stdCoder.decode(s);
|
|
5553
|
-
}
|
|
5554
|
-
base64$1.decode = decode;
|
|
5555
|
-
/**
|
|
5556
|
-
* Implements URL-safe Base64 encoding.
|
|
5557
|
-
* (Same as Base64, but '+' is replaced with '-', and '/' with '_').
|
|
5558
|
-
*
|
|
5559
|
-
* Operates in constant time.
|
|
5560
|
-
*/
|
|
5561
|
-
var URLSafeCoder = /** @class */ (function (_super) {
|
|
5562
|
-
__extends(URLSafeCoder, _super);
|
|
5563
|
-
function URLSafeCoder() {
|
|
5564
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5565
|
-
}
|
|
5566
|
-
// URL-safe encoding have the following encoded/decoded ranges:
|
|
5567
|
-
//
|
|
5568
|
-
// ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _
|
|
5569
|
-
// Index: 0 - 25 26 - 51 52 - 61 62 63
|
|
5570
|
-
// ASCII: 65 - 90 97 - 122 48 - 57 45 95
|
|
5571
|
-
//
|
|
5572
|
-
URLSafeCoder.prototype._encodeByte = function (b) {
|
|
5573
|
-
var result = b;
|
|
5574
|
-
// b >= 0
|
|
5575
|
-
result += 65;
|
|
5576
|
-
// b > 25
|
|
5577
|
-
result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);
|
|
5578
|
-
// b > 51
|
|
5579
|
-
result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);
|
|
5580
|
-
// b > 61
|
|
5581
|
-
result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);
|
|
5582
|
-
// b > 62
|
|
5583
|
-
result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);
|
|
5584
|
-
return String.fromCharCode(result);
|
|
5567
|
+
exports.maxDecodedLength = function(length) {
|
|
5568
|
+
return stdCoder.maxDecodedLength(length);
|
|
5585
5569
|
};
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
// c == 45 (c > 44 and c < 46)
|
|
5589
|
-
result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);
|
|
5590
|
-
// c == 95 (c > 94 and c < 96)
|
|
5591
|
-
result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);
|
|
5592
|
-
// c > 47 and c < 58
|
|
5593
|
-
result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);
|
|
5594
|
-
// c > 64 and c < 91
|
|
5595
|
-
result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);
|
|
5596
|
-
// c > 96 and c < 123
|
|
5597
|
-
result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);
|
|
5598
|
-
return result;
|
|
5570
|
+
exports.decodedLength = function(s) {
|
|
5571
|
+
return stdCoder.decodedLength(s);
|
|
5599
5572
|
};
|
|
5600
|
-
|
|
5601
|
-
}
|
|
5602
|
-
base64$1.URLSafeCoder = URLSafeCoder;
|
|
5603
|
-
var urlSafeCoder = new URLSafeCoder();
|
|
5604
|
-
function encodeURLSafe(data) {
|
|
5605
|
-
return urlSafeCoder.encode(data);
|
|
5606
|
-
}
|
|
5607
|
-
base64$1.encodeURLSafe = encodeURLSafe;
|
|
5608
|
-
function decodeURLSafe(s) {
|
|
5609
|
-
return urlSafeCoder.decode(s);
|
|
5610
|
-
}
|
|
5611
|
-
base64$1.decodeURLSafe = decodeURLSafe;
|
|
5612
|
-
base64$1.encodedLength = function (length) {
|
|
5613
|
-
return stdCoder.encodedLength(length);
|
|
5614
|
-
};
|
|
5615
|
-
base64$1.maxDecodedLength = function (length) {
|
|
5616
|
-
return stdCoder.maxDecodedLength(length);
|
|
5617
|
-
};
|
|
5618
|
-
base64$1.decodedLength = function (s) {
|
|
5619
|
-
return stdCoder.decodedLength(s);
|
|
5620
|
-
};
|
|
5621
|
-
|
|
5622
|
-
var sha256$1 = {exports: {}};
|
|
5623
|
-
|
|
5624
|
-
(function (module) {
|
|
5625
|
-
(function (root, factory) {
|
|
5626
|
-
// Hack to make all exports of this module sha256 function object properties.
|
|
5627
|
-
var exports = {};
|
|
5628
|
-
factory(exports);
|
|
5629
|
-
var sha256 = exports["default"];
|
|
5630
|
-
for (var k in exports) {
|
|
5631
|
-
sha256[k] = exports[k];
|
|
5632
|
-
}
|
|
5633
|
-
|
|
5634
|
-
{
|
|
5635
|
-
module.exports = sha256;
|
|
5636
|
-
}
|
|
5637
|
-
})(commonjsGlobal, function(exports) {
|
|
5638
|
-
exports.__esModule = true;
|
|
5639
|
-
// SHA-256 (+ HMAC and PBKDF2) for JavaScript.
|
|
5640
|
-
//
|
|
5641
|
-
// Written in 2014-2016 by Dmitry Chestnykh.
|
|
5642
|
-
// Public domain, no warranty.
|
|
5643
|
-
//
|
|
5644
|
-
// Functions (accept and return Uint8Arrays):
|
|
5645
|
-
//
|
|
5646
|
-
// sha256(message) -> hash
|
|
5647
|
-
// sha256.hmac(key, message) -> mac
|
|
5648
|
-
// sha256.pbkdf2(password, salt, rounds, dkLen) -> dk
|
|
5649
|
-
//
|
|
5650
|
-
// Classes:
|
|
5651
|
-
//
|
|
5652
|
-
// new sha256.Hash()
|
|
5653
|
-
// new sha256.HMAC(key)
|
|
5654
|
-
//
|
|
5655
|
-
exports.digestLength = 32;
|
|
5656
|
-
exports.blockSize = 64;
|
|
5657
|
-
// SHA-256 constants
|
|
5658
|
-
var K = new Uint32Array([
|
|
5659
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b,
|
|
5660
|
-
0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,
|
|
5661
|
-
0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,
|
|
5662
|
-
0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
|
|
5663
|
-
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152,
|
|
5664
|
-
0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
|
|
5665
|
-
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
|
|
5666
|
-
0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
5667
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,
|
|
5668
|
-
0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08,
|
|
5669
|
-
0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,
|
|
5670
|
-
0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
5671
|
-
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
5672
|
-
]);
|
|
5673
|
-
function hashBlocks(w, v, p, pos, len) {
|
|
5674
|
-
var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
|
|
5675
|
-
while (len >= 64) {
|
|
5676
|
-
a = v[0];
|
|
5677
|
-
b = v[1];
|
|
5678
|
-
c = v[2];
|
|
5679
|
-
d = v[3];
|
|
5680
|
-
e = v[4];
|
|
5681
|
-
f = v[5];
|
|
5682
|
-
g = v[6];
|
|
5683
|
-
h = v[7];
|
|
5684
|
-
for (i = 0; i < 16; i++) {
|
|
5685
|
-
j = pos + i * 4;
|
|
5686
|
-
w[i] = (((p[j] & 0xff) << 24) | ((p[j + 1] & 0xff) << 16) |
|
|
5687
|
-
((p[j + 2] & 0xff) << 8) | (p[j + 3] & 0xff));
|
|
5688
|
-
}
|
|
5689
|
-
for (i = 16; i < 64; i++) {
|
|
5690
|
-
u = w[i - 2];
|
|
5691
|
-
t1 = (u >>> 17 | u << (32 - 17)) ^ (u >>> 19 | u << (32 - 19)) ^ (u >>> 10);
|
|
5692
|
-
u = w[i - 15];
|
|
5693
|
-
t2 = (u >>> 7 | u << (32 - 7)) ^ (u >>> 18 | u << (32 - 18)) ^ (u >>> 3);
|
|
5694
|
-
w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
|
|
5695
|
-
}
|
|
5696
|
-
for (i = 0; i < 64; i++) {
|
|
5697
|
-
t1 = (((((e >>> 6 | e << (32 - 6)) ^ (e >>> 11 | e << (32 - 11)) ^
|
|
5698
|
-
(e >>> 25 | e << (32 - 25))) + ((e & f) ^ (~e & g))) | 0) +
|
|
5699
|
-
((h + ((K[i] + w[i]) | 0)) | 0)) | 0;
|
|
5700
|
-
t2 = (((a >>> 2 | a << (32 - 2)) ^ (a >>> 13 | a << (32 - 13)) ^
|
|
5701
|
-
(a >>> 22 | a << (32 - 22))) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
|
|
5702
|
-
h = g;
|
|
5703
|
-
g = f;
|
|
5704
|
-
f = e;
|
|
5705
|
-
e = (d + t1) | 0;
|
|
5706
|
-
d = c;
|
|
5707
|
-
c = b;
|
|
5708
|
-
b = a;
|
|
5709
|
-
a = (t1 + t2) | 0;
|
|
5710
|
-
}
|
|
5711
|
-
v[0] += a;
|
|
5712
|
-
v[1] += b;
|
|
5713
|
-
v[2] += c;
|
|
5714
|
-
v[3] += d;
|
|
5715
|
-
v[4] += e;
|
|
5716
|
-
v[5] += f;
|
|
5717
|
-
v[6] += g;
|
|
5718
|
-
v[7] += h;
|
|
5719
|
-
pos += 64;
|
|
5720
|
-
len -= 64;
|
|
5721
|
-
}
|
|
5722
|
-
return pos;
|
|
5723
|
-
}
|
|
5724
|
-
// Hash implements SHA256 hash algorithm.
|
|
5725
|
-
var Hash = /** @class */ (function () {
|
|
5726
|
-
function Hash() {
|
|
5727
|
-
this.digestLength = exports.digestLength;
|
|
5728
|
-
this.blockSize = exports.blockSize;
|
|
5729
|
-
// Note: Int32Array is used instead of Uint32Array for performance reasons.
|
|
5730
|
-
this.state = new Int32Array(8); // hash state
|
|
5731
|
-
this.temp = new Int32Array(64); // temporary state
|
|
5732
|
-
this.buffer = new Uint8Array(128); // buffer for data to hash
|
|
5733
|
-
this.bufferLength = 0; // number of bytes in buffer
|
|
5734
|
-
this.bytesHashed = 0; // number of total bytes hashed
|
|
5735
|
-
this.finished = false; // indicates whether the hash was finalized
|
|
5736
|
-
this.reset();
|
|
5737
|
-
}
|
|
5738
|
-
// Resets hash state making it possible
|
|
5739
|
-
// to re-use this instance to hash other data.
|
|
5740
|
-
Hash.prototype.reset = function () {
|
|
5741
|
-
this.state[0] = 0x6a09e667;
|
|
5742
|
-
this.state[1] = 0xbb67ae85;
|
|
5743
|
-
this.state[2] = 0x3c6ef372;
|
|
5744
|
-
this.state[3] = 0xa54ff53a;
|
|
5745
|
-
this.state[4] = 0x510e527f;
|
|
5746
|
-
this.state[5] = 0x9b05688c;
|
|
5747
|
-
this.state[6] = 0x1f83d9ab;
|
|
5748
|
-
this.state[7] = 0x5be0cd19;
|
|
5749
|
-
this.bufferLength = 0;
|
|
5750
|
-
this.bytesHashed = 0;
|
|
5751
|
-
this.finished = false;
|
|
5752
|
-
return this;
|
|
5753
|
-
};
|
|
5754
|
-
// Cleans internal buffers and re-initializes hash state.
|
|
5755
|
-
Hash.prototype.clean = function () {
|
|
5756
|
-
for (var i = 0; i < this.buffer.length; i++) {
|
|
5757
|
-
this.buffer[i] = 0;
|
|
5758
|
-
}
|
|
5759
|
-
for (var i = 0; i < this.temp.length; i++) {
|
|
5760
|
-
this.temp[i] = 0;
|
|
5761
|
-
}
|
|
5762
|
-
this.reset();
|
|
5763
|
-
};
|
|
5764
|
-
// Updates hash state with the given data.
|
|
5765
|
-
//
|
|
5766
|
-
// Optionally, length of the data can be specified to hash
|
|
5767
|
-
// fewer bytes than data.length.
|
|
5768
|
-
//
|
|
5769
|
-
// Throws error when trying to update already finalized hash:
|
|
5770
|
-
// instance must be reset to use it again.
|
|
5771
|
-
Hash.prototype.update = function (data, dataLength) {
|
|
5772
|
-
if (dataLength === void 0) { dataLength = data.length; }
|
|
5773
|
-
if (this.finished) {
|
|
5774
|
-
throw new Error("SHA256: can't update because hash was finished.");
|
|
5775
|
-
}
|
|
5776
|
-
var dataPos = 0;
|
|
5777
|
-
this.bytesHashed += dataLength;
|
|
5778
|
-
if (this.bufferLength > 0) {
|
|
5779
|
-
while (this.bufferLength < 64 && dataLength > 0) {
|
|
5780
|
-
this.buffer[this.bufferLength++] = data[dataPos++];
|
|
5781
|
-
dataLength--;
|
|
5782
|
-
}
|
|
5783
|
-
if (this.bufferLength === 64) {
|
|
5784
|
-
hashBlocks(this.temp, this.state, this.buffer, 0, 64);
|
|
5785
|
-
this.bufferLength = 0;
|
|
5786
|
-
}
|
|
5787
|
-
}
|
|
5788
|
-
if (dataLength >= 64) {
|
|
5789
|
-
dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
|
|
5790
|
-
dataLength %= 64;
|
|
5791
|
-
}
|
|
5792
|
-
while (dataLength > 0) {
|
|
5793
|
-
this.buffer[this.bufferLength++] = data[dataPos++];
|
|
5794
|
-
dataLength--;
|
|
5795
|
-
}
|
|
5796
|
-
return this;
|
|
5797
|
-
};
|
|
5798
|
-
// Finalizes hash state and puts hash into out.
|
|
5799
|
-
//
|
|
5800
|
-
// If hash was already finalized, puts the same value.
|
|
5801
|
-
Hash.prototype.finish = function (out) {
|
|
5802
|
-
if (!this.finished) {
|
|
5803
|
-
var bytesHashed = this.bytesHashed;
|
|
5804
|
-
var left = this.bufferLength;
|
|
5805
|
-
var bitLenHi = (bytesHashed / 0x20000000) | 0;
|
|
5806
|
-
var bitLenLo = bytesHashed << 3;
|
|
5807
|
-
var padLength = (bytesHashed % 64 < 56) ? 64 : 128;
|
|
5808
|
-
this.buffer[left] = 0x80;
|
|
5809
|
-
for (var i = left + 1; i < padLength - 8; i++) {
|
|
5810
|
-
this.buffer[i] = 0;
|
|
5811
|
-
}
|
|
5812
|
-
this.buffer[padLength - 8] = (bitLenHi >>> 24) & 0xff;
|
|
5813
|
-
this.buffer[padLength - 7] = (bitLenHi >>> 16) & 0xff;
|
|
5814
|
-
this.buffer[padLength - 6] = (bitLenHi >>> 8) & 0xff;
|
|
5815
|
-
this.buffer[padLength - 5] = (bitLenHi >>> 0) & 0xff;
|
|
5816
|
-
this.buffer[padLength - 4] = (bitLenLo >>> 24) & 0xff;
|
|
5817
|
-
this.buffer[padLength - 3] = (bitLenLo >>> 16) & 0xff;
|
|
5818
|
-
this.buffer[padLength - 2] = (bitLenLo >>> 8) & 0xff;
|
|
5819
|
-
this.buffer[padLength - 1] = (bitLenLo >>> 0) & 0xff;
|
|
5820
|
-
hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
|
|
5821
|
-
this.finished = true;
|
|
5822
|
-
}
|
|
5823
|
-
for (var i = 0; i < 8; i++) {
|
|
5824
|
-
out[i * 4 + 0] = (this.state[i] >>> 24) & 0xff;
|
|
5825
|
-
out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;
|
|
5826
|
-
out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;
|
|
5827
|
-
out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;
|
|
5828
|
-
}
|
|
5829
|
-
return this;
|
|
5830
|
-
};
|
|
5831
|
-
// Returns the final hash digest.
|
|
5832
|
-
Hash.prototype.digest = function () {
|
|
5833
|
-
var out = new Uint8Array(this.digestLength);
|
|
5834
|
-
this.finish(out);
|
|
5835
|
-
return out;
|
|
5836
|
-
};
|
|
5837
|
-
// Internal function for use in HMAC for optimization.
|
|
5838
|
-
Hash.prototype._saveState = function (out) {
|
|
5839
|
-
for (var i = 0; i < this.state.length; i++) {
|
|
5840
|
-
out[i] = this.state[i];
|
|
5841
|
-
}
|
|
5842
|
-
};
|
|
5843
|
-
// Internal function for use in HMAC for optimization.
|
|
5844
|
-
Hash.prototype._restoreState = function (from, bytesHashed) {
|
|
5845
|
-
for (var i = 0; i < this.state.length; i++) {
|
|
5846
|
-
this.state[i] = from[i];
|
|
5847
|
-
}
|
|
5848
|
-
this.bytesHashed = bytesHashed;
|
|
5849
|
-
this.finished = false;
|
|
5850
|
-
this.bufferLength = 0;
|
|
5851
|
-
};
|
|
5852
|
-
return Hash;
|
|
5853
|
-
}());
|
|
5854
|
-
exports.Hash = Hash;
|
|
5855
|
-
// HMAC implements HMAC-SHA256 message authentication algorithm.
|
|
5856
|
-
var HMAC = /** @class */ (function () {
|
|
5857
|
-
function HMAC(key) {
|
|
5858
|
-
this.inner = new Hash();
|
|
5859
|
-
this.outer = new Hash();
|
|
5860
|
-
this.blockSize = this.inner.blockSize;
|
|
5861
|
-
this.digestLength = this.inner.digestLength;
|
|
5862
|
-
var pad = new Uint8Array(this.blockSize);
|
|
5863
|
-
if (key.length > this.blockSize) {
|
|
5864
|
-
(new Hash()).update(key).finish(pad).clean();
|
|
5865
|
-
}
|
|
5866
|
-
else {
|
|
5867
|
-
for (var i = 0; i < key.length; i++) {
|
|
5868
|
-
pad[i] = key[i];
|
|
5869
|
-
}
|
|
5870
|
-
}
|
|
5871
|
-
for (var i = 0; i < pad.length; i++) {
|
|
5872
|
-
pad[i] ^= 0x36;
|
|
5873
|
-
}
|
|
5874
|
-
this.inner.update(pad);
|
|
5875
|
-
for (var i = 0; i < pad.length; i++) {
|
|
5876
|
-
pad[i] ^= 0x36 ^ 0x5c;
|
|
5877
|
-
}
|
|
5878
|
-
this.outer.update(pad);
|
|
5879
|
-
this.istate = new Uint32Array(8);
|
|
5880
|
-
this.ostate = new Uint32Array(8);
|
|
5881
|
-
this.inner._saveState(this.istate);
|
|
5882
|
-
this.outer._saveState(this.ostate);
|
|
5883
|
-
for (var i = 0; i < pad.length; i++) {
|
|
5884
|
-
pad[i] = 0;
|
|
5885
|
-
}
|
|
5886
|
-
}
|
|
5887
|
-
// Returns HMAC state to the state initialized with key
|
|
5888
|
-
// to make it possible to run HMAC over the other data with the same
|
|
5889
|
-
// key without creating a new instance.
|
|
5890
|
-
HMAC.prototype.reset = function () {
|
|
5891
|
-
this.inner._restoreState(this.istate, this.inner.blockSize);
|
|
5892
|
-
this.outer._restoreState(this.ostate, this.outer.blockSize);
|
|
5893
|
-
return this;
|
|
5894
|
-
};
|
|
5895
|
-
// Cleans HMAC state.
|
|
5896
|
-
HMAC.prototype.clean = function () {
|
|
5897
|
-
for (var i = 0; i < this.istate.length; i++) {
|
|
5898
|
-
this.ostate[i] = this.istate[i] = 0;
|
|
5899
|
-
}
|
|
5900
|
-
this.inner.clean();
|
|
5901
|
-
this.outer.clean();
|
|
5902
|
-
};
|
|
5903
|
-
// Updates state with provided data.
|
|
5904
|
-
HMAC.prototype.update = function (data) {
|
|
5905
|
-
this.inner.update(data);
|
|
5906
|
-
return this;
|
|
5907
|
-
};
|
|
5908
|
-
// Finalizes HMAC and puts the result in out.
|
|
5909
|
-
HMAC.prototype.finish = function (out) {
|
|
5910
|
-
if (this.outer.finished) {
|
|
5911
|
-
this.outer.finish(out);
|
|
5912
|
-
}
|
|
5913
|
-
else {
|
|
5914
|
-
this.inner.finish(out);
|
|
5915
|
-
this.outer.update(out, this.digestLength).finish(out);
|
|
5916
|
-
}
|
|
5917
|
-
return this;
|
|
5918
|
-
};
|
|
5919
|
-
// Returns message authentication code.
|
|
5920
|
-
HMAC.prototype.digest = function () {
|
|
5921
|
-
var out = new Uint8Array(this.digestLength);
|
|
5922
|
-
this.finish(out);
|
|
5923
|
-
return out;
|
|
5924
|
-
};
|
|
5925
|
-
return HMAC;
|
|
5926
|
-
}());
|
|
5927
|
-
exports.HMAC = HMAC;
|
|
5928
|
-
// Returns SHA256 hash of data.
|
|
5929
|
-
function hash(data) {
|
|
5930
|
-
var h = (new Hash()).update(data);
|
|
5931
|
-
var digest = h.digest();
|
|
5932
|
-
h.clean();
|
|
5933
|
-
return digest;
|
|
5934
|
-
}
|
|
5935
|
-
exports.hash = hash;
|
|
5936
|
-
// Function hash is both available as module.hash and as default export.
|
|
5937
|
-
exports["default"] = hash;
|
|
5938
|
-
// Returns HMAC-SHA256 of data under the key.
|
|
5939
|
-
function hmac(key, data) {
|
|
5940
|
-
var h = (new HMAC(key)).update(data);
|
|
5941
|
-
var digest = h.digest();
|
|
5942
|
-
h.clean();
|
|
5943
|
-
return digest;
|
|
5944
|
-
}
|
|
5945
|
-
exports.hmac = hmac;
|
|
5946
|
-
// Fills hkdf buffer like this:
|
|
5947
|
-
// T(1) = HMAC-Hash(PRK, T(0) | info | 0x01)
|
|
5948
|
-
function fillBuffer(buffer, hmac, info, counter) {
|
|
5949
|
-
// Counter is a byte value: check if it overflowed.
|
|
5950
|
-
var num = counter[0];
|
|
5951
|
-
if (num === 0) {
|
|
5952
|
-
throw new Error("hkdf: cannot expand more");
|
|
5953
|
-
}
|
|
5954
|
-
// Prepare HMAC instance for new data with old key.
|
|
5955
|
-
hmac.reset();
|
|
5956
|
-
// Hash in previous output if it was generated
|
|
5957
|
-
// (i.e. counter is greater than 1).
|
|
5958
|
-
if (num > 1) {
|
|
5959
|
-
hmac.update(buffer);
|
|
5960
|
-
}
|
|
5961
|
-
// Hash in info if it exists.
|
|
5962
|
-
if (info) {
|
|
5963
|
-
hmac.update(info);
|
|
5964
|
-
}
|
|
5965
|
-
// Hash in the counter.
|
|
5966
|
-
hmac.update(counter);
|
|
5967
|
-
// Output result to buffer and clean HMAC instance.
|
|
5968
|
-
hmac.finish(buffer);
|
|
5969
|
-
// Increment counter inside typed array, this works properly.
|
|
5970
|
-
counter[0]++;
|
|
5971
|
-
}
|
|
5972
|
-
var hkdfSalt = new Uint8Array(exports.digestLength); // Filled with zeroes.
|
|
5973
|
-
function hkdf(key, salt, info, length) {
|
|
5974
|
-
if (salt === void 0) { salt = hkdfSalt; }
|
|
5975
|
-
if (length === void 0) { length = 32; }
|
|
5976
|
-
var counter = new Uint8Array([1]);
|
|
5977
|
-
// HKDF-Extract uses salt as HMAC key, and key as data.
|
|
5978
|
-
var okm = hmac(salt, key);
|
|
5979
|
-
// Initialize HMAC for expanding with extracted key.
|
|
5980
|
-
// Ensure no collisions with `hmac` function.
|
|
5981
|
-
var hmac_ = new HMAC(okm);
|
|
5982
|
-
// Allocate buffer.
|
|
5983
|
-
var buffer = new Uint8Array(hmac_.digestLength);
|
|
5984
|
-
var bufpos = buffer.length;
|
|
5985
|
-
var out = new Uint8Array(length);
|
|
5986
|
-
for (var i = 0; i < length; i++) {
|
|
5987
|
-
if (bufpos === buffer.length) {
|
|
5988
|
-
fillBuffer(buffer, hmac_, info, counter);
|
|
5989
|
-
bufpos = 0;
|
|
5990
|
-
}
|
|
5991
|
-
out[i] = buffer[bufpos++];
|
|
5992
|
-
}
|
|
5993
|
-
hmac_.clean();
|
|
5994
|
-
buffer.fill(0);
|
|
5995
|
-
counter.fill(0);
|
|
5996
|
-
return out;
|
|
5997
|
-
}
|
|
5998
|
-
exports.hkdf = hkdf;
|
|
5999
|
-
// Derives a key from password and salt using PBKDF2-HMAC-SHA256
|
|
6000
|
-
// with the given number of iterations.
|
|
6001
|
-
//
|
|
6002
|
-
// The number of bytes returned is equal to dkLen.
|
|
6003
|
-
//
|
|
6004
|
-
// (For better security, avoid dkLen greater than hash length - 32 bytes).
|
|
6005
|
-
function pbkdf2(password, salt, iterations, dkLen) {
|
|
6006
|
-
var prf = new HMAC(password);
|
|
6007
|
-
var len = prf.digestLength;
|
|
6008
|
-
var ctr = new Uint8Array(4);
|
|
6009
|
-
var t = new Uint8Array(len);
|
|
6010
|
-
var u = new Uint8Array(len);
|
|
6011
|
-
var dk = new Uint8Array(dkLen);
|
|
6012
|
-
for (var i = 0; i * len < dkLen; i++) {
|
|
6013
|
-
var c = i + 1;
|
|
6014
|
-
ctr[0] = (c >>> 24) & 0xff;
|
|
6015
|
-
ctr[1] = (c >>> 16) & 0xff;
|
|
6016
|
-
ctr[2] = (c >>> 8) & 0xff;
|
|
6017
|
-
ctr[3] = (c >>> 0) & 0xff;
|
|
6018
|
-
prf.reset();
|
|
6019
|
-
prf.update(salt);
|
|
6020
|
-
prf.update(ctr);
|
|
6021
|
-
prf.finish(u);
|
|
6022
|
-
for (var j = 0; j < len; j++) {
|
|
6023
|
-
t[j] = u[j];
|
|
6024
|
-
}
|
|
6025
|
-
for (var j = 2; j <= iterations; j++) {
|
|
6026
|
-
prf.reset();
|
|
6027
|
-
prf.update(u).finish(u);
|
|
6028
|
-
for (var k = 0; k < len; k++) {
|
|
6029
|
-
t[k] ^= u[k];
|
|
6030
|
-
}
|
|
6031
|
-
}
|
|
6032
|
-
for (var j = 0; j < len && i * len + j < dkLen; j++) {
|
|
6033
|
-
dk[i * len + j] = t[j];
|
|
6034
|
-
}
|
|
6035
|
-
}
|
|
6036
|
-
for (var i = 0; i < len; i++) {
|
|
6037
|
-
t[i] = u[i] = 0;
|
|
6038
|
-
}
|
|
6039
|
-
for (var i = 0; i < 4; i++) {
|
|
6040
|
-
ctr[i] = 0;
|
|
6041
|
-
}
|
|
6042
|
-
prf.clean();
|
|
6043
|
-
return dk;
|
|
6044
|
-
}
|
|
6045
|
-
exports.pbkdf2 = pbkdf2;
|
|
6046
|
-
});
|
|
6047
|
-
} (sha256$1));
|
|
5573
|
+
}
|
|
5574
|
+
});
|
|
6048
5575
|
|
|
6049
|
-
|
|
5576
|
+
// ../../node_modules/fast-sha256/sha256.js
|
|
5577
|
+
var require_sha256 = __commonJS({
|
|
5578
|
+
"../../node_modules/fast-sha256/sha256.js"(exports, module) {
|
|
5579
|
+
(function(root, factory) {
|
|
5580
|
+
var exports2 = {};
|
|
5581
|
+
factory(exports2);
|
|
5582
|
+
var sha2562 = exports2["default"];
|
|
5583
|
+
for (var k in exports2) {
|
|
5584
|
+
sha2562[k] = exports2[k];
|
|
5585
|
+
}
|
|
5586
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
5587
|
+
module.exports = sha2562;
|
|
5588
|
+
} else if (typeof define === "function" && define.amd) {
|
|
5589
|
+
define(function() {
|
|
5590
|
+
return sha2562;
|
|
5591
|
+
});
|
|
5592
|
+
} else {
|
|
5593
|
+
root.sha256 = sha2562;
|
|
5594
|
+
}
|
|
5595
|
+
})(exports, function(exports2) {
|
|
5596
|
+
exports2.__esModule = true;
|
|
5597
|
+
exports2.digestLength = 32;
|
|
5598
|
+
exports2.blockSize = 64;
|
|
5599
|
+
var K = new Uint32Array([
|
|
5600
|
+
1116352408,
|
|
5601
|
+
1899447441,
|
|
5602
|
+
3049323471,
|
|
5603
|
+
3921009573,
|
|
5604
|
+
961987163,
|
|
5605
|
+
1508970993,
|
|
5606
|
+
2453635748,
|
|
5607
|
+
2870763221,
|
|
5608
|
+
3624381080,
|
|
5609
|
+
310598401,
|
|
5610
|
+
607225278,
|
|
5611
|
+
1426881987,
|
|
5612
|
+
1925078388,
|
|
5613
|
+
2162078206,
|
|
5614
|
+
2614888103,
|
|
5615
|
+
3248222580,
|
|
5616
|
+
3835390401,
|
|
5617
|
+
4022224774,
|
|
5618
|
+
264347078,
|
|
5619
|
+
604807628,
|
|
5620
|
+
770255983,
|
|
5621
|
+
1249150122,
|
|
5622
|
+
1555081692,
|
|
5623
|
+
1996064986,
|
|
5624
|
+
2554220882,
|
|
5625
|
+
2821834349,
|
|
5626
|
+
2952996808,
|
|
5627
|
+
3210313671,
|
|
5628
|
+
3336571891,
|
|
5629
|
+
3584528711,
|
|
5630
|
+
113926993,
|
|
5631
|
+
338241895,
|
|
5632
|
+
666307205,
|
|
5633
|
+
773529912,
|
|
5634
|
+
1294757372,
|
|
5635
|
+
1396182291,
|
|
5636
|
+
1695183700,
|
|
5637
|
+
1986661051,
|
|
5638
|
+
2177026350,
|
|
5639
|
+
2456956037,
|
|
5640
|
+
2730485921,
|
|
5641
|
+
2820302411,
|
|
5642
|
+
3259730800,
|
|
5643
|
+
3345764771,
|
|
5644
|
+
3516065817,
|
|
5645
|
+
3600352804,
|
|
5646
|
+
4094571909,
|
|
5647
|
+
275423344,
|
|
5648
|
+
430227734,
|
|
5649
|
+
506948616,
|
|
5650
|
+
659060556,
|
|
5651
|
+
883997877,
|
|
5652
|
+
958139571,
|
|
5653
|
+
1322822218,
|
|
5654
|
+
1537002063,
|
|
5655
|
+
1747873779,
|
|
5656
|
+
1955562222,
|
|
5657
|
+
2024104815,
|
|
5658
|
+
2227730452,
|
|
5659
|
+
2361852424,
|
|
5660
|
+
2428436474,
|
|
5661
|
+
2756734187,
|
|
5662
|
+
3204031479,
|
|
5663
|
+
3329325298
|
|
5664
|
+
]);
|
|
5665
|
+
function hashBlocks(w, v, p, pos, len) {
|
|
5666
|
+
var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
|
|
5667
|
+
while (len >= 64) {
|
|
5668
|
+
a = v[0];
|
|
5669
|
+
b = v[1];
|
|
5670
|
+
c = v[2];
|
|
5671
|
+
d = v[3];
|
|
5672
|
+
e = v[4];
|
|
5673
|
+
f = v[5];
|
|
5674
|
+
g = v[6];
|
|
5675
|
+
h = v[7];
|
|
5676
|
+
for (i = 0; i < 16; i++) {
|
|
5677
|
+
j = pos + i * 4;
|
|
5678
|
+
w[i] = (p[j] & 255) << 24 | (p[j + 1] & 255) << 16 | (p[j + 2] & 255) << 8 | p[j + 3] & 255;
|
|
5679
|
+
}
|
|
5680
|
+
for (i = 16; i < 64; i++) {
|
|
5681
|
+
u = w[i - 2];
|
|
5682
|
+
t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10;
|
|
5683
|
+
u = w[i - 15];
|
|
5684
|
+
t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3;
|
|
5685
|
+
w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
|
|
5686
|
+
}
|
|
5687
|
+
for (i = 0; i < 64; i++) {
|
|
5688
|
+
t1 = (((e >>> 6 | e << 32 - 6) ^ (e >>> 11 | e << 32 - 11) ^ (e >>> 25 | e << 32 - 25)) + (e & f ^ ~e & g) | 0) + (h + (K[i] + w[i] | 0) | 0) | 0;
|
|
5689
|
+
t2 = ((a >>> 2 | a << 32 - 2) ^ (a >>> 13 | a << 32 - 13) ^ (a >>> 22 | a << 32 - 22)) + (a & b ^ a & c ^ b & c) | 0;
|
|
5690
|
+
h = g;
|
|
5691
|
+
g = f;
|
|
5692
|
+
f = e;
|
|
5693
|
+
e = d + t1 | 0;
|
|
5694
|
+
d = c;
|
|
5695
|
+
c = b;
|
|
5696
|
+
b = a;
|
|
5697
|
+
a = t1 + t2 | 0;
|
|
5698
|
+
}
|
|
5699
|
+
v[0] += a;
|
|
5700
|
+
v[1] += b;
|
|
5701
|
+
v[2] += c;
|
|
5702
|
+
v[3] += d;
|
|
5703
|
+
v[4] += e;
|
|
5704
|
+
v[5] += f;
|
|
5705
|
+
v[6] += g;
|
|
5706
|
+
v[7] += h;
|
|
5707
|
+
pos += 64;
|
|
5708
|
+
len -= 64;
|
|
5709
|
+
}
|
|
5710
|
+
return pos;
|
|
5711
|
+
}
|
|
5712
|
+
var Hash = (
|
|
5713
|
+
/** @class */
|
|
5714
|
+
function() {
|
|
5715
|
+
function Hash2() {
|
|
5716
|
+
this.digestLength = exports2.digestLength;
|
|
5717
|
+
this.blockSize = exports2.blockSize;
|
|
5718
|
+
this.state = new Int32Array(8);
|
|
5719
|
+
this.temp = new Int32Array(64);
|
|
5720
|
+
this.buffer = new Uint8Array(128);
|
|
5721
|
+
this.bufferLength = 0;
|
|
5722
|
+
this.bytesHashed = 0;
|
|
5723
|
+
this.finished = false;
|
|
5724
|
+
this.reset();
|
|
5725
|
+
}
|
|
5726
|
+
Hash2.prototype.reset = function() {
|
|
5727
|
+
this.state[0] = 1779033703;
|
|
5728
|
+
this.state[1] = 3144134277;
|
|
5729
|
+
this.state[2] = 1013904242;
|
|
5730
|
+
this.state[3] = 2773480762;
|
|
5731
|
+
this.state[4] = 1359893119;
|
|
5732
|
+
this.state[5] = 2600822924;
|
|
5733
|
+
this.state[6] = 528734635;
|
|
5734
|
+
this.state[7] = 1541459225;
|
|
5735
|
+
this.bufferLength = 0;
|
|
5736
|
+
this.bytesHashed = 0;
|
|
5737
|
+
this.finished = false;
|
|
5738
|
+
return this;
|
|
5739
|
+
};
|
|
5740
|
+
Hash2.prototype.clean = function() {
|
|
5741
|
+
for (var i = 0; i < this.buffer.length; i++) {
|
|
5742
|
+
this.buffer[i] = 0;
|
|
5743
|
+
}
|
|
5744
|
+
for (var i = 0; i < this.temp.length; i++) {
|
|
5745
|
+
this.temp[i] = 0;
|
|
5746
|
+
}
|
|
5747
|
+
this.reset();
|
|
5748
|
+
};
|
|
5749
|
+
Hash2.prototype.update = function(data, dataLength) {
|
|
5750
|
+
if (dataLength === void 0) {
|
|
5751
|
+
dataLength = data.length;
|
|
5752
|
+
}
|
|
5753
|
+
if (this.finished) {
|
|
5754
|
+
throw new Error("SHA256: can't update because hash was finished.");
|
|
5755
|
+
}
|
|
5756
|
+
var dataPos = 0;
|
|
5757
|
+
this.bytesHashed += dataLength;
|
|
5758
|
+
if (this.bufferLength > 0) {
|
|
5759
|
+
while (this.bufferLength < 64 && dataLength > 0) {
|
|
5760
|
+
this.buffer[this.bufferLength++] = data[dataPos++];
|
|
5761
|
+
dataLength--;
|
|
5762
|
+
}
|
|
5763
|
+
if (this.bufferLength === 64) {
|
|
5764
|
+
hashBlocks(this.temp, this.state, this.buffer, 0, 64);
|
|
5765
|
+
this.bufferLength = 0;
|
|
5766
|
+
}
|
|
5767
|
+
}
|
|
5768
|
+
if (dataLength >= 64) {
|
|
5769
|
+
dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
|
|
5770
|
+
dataLength %= 64;
|
|
5771
|
+
}
|
|
5772
|
+
while (dataLength > 0) {
|
|
5773
|
+
this.buffer[this.bufferLength++] = data[dataPos++];
|
|
5774
|
+
dataLength--;
|
|
5775
|
+
}
|
|
5776
|
+
return this;
|
|
5777
|
+
};
|
|
5778
|
+
Hash2.prototype.finish = function(out) {
|
|
5779
|
+
if (!this.finished) {
|
|
5780
|
+
var bytesHashed = this.bytesHashed;
|
|
5781
|
+
var left = this.bufferLength;
|
|
5782
|
+
var bitLenHi = bytesHashed / 536870912 | 0;
|
|
5783
|
+
var bitLenLo = bytesHashed << 3;
|
|
5784
|
+
var padLength = bytesHashed % 64 < 56 ? 64 : 128;
|
|
5785
|
+
this.buffer[left] = 128;
|
|
5786
|
+
for (var i = left + 1; i < padLength - 8; i++) {
|
|
5787
|
+
this.buffer[i] = 0;
|
|
5788
|
+
}
|
|
5789
|
+
this.buffer[padLength - 8] = bitLenHi >>> 24 & 255;
|
|
5790
|
+
this.buffer[padLength - 7] = bitLenHi >>> 16 & 255;
|
|
5791
|
+
this.buffer[padLength - 6] = bitLenHi >>> 8 & 255;
|
|
5792
|
+
this.buffer[padLength - 5] = bitLenHi >>> 0 & 255;
|
|
5793
|
+
this.buffer[padLength - 4] = bitLenLo >>> 24 & 255;
|
|
5794
|
+
this.buffer[padLength - 3] = bitLenLo >>> 16 & 255;
|
|
5795
|
+
this.buffer[padLength - 2] = bitLenLo >>> 8 & 255;
|
|
5796
|
+
this.buffer[padLength - 1] = bitLenLo >>> 0 & 255;
|
|
5797
|
+
hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
|
|
5798
|
+
this.finished = true;
|
|
5799
|
+
}
|
|
5800
|
+
for (var i = 0; i < 8; i++) {
|
|
5801
|
+
out[i * 4 + 0] = this.state[i] >>> 24 & 255;
|
|
5802
|
+
out[i * 4 + 1] = this.state[i] >>> 16 & 255;
|
|
5803
|
+
out[i * 4 + 2] = this.state[i] >>> 8 & 255;
|
|
5804
|
+
out[i * 4 + 3] = this.state[i] >>> 0 & 255;
|
|
5805
|
+
}
|
|
5806
|
+
return this;
|
|
5807
|
+
};
|
|
5808
|
+
Hash2.prototype.digest = function() {
|
|
5809
|
+
var out = new Uint8Array(this.digestLength);
|
|
5810
|
+
this.finish(out);
|
|
5811
|
+
return out;
|
|
5812
|
+
};
|
|
5813
|
+
Hash2.prototype._saveState = function(out) {
|
|
5814
|
+
for (var i = 0; i < this.state.length; i++) {
|
|
5815
|
+
out[i] = this.state[i];
|
|
5816
|
+
}
|
|
5817
|
+
};
|
|
5818
|
+
Hash2.prototype._restoreState = function(from, bytesHashed) {
|
|
5819
|
+
for (var i = 0; i < this.state.length; i++) {
|
|
5820
|
+
this.state[i] = from[i];
|
|
5821
|
+
}
|
|
5822
|
+
this.bytesHashed = bytesHashed;
|
|
5823
|
+
this.finished = false;
|
|
5824
|
+
this.bufferLength = 0;
|
|
5825
|
+
};
|
|
5826
|
+
return Hash2;
|
|
5827
|
+
}()
|
|
5828
|
+
);
|
|
5829
|
+
exports2.Hash = Hash;
|
|
5830
|
+
var HMAC = (
|
|
5831
|
+
/** @class */
|
|
5832
|
+
function() {
|
|
5833
|
+
function HMAC2(key) {
|
|
5834
|
+
this.inner = new Hash();
|
|
5835
|
+
this.outer = new Hash();
|
|
5836
|
+
this.blockSize = this.inner.blockSize;
|
|
5837
|
+
this.digestLength = this.inner.digestLength;
|
|
5838
|
+
var pad = new Uint8Array(this.blockSize);
|
|
5839
|
+
if (key.length > this.blockSize) {
|
|
5840
|
+
new Hash().update(key).finish(pad).clean();
|
|
5841
|
+
} else {
|
|
5842
|
+
for (var i = 0; i < key.length; i++) {
|
|
5843
|
+
pad[i] = key[i];
|
|
5844
|
+
}
|
|
5845
|
+
}
|
|
5846
|
+
for (var i = 0; i < pad.length; i++) {
|
|
5847
|
+
pad[i] ^= 54;
|
|
5848
|
+
}
|
|
5849
|
+
this.inner.update(pad);
|
|
5850
|
+
for (var i = 0; i < pad.length; i++) {
|
|
5851
|
+
pad[i] ^= 54 ^ 92;
|
|
5852
|
+
}
|
|
5853
|
+
this.outer.update(pad);
|
|
5854
|
+
this.istate = new Uint32Array(8);
|
|
5855
|
+
this.ostate = new Uint32Array(8);
|
|
5856
|
+
this.inner._saveState(this.istate);
|
|
5857
|
+
this.outer._saveState(this.ostate);
|
|
5858
|
+
for (var i = 0; i < pad.length; i++) {
|
|
5859
|
+
pad[i] = 0;
|
|
5860
|
+
}
|
|
5861
|
+
}
|
|
5862
|
+
HMAC2.prototype.reset = function() {
|
|
5863
|
+
this.inner._restoreState(this.istate, this.inner.blockSize);
|
|
5864
|
+
this.outer._restoreState(this.ostate, this.outer.blockSize);
|
|
5865
|
+
return this;
|
|
5866
|
+
};
|
|
5867
|
+
HMAC2.prototype.clean = function() {
|
|
5868
|
+
for (var i = 0; i < this.istate.length; i++) {
|
|
5869
|
+
this.ostate[i] = this.istate[i] = 0;
|
|
5870
|
+
}
|
|
5871
|
+
this.inner.clean();
|
|
5872
|
+
this.outer.clean();
|
|
5873
|
+
};
|
|
5874
|
+
HMAC2.prototype.update = function(data) {
|
|
5875
|
+
this.inner.update(data);
|
|
5876
|
+
return this;
|
|
5877
|
+
};
|
|
5878
|
+
HMAC2.prototype.finish = function(out) {
|
|
5879
|
+
if (this.outer.finished) {
|
|
5880
|
+
this.outer.finish(out);
|
|
5881
|
+
} else {
|
|
5882
|
+
this.inner.finish(out);
|
|
5883
|
+
this.outer.update(out, this.digestLength).finish(out);
|
|
5884
|
+
}
|
|
5885
|
+
return this;
|
|
5886
|
+
};
|
|
5887
|
+
HMAC2.prototype.digest = function() {
|
|
5888
|
+
var out = new Uint8Array(this.digestLength);
|
|
5889
|
+
this.finish(out);
|
|
5890
|
+
return out;
|
|
5891
|
+
};
|
|
5892
|
+
return HMAC2;
|
|
5893
|
+
}()
|
|
5894
|
+
);
|
|
5895
|
+
exports2.HMAC = HMAC;
|
|
5896
|
+
function hash(data) {
|
|
5897
|
+
var h = new Hash().update(data);
|
|
5898
|
+
var digest = h.digest();
|
|
5899
|
+
h.clean();
|
|
5900
|
+
return digest;
|
|
5901
|
+
}
|
|
5902
|
+
exports2.hash = hash;
|
|
5903
|
+
exports2["default"] = hash;
|
|
5904
|
+
function hmac2(key, data) {
|
|
5905
|
+
var h = new HMAC(key).update(data);
|
|
5906
|
+
var digest = h.digest();
|
|
5907
|
+
h.clean();
|
|
5908
|
+
return digest;
|
|
5909
|
+
}
|
|
5910
|
+
exports2.hmac = hmac2;
|
|
5911
|
+
function fillBuffer(buffer, hmac3, info, counter) {
|
|
5912
|
+
var num = counter[0];
|
|
5913
|
+
if (num === 0) {
|
|
5914
|
+
throw new Error("hkdf: cannot expand more");
|
|
5915
|
+
}
|
|
5916
|
+
hmac3.reset();
|
|
5917
|
+
if (num > 1) {
|
|
5918
|
+
hmac3.update(buffer);
|
|
5919
|
+
}
|
|
5920
|
+
if (info) {
|
|
5921
|
+
hmac3.update(info);
|
|
5922
|
+
}
|
|
5923
|
+
hmac3.update(counter);
|
|
5924
|
+
hmac3.finish(buffer);
|
|
5925
|
+
counter[0]++;
|
|
5926
|
+
}
|
|
5927
|
+
var hkdfSalt = new Uint8Array(exports2.digestLength);
|
|
5928
|
+
function hkdf(key, salt, info, length) {
|
|
5929
|
+
if (salt === void 0) {
|
|
5930
|
+
salt = hkdfSalt;
|
|
5931
|
+
}
|
|
5932
|
+
if (length === void 0) {
|
|
5933
|
+
length = 32;
|
|
5934
|
+
}
|
|
5935
|
+
var counter = new Uint8Array([1]);
|
|
5936
|
+
var okm = hmac2(salt, key);
|
|
5937
|
+
var hmac_ = new HMAC(okm);
|
|
5938
|
+
var buffer = new Uint8Array(hmac_.digestLength);
|
|
5939
|
+
var bufpos = buffer.length;
|
|
5940
|
+
var out = new Uint8Array(length);
|
|
5941
|
+
for (var i = 0; i < length; i++) {
|
|
5942
|
+
if (bufpos === buffer.length) {
|
|
5943
|
+
fillBuffer(buffer, hmac_, info, counter);
|
|
5944
|
+
bufpos = 0;
|
|
5945
|
+
}
|
|
5946
|
+
out[i] = buffer[bufpos++];
|
|
5947
|
+
}
|
|
5948
|
+
hmac_.clean();
|
|
5949
|
+
buffer.fill(0);
|
|
5950
|
+
counter.fill(0);
|
|
5951
|
+
return out;
|
|
5952
|
+
}
|
|
5953
|
+
exports2.hkdf = hkdf;
|
|
5954
|
+
function pbkdf2(password, salt, iterations, dkLen) {
|
|
5955
|
+
var prf = new HMAC(password);
|
|
5956
|
+
var len = prf.digestLength;
|
|
5957
|
+
var ctr = new Uint8Array(4);
|
|
5958
|
+
var t = new Uint8Array(len);
|
|
5959
|
+
var u = new Uint8Array(len);
|
|
5960
|
+
var dk = new Uint8Array(dkLen);
|
|
5961
|
+
for (var i = 0; i * len < dkLen; i++) {
|
|
5962
|
+
var c = i + 1;
|
|
5963
|
+
ctr[0] = c >>> 24 & 255;
|
|
5964
|
+
ctr[1] = c >>> 16 & 255;
|
|
5965
|
+
ctr[2] = c >>> 8 & 255;
|
|
5966
|
+
ctr[3] = c >>> 0 & 255;
|
|
5967
|
+
prf.reset();
|
|
5968
|
+
prf.update(salt);
|
|
5969
|
+
prf.update(ctr);
|
|
5970
|
+
prf.finish(u);
|
|
5971
|
+
for (var j = 0; j < len; j++) {
|
|
5972
|
+
t[j] = u[j];
|
|
5973
|
+
}
|
|
5974
|
+
for (var j = 2; j <= iterations; j++) {
|
|
5975
|
+
prf.reset();
|
|
5976
|
+
prf.update(u).finish(u);
|
|
5977
|
+
for (var k = 0; k < len; k++) {
|
|
5978
|
+
t[k] ^= u[k];
|
|
5979
|
+
}
|
|
5980
|
+
}
|
|
5981
|
+
for (var j = 0; j < len && i * len + j < dkLen; j++) {
|
|
5982
|
+
dk[i * len + j] = t[j];
|
|
5983
|
+
}
|
|
5984
|
+
}
|
|
5985
|
+
for (var i = 0; i < len; i++) {
|
|
5986
|
+
t[i] = u[i] = 0;
|
|
5987
|
+
}
|
|
5988
|
+
for (var i = 0; i < 4; i++) {
|
|
5989
|
+
ctr[i] = 0;
|
|
5990
|
+
}
|
|
5991
|
+
prf.clean();
|
|
5992
|
+
return dk;
|
|
5993
|
+
}
|
|
5994
|
+
exports2.pbkdf2 = pbkdf2;
|
|
5995
|
+
});
|
|
5996
|
+
}
|
|
5997
|
+
});
|
|
6050
5998
|
|
|
6051
|
-
|
|
6052
|
-
var
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
5999
|
+
// src/webhook/vendor/standardwebhook.ts
|
|
6000
|
+
var base64 = __toESM(require_base64());
|
|
6001
|
+
var sha256 = __toESM(require_sha256());
|
|
6002
|
+
var WEBHOOK_TOLERANCE_IN_SECONDS = 5 * 60;
|
|
6003
|
+
var ExtendableError = class _ExtendableError extends Error {
|
|
6004
|
+
constructor(message) {
|
|
6005
|
+
super(message);
|
|
6006
|
+
Object.setPrototypeOf(this, _ExtendableError.prototype);
|
|
6007
|
+
this.name = "ExtendableError";
|
|
6008
|
+
this.stack = new Error(message).stack;
|
|
6009
|
+
}
|
|
6010
|
+
};
|
|
6011
|
+
var WebhookVerificationError = class _WebhookVerificationError extends ExtendableError {
|
|
6012
|
+
constructor(message) {
|
|
6013
|
+
super(message);
|
|
6014
|
+
Object.setPrototypeOf(this, _WebhookVerificationError.prototype);
|
|
6015
|
+
this.name = "WebhookVerificationError";
|
|
6016
|
+
}
|
|
6017
|
+
};
|
|
6018
|
+
var Webhook = class _Webhook {
|
|
6019
|
+
static prefix = "whsec_";
|
|
6020
|
+
key;
|
|
6021
|
+
constructor(secret, options) {
|
|
6022
|
+
if (!secret) {
|
|
6023
|
+
throw new Error("Secret can't be empty.");
|
|
6024
|
+
}
|
|
6025
|
+
if ((options == null ? void 0 : options.format) === "raw") {
|
|
6026
|
+
if (secret instanceof Uint8Array) {
|
|
6027
|
+
this.key = secret;
|
|
6028
|
+
} else {
|
|
6029
|
+
this.key = Uint8Array.from(secret, (c) => c.charCodeAt(0));
|
|
6030
|
+
}
|
|
6031
|
+
} else {
|
|
6032
|
+
if (typeof secret !== "string") {
|
|
6033
|
+
throw new Error("Expected secret to be of type string");
|
|
6034
|
+
}
|
|
6035
|
+
if (secret.startsWith(_Webhook.prefix)) {
|
|
6036
|
+
secret = secret.substring(_Webhook.prefix.length);
|
|
6037
|
+
}
|
|
6038
|
+
this.key = base64.decode(secret);
|
|
6063
6039
|
}
|
|
6064
|
-
}
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6040
|
+
}
|
|
6041
|
+
verify(payload, headers_) {
|
|
6042
|
+
const headers = {};
|
|
6043
|
+
for (const key of Object.keys(headers_)) {
|
|
6044
|
+
headers[key.toLowerCase()] = headers_[key];
|
|
6045
|
+
}
|
|
6046
|
+
const msgId = headers["webhook-id"];
|
|
6047
|
+
const msgSignature = headers["webhook-signature"];
|
|
6048
|
+
const msgTimestamp = headers["webhook-timestamp"];
|
|
6049
|
+
if (!msgSignature || !msgId || !msgTimestamp) {
|
|
6050
|
+
throw new WebhookVerificationError("Missing required headers");
|
|
6051
|
+
}
|
|
6052
|
+
const timestamp = this.verifyTimestamp(msgTimestamp);
|
|
6053
|
+
const computedSignature = this.sign(msgId, timestamp, payload);
|
|
6054
|
+
const expectedSignature = computedSignature.split(",")[1];
|
|
6055
|
+
const passedSignatures = msgSignature.split(" ");
|
|
6056
|
+
const encoder = new globalThis.TextEncoder();
|
|
6057
|
+
for (const versionedSignature of passedSignatures) {
|
|
6058
|
+
const [version, signature] = versionedSignature.split(",");
|
|
6059
|
+
if (version !== "v1") {
|
|
6060
|
+
continue;
|
|
6061
|
+
}
|
|
6062
|
+
if (timingSafeEqual(
|
|
6063
|
+
encoder.encode(signature),
|
|
6064
|
+
encoder.encode(expectedSignature)
|
|
6065
|
+
)) {
|
|
6066
|
+
return JSON.parse(payload.toString());
|
|
6067
|
+
}
|
|
6070
6068
|
}
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
if ((options === null || options === void 0 ? void 0 : options.format) === "raw") {
|
|
6079
|
-
if (secret instanceof Uint8Array) {
|
|
6080
|
-
this.key = secret;
|
|
6081
|
-
}
|
|
6082
|
-
else {
|
|
6083
|
-
this.key = Uint8Array.from(secret, (c) => c.charCodeAt(0));
|
|
6084
|
-
}
|
|
6085
|
-
}
|
|
6086
|
-
else {
|
|
6087
|
-
if (typeof secret !== "string") {
|
|
6088
|
-
throw new Error("Expected secret to be of type string");
|
|
6089
|
-
}
|
|
6090
|
-
if (secret.startsWith(Webhook.prefix)) {
|
|
6091
|
-
secret = secret.substring(Webhook.prefix.length);
|
|
6092
|
-
}
|
|
6093
|
-
this.key = base64.decode(secret);
|
|
6094
|
-
}
|
|
6069
|
+
throw new WebhookVerificationError("No matching signature found");
|
|
6070
|
+
}
|
|
6071
|
+
sign(msgId, timestamp, payload) {
|
|
6072
|
+
if (typeof payload === "string") ; else if (payload.constructor.name === "Buffer") {
|
|
6073
|
+
payload = payload.toString();
|
|
6074
|
+
} else {
|
|
6075
|
+
throw new Error("Expected payload to be of type string or Buffer.");
|
|
6095
6076
|
}
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
const timestamp = this.verifyTimestamp(msgTimestamp);
|
|
6108
|
-
const computedSignature = this.sign(msgId, timestamp, payload);
|
|
6109
|
-
const expectedSignature = computedSignature.split(",")[1];
|
|
6110
|
-
const passedSignatures = msgSignature.split(" ");
|
|
6111
|
-
const encoder = new globalThis.TextEncoder();
|
|
6112
|
-
for (const versionedSignature of passedSignatures) {
|
|
6113
|
-
const [version, signature] = versionedSignature.split(",");
|
|
6114
|
-
if (version !== "v1") {
|
|
6115
|
-
continue;
|
|
6116
|
-
}
|
|
6117
|
-
if ((0, timing_safe_equal_1.timingSafeEqual)(encoder.encode(signature), encoder.encode(expectedSignature))) {
|
|
6118
|
-
return JSON.parse(payload.toString());
|
|
6119
|
-
}
|
|
6120
|
-
}
|
|
6121
|
-
throw new WebhookVerificationError("No matching signature found");
|
|
6077
|
+
const encoder = new TextEncoder();
|
|
6078
|
+
const timestampNumber = Math.floor(timestamp.getTime() / 1e3);
|
|
6079
|
+
const toSign = encoder.encode(`${msgId}.${timestampNumber}.${payload}`);
|
|
6080
|
+
const expectedSignature = base64.encode(sha256.hmac(this.key, toSign));
|
|
6081
|
+
return `v1,${expectedSignature}`;
|
|
6082
|
+
}
|
|
6083
|
+
verifyTimestamp(timestampHeader) {
|
|
6084
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
6085
|
+
const timestamp = parseInt(timestampHeader, 10);
|
|
6086
|
+
if (isNaN(timestamp)) {
|
|
6087
|
+
throw new WebhookVerificationError("Invalid Signature Headers");
|
|
6122
6088
|
}
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
else if (payload.constructor.name === "Buffer") {
|
|
6126
|
-
payload = payload.toString();
|
|
6127
|
-
}
|
|
6128
|
-
else {
|
|
6129
|
-
throw new Error("Expected payload to be of type string or Buffer.");
|
|
6130
|
-
}
|
|
6131
|
-
const encoder = new TextEncoder();
|
|
6132
|
-
const timestampNumber = Math.floor(timestamp.getTime() / 1000);
|
|
6133
|
-
const toSign = encoder.encode(`${msgId}.${timestampNumber}.${payload}`);
|
|
6134
|
-
const expectedSignature = base64.encode(sha256.hmac(this.key, toSign));
|
|
6135
|
-
return `v1,${expectedSignature}`;
|
|
6089
|
+
if (now - timestamp > WEBHOOK_TOLERANCE_IN_SECONDS) {
|
|
6090
|
+
throw new WebhookVerificationError("Message timestamp too old");
|
|
6136
6091
|
}
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
const timestamp = parseInt(timestampHeader, 10);
|
|
6140
|
-
if (isNaN(timestamp)) {
|
|
6141
|
-
throw new WebhookVerificationError("Invalid Signature Headers");
|
|
6142
|
-
}
|
|
6143
|
-
if (now - timestamp > WEBHOOK_TOLERANCE_IN_SECONDS) {
|
|
6144
|
-
throw new WebhookVerificationError("Message timestamp too old");
|
|
6145
|
-
}
|
|
6146
|
-
if (timestamp > now + WEBHOOK_TOLERANCE_IN_SECONDS) {
|
|
6147
|
-
throw new WebhookVerificationError("Message timestamp too new");
|
|
6148
|
-
}
|
|
6149
|
-
return new Date(timestamp * 1000);
|
|
6092
|
+
if (timestamp > now + WEBHOOK_TOLERANCE_IN_SECONDS) {
|
|
6093
|
+
throw new WebhookVerificationError("Message timestamp too new");
|
|
6150
6094
|
}
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6095
|
+
return new Date(timestamp * 1e3);
|
|
6096
|
+
}
|
|
6097
|
+
};
|
|
6098
|
+
/**
|
|
6099
|
+
* The MIT License
|
|
6100
|
+
*
|
|
6101
|
+
* Copyright (c) 2023 Svix (https://www.svix.com)
|
|
6102
|
+
*
|
|
6103
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6104
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6105
|
+
* in the Software without restriction, including without limitation the rights
|
|
6106
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
6107
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
6108
|
+
* furnished to do so, subject to the following conditions:
|
|
6109
|
+
*
|
|
6110
|
+
* The above copyright notice and this permission notice shall be included in
|
|
6111
|
+
* all copies or substantial portions of the Software.
|
|
6112
|
+
*
|
|
6113
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
6114
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
6115
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
6116
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
6117
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
6118
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
6119
|
+
* THE SOFTWARE.
|
|
6120
|
+
*
|
|
6121
|
+
* @fileoverview Server-only webhook verification implementation.
|
|
6122
|
+
* @description Vendored from standardwebhooks package to avoid bundling issues.
|
|
6123
|
+
* Uses Node.js crypto module - DO NOT import in client/browser code.
|
|
6124
|
+
* @license MIT
|
|
6125
|
+
* @internal
|
|
6126
|
+
*/
|
|
6154
6127
|
|
|
6128
|
+
// src/webhook/webhook.ts
|
|
6155
6129
|
async function handleWebhookPayload(payload, config, context) {
|
|
6156
6130
|
const callHandler = (handler, payload2) => {
|
|
6157
6131
|
if (!handler) return;
|
|
@@ -6226,6 +6200,9 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
6226
6200
|
if (payload.type === "subscription.expired") {
|
|
6227
6201
|
await callHandler(config.onSubscriptionExpired, payload);
|
|
6228
6202
|
}
|
|
6203
|
+
if (payload.type === "subscription.updated") {
|
|
6204
|
+
await callHandler(config.onSubscriptionUpdated, payload);
|
|
6205
|
+
}
|
|
6229
6206
|
if (payload.type === "license_key.created") {
|
|
6230
6207
|
await callHandler(config.onLicenseKeyCreated, payload);
|
|
6231
6208
|
}
|
|
@@ -6235,11 +6212,11 @@ var verifyWebhookPayload = async ({
|
|
|
6235
6212
|
headers,
|
|
6236
6213
|
body
|
|
6237
6214
|
}) => {
|
|
6238
|
-
const standardWebhook = new
|
|
6215
|
+
const standardWebhook = new Webhook(webhookKey);
|
|
6239
6216
|
try {
|
|
6240
6217
|
standardWebhook.verify(body, headers);
|
|
6241
6218
|
} catch (e) {
|
|
6242
|
-
if (e instanceof
|
|
6219
|
+
if (e instanceof WebhookVerificationError) {
|
|
6243
6220
|
throw new Error(e.message);
|
|
6244
6221
|
}
|
|
6245
6222
|
throw e;
|