@dodopayments/convex 0.2.7 → 0.2.9

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
@@ -415,8 +415,8 @@ function convexOrUndefinedToJson(value) {
415
415
  return convexOrUndefinedToJsonInternal(value, value, "");
416
416
  }
417
417
 
418
- var __defProp$3 = Object.defineProperty;
419
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
418
+ var __defProp$4 = Object.defineProperty;
419
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
420
420
  var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
421
421
  var _a, _b;
422
422
  const IDENTIFYING_FIELD = Symbol.for("ConvexError");
@@ -531,8 +531,8 @@ function setupActionCalls(requestId) {
531
531
  };
532
532
  }
533
533
 
534
- var __defProp$2 = Object.defineProperty;
535
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
534
+ var __defProp$3 = Object.defineProperty;
535
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
536
536
  var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
537
537
  class FilterExpression {
538
538
  /**
@@ -554,8 +554,8 @@ function validateArg(arg, idx, method, argName) {
554
554
  }
555
555
  }
556
556
 
557
- var __defProp$1 = Object.defineProperty;
558
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
557
+ var __defProp$2 = Object.defineProperty;
558
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
559
559
  var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
560
560
  function setupActionVectorSearch(requestId) {
561
561
  return async (tableName, indexName, query) => {
@@ -832,8 +832,8 @@ const httpActionGeneric = (func) => {
832
832
  return q;
833
833
  };
834
834
 
835
- var __defProp = Object.defineProperty;
836
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
835
+ var __defProp$1 = Object.defineProperty;
836
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
837
837
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
838
838
  class InstalledComponent {
839
839
  constructor(definition, name) {
@@ -4962,23 +4962,33 @@ var PaymentSchema = objectType({
4962
4962
  payload_type: literalType("Payment"),
4963
4963
  billing: objectType({
4964
4964
  city: stringType().nullable(),
4965
- country: stringType().nullable(),
4965
+ country: stringType(),
4966
4966
  state: stringType().nullable(),
4967
4967
  street: stringType().nullable(),
4968
4968
  zipcode: stringType().nullable()
4969
4969
  }),
4970
4970
  brand_id: stringType(),
4971
4971
  business_id: stringType(),
4972
+ card_holder_name: stringType().nullable(),
4972
4973
  card_issuing_country: stringType().nullable(),
4973
4974
  card_last_four: stringType().nullable(),
4974
4975
  card_network: stringType().nullable(),
4975
4976
  card_type: stringType().nullable(),
4977
+ checkout_session_id: stringType().nullable(),
4976
4978
  created_at: stringType().transform((d) => new Date(d)),
4977
4979
  currency: stringType(),
4980
+ custom_field_responses: arrayType(
4981
+ objectType({
4982
+ key: stringType(),
4983
+ value: stringType()
4984
+ })
4985
+ ).nullable(),
4978
4986
  customer: objectType({
4979
4987
  customer_id: stringType(),
4980
4988
  email: stringType(),
4981
- name: stringType().nullable()
4989
+ metadata: recordType(anyType()),
4990
+ name: stringType(),
4991
+ phone_number: stringType().nullable()
4982
4992
  }),
4983
4993
  digital_products_delivered: booleanType(),
4984
4994
  discount_id: stringType().nullable(),
@@ -4989,27 +4999,25 @@ var PaymentSchema = objectType({
4989
4999
  created_at: stringType().transform((d) => new Date(d)),
4990
5000
  currency: stringType(),
4991
5001
  dispute_id: stringType(),
4992
- dispute_stage: enumType([
4993
- "pre_dispute",
4994
- "dispute_opened",
4995
- "dispute_won",
4996
- "dispute_lost"
4997
- ]),
5002
+ dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
4998
5003
  dispute_status: enumType([
4999
5004
  "dispute_opened",
5000
- "dispute_won",
5001
- "dispute_lost",
5005
+ "dispute_expired",
5002
5006
  "dispute_accepted",
5003
5007
  "dispute_cancelled",
5004
- "dispute_challenged"
5008
+ "dispute_challenged",
5009
+ "dispute_won",
5010
+ "dispute_lost"
5005
5011
  ]),
5006
5012
  payment_id: stringType(),
5007
5013
  remarks: stringType().nullable()
5008
5014
  })
5009
- ).nullable(),
5015
+ ).default([]),
5010
5016
  error_code: stringType().nullable(),
5011
5017
  error_message: stringType().nullable(),
5012
- metadata: recordType(anyType()).nullable(),
5018
+ invoice_id: stringType().nullable(),
5019
+ invoice_url: stringType().nullable(),
5020
+ metadata: recordType(anyType()),
5013
5021
  payment_id: stringType(),
5014
5022
  payment_link: stringType().nullable(),
5015
5023
  payment_method: stringType().nullable(),
@@ -5022,21 +5030,34 @@ var PaymentSchema = objectType({
5022
5030
  ).nullable(),
5023
5031
  refunds: arrayType(
5024
5032
  objectType({
5025
- amount: numberType(),
5033
+ amount: numberType().nullable(),
5026
5034
  business_id: stringType(),
5027
5035
  created_at: stringType().transform((d) => new Date(d)),
5028
- currency: stringType(),
5036
+ currency: stringType().nullable(),
5029
5037
  is_partial: booleanType(),
5030
5038
  payment_id: stringType(),
5031
5039
  reason: stringType().nullable(),
5032
5040
  refund_id: stringType(),
5033
- status: enumType(["succeeded", "failed", "pending"])
5041
+ status: enumType(["succeeded", "failed", "pending", "review"])
5034
5042
  })
5035
- ).nullable(),
5043
+ ),
5044
+ refund_status: enumType(["partial", "full"]).nullable(),
5036
5045
  settlement_amount: numberType(),
5037
5046
  settlement_currency: stringType(),
5038
5047
  settlement_tax: numberType().nullable(),
5039
- status: enumType(["succeeded", "failed", "pending", "processing", "cancelled"]),
5048
+ status: enumType([
5049
+ "succeeded",
5050
+ "failed",
5051
+ "cancelled",
5052
+ "processing",
5053
+ "requires_customer_action",
5054
+ "requires_merchant_action",
5055
+ "requires_payment_method",
5056
+ "requires_confirmation",
5057
+ "requires_capture",
5058
+ "partially_captured",
5059
+ "partially_captured_and_capturable"
5060
+ ]).nullable(),
5040
5061
  subscription_id: stringType().nullable(),
5041
5062
  tax: numberType().nullable(),
5042
5063
  total_amount: numberType(),
@@ -5049,10 +5070,10 @@ var SubscriptionSchema = objectType({
5049
5070
  addon_id: stringType(),
5050
5071
  quantity: numberType()
5051
5072
  })
5052
- ).nullable(),
5073
+ ),
5053
5074
  billing: objectType({
5054
5075
  city: stringType().nullable(),
5055
- country: stringType().nullable(),
5076
+ country: stringType(),
5056
5077
  state: stringType().nullable(),
5057
5078
  street: stringType().nullable(),
5058
5079
  zipcode: stringType().nullable()
@@ -5064,15 +5085,72 @@ var SubscriptionSchema = objectType({
5064
5085
  customer: objectType({
5065
5086
  customer_id: stringType(),
5066
5087
  email: stringType(),
5067
- name: stringType().nullable()
5088
+ metadata: recordType(anyType()),
5089
+ name: stringType(),
5090
+ phone_number: stringType().nullable()
5068
5091
  }),
5092
+ custom_field_responses: arrayType(
5093
+ objectType({
5094
+ key: stringType(),
5095
+ value: stringType()
5096
+ })
5097
+ ).nullable(),
5098
+ discount_cycles_remaining: numberType().nullable(),
5069
5099
  discount_id: stringType().nullable(),
5070
- metadata: recordType(anyType()).nullable(),
5071
- next_billing_date: stringType().transform((d) => new Date(d)).nullable(),
5100
+ expires_at: stringType().transform((d) => new Date(d)).nullable(),
5101
+ credit_entitlement_cart: arrayType(
5102
+ objectType({
5103
+ credit_entitlement_id: stringType(),
5104
+ credit_entitlement_name: stringType(),
5105
+ credits_amount: stringType(),
5106
+ overage_balance: stringType(),
5107
+ overage_behavior: enumType([
5108
+ "forgive_at_reset",
5109
+ "invoice_at_billing",
5110
+ "carry_deficit",
5111
+ "carry_deficit_auto_repay"
5112
+ ]),
5113
+ overage_enabled: booleanType(),
5114
+ product_id: stringType(),
5115
+ remaining_balance: stringType(),
5116
+ rollover_enabled: booleanType(),
5117
+ unit: stringType(),
5118
+ expires_after_days: numberType().nullable(),
5119
+ low_balance_threshold_percent: numberType().nullable(),
5120
+ max_rollover_count: numberType().nullable(),
5121
+ overage_limit: stringType().nullable(),
5122
+ rollover_percentage: numberType().nullable(),
5123
+ rollover_timeframe_count: numberType().nullable(),
5124
+ rollover_timeframe_interval: enumType(["Day", "Week", "Month", "Year"]).nullable()
5125
+ })
5126
+ ),
5127
+ meter_credit_entitlement_cart: arrayType(
5128
+ objectType({
5129
+ credit_entitlement_id: stringType(),
5130
+ meter_id: stringType(),
5131
+ meter_name: stringType(),
5132
+ meter_units_per_credit: stringType(),
5133
+ product_id: stringType()
5134
+ })
5135
+ ),
5136
+ meters: arrayType(
5137
+ objectType({
5138
+ currency: stringType(),
5139
+ description: stringType().nullable(),
5140
+ free_threshold: numberType(),
5141
+ measurement_unit: stringType(),
5142
+ meter_id: stringType(),
5143
+ name: stringType(),
5144
+ price_per_unit: stringType().nullable()
5145
+ })
5146
+ ),
5147
+ metadata: recordType(anyType()),
5148
+ next_billing_date: stringType().transform((d) => new Date(d)),
5072
5149
  on_demand: booleanType(),
5073
5150
  payment_frequency_count: numberType(),
5074
5151
  payment_frequency_interval: enumType(["Day", "Week", "Month", "Year"]),
5075
- previous_billing_date: stringType().transform((d) => new Date(d)).nullable(),
5152
+ payment_method_id: stringType().nullable(),
5153
+ previous_billing_date: stringType().transform((d) => new Date(d)),
5076
5154
  product_id: stringType(),
5077
5155
  quantity: numberType(),
5078
5156
  recurring_pre_tax_amount: numberType(),
@@ -5080,7 +5158,6 @@ var SubscriptionSchema = objectType({
5080
5158
  "pending",
5081
5159
  "active",
5082
5160
  "on_hold",
5083
- "paused",
5084
5161
  "cancelled",
5085
5162
  "expired",
5086
5163
  "failed"
@@ -5088,20 +5165,29 @@ var SubscriptionSchema = objectType({
5088
5165
  subscription_id: stringType(),
5089
5166
  subscription_period_count: numberType(),
5090
5167
  subscription_period_interval: enumType(["Day", "Week", "Month", "Year"]),
5168
+ tax_id: stringType().nullable(),
5091
5169
  tax_inclusive: booleanType(),
5092
5170
  trial_period_days: numberType()
5093
5171
  });
5094
5172
  var RefundSchema = objectType({
5095
5173
  payload_type: literalType("Refund"),
5096
- amount: numberType(),
5174
+ amount: numberType().nullable(),
5097
5175
  business_id: stringType(),
5098
5176
  created_at: stringType().transform((d) => new Date(d)),
5099
- currency: stringType(),
5177
+ customer: objectType({
5178
+ customer_id: stringType(),
5179
+ email: stringType(),
5180
+ metadata: recordType(anyType()),
5181
+ name: stringType(),
5182
+ phone_number: stringType().nullable()
5183
+ }),
5184
+ currency: stringType().nullable(),
5100
5185
  is_partial: booleanType(),
5186
+ metadata: recordType(anyType()),
5101
5187
  payment_id: stringType(),
5102
5188
  reason: stringType().nullable(),
5103
5189
  refund_id: stringType(),
5104
- status: enumType(["succeeded", "failed", "pending"])
5190
+ status: enumType(["succeeded", "failed", "pending", "review"])
5105
5191
  });
5106
5192
  var DisputeSchema = objectType({
5107
5193
  payload_type: literalType("Dispute"),
@@ -5109,27 +5195,31 @@ var DisputeSchema = objectType({
5109
5195
  business_id: stringType(),
5110
5196
  created_at: stringType().transform((d) => new Date(d)),
5111
5197
  currency: stringType(),
5198
+ customer: objectType({
5199
+ customer_id: stringType(),
5200
+ email: stringType(),
5201
+ metadata: recordType(anyType()),
5202
+ name: stringType(),
5203
+ phone_number: stringType().nullable()
5204
+ }),
5112
5205
  dispute_id: stringType(),
5113
- dispute_stage: enumType([
5114
- "pre_dispute",
5115
- "dispute_opened",
5116
- "dispute_won",
5117
- "dispute_lost"
5118
- ]),
5206
+ dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
5119
5207
  dispute_status: enumType([
5120
5208
  "dispute_opened",
5121
- "dispute_won",
5122
- "dispute_lost",
5209
+ "dispute_expired",
5123
5210
  "dispute_accepted",
5124
5211
  "dispute_cancelled",
5125
- "dispute_challenged"
5212
+ "dispute_challenged",
5213
+ "dispute_won",
5214
+ "dispute_lost"
5126
5215
  ]),
5127
5216
  payment_id: stringType(),
5217
+ reason: stringType().nullable(),
5128
5218
  remarks: stringType().nullable()
5129
5219
  });
5130
5220
  var LicenseKeySchema = objectType({
5131
5221
  payload_type: literalType("LicenseKey"),
5132
- activations_limit: numberType(),
5222
+ activations_limit: numberType().nullable(),
5133
5223
  business_id: stringType(),
5134
5224
  created_at: stringType().transform((d) => new Date(d)),
5135
5225
  customer_id: stringType(),
@@ -5139,7 +5229,7 @@ var LicenseKeySchema = objectType({
5139
5229
  key: stringType(),
5140
5230
  payment_id: stringType(),
5141
5231
  product_id: stringType(),
5142
- status: enumType(["active", "inactive", "expired"]),
5232
+ status: enumType(["active", "expired", "disabled"]),
5143
5233
  subscription_id: stringType().nullable()
5144
5234
  });
5145
5235
  var PaymentSucceededPayloadSchema = objectType({
@@ -5238,12 +5328,6 @@ var SubscriptionRenewedPayloadSchema = objectType({
5238
5328
  timestamp: stringType().transform((d) => new Date(d)),
5239
5329
  data: SubscriptionSchema
5240
5330
  });
5241
- var SubscriptionPausedPayloadSchema = objectType({
5242
- business_id: stringType(),
5243
- type: literalType("subscription.paused"),
5244
- timestamp: stringType().transform((d) => new Date(d)),
5245
- data: SubscriptionSchema
5246
- });
5247
5331
  var SubscriptionPlanChangedPayloadSchema = objectType({
5248
5332
  business_id: stringType(),
5249
5333
  type: literalType("subscription.plan_changed"),
@@ -5280,6 +5364,94 @@ var LicenseKeyCreatedPayloadSchema = objectType({
5280
5364
  timestamp: stringType().transform((d) => new Date(d)),
5281
5365
  data: LicenseKeySchema
5282
5366
  });
5367
+ var CreditLedgerEntrySchema = objectType({
5368
+ payload_type: literalType("CreditLedgerEntry"),
5369
+ id: stringType(),
5370
+ amount: stringType(),
5371
+ balance_after: stringType(),
5372
+ balance_before: stringType(),
5373
+ business_id: stringType(),
5374
+ created_at: stringType().transform((d) => new Date(d)),
5375
+ credit_entitlement_id: stringType(),
5376
+ customer_id: stringType(),
5377
+ is_credit: booleanType(),
5378
+ overage_after: stringType(),
5379
+ overage_before: stringType(),
5380
+ transaction_type: enumType([
5381
+ "credit_added",
5382
+ "credit_deducted",
5383
+ "credit_expired",
5384
+ "credit_rolled_over",
5385
+ "rollover_forfeited",
5386
+ "overage_charged",
5387
+ "auto_top_up",
5388
+ "manual_adjustment",
5389
+ "refund"
5390
+ ]),
5391
+ description: stringType().nullable(),
5392
+ grant_id: stringType().nullable(),
5393
+ reference_id: stringType().nullable(),
5394
+ reference_type: stringType().nullable()
5395
+ });
5396
+ var CreditBalanceLowSchema = objectType({
5397
+ payload_type: literalType("CreditBalanceLow"),
5398
+ customer_id: stringType(),
5399
+ subscription_id: stringType(),
5400
+ credit_entitlement_id: stringType(),
5401
+ credit_entitlement_name: stringType(),
5402
+ available_balance: stringType(),
5403
+ subscription_credits_amount: stringType(),
5404
+ threshold_percent: numberType(),
5405
+ threshold_amount: stringType()
5406
+ });
5407
+ var CreditAddedPayloadSchema = objectType({
5408
+ business_id: stringType(),
5409
+ type: literalType("credit.added"),
5410
+ timestamp: stringType().transform((d) => new Date(d)),
5411
+ data: CreditLedgerEntrySchema
5412
+ });
5413
+ var CreditDeductedPayloadSchema = objectType({
5414
+ business_id: stringType(),
5415
+ type: literalType("credit.deducted"),
5416
+ timestamp: stringType().transform((d) => new Date(d)),
5417
+ data: CreditLedgerEntrySchema
5418
+ });
5419
+ var CreditExpiredPayloadSchema = objectType({
5420
+ business_id: stringType(),
5421
+ type: literalType("credit.expired"),
5422
+ timestamp: stringType().transform((d) => new Date(d)),
5423
+ data: CreditLedgerEntrySchema
5424
+ });
5425
+ var CreditRolledOverPayloadSchema = objectType({
5426
+ business_id: stringType(),
5427
+ type: literalType("credit.rolled_over"),
5428
+ timestamp: stringType().transform((d) => new Date(d)),
5429
+ data: CreditLedgerEntrySchema
5430
+ });
5431
+ var CreditRolloverForfeitedPayloadSchema = objectType({
5432
+ business_id: stringType(),
5433
+ type: literalType("credit.rollover_forfeited"),
5434
+ timestamp: stringType().transform((d) => new Date(d)),
5435
+ data: CreditLedgerEntrySchema
5436
+ });
5437
+ var CreditOverageChargedPayloadSchema = objectType({
5438
+ business_id: stringType(),
5439
+ type: literalType("credit.overage_charged"),
5440
+ timestamp: stringType().transform((d) => new Date(d)),
5441
+ data: CreditLedgerEntrySchema
5442
+ });
5443
+ var CreditManualAdjustmentPayloadSchema = objectType({
5444
+ business_id: stringType(),
5445
+ type: literalType("credit.manual_adjustment"),
5446
+ timestamp: stringType().transform((d) => new Date(d)),
5447
+ data: CreditLedgerEntrySchema
5448
+ });
5449
+ var CreditBalanceLowPayloadSchema = objectType({
5450
+ business_id: stringType(),
5451
+ type: literalType("credit.balance_low"),
5452
+ timestamp: stringType().transform((d) => new Date(d)),
5453
+ data: CreditBalanceLowSchema
5454
+ });
5283
5455
  var WebhookPayloadSchema = discriminatedUnionType("type", [
5284
5456
  PaymentSucceededPayloadSchema,
5285
5457
  PaymentFailedPayloadSchema,
@@ -5297,866 +5469,840 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
5297
5469
  SubscriptionActivePayloadSchema,
5298
5470
  SubscriptionOnHoldPayloadSchema,
5299
5471
  SubscriptionRenewedPayloadSchema,
5300
- SubscriptionPausedPayloadSchema,
5301
5472
  SubscriptionPlanChangedPayloadSchema,
5302
5473
  SubscriptionCancelledPayloadSchema,
5303
5474
  SubscriptionFailedPayloadSchema,
5304
5475
  SubscriptionExpiredPayloadSchema,
5305
5476
  SubscriptionUpdatedPayloadSchema,
5306
- LicenseKeyCreatedPayloadSchema
5477
+ LicenseKeyCreatedPayloadSchema,
5478
+ CreditAddedPayloadSchema,
5479
+ CreditDeductedPayloadSchema,
5480
+ CreditExpiredPayloadSchema,
5481
+ CreditRolledOverPayloadSchema,
5482
+ CreditRolloverForfeitedPayloadSchema,
5483
+ CreditOverageChargedPayloadSchema,
5484
+ CreditManualAdjustmentPayloadSchema,
5485
+ CreditBalanceLowPayloadSchema
5307
5486
  ]);
5308
5487
 
5309
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5310
-
5311
- var dist = {};
5312
-
5313
- var timing_safe_equal = {};
5314
-
5315
- Object.defineProperty(timing_safe_equal, "__esModule", { value: true });
5316
- timing_safe_equal.timingSafeEqual = void 0;
5488
+ // src/webhook/vendor/timing_safe_equal.ts
5317
5489
  function assert(expr, msg = "") {
5318
- if (!expr) {
5319
- throw new Error(msg);
5320
- }
5490
+ if (!expr) {
5491
+ throw new Error(msg);
5492
+ }
5321
5493
  }
5322
5494
  function timingSafeEqual(a, b) {
5323
- if (a.byteLength !== b.byteLength) {
5324
- return false;
5325
- }
5326
- if (!(a instanceof DataView)) {
5327
- a = new DataView(ArrayBuffer.isView(a) ? a.buffer : a);
5328
- }
5329
- if (!(b instanceof DataView)) {
5330
- b = new DataView(ArrayBuffer.isView(b) ? b.buffer : b);
5331
- }
5332
- assert(a instanceof DataView);
5333
- assert(b instanceof DataView);
5334
- const length = a.byteLength;
5335
- let out = 0;
5336
- let i = -1;
5337
- while (++i < length) {
5338
- out |= a.getUint8(i) ^ b.getUint8(i);
5339
- }
5340
- return out === 0;
5495
+ if (a.byteLength !== b.byteLength) {
5496
+ return false;
5497
+ }
5498
+ if (!(a instanceof DataView)) {
5499
+ a = new DataView(ArrayBuffer.isView(a) ? a.buffer : a);
5500
+ }
5501
+ if (!(b instanceof DataView)) {
5502
+ b = new DataView(ArrayBuffer.isView(b) ? b.buffer : b);
5503
+ }
5504
+ assert(a instanceof DataView);
5505
+ assert(b instanceof DataView);
5506
+ const length = a.byteLength;
5507
+ let out = 0;
5508
+ let i = -1;
5509
+ while (++i < length) {
5510
+ out |= a.getUint8(i) ^ b.getUint8(i);
5511
+ }
5512
+ return out === 0;
5341
5513
  }
5342
- timing_safe_equal.timingSafeEqual = timingSafeEqual;
5343
5514
 
5344
- var base64$1 = {};
5515
+ var __create = Object.create;
5516
+ var __defProp = Object.defineProperty;
5517
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5518
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5519
+ var __getProtoOf = Object.getPrototypeOf;
5520
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5521
+ var __commonJS = (cb, mod) => function __require2() {
5522
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
5523
+ };
5524
+ var __copyProps = (to, from, except, desc) => {
5525
+ if (from && typeof from === "object" || typeof from === "function") {
5526
+ for (let key of __getOwnPropNames(from))
5527
+ if (!__hasOwnProp.call(to, key) && key !== except)
5528
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
5529
+ }
5530
+ return to;
5531
+ };
5532
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
5533
+ // If the importer is in node compatibility mode or this is not an ESM
5534
+ // file that has been converted to a CommonJS file using a Babel-
5535
+ // compatible transform (i.e. "__esModule" has not been set), then set
5536
+ // "default" to the CommonJS "module.exports" for node compatibility.
5537
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
5538
+ mod
5539
+ ));
5345
5540
 
5346
- // Copyright (C) 2016 Dmitry Chestnykh
5347
- // MIT License. See LICENSE file for details.
5348
- var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
5349
- var extendStatics = function (d, b) {
5350
- extendStatics = Object.setPrototypeOf ||
5351
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5352
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5541
+ // ../../node_modules/@stablelib/base64/lib/base64.js
5542
+ var require_base64 = __commonJS({
5543
+ "../../node_modules/@stablelib/base64/lib/base64.js"(exports) {
5544
+ var __extends = exports && exports.__extends || /* @__PURE__ */ function() {
5545
+ var extendStatics = function(d, b) {
5546
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
5547
+ d2.__proto__ = b2;
5548
+ } || function(d2, b2) {
5549
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
5550
+ };
5353
5551
  return extendStatics(d, b);
5354
- };
5355
- return function (d, b) {
5552
+ };
5553
+ return function(d, b) {
5356
5554
  extendStatics(d, b);
5357
- function __() { this.constructor = d; }
5555
+ function __() {
5556
+ this.constructor = d;
5557
+ }
5358
5558
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5359
- };
5360
- })();
5361
- Object.defineProperty(base64$1, "__esModule", { value: true });
5362
- /**
5363
- * Package base64 implements Base64 encoding and decoding.
5364
- */
5365
- // Invalid character used in decoding to indicate
5366
- // that the character to decode is out of range of
5367
- // alphabet and cannot be decoded.
5368
- var INVALID_BYTE = 256;
5369
- /**
5370
- * Implements standard Base64 encoding.
5371
- *
5372
- * Operates in constant time.
5373
- */
5374
- var Coder = /** @class */ (function () {
5375
- // TODO(dchest): methods to encode chunk-by-chunk.
5376
- function Coder(_paddingCharacter) {
5377
- if (_paddingCharacter === void 0) { _paddingCharacter = "="; }
5378
- this._paddingCharacter = _paddingCharacter;
5379
- }
5380
- Coder.prototype.encodedLength = function (length) {
5381
- if (!this._paddingCharacter) {
5559
+ };
5560
+ }();
5561
+ Object.defineProperty(exports, "__esModule", { value: true });
5562
+ var INVALID_BYTE = 256;
5563
+ var Coder = (
5564
+ /** @class */
5565
+ function() {
5566
+ function Coder2(_paddingCharacter) {
5567
+ if (_paddingCharacter === void 0) {
5568
+ _paddingCharacter = "=";
5569
+ }
5570
+ this._paddingCharacter = _paddingCharacter;
5571
+ }
5572
+ Coder2.prototype.encodedLength = function(length) {
5573
+ if (!this._paddingCharacter) {
5382
5574
  return (length * 8 + 5) / 6 | 0;
5383
- }
5384
- return (length + 2) / 3 * 4 | 0;
5385
- };
5386
- Coder.prototype.encode = function (data) {
5387
- var out = "";
5388
- var i = 0;
5389
- for (; i < data.length - 2; i += 3) {
5390
- var c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);
5391
- out += this._encodeByte((c >>> 3 * 6) & 63);
5392
- out += this._encodeByte((c >>> 2 * 6) & 63);
5393
- out += this._encodeByte((c >>> 1 * 6) & 63);
5394
- out += this._encodeByte((c >>> 0 * 6) & 63);
5395
- }
5396
- var left = data.length - i;
5397
- if (left > 0) {
5398
- var c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);
5399
- out += this._encodeByte((c >>> 3 * 6) & 63);
5400
- out += this._encodeByte((c >>> 2 * 6) & 63);
5575
+ }
5576
+ return (length + 2) / 3 * 4 | 0;
5577
+ };
5578
+ Coder2.prototype.encode = function(data) {
5579
+ var out = "";
5580
+ var i = 0;
5581
+ for (; i < data.length - 2; i += 3) {
5582
+ var c = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
5583
+ out += this._encodeByte(c >>> 3 * 6 & 63);
5584
+ out += this._encodeByte(c >>> 2 * 6 & 63);
5585
+ out += this._encodeByte(c >>> 1 * 6 & 63);
5586
+ out += this._encodeByte(c >>> 0 * 6 & 63);
5587
+ }
5588
+ var left = data.length - i;
5589
+ if (left > 0) {
5590
+ var c = data[i] << 16 | (left === 2 ? data[i + 1] << 8 : 0);
5591
+ out += this._encodeByte(c >>> 3 * 6 & 63);
5592
+ out += this._encodeByte(c >>> 2 * 6 & 63);
5401
5593
  if (left === 2) {
5402
- out += this._encodeByte((c >>> 1 * 6) & 63);
5403
- }
5404
- else {
5405
- out += this._paddingCharacter || "";
5594
+ out += this._encodeByte(c >>> 1 * 6 & 63);
5595
+ } else {
5596
+ out += this._paddingCharacter || "";
5406
5597
  }
5407
5598
  out += this._paddingCharacter || "";
5408
- }
5409
- return out;
5410
- };
5411
- Coder.prototype.maxDecodedLength = function (length) {
5412
- if (!this._paddingCharacter) {
5599
+ }
5600
+ return out;
5601
+ };
5602
+ Coder2.prototype.maxDecodedLength = function(length) {
5603
+ if (!this._paddingCharacter) {
5413
5604
  return (length * 6 + 7) / 8 | 0;
5414
- }
5415
- return length / 4 * 3 | 0;
5416
- };
5417
- Coder.prototype.decodedLength = function (s) {
5418
- return this.maxDecodedLength(s.length - this._getPaddingLength(s));
5419
- };
5420
- Coder.prototype.decode = function (s) {
5421
- if (s.length === 0) {
5605
+ }
5606
+ return length / 4 * 3 | 0;
5607
+ };
5608
+ Coder2.prototype.decodedLength = function(s) {
5609
+ return this.maxDecodedLength(s.length - this._getPaddingLength(s));
5610
+ };
5611
+ Coder2.prototype.decode = function(s) {
5612
+ if (s.length === 0) {
5422
5613
  return new Uint8Array(0);
5423
- }
5424
- var paddingLength = this._getPaddingLength(s);
5425
- var length = s.length - paddingLength;
5426
- var out = new Uint8Array(this.maxDecodedLength(length));
5427
- var op = 0;
5428
- var i = 0;
5429
- var haveBad = 0;
5430
- var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
5431
- for (; i < length - 4; i += 4) {
5614
+ }
5615
+ var paddingLength = this._getPaddingLength(s);
5616
+ var length = s.length - paddingLength;
5617
+ var out = new Uint8Array(this.maxDecodedLength(length));
5618
+ var op = 0;
5619
+ var i = 0;
5620
+ var haveBad = 0;
5621
+ var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
5622
+ for (; i < length - 4; i += 4) {
5432
5623
  v0 = this._decodeChar(s.charCodeAt(i + 0));
5433
5624
  v1 = this._decodeChar(s.charCodeAt(i + 1));
5434
5625
  v2 = this._decodeChar(s.charCodeAt(i + 2));
5435
5626
  v3 = this._decodeChar(s.charCodeAt(i + 3));
5436
- out[op++] = (v0 << 2) | (v1 >>> 4);
5437
- out[op++] = (v1 << 4) | (v2 >>> 2);
5438
- out[op++] = (v2 << 6) | v3;
5627
+ out[op++] = v0 << 2 | v1 >>> 4;
5628
+ out[op++] = v1 << 4 | v2 >>> 2;
5629
+ out[op++] = v2 << 6 | v3;
5439
5630
  haveBad |= v0 & INVALID_BYTE;
5440
5631
  haveBad |= v1 & INVALID_BYTE;
5441
5632
  haveBad |= v2 & INVALID_BYTE;
5442
5633
  haveBad |= v3 & INVALID_BYTE;
5443
- }
5444
- if (i < length - 1) {
5634
+ }
5635
+ if (i < length - 1) {
5445
5636
  v0 = this._decodeChar(s.charCodeAt(i));
5446
5637
  v1 = this._decodeChar(s.charCodeAt(i + 1));
5447
- out[op++] = (v0 << 2) | (v1 >>> 4);
5638
+ out[op++] = v0 << 2 | v1 >>> 4;
5448
5639
  haveBad |= v0 & INVALID_BYTE;
5449
5640
  haveBad |= v1 & INVALID_BYTE;
5450
- }
5451
- if (i < length - 2) {
5641
+ }
5642
+ if (i < length - 2) {
5452
5643
  v2 = this._decodeChar(s.charCodeAt(i + 2));
5453
- out[op++] = (v1 << 4) | (v2 >>> 2);
5644
+ out[op++] = v1 << 4 | v2 >>> 2;
5454
5645
  haveBad |= v2 & INVALID_BYTE;
5455
- }
5456
- if (i < length - 3) {
5646
+ }
5647
+ if (i < length - 3) {
5457
5648
  v3 = this._decodeChar(s.charCodeAt(i + 3));
5458
- out[op++] = (v2 << 6) | v3;
5649
+ out[op++] = v2 << 6 | v3;
5459
5650
  haveBad |= v3 & INVALID_BYTE;
5460
- }
5461
- if (haveBad !== 0) {
5651
+ }
5652
+ if (haveBad !== 0) {
5462
5653
  throw new Error("Base64Coder: incorrect characters for decoding");
5463
- }
5464
- return out;
5465
- };
5466
- // Standard encoding have the following encoded/decoded ranges,
5467
- // which we need to convert between.
5468
- //
5469
- // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /
5470
- // Index: 0 - 25 26 - 51 52 - 61 62 63
5471
- // ASCII: 65 - 90 97 - 122 48 - 57 43 47
5472
- //
5473
- // Encode 6 bits in b into a new character.
5474
- Coder.prototype._encodeByte = function (b) {
5475
- // Encoding uses constant time operations as follows:
5476
- //
5477
- // 1. Define comparison of A with B using (A - B) >>> 8:
5478
- // if A > B, then result is positive integer
5479
- // if A <= B, then result is 0
5480
- //
5481
- // 2. Define selection of C or 0 using bitwise AND: X & C:
5482
- // if X == 0, then result is 0
5483
- // if X != 0, then result is C
5484
- //
5485
- // 3. Start with the smallest comparison (b >= 0), which is always
5486
- // true, so set the result to the starting ASCII value (65).
5487
- //
5488
- // 4. Continue comparing b to higher ASCII values, and selecting
5489
- // zero if comparison isn't true, otherwise selecting a value
5490
- // to add to result, which:
5491
- //
5492
- // a) undoes the previous addition
5493
- // b) provides new value to add
5494
- //
5495
- var result = b;
5496
- // b >= 0
5497
- result += 65;
5498
- // b > 25
5499
- result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);
5500
- // b > 51
5501
- result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);
5502
- // b > 61
5503
- result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);
5504
- // b > 62
5505
- result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);
5506
- return String.fromCharCode(result);
5507
- };
5508
- // Decode a character code into a byte.
5509
- // Must return 256 if character is out of alphabet range.
5510
- Coder.prototype._decodeChar = function (c) {
5511
- // Decoding works similar to encoding: using the same comparison
5512
- // function, but now it works on ranges: result is always incremented
5513
- // by value, but this value becomes zero if the range is not
5514
- // satisfied.
5515
- //
5516
- // Decoding starts with invalid value, 256, which is then
5517
- // subtracted when the range is satisfied. If none of the ranges
5518
- // apply, the function returns 256, which is then checked by
5519
- // the caller to throw error.
5520
- var result = INVALID_BYTE; // start with invalid character
5521
- // c == 43 (c > 42 and c < 44)
5522
- result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);
5523
- // c == 47 (c > 46 and c < 48)
5524
- result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);
5525
- // c > 47 and c < 58
5526
- result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);
5527
- // c > 64 and c < 91
5528
- result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);
5529
- // c > 96 and c < 123
5530
- result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);
5531
- return result;
5532
- };
5533
- Coder.prototype._getPaddingLength = function (s) {
5534
- var paddingLength = 0;
5535
- if (this._paddingCharacter) {
5654
+ }
5655
+ return out;
5656
+ };
5657
+ Coder2.prototype._encodeByte = function(b) {
5658
+ var result = b;
5659
+ result += 65;
5660
+ result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
5661
+ result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
5662
+ result += 61 - b >>> 8 & 52 - 48 - 62 + 43;
5663
+ result += 62 - b >>> 8 & 62 - 43 - 63 + 47;
5664
+ return String.fromCharCode(result);
5665
+ };
5666
+ Coder2.prototype._decodeChar = function(c) {
5667
+ var result = INVALID_BYTE;
5668
+ result += (42 - c & c - 44) >>> 8 & -INVALID_BYTE + c - 43 + 62;
5669
+ result += (46 - c & c - 48) >>> 8 & -INVALID_BYTE + c - 47 + 63;
5670
+ result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
5671
+ result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
5672
+ result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
5673
+ return result;
5674
+ };
5675
+ Coder2.prototype._getPaddingLength = function(s) {
5676
+ var paddingLength = 0;
5677
+ if (this._paddingCharacter) {
5536
5678
  for (var i = s.length - 1; i >= 0; i--) {
5537
- if (s[i] !== this._paddingCharacter) {
5538
- break;
5539
- }
5540
- paddingLength++;
5679
+ if (s[i] !== this._paddingCharacter) {
5680
+ break;
5681
+ }
5682
+ paddingLength++;
5541
5683
  }
5542
5684
  if (s.length < 4 || paddingLength > 2) {
5543
- throw new Error("Base64Coder: incorrect padding");
5685
+ throw new Error("Base64Coder: incorrect padding");
5544
5686
  }
5545
- }
5546
- return paddingLength;
5687
+ }
5688
+ return paddingLength;
5689
+ };
5690
+ return Coder2;
5691
+ }()
5692
+ );
5693
+ exports.Coder = Coder;
5694
+ var stdCoder = new Coder();
5695
+ function encode2(data) {
5696
+ return stdCoder.encode(data);
5697
+ }
5698
+ exports.encode = encode2;
5699
+ function decode2(s) {
5700
+ return stdCoder.decode(s);
5701
+ }
5702
+ exports.decode = decode2;
5703
+ var URLSafeCoder = (
5704
+ /** @class */
5705
+ function(_super) {
5706
+ __extends(URLSafeCoder2, _super);
5707
+ function URLSafeCoder2() {
5708
+ return _super !== null && _super.apply(this, arguments) || this;
5709
+ }
5710
+ URLSafeCoder2.prototype._encodeByte = function(b) {
5711
+ var result = b;
5712
+ result += 65;
5713
+ result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
5714
+ result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
5715
+ result += 61 - b >>> 8 & 52 - 48 - 62 + 45;
5716
+ result += 62 - b >>> 8 & 62 - 45 - 63 + 95;
5717
+ return String.fromCharCode(result);
5718
+ };
5719
+ URLSafeCoder2.prototype._decodeChar = function(c) {
5720
+ var result = INVALID_BYTE;
5721
+ result += (44 - c & c - 46) >>> 8 & -INVALID_BYTE + c - 45 + 62;
5722
+ result += (94 - c & c - 96) >>> 8 & -INVALID_BYTE + c - 95 + 63;
5723
+ result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
5724
+ result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
5725
+ result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
5726
+ return result;
5727
+ };
5728
+ return URLSafeCoder2;
5729
+ }(Coder)
5730
+ );
5731
+ exports.URLSafeCoder = URLSafeCoder;
5732
+ var urlSafeCoder = new URLSafeCoder();
5733
+ function encodeURLSafe(data) {
5734
+ return urlSafeCoder.encode(data);
5735
+ }
5736
+ exports.encodeURLSafe = encodeURLSafe;
5737
+ function decodeURLSafe(s) {
5738
+ return urlSafeCoder.decode(s);
5739
+ }
5740
+ exports.decodeURLSafe = decodeURLSafe;
5741
+ exports.encodedLength = function(length) {
5742
+ return stdCoder.encodedLength(length);
5547
5743
  };
