@dodopayments/nextjs 0.3.2 → 0.3.3

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.cjs CHANGED
@@ -1175,23 +1175,23 @@ var error = {};
1175
1175
 
1176
1176
  var cookies$1 = {};
1177
1177
 
1178
- var __defProp = Object.defineProperty;
1179
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1180
- var __getOwnPropNames = Object.getOwnPropertyNames;
1181
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1178
+ var __defProp$1 = Object.defineProperty;
1179
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
1180
+ var __getOwnPropNames$1 = Object.getOwnPropertyNames;
1181
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1182
1182
  var __export = (target, all) => {
1183
1183
  for (var name in all)
1184
- __defProp(target, name, { get: all[name], enumerable: true });
1184
+ __defProp$1(target, name, { get: all[name], enumerable: true });
1185
1185
  };
1186
- var __copyProps = (to, from, except, desc) => {
1186
+ var __copyProps$1 = (to, from, except, desc) => {
1187
1187
  if (from && typeof from === "object" || typeof from === "function") {
1188
- for (let key of __getOwnPropNames(from))
1189
- if (!__hasOwnProp.call(to, key) && key !== except)
1190
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1188
+ for (let key of __getOwnPropNames$1(from))
1189
+ if (!__hasOwnProp$1.call(to, key) && key !== except)
1190
+ __defProp$1(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc$1(from, key)) || desc.enumerable });
1191
1191
  }
1192
1192
  return to;
1193
1193
  };
1194
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1194
+ var __toCommonJS = (mod) => __copyProps$1(__defProp$1({}, "__esModule", { value: true }), mod);
1195
1195
 
1196
1196
  // src/index.ts
1197
1197
  var src_exports = {};
@@ -13153,6 +13153,32 @@ var buildCheckoutUrl = async ({
13153
13153
  }
13154
13154
  };
13155
13155
 
13156
+ var __create = Object.create;
13157
+ var __defProp = Object.defineProperty;
13158
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13159
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13160
+ var __getProtoOf = Object.getPrototypeOf;
13161
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13162
+ var __commonJS = (cb, mod) => function __require2() {
13163
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13164
+ };
13165
+ var __copyProps = (to, from, except, desc) => {
13166
+ if (from && typeof from === "object" || typeof from === "function") {
13167
+ for (let key of __getOwnPropNames(from))
13168
+ if (!__hasOwnProp.call(to, key) && key !== except)
13169
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13170
+ }
13171
+ return to;
13172
+ };
13173
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
13174
+ // If the importer is in node compatibility mode or this is not an ESM
13175
+ // file that has been converted to a CommonJS file using a Babel-
13176
+ // compatible transform (i.e. "__esModule" has not been set), then set
13177
+ // "default" to the CommonJS "module.exports" for node compatibility.
13178
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
13179
+ mod
13180
+ ));
13181
+
13156
13182
  const Checkout = (config) => {
13157
13183
  const getHandler = async (req) => {
13158
13184
  const { searchParams } = new URL(req.url);
@@ -13590,6 +13616,675 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
13590
13616
  LicenseKeyCreatedPayloadSchema
13591
13617
  ]);
13592
13618
 
