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