5548
- return Coder;
5549
- }());
5550
- base64$1.Coder = Coder;
5551
- var stdCoder = new Coder();
5552
- function encode(data) {
5553
- return stdCoder.encode(data);
5554
- }
5555
- base64$1.encode = encode;
5556
- function decode(s) {
5557
- return stdCoder.decode(s);
5558
- }
5559
- base64$1.decode = decode;
5560
- /**
5561
- * Implements URL-safe Base64 encoding.
5562
- * (Same as Base64, but '+' is replaced with '-', and '/' with '_').
5563
- *
5564
- * Operates in constant time.
5565
- */
5566
- var URLSafeCoder = /** @class */ (function (_super) {
5567
- __extends(URLSafeCoder, _super);
5568
- function URLSafeCoder() {
5569
- return _super !== null && _super.apply(this, arguments) || this;
5570
- }
5571
- // URL-safe encoding have the following encoded/decoded ranges:
5572
- //
5573
- // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _
5574
- // Index: 0 - 25 26 - 51 52 - 61 62 63
5575
- // ASCII: 65 - 90 97 - 122 48 - 57 45 95
5576
- //
5577
- URLSafeCoder.prototype._encodeByte = function (b) {
5578
- var result = b;
5579
- // b >= 0
5580
- result += 65;
5581
- // b > 25
5582
- result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);
5583
- // b > 51
5584
- result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);
5585
- // b > 61
5586
- result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);
5587
- // b > 62
5588
- result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);
5589
- return String.fromCharCode(result);
5744
+ exports.maxDecodedLength = function(length) {
5745
+ return stdCoder.maxDecodedLength(length);
5590
5746
  };
