@dodopayments/sveltekit 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1500 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1500 -119
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4274,7 +4274,7 @@ const safeJSON = (text) => {
|
|
|
4274
4274
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4275
4275
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4276
4276
|
|
|
4277
|
-
const VERSION = '2.
|
|
4277
|
+
const VERSION = '2.23.2'; // x-release-please-version
|
|
4278
4278
|
|
|
4279
4279
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4280
4280
|
/**
|
|
@@ -4484,6 +4484,25 @@ const FallbackEncoder = ({ headers, body }) => {
|
|
|
4484
4484
|
};
|
|
4485
4485
|
};
|
|
4486
4486
|
|
|
4487
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4488
|
+
/**
|
|
4489
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
4490
|
+
*/
|
|
4491
|
+
function stringifyQuery(query) {
|
|
4492
|
+
return Object.entries(query)
|
|
4493
|
+
.filter(([_, value]) => typeof value !== 'undefined')
|
|
4494
|
+
.map(([key, value]) => {
|
|
4495
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
4496
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
4497
|
+
}
|
|
4498
|
+
if (value === null) {
|
|
4499
|
+
return `${encodeURIComponent(key)}=`;
|
|
4500
|
+
}
|
|
4501
|
+
throw new DodoPaymentsError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
4502
|
+
})
|
|
4503
|
+
.join('&');
|
|
4504
|
+
}
|
|
4505
|
+
|
|
4487
4506
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4488
4507
|
const levelNumbers = {
|
|
4489
4508
|
off: 0,
|
|
@@ -4577,6 +4596,11 @@ async function defaultParseResponse(client, props) {
|
|
|
4577
4596
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
4578
4597
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
4579
4598
|
if (isJSON) {
|
|
4599
|
+
const contentLength = response.headers.get('content-length');
|
|
4600
|
+
if (contentLength === '0') {
|
|
4601
|
+
// if there is no content we can't do anything
|
|
4602
|
+
return undefined;
|
|
4603
|
+
}
|
|
4580
4604
|
const json = await response.json();
|
|
4581
4605
|
return json;
|
|
4582
4606
|
}
|
|
@@ -4997,6 +5021,16 @@ class Addons extends APIResource {
|
|
|
4997
5021
|
}
|
|
4998
5022
|
}
|
|
4999
5023
|
|
|
5024
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5025
|
+
let Balances$1 = class Balances extends APIResource {
|
|
5026
|
+
retrieveLedger(query = {}, options) {
|
|
5027
|
+
return this._client.getAPIList('/balances/ledger', (DefaultPageNumberPagination), {
|
|
5028
|
+
query,
|
|
5029
|
+
...options,
|
|
5030
|
+
});
|
|
5031
|
+
}
|
|
5032
|
+
};
|
|
5033
|
+
|
|
5000
5034
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5001
5035
|
class Brands extends APIResource {
|
|
5002
5036
|
create(body, options) {
|
|
@@ -5027,66 +5061,155 @@ class CheckoutSessions extends APIResource {
|
|
|
5027
5061
|
retrieve(id, options) {
|
|
5028
5062
|
return this._client.get(path `/checkouts/${id}`, options);
|
|
5029
5063
|
}
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5033
|
-
let CustomerPortal$1 = class CustomerPortal extends APIResource {
|
|
5034
|
-
create(customerID, params = {}, options) {
|
|
5035
|
-
const { send_email } = params ?? {};
|
|
5036
|
-
return this._client.post(path `/customers/${customerID}/customer-portal/session`, {
|
|
5037
|
-
query: { send_email },
|
|
5038
|
-
...options,
|
|
5039
|
-
});
|
|
5040
|
-
}
|
|
5041
|
-
};
|
|
5042
|
-
|
|
5043
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5044
|
-
class LedgerEntries extends APIResource {
|
|
5045
|
-
create(customerID, body, options) {
|
|
5046
|
-
return this._client.post(path `/customers/${customerID}/wallets/ledger-entries`, { body, ...options });
|
|
5047
|
-
}
|
|
5048
|
-
list(customerID, query = {}, options) {
|
|
5049
|
-
return this._client.getAPIList(path `/customers/${customerID}/wallets/ledger-entries`, (DefaultPageNumberPagination), { query, ...options });
|
|
5050
|
-
}
|
|
5051
|
-
}
|
|
5052
|
-
|
|
5053
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5054
|
-
class Wallets extends APIResource {
|
|
5055
|
-
constructor() {
|
|
5056
|
-
super(...arguments);
|
|
5057
|
-
this.ledgerEntries = new LedgerEntries(this._client);
|
|
5058
|
-
}
|
|
5059
|
-
list(customerID, options) {
|
|
5060
|
-
return this._client.get(path `/customers/${customerID}/wallets`, options);
|
|
5064
|
+
preview(body, options) {
|
|
5065
|
+
return this._client.post('/checkouts/preview', { body, ...options });
|
|
5061
5066
|
}
|
|
5062
5067
|
}
|
|
5063
|
-
Wallets.LedgerEntries = LedgerEntries;
|
|
5064
5068
|
|
|
5065
5069
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5066
|
-
class
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5070
|
+
class Balances extends APIResource {
|
|
5071
|
+
/**
|
|
5072
|
+
* Returns the credit balance details for a specific customer and credit
|
|
5073
|
+
* entitlement.
|
|
5074
|
+
*
|
|
5075
|
+
* # Authentication
|
|
5076
|
+
*
|
|
5077
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5078
|
+
*
|
|
5079
|
+
* # Path Parameters
|
|
5080
|
+
*
|
|
5081
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5082
|
+
* - `customer_id` - The unique identifier of the customer
|
|
5083
|
+
*
|
|
5084
|
+
* # Responses
|
|
5085
|
+
*
|
|
5086
|
+
* - `200 OK` - Returns the customer's balance
|
|
5087
|
+
* - `404 Not Found` - Credit entitlement or customer balance not found
|
|
5088
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5089
|
+
*/
|
|
5090
|
+
retrieve(customerID, params, options) {
|
|
5091
|
+
const { credit_entitlement_id } = params;
|
|
5092
|
+
return this._client.get(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}`, options);
|
|
5071
5093
|
}
|
|
5072
|
-
|
|
5073
|
-
|
|
5094
|
+
/**
|
|
5095
|
+
* Returns a paginated list of customer credit balances for the given credit
|
|
5096
|
+
* entitlement.
|
|
5097
|
+
*
|
|
5098
|
+
* # Authentication
|
|
5099
|
+
*
|
|
5100
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5101
|
+
*
|
|
5102
|
+
* # Path Parameters
|
|
5103
|
+
*
|
|
5104
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5105
|
+
*
|
|
5106
|
+
* # Query Parameters
|
|
5107
|
+
*
|
|
5108
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5109
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5110
|
+
* - `customer_id` - Optional filter by specific customer
|
|
5111
|
+
*
|
|
5112
|
+
* # Responses
|
|
5113
|
+
*
|
|
5114
|
+
* - `200 OK` - Returns list of customer balances
|
|
5115
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
5116
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5117
|
+
*/
|
|
5118
|
+
list(creditEntitlementID, query = {}, options) {
|
|
5119
|
+
return this._client.getAPIList(path `/credit-entitlements/${creditEntitlementID}/balances`, (DefaultPageNumberPagination), { query, ...options });
|
|
5074
5120
|
}
|
|
5075
|
-
|
|
5076
|
-
|
|
5121
|
+
/**
|
|
5122
|
+
* For credit entries, a new grant is created. For debit entries, credits are
|
|
5123
|
+
* deducted from existing grants using FIFO (oldest first).
|
|
5124
|
+
*
|
|
5125
|
+
* # Authentication
|
|
5126
|
+
*
|
|
5127
|
+
* Requires an API key with `Editor` role.
|
|
5128
|
+
*
|
|
5129
|
+
* # Path Parameters
|
|
5130
|
+
*
|
|
5131
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5132
|
+
* - `customer_id` - The unique identifier of the customer
|
|
5133
|
+
*
|
|
5134
|
+
* # Request Body
|
|
5135
|
+
*
|
|
5136
|
+
* - `entry_type` - "credit" or "debit"
|
|
5137
|
+
* - `amount` - Amount to credit or debit
|
|
5138
|
+
* - `reason` - Optional human-readable reason
|
|
5139
|
+
* - `expires_at` - Optional expiration for credited amount (only for credit type)
|
|
5140
|
+
* - `idempotency_key` - Optional key to prevent duplicate entries
|
|
5141
|
+
*
|
|
5142
|
+
* # Responses
|
|
5143
|
+
*
|
|
5144
|
+
* - `201 Created` - Ledger entry created successfully
|
|
5145
|
+
* - `400 Bad Request` - Invalid request (e.g., debit with insufficient balance)
|
|
5146
|
+
* - `404 Not Found` - Credit entitlement or customer not found
|
|
5147
|
+
* - `409 Conflict` - Idempotency key already exists
|
|
5148
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5149
|
+
*/
|
|
5150
|
+
createLedgerEntry(customerID, params, options) {
|
|
5151
|
+
const { credit_entitlement_id, ...body } = params;
|
|
5152
|
+
return this._client.post(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/ledger-entries`, { body, ...options });
|
|
5077
5153
|
}
|
|
5078
|
-
|
|
5079
|
-
|
|
5154
|
+
/**
|
|
5155
|
+
* Returns a paginated list of credit grants with optional filtering by status.
|
|
5156
|
+
*
|
|
5157
|
+
* # Authentication
|
|
5158
|
+
*
|
|
5159
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5160
|
+
*
|
|
5161
|
+
* # Path Parameters
|
|
5162
|
+
*
|
|
5163
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5164
|
+
* - `customer_id` - The unique identifier of the customer
|
|
5165
|
+
*
|
|
5166
|
+
* # Query Parameters
|
|
5167
|
+
*
|
|
5168
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5169
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5170
|
+
* - `status` - Filter by status: active, expired, depleted
|
|
5171
|
+
*
|
|
5172
|
+
* # Responses
|
|
5173
|
+
*
|
|
5174
|
+
* - `200 OK` - Returns list of grants
|
|
5175
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
5176
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5177
|
+
*/
|
|
5178
|
+
listGrants(customerID, params, options) {
|
|
5179
|
+
const { credit_entitlement_id, ...query } = params;
|
|
5180
|
+
return this._client.getAPIList(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/grants`, (DefaultPageNumberPagination), { query, ...options });
|
|
5080
5181
|
}
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5182
|
+
/**
|
|
5183
|
+
* Returns a paginated list of credit transaction history with optional filtering.
|
|
5184
|
+
*
|
|
5185
|
+
* # Authentication
|
|
5186
|
+
*
|
|
5187
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5188
|
+
*
|
|
5189
|
+
* # Path Parameters
|
|
5190
|
+
*
|
|
5191
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5192
|
+
* - `customer_id` - The unique identifier of the customer
|
|
5193
|
+
*
|
|
5194
|
+
* # Query Parameters
|
|
5195
|
+
*
|
|
5196
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5197
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5198
|
+
* - `transaction_type` - Filter by transaction type
|
|
5199
|
+
* - `start_date` - Filter entries from this date
|
|
5200
|
+
* - `end_date` - Filter entries until this date
|
|
5201
|
+
*
|
|
5202
|
+
* # Responses
|
|
5203
|
+
*
|
|
5204
|
+
* - `200 OK` - Returns list of ledger entries
|
|
5205
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
5206
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5207
|
+
*/
|
|
5208
|
+
listLedger(customerID, params, options) {
|
|
5209
|
+
const { credit_entitlement_id, ...query } = params;
|
|
5210
|
+
return this._client.getAPIList(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/ledger`, (DefaultPageNumberPagination), { query, ...options });
|
|
5086
5211
|
}
|
|
5087
5212
|
}
|
|
5088
|
-
Customers.CustomerPortal = CustomerPortal$1;
|
|
5089
|
-
Customers.Wallets = Wallets;
|
|
5090
5213
|
|
|
5091
5214
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5092
5215
|
const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
|
|
@@ -5156,6 +5279,313 @@ const buildHeaders = (newHeaders) => {
|
|
|
5156
5279
|
return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
|
|
5157
5280
|
};
|
|
5158
5281
|
|
|
5282
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5283
|
+
class CreditEntitlements extends APIResource {
|
|
5284
|
+
constructor() {
|
|
5285
|
+
super(...arguments);
|
|
5286
|
+
this.balances = new Balances(this._client);
|
|
5287
|
+
}
|
|
5288
|
+
/**
|
|
5289
|
+
* Credit entitlements define reusable credit templates that can be attached to
|
|
5290
|
+
* products. Each entitlement defines how credits behave in terms of expiration,
|
|
5291
|
+
* rollover, and overage.
|
|
5292
|
+
*
|
|
5293
|
+
* # Authentication
|
|
5294
|
+
*
|
|
5295
|
+
* Requires an API key with `Editor` role.
|
|
5296
|
+
*
|
|
5297
|
+
* # Request Body
|
|
5298
|
+
*
|
|
5299
|
+
* - `name` - Human-readable name of the credit entitlement (1-255 characters,
|
|
5300
|
+
* required)
|
|
5301
|
+
* - `description` - Optional description (max 1000 characters)
|
|
5302
|
+
* - `precision` - Decimal precision for credit amounts (0-10 decimal places)
|
|
5303
|
+
* - `unit` - Unit of measurement for the credit (e.g., "API Calls", "Tokens",
|
|
5304
|
+
* "Credits")
|
|
5305
|
+
* - `expires_after_days` - Number of days after which credits expire (optional)
|
|
5306
|
+
* - `rollover_enabled` - Whether unused credits can rollover to the next period
|
|
5307
|
+
* - `rollover_percentage` - Percentage of unused credits that rollover (0-100)
|
|
5308
|
+
* - `rollover_timeframe_count` - Count of timeframe periods for rollover limit
|
|
5309
|
+
* - `rollover_timeframe_interval` - Interval type (day, week, month, year)
|
|
5310
|
+
* - `max_rollover_count` - Maximum number of times credits can be rolled over
|
|
5311
|
+
* - `overage_enabled` - Whether overage charges apply when credits run out
|
|
5312
|
+
* (requires price_per_unit)
|
|
5313
|
+
* - `overage_limit` - Maximum overage units allowed (optional)
|
|
5314
|
+
* - `currency` - Currency for pricing (required if price_per_unit is set)
|
|
5315
|
+
* - `price_per_unit` - Price per credit unit (decimal)
|
|
5316
|
+
*
|
|
5317
|
+
* # Responses
|
|
5318
|
+
*
|
|
5319
|
+
* - `201 Created` - Credit entitlement created successfully, returns the full
|
|
5320
|
+
* entitlement object
|
|
5321
|
+
* - `422 Unprocessable Entity` - Invalid request parameters or validation failure
|
|
5322
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5323
|
+
*
|
|
5324
|
+
* # Business Logic
|
|
5325
|
+
*
|
|
5326
|
+
* - A unique ID with prefix `cde_` is automatically generated for the entitlement
|
|
5327
|
+
* - Created and updated timestamps are automatically set
|
|
5328
|
+
* - Currency is required when price_per_unit is set
|
|
5329
|
+
* - price_per_unit is required when overage_enabled is true
|
|
5330
|
+
* - rollover_timeframe_count and rollover_timeframe_interval must both be set or
|
|
5331
|
+
* both be null
|
|
5332
|
+
*/
|
|
5333
|
+
create(body, options) {
|
|
5334
|
+
return this._client.post('/credit-entitlements', { body, ...options });
|
|
5335
|
+
}
|
|
5336
|
+
/**
|
|
5337
|
+
* Returns the full details of a single credit entitlement including all
|
|
5338
|
+
* configuration settings for expiration, rollover, and overage policies.
|
|
5339
|
+
*
|
|
5340
|
+
* # Authentication
|
|
5341
|
+
*
|
|
5342
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5343
|
+
*
|
|
5344
|
+
* # Path Parameters
|
|
5345
|
+
*
|
|
5346
|
+
* - `id` - The unique identifier of the credit entitlement (format: `cde_...`)
|
|
5347
|
+
*
|
|
5348
|
+
* # Responses
|
|
5349
|
+
*
|
|
5350
|
+
* - `200 OK` - Returns the full credit entitlement object
|
|
5351
|
+
* - `404 Not Found` - Credit entitlement does not exist or does not belong to the
|
|
5352
|
+
* authenticated business
|
|
5353
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5354
|
+
*
|
|
5355
|
+
* # Business Logic
|
|
5356
|
+
*
|
|
5357
|
+
* - Only non-deleted credit entitlements can be retrieved through this endpoint
|
|
5358
|
+
* - The entitlement must belong to the authenticated business (business_id check)
|
|
5359
|
+
* - Deleted entitlements return a 404 error and must be retrieved via the list
|
|
5360
|
+
* endpoint with `deleted=true`
|
|
5361
|
+
*/
|
|
5362
|
+
retrieve(id, options) {
|
|
5363
|
+
return this._client.get(path `/credit-entitlements/${id}`, options);
|
|
5364
|
+
}
|
|
5365
|
+
/**
|
|
5366
|
+
* Allows partial updates to a credit entitlement's configuration. Only the fields
|
|
5367
|
+
* provided in the request body will be updated; all other fields remain unchanged.
|
|
5368
|
+
* This endpoint supports nullable fields using the double option pattern.
|
|
5369
|
+
*
|
|
5370
|
+
* # Authentication
|
|
5371
|
+
*
|
|
5372
|
+
* Requires an API key with `Editor` role.
|
|
5373
|
+
*
|
|
5374
|
+
* # Path Parameters
|
|
5375
|
+
*
|
|
5376
|
+
* - `id` - The unique identifier of the credit entitlement to update (format:
|
|
5377
|
+
* `cde_...`)
|
|
5378
|
+
*
|
|
5379
|
+
* # Request Body (all fields optional)
|
|
5380
|
+
*
|
|
5381
|
+
* - `name` - Human-readable name of the credit entitlement (1-255 characters)
|
|
5382
|
+
* - `description` - Optional description (max 1000 characters)
|
|
5383
|
+
* - `unit` - Unit of measurement for the credit (1-50 characters)
|
|
5384
|
+
*
|
|
5385
|
+
* Note: `precision` cannot be modified after creation as it would invalidate
|
|
5386
|
+
* existing grants.
|
|
5387
|
+
*
|
|
5388
|
+
* - `expires_after_days` - Number of days after which credits expire (use `null`
|
|
5389
|
+
* to remove expiration)
|
|
5390
|
+
* - `rollover_enabled` - Whether unused credits can rollover to the next period
|
|
5391
|
+
* - `rollover_percentage` - Percentage of unused credits that rollover (0-100,
|
|
5392
|
+
* nullable)
|
|
5393
|
+
* - `rollover_timeframe_count` - Count of timeframe periods for rollover limit
|
|
5394
|
+
* (nullable)
|
|
5395
|
+
* - `rollover_timeframe_interval` - Interval type (day, week, month, year,
|
|
5396
|
+
* nullable)
|
|
5397
|
+
* - `max_rollover_count` - Maximum number of times credits can be rolled over
|
|
5398
|
+
* (nullable)
|
|
5399
|
+
* - `overage_enabled` - Whether overage charges apply when credits run out
|
|
5400
|
+
* - `overage_limit` - Maximum overage units allowed (nullable)
|
|
5401
|
+
* - `currency` - Currency for pricing (nullable)
|
|
5402
|
+
* - `price_per_unit` - Price per credit unit (decimal, nullable)
|
|
5403
|
+
*
|
|
5404
|
+
* # Responses
|
|
5405
|
+
*
|
|
5406
|
+
* - `200 OK` - Credit entitlement updated successfully
|
|
5407
|
+
* - `404 Not Found` - Credit entitlement does not exist or does not belong to the
|
|
5408
|
+
* authenticated business
|
|
5409
|
+
* - `422 Unprocessable Entity` - Invalid request parameters or validation failure
|
|
5410
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5411
|
+
*
|
|
5412
|
+
* # Business Logic
|
|
5413
|
+
*
|
|
5414
|
+
* - Only non-deleted credit entitlements can be updated
|
|
5415
|
+
* - Fields set to `null` explicitly will clear the database value (using double
|
|
5416
|
+
* option pattern)
|
|
5417
|
+
* - The `updated_at` timestamp is automatically updated on successful modification
|
|
5418
|
+
* - Changes take effect immediately but do not retroactively affect existing
|
|
5419
|
+
* credit grants
|
|
5420
|
+
* - The merged state is validated: currency required with price, rollover
|
|
5421
|
+
* timeframe fields together, price required for overage
|
|
5422
|
+
*/
|
|
5423
|
+
update(id, body, options) {
|
|
5424
|
+
return this._client.patch(path `/credit-entitlements/${id}`, {
|
|
5425
|
+
body,
|
|
5426
|
+
...options,
|
|
5427
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5428
|
+
});
|
|
5429
|
+
}
|
|
5430
|
+
/**
|
|
5431
|
+
* Returns a paginated list of credit entitlements, allowing filtering of deleted
|
|
5432
|
+
* entitlements. By default, only non-deleted entitlements are returned.
|
|
5433
|
+
*
|
|
5434
|
+
* # Authentication
|
|
5435
|
+
*
|
|
5436
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5437
|
+
*
|
|
5438
|
+
* # Query Parameters
|
|
5439
|
+
*
|
|
5440
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5441
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5442
|
+
* - `deleted` - Boolean flag to list deleted entitlements instead of active ones
|
|
5443
|
+
* (default: false)
|
|
5444
|
+
*
|
|
5445
|
+
* # Responses
|
|
5446
|
+
*
|
|
5447
|
+
* - `200 OK` - Returns a list of credit entitlements wrapped in a response object
|
|
5448
|
+
* - `422 Unprocessable Entity` - Invalid query parameters (e.g., page_size > 100)
|
|
5449
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5450
|
+
*
|
|
5451
|
+
* # Business Logic
|
|
5452
|
+
*
|
|
5453
|
+
* - Results are ordered by creation date in descending order (newest first)
|
|
5454
|
+
* - Only entitlements belonging to the authenticated business are returned
|
|
5455
|
+
* - The `deleted` parameter controls visibility of soft-deleted entitlements
|
|
5456
|
+
* - Pagination uses offset-based pagination (offset = page_number \* page_size)
|
|
5457
|
+
*/
|
|
5458
|
+
list(query = {}, options) {
|
|
5459
|
+
return this._client.getAPIList('/credit-entitlements', (DefaultPageNumberPagination), {
|
|
5460
|
+
query,
|
|
5461
|
+
...options,
|
|
5462
|
+
});
|
|
5463
|
+
}
|
|
5464
|
+
delete(id, options) {
|
|
5465
|
+
return this._client.delete(path `/credit-entitlements/${id}`, {
|
|
5466
|
+
...options,
|
|
5467
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5468
|
+
});
|
|
5469
|
+
}
|
|
5470
|
+
/**
|
|
5471
|
+
* Undeletes a soft-deleted credit entitlement by clearing `deleted_at`, making it
|
|
5472
|
+
* available again through standard list and get endpoints.
|
|
5473
|
+
*
|
|
5474
|
+
* # Authentication
|
|
5475
|
+
*
|
|
5476
|
+
* Requires an API key with `Editor` role.
|
|
5477
|
+
*
|
|
5478
|
+
* # Path Parameters
|
|
5479
|
+
*
|
|
5480
|
+
* - `id` - The unique identifier of the credit entitlement to restore (format:
|
|
5481
|
+
* `cde_...`)
|
|
5482
|
+
*
|
|
5483
|
+
* # Responses
|
|
5484
|
+
*
|
|
5485
|
+
* - `200 OK` - Credit entitlement restored successfully
|
|
5486
|
+
* - `500 Internal Server Error` - Database error, entitlement not found, or
|
|
5487
|
+
* entitlement is not deleted
|
|
5488
|
+
*
|
|
5489
|
+
* # Business Logic
|
|
5490
|
+
*
|
|
5491
|
+
* - Only deleted credit entitlements can be restored
|
|
5492
|
+
* - The query filters for `deleted_at IS NOT NULL`, so non-deleted entitlements
|
|
5493
|
+
* will result in 0 rows affected
|
|
5494
|
+
* - If no rows are affected (entitlement doesn't exist, doesn't belong to
|
|
5495
|
+
* business, or is not deleted), returns 500
|
|
5496
|
+
* - The `updated_at` timestamp is automatically updated on successful restoration
|
|
5497
|
+
* - Once restored, the entitlement becomes immediately available in the standard
|
|
5498
|
+
* list and get endpoints
|
|
5499
|
+
* - All configuration settings are preserved during delete/restore operations
|
|
5500
|
+
*
|
|
5501
|
+
* # Error Handling
|
|
5502
|
+
*
|
|
5503
|
+
* This endpoint returns 500 Internal Server Error in several cases:
|
|
5504
|
+
*
|
|
5505
|
+
* - The credit entitlement does not exist
|
|
5506
|
+
* - The credit entitlement belongs to a different business
|
|
5507
|
+
* - The credit entitlement is not currently deleted (already active)
|
|
5508
|
+
*
|
|
5509
|
+
* Callers should verify the entitlement exists and is deleted before calling this
|
|
5510
|
+
* endpoint.
|
|
5511
|
+
*/
|
|
5512
|
+
undelete(id, options) {
|
|
5513
|
+
return this._client.post(path `/credit-entitlements/${id}/undelete`, {
|
|
5514
|
+
...options,
|
|
5515
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5516
|
+
});
|
|
5517
|
+
}
|
|
5518
|
+
}
|
|
5519
|
+
CreditEntitlements.Balances = Balances;
|
|
5520
|
+
|
|
5521
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5522
|
+
let CustomerPortal$1 = class CustomerPortal extends APIResource {
|
|
5523
|
+
create(customerID, params = {}, options) {
|
|
5524
|
+
const { send_email } = params ?? {};
|
|
5525
|
+
return this._client.post(path `/customers/${customerID}/customer-portal/session`, {
|
|
5526
|
+
query: { send_email },
|
|
5527
|
+
...options,
|
|
5528
|
+
});
|
|
5529
|
+
}
|
|
5530
|
+
};
|
|
5531
|
+
|
|
5532
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5533
|
+
class LedgerEntries extends APIResource {
|
|
5534
|
+
create(customerID, body, options) {
|
|
5535
|
+
return this._client.post(path `/customers/${customerID}/wallets/ledger-entries`, { body, ...options });
|
|
5536
|
+
}
|
|
5537
|
+
list(customerID, query = {}, options) {
|
|
5538
|
+
return this._client.getAPIList(path `/customers/${customerID}/wallets/ledger-entries`, (DefaultPageNumberPagination), { query, ...options });
|
|
5539
|
+
}
|
|
5540
|
+
}
|
|
5541
|
+
|
|
5542
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5543
|
+
class Wallets extends APIResource {
|
|
5544
|
+
constructor() {
|
|
5545
|
+
super(...arguments);
|
|
5546
|
+
this.ledgerEntries = new LedgerEntries(this._client);
|
|
5547
|
+
}
|
|
5548
|
+
list(customerID, options) {
|
|
5549
|
+
return this._client.get(path `/customers/${customerID}/wallets`, options);
|
|
5550
|
+
}
|
|
5551
|
+
}
|
|
5552
|
+
Wallets.LedgerEntries = LedgerEntries;
|
|
5553
|
+
|
|
5554
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5555
|
+
class Customers extends APIResource {
|
|
5556
|
+
constructor() {
|
|
5557
|
+
super(...arguments);
|
|
5558
|
+
this.customerPortal = new CustomerPortal$1(this._client);
|
|
5559
|
+
this.wallets = new Wallets(this._client);
|
|
5560
|
+
}
|
|
5561
|
+
create(body, options) {
|
|
5562
|
+
return this._client.post('/customers', { body, ...options });
|
|
5563
|
+
}
|
|
5564
|
+
retrieve(customerID, options) {
|
|
5565
|
+
return this._client.get(path `/customers/${customerID}`, options);
|
|
5566
|
+
}
|
|
5567
|
+
update(customerID, body, options) {
|
|
5568
|
+
return this._client.patch(path `/customers/${customerID}`, { body, ...options });
|
|
5569
|
+
}
|
|
5570
|
+
list(query = {}, options) {
|
|
5571
|
+
return this._client.getAPIList('/customers', (DefaultPageNumberPagination), {
|
|
5572
|
+
query,
|
|
5573
|
+
...options,
|
|
5574
|
+
});
|
|
5575
|
+
}
|
|
5576
|
+
/**
|
|
5577
|
+
* List all credit entitlements for a customer with their current balances
|
|
5578
|
+
*/
|
|
5579
|
+
listCreditEntitlements(customerID, options) {
|
|
5580
|
+
return this._client.get(path `/customers/${customerID}/credit-entitlements`, options);
|
|
5581
|
+
}
|
|
5582
|
+
retrievePaymentMethods(customerID, options) {
|
|
5583
|
+
return this._client.get(path `/customers/${customerID}/payment-methods`, options);
|
|
5584
|
+
}
|
|
5585
|
+
}
|
|
5586
|
+
Customers.CustomerPortal = CustomerPortal$1;
|
|
5587
|
+
Customers.Wallets = Wallets;
|
|
5588
|
+
|
|
5159
5589
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5160
5590
|
class Discounts extends APIResource {
|
|
5161
5591
|
/**
|
|
@@ -5195,6 +5625,14 @@ class Discounts extends APIResource {
|
|
|
5195
5625
|
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5196
5626
|
});
|
|
5197
5627
|
}
|
|
5628
|
+
/**
|
|
5629
|
+
* Validate and fetch a discount by its code name (e.g., "SAVE20"). This allows
|
|
5630
|
+
* real-time validation directly against the API using the human-readable discount
|
|
5631
|
+
* code instead of requiring the internal discount_id.
|
|
5632
|
+
*/
|
|
5633
|
+
retrieveByCode(code, options) {
|
|
5634
|
+
return this._client.get(path `/discounts/code/${code}`, options);
|
|
5635
|
+
}
|
|
5198
5636
|
}
|
|
5199
5637
|
|
|
5200
5638
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
@@ -5393,6 +5831,9 @@ class Misc extends APIResource {
|
|
|
5393
5831
|
|
|
5394
5832
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5395
5833
|
class Payments extends APIResource {
|
|
5834
|
+
/**
|
|
5835
|
+
* @deprecated
|
|
5836
|
+
*/
|
|
5396
5837
|
create(body, options) {
|
|
5397
5838
|
return this._client.post('/payments', { body, ...options });
|
|
5398
5839
|
}
|
|
@@ -5428,11 +5869,29 @@ class Images extends APIResource {
|
|
|
5428
5869
|
}
|
|
5429
5870
|
}
|
|
5430
5871
|
|
|
5872
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5873
|
+
class ShortLinks extends APIResource {
|
|
5874
|
+
/**
|
|
5875
|
+
* Gives a Short Checkout URL with custom slug for a product. Uses a Static
|
|
5876
|
+
* Checkout URL under the hood.
|
|
5877
|
+
*/
|
|
5878
|
+
create(id, body, options) {
|
|
5879
|
+
return this._client.post(path `/products/${id}/short_links`, { body, ...options });
|
|
5880
|
+
}
|
|
5881
|
+
/**
|
|
5882
|
+
* Lists all short links created by the business.
|
|
5883
|
+
*/
|
|
5884
|
+
list(query = {}, options) {
|
|
5885
|
+
return this._client.getAPIList('/products/short_links', (DefaultPageNumberPagination), { query, ...options });
|
|
5886
|
+
}
|
|
5887
|
+
}
|
|
5888
|
+
|
|
5431
5889
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5432
5890
|
class Products extends APIResource {
|
|
5433
5891
|
constructor() {
|
|
5434
5892
|
super(...arguments);
|
|
5435
5893
|
this.images = new Images(this._client);
|
|
5894
|
+
this.shortLinks = new ShortLinks(this._client);
|
|
5436
5895
|
}
|
|
5437
5896
|
create(body, options) {
|
|
5438
5897
|
return this._client.post('/products', { body, ...options });
|
|
@@ -5470,6 +5929,7 @@ class Products extends APIResource {
|
|
|
5470
5929
|
}
|
|
5471
5930
|
}
|
|
5472
5931
|
Products.Images = Images;
|
|
5932
|
+
Products.ShortLinks = ShortLinks;
|
|
5473
5933
|
|
|
5474
5934
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5475
5935
|
class Refunds extends APIResource {
|
|
@@ -5489,6 +5949,9 @@ class Refunds extends APIResource {
|
|
|
5489
5949
|
|
|
5490
5950
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5491
5951
|
class Subscriptions extends APIResource {
|
|
5952
|
+
/**
|
|
5953
|
+
* @deprecated
|
|
5954
|
+
*/
|
|
5492
5955
|
create(body, options) {
|
|
5493
5956
|
return this._client.post('/subscriptions', { body, ...options });
|
|
5494
5957
|
}
|
|
@@ -5514,6 +5977,15 @@ class Subscriptions extends APIResource {
|
|
|
5514
5977
|
charge(subscriptionID, body, options) {
|
|
5515
5978
|
return this._client.post(path `/subscriptions/${subscriptionID}/charge`, { body, ...options });
|
|
5516
5979
|
}
|
|
5980
|
+
previewChangePlan(subscriptionID, body, options) {
|
|
5981
|
+
return this._client.post(path `/subscriptions/${subscriptionID}/change-plan/preview`, {
|
|
5982
|
+
body,
|
|
5983
|
+
...options,
|
|
5984
|
+
});
|
|
5985
|
+
}
|
|
5986
|
+
retrieveCreditUsage(subscriptionID, options) {
|
|
5987
|
+
return this._client.get(path `/subscriptions/${subscriptionID}/credit-usage`, options);
|
|
5988
|
+
}
|
|
5517
5989
|
/**
|
|
5518
5990
|
* Get detailed usage history for a subscription that includes usage-based billing
|
|
5519
5991
|
* (metered components). This endpoint provides insights into customer usage
|
|
@@ -5561,6 +6033,12 @@ class Subscriptions extends APIResource {
|
|
|
5561
6033
|
retrieveUsageHistory(subscriptionID, query = {}, options) {
|
|
5562
6034
|
return this._client.getAPIList(path `/subscriptions/${subscriptionID}/usage-history`, (DefaultPageNumberPagination), { query, ...options });
|
|
5563
6035
|
}
|
|
6036
|
+
updatePaymentMethod(subscriptionID, body, options) {
|
|
6037
|
+
return this._client.post(path `/subscriptions/${subscriptionID}/update-payment-method`, {
|
|
6038
|
+
body,
|
|
6039
|
+
...options,
|
|
6040
|
+
});
|
|
6041
|
+
}
|
|
5564
6042
|
}
|
|
5565
6043
|
|
|
5566
6044
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
@@ -6682,6 +7160,8 @@ class DodoPayments {
|
|
|
6682
7160
|
this.webhookEvents = new WebhookEvents(this);
|
|
6683
7161
|
this.usageEvents = new UsageEvents(this);
|
|
6684
7162
|
this.meters = new Meters(this);
|
|
7163
|
+
this.balances = new Balances$1(this);
|
|
7164
|
+
this.creditEntitlements = new CreditEntitlements(this);
|
|
6685
7165
|
if (bearerToken === undefined) {
|
|
6686
7166
|
throw new DodoPaymentsError("The DODO_PAYMENTS_API_KEY environment variable is missing or empty; either provide it, or instantiate the DodoPayments client with an bearerToken option, like new DodoPayments({ bearerToken: 'My Bearer Token' }).");
|
|
6687
7167
|
}
|
|
@@ -6746,18 +7226,7 @@ class DodoPayments {
|
|
|
6746
7226
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
6747
7227
|
*/
|
|
6748
7228
|
stringifyQuery(query) {
|
|
6749
|
-
return
|
|
6750
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
6751
|
-
.map(([key, value]) => {
|
|
6752
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
6753
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
6754
|
-
}
|
|
6755
|
-
if (value === null) {
|
|
6756
|
-
return `${encodeURIComponent(key)}=`;
|
|
6757
|
-
}
|
|
6758
|
-
throw new DodoPaymentsError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
6759
|
-
})
|
|
6760
|
-
.join('&');
|
|
7229
|
+
return stringifyQuery(query);
|
|
6761
7230
|
}
|
|
6762
7231
|
getUserAgent() {
|
|
6763
7232
|
return `${this.constructor.name}/JS ${VERSION}`;
|
|
@@ -6921,7 +7390,9 @@ class DodoPayments {
|
|
|
6921
7390
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
6922
7391
|
}
|
|
6923
7392
|
getAPIList(path, Page, opts) {
|
|
6924
|
-
return this.requestAPIList(Page,
|
|
7393
|
+
return this.requestAPIList(Page, opts && 'then' in opts ?
|
|
7394
|
+
opts.then((opts) => ({ method: 'get', path, ...opts }))
|
|
7395
|
+
: { method: 'get', path, ...opts });
|
|
6925
7396
|
}
|
|
6926
7397
|
requestAPIList(Page, options) {
|
|
6927
7398
|
const request = this.makeRequest(options, null, undefined);
|
|
@@ -6929,9 +7400,10 @@ class DodoPayments {
|
|
|
6929
7400
|
}
|
|
6930
7401
|
async fetchWithTimeout(url, init, ms, controller) {
|
|
6931
7402
|
const { signal, method, ...options } = init || {};
|
|
7403
|
+
const abort = this._makeAbort(controller);
|
|
6932
7404
|
if (signal)
|
|
6933
|
-
signal.addEventListener('abort',
|
|
6934
|
-
const timeout = setTimeout(
|
|
7405
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
7406
|
+
const timeout = setTimeout(abort, ms);
|
|
6935
7407
|
const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) ||
|
|
6936
7408
|
(typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body);
|
|
6937
7409
|
const fetchOptions = {
|
|
@@ -6996,9 +7468,9 @@ class DodoPayments {
|
|
|
6996
7468
|
timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
|
|
6997
7469
|
}
|
|
6998
7470
|
}
|
|
6999
|
-
// If the API asks us to wait a certain amount of time
|
|
7000
|
-
//
|
|
7001
|
-
if (
|
|
7471
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
7472
|
+
// says, but otherwise calculate a default
|
|
7473
|
+
if (timeoutMillis === undefined) {
|
|
7002
7474
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
7003
7475
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
7004
7476
|
}
|
|
@@ -7060,6 +7532,11 @@ class DodoPayments {
|
|
|
7060
7532
|
this.validateHeaders(headers);
|
|
7061
7533
|
return headers.values;
|
|
7062
7534
|
}
|
|
7535
|
+
_makeAbort(controller) {
|
|
7536
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
7537
|
+
// would capture all request options, and cause a memory leak.
|
|
7538
|
+
return () => controller.abort();
|
|
7539
|
+
}
|
|
7063
7540
|
buildBody({ options: { body, headers: rawHeaders } }) {
|
|
7064
7541
|
if (!body) {
|
|
7065
7542
|
return { bodyHeaders: undefined, body: undefined };
|
|
@@ -7088,6 +7565,13 @@ class DodoPayments {
|
|
|
7088
7565
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
7089
7566
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
7090
7567
|
}
|
|
7568
|
+
else if (typeof body === 'object' &&
|
|
7569
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
7570
|
+
return {
|
|
7571
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
7572
|
+
body: this.stringifyQuery(body),
|
|
7573
|
+
};
|
|
7574
|
+
}
|
|
7091
7575
|
else {
|
|
7092
7576
|
return __classPrivateFieldGet(this, _DodoPayments_encoder, "f").call(this, { body, headers });
|
|
7093
7577
|
}
|
|
@@ -7132,6 +7616,8 @@ DodoPayments.Webhooks = Webhooks$1;
|
|
|
7132
7616
|
DodoPayments.WebhookEvents = WebhookEvents;
|
|
7133
7617
|
DodoPayments.UsageEvents = UsageEvents;
|
|
7134
7618
|
DodoPayments.Meters = Meters;
|
|
7619
|
+
DodoPayments.Balances = Balances$1;
|
|
7620
|
+
DodoPayments.CreditEntitlements = CreditEntitlements;
|
|
7135
7621
|
|
|
7136
7622
|
// src/checkout/checkout.ts
|
|
7137
7623
|
var checkoutQuerySchema = objectType({
|
|
@@ -7602,6 +8088,32 @@ var buildCheckoutUrl = async ({
|
|
|
7602
8088
|
}
|
|
7603
8089
|
};
|
|
7604
8090
|
|
|
8091
|
+
var __create = Object.create;
|
|
8092
|
+
var __defProp = Object.defineProperty;
|
|
8093
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8094
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8095
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8096
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8097
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
8098
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8099
|
+
};
|
|
8100
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8101
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8102
|
+
for (let key of __getOwnPropNames(from))
|
|
8103
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
8104
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
8105
|
+
}
|
|
8106
|
+
return to;
|
|
8107
|
+
};
|
|
8108
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
8109
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
8110
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
8111
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
8112
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
8113
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
8114
|
+
mod
|
|
8115
|
+
));
|
|
8116
|
+
|
|
7605
8117
|
const Checkout = (config) => {
|
|
7606
8118
|
const getHandler = async (event) => {
|
|
7607
8119
|
const searchParams = event.url.searchParams;
|
|
@@ -7684,23 +8196,33 @@ var PaymentSchema = objectType({
|
|
|
7684
8196
|
payload_type: literalType("Payment"),
|
|
7685
8197
|
billing: objectType({
|
|
7686
8198
|
city: stringType().nullable(),
|
|
7687
|
-
country: stringType()
|
|
8199
|
+
country: stringType(),
|
|
7688
8200
|
state: stringType().nullable(),
|
|
7689
8201
|
street: stringType().nullable(),
|
|
7690
8202
|
zipcode: stringType().nullable()
|
|
7691
8203
|
}),
|
|
7692
8204
|
brand_id: stringType(),
|
|
7693
8205
|
business_id: stringType(),
|
|
8206
|
+
card_holder_name: stringType().nullable(),
|
|
7694
8207
|
card_issuing_country: stringType().nullable(),
|
|
7695
8208
|
card_last_four: stringType().nullable(),
|
|
7696
8209
|
card_network: stringType().nullable(),
|
|
7697
8210
|
card_type: stringType().nullable(),
|
|
8211
|
+
checkout_session_id: stringType().nullable(),
|
|
7698
8212
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7699
8213
|
currency: stringType(),
|
|
8214
|
+
custom_field_responses: arrayType(
|
|
8215
|
+
objectType({
|
|
8216
|
+
key: stringType(),
|
|
8217
|
+
value: stringType()
|
|
8218
|
+
})
|
|
8219
|
+
).nullable(),
|
|
7700
8220
|
customer: objectType({
|
|
7701
8221
|
customer_id: stringType(),
|
|
7702
8222
|
email: stringType(),
|
|
7703
|
-
|
|
8223
|
+
metadata: recordType(anyType()),
|
|
8224
|
+
name: stringType(),
|
|
8225
|
+
phone_number: stringType().nullable()
|
|
7704
8226
|
}),
|
|
7705
8227
|
digital_products_delivered: booleanType(),
|
|
7706
8228
|
discount_id: stringType().nullable(),
|
|
@@ -7711,27 +8233,25 @@ var PaymentSchema = objectType({
|
|
|
7711
8233
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7712
8234
|
currency: stringType(),
|
|
7713
8235
|
dispute_id: stringType(),
|
|
7714
|
-
dispute_stage: enumType([
|
|
7715
|
-
"pre_dispute",
|
|
7716
|
-
"dispute_opened",
|
|
7717
|
-
"dispute_won",
|
|
7718
|
-
"dispute_lost"
|
|
7719
|
-
]),
|
|
8236
|
+
dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
|
|
7720
8237
|
dispute_status: enumType([
|
|
7721
8238
|
"dispute_opened",
|
|
7722
|
-
"
|
|
7723
|
-
"dispute_lost",
|
|
8239
|
+
"dispute_expired",
|
|
7724
8240
|
"dispute_accepted",
|
|
7725
8241
|
"dispute_cancelled",
|
|
7726
|
-
"dispute_challenged"
|
|
8242
|
+
"dispute_challenged",
|
|
8243
|
+
"dispute_won",
|
|
8244
|
+
"dispute_lost"
|
|
7727
8245
|
]),
|
|
7728
8246
|
payment_id: stringType(),
|
|
7729
8247
|
remarks: stringType().nullable()
|
|
7730
8248
|
})
|
|
7731
|
-
).
|
|
8249
|
+
).default([]),
|
|
7732
8250
|
error_code: stringType().nullable(),
|
|
7733
8251
|
error_message: stringType().nullable(),
|
|
7734
|
-
|
|
8252
|
+
invoice_id: stringType().nullable(),
|
|
8253
|
+
invoice_url: stringType().nullable(),
|
|
8254
|
+
metadata: recordType(anyType()),
|
|
7735
8255
|
payment_id: stringType(),
|
|
7736
8256
|
payment_link: stringType().nullable(),
|
|
7737
8257
|
payment_method: stringType().nullable(),
|
|
@@ -7744,21 +8264,34 @@ var PaymentSchema = objectType({
|
|
|
7744
8264
|
).nullable(),
|
|
7745
8265
|
refunds: arrayType(
|
|
7746
8266
|
objectType({
|
|
7747
|
-
amount: numberType(),
|
|
8267
|
+
amount: numberType().nullable(),
|
|
7748
8268
|
business_id: stringType(),
|
|
7749
8269
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7750
|
-
currency: stringType(),
|
|
8270
|
+
currency: stringType().nullable(),
|
|
7751
8271
|
is_partial: booleanType(),
|
|
7752
8272
|
payment_id: stringType(),
|
|
7753
8273
|
reason: stringType().nullable(),
|
|
7754
8274
|
refund_id: stringType(),
|
|
7755
|
-
status: enumType(["succeeded", "failed", "pending"])
|
|
8275
|
+
status: enumType(["succeeded", "failed", "pending", "review"])
|
|
7756
8276
|
})
|
|
7757
|
-
)
|
|
8277
|
+
),
|
|
8278
|
+
refund_status: enumType(["partial", "full"]).nullable(),
|
|
7758
8279
|
settlement_amount: numberType(),
|
|
7759
8280
|
settlement_currency: stringType(),
|
|
7760
8281
|
settlement_tax: numberType().nullable(),
|
|
7761
|
-
status: enumType([
|
|
8282
|
+
status: enumType([
|
|
8283
|
+
"succeeded",
|
|
8284
|
+
"failed",
|
|
8285
|
+
"cancelled",
|
|
8286
|
+
"processing",
|
|
8287
|
+
"requires_customer_action",
|
|
8288
|
+
"requires_merchant_action",
|
|
8289
|
+
"requires_payment_method",
|
|
8290
|
+
"requires_confirmation",
|
|
8291
|
+
"requires_capture",
|
|
8292
|
+
"partially_captured",
|
|
8293
|
+
"partially_captured_and_capturable"
|
|
8294
|
+
]).nullable(),
|
|
7762
8295
|
subscription_id: stringType().nullable(),
|
|
7763
8296
|
tax: numberType().nullable(),
|
|
7764
8297
|
total_amount: numberType(),
|
|
@@ -7771,10 +8304,10 @@ var SubscriptionSchema = objectType({
|
|
|
7771
8304
|
addon_id: stringType(),
|
|
7772
8305
|
quantity: numberType()
|
|
7773
8306
|
})
|
|
7774
|
-
)
|
|
8307
|
+
),
|
|
7775
8308
|
billing: objectType({
|
|
7776
8309
|
city: stringType().nullable(),
|
|
7777
|
-
country: stringType()
|
|
8310
|
+
country: stringType(),
|
|
7778
8311
|
state: stringType().nullable(),
|
|
7779
8312
|
street: stringType().nullable(),
|
|
7780
8313
|
zipcode: stringType().nullable()
|
|
@@ -7786,15 +8319,72 @@ var SubscriptionSchema = objectType({
|
|
|
7786
8319
|
customer: objectType({
|
|
7787
8320
|
customer_id: stringType(),
|
|
7788
8321
|
email: stringType(),
|
|
7789
|
-
|
|
8322
|
+
metadata: recordType(anyType()),
|
|
8323
|
+
name: stringType(),
|
|
8324
|
+
phone_number: stringType().nullable()
|
|
7790
8325
|
}),
|
|
8326
|
+
custom_field_responses: arrayType(
|
|
8327
|
+
objectType({
|
|
8328
|
+
key: stringType(),
|
|
8329
|
+
value: stringType()
|
|
8330
|
+
})
|
|
8331
|
+
).nullable(),
|
|
8332
|
+
discount_cycles_remaining: numberType().nullable(),
|
|
7791
8333
|
discount_id: stringType().nullable(),
|
|
7792
|
-
|
|
7793
|
-
|
|
8334
|
+
expires_at: stringType().transform((d) => new Date(d)).nullable(),
|
|
8335
|
+
credit_entitlement_cart: arrayType(
|
|
8336
|
+
objectType({
|
|
8337
|
+
credit_entitlement_id: stringType(),
|
|
8338
|
+
credit_entitlement_name: stringType(),
|
|
8339
|
+
credits_amount: stringType(),
|
|
8340
|
+
overage_balance: stringType(),
|
|
8341
|
+
overage_behavior: enumType([
|
|
8342
|
+
"forgive_at_reset",
|
|
8343
|
+
"invoice_at_billing",
|
|
8344
|
+
"carry_deficit",
|
|
8345
|
+
"carry_deficit_auto_repay"
|
|
8346
|
+
]),
|
|
8347
|
+
overage_enabled: booleanType(),
|
|
8348
|
+
product_id: stringType(),
|
|
8349
|
+
remaining_balance: stringType(),
|
|
8350
|
+
rollover_enabled: booleanType(),
|
|
8351
|
+
unit: stringType(),
|
|
8352
|
+
expires_after_days: numberType().nullable(),
|
|
8353
|
+
low_balance_threshold_percent: numberType().nullable(),
|
|
8354
|
+
max_rollover_count: numberType().nullable(),
|
|
8355
|
+
overage_limit: stringType().nullable(),
|
|
8356
|
+
rollover_percentage: numberType().nullable(),
|
|
8357
|
+
rollover_timeframe_count: numberType().nullable(),
|
|
8358
|
+
rollover_timeframe_interval: enumType(["Day", "Week", "Month", "Year"]).nullable()
|
|
8359
|
+
})
|
|
8360
|
+
),
|
|
8361
|
+
meter_credit_entitlement_cart: arrayType(
|
|
8362
|
+
objectType({
|
|
8363
|
+
credit_entitlement_id: stringType(),
|
|
8364
|
+
meter_id: stringType(),
|
|
8365
|
+
meter_name: stringType(),
|
|
8366
|
+
meter_units_per_credit: stringType(),
|
|
8367
|
+
product_id: stringType()
|
|
8368
|
+
})
|
|
8369
|
+
),
|
|
8370
|
+
meters: arrayType(
|
|
8371
|
+
objectType({
|
|
8372
|
+
currency: stringType(),
|
|
8373
|
+
description: stringType().nullable(),
|
|
8374
|
+
free_threshold: numberType(),
|
|
8375
|
+
measurement_unit: stringType(),
|
|
8376
|
+
meter_id: stringType(),
|
|
8377
|
+
name: stringType(),
|
|
8378
|
+
price_per_unit: stringType().nullable()
|
|
8379
|
+
})
|
|
8380
|
+
),
|
|
8381
|
+
metadata: recordType(anyType()),
|
|
8382
|
+
next_billing_date: stringType().transform((d) => new Date(d)),
|
|
7794
8383
|
on_demand: booleanType(),
|
|
7795
8384
|
payment_frequency_count: numberType(),
|
|
7796
8385
|
payment_frequency_interval: enumType(["Day", "Week", "Month", "Year"]),
|
|
7797
|
-
|
|
8386
|
+
payment_method_id: stringType().nullable(),
|
|
8387
|
+
previous_billing_date: stringType().transform((d) => new Date(d)),
|
|
7798
8388
|
product_id: stringType(),
|
|
7799
8389
|
quantity: numberType(),
|
|
7800
8390
|
recurring_pre_tax_amount: numberType(),
|
|
@@ -7802,7 +8392,6 @@ var SubscriptionSchema = objectType({
|
|
|
7802
8392
|
"pending",
|
|
7803
8393
|
"active",
|
|
7804
8394
|
"on_hold",
|
|
7805
|
-
"paused",
|
|
7806
8395
|
"cancelled",
|
|
7807
8396
|
"expired",
|
|
7808
8397
|
"failed"
|
|
@@ -7810,20 +8399,29 @@ var SubscriptionSchema = objectType({
|
|
|
7810
8399
|
subscription_id: stringType(),
|
|
7811
8400
|
subscription_period_count: numberType(),
|
|
7812
8401
|
subscription_period_interval: enumType(["Day", "Week", "Month", "Year"]),
|
|
8402
|
+
tax_id: stringType().nullable(),
|
|
7813
8403
|
tax_inclusive: booleanType(),
|
|
7814
8404
|
trial_period_days: numberType()
|
|
7815
8405
|
});
|
|
7816
8406
|
var RefundSchema = objectType({
|
|
7817
8407
|
payload_type: literalType("Refund"),
|
|
7818
|
-
amount: numberType(),
|
|
8408
|
+
amount: numberType().nullable(),
|
|
7819
8409
|
business_id: stringType(),
|
|
7820
8410
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7821
|
-
|
|
8411
|
+
customer: objectType({
|
|
8412
|
+
customer_id: stringType(),
|
|
8413
|
+
email: stringType(),
|
|
8414
|
+
metadata: recordType(anyType()),
|
|
8415
|
+
name: stringType(),
|
|
8416
|
+
phone_number: stringType().nullable()
|
|
8417
|
+
}),
|
|
8418
|
+
currency: stringType().nullable(),
|
|
7822
8419
|
is_partial: booleanType(),
|
|
8420
|
+
metadata: recordType(anyType()),
|
|
7823
8421
|
payment_id: stringType(),
|
|
7824
8422
|
reason: stringType().nullable(),
|
|
7825
8423
|
refund_id: stringType(),
|
|
7826
|
-
status: enumType(["succeeded", "failed", "pending"])
|
|
8424
|
+
status: enumType(["succeeded", "failed", "pending", "review"])
|
|
7827
8425
|
});
|
|
7828
8426
|
var DisputeSchema = objectType({
|
|
7829
8427
|
payload_type: literalType("Dispute"),
|
|
@@ -7831,27 +8429,31 @@ var DisputeSchema = objectType({
|
|
|
7831
8429
|
business_id: stringType(),
|
|
7832
8430
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7833
8431
|
currency: stringType(),
|
|
8432
|
+
customer: objectType({
|
|
8433
|
+
customer_id: stringType(),
|
|
8434
|
+
email: stringType(),
|
|
8435
|
+
metadata: recordType(anyType()),
|
|
8436
|
+
name: stringType(),
|
|
8437
|
+
phone_number: stringType().nullable()
|
|
8438
|
+
}),
|
|
7834
8439
|
dispute_id: stringType(),
|
|
7835
|
-
dispute_stage: enumType([
|
|
7836
|
-
"pre_dispute",
|
|
7837
|
-
"dispute_opened",
|
|
7838
|
-
"dispute_won",
|
|
7839
|
-
"dispute_lost"
|
|
7840
|
-
]),
|
|
8440
|
+
dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
|
|
7841
8441
|
dispute_status: enumType([
|
|
7842
8442
|
"dispute_opened",
|
|
7843
|
-
"
|
|
7844
|
-
"dispute_lost",
|
|
8443
|
+
"dispute_expired",
|
|
7845
8444
|
"dispute_accepted",
|
|
7846
8445
|
"dispute_cancelled",
|
|
7847
|
-
"dispute_challenged"
|
|
8446
|
+
"dispute_challenged",
|
|
8447
|
+
"dispute_won",
|
|
8448
|
+
"dispute_lost"
|
|
7848
8449
|
]),
|
|
7849
8450
|
payment_id: stringType(),
|
|
8451
|
+
reason: stringType().nullable(),
|
|
7850
8452
|
remarks: stringType().nullable()
|
|
7851
8453
|
});
|
|
7852
8454
|
var LicenseKeySchema = objectType({
|
|
7853
8455
|
payload_type: literalType("LicenseKey"),
|
|
7854
|
-
activations_limit: numberType(),
|
|
8456
|
+
activations_limit: numberType().nullable(),
|
|
7855
8457
|
business_id: stringType(),
|
|
7856
8458
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7857
8459
|
customer_id: stringType(),
|
|
@@ -7861,7 +8463,7 @@ var LicenseKeySchema = objectType({
|
|
|
7861
8463
|
key: stringType(),
|
|
7862
8464
|
payment_id: stringType(),
|
|
7863
8465
|
product_id: stringType(),
|
|
7864
|
-
status: enumType(["active", "
|
|
8466
|
+
status: enumType(["active", "expired", "disabled"]),
|
|
7865
8467
|
subscription_id: stringType().nullable()
|
|
7866
8468
|
});
|
|
7867
8469
|
var PaymentSucceededPayloadSchema = objectType({
|
|
@@ -7960,12 +8562,6 @@ var SubscriptionRenewedPayloadSchema = objectType({
|
|
|
7960
8562
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
7961
8563
|
data: SubscriptionSchema
|
|
7962
8564
|
});
|
|
7963
|
-
var SubscriptionPausedPayloadSchema = objectType({
|
|
7964
|
-
business_id: stringType(),
|
|
7965
|
-
type: literalType("subscription.paused"),
|
|
7966
|
-
timestamp: stringType().transform((d) => new Date(d)),
|
|
7967
|
-
data: SubscriptionSchema
|
|
7968
|
-
});
|
|
7969
8565
|
var SubscriptionPlanChangedPayloadSchema = objectType({
|
|
7970
8566
|
business_id: stringType(),
|
|
7971
8567
|
type: literalType("subscription.plan_changed"),
|
|
@@ -8002,6 +8598,94 @@ var LicenseKeyCreatedPayloadSchema = objectType({
|
|
|
8002
8598
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
8003
8599
|
data: LicenseKeySchema
|
|
8004
8600
|
});
|
|
8601
|
+
var CreditLedgerEntrySchema = objectType({
|
|
8602
|
+
payload_type: literalType("CreditLedgerEntry"),
|
|
8603
|
+
id: stringType(),
|
|
8604
|
+
amount: stringType(),
|
|
8605
|
+
balance_after: stringType(),
|
|
8606
|
+
balance_before: stringType(),
|
|
8607
|
+
business_id: stringType(),
|
|
8608
|
+
created_at: stringType().transform((d) => new Date(d)),
|
|
8609
|
+
credit_entitlement_id: stringType(),
|
|
8610
|
+
customer_id: stringType(),
|
|
8611
|
+
is_credit: booleanType(),
|
|
8612
|
+
overage_after: stringType(),
|
|
8613
|
+
overage_before: stringType(),
|
|
8614
|
+
transaction_type: enumType([
|
|
8615
|
+
"credit_added",
|
|
8616
|
+
"credit_deducted",
|
|
8617
|
+
"credit_expired",
|
|
8618
|
+
"credit_rolled_over",
|
|
8619
|
+
"rollover_forfeited",
|
|
8620
|
+
"overage_charged",
|
|
8621
|
+
"auto_top_up",
|
|
8622
|
+
"manual_adjustment",
|
|
8623
|
+
"refund"
|
|
8624
|
+
]),
|
|
8625
|
+
description: stringType().nullable(),
|
|
8626
|
+
grant_id: stringType().nullable(),
|
|
8627
|
+
reference_id: stringType().nullable(),
|
|
8628
|
+
reference_type: stringType().nullable()
|
|
8629
|
+
});
|
|
8630
|
+
var CreditBalanceLowSchema = objectType({
|
|
8631
|
+
payload_type: literalType("CreditBalanceLow"),
|
|
8632
|
+
customer_id: stringType(),
|
|
8633
|
+
subscription_id: stringType(),
|
|
8634
|
+
credit_entitlement_id: stringType(),
|
|
8635
|
+
credit_entitlement_name: stringType(),
|
|
8636
|
+
available_balance: stringType(),
|
|
8637
|
+
subscription_credits_amount: stringType(),
|
|
8638
|
+
threshold_percent: numberType(),
|
|
8639
|
+
threshold_amount: stringType()
|
|
8640
|
+
});
|
|
8641
|
+
var CreditAddedPayloadSchema = objectType({
|
|
8642
|
+
business_id: stringType(),
|
|
8643
|
+
type: literalType("credit.added"),
|
|
8644
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8645
|
+
data: CreditLedgerEntrySchema
|
|
8646
|
+
});
|
|
8647
|
+
var CreditDeductedPayloadSchema = objectType({
|
|
8648
|
+
business_id: stringType(),
|
|
8649
|
+
type: literalType("credit.deducted"),
|
|
8650
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8651
|
+
data: CreditLedgerEntrySchema
|
|
8652
|
+
});
|
|
8653
|
+
var CreditExpiredPayloadSchema = objectType({
|
|
8654
|
+
business_id: stringType(),
|
|
8655
|
+
type: literalType("credit.expired"),
|
|
8656
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8657
|
+
data: CreditLedgerEntrySchema
|
|
8658
|
+
});
|
|
8659
|
+
var CreditRolledOverPayloadSchema = objectType({
|
|
8660
|
+
business_id: stringType(),
|
|
8661
|
+
type: literalType("credit.rolled_over"),
|
|
8662
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8663
|
+
data: CreditLedgerEntrySchema
|
|
8664
|
+
});
|
|
8665
|
+
var CreditRolloverForfeitedPayloadSchema = objectType({
|
|
8666
|
+
business_id: stringType(),
|
|
8667
|
+
type: literalType("credit.rollover_forfeited"),
|
|
8668
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8669
|
+
data: CreditLedgerEntrySchema
|
|
8670
|
+
});
|
|
8671
|
+
var CreditOverageChargedPayloadSchema = objectType({
|
|
8672
|
+
business_id: stringType(),
|
|
8673
|
+
type: literalType("credit.overage_charged"),
|
|
8674
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8675
|
+
data: CreditLedgerEntrySchema
|
|
8676
|
+
});
|
|
8677
|
+
var CreditManualAdjustmentPayloadSchema = objectType({
|
|
8678
|
+
business_id: stringType(),
|
|
8679
|
+
type: literalType("credit.manual_adjustment"),
|
|
8680
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8681
|
+
data: CreditLedgerEntrySchema
|
|
8682
|
+
});
|
|
8683
|
+
var CreditBalanceLowPayloadSchema = objectType({
|
|
8684
|
+
business_id: stringType(),
|
|
8685
|
+
type: literalType("credit.balance_low"),
|
|
8686
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8687
|
+
data: CreditBalanceLowSchema
|
|
8688
|
+
});
|
|
8005
8689
|
var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
8006
8690
|
PaymentSucceededPayloadSchema,
|
|
8007
8691
|
PaymentFailedPayloadSchema,
|
|
@@ -8019,15 +8703,691 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
|
8019
8703
|
SubscriptionActivePayloadSchema,
|
|
8020
8704
|
SubscriptionOnHoldPayloadSchema,
|
|
8021
8705
|
SubscriptionRenewedPayloadSchema,
|
|
8022
|
-
SubscriptionPausedPayloadSchema,
|
|
8023
8706
|
SubscriptionPlanChangedPayloadSchema,
|
|
8024
8707
|
SubscriptionCancelledPayloadSchema,
|
|
8025
8708
|
SubscriptionFailedPayloadSchema,
|
|
8026
8709
|
SubscriptionExpiredPayloadSchema,
|
|
8027
8710
|
SubscriptionUpdatedPayloadSchema,
|
|
8028
|
-
LicenseKeyCreatedPayloadSchema
|
|
8711
|
+
LicenseKeyCreatedPayloadSchema,
|
|
8712
|
+
CreditAddedPayloadSchema,
|
|
8713
|
+
CreditDeductedPayloadSchema,
|
|
8714
|
+
CreditExpiredPayloadSchema,
|
|
8715
|
+
CreditRolledOverPayloadSchema,
|
|
8716
|
+
CreditRolloverForfeitedPayloadSchema,
|
|
8717
|
+
CreditOverageChargedPayloadSchema,
|
|
8718
|
+
CreditManualAdjustmentPayloadSchema,
|
|
8719
|
+
CreditBalanceLowPayloadSchema
|
|
8029
8720
|
]);
|
|
8030
8721
|
|
|
8722
|
+
// ../../node_modules/@stablelib/base64/lib/base64.js
|
|
8723
|
+
var require_base64 = __commonJS({
|
|
8724
|
+
"../../node_modules/@stablelib/base64/lib/base64.js"(exports) {
|
|
8725
|
+
var __extends = exports && exports.__extends || /* @__PURE__ */ function() {
|
|
8726
|
+
var extendStatics = function(d, b) {
|
|
8727
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
8728
|
+
d2.__proto__ = b2;
|
|
8729
|
+
} || function(d2, b2) {
|
|
8730
|
+
for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
|
|
8731
|
+
};
|
|
8732
|
+
return extendStatics(d, b);
|
|
8733
|
+
};
|
|
8734
|
+
return function(d, b) {
|
|
8735
|
+
extendStatics(d, b);
|
|
8736
|
+
function __() {
|
|
8737
|
+
this.constructor = d;
|
|
8738
|
+
}
|
|
8739
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8740
|
+
};
|
|
8741
|
+
}();
|
|
8742
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8743
|
+
var INVALID_BYTE = 256;
|
|
8744
|
+
var Coder = (
|
|
8745
|
+
/** @class */
|
|
8746
|
+
function() {
|
|
8747
|
+
function Coder2(_paddingCharacter) {
|
|
8748
|
+
if (_paddingCharacter === void 0) {
|
|
8749
|
+
_paddingCharacter = "=";
|
|
8750
|
+
}
|
|
8751
|
+
this._paddingCharacter = _paddingCharacter;
|
|
8752
|
+
}
|
|
8753
|
+
Coder2.prototype.encodedLength = function(length) {
|
|
8754
|
+
if (!this._paddingCharacter) {
|
|
8755
|
+
return (length * 8 + 5) / 6 | 0;
|
|
8756
|
+
}
|
|
8757
|
+
return (length + 2) / 3 * 4 | 0;
|
|
8758
|
+
};
|
|
8759
|
+
Coder2.prototype.encode = function(data) {
|
|
8760
|
+
var out = "";
|
|
8761
|
+
var i = 0;
|
|
8762
|
+
for (; i < data.length - 2; i += 3) {
|
|
8763
|
+
var c = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
|
|
8764
|
+
out += this._encodeByte(c >>> 3 * 6 & 63);
|
|
8765
|
+
out += this._encodeByte(c >>> 2 * 6 & 63);
|
|
8766
|
+
out += this._encodeByte(c >>> 1 * 6 & 63);
|
|
8767
|
+
out += this._encodeByte(c >>> 0 * 6 & 63);
|
|
8768
|
+
}
|
|
8769
|
+
var left = data.length - i;
|
|
8770
|
+
if (left > 0) {
|
|
8771
|
+
var c = data[i] << 16 | (left === 2 ? data[i + 1] << 8 : 0);
|
|
8772
|
+
out += this._encodeByte(c >>> 3 * 6 & 63);
|
|
8773
|
+
out += this._encodeByte(c >>> 2 * 6 & 63);
|
|
8774
|
+
if (left === 2) {
|
|
8775
|
+
out += this._encodeByte(c >>> 1 * 6 & 63);
|
|
8776
|
+
} else {
|
|
8777
|
+
out += this._paddingCharacter || "";
|
|
8778
|
+
}
|
|
8779
|
+
out += this._paddingCharacter || "";
|
|
8780
|
+
}
|
|
8781
|
+
return out;
|
|
8782
|
+
};
|
|
8783
|
+
Coder2.prototype.maxDecodedLength = function(length) {
|
|
8784
|
+
if (!this._paddingCharacter) {
|
|
8785
|
+
return (length * 6 + 7) / 8 | 0;
|
|
8786
|
+
}
|
|
8787
|
+
return length / 4 * 3 | 0;
|
|
8788
|
+
};
|
|
8789
|
+
Coder2.prototype.decodedLength = function(s) {
|
|
8790
|
+
return this.maxDecodedLength(s.length - this._getPaddingLength(s));
|
|
8791
|
+
};
|
|
8792
|
+
Coder2.prototype.decode = function(s) {
|
|
8793
|
+
if (s.length === 0) {
|
|
8794
|
+
return new Uint8Array(0);
|
|
8795
|
+
}
|
|
8796
|
+
var paddingLength = this._getPaddingLength(s);
|
|
8797
|
+
var length = s.length - paddingLength;
|
|
8798
|
+
var out = new Uint8Array(this.maxDecodedLength(length));
|
|
8799
|
+
var op = 0;
|
|
8800
|
+
var i = 0;
|
|
8801
|
+
var haveBad = 0;
|
|
8802
|
+
var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
|
|
8803
|
+
for (; i < length - 4; i += 4) {
|
|
8804
|
+
v0 = this._decodeChar(s.charCodeAt(i + 0));
|
|
8805
|
+
v1 = this._decodeChar(s.charCodeAt(i + 1));
|
|
8806
|
+
v2 = this._decodeChar(s.charCodeAt(i + 2));
|
|
8807
|
+
v3 = this._decodeChar(s.charCodeAt(i + 3));
|
|
8808
|
+
out[op++] = v0 << 2 | v1 >>> 4;
|
|
8809
|
+
out[op++] = v1 << 4 | v2 >>> 2;
|
|
8810
|
+
out[op++] = v2 << 6 | v3;
|
|
8811
|
+
haveBad |= v0 & INVALID_BYTE;
|
|
8812
|
+
haveBad |= v1 & INVALID_BYTE;
|
|
8813
|
+
haveBad |= v2 & INVALID_BYTE;
|
|
8814
|
+
haveBad |= v3 & INVALID_BYTE;
|
|
8815
|
+
}
|
|
8816
|
+
if (i < length - 1) {
|
|
8817
|
+
v0 = this._decodeChar(s.charCodeAt(i));
|
|
8818
|
+
v1 = this._decodeChar(s.charCodeAt(i + 1));
|
|
8819
|
+
out[op++] = v0 << 2 | v1 >>> 4;
|
|
8820
|
+
haveBad |= v0 & INVALID_BYTE;
|
|
8821
|
+
haveBad |= v1 & INVALID_BYTE;
|
|
8822
|
+
}
|
|
8823
|
+
if (i < length - 2) {
|
|
8824
|
+
v2 = this._decodeChar(s.charCodeAt(i + 2));
|
|
8825
|
+
out[op++] = v1 << 4 | v2 >>> 2;
|
|
8826
|
+
haveBad |= v2 & INVALID_BYTE;
|
|
8827
|
+
}
|
|
8828
|
+
if (i < length - 3) {
|
|
8829
|
+
v3 = this._decodeChar(s.charCodeAt(i + 3));
|
|
8830
|
+
out[op++] = v2 << 6 | v3;
|
|
8831
|
+
haveBad |= v3 & INVALID_BYTE;
|
|
8832
|
+
}
|
|
8833
|
+
if (haveBad !== 0) {
|
|
8834
|
+
throw new Error("Base64Coder: incorrect characters for decoding");
|
|
8835
|
+
}
|
|
8836
|
+
return out;
|
|
8837
|
+
};
|
|
8838
|
+
Coder2.prototype._encodeByte = function(b) {
|
|
8839
|
+
var result = b;
|
|
8840
|
+
result += 65;
|
|
8841
|
+
result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
|
|
8842
|
+
result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
|
|
8843
|
+
result += 61 - b >>> 8 & 52 - 48 - 62 + 43;
|
|
8844
|
+
result += 62 - b >>> 8 & 62 - 43 - 63 + 47;
|
|
8845
|
+
return String.fromCharCode(result);
|
|
8846
|
+
};
|
|
8847
|
+
Coder2.prototype._decodeChar = function(c) {
|
|
8848
|
+
var result = INVALID_BYTE;
|
|
8849
|
+
result += (42 - c & c - 44) >>> 8 & -INVALID_BYTE + c - 43 + 62;
|
|
8850
|
+
result += (46 - c & c - 48) >>> 8 & -INVALID_BYTE + c - 47 + 63;
|
|
8851
|
+
result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
|
|
8852
|
+
result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
|
|
8853
|
+
result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
|
|
8854
|
+
return result;
|
|
8855
|
+
};
|
|
8856
|
+
Coder2.prototype._getPaddingLength = function(s) {
|
|
8857
|
+
var paddingLength = 0;
|
|
8858
|
+
if (this._paddingCharacter) {
|
|
8859
|
+
for (var i = s.length - 1; i >= 0; i--) {
|
|
8860
|
+
if (s[i] !== this._paddingCharacter) {
|
|
8861
|
+
break;
|
|
8862
|
+
}
|
|
8863
|
+
paddingLength++;
|
|
8864
|
+
}
|
|
8865
|
+
if (s.length < 4 || paddingLength > 2) {
|
|
8866
|
+
throw new Error("Base64Coder: incorrect padding");
|
|
8867
|
+
}
|
|
8868
|
+
}
|
|
8869
|
+
return paddingLength;
|
|
8870
|
+
};
|
|
8871
|
+
return Coder2;
|
|
8872
|
+
}()
|
|
8873
|
+
);
|
|
8874
|
+
exports.Coder = Coder;
|
|
8875
|
+
var stdCoder = new Coder();
|
|
8876
|
+
function encode2(data) {
|
|
8877
|
+
return stdCoder.encode(data);
|
|
8878
|
+
}
|
|
8879
|
+
exports.encode = encode2;
|
|
8880
|
+
function decode2(s) {
|
|
8881
|
+
return stdCoder.decode(s);
|
|
8882
|
+
}
|
|
8883
|
+
exports.decode = decode2;
|
|
8884
|
+
var URLSafeCoder = (
|
|
8885
|
+
/** @class */
|
|
8886
|
+
function(_super) {
|
|
8887
|
+
__extends(URLSafeCoder2, _super);
|
|
8888
|
+
function URLSafeCoder2() {
|
|
8889
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
8890
|
+
}
|
|
8891
|
+
URLSafeCoder2.prototype._encodeByte = function(b) {
|
|
8892
|
+
var result = b;
|
|
8893
|
+
result += 65;
|
|
8894
|
+
result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
|
|
8895
|
+
result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
|
|
8896
|
+
result += 61 - b >>> 8 & 52 - 48 - 62 + 45;
|
|
8897
|
+
result += 62 - b >>> 8 & 62 - 45 - 63 + 95;
|
|
8898
|
+
return String.fromCharCode(result);
|
|
8899
|
+
};
|
|
8900
|
+
URLSafeCoder2.prototype._decodeChar = function(c) {
|
|
8901
|
+
var result = INVALID_BYTE;
|
|
8902
|
+
result += (44 - c & c - 46) >>> 8 & -INVALID_BYTE + c - 45 + 62;
|
|
8903
|
+
result += (94 - c & c - 96) >>> 8 & -INVALID_BYTE + c - 95 + 63;
|
|
8904
|
+
result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
|
|
8905
|
+
result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
|
|
8906
|
+
result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
|
|
8907
|
+
return result;
|
|
8908
|
+
};
|
|
8909
|
+
return URLSafeCoder2;
|
|
8910
|
+
}(Coder)
|
|
8911
|
+
);
|
|
8912
|
+
exports.URLSafeCoder = URLSafeCoder;
|
|
8913
|
+
var urlSafeCoder = new URLSafeCoder();
|
|
8914
|
+
function encodeURLSafe(data) {
|
|
8915
|
+
return urlSafeCoder.encode(data);
|
|
8916
|
+
}
|
|
8917
|
+
exports.encodeURLSafe = encodeURLSafe;
|
|
8918
|
+
function decodeURLSafe(s) {
|
|
8919
|
+
return urlSafeCoder.decode(s);
|
|
8920
|
+
}
|
|
8921
|
+
exports.decodeURLSafe = decodeURLSafe;
|
|
8922
|
+
exports.encodedLength = function(length) {
|
|
8923
|
+
return stdCoder.encodedLength(length);
|
|
8924
|
+
};
|
|
8925
|
+
exports.maxDecodedLength = function(length) {
|
|
8926
|
+
return stdCoder.maxDecodedLength(length);
|
|
8927
|
+
};
|
|
8928
|
+
exports.decodedLength = function(s) {
|
|
8929
|
+
return stdCoder.decodedLength(s);
|
|
8930
|
+
};
|
|
8931
|
+
}
|
|
8932
|
+
});
|
|
8933
|
+
|
|
8934
|
+
// ../../node_modules/fast-sha256/sha256.js
|
|
8935
|
+
var require_sha256 = __commonJS({
|
|
8936
|
+
"../../node_modules/fast-sha256/sha256.js"(exports, module) {
|
|
8937
|
+
(function(root, factory) {
|
|
8938
|
+
var exports2 = {};
|
|
8939
|
+
factory(exports2);
|
|
8940
|
+
var sha2562 = exports2["default"];
|
|
8941
|
+
for (var k in exports2) {
|
|
8942
|
+
sha2562[k] = exports2[k];
|
|
8943
|
+
}
|
|
8944
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
8945
|
+
module.exports = sha2562;
|
|
8946
|
+
} else if (typeof define === "function" && define.amd) {
|
|
8947
|
+
define(function() {
|
|
8948
|
+
return sha2562;
|
|
8949
|
+
});
|
|
8950
|
+
} else {
|
|
8951
|
+
root.sha256 = sha2562;
|
|
8952
|
+
}
|
|
8953
|
+
})(exports, function(exports2) {
|
|
8954
|
+
exports2.__esModule = true;
|
|
8955
|
+
exports2.digestLength = 32;
|
|
8956
|
+
exports2.blockSize = 64;
|
|
8957
|
+
var K = new Uint32Array([
|
|
8958
|
+
1116352408,
|
|
8959
|
+
1899447441,
|
|
8960
|
+
3049323471,
|
|
8961
|
+
3921009573,
|
|
8962
|
+
961987163,
|
|
8963
|
+
1508970993,
|
|
8964
|
+
2453635748,
|
|
8965
|
+
2870763221,
|
|
8966
|
+
3624381080,
|
|
8967
|
+
310598401,
|
|
8968
|
+
607225278,
|
|
8969
|
+
1426881987,
|
|
8970
|
+
1925078388,
|
|
8971
|
+
2162078206,
|
|
8972
|
+
2614888103,
|
|
8973
|
+
3248222580,
|
|
8974
|
+
3835390401,
|
|
8975
|
+
4022224774,
|
|
8976
|
+
264347078,
|
|
8977
|
+
604807628,
|
|
8978
|
+
770255983,
|
|
8979
|
+
1249150122,
|
|
8980
|
+
1555081692,
|
|
8981
|
+
1996064986,
|
|
8982
|
+
2554220882,
|
|
8983
|
+
2821834349,
|
|
8984
|
+
2952996808,
|
|
8985
|
+
3210313671,
|
|
8986
|
+
3336571891,
|
|
8987
|
+
3584528711,
|
|
8988
|
+
113926993,
|
|
8989
|
+
338241895,
|
|
8990
|
+
666307205,
|
|
8991
|
+
773529912,
|
|
8992
|
+
1294757372,
|
|
8993
|
+
1396182291,
|
|
8994
|
+
1695183700,
|
|
8995
|
+
1986661051,
|
|
8996
|
+
2177026350,
|
|
8997
|
+
2456956037,
|
|
8998
|
+
2730485921,
|
|
8999
|
+
2820302411,
|
|
9000
|
+
3259730800,
|
|
9001
|
+
3345764771,
|
|
9002
|
+
3516065817,
|
|
9003
|
+
3600352804,
|
|
9004
|
+
4094571909,
|
|
9005
|
+
275423344,
|
|
9006
|
+
430227734,
|
|
9007
|
+
506948616,
|
|
9008
|
+
659060556,
|
|
9009
|
+
883997877,
|
|
9010
|
+
958139571,
|
|
9011
|
+
1322822218,
|
|
9012
|
+
1537002063,
|
|
9013
|
+
1747873779,
|
|
9014
|
+
1955562222,
|
|
9015
|
+
2024104815,
|
|
9016
|
+
2227730452,
|
|
9017
|
+
2361852424,
|
|
9018
|
+
2428436474,
|
|
9019
|
+
2756734187,
|
|
9020
|
+
3204031479,
|
|
9021
|
+
3329325298
|
|
9022
|
+
]);
|
|
9023
|
+
function hashBlocks(w, v, p, pos, len) {
|
|
9024
|
+
var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
|
|
9025
|
+
while (len >= 64) {
|
|
9026
|
+
a = v[0];
|
|
9027
|
+
b = v[1];
|
|
9028
|
+
c = v[2];
|
|
9029
|
+
d = v[3];
|
|
9030
|
+
e = v[4];
|
|
9031
|
+
f = v[5];
|
|
9032
|
+
g = v[6];
|
|
9033
|
+
h = v[7];
|
|
9034
|
+
for (i = 0; i < 16; i++) {
|
|
9035
|
+
j = pos + i * 4;
|
|
9036
|
+
w[i] = (p[j] & 255) << 24 | (p[j + 1] & 255) << 16 | (p[j + 2] & 255) << 8 | p[j + 3] & 255;
|
|
9037
|
+
}
|
|
9038
|
+
for (i = 16; i < 64; i++) {
|
|
9039
|
+
u = w[i - 2];
|
|
9040
|
+
t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10;
|
|
9041
|
+
u = w[i - 15];
|
|
9042
|
+
t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3;
|
|
9043
|
+
w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
|
|
9044
|
+
}
|
|
9045
|
+
for (i = 0; i < 64; i++) {
|
|
9046
|
+
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;
|
|
9047
|
+
t2 = ((a >>> 2 | a << 32 - 2) ^ (a >>> 13 | a << 32 - 13) ^ (a >>> 22 | a << 32 - 22)) + (a & b ^ a & c ^ b & c) | 0;
|
|
9048
|
+
h = g;
|
|
9049
|
+
g = f;
|
|
9050
|
+
f = e;
|
|
9051
|
+
e = d + t1 | 0;
|
|
9052
|
+
d = c;
|
|
9053
|
+
c = b;
|
|
9054
|
+
b = a;
|
|
9055
|
+
a = t1 + t2 | 0;
|
|
9056
|
+
}
|
|
9057
|
+
v[0] += a;
|
|
9058
|
+
v[1] += b;
|
|
9059
|
+
v[2] += c;
|
|
9060
|
+
v[3] += d;
|
|
9061
|
+
v[4] += e;
|
|
9062
|
+
v[5] += f;
|
|
9063
|
+
v[6] += g;
|
|
9064
|
+
v[7] += h;
|
|
9065
|
+
pos += 64;
|
|
9066
|
+
len -= 64;
|
|
9067
|
+
}
|
|
9068
|
+
return pos;
|
|
9069
|
+
}
|
|
9070
|
+
var Hash = (
|
|
9071
|
+
/** @class */
|
|
9072
|
+
function() {
|
|
9073
|
+
function Hash2() {
|
|
9074
|
+
this.digestLength = exports2.digestLength;
|
|
9075
|
+
this.blockSize = exports2.blockSize;
|
|
9076
|
+
this.state = new Int32Array(8);
|
|
9077
|
+
this.temp = new Int32Array(64);
|
|
9078
|
+
this.buffer = new Uint8Array(128);
|
|
9079
|
+
this.bufferLength = 0;
|
|
9080
|
+
this.bytesHashed = 0;
|
|
9081
|
+
this.finished = false;
|
|
9082
|
+
this.reset();
|
|
9083
|
+
}
|
|
9084
|
+
Hash2.prototype.reset = function() {
|
|
9085
|
+
this.state[0] = 1779033703;
|
|
9086
|
+
this.state[1] = 3144134277;
|
|
9087
|
+
this.state[2] = 1013904242;
|
|
9088
|
+
this.state[3] = 2773480762;
|
|
9089
|
+
this.state[4] = 1359893119;
|
|
9090
|
+
this.state[5] = 2600822924;
|
|
9091
|
+
this.state[6] = 528734635;
|
|
9092
|
+
this.state[7] = 1541459225;
|
|
9093
|
+
this.bufferLength = 0;
|
|
9094
|
+
this.bytesHashed = 0;
|
|
9095
|
+
this.finished = false;
|
|
9096
|
+
return this;
|
|
9097
|
+
};
|
|
9098
|
+
Hash2.prototype.clean = function() {
|
|
9099
|
+
for (var i = 0; i < this.buffer.length; i++) {
|
|
9100
|
+
this.buffer[i] = 0;
|
|
9101
|
+
}
|
|
9102
|
+
for (var i = 0; i < this.temp.length; i++) {
|
|
9103
|
+
this.temp[i] = 0;
|
|
9104
|
+
}
|
|
9105
|
+
this.reset();
|
|
9106
|
+
};
|
|
9107
|
+
Hash2.prototype.update = function(data, dataLength) {
|
|
9108
|
+
if (dataLength === void 0) {
|
|
9109
|
+
dataLength = data.length;
|
|
9110
|
+
}
|
|
9111
|
+
if (this.finished) {
|
|
9112
|
+
throw new Error("SHA256: can't update because hash was finished.");
|
|
9113
|
+
}
|
|
9114
|
+
var dataPos = 0;
|
|
9115
|
+
this.bytesHashed += dataLength;
|
|
9116
|
+
if (this.bufferLength > 0) {
|
|
9117
|
+
while (this.bufferLength < 64 && dataLength > 0) {
|
|
9118
|
+
this.buffer[this.bufferLength++] = data[dataPos++];
|
|
9119
|
+
dataLength--;
|
|
9120
|
+
}
|
|
9121
|
+
if (this.bufferLength === 64) {
|
|
9122
|
+
hashBlocks(this.temp, this.state, this.buffer, 0, 64);
|
|
9123
|
+
this.bufferLength = 0;
|
|
9124
|
+
}
|
|
9125
|
+
}
|
|
9126
|
+
if (dataLength >= 64) {
|
|
9127
|
+
dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
|
|
9128
|
+
dataLength %= 64;
|
|
9129
|
+
}
|
|
9130
|
+
while (dataLength > 0) {
|
|
9131
|
+
this.buffer[this.bufferLength++] = data[dataPos++];
|
|
9132
|
+
dataLength--;
|
|
9133
|
+
}
|
|
9134
|
+
return this;
|
|
9135
|
+
};
|
|
9136
|
+
Hash2.prototype.finish = function(out) {
|
|
9137
|
+
if (!this.finished) {
|
|
9138
|
+
var bytesHashed = this.bytesHashed;
|
|
9139
|
+
var left = this.bufferLength;
|
|
9140
|
+
var bitLenHi = bytesHashed / 536870912 | 0;
|
|
9141
|
+
var bitLenLo = bytesHashed << 3;
|
|
9142
|
+
var padLength = bytesHashed % 64 < 56 ? 64 : 128;
|
|
9143
|
+
this.buffer[left] = 128;
|
|
9144
|
+
for (var i = left + 1; i < padLength - 8; i++) {
|
|
9145
|
+
this.buffer[i] = 0;
|
|
9146
|
+
}
|
|
9147
|
+
this.buffer[padLength - 8] = bitLenHi >>> 24 & 255;
|
|
9148
|
+
this.buffer[padLength - 7] = bitLenHi >>> 16 & 255;
|
|
9149
|
+
this.buffer[padLength - 6] = bitLenHi >>> 8 & 255;
|
|
9150
|
+
this.buffer[padLength - 5] = bitLenHi >>> 0 & 255;
|
|
9151
|
+
this.buffer[padLength - 4] = bitLenLo >>> 24 & 255;
|
|
9152
|
+
this.buffer[padLength - 3] = bitLenLo >>> 16 & 255;
|
|
9153
|
+
this.buffer[padLength - 2] = bitLenLo >>> 8 & 255;
|
|
9154
|
+
this.buffer[padLength - 1] = bitLenLo >>> 0 & 255;
|
|
9155
|
+
hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
|
|
9156
|
+
this.finished = true;
|
|
9157
|
+
}
|
|
9158
|
+
for (var i = 0; i < 8; i++) {
|
|
9159
|
+
out[i * 4 + 0] = this.state[i] >>> 24 & 255;
|
|
9160
|
+
out[i * 4 + 1] = this.state[i] >>> 16 & 255;
|
|
9161
|
+
out[i * 4 + 2] = this.state[i] >>> 8 & 255;
|
|
9162
|
+
out[i * 4 + 3] = this.state[i] >>> 0 & 255;
|
|
9163
|
+
}
|
|
9164
|
+
return this;
|
|
9165
|
+
};
|
|
9166
|
+
Hash2.prototype.digest = function() {
|
|
9167
|
+
var out = new Uint8Array(this.digestLength);
|
|
9168
|
+
this.finish(out);
|
|
9169
|
+
return out;
|
|
9170
|
+
};
|
|
9171
|
+
Hash2.prototype._saveState = function(out) {
|
|
9172
|
+
for (var i = 0; i < this.state.length; i++) {
|
|
9173
|
+
out[i] = this.state[i];
|
|
9174
|
+
}
|
|
9175
|
+
};
|
|
9176
|
+
Hash2.prototype._restoreState = function(from, bytesHashed) {
|
|
9177
|
+
for (var i = 0; i < this.state.length; i++) {
|
|
9178
|
+
this.state[i] = from[i];
|
|
9179
|
+
}
|
|
9180
|
+
this.bytesHashed = bytesHashed;
|
|
9181
|
+
this.finished = false;
|
|
9182
|
+
this.bufferLength = 0;
|
|
9183
|
+
};
|
|
9184
|
+
return Hash2;
|
|
9185
|
+
}()
|
|
9186
|
+
);
|
|
9187
|
+
exports2.Hash = Hash;
|
|
9188
|
+
var HMAC = (
|
|
9189
|
+
/** @class */
|
|
9190
|
+
function() {
|
|
9191
|
+
function HMAC2(key) {
|
|
9192
|
+
this.inner = new Hash();
|
|
9193
|
+
this.outer = new Hash();
|
|
9194
|
+
this.blockSize = this.inner.blockSize;
|
|
9195
|
+
this.digestLength = this.inner.digestLength;
|
|
9196
|
+
var pad = new Uint8Array(this.blockSize);
|
|
9197
|
+
if (key.length > this.blockSize) {
|
|
9198
|
+
new Hash().update(key).finish(pad).clean();
|
|
9199
|
+
} else {
|
|
9200
|
+
for (var i = 0; i < key.length; i++) {
|
|
9201
|
+
pad[i] = key[i];
|
|
9202
|
+
}
|
|
9203
|
+
}
|
|
9204
|
+
for (var i = 0; i < pad.length; i++) {
|
|
9205
|
+
pad[i] ^= 54;
|
|
9206
|
+
}
|
|
9207
|
+
this.inner.update(pad);
|
|
9208
|
+
for (var i = 0; i < pad.length; i++) {
|
|
9209
|
+
pad[i] ^= 54 ^ 92;
|
|
9210
|
+
}
|
|
9211
|
+
this.outer.update(pad);
|
|
9212
|
+
this.istate = new Uint32Array(8);
|
|
9213
|
+
this.ostate = new Uint32Array(8);
|
|
9214
|
+
this.inner._saveState(this.istate);
|
|
9215
|
+
this.outer._saveState(this.ostate);
|
|
9216
|
+
for (var i = 0; i < pad.length; i++) {
|
|
9217
|
+
pad[i] = 0;
|
|
9218
|
+
}
|
|
9219
|
+
}
|
|
9220
|
+
HMAC2.prototype.reset = function() {
|
|
9221
|
+
this.inner._restoreState(this.istate, this.inner.blockSize);
|
|
9222
|
+
this.outer._restoreState(this.ostate, this.outer.blockSize);
|
|
9223
|
+
return this;
|
|
9224
|
+
};
|
|
9225
|
+
HMAC2.prototype.clean = function() {
|
|
9226
|
+
for (var i = 0; i < this.istate.length; i++) {
|
|
9227
|
+
this.ostate[i] = this.istate[i] = 0;
|
|
9228
|
+
}
|
|
9229
|
+
this.inner.clean();
|
|
9230
|
+
this.outer.clean();
|
|
9231
|
+
};
|
|
9232
|
+
HMAC2.prototype.update = function(data) {
|
|
9233
|
+
this.inner.update(data);
|
|
9234
|
+
return this;
|
|
9235
|
+
};
|
|
9236
|
+
HMAC2.prototype.finish = function(out) {
|
|
9237
|
+
if (this.outer.finished) {
|
|
9238
|
+
this.outer.finish(out);
|
|
9239
|
+
} else {
|
|
9240
|
+
this.inner.finish(out);
|
|
9241
|
+
this.outer.update(out, this.digestLength).finish(out);
|
|
9242
|
+
}
|
|
9243
|
+
return this;
|
|
9244
|
+
};
|
|
9245
|
+
HMAC2.prototype.digest = function() {
|
|
9246
|
+
var out = new Uint8Array(this.digestLength);
|
|
9247
|
+
this.finish(out);
|
|
9248
|
+
return out;
|
|
9249
|
+
};
|
|
9250
|
+
return HMAC2;
|
|
9251
|
+
}()
|
|
9252
|
+
);
|
|
9253
|
+
exports2.HMAC = HMAC;
|
|
9254
|
+
function hash(data) {
|
|
9255
|
+
var h = new Hash().update(data);
|
|
9256
|
+
var digest = h.digest();
|
|
9257
|
+
h.clean();
|
|
9258
|
+
return digest;
|
|
9259
|
+
}
|
|
9260
|
+
exports2.hash = hash;
|
|
9261
|
+
exports2["default"] = hash;
|
|
9262
|
+
function hmac2(key, data) {
|
|
9263
|
+
var h = new HMAC(key).update(data);
|
|
9264
|
+
var digest = h.digest();
|
|
9265
|
+
h.clean();
|
|
9266
|
+
return digest;
|
|
9267
|
+
}
|
|
9268
|
+
exports2.hmac = hmac2;
|
|
9269
|
+
function fillBuffer(buffer, hmac3, info, counter) {
|
|
9270
|
+
var num = counter[0];
|
|
9271
|
+
if (num === 0) {
|
|
9272
|
+
throw new Error("hkdf: cannot expand more");
|
|
9273
|
+
}
|
|
9274
|
+
hmac3.reset();
|
|
9275
|
+
if (num > 1) {
|
|
9276
|
+
hmac3.update(buffer);
|
|
9277
|
+
}
|
|
9278
|
+
if (info) {
|
|
9279
|
+
hmac3.update(info);
|
|
9280
|
+
}
|
|
9281
|
+
hmac3.update(counter);
|
|
9282
|
+
hmac3.finish(buffer);
|
|
9283
|
+
counter[0]++;
|
|
9284
|
+
}
|
|
9285
|
+
var hkdfSalt = new Uint8Array(exports2.digestLength);
|
|
9286
|
+
function hkdf(key, salt, info, length) {
|
|
9287
|
+
if (salt === void 0) {
|
|
9288
|
+
salt = hkdfSalt;
|
|
9289
|
+
}
|
|
9290
|
+
if (length === void 0) {
|
|
9291
|
+
length = 32;
|
|
9292
|
+
}
|
|
9293
|
+
var counter = new Uint8Array([1]);
|
|
9294
|
+
var okm = hmac2(salt, key);
|
|
9295
|
+
var hmac_ = new HMAC(okm);
|
|
9296
|
+
var buffer = new Uint8Array(hmac_.digestLength);
|
|
9297
|
+
var bufpos = buffer.length;
|
|
9298
|
+
var out = new Uint8Array(length);
|
|
9299
|
+
for (var i = 0; i < length; i++) {
|
|
9300
|
+
if (bufpos === buffer.length) {
|
|
9301
|
+
fillBuffer(buffer, hmac_, info, counter);
|
|
9302
|
+
bufpos = 0;
|
|
9303
|
+
}
|
|
9304
|
+
out[i] = buffer[bufpos++];
|
|
9305
|
+
}
|
|
9306
|
+
hmac_.clean();
|
|
9307
|
+
buffer.fill(0);
|
|
9308
|
+
counter.fill(0);
|
|
9309
|
+
return out;
|
|
9310
|
+
}
|
|
9311
|
+
exports2.hkdf = hkdf;
|
|
9312
|
+
function pbkdf2(password, salt, iterations, dkLen) {
|
|
9313
|
+
var prf = new HMAC(password);
|
|
9314
|
+
var len = prf.digestLength;
|
|
9315
|
+
var ctr = new Uint8Array(4);
|
|
9316
|
+
var t = new Uint8Array(len);
|
|
9317
|
+
var u = new Uint8Array(len);
|
|
9318
|
+
var dk = new Uint8Array(dkLen);
|
|
9319
|
+
for (var i = 0; i * len < dkLen; i++) {
|
|
9320
|
+
var c = i + 1;
|
|
9321
|
+
ctr[0] = c >>> 24 & 255;
|
|
9322
|
+
ctr[1] = c >>> 16 & 255;
|
|
9323
|
+
ctr[2] = c >>> 8 & 255;
|
|
9324
|
+
ctr[3] = c >>> 0 & 255;
|
|
9325
|
+
prf.reset();
|
|
9326
|
+
prf.update(salt);
|
|
9327
|
+
prf.update(ctr);
|
|
9328
|
+
prf.finish(u);
|
|
9329
|
+
for (var j = 0; j < len; j++) {
|
|
9330
|
+
t[j] = u[j];
|
|
9331
|
+
}
|
|
9332
|
+
for (var j = 2; j <= iterations; j++) {
|
|
9333
|
+
prf.reset();
|
|
9334
|
+
prf.update(u).finish(u);
|
|
9335
|
+
for (var k = 0; k < len; k++) {
|
|
9336
|
+
t[k] ^= u[k];
|
|
9337
|
+
}
|
|
9338
|
+
}
|
|
9339
|
+
for (var j = 0; j < len && i * len + j < dkLen; j++) {
|
|
9340
|
+
dk[i * len + j] = t[j];
|
|
9341
|
+
}
|
|
9342
|
+
}
|
|
9343
|
+
for (var i = 0; i < len; i++) {
|
|
9344
|
+
t[i] = u[i] = 0;
|
|
9345
|
+
}
|
|
9346
|
+
for (var i = 0; i < 4; i++) {
|
|
9347
|
+
ctr[i] = 0;
|
|
9348
|
+
}
|
|
9349
|
+
prf.clean();
|
|
9350
|
+
return dk;
|
|
9351
|
+
}
|
|
9352
|
+
exports2.pbkdf2 = pbkdf2;
|
|
9353
|
+
});
|
|
9354
|
+
}
|
|
9355
|
+
});
|
|
9356
|
+
|
|
9357
|
+
// src/webhook/vendor/standardwebhook.ts
|
|
9358
|
+
__toESM(require_base64());
|
|
9359
|
+
__toESM(require_sha256());
|
|
9360
|
+
/**
|
|
9361
|
+
* The MIT License
|
|
9362
|
+
*
|
|
9363
|
+
* Copyright (c) 2023 Svix (https://www.svix.com)
|
|
9364
|
+
*
|
|
9365
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9366
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9367
|
+
* in the Software without restriction, including without limitation the rights
|
|
9368
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9369
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9370
|
+
* furnished to do so, subject to the following conditions:
|
|
9371
|
+
*
|
|
9372
|
+
* The above copyright notice and this permission notice shall be included in
|
|
9373
|
+
* all copies or substantial portions of the Software.
|
|
9374
|
+
*
|
|
9375
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
9376
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
9377
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
9378
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
9379
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
9380
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
9381
|
+
* THE SOFTWARE.
|
|
9382
|
+
*
|
|
9383
|
+
* @fileoverview Server-only webhook verification implementation.
|
|
9384
|
+
* @description Vendored from standardwebhooks package to avoid bundling issues.
|
|
9385
|
+
* Uses Node.js crypto module - DO NOT import in client/browser code.
|
|
9386
|
+
* @license MIT
|
|
9387
|
+
* @internal
|
|
9388
|
+
*/
|
|
9389
|
+
|
|
9390
|
+
// src/webhook/webhook.ts
|
|
8031
9391
|
async function handleWebhookPayload(payload, config, context) {
|
|
8032
9392
|
const callHandler = (handler, payload2) => {
|
|
8033
9393
|
if (!handler) return;
|
|
@@ -8084,9 +9444,6 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
8084
9444
|
if (payload.type === "subscription.renewed") {
|
|
8085
9445
|
await callHandler(config.onSubscriptionRenewed, payload);
|
|
8086
9446
|
}
|
|
8087
|
-
if (payload.type === "subscription.paused") {
|
|
8088
|
-
await callHandler(config.onSubscriptionPaused, payload);
|
|
8089
|
-
}
|
|
8090
9447
|
if (payload.type === "subscription.plan_changed") {
|
|
8091
9448
|
await callHandler(config.onSubscriptionPlanChanged, payload);
|
|
8092
9449
|
}
|
|
@@ -8105,6 +9462,30 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
8105
9462
|
if (payload.type === "license_key.created") {
|
|
8106
9463
|
await callHandler(config.onLicenseKeyCreated, payload);
|
|
8107
9464
|
}
|
|
9465
|
+
if (payload.type === "credit.added") {
|
|
9466
|
+
await callHandler(config.onCreditAdded, payload);
|
|
9467
|
+
}
|
|
9468
|
+
if (payload.type === "credit.deducted") {
|
|
9469
|
+
await callHandler(config.onCreditDeducted, payload);
|
|
9470
|
+
}
|
|
9471
|
+
if (payload.type === "credit.expired") {
|
|
9472
|
+
await callHandler(config.onCreditExpired, payload);
|
|
9473
|
+
}
|
|
9474
|
+
if (payload.type === "credit.rolled_over") {
|
|
9475
|
+
await callHandler(config.onCreditRolledOver, payload);
|
|
9476
|
+
}
|
|
9477
|
+
if (payload.type === "credit.rollover_forfeited") {
|
|
9478
|
+
await callHandler(config.onCreditRolloverForfeited, payload);
|
|
9479
|
+
}
|
|
9480
|
+
if (payload.type === "credit.overage_charged") {
|
|
9481
|
+
await callHandler(config.onCreditOverageCharged, payload);
|
|
9482
|
+
}
|
|
9483
|
+
if (payload.type === "credit.manual_adjustment") {
|
|
9484
|
+
await callHandler(config.onCreditManualAdjustment, payload);
|
|
9485
|
+
}
|
|
9486
|
+
if (payload.type === "credit.balance_low") {
|
|
9487
|
+
await callHandler(config.onCreditBalanceLow, payload);
|
|
9488
|
+
}
|
|
8108
9489
|
}
|
|
8109
9490
|
|
|
8110
9491
|
const Webhooks = ({ webhookKey, ...eventHandlers }) => {
|