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