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