5591
- URLSafeCoder.prototype._decodeChar = function (c) {
5592
- var result = INVALID_BYTE;
5593
- // c == 45 (c > 44 and c < 46)
5594
- result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);
5595
- // c == 95 (c > 94 and c < 96)
5596
- result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);
5597
- // c > 47 and c < 58
5598
- result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);
5599
- // c > 64 and c < 91
5600
- result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);
5601
- // c > 96 and c < 123
5602
- result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);
5603
- return result;
5747
+ exports.decodedLength = function(s) {
5748
+ return stdCoder.decodedLength(s);
5604
5749
  };
5605
- return URLSafeCoder;
5606
- }(Coder));
5607
- base64$1.URLSafeCoder = URLSafeCoder;
5608
- var urlSafeCoder = new URLSafeCoder();
5609
- function encodeURLSafe(data) {
5610
- return urlSafeCoder.encode(data);
5611
- }
5612
- base64$1.encodeURLSafe = encodeURLSafe;
5613
- function decodeURLSafe(s) {
5614
- return urlSafeCoder.decode(s);
5615
- }
5616
- base64$1.decodeURLSafe = decodeURLSafe;
5617
- base64$1.encodedLength = function (length) {
5618
- return stdCoder.encodedLength(length);
5619
- };
5620
- base64$1.maxDecodedLength = function (length) {
5621
- return stdCoder.maxDecodedLength(length);
5622
- };
5623
- base64$1.decodedLength = function (s) {
5624
- return stdCoder.decodedLength(s);
5625
- };
5626
-
5627
- var sha256$1 = {exports: {}};
5628
-
5629
- (function (module) {
5630
- (function (root, factory) {
5631
- // Hack to make all exports of this module sha256 function object properties.
5632
- var exports = {};
5633
- factory(exports);
5634
- var sha256 = exports["default"];
5635
- for (var k in exports) {
5636
- sha256[k] = exports[k];
5637
- }
5638
-
5639
- {
5640
- module.exports = sha256;
5641
- }
5642
- })(commonjsGlobal, function(exports) {
5643
- exports.__esModule = true;
5644
- // SHA-256 (+ HMAC and PBKDF2) for JavaScript.
5645
- //
5646
- // Written in 2014-2016 by Dmitry Chestnykh.
5647
- // Public domain, no warranty.
5648
- //
5649
- // Functions (accept and return Uint8Arrays):
5650
- //
5651
- // sha256(message) -> hash
5652
- // sha256.hmac(key, message) -> mac
5653
- // sha256.pbkdf2(password, salt, rounds, dkLen) -> dk
5654
- //
5655
- // Classes:
5656
- //
5657
- // new sha256.Hash()
5658
- // new sha256.HMAC(key)
5659
- //
5660
- exports.digestLength = 32;
5661
- exports.blockSize = 64;
5662
- // SHA-256 constants
5663
- var K = new Uint32Array([
5664
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b,
5665
- 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,
5666
- 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,
5667
- 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
5668
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152,
5669
- 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
5670
- 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
5671
- 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
5672
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,
5673
- 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08,
5674
- 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,
5675
- 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
5676
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
5677
- ]);
5678
- function hashBlocks(w, v, p, pos, len) {
5679
- var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
5680
- while (len >= 64) {
5681
- a = v[0];
5682
- b = v[1];
5683
- c = v[2];
5684
- d = v[3];
5685
- e = v[4];
5686
- f = v[5];
5687
- g = v[6];
5688
- h = v[7];
5689
- for (i = 0; i < 16; i++) {
5690
- j = pos + i * 4;
5691
- w[i] = (((p[j] & 0xff) << 24) | ((p[j + 1] & 0xff) << 16) |
5692
- ((p[j + 2] & 0xff) << 8) | (p[j + 3] & 0xff));
5693
- }
5694
- for (i = 16; i < 64; i++) {
5695
- u = w[i - 2];
5696
- t1 = (u >>> 17 | u << (32 - 17)) ^ (u >>> 19 | u << (32 - 19)) ^ (u >>> 10);
5697
- u = w[i - 15];
5698
- t2 = (u >>> 7 | u << (32 - 7)) ^ (u >>> 18 | u << (32 - 18)) ^ (u >>> 3);
5699
- w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
5700
- }
5701
- for (i = 0; i < 64; i++) {
5702
- t1 = (((((e >>> 6 | e << (32 - 6)) ^ (e >>> 11 | e << (32 - 11)) ^
5703
- (e >>> 25 | e << (32 - 25))) + ((e & f) ^ (~e & g))) | 0) +
5704
- ((h + ((K[i] + w[i]) | 0)) | 0)) | 0;
5705
- t2 = (((a >>> 2 | a << (32 - 2)) ^ (a >>> 13 | a << (32 - 13)) ^
5706
- (a >>> 22 | a << (32 - 22))) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
5707
- h = g;
5708
- g = f;
5709
- f = e;
5710
- e = (d + t1) | 0;
5711
- d = c;
5712
- c = b;
5713
- b = a;
5714
- a = (t1 + t2) | 0;
5715
- }
5716
- v[0] += a;
5717
- v[1] += b;
5718
- v[2] += c;
5719
- v[3] += d;
5720
- v[4] += e;
5721
- v[5] += f;
5722
- v[6] += g;
5723
- v[7] += h;
5724
- pos += 64;
5725
- len -= 64;
5726
- }
5727
- return pos;
5728
- }
5729
- // Hash implements SHA256 hash algorithm.
5730
- var Hash = /** @class */ (function () {
5731
- function Hash() {
5732
- this.digestLength = exports.digestLength;
5733
- this.blockSize = exports.blockSize;
5734
- // Note: Int32Array is used instead of Uint32Array for performance reasons.
5735
- this.state = new Int32Array(8); // hash state
5736
- this.temp = new Int32Array(64); // temporary state
5737
- this.buffer = new Uint8Array(128); // buffer for data to hash
5738
- this.bufferLength = 0; // number of bytes in buffer
5739
- this.bytesHashed = 0; // number of total bytes hashed
5740
- this.finished = false; // indicates whether the hash was finalized
5741
- this.reset();
5742
- }
5743
- // Resets hash state making it possible
5744
- // to re-use this instance to hash other data.
5745
- Hash.prototype.reset = function () {
5746
- this.state[0] = 0x6a09e667;
5747
- this.state[1] = 0xbb67ae85;
5748
- this.state[2] = 0x3c6ef372;
5749
- this.state[3] = 0xa54ff53a;
5750
- this.state[4] = 0x510e527f;
5751
- this.state[5] = 0x9b05688c;
5752
- this.state[6] = 0x1f83d9ab;
5753
- this.state[7] = 0x5be0cd19;
5754
- this.bufferLength = 0;
5755
- this.bytesHashed = 0;
5756
- this.finished = false;
5757
- return this;
5758
- };
5759
- // Cleans internal buffers and re-initializes hash state.
5760
- Hash.prototype.clean = function () {
5761
- for (var i = 0; i < this.buffer.length; i++) {
5762
- this.buffer[i] = 0;
5763
- }
5764
- for (var i = 0; i < this.temp.length; i++) {
5765
- this.temp[i] = 0;
5766
- }
5767
- this.reset();
5768
- };
5769
- // Updates hash state with the given data.
5770
- //
5771
- // Optionally, length of the data can be specified to hash
5772
- // fewer bytes than data.length.
5773
- //
5774
- // Throws error when trying to update already finalized hash:
5775
- // instance must be reset to use it again.
5776
- Hash.prototype.update = function (data, dataLength) {
5777
- if (dataLength === void 0) { dataLength = data.length; }
5778
- if (this.finished) {
5779
- throw new Error("SHA256: can't update because hash was finished.");
5780
- }
5781
- var dataPos = 0;
5782
- this.bytesHashed += dataLength;
5783
- if (this.bufferLength > 0) {
5784
- while (this.bufferLength < 64 && dataLength > 0) {
5785
- this.buffer[this.bufferLength++] = data[dataPos++];
5786
- dataLength--;
5787
- }
5788
- if (this.bufferLength === 64) {
5789
- hashBlocks(this.temp, this.state, this.buffer, 0, 64);
5790
- this.bufferLength = 0;
5791
- }
5792
- }
5793
- if (dataLength >= 64) {
5794
- dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
5795
- dataLength %= 64;
5796
- }
5797
- while (dataLength > 0) {
5798
- this.buffer[this.bufferLength++] = data[dataPos++];
5799
- dataLength--;
5800
- }
5801
- return this;
5802
- };
5803
- // Finalizes hash state and puts hash into out.
5804
- //
5805
- // If hash was already finalized, puts the same value.
5806
- Hash.prototype.finish = function (out) {
5807
- if (!this.finished) {
5808
- var bytesHashed = this.bytesHashed;
5809
- var left = this.bufferLength;
5810
- var bitLenHi = (bytesHashed / 0x20000000) | 0;
5811
- var bitLenLo = bytesHashed << 3;
5812
- var padLength = (bytesHashed % 64 < 56) ? 64 : 128;
5813
- this.buffer[left] = 0x80;
5814
- for (var i = left + 1; i < padLength - 8; i++) {
5815
- this.buffer[i] = 0;
5816
- }
5817
- this.buffer[padLength - 8] = (bitLenHi >>> 24) & 0xff;
5818
- this.buffer[padLength - 7] = (bitLenHi >>> 16) & 0xff;
5819
- this.buffer[padLength - 6] = (bitLenHi >>> 8) & 0xff;
5820
- this.buffer[padLength - 5] = (bitLenHi >>> 0) & 0xff;
5821
- this.buffer[padLength - 4] = (bitLenLo >>> 24) & 0xff;
5822
- this.buffer[padLength - 3] = (bitLenLo >>> 16) & 0xff;
5823
- this.buffer[padLength - 2] = (bitLenLo >>> 8) & 0xff;
5824
- this.buffer[padLength - 1] = (bitLenLo >>> 0) & 0xff;
5825
- hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
5826
- this.finished = true;
5827
- }
5828
- for (var i = 0; i < 8; i++) {
5829
- out[i * 4 + 0] = (this.state[i] >>> 24) & 0xff;
5830
- out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;
5831
- out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;
5832
- out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;
5833
- }
5834
- return this;
5835
- };
5836
- // Returns the final hash digest.
5837
- Hash.prototype.digest = function () {
5838
- var out = new Uint8Array(this.digestLength);
5839
- this.finish(out);
5840
- return out;
5841
- };
5842
- // Internal function for use in HMAC for optimization.
5843
- Hash.prototype._saveState = function (out) {
5844
- for (var i = 0; i < this.state.length; i++) {
5845
- out[i] = this.state[i];
5846
- }
5847
- };
5848
- // Internal function for use in HMAC for optimization.
5849
- Hash.prototype._restoreState = function (from, bytesHashed) {
5850
- for (var i = 0; i < this.state.length; i++) {
5851
- this.state[i] = from[i];
5852
- }
5853
- this.bytesHashed = bytesHashed;
5854
- this.finished = false;
5855
- this.bufferLength = 0;
5856
- };
5857
- return Hash;
5858
- }());
5859
- exports.Hash = Hash;
5860
- // HMAC implements HMAC-SHA256 message authentication algorithm.
5861
- var HMAC = /** @class */ (function () {
5862
- function HMAC(key) {
5863
- this.inner = new Hash();
5864
- this.outer = new Hash();
5865
- this.blockSize = this.inner.blockSize;
5866
- this.digestLength = this.inner.digestLength;
5867
- var pad = new Uint8Array(this.blockSize);
5868
- if (key.length > this.blockSize) {
5869
- (new Hash()).update(key).finish(pad).clean();
5870
- }
5871
- else {
5872
- for (var i = 0; i < key.length; i++) {
5873
- pad[i] = key[i];
5874
- }
5875
- }
5876
- for (var i = 0; i < pad.length; i++) {
5877
- pad[i] ^= 0x36;
5878
- }
5879
- this.inner.update(pad);
5880
- for (var i = 0; i < pad.length; i++) {
5881
- pad[i] ^= 0x36 ^ 0x5c;
5882
- }
5883
- this.outer.update(pad);
5884
- this.istate = new Uint32Array(8);
5885
- this.ostate = new Uint32Array(8);
5886
- this.inner._saveState(this.istate);
5887
- this.outer._saveState(this.ostate);
5888
- for (var i = 0; i < pad.length; i++) {
5889
- pad[i] = 0;
5890
- }
5891
- }
5892
- // Returns HMAC state to the state initialized with key
5893
- // to make it possible to run HMAC over the other data with the same
5894
- // key without creating a new instance.
5895
- HMAC.prototype.reset = function () {
5896
- this.inner._restoreState(this.istate, this.inner.blockSize);
5897
- this.outer._restoreState(this.ostate, this.outer.blockSize);
5898
- return this;
5899
- };
5900
- // Cleans HMAC state.
5901
- HMAC.prototype.clean = function () {
5902
- for (var i = 0; i < this.istate.length; i++) {
5903
- this.ostate[i] = this.istate[i] = 0;
5904
- }
5905
- this.inner.clean();
5906
- this.outer.clean();
5907
- };
5908
- // Updates state with provided data.
5909
- HMAC.prototype.update = function (data) {
5910
- this.inner.update(data);
5911
- return this;
5912
- };
5913
- // Finalizes HMAC and puts the result in out.
5914
- HMAC.prototype.finish = function (out) {
5915
- if (this.outer.finished) {
5916
- this.outer.finish(out);
5917
- }
5918
- else {
5919
- this.inner.finish(out);
5920
- this.outer.update(out, this.digestLength).finish(out);
5921
- }
5922
- return this;
5923
- };
5924
- // Returns message authentication code.
5925
- HMAC.prototype.digest = function () {
5926
- var out = new Uint8Array(this.digestLength);
5927
- this.finish(out);
5928
- return out;
5929
- };
5930
- return HMAC;
5931
- }());
5932
- exports.HMAC = HMAC;
5933
- // Returns SHA256 hash of data.
5934
- function hash(data) {
5935
- var h = (new Hash()).update(data);
5936
- var digest = h.digest();
5937
- h.clean();
5938
- return digest;
5939
- }
5940
- exports.hash = hash;
5941
- // Function hash is both available as module.hash and as default export.
5942
- exports["default"] = hash;
5943
- // Returns HMAC-SHA256 of data under the key.
5944
- function hmac(key, data) {
5945
- var h = (new HMAC(key)).update(data);
5946
- var digest = h.digest();
5947
- h.clean();
5948
- return digest;
5949
- }
5950
- exports.hmac = hmac;
5951
- // Fills hkdf buffer like this:
5952
- // T(1) = HMAC-Hash(PRK, T(0) | info | 0x01)
5953
- function fillBuffer(buffer, hmac, info, counter) {
5954
- // Counter is a byte value: check if it overflowed.
5955
- var num = counter[0];
5956
- if (num === 0) {
5957
- throw new Error("hkdf: cannot expand more");
5958
- }
5959
- // Prepare HMAC instance for new data with old key.
5960
- hmac.reset();
5961
- // Hash in previous output if it was generated
5962
- // (i.e. counter is greater than 1).
5963
- if (num > 1) {
5964
- hmac.update(buffer);
5965
- }
5966
- // Hash in info if it exists.
5967
- if (info) {
5968
- hmac.update(info);
5969
- }
5970
- // Hash in the counter.
5971
- hmac.update(counter);
5972
- // Output result to buffer and clean HMAC instance.
5973
- hmac.finish(buffer);
5974
- // Increment counter inside typed array, this works properly.
5975
- counter[0]++;
5976
- }
5977
- var hkdfSalt = new Uint8Array(exports.digestLength); // Filled with zeroes.
5978
- function hkdf(key, salt, info, length) {
5979
- if (salt === void 0) { salt = hkdfSalt; }
5980
- if (length === void 0) { length = 32; }
5981
- var counter = new Uint8Array([1]);
5982
- // HKDF-Extract uses salt as HMAC key, and key as data.
5983
- var okm = hmac(salt, key);
5984
- // Initialize HMAC for expanding with extracted key.
5985
- // Ensure no collisions with `hmac` function.
5986
- var hmac_ = new HMAC(okm);
5987
- // Allocate buffer.
5988
- var buffer = new Uint8Array(hmac_.digestLength);
5989
- var bufpos = buffer.length;
5990
- var out = new Uint8Array(length);
5991
- for (var i = 0; i < length; i++) {
5992
- if (bufpos === buffer.length) {
5993
- fillBuffer(buffer, hmac_, info, counter);
5994
- bufpos = 0;
5995
- }
5996
- out[i] = buffer[bufpos++];
5997
- }
5998
- hmac_.clean();
5999
- buffer.fill(0);
6000
- counter.fill(0);
6001
- return out;
6002
- }
6003
- exports.hkdf = hkdf;
6004
- // Derives a key from password and salt using PBKDF2-HMAC-SHA256
6005
- // with the given number of iterations.
6006
- //
6007
- // The number of bytes returned is equal to dkLen.
6008
- //
6009
- // (For better security, avoid dkLen greater than hash length - 32 bytes).
6010
- function pbkdf2(password, salt, iterations, dkLen) {
6011
- var prf = new HMAC(password);
6012
- var len = prf.digestLength;
6013
- var ctr = new Uint8Array(4);
6014
- var t = new Uint8Array(len);
6015
- var u = new Uint8Array(len);
6016
- var dk = new Uint8Array(dkLen);
6017
- for (var i = 0; i * len < dkLen; i++) {
6018
- var c = i + 1;
6019
- ctr[0] = (c >>> 24) & 0xff;
6020
- ctr[1] = (c >>> 16) & 0xff;
6021
- ctr[2] = (c >>> 8) & 0xff;
6022
- ctr[3] = (c >>> 0) & 0xff;
6023
- prf.reset();
6024
- prf.update(salt);
6025
- prf.update(ctr);
6026
- prf.finish(u);
6027
- for (var j = 0; j < len; j++) {
6028
- t[j] = u[j];
6029
- }
6030
- for (var j = 2; j <= iterations; j++) {
6031
- prf.reset();
6032
- prf.update(u).finish(u);
6033
- for (var k = 0; k < len; k++) {
6034
- t[k] ^= u[k];
6035
- }
6036
- }
6037
- for (var j = 0; j < len && i * len + j < dkLen; j++) {
6038
- dk[i * len + j] = t[j];
6039
- }
6040
- }
6041
- for (var i = 0; i < len; i++) {
6042
- t[i] = u[i] = 0;
6043
- }
6044
- for (var i = 0; i < 4; i++) {
6045
- ctr[i] = 0;
6046
- }
6047
- prf.clean();
6048
- return dk;
6049
- }
6050
- exports.pbkdf2 = pbkdf2;
6051
- });
6052
- } (sha256$1));
5750
+ }
5751
+ });
6053
5752
 
