@dodopayments/nextjs 0.3.2 → 0.3.4

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