@dodopayments/fastify 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
@@ -7165,6 +7165,13 @@ var checkoutSessionCustomizationSchema = objectType({
7165
7165
  }).optional();
7166
7166
  var checkoutSessionFeatureFlagsSchema = objectType({
7167
7167
  allow_currency_selection: booleanType().optional(),
7168
+ allow_customer_editing_city: booleanType().optional(),
7169
+ allow_customer_editing_country: booleanType().optional(),
7170
+ allow_customer_editing_email: booleanType().optional(),
7171
+ allow_customer_editing_name: booleanType().optional(),
7172
+ allow_customer_editing_state: booleanType().optional(),
7173
+ allow_customer_editing_street: booleanType().optional(),
7174
+ allow_customer_editing_zipcode: booleanType().optional(),
7168
7175
  allow_discount_code: booleanType().optional(),
7169
7176
  allow_phone_number_collection: booleanType().optional(),
7170
7177
  allow_tax_id: booleanType().optional(),
@@ -7265,7 +7272,11 @@ var buildCheckoutUrl = async ({
7265
7272
  if (!sessionPayload) {
7266
7273
  throw new Error("sessionPayload is required when type is 'session'");
7267
7274
  }
7268
- const session = await createCheckoutSession(sessionPayload, {
7275
+ const finalPayload = {
7276
+ ...sessionPayload,
7277
+ return_url: sessionPayload.return_url ?? returnUrl
7278
+ };
7279
+ const session = await createCheckoutSession(finalPayload, {
7269
7280
  bearerToken,
7270
7281
  environment
7271
7282
  });
@@ -7497,6 +7508,32 @@ var buildCheckoutUrl = async ({
7497
7508
  }
7498
7509
  };
7499
7510
 
7511
+ var __create = Object.create;
7512
+ var __defProp = Object.defineProperty;
7513
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7514
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7515
+ var __getProtoOf = Object.getPrototypeOf;
7516
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7517
+ var __commonJS = (cb, mod) => function __require2() {
7518
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7519
+ };
7520
+ var __copyProps = (to, from, except, desc) => {
7521
+ if (from && typeof from === "object" || typeof from === "function") {
7522
+ for (let key of __getOwnPropNames(from))
7523
+ if (!__hasOwnProp.call(to, key) && key !== except)
7524
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
7525
+ }
7526
+ return to;
7527
+ };
7528
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
7529
+ // If the importer is in node compatibility mode or this is not an ESM
7530
+ // file that has been converted to a CommonJS file using a Babel-
7531
+ // compatible transform (i.e. "__esModule" has not been set), then set
7532
+ // "default" to the CommonJS "module.exports" for node compatibility.
7533
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
7534
+ mod
7535
+ ));
7536
+
7500
7537
  const Checkout = (config) => {
7501
7538
  // GET handler for static checkout
7502
7539
  const getHandler = async (request, reply) => {
@@ -7887,6 +7924,12 @@ var SubscriptionExpiredPayloadSchema = objectType({
7887
7924
  timestamp: stringType().transform((d) => new Date(d)),
7888
7925
  data: SubscriptionSchema
7889
7926
  });
7927
+ var SubscriptionUpdatedPayloadSchema = objectType({
7928
+ business_id: stringType(),
7929
+ type: literalType("subscription.updated"),
7930
+ timestamp: stringType().transform((d) => new Date(d)),
7931
+ data: SubscriptionSchema
7932
+ });
7890
7933
  var LicenseKeyCreatedPayloadSchema = objectType({
7891
7934
  business_id: stringType(),
7892
7935
  type: literalType("license_key.created"),
@@ -7915,9 +7958,679 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
7915
7958
  SubscriptionCancelledPayloadSchema,
7916
7959
  SubscriptionFailedPayloadSchema,
7917
7960
  SubscriptionExpiredPayloadSchema,
7961
+ SubscriptionUpdatedPayloadSchema,
7918
7962
  LicenseKeyCreatedPayloadSchema
7919
7963
  ]);
7920
7964
 
7965
+ // ../../node_modules/@stablelib/base64/lib/base64.js
7966
+ var require_base64 = __commonJS({
7967
+ "../../node_modules/@stablelib/base64/lib/base64.js"(exports) {
7968
+ var __extends = exports && exports.__extends || /* @__PURE__ */ function() {
7969
+ var extendStatics = function(d, b) {
7970
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
7971
+ d2.__proto__ = b2;
7972
+ } || function(d2, b2) {
7973
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
7974
+ };
7975
+ return extendStatics(d, b);
7976
+ };
7977
+ return function(d, b) {
7978
+ extendStatics(d, b);
7979
+ function __() {
7980
+ this.constructor = d;
7981
+ }
7982
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7983
+ };
7984
+ }();
7985
+ Object.defineProperty(exports, "__esModule", { value: true });
7986
+ var INVALID_BYTE = 256;
7987
+ var Coder = (
7988
+ /** @class */
7989
+ function() {
7990
+ function Coder2(_paddingCharacter) {
7991
+ if (_paddingCharacter === void 0) {
7992
+ _paddingCharacter = "=";
7993
+ }
7994
+ this._paddingCharacter = _paddingCharacter;
7995
+ }
7996
+ Coder2.prototype.encodedLength = function(length) {
7997
+ if (!this._paddingCharacter) {
7998
+ return (length * 8 + 5) / 6 | 0;
7999
+ }
8000
+ return (length + 2) / 3 * 4 | 0;
8001
+ };
8002
+ Coder2.prototype.encode = function(data) {
8003
+ var out = "";
8004
+ var i = 0;
8005
+ for (; i < data.length - 2; i += 3) {
8006
+ var c = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
8007
+ out += this._encodeByte(c >>> 3 * 6 & 63);
8008
+ out += this._encodeByte(c >>> 2 * 6 & 63);
8009
+ out += this._encodeByte(c >>> 1 * 6 & 63);
8010
+ out += this._encodeByte(c >>> 0 * 6 & 63);
8011
+ }
8012
+ var left = data.length - i;
8013
+ if (left > 0) {
8014
+ var c = data[i] << 16 | (left === 2 ? data[i + 1] << 8 : 0);
8015
+ out += this._encodeByte(c >>> 3 * 6 & 63);
8016
+ out += this._encodeByte(c >>> 2 * 6 & 63);
8017
+ if (left === 2) {
8018
+ out += this._encodeByte(c >>> 1 * 6 & 63);
8019
+ } else {
8020
+ out += this._paddingCharacter || "";
8021
+ }
8022
+ out += this._paddingCharacter || "";
8023
+ }
8024
+ return out;
8025
+ };
8026
+ Coder2.prototype.maxDecodedLength = function(length) {
8027
+ if (!this._paddingCharacter) {
8028
+ return (length * 6 + 7) / 8 | 0;
8029
+ }
8030
+ return length / 4 * 3 | 0;
8031
+ };
8032
+ Coder2.prototype.decodedLength = function(s) {
8033
+ return this.maxDecodedLength(s.length - this._getPaddingLength(s));
8034
+ };
8035
+ Coder2.prototype.decode = function(s) {
8036
+ if (s.length === 0) {
8037
+ return new Uint8Array(0);
8038
+ }
8039
+ var paddingLength = this._getPaddingLength(s);
8040
+ var length = s.length - paddingLength;
8041
+ var out = new Uint8Array(this.maxDecodedLength(length));
8042
+ var op = 0;
8043
+ var i = 0;
8044
+ var haveBad = 0;
8045
+ var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
8046
+ for (; i < length - 4; i += 4) {
8047
+ v0 = this._decodeChar(s.charCodeAt(i + 0));
8048
+ v1 = this._decodeChar(s.charCodeAt(i + 1));
8049
+ v2 = this._decodeChar(s.charCodeAt(i + 2));
8050
+ v3 = this._decodeChar(s.charCodeAt(i + 3));
8051
+ out[op++] = v0 << 2 | v1 >>> 4;
8052
+ out[op++] = v1 << 4 | v2 >>> 2;
8053
+ out[op++] = v2 << 6 | v3;
8054
+ haveBad |= v0 & INVALID_BYTE;
8055
+ haveBad |= v1 & INVALID_BYTE;
8056
+ haveBad |= v2 & INVALID_BYTE;
8057
+ haveBad |= v3 & INVALID_BYTE;
8058
+ }
8059
+ if (i < length - 1) {
8060
+ v0 = this._decodeChar(s.charCodeAt(i));
8061
+ v1 = this._decodeChar(s.charCodeAt(i + 1));
8062
+ out[op++] = v0 << 2 | v1 >>> 4;
8063
+ haveBad |= v0 & INVALID_BYTE;
8064
+ haveBad |= v1 & INVALID_BYTE;
8065
+ }
8066
+ if (i < length - 2) {
8067
+ v2 = this._decodeChar(s.charCodeAt(i + 2));
8068
+ out[op++] = v1 << 4 | v2 >>> 2;
8069
+ haveBad |= v2 & INVALID_BYTE;
8070
+ }
8071
+ if (i < length - 3) {
8072
+ v3 = this._decodeChar(s.charCodeAt(i + 3));
8073
+ out[op++] = v2 << 6 | v3;
8074
+ haveBad |= v3 & INVALID_BYTE;
8075
+ }
8076
+ if (haveBad !== 0) {
8077
+ throw new Error("Base64Coder: incorrect characters for decoding");
8078
+ }
8079
+ return out;
8080
+ };
8081
+ Coder2.prototype._encodeByte = function(b) {
8082
+ var result = b;
8083
+ result += 65;
8084
+ result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
8085
+ result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
8086
+ result += 61 - b >>> 8 & 52 - 48 - 62 + 43;
8087
+ result += 62 - b >>> 8 & 62 - 43 - 63 + 47;
8088
+ return String.fromCharCode(result);
8089
+ };
8090
+ Coder2.prototype._decodeChar = function(c) {
8091
+ var result = INVALID_BYTE;
8092
+ result += (42 - c & c - 44) >>> 8 & -INVALID_BYTE + c - 43 + 62;
8093
+ result += (46 - c & c - 48) >>> 8 & -INVALID_BYTE + c - 47 + 63;
8094
+ result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
8095
+ result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
8096
+ result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
8097
+ return result;
8098
+ };
8099
+ Coder2.prototype._getPaddingLength = function(s) {
8100
+ var paddingLength = 0;
8101
+ if (this._paddingCharacter) {
8102
+ for (var i = s.length - 1; i >= 0; i--) {
8103
+ if (s[i] !== this._paddingCharacter) {
8104
+ break;
8105
+ }
8106
+ paddingLength++;
8107
+ }
8108
+ if (s.length < 4 || paddingLength > 2) {
8109
+ throw new Error("Base64Coder: incorrect padding");
8110
+ }
8111
+ }
8112
+ return paddingLength;
8113
+ };
8114
+ return Coder2;
8115
+ }()
8116
+ );
8117
+ exports.Coder = Coder;
8118
+ var stdCoder = new Coder();
8119
+ function encode2(data) {
8120
+ return stdCoder.encode(data);
8121
+ }
8122
+ exports.encode = encode2;
8123
+ function decode2(s) {
8124
+ return stdCoder.decode(s);
8125
+ }
8126
+ exports.decode = decode2;
8127
+ var URLSafeCoder = (
8128
+ /** @class */
8129
+ function(_super) {
8130
+ __extends(URLSafeCoder2, _super);
8131
+ function URLSafeCoder2() {
8132
+ return _super !== null && _super.apply(this, arguments) || this;
8133
+ }
8134
+ URLSafeCoder2.prototype._encodeByte = function(b) {
8135
+ var result = b;
8136
+ result += 65;
8137
+ result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
8138
+ result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
8139
+ result += 61 - b >>> 8 & 52 - 48 - 62 + 45;
8140
+ result += 62 - b >>> 8 & 62 - 45 - 63 + 95;
8141
+ return String.fromCharCode(result);
8142
+ };
8143
+ URLSafeCoder2.prototype._decodeChar = function(c) {
8144
+ var result = INVALID_BYTE;
8145
+ result += (44 - c & c - 46) >>> 8 & -INVALID_BYTE + c - 45 + 62;
8146
+ result += (94 - c & c - 96) >>> 8 & -INVALID_BYTE + c - 95 + 63;
8147
+ result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
8148
+ result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
8149
+ result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
8150
+ return result;
8151
+ };
8152
+ return URLSafeCoder2;
8153
+ }(Coder)
8154
+ );
8155
+ exports.URLSafeCoder = URLSafeCoder;
8156
+ var urlSafeCoder = new URLSafeCoder();
8157
+ function encodeURLSafe(data) {
8158
+ return urlSafeCoder.encode(data);
8159
+ }
8160
+ exports.encodeURLSafe = encodeURLSafe;
8161
+ function decodeURLSafe(s) {
8162
+ return urlSafeCoder.decode(s);
8163
+ }
8164
+ exports.decodeURLSafe = decodeURLSafe;
8165
+ exports.encodedLength = function(length) {
8166
+ return stdCoder.encodedLength(length);
8167
+ };
8168
+ exports.maxDecodedLength = function(length) {
8169
+ return stdCoder.maxDecodedLength(length);
8170
+ };
8171
+ exports.decodedLength = function(s) {
8172
+ return stdCoder.decodedLength(s);
8173
+ };
8174
+ }
8175
+ });
8176
+
8177
+ // ../../node_modules/fast-sha256/sha256.js
8178
+ var require_sha256 = __commonJS({
8179
+ "../../node_modules/fast-sha256/sha256.js"(exports, module) {
8180
+ (function(root, factory) {
8181
+ var exports2 = {};
8182
+ factory(exports2);
8183
+ var sha2562 = exports2["default"];
8184
+ for (var k in exports2) {
8185
+ sha2562[k] = exports2[k];
8186
+ }
8187
+ if (typeof module === "object" && typeof module.exports === "object") {
8188
+ module.exports = sha2562;
8189
+ } else if (typeof define === "function" && define.amd) {
8190
+ define(function() {
8191
+ return sha2562;
8192
+ });
8193
+ } else {
8194
+ root.sha256 = sha2562;
8195
+ }
8196
+ })(exports, function(exports2) {
8197
+ exports2.__esModule = true;
8198
+ exports2.digestLength = 32;
8199
+ exports2.blockSize = 64;
8200
+ var K = new Uint32Array([
8201
+ 1116352408,
8202
+ 1899447441,
8203
+ 3049323471,
8204
+ 3921009573,
8205
+ 961987163,
8206
+ 1508970993,
8207
+ 2453635748,
8208
+ 2870763221,
8209
+ 3624381080,
8210
+ 310598401,
8211
+ 607225278,
8212
+ 1426881987,
8213
+ 1925078388,
8214
+ 2162078206,
8215
+ 2614888103,
8216
+ 3248222580,
8217
+ 3835390401,
8218
+ 4022224774,
8219
+ 264347078,
8220
+ 604807628,
8221
+ 770255983,
8222
+ 1249150122,
8223
+ 1555081692,
8224
+ 1996064986,
8225
+ 2554220882,
8226
+ 2821834349,
8227
+ 2952996808,
8228
+ 3210313671,
8229
+ 3336571891,
8230
+ 3584528711,
8231
+ 113926993,
8232
+ 338241895,
8233
+ 666307205,
8234
+ 773529912,
8235
+ 1294757372,
8236
+ 1396182291,
8237
+ 1695183700,
8238
+ 1986661051,
8239
+ 2177026350,
8240
+ 2456956037,
8241
+ 2730485921,
8242
+ 2820302411,
8243
+ 3259730800,
8244
+ 3345764771,
8245
+ 3516065817,
8246
+ 3600352804,
8247
+ 4094571909,
8248
+ 275423344,
8249
+ 430227734,
8250
+ 506948616,
8251
+ 659060556,
8252
+ 883997877,
8253
+ 958139571,
8254
+ 1322822218,
8255
+ 1537002063,
8256
+ 1747873779,
8257
+ 1955562222,
8258
+ 2024104815,
8259
+ 2227730452,
8260
+ 2361852424,
8261
+ 2428436474,
8262
+ 2756734187,
8263
+ 3204031479,
8264
+ 3329325298
8265
+ ]);
8266
+ function hashBlocks(w, v, p, pos, len) {
8267
+ var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
8268
+ while (len >= 64) {
8269
+ a = v[0];
8270
+ b = v[1];
8271
+ c = v[2];
8272
+ d = v[3];
8273
+ e = v[4];
8274
+ f = v[5];
8275
+ g = v[6];
8276
+ h = v[7];
8277
+ for (i = 0; i < 16; i++) {
8278
+ j = pos + i * 4;
8279
+ w[i] = (p[j] & 255) << 24 | (p[j + 1] & 255) << 16 | (p[j + 2] & 255) << 8 | p[j + 3] & 255;
8280
+ }
8281
+ for (i = 16; i < 64; i++) {
8282
+ u = w[i - 2];
8283
+ t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10;
8284
+ u = w[i - 15];
8285
+ t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3;
8286
+ w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
8287
+ }
8288
+ for (i = 0; i < 64; i++) {
8289
+ 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;
8290
+ t2 = ((a >>> 2 | a << 32 - 2) ^ (a >>> 13 | a << 32 - 13) ^ (a >>> 22 | a << 32 - 22)) + (a & b ^ a & c ^ b & c) | 0;
8291
+ h = g;
8292
+ g = f;
8293
+ f = e;
8294
+ e = d + t1 | 0;
8295
+ d = c;
8296
+ c = b;
8297
+ b = a;
8298
+ a = t1 + t2 | 0;
8299
+ }
8300
+ v[0] += a;
8301
+ v[1] += b;
8302
+ v[2] += c;
8303
+ v[3] += d;
8304
+ v[4] += e;
8305
+ v[5] += f;
8306
+ v[6] += g;
8307
+ v[7] += h;
8308
+ pos += 64;
8309
+ len -= 64;
8310
+ }
8311
+ return pos;
8312
+ }
8313
+ var Hash = (
8314
+ /** @class */
8315
+ function() {
8316
+ function Hash2() {
8317
+ this.digestLength = exports2.digestLength;
8318
+ this.blockSize = exports2.blockSize;
8319
+ this.state = new Int32Array(8);
8320
+ this.temp = new Int32Array(64);
8321
+ this.buffer = new Uint8Array(128);
8322
+ this.bufferLength = 0;
8323
+ this.bytesHashed = 0;
8324
+ this.finished = false;
8325
+ this.reset();
8326
+ }
8327
+ Hash2.prototype.reset = function() {
8328
+ this.state[0] = 1779033703;
8329
+ this.state[1] = 3144134277;
8330
+ this.state[2] = 1013904242;
8331
+ this.state[3] = 2773480762;
8332
+ this.state[4] = 1359893119;
8333
+ this.state[5] = 2600822924;
8334
+ this.state[6] = 528734635;
8335
+ this.state[7] = 1541459225;
8336
+ this.bufferLength = 0;
8337
+ this.bytesHashed = 0;
8338
+ this.finished = false;
8339
+ return this;
8340
+ };
8341
+ Hash2.prototype.clean = function() {
8342
+ for (var i = 0; i < this.buffer.length; i++) {
8343
+ this.buffer[i] = 0;
8344
+ }
8345
+ for (var i = 0; i < this.temp.length; i++) {
8346
+ this.temp[i] = 0;
8347
+ }
8348
+ this.reset();
8349
+ };
8350
+ Hash2.prototype.update = function(data, dataLength) {
8351
+ if (dataLength === void 0) {
8352
+ dataLength = data.length;
8353
+ }
8354
+ if (this.finished) {
8355
+ throw new Error("SHA256: can't update because hash was finished.");
8356
+ }
8357
+ var dataPos = 0;
8358
+ this.bytesHashed += dataLength;
8359
+ if (this.bufferLength > 0) {
8360
+ while (this.bufferLength < 64 && dataLength > 0) {
8361
+ this.buffer[this.bufferLength++] = data[dataPos++];
8362
+ dataLength--;
8363
+ }
8364
+ if (this.bufferLength === 64) {
8365
+ hashBlocks(this.temp, this.state, this.buffer, 0, 64);
8366
+ this.bufferLength = 0;
8367
+ }
8368
+ }
8369
+ if (dataLength >= 64) {
8370
+ dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
8371
+ dataLength %= 64;
8372
+ }
8373
+ while (dataLength > 0) {
8374
+ this.buffer[this.bufferLength++] = data[dataPos++];
8375
+ dataLength--;
8376
+ }
8377
+ return this;
8378
+ };
8379
+ Hash2.prototype.finish = function(out) {
8380
+ if (!this.finished) {
8381
+ var bytesHashed = this.bytesHashed;
8382
+ var left = this.bufferLength;
8383
+ var bitLenHi = bytesHashed / 536870912 | 0;
8384
+ var bitLenLo = bytesHashed << 3;
8385
+ var padLength = bytesHashed % 64 < 56 ? 64 : 128;
8386
+ this.buffer[left] = 128;
8387
+ for (var i = left + 1; i < padLength - 8; i++) {
8388
+ this.buffer[i] = 0;
8389
+ }
8390
+ this.buffer[padLength - 8] = bitLenHi >>> 24 & 255;
8391
+ this.buffer[padLength - 7] = bitLenHi >>> 16 & 255;
8392
+ this.buffer[padLength - 6] = bitLenHi >>> 8 & 255;
8393
+ this.buffer[padLength - 5] = bitLenHi >>> 0 & 255;
8394
+ this.buffer[padLength - 4] = bitLenLo >>> 24 & 255;
8395
+ this.buffer[padLength - 3] = bitLenLo >>> 16 & 255;
8396
+ this.buffer[padLength - 2] = bitLenLo >>> 8 & 255;
8397
+ this.buffer[padLength - 1] = bitLenLo >>> 0 & 255;
8398
+ hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
8399
+ this.finished = true;
8400
+ }
8401
+ for (var i = 0; i < 8; i++) {
8402
+ out[i * 4 + 0] = this.state[i] >>> 24 & 255;
8403
+ out[i * 4 + 1] = this.state[i] >>> 16 & 255;
8404
+ out[i * 4 + 2] = this.state[i] >>> 8 & 255;
8405
+ out[i * 4 + 3] = this.state[i] >>> 0 & 255;
8406
+ }
8407
+ return this;
8408
+ };
8409
+ Hash2.prototype.digest = function() {
8410
+ var out = new Uint8Array(this.digestLength);
8411
+ this.finish(out);
8412
+ return out;
8413
+ };
8414
+ Hash2.prototype._saveState = function(out) {
8415
+ for (var i = 0; i < this.state.length; i++) {
8416
+ out[i] = this.state[i];
8417
+ }
8418
+ };
8419
+ Hash2.prototype._restoreState = function(from, bytesHashed) {
8420
+ for (var i = 0; i < this.state.length; i++) {
8421
+ this.state[i] = from[i];
8422
+ }
8423
+ this.bytesHashed = bytesHashed;
8424
+ this.finished = false;
8425
+ this.bufferLength = 0;
8426
+ };
8427
+ return Hash2;
8428
+ }()
8429
+ );
8430
+ exports2.Hash = Hash;
8431
+ var HMAC = (
8432
+ /** @class */
8433
+ function() {
8434
+ function HMAC2(key) {
8435
+ this.inner = new Hash();
8436
+ this.outer = new Hash();
8437
+ this.blockSize = this.inner.blockSize;
8438
+ this.digestLength = this.inner.digestLength;
8439
+ var pad = new Uint8Array(this.blockSize);
8440
+ if (key.length > this.blockSize) {
8441
+ new Hash().update(key).finish(pad).clean();
8442
+ } else {
8443
+ for (var i = 0; i < key.length; i++) {
8444
+ pad[i] = key[i];
8445
+ }
8446
+ }
8447
+ for (var i = 0; i < pad.length; i++) {
8448
+ pad[i] ^= 54;
8449
+ }
8450
+ this.inner.update(pad);
8451
+ for (var i = 0; i < pad.length; i++) {
8452
+ pad[i] ^= 54 ^ 92;
8453
+ }
8454
+ this.outer.update(pad);
8455
+ this.istate = new Uint32Array(8);
8456
+ this.ostate = new Uint32Array(8);
8457
+ this.inner._saveState(this.istate);
8458
+ this.outer._saveState(this.ostate);
8459
+ for (var i = 0; i < pad.length; i++) {
8460
+ pad[i] = 0;
8461
+ }
8462
+ }
8463
+ HMAC2.prototype.reset = function() {
8464
+ this.inner._restoreState(this.istate, this.inner.blockSize);
8465
+ this.outer._restoreState(this.ostate, this.outer.blockSize);
8466
+ return this;
8467
+ };
8468
+ HMAC2.prototype.clean = function() {
8469
+ for (var i = 0; i < this.istate.length; i++) {
8470
+ this.ostate[i] = this.istate[i] = 0;
8471
+ }
8472
+ this.inner.clean();
8473
+ this.outer.clean();
8474
+ };
8475
+ HMAC2.prototype.update = function(data) {
8476
+ this.inner.update(data);
8477
+ return this;
8478
+ };
8479
+ HMAC2.prototype.finish = function(out) {
8480
+ if (this.outer.finished) {
8481
+ this.outer.finish(out);
8482
+ } else {
8483
+ this.inner.finish(out);
8484
+ this.outer.update(out, this.digestLength).finish(out);
8485
+ }
8486
+ return this;
8487
+ };
8488
+ HMAC2.prototype.digest = function() {
8489
+ var out = new Uint8Array(this.digestLength);
8490
+ this.finish(out);
8491
+ return out;
8492
+ };
8493
+ return HMAC2;
8494
+ }()
8495
+ );
8496
+ exports2.HMAC = HMAC;
8497
+ function hash(data) {
8498
+ var h = new Hash().update(data);
8499
+ var digest = h.digest();
8500
+ h.clean();
8501
+ return digest;
8502
+ }
8503
+ exports2.hash = hash;
8504
+ exports2["default"] = hash;
8505
+ function hmac2(key, data) {
8506
+ var h = new HMAC(key).update(data);
8507
+ var digest = h.digest();
8508
+ h.clean();
8509
+ return digest;
8510
+ }
8511
+ exports2.hmac = hmac2;
8512
+ function fillBuffer(buffer, hmac3, info, counter) {
8513
+ var num = counter[0];
8514
+ if (num === 0) {
8515
+ throw new Error("hkdf: cannot expand more");
8516
+ }
8517
+ hmac3.reset();
8518
+ if (num > 1) {
8519
+ hmac3.update(buffer);
8520
+ }
8521
+ if (info) {
8522
+ hmac3.update(info);
8523
+ }
8524
+ hmac3.update(counter);
8525
+ hmac3.finish(buffer);
8526
+ counter[0]++;
8527
+ }
8528
+ var hkdfSalt = new Uint8Array(exports2.digestLength);
8529
+ function hkdf(key, salt, info, length) {
8530
+ if (salt === void 0) {
8531
+ salt = hkdfSalt;
8532
+ }
8533
+ if (length === void 0) {
8534
+ length = 32;
8535
+ }
8536
+ var counter = new Uint8Array([1]);
8537
+ var okm = hmac2(salt, key);
8538
+ var hmac_ = new HMAC(okm);
8539
+ var buffer = new Uint8Array(hmac_.digestLength);
8540
+ var bufpos = buffer.length;
8541
+ var out = new Uint8Array(length);
8542
+ for (var i = 0; i < length; i++) {
8543
+ if (bufpos === buffer.length) {
8544
+ fillBuffer(buffer, hmac_, info, counter);
8545
+ bufpos = 0;
8546
+ }
8547
+ out[i] = buffer[bufpos++];
8548
+ }
8549
+ hmac_.clean();
8550
+ buffer.fill(0);
8551
+ counter.fill(0);
8552
+ return out;
8553
+ }
8554
+ exports2.hkdf = hkdf;
8555
+ function pbkdf2(password, salt, iterations, dkLen) {
8556
+ var prf = new HMAC(password);
8557
+ var len = prf.digestLength;
8558
+ var ctr = new Uint8Array(4);
8559
+ var t = new Uint8Array(len);
8560
+ var u = new Uint8Array(len);
8561
+ var dk = new Uint8Array(dkLen);
8562
+ for (var i = 0; i * len < dkLen; i++) {
8563
+ var c = i + 1;
8564
+ ctr[0] = c >>> 24 & 255;
8565
+ ctr[1] = c >>> 16 & 255;
8566
+ ctr[2] = c >>> 8 & 255;
8567
+ ctr[3] = c >>> 0 & 255;
8568
+ prf.reset();
8569
+ prf.update(salt);
8570
+ prf.update(ctr);
8571
+ prf.finish(u);
8572
+ for (var j = 0; j < len; j++) {
8573
+ t[j] = u[j];
8574
+ }
8575
+ for (var j = 2; j <= iterations; j++) {
8576
+ prf.reset();
8577
+ prf.update(u).finish(u);
8578
+ for (var k = 0; k < len; k++) {
8579
+ t[k] ^= u[k];
8580
+ }
8581
+ }
8582
+ for (var j = 0; j < len && i * len + j < dkLen; j++) {
8583
+ dk[i * len + j] = t[j];
8584
+ }
8585
+ }
8586
+ for (var i = 0; i < len; i++) {
8587
+ t[i] = u[i] = 0;
8588
+ }
8589
+ for (var i = 0; i < 4; i++) {
8590
+ ctr[i] = 0;
8591
+ }
8592
+ prf.clean();
8593
+ return dk;
8594
+ }
8595
+ exports2.pbkdf2 = pbkdf2;
8596
+ });
8597
+ }
8598
+ });
8599
+
8600
+ // src/webhook/vendor/standardwebhook.ts
8601
+ __toESM(require_base64());
8602
+ __toESM(require_sha256());
8603
+ /**
8604
+ * The MIT License
8605
+ *
8606
+ * Copyright (c) 2023 Svix (https://www.svix.com)
8607
+ *
8608
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8609
+ * of this software and associated documentation files (the "Software"), to deal
8610
+ * in the Software without restriction, including without limitation the rights
8611
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8612
+ * copies of the Software, and to permit persons to whom the Software is
8613
+ * furnished to do so, subject to the following conditions:
8614
+ *
8615
+ * The above copyright notice and this permission notice shall be included in
8616
+ * all copies or substantial portions of the Software.
8617
+ *
8618
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8619
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8620
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8621
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8622
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
8623
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
8624
+ * THE SOFTWARE.
8625
+ *
8626
+ * @fileoverview Server-only webhook verification implementation.
8627
+ * @description Vendored from standardwebhooks package to avoid bundling issues.
8628
+ * Uses Node.js crypto module - DO NOT import in client/browser code.
8629
+ * @license MIT
8630
+ * @internal
8631
+ */
8632
+
8633
+ // src/webhook/webhook.ts
7921
8634
  async function handleWebhookPayload(payload, config, context) {
7922
8635
  const callHandler = (handler, payload2) => {
7923
8636
  if (!handler) return;
@@ -7989,6 +8702,9 @@ async function handleWebhookPayload(payload, config, context) {
7989
8702
  if (payload.type === "subscription.expired") {
7990
8703
  await callHandler(config.onSubscriptionExpired, payload);
7991
8704
  }
8705
+ if (payload.type === "subscription.updated") {
8706
+ await callHandler(config.onSubscriptionUpdated, payload);
8707
+ }
7992
8708
  if (payload.type === "license_key.created") {
7993
8709
  await callHandler(config.onLicenseKeyCreated, payload);
7994
8710
  }