6054
- var sha256Exports = sha256$1.exports;
5753
+ // ../../node_modules/fast-sha256/sha256.js
5754
+ var require_sha256 = __commonJS({
5755
+ "../../node_modules/fast-sha256/sha256.js"(exports, module) {
5756
+ (function(root, factory) {
5757
+ var exports2 = {};
5758
+ factory(exports2);
5759
+ var sha2562 = exports2["default"];
5760
+ for (var k in exports2) {
5761
+ sha2562[k] = exports2[k];
5762
+ }
5763
+ if (typeof module === "object" && typeof module.exports === "object") {
5764
+ module.exports = sha2562;
5765
+ } else if (typeof define === "function" && define.amd) {
5766
+ define(function() {
5767
+ return sha2562;
5768
+ });
5769
+ } else {
5770
+ root.sha256 = sha2562;
5771
+ }
5772
+ })(exports, function(exports2) {
5773
+ exports2.__esModule = true;
5774
+ exports2.digestLength = 32;
5775
+ exports2.blockSize = 64;
5776
+ var K = new Uint32Array([
5777
+ 1116352408,
5778
+ 1899447441,
5779
+ 3049323471,
5780
+ 3921009573,
5781
+ 961987163,
5782
+ 1508970993,
5783
+ 2453635748,
5784
+ 2870763221,
5785
+ 3624381080,
5786
+ 310598401,
5787
+ 607225278,
5788
+ 1426881987,
5789
+ 1925078388,
5790
+ 2162078206,
5791
+ 2614888103,
5792
+ 3248222580,
5793
+ 3835390401,
5794
+ 4022224774,
5795
+ 264347078,
5796
+ 604807628,
5797
+ 770255983,
5798
+ 1249150122,
5799
+ 1555081692,
5800
+ 1996064986,
5801
+ 2554220882,
5802
+ 2821834349,
5803
+ 2952996808,
5804
+ 3210313671,
5805
+ 3336571891,
5806
+ 3584528711,
5807
+ 113926993,
5808
+ 338241895,
5809
+ 666307205,
5810
+ 773529912,
5811
+ 1294757372,
5812
+ 1396182291,
5813
+ 1695183700,
5814
+ 1986661051,
5815
+ 2177026350,
5816
+ 2456956037,
5817
+ 2730485921,
5818
+ 2820302411,
5819
+ 3259730800,
5820
+ 3345764771,
5821
+ 3516065817,
5822
+ 3600352804,
5823
+ 4094571909,
5824
+ 275423344,
5825
+ 430227734,
5826
+ 506948616,
5827
+ 659060556,
5828
+ 883997877,
5829
+ 958139571,
5830
+ 1322822218,
5831
+ 1537002063,
5832
+ 1747873779,
5833
+ 1955562222,
5834
+ 2024104815,
5835
+ 2227730452,
5836
+ 2361852424,
5837
+ 2428436474,
5838
+ 2756734187,
5839
+ 3204031479,
5840
+ 3329325298
5841
+ ]);
5842
+ function hashBlocks(w, v, p, pos, len) {
5843
+ var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
5844
+ while (len >= 64) {
5845
+ a = v[0];
5846
+ b = v[1];
5847
+ c = v[2];
5848
+ d = v[3];
5849
+ e = v[4];
5850
+ f = v[5];
5851
+ g = v[6];
5852
+ h = v[7];
5853
+ for (i = 0; i < 16; i++) {
5854
+ j = pos + i * 4;
5855
+ w[i] = (p[j] & 255) << 24 | (p[j + 1] & 255) << 16 | (p[j + 2] & 255) << 8 | p[j + 3] & 255;
5856
+ }
5857
+ for (i = 16; i < 64; i++) {
5858
+ u = w[i - 2];
5859
+ t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10;
5860
+ u = w[i - 15];
5861
+ t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3;
5862
+ w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
5863
+ }
5864
+ for (i = 0; i < 64; i++) {
5865
+ 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;
5866
+ t2 = ((a >>> 2 | a << 32 - 2) ^ (a >>> 13 | a << 32 - 13) ^ (a >>> 22 | a << 32 - 22)) + (a & b ^ a & c ^ b & c) | 0;
5867
+ h = g;
5868
+ g = f;
5869
+ f = e;
5870
+ e = d + t1 | 0;
5871
+ d = c;
5872
+ c = b;
5873
+ b = a;
5874
+ a = t1 + t2 | 0;
5875
+ }
5876
+ v[0] += a;
5877
+ v[1] += b;
5878
+ v[2] += c;
5879
+ v[3] += d;
5880
+ v[4] += e;
5881
+ v[5] += f;
5882
+ v[6] += g;
5883
+ v[7] += h;
5884
+ pos += 64;
5885
+ len -= 64;
5886
+ }
5887
+ return pos;
5888
+ }
5889
+ var Hash = (
5890
+ /** @class */
5891
+ function() {
5892
+ function Hash2() {
5893
+ this.digestLength = exports2.digestLength;
5894
+ this.blockSize = exports2.blockSize;
5895
+ this.state = new Int32Array(8);
5896
+ this.temp = new Int32Array(64);
5897
+ this.buffer = new Uint8Array(128);
5898
+ this.bufferLength = 0;
5899
+ this.bytesHashed = 0;
5900
+ this.finished = false;
5901
+ this.reset();
5902
+ }
5903
+ Hash2.prototype.reset = function() {
5904
+ this.state[0] = 1779033703;
5905
+ this.state[1] = 3144134277;
5906
+ this.state[2] = 1013904242;
5907
+ this.state[3] = 2773480762;
5908
+ this.state[4] = 1359893119;
5909
+ this.state[5] = 2600822924;
5910
+ this.state[6] = 528734635;
5911
+ this.state[7] = 1541459225;
5912
+ this.bufferLength = 0;
5913
+ this.bytesHashed = 0;
5914
+ this.finished = false;
5915
+ return this;
5916
+ };
5917
+ Hash2.prototype.clean = function() {
5918
+ for (var i = 0; i < this.buffer.length; i++) {
5919
+ this.buffer[i] = 0;
5920
+ }
5921
+ for (var i = 0; i < this.temp.length; i++) {
5922
+ this.temp[i] = 0;
5923
+ }
5924
+ this.reset();
5925
+ };
5926
+ Hash2.prototype.update = function(data, dataLength) {
5927
+ if (dataLength === void 0) {
5928
+ dataLength = data.length;
5929
+ }
5930
+ if (this.finished) {
5931
+ throw new Error("SHA256: can't update because hash was finished.");
5932
+ }
5933
+ var dataPos = 0;
5934
+ this.bytesHashed += dataLength;
5935
+ if (this.bufferLength > 0) {
5936
+ while (this.bufferLength < 64 && dataLength > 0) {
5937
+ this.buffer[this.bufferLength++] = data[dataPos++];
5938
+ dataLength--;
5939
+ }
5940
+ if (this.bufferLength === 64) {
5941
+ hashBlocks(this.temp, this.state, this.buffer, 0, 64);
5942
+ this.bufferLength = 0;
5943
+ }
5944
+ }
5945
+ if (dataLength >= 64) {
5946
+ dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
5947
+ dataLength %= 64;
5948
+ }
5949
+ while (dataLength > 0) {
5950
+ this.buffer[this.bufferLength++] = data[dataPos++];
5951
+ dataLength--;
5952
+ }
5953
+ return this;
5954
+ };
5955
+ Hash2.prototype.finish = function(out) {
5956
+ if (!this.finished) {
5957
+ var bytesHashed = this.bytesHashed;
5958
+ var left = this.bufferLength;
5959
+ var bitLenHi = bytesHashed / 536870912 | 0;
5960
+ var bitLenLo = bytesHashed << 3;
5961
+ var padLength = bytesHashed % 64 < 56 ? 64 : 128;
5962
+ this.buffer[left] = 128;
5963
+ for (var i = left + 1; i < padLength - 8; i++) {
5964
+ this.buffer[i] = 0;
5965
+ }
5966
+ this.buffer[padLength - 8] = bitLenHi >>> 24 & 255;
5967
+ this.buffer[padLength - 7] = bitLenHi >>> 16 & 255;
5968
+ this.buffer[padLength - 6] = bitLenHi >>> 8 & 255;
5969
+ this.buffer[padLength - 5] = bitLenHi >>> 0 & 255;
5970
+ this.buffer[padLength - 4] = bitLenLo >>> 24 & 255;
5971
+ this.buffer[padLength - 3] = bitLenLo >>> 16 & 255;
5972
+ this.buffer[padLength - 2] = bitLenLo >>> 8 & 255;
5973
+ this.buffer[padLength - 1] = bitLenLo >>> 0 & 255;
5974
+ hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
5975
+ this.finished = true;
5976
+ }
5977
+ for (var i = 0; i < 8; i++) {
5978
+ out[i * 4 + 0] = this.state[i] >>> 24 & 255;
5979
+ out[i * 4 + 1] = this.state[i] >>> 16 & 255;
5980
+ out[i * 4 + 2] = this.state[i] >>> 8 & 255;
5981
+ out[i * 4 + 3] = this.state[i] >>> 0 & 255;
5982
+ }
5983
+ return this;
5984
+ };
5985
+ Hash2.prototype.digest = function() {
5986
+ var out = new Uint8Array(this.digestLength);
5987
+ this.finish(out);
5988
+ return out;
5989
+ };
5990
+ Hash2.prototype._saveState = function(out) {
5991
+ for (var i = 0; i < this.state.length; i++) {
5992
+ out[i] = this.state[i];
5993
+ }
5994
+ };
5995
+ Hash2.prototype._restoreState = function(from, bytesHashed) {
5996
+ for (var i = 0; i < this.state.length; i++) {
5997
+ this.state[i] = from[i];
5998
+ }
5999
+ this.bytesHashed = bytesHashed;
6000
+ this.finished = false;
6001
+ this.bufferLength = 0;
6002
+ };
6003
+ return Hash2;
6004
+ }()
6005
+ );
6006
+ exports2.Hash = Hash;
6007
+ var HMAC = (
6008
+ /** @class */
6009
+ function() {
6010
+ function HMAC2(key) {
6011
+ this.inner = new Hash();
6012
+ this.outer = new Hash();
6013
+ this.blockSize = this.inner.blockSize;
6014
+ this.digestLength = this.inner.digestLength;
6015
+ var pad = new Uint8Array(this.blockSize);
6016
+ if (key.length > this.blockSize) {
6017
+ new Hash().update(key).finish(pad).clean();
6018
+ } else {
6019
+ for (var i = 0; i < key.length; i++) {
6020
+ pad[i] = key[i];
6021
+ }
6022
+ }
6023
+ for (var i = 0; i < pad.length; i++) {
6024
+ pad[i] ^= 54;
6025
+ }
6026
+ this.inner.update(pad);
6027
+ for (var i = 0; i < pad.length; i++) {
6028
+ pad[i] ^= 54 ^ 92;
6029
+ }
6030
+ this.outer.update(pad);
6031
+ this.istate = new Uint32Array(8);
6032
+ this.ostate = new Uint32Array(8);
6033
+ this.inner._saveState(this.istate);
6034
+ this.outer._saveState(this.ostate);
6035
+ for (var i = 0; i < pad.length; i++) {
6036
+ pad[i] = 0;
6037
+ }
6038
+ }
6039
+ HMAC2.prototype.reset = function() {
6040
+ this.inner._restoreState(this.istate, this.inner.blockSize);
6041
+ this.outer._restoreState(this.ostate, this.outer.blockSize);
6042
+ return this;
6043
+ };
6044
+ HMAC2.prototype.clean = function() {
6045
+ for (var i = 0; i < this.istate.length; i++) {
6046
+ this.ostate[i] = this.istate[i] = 0;
6047
+ }
6048
+ this.inner.clean();
6049
+ this.outer.clean();
6050
+ };
6051
+ HMAC2.prototype.update = function(data) {
6052
+ this.inner.update(data);
6053
+ return this;
6054
+ };
6055
+ HMAC2.prototype.finish = function(out) {
6056
+ if (this.outer.finished) {
6057
+ this.outer.finish(out);
6058
+ } else {
6059
+ this.inner.finish(out);
6060
+ this.outer.update(out, this.digestLength).finish(out);
6061
+ }
6062
+ return this;
6063
+ };
6064
+ HMAC2.prototype.digest = function() {
6065
+ var out = new Uint8Array(this.digestLength);
6066
+ this.finish(out);
6067
+ return out;
6068
+ };
6069
+ return HMAC2;
6070
+ }()
6071
+ );
6072
+ exports2.HMAC = HMAC;
6073
+ function hash(data) {
6074
+ var h = new Hash().update(data);
6075
+ var digest = h.digest();
6076
+ h.clean();
6077
+ return digest;
6078
+ }
6079
+ exports2.hash = hash;
6080
+ exports2["default"] = hash;
6081
+ function hmac2(key, data) {
6082
+ var h = new HMAC(key).update(data);
6083
+ var digest = h.digest();
6084
+ h.clean();
6085
+ return digest;
6086
+ }
6087
+ exports2.hmac = hmac2;
6088
+ function fillBuffer(buffer, hmac3, info, counter) {
6089
+ var num = counter[0];
6090
+ if (num === 0) {
6091
+ throw new Error("hkdf: cannot expand more");
6092
+ }
6093
+ hmac3.reset();
6094
+ if (num > 1) {
6095
+ hmac3.update(buffer);
6096
+ }
6097
+ if (info) {
6098
+ hmac3.update(info);
6099
+ }
6100
+ hmac3.update(counter);
6101
+ hmac3.finish(buffer);
6102
+ counter[0]++;
6103
+ }
6104
+ var hkdfSalt = new Uint8Array(exports2.digestLength);
6105
+ function hkdf(key, salt, info, length) {
6106
+ if (salt === void 0) {
6107
+ salt = hkdfSalt;
6108
+ }
6109
+ if (length === void 0) {
6110
+ length = 32;
6111
+ }
6112
+ var counter = new Uint8Array([1]);
6113
+ var okm = hmac2(salt, key);
6114
+ var hmac_ = new HMAC(okm);
6115
+ var buffer = new Uint8Array(hmac_.digestLength);
6116
+ var bufpos = buffer.length;
6117
+ var out = new Uint8Array(length);
6118
+ for (var i = 0; i < length; i++) {
6119
+ if (bufpos === buffer.length) {
6120
+ fillBuffer(buffer, hmac_, info, counter);
6121
+ bufpos = 0;
6122
+ }
6123
+ out[i] = buffer[bufpos++];
6124
+ }
6125
+ hmac_.clean();
6126
+ buffer.fill(0);
6127
+ counter.fill(0);
6128
+ return out;
6129
+ }
6130
+ exports2.hkdf = hkdf;
6131
+ function pbkdf2(password, salt, iterations, dkLen) {
6132
+ var prf = new HMAC(password);
6133
+ var len = prf.digestLength;
6134
+ var ctr = new Uint8Array(4);
6135
+ var t = new Uint8Array(len);
6136
+ var u = new Uint8Array(len);
6137
+ var dk = new Uint8Array(dkLen);
6138
+ for (var i = 0; i * len < dkLen; i++) {
6139
+ var c = i + 1;
6140
+ ctr[0] = c >>> 24 & 255;
6141
+ ctr[1] = c >>> 16 & 255;
6142
+ ctr[2] = c >>> 8 & 255;
6143
+ ctr[3] = c >>> 0 & 255;
6144
+ prf.reset();
6145
+ prf.update(salt);
6146
+ prf.update(ctr);
6147
+ prf.finish(u);
6148
+ for (var j = 0; j < len; j++) {
6149
+ t[j] = u[j];
6150
+ }
6151
+ for (var j = 2; j <= iterations; j++) {
6152
+ prf.reset();
6153
+ prf.update(u).finish(u);
6154
+ for (var k = 0; k < len; k++) {
6155
+ t[k] ^= u[k];
6156
+ }
6157
+ }
6158
+ for (var j = 0; j < len && i * len + j < dkLen; j++) {
6159
+ dk[i * len + j] = t[j];
6160
+ }
6161
+ }
6162
+ for (var i = 0; i < len; i++) {
6163
+ t[i] = u[i] = 0;
6164
+ }
6165
+ for (var i = 0; i < 4; i++) {
6166
+ ctr[i] = 0;
6167
+ }
6168
+ prf.clean();
6169
+ return dk;
6170
+ }
6171
+ exports2.pbkdf2 = pbkdf2;
6172
+ });
6173
+ }
6174
+ });
6055
6175
 
