@dodopayments/sveltekit 0.2.3 → 0.2.5

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
@@ -7259,6 +7259,13 @@ var checkoutSessionCustomizationSchema = objectType({
7259
7259
  }).optional();
7260
7260
  var checkoutSessionFeatureFlagsSchema = objectType({
7261
7261
  allow_currency_selection: booleanType().optional(),
7262
+ allow_customer_editing_city: booleanType().optional(),
7263
+ allow_customer_editing_country: booleanType().optional(),
7264
+ allow_customer_editing_email: booleanType().optional(),
7265
+ allow_customer_editing_name: booleanType().optional(),
7266
+ allow_customer_editing_state: booleanType().optional(),
7267
+ allow_customer_editing_street: booleanType().optional(),
7268
+ allow_customer_editing_zipcode: booleanType().optional(),
7262
7269
  allow_discount_code: booleanType().optional(),
7263
7270
  allow_phone_number_collection: booleanType().optional(),
7264
7271
  allow_tax_id: booleanType().optional(),
@@ -7359,7 +7366,11 @@ var buildCheckoutUrl = async ({
7359
7366
  if (!sessionPayload) {
7360
7367
  throw new Error("sessionPayload is required when type is 'session'");
7361
7368
  }
7362
- const session = await createCheckoutSession(sessionPayload, {
7369
+ const finalPayload = {
7370
+ ...sessionPayload,
7371
+ return_url: sessionPayload.return_url ?? returnUrl
7372
+ };
7373
+ const session = await createCheckoutSession(finalPayload, {
7363
7374
  bearerToken,
7364
7375
  environment
7365
7376
  });
@@ -7591,6 +7602,32 @@ var buildCheckoutUrl = async ({
7591
7602
  }
7592
7603
  };
7593
7604
 
7605
+ var __create = Object.create;
7606
+ var __defProp = Object.defineProperty;
7607
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7608
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7609
+ var __getProtoOf = Object.getPrototypeOf;
7610
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7611
+ var __commonJS = (cb, mod) => function __require2() {
7612
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7613
+ };
7614
+ var __copyProps = (to, from, except, desc) => {
7615
+ if (from && typeof from === "object" || typeof from === "function") {
7616
+ for (let key of __getOwnPropNames(from))
7617
+ if (!__hasOwnProp.call(to, key) && key !== except)
7618
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
7619
+ }
7620
+ return to;
7621
+ };
7622
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
7623
+ // If the importer is in node compatibility mode or this is not an ESM
7624
+ // file that has been converted to a CommonJS file using a Babel-
7625
+ // compatible transform (i.e. "__esModule" has not been set), then set
7626
+ // "default" to the CommonJS "module.exports" for node compatibility.
7627
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
7628
+ mod
7629
+ ));
7630
+
7594
7631
  const Checkout = (config) => {
7595
7632
  const getHandler = async (event) => {
7596
7633
  const searchParams = event.url.searchParams;
@@ -7979,6 +8016,12 @@ var SubscriptionExpiredPayloadSchema = objectType({
7979
8016
  timestamp: stringType().transform((d) => new Date(d)),
7980
8017
  data: SubscriptionSchema
7981
8018
  });
8019
+ var SubscriptionUpdatedPayloadSchema = objectType({
8020
+ business_id: stringType(),
8021
+ type: literalType("subscription.updated"),
8022
+ timestamp: stringType().transform((d) => new Date(d)),
8023
+ data: SubscriptionSchema
8024
+ });
7982
8025
  var LicenseKeyCreatedPayloadSchema = objectType({
7983
8026
  business_id: stringType(),
7984
8027
  type: literalType("license_key.created"),
@@ -8007,9 +8050,679 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
8007
8050
  SubscriptionCancelledPayloadSchema,
8008
8051
  SubscriptionFailedPayloadSchema,
8009
8052
  SubscriptionExpiredPayloadSchema,
8053
+ SubscriptionUpdatedPayloadSchema,
8010
8054
  LicenseKeyCreatedPayloadSchema
8011
8055
  ]);
8012
8056
 
8057
+ // ../../node_modules/@stablelib/base64/lib/base64.js
8058
+ var require_base64 = __commonJS({
8059
+ "../../node_modules/@stablelib/base64/lib/base64.js"(exports) {
8060
+ var __extends = exports && exports.__extends || /* @__PURE__ */ function() {
8061
+ var extendStatics = function(d, b) {
8062
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
8063
+ d2.__proto__ = b2;
8064
+ } || function(d2, b2) {
8065
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
8066
+ };
8067
+ return extendStatics(d, b);
8068
+ };
8069
+ return function(d, b) {
8070
+ extendStatics(d, b);
8071
+ function __() {
8072
+ this.constructor = d;
8073
+ }
8074
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8075
+ };
8076
+ }();
8077
+ Object.defineProperty(exports, "__esModule", { value: true });
8078
+ var INVALID_BYTE = 256;
8079
+ var Coder = (
8080
+ /** @class */
8081
+ function() {
8082
+ function Coder2(_paddingCharacter) {
8083
+ if (_paddingCharacter === void 0) {
8084
+ _paddingCharacter = "=";
8085
+ }
8086
+ this._paddingCharacter = _paddingCharacter;
8087
+ }
8088
+ Coder2.prototype.encodedLength = function(length) {
8089
+ if (!this._paddingCharacter) {
8090
+ return (length * 8 + 5) / 6 | 0;
8091
+ }
8092
+ return (length + 2) / 3 * 4 | 0;
8093
+ };
8094
+ Coder2.prototype.encode = function(data) {
8095
+ var out = "";
8096
+ var i = 0;
8097
+ for (; i < data.length - 2; i += 3) {
8098
+ var c = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
8099
+ out += this._encodeByte(c >>> 3 * 6 & 63);
8100
+ out += this._encodeByte(c >>> 2 * 6 & 63);
8101
+ out += this._encodeByte(c >>> 1 * 6 & 63);
8102
+ out += this._encodeByte(c >>> 0 * 6 & 63);
8103
+ }
8104
+ var left = data.length - i;
8105
+ if (left > 0) {
8106
+ var c = data[i] << 16 | (left === 2 ? data[i + 1] << 8 : 0);
8107
+ out += this._encodeByte(c >>> 3 * 6 & 63);
8108
+ out += this._encodeByte(c >>> 2 * 6 & 63);
8109
+ if (left === 2) {
8110
+ out += this._encodeByte(c >>> 1 * 6 & 63);
8111
+ } else {
8112
+ out += this._paddingCharacter || "";
8113
+ }
8114
+ out += this._paddingCharacter || "";
8115
+ }
8116
+ return out;
8117
+ };
8118
+ Coder2.prototype.maxDecodedLength = function(length) {
8119
+ if (!this._paddingCharacter) {
8120
+ return (length * 6 + 7) / 8 | 0;
8121
+ }
8122
+ return length / 4 * 3 | 0;
8123
+ };
8124
+ Coder2.prototype.decodedLength = function(s) {
8125
+ return this.maxDecodedLength(s.length - this._getPaddingLength(s));
8126
+ };
8127
+ Coder2.prototype.decode = function(s) {
8128
+ if (s.length === 0) {
8129
+ return new Uint8Array(0);
8130
+ }
8131
+ var paddingLength = this._getPaddingLength(s);
8132
+ var length = s.length - paddingLength;
8133
+ var out = new Uint8Array(this.maxDecodedLength(length));
8134
+ var op = 0;
8135
+ var i = 0;
8136
+ var haveBad = 0;
8137
+ var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
8138
+ for (; i < length - 4; i += 4) {
8139
+ v0 = this._decodeChar(s.charCodeAt(i + 0));
8140
+ v1 = this._decodeChar(s.charCodeAt(i + 1));
8141
+ v2 = this._decodeChar(s.charCodeAt(i + 2));
8142
+ v3 = this._decodeChar(s.charCodeAt(i + 3));
8143
+ out[op++] = v0 << 2 | v1 >>> 4;
8144
+ out[op++] = v1 << 4 | v2 >>> 2;
8145
+ out[op++] = v2 << 6 | v3;
8146
+ haveBad |= v0 & INVALID_BYTE;
8147
+ haveBad |= v1 & INVALID_BYTE;
8148
+ haveBad |= v2 & INVALID_BYTE;
8149
+ haveBad |= v3 & INVALID_BYTE;
8150
+ }
8151
+ if (i < length - 1) {
8152
+ v0 = this._decodeChar(s.charCodeAt(i));
8153
+ v1 = this._decodeChar(s.charCodeAt(i + 1));
8154
+ out[op++] = v0 << 2 | v1 >>> 4;
8155
+ haveBad |= v0 & INVALID_BYTE;
8156
+ haveBad |= v1 & INVALID_BYTE;
8157
+ }
8158
+ if (i < length - 2) {
8159
+ v2 = this._decodeChar(s.charCodeAt(i + 2));
8160
+ out[op++] = v1 << 4 | v2 >>> 2;
8161
+ haveBad |= v2 & INVALID_BYTE;
8162
+ }
8163
+ if (i < length - 3) {
8164
+ v3 = this._decodeChar(s.charCodeAt(i + 3));
8165
+ out[op++] = v2 << 6 | v3;
8166
+ haveBad |= v3 & INVALID_BYTE;
8167
+ }
8168
+ if (haveBad !== 0) {
8169
+ throw new Error("Base64Coder: incorrect characters for decoding");
8170
+ }
8171
+ return out;
8172
+ };
8173
+ Coder2.prototype._encodeByte = function(b) {
8174
+ var result = b;
8175
+ result += 65;
8176
+ result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
8177
+ result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
8178
+ result += 61 - b >>> 8 & 52 - 48 - 62 + 43;
8179
+ result += 62 - b >>> 8 & 62 - 43 - 63 + 47;
8180
+ return String.fromCharCode(result);
8181
+ };
8182
+ Coder2.prototype._decodeChar = function(c) {
8183
+ var result = INVALID_BYTE;
8184
+ result += (42 - c & c - 44) >>> 8 & -INVALID_BYTE + c - 43 + 62;
8185
+ result += (46 - c & c - 48) >>> 8 & -INVALID_BYTE + c - 47 + 63;
8186
+ result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
8187
+ result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
8188
+ result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
8189
+ return result;
8190
+ };
8191
+ Coder2.prototype._getPaddingLength = function(s) {
8192
+ var paddingLength = 0;
8193
+ if (this._paddingCharacter) {
8194
+ for (var i = s.length - 1; i >= 0; i--) {
8195
+ if (s[i] !== this._paddingCharacter) {
8196
+ break;
8197
+ }
8198
+ paddingLength++;
8199
+ }
8200
+ if (s.length < 4 || paddingLength > 2) {
8201
+ throw new Error("Base64Coder: incorrect padding");
8202
+ }
8203
+ }
8204
+ return paddingLength;
8205
+ };
8206
+ return Coder2;
8207
+ }()
8208
+ );
8209
+ exports.Coder = Coder;
8210
+ var stdCoder = new Coder();
8211
+ function encode2(data) {
8212
+ return stdCoder.encode(data);
8213
+ }
8214
+ exports.encode = encode2;
8215
+ function decode2(s) {
8216
+ return stdCoder.decode(s);
8217
+ }
8218
+ exports.decode = decode2;
8219
+ var URLSafeCoder = (
8220
+ /** @class */
8221
+ function(_super) {
8222
+ __extends(URLSafeCoder2, _super);
8223
+ function URLSafeCoder2() {
8224
+ return _super !== null && _super.apply(this, arguments) || this;
8225
+ }
8226
+ URLSafeCoder2.prototype._encodeByte = function(b) {
8227
+ var result = b;
8228
+ result += 65;
8229
+ result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
8230
+ result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
8231
+ result += 61 - b >>> 8 & 52 - 48 - 62 + 45;
8232
+ result += 62 - b >>> 8 & 62 - 45 - 63 + 95;
8233
+ return String.fromCharCode(result);
8234
+ };
8235
+ URLSafeCoder2.prototype._decodeChar = function(c) {
8236
+ var result = INVALID_BYTE;
8237
+ result += (44 - c & c - 46) >>> 8 & -INVALID_BYTE + c - 45 + 62;
8238
+ result += (94 - c & c - 96) >>> 8 & -INVALID_BYTE + c - 95 + 63;
8239
+ result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
8240
+ result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
8241
+ result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
8242
+ return result;
8243
+ };
8244
+ return URLSafeCoder2;
8245
+ }(Coder)
8246
+ );
8247
+ exports.URLSafeCoder = URLSafeCoder;
8248
+ var urlSafeCoder = new URLSafeCoder();
8249
+ function encodeURLSafe(data) {
8250
+ return urlSafeCoder.encode(data);
8251
+ }
8252
+ exports.encodeURLSafe = encodeURLSafe;
8253
+ function decodeURLSafe(s) {
8254
+ return urlSafeCoder.decode(s);
8255
+ }
8256
+ exports.decodeURLSafe = decodeURLSafe;
8257
+ exports.encodedLength = function(length) {
8258
+ return stdCoder.encodedLength(length);
8259
+ };
8260
+ exports.maxDecodedLength = function(length) {
8261
+ return stdCoder.maxDecodedLength(length);
8262
+ };
8263
+ exports.decodedLength = function(s) {
8264
+ return stdCoder.decodedLength(s);
8265
+ };
8266
+ }
8267
+ });
8268
+
8269
+ // ../../node_modules/fast-sha256/sha256.js
8270
+ var require_sha256 = __commonJS({
8271
+ "../../node_modules/fast-sha256/sha256.js"(exports, module) {
8272
+ (function(root, factory) {
8273
+ var exports2 = {};
8274
+ factory(exports2);
8275
+ var sha2562 = exports2["default"];
8276
+ for (var k in exports2) {
8277
+ sha2562[k] = exports2[k];
8278
+ }
8279
+ if (typeof module === "object" && typeof module.exports === "object") {
8280
+ module.exports = sha2562;
8281
+ } else if (typeof define === "function" && define.amd) {
8282
+ define(function() {
8283
+ return sha2562;
8284
+ });
8285
+ } else {
8286
+ root.sha256 = sha2562;
8287
+ }
8288
+ })(exports, function(exports2) {
8289
+ exports2.__esModule = true;
8290
+ exports2.digestLength = 32;
8291
+ exports2.blockSize = 64;
8292
+ var K = new Uint32Array([
8293
+ 1116352408,
8294
+ 1899447441,
8295
+ 3049323471,
8296
+ 3921009573,
8297
+ 961987163,
8298
+ 1508970993,
8299
+ 2453635748,
8300
+ 2870763221,
8301
+ 3624381080,
8302
+ 310598401,
8303
+ 607225278,
8304
+ 1426881987,
8305
+ 1925078388,
8306
+ 2162078206,
8307
+ 2614888103,
8308
+ 3248222580,
8309
+ 3835390401,
8310
+ 4022224774,
8311
+ 264347078,
8312
+ 604807628,
8313
+ 770255983,
8314
+ 1249150122,
8315
+ 1555081692,
8316
+ 1996064986,
8317
+ 2554220882,
8318
+ 2821834349,
8319
+ 2952996808,
8320
+ 3210313671,
8321
+ 3336571891,
8322
+ 3584528711,
8323
+ 113926993,
8324
+ 338241895,
8325
+ 666307205,
8326
+ 773529912,
8327
+ 1294757372,
8328
+ 1396182291,
8329
+ 1695183700,
8330
+ 1986661051,
8331
+ 2177026350,
8332
+ 2456956037,
8333
+ 2730485921,
8334
+ 2820302411,
8335
+ 3259730800,
8336
+ 3345764771,
8337
+ 3516065817,
8338
+ 3600352804,
8339
+ 4094571909,
8340
+ 275423344,
8341
+ 430227734,
8342
+ 506948616,
8343
+ 659060556,
8344
+ 883997877,
8345
+ 958139571,
8346
+ 1322822218,
8347
+ 1537002063,
8348
+ 1747873779,
8349
+ 1955562222,
8350
+ 2024104815,
8351
+ 2227730452,
8352
+ 2361852424,
8353
+ 2428436474,
8354
+ 2756734187,
8355
+ 3204031479,
8356
+ 3329325298
8357
+ ]);
8358
+ function hashBlocks(w, v, p, pos, len) {
8359
+ var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
8360
+ while (len >= 64) {
8361
+ a = v[0];
8362
+ b = v[1];
8363
+ c = v[2];
8364
+ d = v[3];
8365
+ e = v[4];
8366
+ f = v[5];
8367
+ g = v[6];
8368
+ h = v[7];
8369
+ for (i = 0; i < 16; i++) {
8370
+ j = pos + i * 4;
8371
+ w[i] = (p[j] & 255) << 24 | (p[j + 1] & 255) << 16 | (p[j + 2] & 255) << 8 | p[j + 3] & 255;
8372
+ }
8373
+ for (i = 16; i < 64; i++) {
8374
+ u = w[i - 2];
8375
+ t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10;
8376
+ u = w[i - 15];
8377
+ t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3;
8378
+ w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
8379
+ }
8380
+ for (i = 0; i < 64; i++) {
8381
+ 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;
8382
+ t2 = ((a >>> 2 | a << 32 - 2) ^ (a >>> 13 | a << 32 - 13) ^ (a >>> 22 | a << 32 - 22)) + (a & b ^ a & c ^ b & c) | 0;
8383
+ h = g;
8384
+ g = f;
8385
+ f = e;
8386
+ e = d + t1 | 0;
8387
+ d = c;
8388
+ c = b;
8389
+ b = a;
8390
+ a = t1 + t2 | 0;
8391
+ }
8392
+ v[0] += a;
8393
+ v[1] += b;
8394
+ v[2] += c;
8395
+ v[3] += d;
8396
+ v[4] += e;
8397
+ v[5] += f;
8398
+ v[6] += g;
8399
+ v[7] += h;
8400
+ pos += 64;
8401
+ len -= 64;
8402
+ }
8403
+ return pos;
8404
+ }
8405
+ var Hash = (
8406
+ /** @class */
8407
+ function() {
8408
+ function Hash2() {
8409
+ this.digestLength = exports2.digestLength;
8410
+ this.blockSize = exports2.blockSize;
8411
+ this.state = new Int32Array(8);
8412
+ this.temp = new Int32Array(64);
8413
+ this.buffer = new Uint8Array(128);
8414
+ this.bufferLength = 0;
8415
+ this.bytesHashed = 0;
8416
+ this.finished = false;
8417
+ this.reset();
8418
+ }
8419
+ Hash2.prototype.reset = function() {
8420
+ this.state[0] = 1779033703;
8421
+ this.state[1] = 3144134277;
8422
+ this.state[2] = 1013904242;
8423
+ this.state[3] = 2773480762;
8424
+ this.state[4] = 1359893119;
8425
+ this.state[5] = 2600822924;
8426
+ this.state[6] = 528734635;
8427
+ this.state[7] = 1541459225;
8428
+ this.bufferLength = 0;
8429
+ this.bytesHashed = 0;
8430
+ this.finished = false;
8431
+ return this;
8432
+ };
8433
+ Hash2.prototype.clean = function() {
8434
+ for (var i = 0; i < this.buffer.length; i++) {
8435
+ this.buffer[i] = 0;
8436
+ }
8437
+ for (var i = 0; i < this.temp.length; i++) {
8438
+ this.temp[i] = 0;
8439
+ }
8440
+ this.reset();
8441
+ };
8442
+ Hash2.prototype.update = function(data, dataLength) {
8443
+ if (dataLength === void 0) {
8444
+ dataLength = data.length;
8445
+ }
8446
+ if (this.finished) {
8447
+ throw new Error("SHA256: can't update because hash was finished.");
8448
+ }
8449
+ var dataPos = 0;
8450
+ this.bytesHashed += dataLength;
8451
+ if (this.bufferLength > 0) {
8452
+ while (this.bufferLength < 64 && dataLength > 0) {
8453
+ this.buffer[this.bufferLength++] = data[dataPos++];
8454
+ dataLength--;
8455
+ }
8456
+ if (this.bufferLength === 64) {
8457
+ hashBlocks(this.temp, this.state, this.buffer, 0, 64);
8458
+ this.bufferLength = 0;
8459
+ }
8460
+ }
8461
+ if (dataLength >= 64) {
8462
+ dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
8463
+ dataLength %= 64;
8464
+ }
8465
+ while (dataLength > 0) {
8466
+ this.buffer[this.bufferLength++] = data[dataPos++];
8467
+ dataLength--;
8468
+ }
8469
+ return this;
8470
+ };
8471
+ Hash2.prototype.finish = function(out) {
8472
+ if (!this.finished) {
8473
+ var bytesHashed = this.bytesHashed;
8474
+ var left = this.bufferLength;
8475
+ var bitLenHi = bytesHashed / 536870912 | 0;
8476
+ var bitLenLo = bytesHashed << 3;
8477
+ var padLength = bytesHashed % 64 < 56 ? 64 : 128;
8478
+ this.buffer[left] = 128;
8479
+ for (var i = left + 1; i < padLength - 8; i++) {
8480
+ this.buffer[i] = 0;
8481
+ }
8482
+ this.buffer[padLength - 8] = bitLenHi >>> 24 & 255;
8483
+ this.buffer[padLength - 7] = bitLenHi >>> 16 & 255;
8484
+ this.buffer[padLength - 6] = bitLenHi >>> 8 & 255;
8485
+ this.buffer[padLength - 5] = bitLenHi >>> 0 & 255;
8486
+ this.buffer[padLength - 4] = bitLenLo >>> 24 & 255;
8487
+ this.buffer[padLength - 3] = bitLenLo >>> 16 & 255;
8488
+ this.buffer[padLength - 2] = bitLenLo >>> 8 & 255;
8489
+ this.buffer[padLength - 1] = bitLenLo >>> 0 & 255;
8490
+ hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
8491
+ this.finished = true;
8492
+ }
8493
+ for (var i = 0; i < 8; i++) {
8494
+ out[i * 4 + 0] = this.state[i] >>> 24 & 255;
8495
+ out[i * 4 + 1] = this.state[i] >>> 16 & 255;
8496
+ out[i * 4 + 2] = this.state[i] >>> 8 & 255;
8497
+ out[i * 4 + 3] = this.state[i] >>> 0 & 255;
8498
+ }
8499
+ return this;
8500
+ };
8501
+ Hash2.prototype.digest = function() {
8502
+ var out = new Uint8Array(this.digestLength);
8503
+ this.finish(out);
8504
+ return out;
8505
+ };
8506
+ Hash2.prototype._saveState = function(out) {
8507
+ for (var i = 0; i < this.state.length; i++) {
8508
+ out[i] = this.state[i];
8509
+ }
8510
+ };
8511
+ Hash2.prototype._restoreState = function(from, bytesHashed) {
8512
+ for (var i = 0; i < this.state.length; i++) {
8513
+ this.state[i] = from[i];
8514
+ }
8515
+ this.bytesHashed = bytesHashed;
8516
+ this.finished = false;
8517
+ this.bufferLength = 0;
8518
+ };
8519
+ return Hash2;
8520
+ }()
8521
+ );
8522
+ exports2.Hash = Hash;
8523
+ var HMAC = (
8524
+ /** @class */
8525
+ function() {
8526
+ function HMAC2(key) {
8527
+ this.inner = new Hash();
8528
+ this.outer = new Hash();
8529
+ this.blockSize = this.inner.blockSize;
8530
+ this.digestLength = this.inner.digestLength;
8531
+ var pad = new Uint8Array(this.blockSize);
8532
+ if (key.length > this.blockSize) {
8533
+ new Hash().update(key).finish(pad).clean();
8534
+ } else {
8535
+ for (var i = 0; i < key.length; i++) {
8536
+ pad[i] = key[i];
8537
+ }
8538
+ }
8539
+ for (var i = 0; i < pad.length; i++) {
8540
+ pad[i] ^= 54;
8541
+ }
8542
+ this.inner.update(pad);
8543
+ for (var i = 0; i < pad.length; i++) {
8544
+ pad[i] ^= 54 ^ 92;
8545
+ }
8546
+ this.outer.update(pad);
8547
+ this.istate = new Uint32Array(8);
8548
+ this.ostate = new Uint32Array(8);
8549
+ this.inner._saveState(this.istate);
8550
+ this.outer._saveState(this.ostate);
8551
+ for (var i = 0; i < pad.length; i++) {
8552
+ pad[i] = 0;
8553
+ }
8554
+ }
8555
+ HMAC2.prototype.reset = function() {
8556
+ this.inner._restoreState(this.istate, this.inner.blockSize);
8557
+ this.outer._restoreState(this.ostate, this.outer.blockSize);
8558
+ return this;
8559
+ };
8560
+ HMAC2.prototype.clean = function() {
8561
+ for (var i = 0; i < this.istate.length; i++) {
8562
+ this.ostate[i] = this.istate[i] = 0;
8563
+ }
8564
+ this.inner.clean();
8565
+ this.outer.clean();
8566
+ };
8567
+ HMAC2.prototype.update = function(data) {
8568
+ this.inner.update(data);
8569
+ return this;
8570
+ };
8571
+ HMAC2.prototype.finish = function(out) {
8572
+ if (this.outer.finished) {
8573
+ this.outer.finish(out);
8574
+ } else {
8575
+ this.inner.finish(out);
8576
+ this.outer.update(out, this.digestLength).finish(out);
8577
+ }
8578
+ return this;
8579
+ };
8580
+ HMAC2.prototype.digest = function() {
8581
+ var out = new Uint8Array(this.digestLength);
8582
+ this.finish(out);
8583
+ return out;
8584
+ };
8585
+ return HMAC2;
8586
+ }()
8587
+ );
8588
+ exports2.HMAC = HMAC;
8589
+ function hash(data) {
8590
+ var h = new Hash().update(data);
8591
+ var digest = h.digest();
8592
+ h.clean();
8593
+ return digest;
8594
+ }
8595
+ exports2.hash = hash;
8596
+ exports2["default"] = hash;
8597
+ function hmac2(key, data) {
8598
+ var h = new HMAC(key).update(data);
8599
+ var digest = h.digest();
8600
+ h.clean();
8601
+ return digest;
8602
+ }
8603
+ exports2.hmac = hmac2;
8604
+ function fillBuffer(buffer, hmac3, info, counter) {
8605
+ var num = counter[0];
8606
+ if (num === 0) {
8607
+ throw new Error("hkdf: cannot expand more");
8608
+ }
8609
+ hmac3.reset();
8610
+ if (num > 1) {
8611
+ hmac3.update(buffer);
8612
+ }
8613
+ if (info) {
8614
+ hmac3.update(info);
8615
+ }
8616
+ hmac3.update(counter);
8617
+ hmac3.finish(buffer);
8618
+ counter[0]++;
8619
+ }
8620
+ var hkdfSalt = new Uint8Array(exports2.digestLength);
8621
+ function hkdf(key, salt, info, length) {
8622
+ if (salt === void 0) {
8623
+ salt = hkdfSalt;
8624
+ }
8625
+ if (length === void 0) {
8626
+ length = 32;
8627
+ }
8628
+ var counter = new Uint8Array([1]);
8629
+ var okm = hmac2(salt, key);
8630
+ var hmac_ = new HMAC(okm);
8631
+ var buffer = new Uint8Array(hmac_.digestLength);
8632
+ var bufpos = buffer.length;
8633
+ var out = new Uint8Array(length);
8634
+ for (var i = 0; i < length; i++) {
8635
+ if (bufpos === buffer.length) {
8636
+ fillBuffer(buffer, hmac_, info, counter);
8637
+ bufpos = 0;
8638
+ }
8639
+ out[i] = buffer[bufpos++];
8640
+ }
8641
+ hmac_.clean();
8642
+ buffer.fill(0);
8643
+ counter.fill(0);
8644
+ return out;
8645
+ }
8646
+ exports2.hkdf = hkdf;
8647
+ function pbkdf2(password, salt, iterations, dkLen) {
8648
+ var prf = new HMAC(password);
8649
+ var len = prf.digestLength;
8650
+ var ctr = new Uint8Array(4);
8651
+ var t = new Uint8Array(len);
8652
+ var u = new Uint8Array(len);
8653
+ var dk = new Uint8Array(dkLen);
8654
+ for (var i = 0; i * len < dkLen; i++) {
8655
+ var c = i + 1;
8656
+ ctr[0] = c >>> 24 & 255;
8657
+ ctr[1] = c >>> 16 & 255;
8658
+ ctr[2] = c >>> 8 & 255;
8659
+ ctr[3] = c >>> 0 & 255;
8660
+ prf.reset();
8661
+ prf.update(salt);
8662
+ prf.update(ctr);
8663
+ prf.finish(u);
8664
+ for (var j = 0; j < len; j++) {
8665
+ t[j] = u[j];
8666
+ }
8667
+ for (var j = 2; j <= iterations; j++) {
8668
+ prf.reset();
8669
+ prf.update(u).finish(u);
8670
+ for (var k = 0; k < len; k++) {
8671
+ t[k] ^= u[k];
8672
+ }
8673
+ }
8674
+ for (var j = 0; j < len && i * len + j < dkLen; j++) {
8675
+ dk[i * len + j] = t[j];
8676
+ }
8677
+ }
8678
+ for (var i = 0; i < len; i++) {
8679
+ t[i] = u[i] = 0;
8680
+ }
8681
+ for (var i = 0; i < 4; i++) {
8682
+ ctr[i] = 0;
8683
+ }
8684
+ prf.clean();
8685
+ return dk;
8686
+ }
8687
+ exports2.pbkdf2 = pbkdf2;
8688
+ });
8689
+ }
8690
+ });
8691
+
8692
+ // src/webhook/vendor/standardwebhook.ts
8693
+ __toESM(require_base64());
8694
+ __toESM(require_sha256());
8695
+ /**
8696
+ * The MIT License
8697
+ *
8698
+ * Copyright (c) 2023 Svix (https://www.svix.com)
8699
+ *
8700
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8701
+ * of this software and associated documentation files (the "Software"), to deal
8702
+ * in the Software without restriction, including without limitation the rights
8703
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8704
+ * copies of the Software, and to permit persons to whom the Software is
8705
+ * furnished to do so, subject to the following conditions:
8706
+ *
8707
+ * The above copyright notice and this permission notice shall be included in
8708
+ * all copies or substantial portions of the Software.
8709
+ *
8710
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8711
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8712
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8713
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8714
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
8715
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
8716
+ * THE SOFTWARE.
8717
+ *
8718
+ * @fileoverview Server-only webhook verification implementation.
8719
+ * @description Vendored from standardwebhooks package to avoid bundling issues.
8720
+ * Uses Node.js crypto module - DO NOT import in client/browser code.
8721
+ * @license MIT
8722
+ * @internal
8723
+ */
8724
+
8725
+ // src/webhook/webhook.ts
8013
8726
  async function handleWebhookPayload(payload, config, context) {
8014
8727
  const callHandler = (handler, payload2) => {
8015
8728
  if (!handler) return;
@@ -8081,6 +8794,9 @@ async function handleWebhookPayload(payload, config, context) {
8081
8794
  if (payload.type === "subscription.expired") {
8082
8795
  await callHandler(config.onSubscriptionExpired, payload);
8083
8796
  }
8797
+ if (payload.type === "subscription.updated") {
8798
+ await callHandler(config.onSubscriptionUpdated, payload);
8799
+ }
8084
8800
  if (payload.type === "license_key.created") {
8085
8801
  await callHandler(config.onLicenseKeyCreated, payload);
8086
8802
  }