13619
+ // ../../node_modules/@stablelib/base64/lib/base64.js
13620
+ var require_base64 = __commonJS({
13621
+ "../../node_modules/@stablelib/base64/lib/base64.js"(exports) {
13622
+ var __extends = exports && exports.__extends || /* @__PURE__ */ function() {
13623
+ var extendStatics = function(d, b) {
13624
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
13625
+ d2.__proto__ = b2;
13626
+ } || function(d2, b2) {
13627
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
13628
+ };
13629
+ return extendStatics(d, b);
13630
+ };
13631
+ return function(d, b) {
13632
+ extendStatics(d, b);
13633
+ function __() {
13634
+ this.constructor = d;
13635
+ }
13636
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13637
+ };
13638
+ }();
13639
+ Object.defineProperty(exports, "__esModule", { value: true });
13640
+ var INVALID_BYTE = 256;
13641
+ var Coder = (
13642
+ /** @class */
13643
+ function() {
13644
+ function Coder2(_paddingCharacter) {
13645
+ if (_paddingCharacter === void 0) {
13646
+ _paddingCharacter = "=";
13647
+ }
13648
+ this._paddingCharacter = _paddingCharacter;
13649
+ }
13650
+ Coder2.prototype.encodedLength = function(length) {
13651
+ if (!this._paddingCharacter) {
13652
+ return (length * 8 + 5) / 6 | 0;
13653
+ }
13654
+ return (length + 2) / 3 * 4 | 0;
13655
+ };
13656
+ Coder2.prototype.encode = function(data) {
13657
+ var out = "";
13658
+ var i = 0;
13659
+ for (; i < data.length - 2; i += 3) {
13660
+ var c = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
13661
+ out += this._encodeByte(c >>> 3 * 6 & 63);
13662
+ out += this._encodeByte(c >>> 2 * 6 & 63);
13663
+ out += this._encodeByte(c >>> 1 * 6 & 63);
13664
+ out += this._encodeByte(c >>> 0 * 6 & 63);
13665
+ }
13666
+ var left = data.length - i;
13667
+ if (left > 0) {
13668
+ var c = data[i] << 16 | (left === 2 ? data[i + 1] << 8 : 0);
13669
+ out += this._encodeByte(c >>> 3 * 6 & 63);
13670
+ out += this._encodeByte(c >>> 2 * 6 & 63);
13671
+ if (left === 2) {
13672
+ out += this._encodeByte(c >>> 1 * 6 & 63);
13673
+ } else {
13674
+ out += this._paddingCharacter || "";
13675
+ }
13676
+ out += this._paddingCharacter || "";
13677
+ }
13678
+ return out;
13679
+ };
13680
+ Coder2.prototype.maxDecodedLength = function(length) {
13681
+ if (!this._paddingCharacter) {
13682
+ return (length * 6 + 7) / 8 | 0;
13683
+ }
13684
+ return length / 4 * 3 | 0;
13685
+ };
13686
+ Coder2.prototype.decodedLength = function(s) {
13687
+ return this.maxDecodedLength(s.length - this._getPaddingLength(s));
13688
+ };
13689
+ Coder2.prototype.decode = function(s) {
13690
+ if (s.length === 0) {
13691
+ return new Uint8Array(0);
13692
+ }
13693
+ var paddingLength = this._getPaddingLength(s);
13694
+ var length = s.length - paddingLength;
13695
+ var out = new Uint8Array(this.maxDecodedLength(length));
13696
+ var op = 0;
13697
+ var i = 0;
13698
+ var haveBad = 0;
13699
+ var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
13700
+ for (; i < length - 4; i += 4) {
13701
+ v0 = this._decodeChar(s.charCodeAt(i + 0));
13702
+ v1 = this._decodeChar(s.charCodeAt(i + 1));
13703
+ v2 = this._decodeChar(s.charCodeAt(i + 2));
13704
+ v3 = this._decodeChar(s.charCodeAt(i + 3));
13705
+ out[op++] = v0 << 2 | v1 >>> 4;
13706
+ out[op++] = v1 << 4 | v2 >>> 2;
13707
+ out[op++] = v2 << 6 | v3;
13708
+ haveBad |= v0 & INVALID_BYTE;
13709
+ haveBad |= v1 & INVALID_BYTE;
13710
+ haveBad |= v2 & INVALID_BYTE;
13711
+ haveBad |= v3 & INVALID_BYTE;
13712
+ }
13713
+ if (i < length - 1) {
13714
+ v0 = this._decodeChar(s.charCodeAt(i));
13715
+ v1 = this._decodeChar(s.charCodeAt(i + 1));
13716
+ out[op++] = v0 << 2 | v1 >>> 4;
13717
+ haveBad |= v0 & INVALID_BYTE;
13718
+ haveBad |= v1 & INVALID_BYTE;
13719
+ }
13720
+ if (i < length - 2) {
13721
+ v2 = this._decodeChar(s.charCodeAt(i + 2));
13722
+ out[op++] = v1 << 4 | v2 >>> 2;
13723
+ haveBad |= v2 & INVALID_BYTE;
13724
+ }
13725
+ if (i < length - 3) {
13726
+ v3 = this._decodeChar(s.charCodeAt(i + 3));
13727
+ out[op++] = v2 << 6 | v3;
13728
+ haveBad |= v3 & INVALID_BYTE;
13729
+ }
13730
+ if (haveBad !== 0) {
13731
+ throw new Error("Base64Coder: incorrect characters for decoding");
13732
+ }
13733
+ return out;
13734
+ };
13735
+ Coder2.prototype._encodeByte = function(b) {
13736
+ var result = b;
13737
+ result += 65;
13738
+ result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
13739
+ result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
13740
+ result += 61 - b >>> 8 & 52 - 48 - 62 + 43;
13741
+ result += 62 - b >>> 8 & 62 - 43 - 63 + 47;
13742
+ return String.fromCharCode(result);
13743
+ };
13744
+ Coder2.prototype._decodeChar = function(c) {
13745
+ var result = INVALID_BYTE;
13746
+ result += (42 - c & c - 44) >>> 8 & -INVALID_BYTE + c - 43 + 62;
13747
+ result += (46 - c & c - 48) >>> 8 & -INVALID_BYTE + c - 47 + 63;
13748
+ result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
13749
+ result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
13750
+ result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
13751
+ return result;
13752
+ };
13753
+ Coder2.prototype._getPaddingLength = function(s) {
13754
+ var paddingLength = 0;
13755
+ if (this._paddingCharacter) {
13756
+ for (var i = s.length - 1; i >= 0; i--) {
13757
+ if (s[i] !== this._paddingCharacter) {
13758
+ break;
13759
+ }
13760
+ paddingLength++;
13761
+ }
13762
+ if (s.length < 4 || paddingLength > 2) {
13763
+ throw new Error("Base64Coder: incorrect padding");
13764
+ }
13765
+ }
13766
+ return paddingLength;
13767
+ };
13768
+ return Coder2;
13769
+ }()
13770
+ );
13771
+ exports.Coder = Coder;
13772
+ var stdCoder = new Coder();
13773
+ function encode2(data) {
13774
+ return stdCoder.encode(data);
13775
+ }
13776
+ exports.encode = encode2;
13777
+ function decode2(s) {
13778
+ return stdCoder.decode(s);
13779
+ }
13780
+ exports.decode = decode2;
13781
+ var URLSafeCoder = (
13782
+ /** @class */
13783
+ function(_super) {
13784
+ __extends(URLSafeCoder2, _super);
13785
+ function URLSafeCoder2() {
13786
+ return _super !== null && _super.apply(this, arguments) || this;
13787
+ }
13788
+ URLSafeCoder2.prototype._encodeByte = function(b) {
13789
+ var result = b;
13790
+ result += 65;
13791
+ result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
13792
+ result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
13793
+ result += 61 - b >>> 8 & 52 - 48 - 62 + 45;
13794
+ result += 62 - b >>> 8 & 62 - 45 - 63 + 95;
13795
+ return String.fromCharCode(result);
13796
+ };
13797
+ URLSafeCoder2.prototype._decodeChar = function(c) {
13798
+ var result = INVALID_BYTE;
13799
+ result += (44 - c & c - 46) >>> 8 & -INVALID_BYTE + c - 45 + 62;
13800
+ result += (94 - c & c - 96) >>> 8 & -INVALID_BYTE + c - 95 + 63;
13801
+ result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
13802
+ result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
13803
+ result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
13804
+ return result;
13805
+ };
13806
+ return URLSafeCoder2;
13807
+ }(Coder)
13808
+ );
13809
+ exports.URLSafeCoder = URLSafeCoder;
13810
+ var urlSafeCoder = new URLSafeCoder();
13811
+ function encodeURLSafe(data) {
13812
+ return urlSafeCoder.encode(data);
13813
+ }
13814
+ exports.encodeURLSafe = encodeURLSafe;
13815
+ function decodeURLSafe(s) {
13816
+ return urlSafeCoder.decode(s);
13817
+ }
13818
+ exports.decodeURLSafe = decodeURLSafe;
13819
+ exports.encodedLength = function(length) {
13820
+ return stdCoder.encodedLength(length);
13821
+ };
13822
+ exports.maxDecodedLength = function(length) {
13823
+ return stdCoder.maxDecodedLength(length);
13824
+ };
13825
+ exports.decodedLength = function(s) {
13826
+ return stdCoder.decodedLength(s);
13827
+ };
13828
+ }
13829
+ });
13830
+
13831
+ // ../../node_modules/fast-sha256/sha256.js
13832
+ var require_sha256 = __commonJS({
13833
+ "../../node_modules/fast-sha256/sha256.js"(exports, module) {
13834
+ (function(root, factory) {
13835
+ var exports2 = {};
13836
+ factory(exports2);
13837
+ var sha2562 = exports2["default"];
13838
+ for (var k in exports2) {
13839
+ sha2562[k] = exports2[k];
13840
+ }
13841
+ if (typeof module === "object" && typeof module.exports === "object") {
13842
+ module.exports = sha2562;
13843
+ } else if (typeof define === "function" && define.amd) {
13844
+ define(function() {
13845
+ return sha2562;
13846
+ });
13847
+ } else {
13848
+ root.sha256 = sha2562;
13849
+ }
13850
+ })(exports, function(exports2) {
13851
+ exports2.__esModule = true;
13852
+ exports2.digestLength = 32;
13853
+ exports2.blockSize = 64;
13854
+ var K = new Uint32Array([
13855
+ 1116352408,
13856
+ 1899447441,
13857
+ 3049323471,
13858
+ 3921009573,
13859
+ 961987163,
13860
+ 1508970993,
13861
+ 2453635748,
13862
+ 2870763221,
13863
+ 3624381080,
13864
+ 310598401,
13865
+ 607225278,
13866
+ 1426881987,
13867
+ 1925078388,
13868
+ 2162078206,
13869
+ 2614888103,
13870
+ 3248222580,
13871
+ 3835390401,
13872
+ 4022224774,
13873
+ 264347078,
13874
+ 604807628,
13875
+ 770255983,
13876
+ 1249150122,
13877
+ 1555081692,
13878
+ 1996064986,
13879
+ 2554220882,
13880
+ 2821834349,
13881
+ 2952996808,
13882
+ 3210313671,
13883
+ 3336571891,
13884
+ 3584528711,
13885
+ 113926993,
13886
+ 338241895,
13887
+ 666307205,
13888
+ 773529912,
13889
+ 1294757372,
13890
+ 1396182291,
13891
+ 1695183700,
13892
+ 1986661051,
13893
+ 2177026350,
13894
+ 2456956037,
13895
+ 2730485921,
13896
+ 2820302411,
13897
+ 3259730800,
13898
+ 3345764771,
13899
+ 3516065817,
13900
+ 3600352804,
13901
+ 4094571909,
13902
+ 275423344,
13903
+ 430227734,
13904
+ 506948616,
13905
+ 659060556,
13906
+ 883997877,
13907
+ 958139571,
13908
+ 1322822218,
13909
+ 1537002063,
13910
+ 1747873779,
13911
+ 1955562222,
13912
+ 2024104815,
13913
+ 2227730452,
13914
+ 2361852424,
13915
+ 2428436474,
13916
+ 2756734187,
13917
+ 3204031479,
13918
+ 3329325298
13919
+ ]);
13920
+ function hashBlocks(w, v, p, pos, len) {
13921
+ var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
13922
+ while (len >= 64) {
13923
+ a = v[0];
13924
+ b = v[1];
13925
+ c = v[2];
13926
+ d = v[3];
13927
+ e = v[4];
13928
+ f = v[5];
13929
+ g = v[6];
13930
+ h = v[7];
13931
+ for (i = 0; i < 16; i++) {
13932
+ j = pos + i * 4;
13933
+ w[i] = (p[j] & 255) << 24 | (p[j + 1] & 255) << 16 | (p[j + 2] & 255) << 8 | p[j + 3] & 255;
13934
+ }
13935
+ for (i = 16; i < 64; i++) {
13936
+ u = w[i - 2];
13937
+ t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10;
13938
+ u = w[i - 15];
13939
+ t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3;
13940
+ w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
13941
+ }
13942
+ for (i = 0; i < 64; i++) {
13943
+ 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;
13944
+ t2 = ((a >>> 2 | a << 32 - 2) ^ (a >>> 13 | a << 32 - 13) ^ (a >>> 22 | a << 32 - 22)) + (a & b ^ a & c ^ b & c) | 0;
13945
+ h = g;
13946
+ g = f;
13947
+ f = e;
13948
+ e = d + t1 | 0;
13949
+ d = c;
13950
+ c = b;
13951
+ b = a;
13952
+ a = t1 + t2 | 0;
13953
+ }
13954
+ v[0] += a;
13955
+ v[1] += b;
13956
+ v[2] += c;
13957
+ v[3] += d;
13958
+ v[4] += e;
13959
+ v[5] += f;
13960
+ v[6] += g;
13961
+ v[7] += h;
13962
+ pos += 64;
13963
+ len -= 64;
13964
+ }
13965
+ return pos;
13966
+ }
13967
+ var Hash = (
13968
+ /** @class */
13969
+ function() {
13970
+ function Hash2() {
13971
+ this.digestLength = exports2.digestLength;
13972
+ this.blockSize = exports2.blockSize;
13973
+ this.state = new Int32Array(8);
13974
+ this.temp = new Int32Array(64);
13975
+ this.buffer = new Uint8Array(128);
13976
+ this.bufferLength = 0;
13977
+ this.bytesHashed = 0;
13978
+ this.finished = false;
13979
+ this.reset();
13980
+ }
13981
+ Hash2.prototype.reset = function() {
13982
+ this.state[0] = 1779033703;
13983
+ this.state[1] = 3144134277;
13984
+ this.state[2] = 1013904242;
13985
+ this.state[3] = 2773480762;
13986
+ this.state[4] = 1359893119;
13987
+ this.state[5] = 2600822924;
13988
+ this.state[6] = 528734635;
13989
+ this.state[7] = 1541459225;
13990
+ this.bufferLength = 0;
13991
+ this.bytesHashed = 0;
13992
+ this.finished = false;
13993
+ return this;
13994
+ };
13995
+ Hash2.prototype.clean = function() {
13996
+ for (var i = 0; i < this.buffer.length; i++) {
13997
+ this.buffer[i] = 0;
13998
+ }
13999
+ for (var i = 0; i < this.temp.length; i++) {
14000
+ this.temp[i] = 0;
14001
+ }
14002
+ this.reset();
14003
+ };
14004
+ Hash2.prototype.update = function(data, dataLength) {
14005
+ if (dataLength === void 0) {
14006
+ dataLength = data.length;
14007
+ }
14008
+ if (this.finished) {
14009
+ throw new Error("SHA256: can't update because hash was finished.");
14010
+ }
14011
+ var dataPos = 0;
14012
+ this.bytesHashed += dataLength;
14013
+ if (this.bufferLength > 0) {
14014
+ while (this.bufferLength < 64 && dataLength > 0) {
14015
+ this.buffer[this.bufferLength++] = data[dataPos++];
14016
+ dataLength--;
14017
+ }
14018
+ if (this.bufferLength === 64) {
14019
+ hashBlocks(this.temp, this.state, this.buffer, 0, 64);
14020
+ this.bufferLength = 0;
14021
+ }
14022
+ }
14023
+ if (dataLength >= 64) {
14024
+ dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
14025
+ dataLength %= 64;
14026
+ }
14027
+ while (dataLength > 0) {
14028
+ this.buffer[this.bufferLength++] = data[dataPos++];
14029
+ dataLength--;
14030
+ }
14031
+ return this;
14032
+ };
14033
+ Hash2.prototype.finish = function(out) {
14034
+ if (!this.finished) {
14035
+ var bytesHashed = this.bytesHashed;
14036
+ var left = this.bufferLength;
14037
+ var bitLenHi = bytesHashed / 536870912 | 0;
14038
+ var bitLenLo = bytesHashed << 3;
14039
+ var padLength = bytesHashed % 64 < 56 ? 64 : 128;
14040
+ this.buffer[left] = 128;
14041
+ for (var i = left + 1; i < padLength - 8; i++) {
14042
+ this.buffer[i] = 0;
14043
+ }
14044
+ this.buffer[padLength - 8] = bitLenHi >>> 24 & 255;
14045
+ this.buffer[padLength - 7] = bitLenHi >>> 16 & 255;
14046
+ this.buffer[padLength - 6] = bitLenHi >>> 8 & 255;
14047
+ this.buffer[padLength - 5] = bitLenHi >>> 0 & 255;
14048
+ this.buffer[padLength - 4] = bitLenLo >>> 24 & 255;
14049
+ this.buffer[padLength - 3] = bitLenLo >>> 16 & 255;
14050
+ this.buffer[padLength - 2] = bitLenLo >>> 8 & 255;
14051
+ this.buffer[padLength - 1] = bitLenLo >>> 0 & 255;
14052
+ hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
14053
+ this.finished = true;
14054
+ }
14055
+ for (var i = 0; i < 8; i++) {
14056
+ out[i * 4 + 0] = this.state[i] >>> 24 & 255;
14057
+ out[i * 4 + 1] = this.state[i] >>> 16 & 255;
14058
+ out[i * 4 + 2] = this.state[i] >>> 8 & 255;
14059
+ out[i * 4 + 3] = this.state[i] >>> 0 & 255;
14060
+ }
14061
+ return this;
14062
+ };
14063
+ Hash2.prototype.digest = function() {
14064
+ var out = new Uint8Array(this.digestLength);
14065
+ this.finish(out);
14066
+ return out;
14067
+ };
14068
+ Hash2.prototype._saveState = function(out) {
14069
+ for (var i = 0; i < this.state.length; i++) {
14070
+ out[i] = this.state[i];
14071
+ }
14072
+ };
14073
+ Hash2.prototype._restoreState = function(from, bytesHashed) {
14074
+ for (var i = 0; i < this.state.length; i++) {
14075
+ this.state[i] = from[i];
14076
+ }
14077
+ this.bytesHashed = bytesHashed;
14078
+ this.finished = false;
14079
+ this.bufferLength = 0;
14080
+ };
14081
+ return Hash2;
14082
+ }()
14083
+ );
14084
+ exports2.Hash = Hash;
14085
+ var HMAC = (
14086
+ /** @class */
14087
+ function() {
14088
+ function HMAC2(key) {
14089
+ this.inner = new Hash();
14090
+ this.outer = new Hash();
14091
+ this.blockSize = this.inner.blockSize;
14092
+ this.digestLength = this.inner.digestLength;
14093
+ var pad = new Uint8Array(this.blockSize);
14094
+ if (key.length > this.blockSize) {
14095
+ new Hash().update(key).finish(pad).clean();
14096
+ } else {
14097
+ for (var i = 0; i < key.length; i++) {
14098
+ pad[i] = key[i];
14099
+ }
14100
+ }
14101
+ for (var i = 0; i < pad.length; i++) {
14102
+ pad[i] ^= 54;
14103
+ }
14104
+ this.inner.update(pad);
14105
+ for (var i = 0; i < pad.length; i++) {
14106
+ pad[i] ^= 54 ^ 92;
14107
+ }
14108
+ this.outer.update(pad);
14109
+ this.istate = new Uint32Array(8);
14110
+ this.ostate = new Uint32Array(8);
14111
+ this.inner._saveState(this.istate);
14112
+ this.outer._saveState(this.ostate);
14113
+ for (var i = 0; i < pad.length; i++) {
14114
+ pad[i] = 0;
14115
+ }
14116
+ }
14117
+ HMAC2.prototype.reset = function() {
14118
+ this.inner._restoreState(this.istate, this.inner.blockSize);
14119
+ this.outer._restoreState(this.ostate, this.outer.blockSize);
14120
+ return this;
14121
+ };
14122
+ HMAC2.prototype.clean = function() {
14123
+ for (var i = 0; i < this.istate.length; i++) {
14124
+ this.ostate[i] = this.istate[i] = 0;
14125
+ }
14126
+ this.inner.clean();
14127
+ this.outer.clean();
14128
+ };
14129
+ HMAC2.prototype.update = function(data) {
14130
+ this.inner.update(data);
14131
+ return this;
14132
+ };
14133
+ HMAC2.prototype.finish = function(out) {
14134
+ if (this.outer.finished) {
14135
+ this.outer.finish(out);
14136
+ } else {
14137
+ this.inner.finish(out);
14138
+ this.outer.update(out, this.digestLength).finish(out);
14139
+ }
14140
+ return this;
14141
+ };
14142
+ HMAC2.prototype.digest = function() {
14143
+ var out = new Uint8Array(this.digestLength);
14144
+ this.finish(out);
14145
+ return out;
14146
+ };
14147
+ return HMAC2;
14148
+ }()
14149
+ );
14150
+ exports2.HMAC = HMAC;
14151
+ function hash(data) {
14152
+ var h = new Hash().update(data);
14153
+ var digest = h.digest();
14154
+ h.clean();
14155
+ return digest;
14156
+ }
14157
+ exports2.hash = hash;
14158
+ exports2["default"] = hash;
14159
+ function hmac2(key, data) {
14160
+ var h = new HMAC(key).update(data);
14161
+ var digest = h.digest();
14162
+ h.clean();
14163
+ return digest;
14164
+ }
14165
+ exports2.hmac = hmac2;
14166
+ function fillBuffer(buffer, hmac3, info, counter) {
14167
+ var num = counter[0];
14168
+ if (num === 0) {
14169
+ throw new Error("hkdf: cannot expand more");
14170
+ }
14171
+ hmac3.reset();
14172
+ if (num > 1) {
14173
+ hmac3.update(buffer);
14174
+ }
14175
+ if (info) {
14176
+ hmac3.update(info);
14177
+ }
14178
+ hmac3.update(counter);
14179
+ hmac3.finish(buffer);
14180
+ counter[0]++;
14181
+ }
14182
+ var hkdfSalt = new Uint8Array(exports2.digestLength);
14183
+ function hkdf(key, salt, info, length) {
14184
+ if (salt === void 0) {
14185
+ salt = hkdfSalt;
14186
+ }
14187
+ if (length === void 0) {
14188
+ length = 32;
14189
+ }
14190
+ var counter = new Uint8Array([1]);
14191
+ var okm = hmac2(salt, key);
14192
+ var hmac_ = new HMAC(okm);
14193
+ var buffer = new Uint8Array(hmac_.digestLength);
14194
+ var bufpos = buffer.length;
14195
+ var out = new Uint8Array(length);
14196
+ for (var i = 0; i < length; i++) {
14197
+ if (bufpos === buffer.length) {
14198
+ fillBuffer(buffer, hmac_, info, counter);
14199
+ bufpos = 0;
14200
+ }
14201
+ out[i] = buffer[bufpos++];
14202
+ }
14203
+ hmac_.clean();
14204
+ buffer.fill(0);
14205
+ counter.fill(0);
14206
+ return out;
14207
+ }
14208
+ exports2.hkdf = hkdf;
14209
+ function pbkdf2(password, salt, iterations, dkLen) {
14210
+ var prf = new HMAC(password);
14211
+ var len = prf.digestLength;
14212
+ var ctr = new Uint8Array(4);
14213
+ var t = new Uint8Array(len);
14214
+ var u = new Uint8Array(len);
14215
+ var dk = new Uint8Array(dkLen);
14216
+ for (var i = 0; i * len < dkLen; i++) {
14217
+ var c = i + 1;
14218
+ ctr[0] = c >>> 24 & 255;
14219
+ ctr[1] = c >>> 16 & 255;
14220
+ ctr[2] = c >>> 8 & 255;
14221
+ ctr[3] = c >>> 0 & 255;
14222
+ prf.reset();
14223
+ prf.update(salt);
14224
+ prf.update(ctr);
14225
+ prf.finish(u);
14226
+ for (var j = 0; j < len; j++) {
14227
+ t[j] = u[j];
14228
+ }
14229
+ for (var j = 2; j <= iterations; j++) {
14230
+ prf.reset();
14231
+ prf.update(u).finish(u);
14232
+ for (var k = 0; k < len; k++) {
14233
+ t[k] ^= u[k];
14234
+ }
14235
+ }
14236
+ for (var j = 0; j < len && i * len + j < dkLen; j++) {
14237
+ dk[i * len + j] = t[j];
14238
+ }
14239
+ }
14240
+ for (var i = 0; i < len; i++) {
14241
+ t[i] = u[i] = 0;
14242
+ }
14243
+ for (var i = 0; i < 4; i++) {
14244
+ ctr[i] = 0;
14245
+ }
14246
+ prf.clean();
14247
+ return dk;
14248
+ }
14249
+ exports2.pbkdf2 = pbkdf2;
14250
+ });
14251
+ }
14252
+ });
14253
+
14254
+ // src/webhook/vendor/standardwebhook.ts
14255
+ __toESM(require_base64());
14256
+ __toESM(require_sha256());
14257
+ /**
14258
+ * The MIT License
14259
+ *
14260
+ * Copyright (c) 2023 Svix (https://www.svix.com)
14261
+ *
14262
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14263
+ * of this software and associated documentation files (the "Software"), to deal
14264
+ * in the Software without restriction, including without limitation the rights
14265
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14266
+ * copies of the Software, and to permit persons to whom the Software is
14267
+ * furnished to do so, subject to the following conditions:
14268
+ *
14269
+ * The above copyright notice and this permission notice shall be included in
14270
+ * all copies or substantial portions of the Software.
14271
+ *
14272
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14273
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14274
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14275
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14276
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
14277
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
14278
+ * THE SOFTWARE.
14279
+ *
14280
+ * @fileoverview Server-only webhook verification implementation.
14281
+ * @description Vendored from standardwebhooks package to avoid bundling issues.
14282
+ * Uses Node.js crypto module - DO NOT import in client/browser code.
14283
+ * @license MIT
14284
+ * @internal
14285
+ */
14286
+
14287
+ // src/webhook/webhook.ts
13593
14288
  async function handleWebhookPayload(payload, config, context) {
13594
14289
  const callHandler = (handler, payload2) => {
13595
14290
  if (!handler) return;