6056
- Object.defineProperty(dist, "__esModule", { value: true });
6057
- var Webhook_1 = dist.Webhook = WebhookVerificationError_1 = dist.WebhookVerificationError = void 0;
6058
- const timing_safe_equal_1 = timing_safe_equal;
6059
- const base64 = base64$1;
6060
- const sha256 = sha256Exports;
6061
- const WEBHOOK_TOLERANCE_IN_SECONDS = 5 * 60;
6062
- class ExtendableError extends Error {
6063
- constructor(message) {
6064
- super(message);
6065
- Object.setPrototypeOf(this, ExtendableError.prototype);
6066
- this.name = "ExtendableError";
6067
- this.stack = new Error(message).stack;
6176
+ // src/webhook/vendor/standardwebhook.ts
6177
+ var base64 = __toESM(require_base64());
6178
+ var sha256 = __toESM(require_sha256());
6179
+ var WEBHOOK_TOLERANCE_IN_SECONDS = 5 * 60;
6180
+ var ExtendableError = class _ExtendableError extends Error {
6181
+ constructor(message) {
6182
+ super(message);
6183
+ Object.setPrototypeOf(this, _ExtendableError.prototype);
6184
+ this.name = "ExtendableError";
6185
+ this.stack = new Error(message).stack;
6186
+ }
6187
+ };
6188
+ var WebhookVerificationError = class _WebhookVerificationError extends ExtendableError {
6189
+ constructor(message) {
6190
+ super(message);
6191
+ Object.setPrototypeOf(this, _WebhookVerificationError.prototype);
6192
+ this.name = "WebhookVerificationError";
6193
+ }
6194
+ };
6195
+ var Webhook = class _Webhook {
6196
+ static prefix = "whsec_";
6197
+ key;
6198
+ constructor(secret, options) {
6199
+ if (!secret) {
6200
+ throw new Error("Secret can't be empty.");
6201
+ }
6202
+ if ((options == null ? void 0 : options.format) === "raw") {
6203
+ if (secret instanceof Uint8Array) {
6204
+ this.key = secret;
6205
+ } else {
6206
+ this.key = Uint8Array.from(secret, (c) => c.charCodeAt(0));
6207
+ }
6208
+ } else {
6209
+ if (typeof secret !== "string") {
6210
+ throw new Error("Expected secret to be of type string");
6211
+ }
6212
+ if (secret.startsWith(_Webhook.prefix)) {
6213
+ secret = secret.substring(_Webhook.prefix.length);
6214
+ }
6215
+ this.key = base64.decode(secret);
6068
6216
  }
6069
- }
6070
- class WebhookVerificationError extends ExtendableError {
6071
- constructor(message) {
6072
- super(message);
6073
- Object.setPrototypeOf(this, WebhookVerificationError.prototype);
6074
- this.name = "WebhookVerificationError";
6217
+ }
6218
+ verify(payload, headers_) {
6219
+ const headers = {};
6220
+ for (const key of Object.keys(headers_)) {
6221
+ headers[key.toLowerCase()] = headers_[key];
6222
+ }
6223
+ const msgId = headers["webhook-id"];
6224
+ const msgSignature = headers["webhook-signature"];
6225
+ const msgTimestamp = headers["webhook-timestamp"];
6226
+ if (!msgSignature || !msgId || !msgTimestamp) {
6227
+ throw new WebhookVerificationError("Missing required headers");
6228
+ }
6229
+ const timestamp = this.verifyTimestamp(msgTimestamp);
6230
+ const computedSignature = this.sign(msgId, timestamp, payload);
6231
+ const expectedSignature = computedSignature.split(",")[1];
6232
+ const passedSignatures = msgSignature.split(" ");
6233
+ const encoder = new globalThis.TextEncoder();
6234
+ for (const versionedSignature of passedSignatures) {
6235
+ const [version, signature] = versionedSignature.split(",");
6236
+ if (version !== "v1") {
6237
+ continue;
6238
+ }
6239
+ if (timingSafeEqual(
6240
+ encoder.encode(signature),
6241
+ encoder.encode(expectedSignature)
6242
+ )) {
6243
+ return JSON.parse(payload.toString());
6244
+ }
6075
6245
  }
6076
- }
6077
- var WebhookVerificationError_1 = dist.WebhookVerificationError = WebhookVerificationError;
6078
- class Webhook {
6079
- constructor(secret, options) {
6080
- if (!secret) {
6081
- throw new Error("Secret can't be empty.");
6082
- }
6083
- if ((options === null || options === void 0 ? void 0 : options.format) === "raw") {
6084
- if (secret instanceof Uint8Array) {
6085
- this.key = secret;
6086
- }
6087
- else {
6088
- this.key = Uint8Array.from(secret, (c) => c.charCodeAt(0));
6089
- }
6090
- }
6091
- else {
6092
- if (typeof secret !== "string") {
6093
- throw new Error("Expected secret to be of type string");
6094
- }
6095
- if (secret.startsWith(Webhook.prefix)) {
6096
- secret = secret.substring(Webhook.prefix.length);
6097
- }
6098
- this.key = base64.decode(secret);
6099
- }
6246
+ throw new WebhookVerificationError("No matching signature found");
6247
+ }
6248
+ sign(msgId, timestamp, payload) {
6249
+ if (typeof payload === "string") ; else if (payload.constructor.name === "Buffer") {
6250
+ payload = payload.toString();
6251
+ } else {
6252
+ throw new Error("Expected payload to be of type string or Buffer.");
6100
6253
  }
6101
- verify(payload, headers_) {
6102
- const headers = {};
6103
- for (const key of Object.keys(headers_)) {
6104
- headers[key.toLowerCase()] = headers_[key];
6105
- }
6106
- const msgId = headers["webhook-id"];
6107
- const msgSignature = headers["webhook-signature"];
6108
- const msgTimestamp = headers["webhook-timestamp"];
6109
- if (!msgSignature || !msgId || !msgTimestamp) {
6110
- throw new WebhookVerificationError("Missing required headers");
6111
- }
6112
- const timestamp = this.verifyTimestamp(msgTimestamp);
6113
- const computedSignature = this.sign(msgId, timestamp, payload);
6114
- const expectedSignature = computedSignature.split(",")[1];
6115
- const passedSignatures = msgSignature.split(" ");
6116
- const encoder = new globalThis.TextEncoder();
6117
- for (const versionedSignature of passedSignatures) {
6118
- const [version, signature] = versionedSignature.split(",");
6119
- if (version !== "v1") {
6120
- continue;
6121
- }
6122
- if ((0, timing_safe_equal_1.timingSafeEqual)(encoder.encode(signature), encoder.encode(expectedSignature))) {
6123
- return JSON.parse(payload.toString());
6124
- }
6125
- }
6126
- throw new WebhookVerificationError("No matching signature found");
6254
+ const encoder = new TextEncoder();
6255
+ const timestampNumber = Math.floor(timestamp.getTime() / 1e3);
6256
+ const toSign = encoder.encode(`${msgId}.${timestampNumber}.${payload}`);
6257
+ const expectedSignature = base64.encode(sha256.hmac(this.key, toSign));
6258
+ return `v1,${expectedSignature}`;
6259
+ }
6260
+ verifyTimestamp(timestampHeader) {
6261
+ const now = Math.floor(Date.now() / 1e3);
6262
+ const timestamp = parseInt(timestampHeader, 10);
6263
+ if (isNaN(timestamp)) {
6264
+ throw new WebhookVerificationError("Invalid Signature Headers");
6127
6265
  }
6128
- sign(msgId, timestamp, payload) {
6129
- if (typeof payload === "string") ;
6130
- else if (payload.constructor.name === "Buffer") {
6131
- payload = payload.toString();
6132
- }
6133
- else {
6134
- throw new Error("Expected payload to be of type string or Buffer.");
6135
- }
6136
- const encoder = new TextEncoder();
6137
- const timestampNumber = Math.floor(timestamp.getTime() / 1000);
6138
- const toSign = encoder.encode(`${msgId}.${timestampNumber}.${payload}`);
6139
- const expectedSignature = base64.encode(sha256.hmac(this.key, toSign));
6140
- return `v1,${expectedSignature}`;
6266
+ if (now - timestamp > WEBHOOK_TOLERANCE_IN_SECONDS) {
6267
+ throw new WebhookVerificationError("Message timestamp too old");
6141
6268
  }
6142
- verifyTimestamp(timestampHeader) {
6143
- const now = Math.floor(Date.now() / 1000);
6144
- const timestamp = parseInt(timestampHeader, 10);
6145
- if (isNaN(timestamp)) {
6146
- throw new WebhookVerificationError("Invalid Signature Headers");
6147
- }
6148
- if (now - timestamp > WEBHOOK_TOLERANCE_IN_SECONDS) {
6149
- throw new WebhookVerificationError("Message timestamp too old");
6150
- }
6151
- if (timestamp > now + WEBHOOK_TOLERANCE_IN_SECONDS) {
6152
- throw new WebhookVerificationError("Message timestamp too new");
6153
- }
6154
- return new Date(timestamp * 1000);
6269
+ if (timestamp > now + WEBHOOK_TOLERANCE_IN_SECONDS) {
6270
+ throw new WebhookVerificationError("Message timestamp too new");
6155
6271
  }
6156
- }
6157
- Webhook_1 = dist.Webhook = Webhook;
6158
- Webhook.prefix = "whsec_";
6272
+ return new Date(timestamp * 1e3);
6273
+ }
6274
+ };
6275
+ /**
6276
+ * The MIT License
6277
+ *
6278
+ * Copyright (c) 2023 Svix (https://www.svix.com)
6279
+ *
6280
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6281
+ * of this software and associated documentation files (the "Software"), to deal
6282
+ * in the Software without restriction, including without limitation the rights
6283
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6284
+ * copies of the Software, and to permit persons to whom the Software is
6285
+ * furnished to do so, subject to the following conditions:
6286
+ *
6287
+ * The above copyright notice and this permission notice shall be included in
6288
+ * all copies or substantial portions of the Software.
6289
+ *
6290
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6291
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6292
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6293
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6294
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6295
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
6296
+ * THE SOFTWARE.
6297
+ *
6298
+ * @fileoverview Server-only webhook verification implementation.
6299
+ * @description Vendored from standardwebhooks package to avoid bundling issues.
6300
+ * Uses Node.js crypto module - DO NOT import in client/browser code.
6301
+ * @license MIT
6302
+ * @internal
6303
+ */
6159
6304
 
6305
+ // src/webhook/webhook.ts
6160
6306
  async function handleWebhookPayload(payload, config, context) {
6161
6307
  const callHandler = (handler, payload2) => {
6162
6308
  if (!handler) return;
@@ -6216,9 +6362,6 @@ async function handleWebhookPayload(payload, config, context) {
6216
6362
  if (payload.type === "subscription.renewed") {
6217
6363
  await callHandler(config.onSubscriptionRenewed, payload);
6218
6364
  }
6219
- if (payload.type === "subscription.paused") {
6220
- await callHandler(config.onSubscriptionPaused, payload);
6221
- }
6222
6365
  if (payload.type === "subscription.plan_changed") {
6223
6366
  await callHandler(config.onSubscriptionPlanChanged, payload);
6224
6367
  }
@@ -6237,17 +6380,41 @@ async function handleWebhookPayload(payload, config, context) {
6237
6380
  if (payload.type === "license_key.created") {
6238
6381
  await callHandler(config.onLicenseKeyCreated, payload);
6239
6382
  }
6383
+ if (payload.type === "credit.added") {
6384
+ await callHandler(config.onCreditAdded, payload);
6385
+ }
6386
+ if (payload.type === "credit.deducted") {
6387
+ await callHandler(config.onCreditDeducted, payload);
6388
+ }
6389
+ if (payload.type === "credit.expired") {
6390
+ await callHandler(config.onCreditExpired, payload);
6391
+ }
6392
+ if (payload.type === "credit.rolled_over") {
6393
+ await callHandler(config.onCreditRolledOver, payload);
6394
+ }
6395
+ if (payload.type === "credit.rollover_forfeited") {
6396
+ await callHandler(config.onCreditRolloverForfeited, payload);
6397
+ }
6398
+ if (payload.type === "credit.overage_charged") {
6399
+ await callHandler(config.onCreditOverageCharged, payload);
6400
+ }
6401
+ if (payload.type === "credit.manual_adjustment") {
6402
+ await callHandler(config.onCreditManualAdjustment, payload);
6403
+ }
6404
+ if (payload.type === "credit.balance_low") {
6405
+ await callHandler(config.onCreditBalanceLow, payload);
6406
+ }
6240
6407
  }
6241
6408
  var verifyWebhookPayload = async ({
6242
6409
  webhookKey,
6243
6410
  headers,
6244
6411
  body
6245
6412
  }) => {
6246
- const standardWebhook = new Webhook_1(webhookKey);
6413
+ const standardWebhook = new Webhook(webhookKey);
6247
6414
  try {
6248
6415
  standardWebhook.verify(body, headers);
6249
6416
  } catch (e) {
6250
- if (e instanceof WebhookVerificationError_1) {
6417
+ if (e instanceof WebhookVerificationError) {
6251
6418
  throw new Error(e.message);
6252
6419
  }
6253
6420
  throw e;