@dodopayments/astro 0.2.5 → 0.2.7
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/customerPortal/customerPortal.d.ts.map +1 -1
- package/dist/index.cjs +1505 -125
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1505 -125
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4178,7 +4178,7 @@ const safeJSON = (text) => {
|
|
|
4178
4178
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4179
4179
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4180
4180
|
|
|
4181
|
-
const VERSION = '2.
|
|
4181
|
+
const VERSION = '2.23.2'; // x-release-please-version
|
|
4182
4182
|
|
|
4183
4183
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4184
4184
|
/**
|
|
@@ -4388,6 +4388,25 @@ const FallbackEncoder = ({ headers, body }) => {
|
|
|
4388
4388
|
};
|
|
4389
4389
|
};
|
|
4390
4390
|
|
|
4391
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4392
|
+
/**
|
|
4393
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
4394
|
+
*/
|
|
4395
|
+
function stringifyQuery(query) {
|
|
4396
|
+
return Object.entries(query)
|
|
4397
|
+
.filter(([_, value]) => typeof value !== 'undefined')
|
|
4398
|
+
.map(([key, value]) => {
|
|
4399
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
4400
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
4401
|
+
}
|
|
4402
|
+
if (value === null) {
|
|
4403
|
+
return `${encodeURIComponent(key)}=`;
|
|
4404
|
+
}
|
|
4405
|
+
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.`);
|
|
4406
|
+
})
|
|
4407
|
+
.join('&');
|
|
4408
|
+
}
|
|
4409
|
+
|
|
4391
4410
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4392
4411
|
const levelNumbers = {
|
|
4393
4412
|
off: 0,
|
|
@@ -4481,6 +4500,11 @@ async function defaultParseResponse(client, props) {
|
|
|
4481
4500
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
4482
4501
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
4483
4502
|
if (isJSON) {
|
|
4503
|
+
const contentLength = response.headers.get('content-length');
|
|
4504
|
+
if (contentLength === '0') {
|
|
4505
|
+
// if there is no content we can't do anything
|
|
4506
|
+
return undefined;
|
|
4507
|
+
}
|
|
4484
4508
|
const json = await response.json();
|
|
4485
4509
|
return json;
|
|
4486
4510
|
}
|
|
@@ -4901,6 +4925,16 @@ class Addons extends APIResource {
|
|
|
4901
4925
|
}
|
|
4902
4926
|
}
|
|
4903
4927
|
|
|
4928
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4929
|
+
let Balances$1 = class Balances extends APIResource {
|
|
4930
|
+
retrieveLedger(query = {}, options) {
|
|
4931
|
+
return this._client.getAPIList('/balances/ledger', (DefaultPageNumberPagination), {
|
|
4932
|
+
query,
|
|
4933
|
+
...options,
|
|
4934
|
+
});
|
|
4935
|
+
}
|
|
4936
|
+
};
|
|
4937
|
+
|
|
4904
4938
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4905
4939
|
class Brands extends APIResource {
|
|
4906
4940
|
create(body, options) {
|
|
@@ -4931,66 +4965,155 @@ class CheckoutSessions extends APIResource {
|
|
|
4931
4965
|
retrieve(id, options) {
|
|
4932
4966
|
return this._client.get(path `/checkouts/${id}`, options);
|
|
4933
4967
|
}
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4937
|
-
let CustomerPortal$1 = class CustomerPortal extends APIResource {
|
|
4938
|
-
create(customerID, params = {}, options) {
|
|
4939
|
-
const { send_email } = params ?? {};
|
|
4940
|
-
return this._client.post(path `/customers/${customerID}/customer-portal/session`, {
|
|
4941
|
-
query: { send_email },
|
|
4942
|
-
...options,
|
|
4943
|
-
});
|
|
4944
|
-
}
|
|
4945
|
-
};
|
|
4946
|
-
|
|
4947
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4948
|
-
class LedgerEntries extends APIResource {
|
|
4949
|
-
create(customerID, body, options) {
|
|
4950
|
-
return this._client.post(path `/customers/${customerID}/wallets/ledger-entries`, { body, ...options });
|
|
4951
|
-
}
|
|
4952
|
-
list(customerID, query = {}, options) {
|
|
4953
|
-
return this._client.getAPIList(path `/customers/${customerID}/wallets/ledger-entries`, (DefaultPageNumberPagination), { query, ...options });
|
|
4954
|
-
}
|
|
4955
|
-
}
|
|
4956
|
-
|
|
4957
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4958
|
-
class Wallets extends APIResource {
|
|
4959
|
-
constructor() {
|
|
4960
|
-
super(...arguments);
|
|
4961
|
-
this.ledgerEntries = new LedgerEntries(this._client);
|
|
4962
|
-
}
|
|
4963
|
-
list(customerID, options) {
|
|
4964
|
-
return this._client.get(path `/customers/${customerID}/wallets`, options);
|
|
4968
|
+
preview(body, options) {
|
|
4969
|
+
return this._client.post('/checkouts/preview', { body, ...options });
|
|
4965
4970
|
}
|
|
4966
4971
|
}
|
|
4967
|
-
Wallets.LedgerEntries = LedgerEntries;
|
|
4968
4972
|
|
|
4969
4973
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4970
|
-
class
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4974
|
+
class Balances extends APIResource {
|
|
4975
|
+
/**
|
|
4976
|
+
* Returns the credit balance details for a specific customer and credit
|
|
4977
|
+
* entitlement.
|
|
4978
|
+
*
|
|
4979
|
+
* # Authentication
|
|
4980
|
+
*
|
|
4981
|
+
* Requires an API key with `Viewer` role or higher.
|
|
4982
|
+
*
|
|
4983
|
+
* # Path Parameters
|
|
4984
|
+
*
|
|
4985
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
4986
|
+
* - `customer_id` - The unique identifier of the customer
|
|
4987
|
+
*
|
|
4988
|
+
* # Responses
|
|
4989
|
+
*
|
|
4990
|
+
* - `200 OK` - Returns the customer's balance
|
|
4991
|
+
* - `404 Not Found` - Credit entitlement or customer balance not found
|
|
4992
|
+
* - `500 Internal Server Error` - Database or server error
|
|
4993
|
+
*/
|
|
4994
|
+
retrieve(customerID, params, options) {
|
|
4995
|
+
const { credit_entitlement_id } = params;
|
|
4996
|
+
return this._client.get(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}`, options);
|
|
4975
4997
|
}
|
|
4976
|
-
|
|
4977
|
-
|
|
4998
|
+
/**
|
|
4999
|
+
* Returns a paginated list of customer credit balances for the given credit
|
|
5000
|
+
* entitlement.
|
|
5001
|
+
*
|
|
5002
|
+
* # Authentication
|
|
5003
|
+
*
|
|
5004
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5005
|
+
*
|
|
5006
|
+
* # Path Parameters
|
|
5007
|
+
*
|
|
5008
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5009
|
+
*
|
|
5010
|
+
* # Query Parameters
|
|
5011
|
+
*
|
|
5012
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5013
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5014
|
+
* - `customer_id` - Optional filter by specific customer
|
|
5015
|
+
*
|
|
5016
|
+
* # Responses
|
|
5017
|
+
*
|
|
5018
|
+
* - `200 OK` - Returns list of customer balances
|
|
5019
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
5020
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5021
|
+
*/
|
|
5022
|
+
list(creditEntitlementID, query = {}, options) {
|
|
5023
|
+
return this._client.getAPIList(path `/credit-entitlements/${creditEntitlementID}/balances`, (DefaultPageNumberPagination), { query, ...options });
|
|
4978
5024
|
}
|
|
4979
|
-
|
|
4980
|
-
|
|
5025
|
+
/**
|
|
5026
|
+
* For credit entries, a new grant is created. For debit entries, credits are
|
|
5027
|
+
* deducted from existing grants using FIFO (oldest first).
|
|
5028
|
+
*
|
|
5029
|
+
* # Authentication
|
|
5030
|
+
*
|
|
5031
|
+
* Requires an API key with `Editor` role.
|
|
5032
|
+
*
|
|
5033
|
+
* # Path Parameters
|
|
5034
|
+
*
|
|
5035
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5036
|
+
* - `customer_id` - The unique identifier of the customer
|
|
5037
|
+
*
|
|
5038
|
+
* # Request Body
|
|
5039
|
+
*
|
|
5040
|
+
* - `entry_type` - "credit" or "debit"
|
|
5041
|
+
* - `amount` - Amount to credit or debit
|
|
5042
|
+
* - `reason` - Optional human-readable reason
|
|
5043
|
+
* - `expires_at` - Optional expiration for credited amount (only for credit type)
|
|
5044
|
+
* - `idempotency_key` - Optional key to prevent duplicate entries
|
|
5045
|
+
*
|
|
5046
|
+
* # Responses
|
|
5047
|
+
*
|
|
5048
|
+
* - `201 Created` - Ledger entry created successfully
|
|
5049
|
+
* - `400 Bad Request` - Invalid request (e.g., debit with insufficient balance)
|
|
5050
|
+
* - `404 Not Found` - Credit entitlement or customer not found
|
|
5051
|
+
* - `409 Conflict` - Idempotency key already exists
|
|
5052
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5053
|
+
*/
|
|
5054
|
+
createLedgerEntry(customerID, params, options) {
|
|
5055
|
+
const { credit_entitlement_id, ...body } = params;
|
|
5056
|
+
return this._client.post(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/ledger-entries`, { body, ...options });
|
|
4981
5057
|
}
|
|
4982
|
-
|
|
4983
|
-
|
|
5058
|
+
/**
|
|
5059
|
+
* Returns a paginated list of credit grants with optional filtering by status.
|
|
5060
|
+
*
|
|
5061
|
+
* # Authentication
|
|
5062
|
+
*
|
|
5063
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5064
|
+
*
|
|
5065
|
+
* # Path Parameters
|
|
5066
|
+
*
|
|
5067
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5068
|
+
* - `customer_id` - The unique identifier of the customer
|
|
5069
|
+
*
|
|
5070
|
+
* # Query Parameters
|
|
5071
|
+
*
|
|
5072
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5073
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5074
|
+
* - `status` - Filter by status: active, expired, depleted
|
|
5075
|
+
*
|
|
5076
|
+
* # Responses
|
|
5077
|
+
*
|
|
5078
|
+
* - `200 OK` - Returns list of grants
|
|
5079
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
5080
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5081
|
+
*/
|
|
5082
|
+
listGrants(customerID, params, options) {
|
|
5083
|
+
const { credit_entitlement_id, ...query } = params;
|
|
5084
|
+
return this._client.getAPIList(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/grants`, (DefaultPageNumberPagination), { query, ...options });
|
|
4984
5085
|
}
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
5086
|
+
/**
|
|
5087
|
+
* Returns a paginated list of credit transaction history with optional filtering.
|
|
5088
|
+
*
|
|
5089
|
+
* # Authentication
|
|
5090
|
+
*
|
|
5091
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5092
|
+
*
|
|
5093
|
+
* # Path Parameters
|
|
5094
|
+
*
|
|
5095
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5096
|
+
* - `customer_id` - The unique identifier of the customer
|
|
5097
|
+
*
|
|
5098
|
+
* # Query Parameters
|
|
5099
|
+
*
|
|
5100
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5101
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5102
|
+
* - `transaction_type` - Filter by transaction type
|
|
5103
|
+
* - `start_date` - Filter entries from this date
|
|
5104
|
+
* - `end_date` - Filter entries until this date
|
|
5105
|
+
*
|
|
5106
|
+
* # Responses
|
|
5107
|
+
*
|
|
5108
|
+
* - `200 OK` - Returns list of ledger entries
|
|
5109
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
5110
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5111
|
+
*/
|
|
5112
|
+
listLedger(customerID, params, options) {
|
|
5113
|
+
const { credit_entitlement_id, ...query } = params;
|
|
5114
|
+
return this._client.getAPIList(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/ledger`, (DefaultPageNumberPagination), { query, ...options });
|
|
4990
5115
|
}
|
|
4991
5116
|
}
|
|
4992
|
-
Customers.CustomerPortal = CustomerPortal$1;
|
|
4993
|
-
Customers.Wallets = Wallets;
|
|
4994
5117
|
|
|
4995
5118
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4996
5119
|
const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
|
|
@@ -5060,6 +5183,313 @@ const buildHeaders = (newHeaders) => {
|
|
|
5060
5183
|
return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
|
|
5061
5184
|
};
|
|
5062
5185
|
|
|
5186
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5187
|
+
class CreditEntitlements extends APIResource {
|
|
5188
|
+
constructor() {
|
|
5189
|
+
super(...arguments);
|
|
5190
|
+
this.balances = new Balances(this._client);
|
|
5191
|
+
}
|
|
5192
|
+
/**
|
|
5193
|
+
* Credit entitlements define reusable credit templates that can be attached to
|
|
5194
|
+
* products. Each entitlement defines how credits behave in terms of expiration,
|
|
5195
|
+
* rollover, and overage.
|
|
5196
|
+
*
|
|
5197
|
+
* # Authentication
|
|
5198
|
+
*
|
|
5199
|
+
* Requires an API key with `Editor` role.
|
|
5200
|
+
*
|
|
5201
|
+
* # Request Body
|
|
5202
|
+
*
|
|
5203
|
+
* - `name` - Human-readable name of the credit entitlement (1-255 characters,
|
|
5204
|
+
* required)
|
|
5205
|
+
* - `description` - Optional description (max 1000 characters)
|
|
5206
|
+
* - `precision` - Decimal precision for credit amounts (0-10 decimal places)
|
|
5207
|
+
* - `unit` - Unit of measurement for the credit (e.g., "API Calls", "Tokens",
|
|
5208
|
+
* "Credits")
|
|
5209
|
+
* - `expires_after_days` - Number of days after which credits expire (optional)
|
|
5210
|
+
* - `rollover_enabled` - Whether unused credits can rollover to the next period
|
|
5211
|
+
* - `rollover_percentage` - Percentage of unused credits that rollover (0-100)
|
|
5212
|
+
* - `rollover_timeframe_count` - Count of timeframe periods for rollover limit
|
|
5213
|
+
* - `rollover_timeframe_interval` - Interval type (day, week, month, year)
|
|
5214
|
+
* - `max_rollover_count` - Maximum number of times credits can be rolled over
|
|
5215
|
+
* - `overage_enabled` - Whether overage charges apply when credits run out
|
|
5216
|
+
* (requires price_per_unit)
|
|
5217
|
+
* - `overage_limit` - Maximum overage units allowed (optional)
|
|
5218
|
+
* - `currency` - Currency for pricing (required if price_per_unit is set)
|
|
5219
|
+
* - `price_per_unit` - Price per credit unit (decimal)
|
|
5220
|
+
*
|
|
5221
|
+
* # Responses
|
|
5222
|
+
*
|
|
5223
|
+
* - `201 Created` - Credit entitlement created successfully, returns the full
|
|
5224
|
+
* entitlement object
|
|
5225
|
+
* - `422 Unprocessable Entity` - Invalid request parameters or validation failure
|
|
5226
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5227
|
+
*
|
|
5228
|
+
* # Business Logic
|
|
5229
|
+
*
|
|
5230
|
+
* - A unique ID with prefix `cde_` is automatically generated for the entitlement
|
|
5231
|
+
* - Created and updated timestamps are automatically set
|
|
5232
|
+
* - Currency is required when price_per_unit is set
|
|
5233
|
+
* - price_per_unit is required when overage_enabled is true
|
|
5234
|
+
* - rollover_timeframe_count and rollover_timeframe_interval must both be set or
|
|
5235
|
+
* both be null
|
|
5236
|
+
*/
|
|
5237
|
+
create(body, options) {
|
|
5238
|
+
return this._client.post('/credit-entitlements', { body, ...options });
|
|
5239
|
+
}
|
|
5240
|
+
/**
|
|
5241
|
+
* Returns the full details of a single credit entitlement including all
|
|
5242
|
+
* configuration settings for expiration, rollover, and overage policies.
|
|
5243
|
+
*
|
|
5244
|
+
* # Authentication
|
|
5245
|
+
*
|
|
5246
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5247
|
+
*
|
|
5248
|
+
* # Path Parameters
|
|
5249
|
+
*
|
|
5250
|
+
* - `id` - The unique identifier of the credit entitlement (format: `cde_...`)
|
|
5251
|
+
*
|
|
5252
|
+
* # Responses
|
|
5253
|
+
*
|
|
5254
|
+
* - `200 OK` - Returns the full credit entitlement object
|
|
5255
|
+
* - `404 Not Found` - Credit entitlement does not exist or does not belong to the
|
|
5256
|
+
* authenticated business
|
|
5257
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5258
|
+
*
|
|
5259
|
+
* # Business Logic
|
|
5260
|
+
*
|
|
5261
|
+
* - Only non-deleted credit entitlements can be retrieved through this endpoint
|
|
5262
|
+
* - The entitlement must belong to the authenticated business (business_id check)
|
|
5263
|
+
* - Deleted entitlements return a 404 error and must be retrieved via the list
|
|
5264
|
+
* endpoint with `deleted=true`
|
|
5265
|
+
*/
|
|
5266
|
+
retrieve(id, options) {
|
|
5267
|
+
return this._client.get(path `/credit-entitlements/${id}`, options);
|
|
5268
|
+
}
|
|
5269
|
+
/**
|
|
5270
|
+
* Allows partial updates to a credit entitlement's configuration. Only the fields
|
|
5271
|
+
* provided in the request body will be updated; all other fields remain unchanged.
|
|
5272
|
+
* This endpoint supports nullable fields using the double option pattern.
|
|
5273
|
+
*
|
|
5274
|
+
* # Authentication
|
|
5275
|
+
*
|
|
5276
|
+
* Requires an API key with `Editor` role.
|
|
5277
|
+
*
|
|
5278
|
+
* # Path Parameters
|
|
5279
|
+
*
|
|
5280
|
+
* - `id` - The unique identifier of the credit entitlement to update (format:
|
|
5281
|
+
* `cde_...`)
|
|
5282
|
+
*
|
|
5283
|
+
* # Request Body (all fields optional)
|
|
5284
|
+
*
|
|
5285
|
+
* - `name` - Human-readable name of the credit entitlement (1-255 characters)
|
|
5286
|
+
* - `description` - Optional description (max 1000 characters)
|
|
5287
|
+
* - `unit` - Unit of measurement for the credit (1-50 characters)
|
|
5288
|
+
*
|
|
5289
|
+
* Note: `precision` cannot be modified after creation as it would invalidate
|
|
5290
|
+
* existing grants.
|
|
5291
|
+
*
|
|
5292
|
+
* - `expires_after_days` - Number of days after which credits expire (use `null`
|
|
5293
|
+
* to remove expiration)
|
|
5294
|
+
* - `rollover_enabled` - Whether unused credits can rollover to the next period
|
|
5295
|
+
* - `rollover_percentage` - Percentage of unused credits that rollover (0-100,
|
|
5296
|
+
* nullable)
|
|
5297
|
+
* - `rollover_timeframe_count` - Count of timeframe periods for rollover limit
|
|
5298
|
+
* (nullable)
|
|
5299
|
+
* - `rollover_timeframe_interval` - Interval type (day, week, month, year,
|
|
5300
|
+
* nullable)
|
|
5301
|
+
* - `max_rollover_count` - Maximum number of times credits can be rolled over
|
|
5302
|
+
* (nullable)
|
|
5303
|
+
* - `overage_enabled` - Whether overage charges apply when credits run out
|
|
5304
|
+
* - `overage_limit` - Maximum overage units allowed (nullable)
|
|
5305
|
+
* - `currency` - Currency for pricing (nullable)
|
|
5306
|
+
* - `price_per_unit` - Price per credit unit (decimal, nullable)
|
|
5307
|
+
*
|
|
5308
|
+
* # Responses
|
|
5309
|
+
*
|
|
5310
|
+
* - `200 OK` - Credit entitlement updated successfully
|
|
5311
|
+
* - `404 Not Found` - Credit entitlement does not exist or does not belong to the
|
|
5312
|
+
* authenticated business
|
|
5313
|
+
* - `422 Unprocessable Entity` - Invalid request parameters or validation failure
|
|
5314
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5315
|
+
*
|
|
5316
|
+
* # Business Logic
|
|
5317
|
+
*
|
|
5318
|
+
* - Only non-deleted credit entitlements can be updated
|
|
5319
|
+
* - Fields set to `null` explicitly will clear the database value (using double
|
|
5320
|
+
* option pattern)
|
|
5321
|
+
* - The `updated_at` timestamp is automatically updated on successful modification
|
|
5322
|
+
* - Changes take effect immediately but do not retroactively affect existing
|
|
5323
|
+
* credit grants
|
|
5324
|
+
* - The merged state is validated: currency required with price, rollover
|
|
5325
|
+
* timeframe fields together, price required for overage
|
|
5326
|
+
*/
|
|
5327
|
+
update(id, body, options) {
|
|
5328
|
+
return this._client.patch(path `/credit-entitlements/${id}`, {
|
|
5329
|
+
body,
|
|
5330
|
+
...options,
|
|
5331
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5332
|
+
});
|
|
5333
|
+
}
|
|
5334
|
+
/**
|
|
5335
|
+
* Returns a paginated list of credit entitlements, allowing filtering of deleted
|
|
5336
|
+
* entitlements. By default, only non-deleted entitlements are returned.
|
|
5337
|
+
*
|
|
5338
|
+
* # Authentication
|
|
5339
|
+
*
|
|
5340
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5341
|
+
*
|
|
5342
|
+
* # Query Parameters
|
|
5343
|
+
*
|
|
5344
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5345
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5346
|
+
* - `deleted` - Boolean flag to list deleted entitlements instead of active ones
|
|
5347
|
+
* (default: false)
|
|
5348
|
+
*
|
|
5349
|
+
* # Responses
|
|
5350
|
+
*
|
|
5351
|
+
* - `200 OK` - Returns a list of credit entitlements wrapped in a response object
|
|
5352
|
+
* - `422 Unprocessable Entity` - Invalid query parameters (e.g., page_size > 100)
|
|
5353
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5354
|
+
*
|
|
5355
|
+
* # Business Logic
|
|
5356
|
+
*
|
|
5357
|
+
* - Results are ordered by creation date in descending order (newest first)
|
|
5358
|
+
* - Only entitlements belonging to the authenticated business are returned
|
|
5359
|
+
* - The `deleted` parameter controls visibility of soft-deleted entitlements
|
|
5360
|
+
* - Pagination uses offset-based pagination (offset = page_number \* page_size)
|
|
5361
|
+
*/
|
|
5362
|
+
list(query = {}, options) {
|
|
5363
|
+
return this._client.getAPIList('/credit-entitlements', (DefaultPageNumberPagination), {
|
|
5364
|
+
query,
|
|
5365
|
+
...options,
|
|
5366
|
+
});
|
|
5367
|
+
}
|
|
5368
|
+
delete(id, options) {
|
|
5369
|
+
return this._client.delete(path `/credit-entitlements/${id}`, {
|
|
5370
|
+
...options,
|
|
5371
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5372
|
+
});
|
|
5373
|
+
}
|
|
5374
|
+
/**
|
|
5375
|
+
* Undeletes a soft-deleted credit entitlement by clearing `deleted_at`, making it
|
|
5376
|
+
* available again through standard list and get endpoints.
|
|
5377
|
+
*
|
|
5378
|
+
* # Authentication
|
|
5379
|
+
*
|
|
5380
|
+
* Requires an API key with `Editor` role.
|
|
5381
|
+
*
|
|
5382
|
+
* # Path Parameters
|
|
5383
|
+
*
|
|
5384
|
+
* - `id` - The unique identifier of the credit entitlement to restore (format:
|
|
5385
|
+
* `cde_...`)
|
|
5386
|
+
*
|
|
5387
|
+
* # Responses
|
|
5388
|
+
*
|
|
5389
|
+
* - `200 OK` - Credit entitlement restored successfully
|
|
5390
|
+
* - `500 Internal Server Error` - Database error, entitlement not found, or
|
|
5391
|
+
* entitlement is not deleted
|
|
5392
|
+
*
|
|
5393
|
+
* # Business Logic
|
|
5394
|
+
*
|
|
5395
|
+
* - Only deleted credit entitlements can be restored
|
|
5396
|
+
* - The query filters for `deleted_at IS NOT NULL`, so non-deleted entitlements
|
|
5397
|
+
* will result in 0 rows affected
|
|
5398
|
+
* - If no rows are affected (entitlement doesn't exist, doesn't belong to
|
|
5399
|
+
* business, or is not deleted), returns 500
|
|
5400
|
+
* - The `updated_at` timestamp is automatically updated on successful restoration
|
|
5401
|
+
* - Once restored, the entitlement becomes immediately available in the standard
|
|
5402
|
+
* list and get endpoints
|
|
5403
|
+
* - All configuration settings are preserved during delete/restore operations
|
|
5404
|
+
*
|
|
5405
|
+
* # Error Handling
|
|
5406
|
+
*
|
|
5407
|
+
* This endpoint returns 500 Internal Server Error in several cases:
|
|
5408
|
+
*
|
|
5409
|
+
* - The credit entitlement does not exist
|
|
5410
|
+
* - The credit entitlement belongs to a different business
|
|
5411
|
+
* - The credit entitlement is not currently deleted (already active)
|
|
5412
|
+
*
|
|
5413
|
+
* Callers should verify the entitlement exists and is deleted before calling this
|
|
5414
|
+
* endpoint.
|
|
5415
|
+
*/
|
|
5416
|
+
undelete(id, options) {
|
|
5417
|
+
return this._client.post(path `/credit-entitlements/${id}/undelete`, {
|
|
5418
|
+
...options,
|
|
5419
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5420
|
+
});
|
|
5421
|
+
}
|
|
5422
|
+
}
|
|
5423
|
+
CreditEntitlements.Balances = Balances;
|
|
5424
|
+
|
|
5425
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5426
|
+
let CustomerPortal$1 = class CustomerPortal extends APIResource {
|
|
5427
|
+
create(customerID, params = {}, options) {
|
|
5428
|
+
const { send_email } = params ?? {};
|
|
5429
|
+
return this._client.post(path `/customers/${customerID}/customer-portal/session`, {
|
|
5430
|
+
query: { send_email },
|
|
5431
|
+
...options,
|
|
5432
|
+
});
|
|
5433
|
+
}
|
|
5434
|
+
};
|
|
5435
|
+
|
|
5436
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5437
|
+
class LedgerEntries extends APIResource {
|
|
5438
|
+
create(customerID, body, options) {
|
|
5439
|
+
return this._client.post(path `/customers/${customerID}/wallets/ledger-entries`, { body, ...options });
|
|
5440
|
+
}
|
|
5441
|
+
list(customerID, query = {}, options) {
|
|
5442
|
+
return this._client.getAPIList(path `/customers/${customerID}/wallets/ledger-entries`, (DefaultPageNumberPagination), { query, ...options });
|
|
5443
|
+
}
|
|
5444
|
+
}
|
|
5445
|
+
|
|
5446
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5447
|
+
class Wallets extends APIResource {
|
|
5448
|
+
constructor() {
|
|
5449
|
+
super(...arguments);
|
|
5450
|
+
this.ledgerEntries = new LedgerEntries(this._client);
|
|
5451
|
+
}
|
|
5452
|
+
list(customerID, options) {
|
|
5453
|
+
return this._client.get(path `/customers/${customerID}/wallets`, options);
|
|
5454
|
+
}
|
|
5455
|
+
}
|
|
5456
|
+
Wallets.LedgerEntries = LedgerEntries;
|
|
5457
|
+
|
|
5458
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5459
|
+
class Customers extends APIResource {
|
|
5460
|
+
constructor() {
|
|
5461
|
+
super(...arguments);
|
|
5462
|
+
this.customerPortal = new CustomerPortal$1(this._client);
|
|
5463
|
+
this.wallets = new Wallets(this._client);
|
|
5464
|
+
}
|
|
5465
|
+
create(body, options) {
|
|
5466
|
+
return this._client.post('/customers', { body, ...options });
|
|
5467
|
+
}
|
|
5468
|
+
retrieve(customerID, options) {
|
|
5469
|
+
return this._client.get(path `/customers/${customerID}`, options);
|
|
5470
|
+
}
|
|
5471
|
+
update(customerID, body, options) {
|
|
5472
|
+
return this._client.patch(path `/customers/${customerID}`, { body, ...options });
|
|
5473
|
+
}
|
|
5474
|
+
list(query = {}, options) {
|
|
5475
|
+
return this._client.getAPIList('/customers', (DefaultPageNumberPagination), {
|
|
5476
|
+
query,
|
|
5477
|
+
...options,
|
|
5478
|
+
});
|
|
5479
|
+
}
|
|
5480
|
+
/**
|
|
5481
|
+
* List all credit entitlements for a customer with their current balances
|
|
5482
|
+
*/
|
|
5483
|
+
listCreditEntitlements(customerID, options) {
|
|
5484
|
+
return this._client.get(path `/customers/${customerID}/credit-entitlements`, options);
|
|
5485
|
+
}
|
|
5486
|
+
retrievePaymentMethods(customerID, options) {
|
|
5487
|
+
return this._client.get(path `/customers/${customerID}/payment-methods`, options);
|
|
5488
|
+
}
|
|
5489
|
+
}
|
|
5490
|
+
Customers.CustomerPortal = CustomerPortal$1;
|
|
5491
|
+
Customers.Wallets = Wallets;
|
|
5492
|
+
|
|
5063
5493
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5064
5494
|
class Discounts extends APIResource {
|
|
5065
5495
|
/**
|
|
@@ -5099,6 +5529,14 @@ class Discounts extends APIResource {
|
|
|
5099
5529
|
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5100
5530
|
});
|
|
5101
5531
|
}
|
|
5532
|
+
/**
|
|
5533
|
+
* Validate and fetch a discount by its code name (e.g., "SAVE20"). This allows
|
|
5534
|
+
* real-time validation directly against the API using the human-readable discount
|
|
5535
|
+
* code instead of requiring the internal discount_id.
|
|
5536
|
+
*/
|
|
5537
|
+
retrieveByCode(code, options) {
|
|
5538
|
+
return this._client.get(path `/discounts/code/${code}`, options);
|
|
5539
|
+
}
|
|
5102
5540
|
}
|
|
5103
5541
|
|
|
5104
5542
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
@@ -5297,6 +5735,9 @@ class Misc extends APIResource {
|
|
|
5297
5735
|
|
|
5298
5736
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5299
5737
|
class Payments extends APIResource {
|
|
5738
|
+
/**
|
|
5739
|
+
* @deprecated
|
|
5740
|
+
*/
|
|
5300
5741
|
create(body, options) {
|
|
5301
5742
|
return this._client.post('/payments', { body, ...options });
|
|
5302
5743
|
}
|
|
@@ -5332,11 +5773,29 @@ class Images extends APIResource {
|
|
|
5332
5773
|
}
|
|
5333
5774
|
}
|
|
5334
5775
|
|
|
5776
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5777
|
+
class ShortLinks extends APIResource {
|
|
5778
|
+
/**
|
|
5779
|
+
* Gives a Short Checkout URL with custom slug for a product. Uses a Static
|
|
5780
|
+
* Checkout URL under the hood.
|
|
5781
|
+
*/
|
|
5782
|
+
create(id, body, options) {
|
|
5783
|
+
return this._client.post(path `/products/${id}/short_links`, { body, ...options });
|
|
5784
|
+
}
|
|
5785
|
+
/**
|
|
5786
|
+
* Lists all short links created by the business.
|
|
5787
|
+
*/
|
|
5788
|
+
list(query = {}, options) {
|
|
5789
|
+
return this._client.getAPIList('/products/short_links', (DefaultPageNumberPagination), { query, ...options });
|
|
5790
|
+
}
|
|
5791
|
+
}
|
|
5792
|
+
|
|
5335
5793
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5336
5794
|
class Products extends APIResource {
|
|
5337
5795
|
constructor() {
|
|
5338
5796
|
super(...arguments);
|
|
5339
5797
|
this.images = new Images(this._client);
|
|
5798
|
+
this.shortLinks = new ShortLinks(this._client);
|
|
5340
5799
|
}
|
|
5341
5800
|
create(body, options) {
|
|
5342
5801
|
return this._client.post('/products', { body, ...options });
|
|
@@ -5374,6 +5833,7 @@ class Products extends APIResource {
|
|
|
5374
5833
|
}
|
|
5375
5834
|
}
|
|
5376
5835
|
Products.Images = Images;
|
|
5836
|
+
Products.ShortLinks = ShortLinks;
|
|
5377
5837
|
|
|
5378
5838
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5379
5839
|
class Refunds extends APIResource {
|
|
@@ -5393,6 +5853,9 @@ class Refunds extends APIResource {
|
|
|
5393
5853
|
|
|
5394
5854
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5395
5855
|
class Subscriptions extends APIResource {
|
|
5856
|
+
/**
|
|
5857
|
+
* @deprecated
|
|
5858
|
+
*/
|
|
5396
5859
|
create(body, options) {
|
|
5397
5860
|
return this._client.post('/subscriptions', { body, ...options });
|
|
5398
5861
|
}
|
|
@@ -5418,6 +5881,15 @@ class Subscriptions extends APIResource {
|
|
|
5418
5881
|
charge(subscriptionID, body, options) {
|
|
5419
5882
|
return this._client.post(path `/subscriptions/${subscriptionID}/charge`, { body, ...options });
|
|
5420
5883
|
}
|
|
5884
|
+
previewChangePlan(subscriptionID, body, options) {
|
|
5885
|
+
return this._client.post(path `/subscriptions/${subscriptionID}/change-plan/preview`, {
|
|
5886
|
+
body,
|
|
5887
|
+
...options,
|
|
5888
|
+
});
|
|
5889
|
+
}
|
|
5890
|
+
retrieveCreditUsage(subscriptionID, options) {
|
|
5891
|
+
return this._client.get(path `/subscriptions/${subscriptionID}/credit-usage`, options);
|
|
5892
|
+
}
|
|
5421
5893
|
/**
|
|
5422
5894
|
* Get detailed usage history for a subscription that includes usage-based billing
|
|
5423
5895
|
* (metered components). This endpoint provides insights into customer usage
|
|
@@ -5465,6 +5937,12 @@ class Subscriptions extends APIResource {
|
|
|
5465
5937
|
retrieveUsageHistory(subscriptionID, query = {}, options) {
|
|
5466
5938
|
return this._client.getAPIList(path `/subscriptions/${subscriptionID}/usage-history`, (DefaultPageNumberPagination), { query, ...options });
|
|
5467
5939
|
}
|
|
5940
|
+
updatePaymentMethod(subscriptionID, body, options) {
|
|
5941
|
+
return this._client.post(path `/subscriptions/${subscriptionID}/update-payment-method`, {
|
|
5942
|
+
body,
|
|
5943
|
+
...options,
|
|
5944
|
+
});
|
|
5945
|
+
}
|
|
5468
5946
|
}
|
|
5469
5947
|
|
|
5470
5948
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
@@ -6586,6 +7064,8 @@ class DodoPayments {
|
|
|
6586
7064
|
this.webhookEvents = new WebhookEvents(this);
|
|
6587
7065
|
this.usageEvents = new UsageEvents(this);
|
|
6588
7066
|
this.meters = new Meters(this);
|
|
7067
|
+
this.balances = new Balances$1(this);
|
|
7068
|
+
this.creditEntitlements = new CreditEntitlements(this);
|
|
6589
7069
|
if (bearerToken === undefined) {
|
|
6590
7070
|
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' }).");
|
|
6591
7071
|
}
|
|
@@ -6650,18 +7130,7 @@ class DodoPayments {
|
|
|
6650
7130
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
6651
7131
|
*/
|
|
6652
7132
|
stringifyQuery(query) {
|
|
6653
|
-
return
|
|
6654
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
6655
|
-
.map(([key, value]) => {
|
|
6656
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
6657
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
6658
|
-
}
|
|
6659
|
-
if (value === null) {
|
|
6660
|
-
return `${encodeURIComponent(key)}=`;
|
|
6661
|
-
}
|
|
6662
|
-
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.`);
|
|
6663
|
-
})
|
|
6664
|
-
.join('&');
|
|
7133
|
+
return stringifyQuery(query);
|
|
6665
7134
|
}
|
|
6666
7135
|
getUserAgent() {
|
|
6667
7136
|
return `${this.constructor.name}/JS ${VERSION}`;
|
|
@@ -6825,7 +7294,9 @@ class DodoPayments {
|
|
|
6825
7294
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
6826
7295
|
}
|
|
6827
7296
|
getAPIList(path, Page, opts) {
|
|
6828
|
-
return this.requestAPIList(Page,
|
|
7297
|
+
return this.requestAPIList(Page, opts && 'then' in opts ?
|
|
7298
|
+
opts.then((opts) => ({ method: 'get', path, ...opts }))
|
|
7299
|
+
: { method: 'get', path, ...opts });
|
|
6829
7300
|
}
|
|
6830
7301
|
requestAPIList(Page, options) {
|
|
6831
7302
|
const request = this.makeRequest(options, null, undefined);
|
|
@@ -6833,9 +7304,10 @@ class DodoPayments {
|
|
|
6833
7304
|
}
|
|
6834
7305
|
async fetchWithTimeout(url, init, ms, controller) {
|
|
6835
7306
|
const { signal, method, ...options } = init || {};
|
|
7307
|
+
const abort = this._makeAbort(controller);
|
|
6836
7308
|
if (signal)
|
|
6837
|
-
signal.addEventListener('abort',
|
|
6838
|
-
const timeout = setTimeout(
|
|
7309
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
7310
|
+
const timeout = setTimeout(abort, ms);
|
|
6839
7311
|
const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) ||
|
|
6840
7312
|
(typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body);
|
|
6841
7313
|
const fetchOptions = {
|
|
@@ -6900,9 +7372,9 @@ class DodoPayments {
|
|
|
6900
7372
|
timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
|
|
6901
7373
|
}
|
|
6902
7374
|
}
|
|
6903
|
-
// If the API asks us to wait a certain amount of time
|
|
6904
|
-
//
|
|
6905
|
-
if (
|
|
7375
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
7376
|
+
// says, but otherwise calculate a default
|
|
7377
|
+
if (timeoutMillis === undefined) {
|
|
6906
7378
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
6907
7379
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
6908
7380
|
}
|
|
@@ -6964,6 +7436,11 @@ class DodoPayments {
|
|
|
6964
7436
|
this.validateHeaders(headers);
|
|
6965
7437
|
return headers.values;
|
|
6966
7438
|
}
|
|
7439
|
+
_makeAbort(controller) {
|
|
7440
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
7441
|
+
// would capture all request options, and cause a memory leak.
|
|
7442
|
+
return () => controller.abort();
|
|
7443
|
+
}
|
|
6967
7444
|
buildBody({ options: { body, headers: rawHeaders } }) {
|
|
6968
7445
|
if (!body) {
|
|
6969
7446
|
return { bodyHeaders: undefined, body: undefined };
|
|
@@ -6992,6 +7469,13 @@ class DodoPayments {
|
|
|
6992
7469
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
6993
7470
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
6994
7471
|
}
|
|
7472
|
+
else if (typeof body === 'object' &&
|
|
7473
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
7474
|
+
return {
|
|
7475
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
7476
|
+
body: this.stringifyQuery(body),
|
|
7477
|
+
};
|
|
7478
|
+
}
|
|
6995
7479
|
else {
|
|
6996
7480
|
return __classPrivateFieldGet(this, _DodoPayments_encoder, "f").call(this, { body, headers });
|
|
6997
7481
|
}
|
|
@@ -7036,6 +7520,8 @@ DodoPayments.Webhooks = Webhooks$1;
|
|
|
7036
7520
|
DodoPayments.WebhookEvents = WebhookEvents;
|
|
7037
7521
|
DodoPayments.UsageEvents = UsageEvents;
|
|
7038
7522
|
DodoPayments.Meters = Meters;
|
|
7523
|
+
DodoPayments.Balances = Balances$1;
|
|
7524
|
+
DodoPayments.CreditEntitlements = CreditEntitlements;
|
|
7039
7525
|
|
|
7040
7526
|
// src/checkout/checkout.ts
|
|
7041
7527
|
var checkoutQuerySchema = objectType({
|
|
@@ -7506,6 +7992,32 @@ var buildCheckoutUrl = async ({
|
|
|
7506
7992
|
}
|
|
7507
7993
|
};
|
|
7508
7994
|
|
|
7995
|
+
var __create = Object.create;
|
|
7996
|
+
var __defProp = Object.defineProperty;
|
|
7997
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7998
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7999
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8000
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8001
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
8002
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8003
|
+
};
|
|
8004
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8005
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8006
|
+
for (let key of __getOwnPropNames(from))
|
|
8007
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
8008
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
8009
|
+
}
|
|
8010
|
+
return to;
|
|
8011
|
+
};
|
|
8012
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
8013
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
8014
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
8015
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
8016
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
8017
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
8018
|
+
mod
|
|
8019
|
+
));
|
|
8020
|
+
|
|
7509
8021
|
const Checkout = (config) => {
|
|
7510
8022
|
const getHandler = async ({ request }) => {
|
|
7511
8023
|
const { searchParams } = new URL(request.url);
|
|
@@ -7598,12 +8110,11 @@ const CustomerPortal = ({ bearerToken, environment, }) => {
|
|
|
7598
8110
|
const getHandler = async ({ request }) => {
|
|
7599
8111
|
const { searchParams } = new URL(request.url);
|
|
7600
8112
|
const customerId = searchParams.get("customer_id");
|
|
7601
|
-
const
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
params.send_email = sendEmail;
|
|
8113
|
+
const sendEmailParam = searchParams.get("send_email");
|
|
8114
|
+
const params = {};
|
|
8115
|
+
if (sendEmailParam !== null) {
|
|
8116
|
+
// searchParams.get() already returns a single string or null
|
|
8117
|
+
params.send_email = sendEmailParam === "true";
|
|
7607
8118
|
}
|
|
7608
8119
|
if (!customerId) {
|
|
7609
8120
|
return new Response("Missing customerId in query parameters", {
|
|
@@ -7633,23 +8144,33 @@ var PaymentSchema = objectType({
|
|
|
7633
8144
|
payload_type: literalType("Payment"),
|
|
7634
8145
|
billing: objectType({
|
|
7635
8146
|
city: stringType().nullable(),
|
|
7636
|
-
country: stringType()
|
|
8147
|
+
country: stringType(),
|
|
7637
8148
|
state: stringType().nullable(),
|
|
7638
8149
|
street: stringType().nullable(),
|
|
7639
8150
|
zipcode: stringType().nullable()
|
|
7640
8151
|
}),
|
|
7641
8152
|
brand_id: stringType(),
|
|
7642
8153
|
business_id: stringType(),
|
|
8154
|
+
card_holder_name: stringType().nullable(),
|
|
7643
8155
|
card_issuing_country: stringType().nullable(),
|
|
7644
8156
|
card_last_four: stringType().nullable(),
|
|
7645
8157
|
card_network: stringType().nullable(),
|
|
7646
8158
|
card_type: stringType().nullable(),
|
|
8159
|
+
checkout_session_id: stringType().nullable(),
|
|
7647
8160
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7648
8161
|
currency: stringType(),
|
|
8162
|
+
custom_field_responses: arrayType(
|
|
8163
|
+
objectType({
|
|
8164
|
+
key: stringType(),
|
|
8165
|
+
value: stringType()
|
|
8166
|
+
})
|
|
8167
|
+
).nullable(),
|
|
7649
8168
|
customer: objectType({
|
|
7650
8169
|
customer_id: stringType(),
|
|
7651
8170
|
email: stringType(),
|
|
7652
|
-
|
|
8171
|
+
metadata: recordType(anyType()),
|
|
8172
|
+
name: stringType(),
|
|
8173
|
+
phone_number: stringType().nullable()
|
|
7653
8174
|
}),
|
|
7654
8175
|
digital_products_delivered: booleanType(),
|
|
7655
8176
|
discount_id: stringType().nullable(),
|
|
@@ -7660,27 +8181,25 @@ var PaymentSchema = objectType({
|
|
|
7660
8181
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7661
8182
|
currency: stringType(),
|
|
7662
8183
|
dispute_id: stringType(),
|
|
7663
|
-
dispute_stage: enumType([
|
|
7664
|
-
"pre_dispute",
|
|
7665
|
-
"dispute_opened",
|
|
7666
|
-
"dispute_won",
|
|
7667
|
-
"dispute_lost"
|
|
7668
|
-
]),
|
|
8184
|
+
dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
|
|
7669
8185
|
dispute_status: enumType([
|
|
7670
8186
|
"dispute_opened",
|
|
7671
|
-
"
|
|
7672
|
-
"dispute_lost",
|
|
8187
|
+
"dispute_expired",
|
|
7673
8188
|
"dispute_accepted",
|
|
7674
8189
|
"dispute_cancelled",
|
|
7675
|
-
"dispute_challenged"
|
|
8190
|
+
"dispute_challenged",
|
|
8191
|
+
"dispute_won",
|
|
8192
|
+
"dispute_lost"
|
|
7676
8193
|
]),
|
|
7677
8194
|
payment_id: stringType(),
|
|
7678
8195
|
remarks: stringType().nullable()
|
|
7679
8196
|
})
|
|
7680
|
-
).
|
|
8197
|
+
).default([]),
|
|
7681
8198
|
error_code: stringType().nullable(),
|
|
7682
8199
|
error_message: stringType().nullable(),
|
|
7683
|
-
|
|
8200
|
+
invoice_id: stringType().nullable(),
|
|
8201
|
+
invoice_url: stringType().nullable(),
|
|
8202
|
+
metadata: recordType(anyType()),
|
|
7684
8203
|
payment_id: stringType(),
|
|
7685
8204
|
payment_link: stringType().nullable(),
|
|
7686
8205
|
payment_method: stringType().nullable(),
|
|
@@ -7693,21 +8212,34 @@ var PaymentSchema = objectType({
|
|
|
7693
8212
|
).nullable(),
|
|
7694
8213
|
refunds: arrayType(
|
|
7695
8214
|
objectType({
|
|
7696
|
-
amount: numberType(),
|
|
8215
|
+
amount: numberType().nullable(),
|
|
7697
8216
|
business_id: stringType(),
|
|
7698
8217
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7699
|
-
currency: stringType(),
|
|
8218
|
+
currency: stringType().nullable(),
|
|
7700
8219
|
is_partial: booleanType(),
|
|
7701
8220
|
payment_id: stringType(),
|
|
7702
8221
|
reason: stringType().nullable(),
|
|
7703
8222
|
refund_id: stringType(),
|
|
7704
|
-
status: enumType(["succeeded", "failed", "pending"])
|
|
8223
|
+
status: enumType(["succeeded", "failed", "pending", "review"])
|
|
7705
8224
|
})
|
|
7706
|
-
)
|
|
8225
|
+
),
|
|
8226
|
+
refund_status: enumType(["partial", "full"]).nullable(),
|
|
7707
8227
|
settlement_amount: numberType(),
|
|
7708
8228
|
settlement_currency: stringType(),
|
|
7709
8229
|
settlement_tax: numberType().nullable(),
|
|
7710
|
-
status: enumType([
|
|
8230
|
+
status: enumType([
|
|
8231
|
+
"succeeded",
|
|
8232
|
+
"failed",
|
|
8233
|
+
"cancelled",
|
|
8234
|
+
"processing",
|
|
8235
|
+
"requires_customer_action",
|
|
8236
|
+
"requires_merchant_action",
|
|
8237
|
+
"requires_payment_method",
|
|
8238
|
+
"requires_confirmation",
|
|
8239
|
+
"requires_capture",
|
|
8240
|
+
"partially_captured",
|
|
8241
|
+
"partially_captured_and_capturable"
|
|
8242
|
+
]).nullable(),
|
|
7711
8243
|
subscription_id: stringType().nullable(),
|
|
7712
8244
|
tax: numberType().nullable(),
|
|
7713
8245
|
total_amount: numberType(),
|
|
@@ -7720,10 +8252,10 @@ var SubscriptionSchema = objectType({
|
|
|
7720
8252
|
addon_id: stringType(),
|
|
7721
8253
|
quantity: numberType()
|
|
7722
8254
|
})
|
|
7723
|
-
)
|
|
8255
|
+
),
|
|
7724
8256
|
billing: objectType({
|
|
7725
8257
|
city: stringType().nullable(),
|
|
7726
|
-
country: stringType()
|
|
8258
|
+
country: stringType(),
|
|
7727
8259
|
state: stringType().nullable(),
|
|
7728
8260
|
street: stringType().nullable(),
|
|
7729
8261
|
zipcode: stringType().nullable()
|
|
@@ -7735,15 +8267,72 @@ var SubscriptionSchema = objectType({
|
|
|
7735
8267
|
customer: objectType({
|
|
7736
8268
|
customer_id: stringType(),
|
|
7737
8269
|
email: stringType(),
|
|
7738
|
-
|
|
8270
|
+
metadata: recordType(anyType()),
|
|
8271
|
+
name: stringType(),
|
|
8272
|
+
phone_number: stringType().nullable()
|
|
7739
8273
|
}),
|
|
8274
|
+
custom_field_responses: arrayType(
|
|
8275
|
+
objectType({
|
|
8276
|
+
key: stringType(),
|
|
8277
|
+
value: stringType()
|
|
8278
|
+
})
|
|
8279
|
+
).nullable(),
|
|
8280
|
+
discount_cycles_remaining: numberType().nullable(),
|
|
7740
8281
|
discount_id: stringType().nullable(),
|
|
7741
|
-
|
|
7742
|
-
|
|
8282
|
+
expires_at: stringType().transform((d) => new Date(d)).nullable(),
|
|
8283
|
+
credit_entitlement_cart: arrayType(
|
|
8284
|
+
objectType({
|
|
8285
|
+
credit_entitlement_id: stringType(),
|
|
8286
|
+
credit_entitlement_name: stringType(),
|
|
8287
|
+
credits_amount: stringType(),
|
|
8288
|
+
overage_balance: stringType(),
|
|
8289
|
+
overage_behavior: enumType([
|
|
8290
|
+
"forgive_at_reset",
|
|
8291
|
+
"invoice_at_billing",
|
|
8292
|
+
"carry_deficit",
|
|
8293
|
+
"carry_deficit_auto_repay"
|
|
8294
|
+
]),
|
|
8295
|
+
overage_enabled: booleanType(),
|
|
8296
|
+
product_id: stringType(),
|
|
8297
|
+
remaining_balance: stringType(),
|
|
8298
|
+
rollover_enabled: booleanType(),
|
|
8299
|
+
unit: stringType(),
|
|
8300
|
+
expires_after_days: numberType().nullable(),
|
|
8301
|
+
low_balance_threshold_percent: numberType().nullable(),
|
|
8302
|
+
max_rollover_count: numberType().nullable(),
|
|
8303
|
+
overage_limit: stringType().nullable(),
|
|
8304
|
+
rollover_percentage: numberType().nullable(),
|
|
8305
|
+
rollover_timeframe_count: numberType().nullable(),
|
|
8306
|
+
rollover_timeframe_interval: enumType(["Day", "Week", "Month", "Year"]).nullable()
|
|
8307
|
+
})
|
|
8308
|
+
),
|
|
8309
|
+
meter_credit_entitlement_cart: arrayType(
|
|
8310
|
+
objectType({
|
|
8311
|
+
credit_entitlement_id: stringType(),
|
|
8312
|
+
meter_id: stringType(),
|
|
8313
|
+
meter_name: stringType(),
|
|
8314
|
+
meter_units_per_credit: stringType(),
|
|
8315
|
+
product_id: stringType()
|
|
8316
|
+
})
|
|
8317
|
+
),
|
|
8318
|
+
meters: arrayType(
|
|
8319
|
+
objectType({
|
|
8320
|
+
currency: stringType(),
|
|
8321
|
+
description: stringType().nullable(),
|
|
8322
|
+
free_threshold: numberType(),
|
|
8323
|
+
measurement_unit: stringType(),
|
|
8324
|
+
meter_id: stringType(),
|
|
8325
|
+
name: stringType(),
|
|
8326
|
+
price_per_unit: stringType().nullable()
|
|
8327
|
+
})
|
|
8328
|
+
),
|
|
8329
|
+
metadata: recordType(anyType()),
|
|
8330
|
+
next_billing_date: stringType().transform((d) => new Date(d)),
|
|
7743
8331
|
on_demand: booleanType(),
|
|
7744
8332
|
payment_frequency_count: numberType(),
|
|
7745
8333
|
payment_frequency_interval: enumType(["Day", "Week", "Month", "Year"]),
|
|
7746
|
-
|
|
8334
|
+
payment_method_id: stringType().nullable(),
|
|
8335
|
+
previous_billing_date: stringType().transform((d) => new Date(d)),
|
|
7747
8336
|
product_id: stringType(),
|
|
7748
8337
|
quantity: numberType(),
|
|
7749
8338
|
recurring_pre_tax_amount: numberType(),
|
|
@@ -7751,7 +8340,6 @@ var SubscriptionSchema = objectType({
|
|
|
7751
8340
|
"pending",
|
|
7752
8341
|
"active",
|
|
7753
8342
|
"on_hold",
|
|
7754
|
-
"paused",
|
|
7755
8343
|
"cancelled",
|
|
7756
8344
|
"expired",
|
|
7757
8345
|
"failed"
|
|
@@ -7759,20 +8347,29 @@ var SubscriptionSchema = objectType({
|
|
|
7759
8347
|
subscription_id: stringType(),
|
|
7760
8348
|
subscription_period_count: numberType(),
|
|
7761
8349
|
subscription_period_interval: enumType(["Day", "Week", "Month", "Year"]),
|
|
8350
|
+
tax_id: stringType().nullable(),
|
|
7762
8351
|
tax_inclusive: booleanType(),
|
|
7763
8352
|
trial_period_days: numberType()
|
|
7764
8353
|
});
|
|
7765
8354
|
var RefundSchema = objectType({
|
|
7766
8355
|
payload_type: literalType("Refund"),
|
|
7767
|
-
amount: numberType(),
|
|
8356
|
+
amount: numberType().nullable(),
|
|
7768
8357
|
business_id: stringType(),
|
|
7769
8358
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7770
|
-
|
|
8359
|
+
customer: objectType({
|
|
8360
|
+
customer_id: stringType(),
|
|
8361
|
+
email: stringType(),
|
|
8362
|
+
metadata: recordType(anyType()),
|
|
8363
|
+
name: stringType(),
|
|
8364
|
+
phone_number: stringType().nullable()
|
|
8365
|
+
}),
|
|
8366
|
+
currency: stringType().nullable(),
|
|
7771
8367
|
is_partial: booleanType(),
|
|
8368
|
+
metadata: recordType(anyType()),
|
|
7772
8369
|
payment_id: stringType(),
|
|
7773
8370
|
reason: stringType().nullable(),
|
|
7774
8371
|
refund_id: stringType(),
|
|
7775
|
-
status: enumType(["succeeded", "failed", "pending"])
|
|
8372
|
+
status: enumType(["succeeded", "failed", "pending", "review"])
|
|
7776
8373
|
});
|
|
7777
8374
|
var DisputeSchema = objectType({
|
|
7778
8375
|
payload_type: literalType("Dispute"),
|
|
@@ -7780,27 +8377,31 @@ var DisputeSchema = objectType({
|
|
|
7780
8377
|
business_id: stringType(),
|
|
7781
8378
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7782
8379
|
currency: stringType(),
|
|
8380
|
+
customer: objectType({
|
|
8381
|
+
customer_id: stringType(),
|
|
8382
|
+
email: stringType(),
|
|
8383
|
+
metadata: recordType(anyType()),
|
|
8384
|
+
name: stringType(),
|
|
8385
|
+
phone_number: stringType().nullable()
|
|
8386
|
+
}),
|
|
7783
8387
|
dispute_id: stringType(),
|
|
7784
|
-
dispute_stage: enumType([
|
|
7785
|
-
"pre_dispute",
|
|
7786
|
-
"dispute_opened",
|
|
7787
|
-
"dispute_won",
|
|
7788
|
-
"dispute_lost"
|
|
7789
|
-
]),
|
|
8388
|
+
dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
|
|
7790
8389
|
dispute_status: enumType([
|
|
7791
8390
|
"dispute_opened",
|
|
7792
|
-
"
|
|
7793
|
-
"dispute_lost",
|
|
8391
|
+
"dispute_expired",
|
|
7794
8392
|
"dispute_accepted",
|
|
7795
8393
|
"dispute_cancelled",
|
|
7796
|
-
"dispute_challenged"
|
|
8394
|
+
"dispute_challenged",
|
|
8395
|
+
"dispute_won",
|
|
8396
|
+
"dispute_lost"
|
|
7797
8397
|
]),
|
|
7798
8398
|
payment_id: stringType(),
|
|
8399
|
+
reason: stringType().nullable(),
|
|
7799
8400
|
remarks: stringType().nullable()
|
|
7800
8401
|
});
|
|
7801
8402
|
var LicenseKeySchema = objectType({
|
|
7802
8403
|
payload_type: literalType("LicenseKey"),
|
|
7803
|
-
activations_limit: numberType(),
|
|
8404
|
+
activations_limit: numberType().nullable(),
|
|
7804
8405
|
business_id: stringType(),
|
|
7805
8406
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7806
8407
|
customer_id: stringType(),
|
|
@@ -7810,7 +8411,7 @@ var LicenseKeySchema = objectType({
|
|
|
7810
8411
|
key: stringType(),
|
|
7811
8412
|
payment_id: stringType(),
|
|
7812
8413
|
product_id: stringType(),
|
|
7813
|
-
status: enumType(["active", "
|
|
8414
|
+
status: enumType(["active", "expired", "disabled"]),
|
|
7814
8415
|
subscription_id: stringType().nullable()
|
|
7815
8416
|
});
|
|
7816
8417
|
var PaymentSucceededPayloadSchema = objectType({
|
|
@@ -7909,12 +8510,6 @@ var SubscriptionRenewedPayloadSchema = objectType({
|
|
|
7909
8510
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
7910
8511
|
data: SubscriptionSchema
|
|
7911
8512
|
});
|
|
7912
|
-
var SubscriptionPausedPayloadSchema = objectType({
|
|
7913
|
-
business_id: stringType(),
|
|
7914
|
-
type: literalType("subscription.paused"),
|
|
7915
|
-
timestamp: stringType().transform((d) => new Date(d)),
|
|
7916
|
-
data: SubscriptionSchema
|
|
7917
|
-
});
|
|
7918
8513
|
var SubscriptionPlanChangedPayloadSchema = objectType({
|
|
7919
8514
|
business_id: stringType(),
|
|
7920
8515
|
type: literalType("subscription.plan_changed"),
|
|
@@ -7951,6 +8546,94 @@ var LicenseKeyCreatedPayloadSchema = objectType({
|
|
|
7951
8546
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
7952
8547
|
data: LicenseKeySchema
|
|
7953
8548
|
});
|
|
8549
|
+
var CreditLedgerEntrySchema = objectType({
|
|
8550
|
+
payload_type: literalType("CreditLedgerEntry"),
|
|
8551
|
+
id: stringType(),
|
|
8552
|
+
amount: stringType(),
|
|
8553
|
+
balance_after: stringType(),
|
|
8554
|
+
balance_before: stringType(),
|
|
8555
|
+
business_id: stringType(),
|
|
8556
|
+
created_at: stringType().transform((d) => new Date(d)),
|
|
8557
|
+
credit_entitlement_id: stringType(),
|
|
8558
|
+
customer_id: stringType(),
|
|
8559
|
+
is_credit: booleanType(),
|
|
8560
|
+
overage_after: stringType(),
|
|
8561
|
+
overage_before: stringType(),
|
|
8562
|
+
transaction_type: enumType([
|
|
8563
|
+
"credit_added",
|
|
8564
|
+
"credit_deducted",
|
|
8565
|
+
"credit_expired",
|
|
8566
|
+
"credit_rolled_over",
|
|
8567
|
+
"rollover_forfeited",
|
|
8568
|
+
"overage_charged",
|
|
8569
|
+
"auto_top_up",
|
|
8570
|
+
"manual_adjustment",
|
|
8571
|
+
"refund"
|
|
8572
|
+
]),
|
|
8573
|
+
description: stringType().nullable(),
|
|
8574
|
+
grant_id: stringType().nullable(),
|
|
8575
|
+
reference_id: stringType().nullable(),
|
|
8576
|
+
reference_type: stringType().nullable()
|
|
8577
|
+
});
|
|
8578
|
+
var CreditBalanceLowSchema = objectType({
|
|
8579
|
+
payload_type: literalType("CreditBalanceLow"),
|
|
8580
|
+
customer_id: stringType(),
|
|
8581
|
+
subscription_id: stringType(),
|
|
8582
|
+
credit_entitlement_id: stringType(),
|
|
8583
|
+
credit_entitlement_name: stringType(),
|
|
8584
|
+
available_balance: stringType(),
|
|
8585
|
+
subscription_credits_amount: stringType(),
|
|
8586
|
+
threshold_percent: numberType(),
|
|
8587
|
+
threshold_amount: stringType()
|
|
8588
|
+
});
|
|
8589
|
+
var CreditAddedPayloadSchema = objectType({
|
|
8590
|
+
business_id: stringType(),
|
|
8591
|
+
type: literalType("credit.added"),
|
|
8592
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8593
|
+
data: CreditLedgerEntrySchema
|
|
8594
|
+
});
|
|
8595
|
+
var CreditDeductedPayloadSchema = objectType({
|
|
8596
|
+
business_id: stringType(),
|
|
8597
|
+
type: literalType("credit.deducted"),
|
|
8598
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8599
|
+
data: CreditLedgerEntrySchema
|
|
8600
|
+
});
|
|
8601
|
+
var CreditExpiredPayloadSchema = objectType({
|
|
8602
|
+
business_id: stringType(),
|
|
8603
|
+
type: literalType("credit.expired"),
|
|
8604
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8605
|
+
data: CreditLedgerEntrySchema
|
|
8606
|
+
});
|
|
8607
|
+
var CreditRolledOverPayloadSchema = objectType({
|
|
8608
|
+
business_id: stringType(),
|
|
8609
|
+
type: literalType("credit.rolled_over"),
|
|
8610
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8611
|
+
data: CreditLedgerEntrySchema
|
|
8612
|
+
});
|
|
8613
|
+
var CreditRolloverForfeitedPayloadSchema = objectType({
|
|
8614
|
+
business_id: stringType(),
|
|
8615
|
+
type: literalType("credit.rollover_forfeited"),
|
|
8616
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8617
|
+
data: CreditLedgerEntrySchema
|
|
8618
|
+
});
|
|
8619
|
+
var CreditOverageChargedPayloadSchema = objectType({
|
|
8620
|
+
business_id: stringType(),
|
|
8621
|
+
type: literalType("credit.overage_charged"),
|
|
8622
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8623
|
+
data: CreditLedgerEntrySchema
|
|
8624
|
+
});
|
|
8625
|
+
var CreditManualAdjustmentPayloadSchema = objectType({
|
|
8626
|
+
business_id: stringType(),
|
|
8627
|
+
type: literalType("credit.manual_adjustment"),
|
|
8628
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8629
|
+
data: CreditLedgerEntrySchema
|
|
8630
|
+
});
|
|
8631
|
+
var CreditBalanceLowPayloadSchema = objectType({
|
|
8632
|
+
business_id: stringType(),
|
|
8633
|
+
type: literalType("credit.balance_low"),
|
|
8634
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8635
|
+
data: CreditBalanceLowSchema
|
|
8636
|
+
});
|
|
7954
8637
|
var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
7955
8638
|
PaymentSucceededPayloadSchema,
|
|
7956
8639
|
PaymentFailedPayloadSchema,
|
|
@@ -7968,15 +8651,691 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
|
7968
8651
|
SubscriptionActivePayloadSchema,
|
|
7969
8652
|
SubscriptionOnHoldPayloadSchema,
|
|
7970
8653
|
SubscriptionRenewedPayloadSchema,
|
|
7971
|
-
SubscriptionPausedPayloadSchema,
|
|
7972
8654
|
SubscriptionPlanChangedPayloadSchema,
|
|
7973
8655
|
SubscriptionCancelledPayloadSchema,
|
|
7974
8656
|
SubscriptionFailedPayloadSchema,
|
|
7975
8657
|
SubscriptionExpiredPayloadSchema,
|
|
7976
8658
|
SubscriptionUpdatedPayloadSchema,
|
|
7977
|
-
LicenseKeyCreatedPayloadSchema
|
|
8659
|
+
LicenseKeyCreatedPayloadSchema,
|
|
8660
|
+
CreditAddedPayloadSchema,
|
|
8661
|
+
CreditDeductedPayloadSchema,
|
|
8662
|
+
CreditExpiredPayloadSchema,
|
|
8663
|
+
CreditRolledOverPayloadSchema,
|
|
8664
|
+
CreditRolloverForfeitedPayloadSchema,
|
|
8665
|
+
CreditOverageChargedPayloadSchema,
|
|
8666
|
+
CreditManualAdjustmentPayloadSchema,
|
|
8667
|
+
CreditBalanceLowPayloadSchema
|
|
7978
8668
|
]);
|
|
7979
8669
|
|
|
8670
|
+
// ../../node_modules/@stablelib/base64/lib/base64.js
|
|
8671
|
+
var require_base64 = __commonJS({
|
|
8672
|
+
"../../node_modules/@stablelib/base64/lib/base64.js"(exports) {
|
|
8673
|
+
var __extends = exports && exports.__extends || /* @__PURE__ */ function() {
|
|
8674
|
+
var extendStatics = function(d, b) {
|
|
8675
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
8676
|
+
d2.__proto__ = b2;
|
|
8677
|
+
} || function(d2, b2) {
|
|
8678
|
+
for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
|
|
8679
|
+
};
|
|
8680
|
+
return extendStatics(d, b);
|
|
8681
|
+
};
|
|
8682
|
+
return function(d, b) {
|
|
8683
|
+
extendStatics(d, b);
|
|
8684
|
+
function __() {
|
|
8685
|
+
this.constructor = d;
|
|
8686
|
+
}
|
|
8687
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8688
|
+
};
|
|
8689
|
+
}();
|
|
8690
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8691
|
+
var INVALID_BYTE = 256;
|
|
8692
|
+
var Coder = (
|
|
8693
|
+
/** @class */
|
|
8694
|
+
function() {
|
|
8695
|
+
function Coder2(_paddingCharacter) {
|
|
8696
|
+
if (_paddingCharacter === void 0) {
|
|
8697
|
+
_paddingCharacter = "=";
|
|
8698
|
+
}
|
|
8699
|
+
this._paddingCharacter = _paddingCharacter;
|
|
8700
|
+
}
|
|
8701
|
+
Coder2.prototype.encodedLength = function(length) {
|
|
8702
|
+
if (!this._paddingCharacter) {
|
|
8703
|
+
return (length * 8 + 5) / 6 | 0;
|
|
8704
|
+
}
|
|
8705
|
+
return (length + 2) / 3 * 4 | 0;
|
|
8706
|
+
};
|
|
8707
|
+
Coder2.prototype.encode = function(data) {
|
|
8708
|
+
var out = "";
|
|
8709
|
+
var i = 0;
|
|
8710
|
+
for (; i < data.length - 2; i += 3) {
|
|
8711
|
+
var c = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
|
|
8712
|
+
out += this._encodeByte(c >>> 3 * 6 & 63);
|
|
8713
|
+
out += this._encodeByte(c >>> 2 * 6 & 63);
|
|
8714
|
+
out += this._encodeByte(c >>> 1 * 6 & 63);
|
|
8715
|
+
out += this._encodeByte(c >>> 0 * 6 & 63);
|
|
8716
|
+
}
|
|
8717
|
+
var left = data.length - i;
|
|
8718
|
+
if (left > 0) {
|
|
8719
|
+
var c = data[i] << 16 | (left === 2 ? data[i + 1] << 8 : 0);
|
|
8720
|
+
out += this._encodeByte(c >>> 3 * 6 & 63);
|
|
8721
|
+
out += this._encodeByte(c >>> 2 * 6 & 63);
|
|
8722
|
+
if (left === 2) {
|
|
8723
|
+
out += this._encodeByte(c >>> 1 * 6 & 63);
|
|
8724
|
+
} else {
|
|
8725
|
+
out += this._paddingCharacter || "";
|
|
8726
|
+
}
|
|
8727
|
+
out += this._paddingCharacter || "";
|
|
8728
|
+
}
|
|
8729
|
+
return out;
|
|
8730
|
+
};
|
|
8731
|
+
Coder2.prototype.maxDecodedLength = function(length) {
|
|
8732
|
+
if (!this._paddingCharacter) {
|
|
8733
|
+
return (length * 6 + 7) / 8 | 0;
|
|
8734
|
+
}
|
|
8735
|
+
return length / 4 * 3 | 0;
|
|
8736
|
+
};
|
|
8737
|
+
Coder2.prototype.decodedLength = function(s) {
|
|
8738
|
+
return this.maxDecodedLength(s.length - this._getPaddingLength(s));
|
|
8739
|
+
};
|
|
8740
|
+
Coder2.prototype.decode = function(s) {
|
|
8741
|
+
if (s.length === 0) {
|
|
8742
|
+
return new Uint8Array(0);
|
|
8743
|
+
}
|
|
8744
|
+
var paddingLength = this._getPaddingLength(s);
|
|
8745
|
+
var length = s.length - paddingLength;
|
|
8746
|
+
var out = new Uint8Array(this.maxDecodedLength(length));
|
|
8747
|
+
var op = 0;
|
|
8748
|
+
var i = 0;
|
|
8749
|
+
var haveBad = 0;
|
|
8750
|
+
var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
|
|
8751
|
+
for (; i < length - 4; i += 4) {
|
|
8752
|
+
v0 = this._decodeChar(s.charCodeAt(i + 0));
|
|
8753
|
+
v1 = this._decodeChar(s.charCodeAt(i + 1));
|
|
8754
|
+
v2 = this._decodeChar(s.charCodeAt(i + 2));
|
|
8755
|
+
v3 = this._decodeChar(s.charCodeAt(i + 3));
|
|
8756
|
+
out[op++] = v0 << 2 | v1 >>> 4;
|
|
8757
|
+
out[op++] = v1 << 4 | v2 >>> 2;
|
|
8758
|
+
out[op++] = v2 << 6 | v3;
|
|
8759
|
+
haveBad |= v0 & INVALID_BYTE;
|
|
8760
|
+
haveBad |= v1 & INVALID_BYTE;
|
|
8761
|
+
haveBad |= v2 & INVALID_BYTE;
|
|
8762
|
+
haveBad |= v3 & INVALID_BYTE;
|
|
8763
|
+
}
|
|
8764
|
+
if (i < length - 1) {
|
|
8765
|
+
v0 = this._decodeChar(s.charCodeAt(i));
|
|
8766
|
+
v1 = this._decodeChar(s.charCodeAt(i + 1));
|
|
8767
|
+
out[op++] = v0 << 2 | v1 >>> 4;
|
|
8768
|
+
haveBad |= v0 & INVALID_BYTE;
|
|
8769
|
+
haveBad |= v1 & INVALID_BYTE;
|
|
8770
|
+
}
|
|
8771
|
+
if (i < length - 2) {
|
|
8772
|
+
v2 = this._decodeChar(s.charCodeAt(i + 2));
|
|
8773
|
+
out[op++] = v1 << 4 | v2 >>> 2;
|
|
8774
|
+
haveBad |= v2 & INVALID_BYTE;
|
|
8775
|
+
}
|
|
8776
|
+
if (i < length - 3) {
|
|
8777
|
+
v3 = this._decodeChar(s.charCodeAt(i + 3));
|
|
8778
|
+
out[op++] = v2 << 6 | v3;
|
|
8779
|
+
haveBad |= v3 & INVALID_BYTE;
|
|
8780
|
+
}
|
|
8781
|
+
if (haveBad !== 0) {
|
|
8782
|
+
throw new Error("Base64Coder: incorrect characters for decoding");
|
|
8783
|
+
}
|
|
8784
|
+
return out;
|
|
8785
|
+
};
|
|
8786
|
+
Coder2.prototype._encodeByte = function(b) {
|
|
8787
|
+
var result = b;
|
|
8788
|
+
result += 65;
|
|
8789
|
+
result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
|
|
8790
|
+
result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
|
|
8791
|
+
result += 61 - b >>> 8 & 52 - 48 - 62 + 43;
|
|
8792
|
+
result += 62 - b >>> 8 & 62 - 43 - 63 + 47;
|
|
8793
|
+
return String.fromCharCode(result);
|
|
8794
|
+
};
|
|
8795
|
+
Coder2.prototype._decodeChar = function(c) {
|
|
8796
|
+
var result = INVALID_BYTE;
|
|
8797
|
+
result += (42 - c & c - 44) >>> 8 & -INVALID_BYTE + c - 43 + 62;
|
|
8798
|
+
result += (46 - c & c - 48) >>> 8 & -INVALID_BYTE + c - 47 + 63;
|
|
8799
|
+
result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
|
|
8800
|
+
result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
|
|
8801
|
+
result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
|
|
8802
|
+
return result;
|
|
8803
|
+
};
|
|
8804
|
+
Coder2.prototype._getPaddingLength = function(s) {
|
|
8805
|
+
var paddingLength = 0;
|
|
8806
|
+
if (this._paddingCharacter) {
|
|
8807
|
+
for (var i = s.length - 1; i >= 0; i--) {
|
|
8808
|
+
if (s[i] !== this._paddingCharacter) {
|
|
8809
|
+
break;
|
|
8810
|
+
}
|
|
8811
|
+
paddingLength++;
|
|
8812
|
+
}
|
|
8813
|
+
if (s.length < 4 || paddingLength > 2) {
|
|
8814
|
+
throw new Error("Base64Coder: incorrect padding");
|
|
8815
|
+
}
|
|
8816
|
+
}
|
|
8817
|
+
return paddingLength;
|
|
8818
|
+
};
|
|
8819
|
+
return Coder2;
|
|
8820
|
+
}()
|
|
8821
|
+
);
|
|
8822
|
+
exports.Coder = Coder;
|
|
8823
|
+
var stdCoder = new Coder();
|
|
8824
|
+
function encode2(data) {
|
|
8825
|
+
return stdCoder.encode(data);
|
|
8826
|
+
}
|
|
8827
|
+
exports.encode = encode2;
|
|
8828
|
+
function decode2(s) {
|
|
8829
|
+
return stdCoder.decode(s);
|
|
8830
|
+
}
|
|
8831
|
+
exports.decode = decode2;
|
|
8832
|
+
var URLSafeCoder = (
|
|
8833
|
+
/** @class */
|
|
8834
|
+
function(_super) {
|
|
8835
|
+
__extends(URLSafeCoder2, _super);
|
|
8836
|
+
function URLSafeCoder2() {
|
|
8837
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
8838
|
+
}
|
|
8839
|
+
URLSafeCoder2.prototype._encodeByte = function(b) {
|
|
8840
|
+
var result = b;
|
|
8841
|
+
result += 65;
|
|
8842
|
+
result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
|
|
8843
|
+
result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
|
|
8844
|
+
result += 61 - b >>> 8 & 52 - 48 - 62 + 45;
|
|
8845
|
+
result += 62 - b >>> 8 & 62 - 45 - 63 + 95;
|
|
8846
|
+
return String.fromCharCode(result);
|
|
8847
|
+
};
|
|
8848
|
+
URLSafeCoder2.prototype._decodeChar = function(c) {
|
|
8849
|
+
var result = INVALID_BYTE;
|
|
8850
|
+
result += (44 - c & c - 46) >>> 8 & -INVALID_BYTE + c - 45 + 62;
|
|
8851
|
+
result += (94 - c & c - 96) >>> 8 & -INVALID_BYTE + c - 95 + 63;
|
|
8852
|
+
result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
|
|
8853
|
+
result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
|
|
8854
|
+
result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
|
|
8855
|
+
return result;
|
|
8856
|
+
};
|
|
8857
|
+
return URLSafeCoder2;
|
|
8858
|
+
}(Coder)
|
|
8859
|
+
);
|
|
8860
|
+
exports.URLSafeCoder = URLSafeCoder;
|
|
8861
|
+
var urlSafeCoder = new URLSafeCoder();
|
|
8862
|
+
function encodeURLSafe(data) {
|
|
8863
|
+
return urlSafeCoder.encode(data);
|
|
8864
|
+
}
|
|
8865
|
+
exports.encodeURLSafe = encodeURLSafe;
|
|
8866
|
+
function decodeURLSafe(s) {
|
|
8867
|
+
return urlSafeCoder.decode(s);
|
|
8868
|
+
}
|
|
8869
|
+
exports.decodeURLSafe = decodeURLSafe;
|
|
8870
|
+
exports.encodedLength = function(length) {
|
|
8871
|
+
return stdCoder.encodedLength(length);
|
|
8872
|
+
};
|
|
8873
|
+
exports.maxDecodedLength = function(length) {
|
|
8874
|
+
return stdCoder.maxDecodedLength(length);
|
|
8875
|
+
};
|
|
8876
|
+
exports.decodedLength = function(s) {
|
|
8877
|
+
return stdCoder.decodedLength(s);
|
|
8878
|
+
};
|
|
8879
|
+
}
|
|
8880
|
+
});
|
|
8881
|
+
|
|
8882
|
+
// ../../node_modules/fast-sha256/sha256.js
|
|
8883
|
+
var require_sha256 = __commonJS({
|
|
8884
|
+
"../../node_modules/fast-sha256/sha256.js"(exports, module) {
|
|
8885
|
+
(function(root, factory) {
|
|
8886
|
+
var exports2 = {};
|
|
8887
|
+
factory(exports2);
|
|
8888
|
+
var sha2562 = exports2["default"];
|
|
8889
|
+
for (var k in exports2) {
|
|
8890
|
+
sha2562[k] = exports2[k];
|
|
8891
|
+
}
|
|
8892
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
8893
|
+
module.exports = sha2562;
|
|
8894
|
+
} else if (typeof define === "function" && define.amd) {
|
|
8895
|
+
define(function() {
|
|
8896
|
+
return sha2562;
|
|
8897
|
+
});
|
|
8898
|
+
} else {
|
|
8899
|
+
root.sha256 = sha2562;
|
|
8900
|
+
}
|
|
8901
|
+
})(exports, function(exports2) {
|
|
8902
|
+
exports2.__esModule = true;
|
|
8903
|
+
exports2.digestLength = 32;
|
|
8904
|
+
exports2.blockSize = 64;
|
|
8905
|
+
var K = new Uint32Array([
|
|
8906
|
+
1116352408,
|
|
8907
|
+
1899447441,
|
|
8908
|
+
3049323471,
|
|
8909
|
+
3921009573,
|
|
8910
|
+
961987163,
|
|
8911
|
+
1508970993,
|
|
8912
|
+
2453635748,
|
|
8913
|
+
2870763221,
|
|
8914
|
+
3624381080,
|
|
8915
|
+
310598401,
|
|
8916
|
+
607225278,
|
|
8917
|
+
1426881987,
|
|
8918
|
+
1925078388,
|
|
8919
|
+
2162078206,
|
|
8920
|
+
2614888103,
|
|
8921
|
+
3248222580,
|
|
8922
|
+
3835390401,
|
|
8923
|
+
4022224774,
|
|
8924
|
+
264347078,
|
|
8925
|
+
604807628,
|
|
8926
|
+
770255983,
|
|
8927
|
+
1249150122,
|
|
8928
|
+
1555081692,
|
|
8929
|
+
1996064986,
|
|
8930
|
+
2554220882,
|
|
8931
|
+
2821834349,
|
|
8932
|
+
2952996808,
|
|
8933
|
+
3210313671,
|
|
8934
|
+
3336571891,
|
|
8935
|
+
3584528711,
|
|
8936
|
+
113926993,
|
|
8937
|
+
338241895,
|
|
8938
|
+
666307205,
|
|
8939
|
+
773529912,
|
|
8940
|
+
1294757372,
|
|
8941
|
+
1396182291,
|
|
8942
|
+
1695183700,
|
|
8943
|
+
1986661051,
|
|
8944
|
+
2177026350,
|
|
8945
|
+
2456956037,
|
|
8946
|
+
2730485921,
|
|
8947
|
+
2820302411,
|
|
8948
|
+
3259730800,
|
|
8949
|
+
3345764771,
|
|
8950
|
+
3516065817,
|
|
8951
|
+
3600352804,
|
|
8952
|
+
4094571909,
|
|
8953
|
+
275423344,
|
|
8954
|
+
430227734,
|
|
8955
|
+
506948616,
|
|
8956
|
+
659060556,
|
|
8957
|
+
883997877,
|
|
8958
|
+
958139571,
|
|
8959
|
+
1322822218,
|
|
8960
|
+
1537002063,
|
|
8961
|
+
1747873779,
|
|
8962
|
+
1955562222,
|
|
8963
|
+
2024104815,
|
|
8964
|
+
2227730452,
|
|
8965
|
+
2361852424,
|
|
8966
|
+
2428436474,
|
|
8967
|
+
2756734187,
|
|
8968
|
+
3204031479,
|
|
8969
|
+
3329325298
|
|
8970
|
+
]);
|
|
8971
|
+
function hashBlocks(w, v, p, pos, len) {
|
|
8972
|
+
var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
|
|
8973
|
+
while (len >= 64) {
|
|
8974
|
+
a = v[0];
|
|
8975
|
+
b = v[1];
|
|
8976
|
+
c = v[2];
|
|
8977
|
+
d = v[3];
|
|
8978
|
+
e = v[4];
|
|
8979
|
+
f = v[5];
|
|
8980
|
+
g = v[6];
|
|
8981
|
+
h = v[7];
|
|
8982
|
+
for (i = 0; i < 16; i++) {
|
|
8983
|
+
j = pos + i * 4;
|
|
8984
|
+
w[i] = (p[j] & 255) << 24 | (p[j + 1] & 255) << 16 | (p[j + 2] & 255) << 8 | p[j + 3] & 255;
|
|
8985
|
+
}
|
|
8986
|
+
for (i = 16; i < 64; i++) {
|
|
8987
|
+
u = w[i - 2];
|
|
8988
|
+
t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10;
|
|
8989
|
+
u = w[i - 15];
|
|
8990
|
+
t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3;
|
|
8991
|
+
w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
|
|
8992
|
+
}
|
|
8993
|
+
for (i = 0; i < 64; i++) {
|
|
8994
|
+
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;
|
|
8995
|
+
t2 = ((a >>> 2 | a << 32 - 2) ^ (a >>> 13 | a << 32 - 13) ^ (a >>> 22 | a << 32 - 22)) + (a & b ^ a & c ^ b & c) | 0;
|
|
8996
|
+
h = g;
|
|
8997
|
+
g = f;
|
|
8998
|
+
f = e;
|
|
8999
|
+
e = d + t1 | 0;
|
|
9000
|
+
d = c;
|
|
9001
|
+
c = b;
|
|
9002
|
+
b = a;
|
|
9003
|
+
a = t1 + t2 | 0;
|
|
9004
|
+
}
|
|
9005
|
+
v[0] += a;
|
|
9006
|
+
v[1] += b;
|
|
9007
|
+
v[2] += c;
|
|
9008
|
+
v[3] += d;
|
|
9009
|
+
v[4] += e;
|
|
9010
|
+
v[5] += f;
|
|
9011
|
+
v[6] += g;
|
|
9012
|
+
v[7] += h;
|
|
9013
|
+
pos += 64;
|
|
9014
|
+
len -= 64;
|
|
9015
|
+
}
|
|
9016
|
+
return pos;
|
|
9017
|
+
}
|
|
9018
|
+
var Hash = (
|
|
9019
|
+
/** @class */
|
|
9020
|
+
function() {
|
|
9021
|
+
function Hash2() {
|
|
9022
|
+
this.digestLength = exports2.digestLength;
|
|
9023
|
+
this.blockSize = exports2.blockSize;
|
|
9024
|
+
this.state = new Int32Array(8);
|
|
9025
|
+
this.temp = new Int32Array(64);
|
|
9026
|
+
this.buffer = new Uint8Array(128);
|
|
9027
|
+
this.bufferLength = 0;
|
|
9028
|
+
this.bytesHashed = 0;
|
|
9029
|
+
this.finished = false;
|
|
9030
|
+
this.reset();
|
|
9031
|
+
}
|
|
9032
|
+
Hash2.prototype.reset = function() {
|
|
9033
|
+
this.state[0] = 1779033703;
|
|
9034
|
+
this.state[1] = 3144134277;
|
|
9035
|
+
this.state[2] = 1013904242;
|
|
9036
|
+
this.state[3] = 2773480762;
|
|
9037
|
+
this.state[4] = 1359893119;
|
|
9038
|
+
this.state[5] = 2600822924;
|
|
9039
|
+
this.state[6] = 528734635;
|
|
9040
|
+
this.state[7] = 1541459225;
|
|
9041
|
+
this.bufferLength = 0;
|
|
9042
|
+
this.bytesHashed = 0;
|
|
9043
|
+
this.finished = false;
|
|
9044
|
+
return this;
|
|
9045
|
+
};
|
|
9046
|
+
Hash2.prototype.clean = function() {
|
|
9047
|
+
for (var i = 0; i < this.buffer.length; i++) {
|
|
9048
|
+
this.buffer[i] = 0;
|
|
9049
|
+
}
|
|
9050
|
+
for (var i = 0; i < this.temp.length; i++) {
|
|
9051
|
+
this.temp[i] = 0;
|
|
9052
|
+
}
|
|
9053
|
+
this.reset();
|
|
9054
|
+
};
|
|
9055
|
+
Hash2.prototype.update = function(data, dataLength) {
|
|
9056
|
+
if (dataLength === void 0) {
|
|
9057
|
+
dataLength = data.length;
|
|
9058
|
+
}
|
|
9059
|
+
if (this.finished) {
|
|
9060
|
+
throw new Error("SHA256: can't update because hash was finished.");
|
|
9061
|
+
}
|
|
9062
|
+
var dataPos = 0;
|
|
9063
|
+
this.bytesHashed += dataLength;
|
|
9064
|
+
if (this.bufferLength > 0) {
|
|
9065
|
+
while (this.bufferLength < 64 && dataLength > 0) {
|
|
9066
|
+
this.buffer[this.bufferLength++] = data[dataPos++];
|
|
9067
|
+
dataLength--;
|
|
9068
|
+
}
|
|
9069
|
+
if (this.bufferLength === 64) {
|
|
9070
|
+
hashBlocks(this.temp, this.state, this.buffer, 0, 64);
|
|
9071
|
+
this.bufferLength = 0;
|
|
9072
|
+
}
|
|
9073
|
+
}
|
|
9074
|
+
if (dataLength >= 64) {
|
|
9075
|
+
dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
|
|
9076
|
+
dataLength %= 64;
|
|
9077
|
+
}
|
|
9078
|
+
while (dataLength > 0) {
|
|
9079
|
+
this.buffer[this.bufferLength++] = data[dataPos++];
|
|
9080
|
+
dataLength--;
|
|
9081
|
+
}
|
|
9082
|
+
return this;
|
|
9083
|
+
};
|
|
9084
|
+
Hash2.prototype.finish = function(out) {
|
|
9085
|
+
if (!this.finished) {
|
|
9086
|
+
var bytesHashed = this.bytesHashed;
|
|
9087
|
+
var left = this.bufferLength;
|
|
9088
|
+
var bitLenHi = bytesHashed / 536870912 | 0;
|
|
9089
|
+
var bitLenLo = bytesHashed << 3;
|
|
9090
|
+
var padLength = bytesHashed % 64 < 56 ? 64 : 128;
|
|
9091
|
+
this.buffer[left] = 128;
|
|
9092
|
+
for (var i = left + 1; i < padLength - 8; i++) {
|
|
9093
|
+
this.buffer[i] = 0;
|
|
9094
|
+
}
|
|
9095
|
+
this.buffer[padLength - 8] = bitLenHi >>> 24 & 255;
|
|
9096
|
+
this.buffer[padLength - 7] = bitLenHi >>> 16 & 255;
|
|
9097
|
+
this.buffer[padLength - 6] = bitLenHi >>> 8 & 255;
|
|
9098
|
+
this.buffer[padLength - 5] = bitLenHi >>> 0 & 255;
|
|
9099
|
+
this.buffer[padLength - 4] = bitLenLo >>> 24 & 255;
|
|
9100
|
+
this.buffer[padLength - 3] = bitLenLo >>> 16 & 255;
|
|
9101
|
+
this.buffer[padLength - 2] = bitLenLo >>> 8 & 255;
|
|
9102
|
+
this.buffer[padLength - 1] = bitLenLo >>> 0 & 255;
|
|
9103
|
+
hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
|
|
9104
|
+
this.finished = true;
|
|
9105
|
+
}
|
|
9106
|
+
for (var i = 0; i < 8; i++) {
|
|
9107
|
+
out[i * 4 + 0] = this.state[i] >>> 24 & 255;
|
|
9108
|
+
out[i * 4 + 1] = this.state[i] >>> 16 & 255;
|
|
9109
|
+
out[i * 4 + 2] = this.state[i] >>> 8 & 255;
|
|
9110
|
+
out[i * 4 + 3] = this.state[i] >>> 0 & 255;
|
|
9111
|
+
}
|
|
9112
|
+
return this;
|
|
9113
|
+
};
|
|
9114
|
+
Hash2.prototype.digest = function() {
|
|
9115
|
+
var out = new Uint8Array(this.digestLength);
|
|
9116
|
+
this.finish(out);
|
|
9117
|
+
return out;
|
|
9118
|
+
};
|
|
9119
|
+
Hash2.prototype._saveState = function(out) {
|
|
9120
|
+
for (var i = 0; i < this.state.length; i++) {
|
|
9121
|
+
out[i] = this.state[i];
|
|
9122
|
+
}
|
|
9123
|
+
};
|
|
9124
|
+
Hash2.prototype._restoreState = function(from, bytesHashed) {
|
|
9125
|
+
for (var i = 0; i < this.state.length; i++) {
|
|
9126
|
+
this.state[i] = from[i];
|
|
9127
|
+
}
|
|
9128
|
+
this.bytesHashed = bytesHashed;
|
|
9129
|
+
this.finished = false;
|
|
9130
|
+
this.bufferLength = 0;
|
|
9131
|
+
};
|
|
9132
|
+
return Hash2;
|
|
9133
|
+
}()
|
|
9134
|
+
);
|
|
9135
|
+
exports2.Hash = Hash;
|
|
9136
|
+
var HMAC = (
|
|
9137
|
+
/** @class */
|
|
9138
|
+
function() {
|
|
9139
|
+
function HMAC2(key) {
|
|
9140
|
+
this.inner = new Hash();
|
|
9141
|
+
this.outer = new Hash();
|
|
9142
|
+
this.blockSize = this.inner.blockSize;
|
|
9143
|
+
this.digestLength = this.inner.digestLength;
|
|
9144
|
+
var pad = new Uint8Array(this.blockSize);
|
|
9145
|
+
if (key.length > this.blockSize) {
|
|
9146
|
+
new Hash().update(key).finish(pad).clean();
|
|
9147
|
+
} else {
|
|
9148
|
+
for (var i = 0; i < key.length; i++) {
|
|
9149
|
+
pad[i] = key[i];
|
|
9150
|
+
}
|
|
9151
|
+
}
|
|
9152
|
+
for (var i = 0; i < pad.length; i++) {
|
|
9153
|
+
pad[i] ^= 54;
|
|
9154
|
+
}
|
|
9155
|
+
this.inner.update(pad);
|
|
9156
|
+
for (var i = 0; i < pad.length; i++) {
|
|
9157
|
+
pad[i] ^= 54 ^ 92;
|
|
9158
|
+
}
|
|
9159
|
+
this.outer.update(pad);
|
|
9160
|
+
this.istate = new Uint32Array(8);
|
|
9161
|
+
this.ostate = new Uint32Array(8);
|
|
9162
|
+
this.inner._saveState(this.istate);
|
|
9163
|
+
this.outer._saveState(this.ostate);
|
|
9164
|
+
for (var i = 0; i < pad.length; i++) {
|
|
9165
|
+
pad[i] = 0;
|
|
9166
|
+
}
|
|
9167
|
+
}
|
|
9168
|
+
HMAC2.prototype.reset = function() {
|
|
9169
|
+
this.inner._restoreState(this.istate, this.inner.blockSize);
|
|
9170
|
+
this.outer._restoreState(this.ostate, this.outer.blockSize);
|
|
9171
|
+
return this;
|
|
9172
|
+
};
|
|
9173
|
+
HMAC2.prototype.clean = function() {
|
|
9174
|
+
for (var i = 0; i < this.istate.length; i++) {
|
|
9175
|
+
this.ostate[i] = this.istate[i] = 0;
|
|
9176
|
+
}
|
|
9177
|
+
this.inner.clean();
|
|
9178
|
+
this.outer.clean();
|
|
9179
|
+
};
|
|
9180
|
+
HMAC2.prototype.update = function(data) {
|
|
9181
|
+
this.inner.update(data);
|
|
9182
|
+
return this;
|
|
9183
|
+
};
|
|
9184
|
+
HMAC2.prototype.finish = function(out) {
|
|
9185
|
+
if (this.outer.finished) {
|
|
9186
|
+
this.outer.finish(out);
|
|
9187
|
+
} else {
|
|
9188
|
+
this.inner.finish(out);
|
|
9189
|
+
this.outer.update(out, this.digestLength).finish(out);
|
|
9190
|
+
}
|
|
9191
|
+
return this;
|
|
9192
|
+
};
|
|
9193
|
+
HMAC2.prototype.digest = function() {
|
|
9194
|
+
var out = new Uint8Array(this.digestLength);
|
|
9195
|
+
this.finish(out);
|
|
9196
|
+
return out;
|
|
9197
|
+
};
|
|
9198
|
+
return HMAC2;
|
|
9199
|
+
}()
|
|
9200
|
+
);
|
|
9201
|
+
exports2.HMAC = HMAC;
|
|
9202
|
+
function hash(data) {
|
|
9203
|
+
var h = new Hash().update(data);
|
|
9204
|
+
var digest = h.digest();
|
|
9205
|
+
h.clean();
|
|
9206
|
+
return digest;
|
|
9207
|
+
}
|
|
9208
|
+
exports2.hash = hash;
|
|
9209
|
+
exports2["default"] = hash;
|
|
9210
|
+
function hmac2(key, data) {
|
|
9211
|
+
var h = new HMAC(key).update(data);
|
|
9212
|
+
var digest = h.digest();
|
|
9213
|
+
h.clean();
|
|
9214
|
+
return digest;
|
|
9215
|
+
}
|
|
9216
|
+
exports2.hmac = hmac2;
|
|
9217
|
+
function fillBuffer(buffer, hmac3, info, counter) {
|
|
9218
|
+
var num = counter[0];
|
|
9219
|
+
if (num === 0) {
|
|
9220
|
+
throw new Error("hkdf: cannot expand more");
|
|
9221
|
+
}
|
|
9222
|
+
hmac3.reset();
|
|
9223
|
+
if (num > 1) {
|
|
9224
|
+
hmac3.update(buffer);
|
|
9225
|
+
}
|
|
9226
|
+
if (info) {
|
|
9227
|
+
hmac3.update(info);
|
|
9228
|
+
}
|
|
9229
|
+
hmac3.update(counter);
|
|
9230
|
+
hmac3.finish(buffer);
|
|
9231
|
+
counter[0]++;
|
|
9232
|
+
}
|
|
9233
|
+
var hkdfSalt = new Uint8Array(exports2.digestLength);
|
|
9234
|
+
function hkdf(key, salt, info, length) {
|
|
9235
|
+
if (salt === void 0) {
|
|
9236
|
+
salt = hkdfSalt;
|
|
9237
|
+
}
|
|
9238
|
+
if (length === void 0) {
|
|
9239
|
+
length = 32;
|
|
9240
|
+
}
|
|
9241
|
+
var counter = new Uint8Array([1]);
|
|
9242
|
+
var okm = hmac2(salt, key);
|
|
9243
|
+
var hmac_ = new HMAC(okm);
|
|
9244
|
+
var buffer = new Uint8Array(hmac_.digestLength);
|
|
9245
|
+
var bufpos = buffer.length;
|
|
9246
|
+
var out = new Uint8Array(length);
|
|
9247
|
+
for (var i = 0; i < length; i++) {
|
|
9248
|
+
if (bufpos === buffer.length) {
|
|
9249
|
+
fillBuffer(buffer, hmac_, info, counter);
|
|
9250
|
+
bufpos = 0;
|
|
9251
|
+
}
|
|
9252
|
+
out[i] = buffer[bufpos++];
|
|
9253
|
+
}
|
|
9254
|
+
hmac_.clean();
|
|
9255
|
+
buffer.fill(0);
|
|
9256
|
+
counter.fill(0);
|
|
9257
|
+
return out;
|
|
9258
|
+
}
|
|
9259
|
+
exports2.hkdf = hkdf;
|
|
9260
|
+
function pbkdf2(password, salt, iterations, dkLen) {
|
|
9261
|
+
var prf = new HMAC(password);
|
|
9262
|
+
var len = prf.digestLength;
|
|
9263
|
+
var ctr = new Uint8Array(4);
|
|
9264
|
+
var t = new Uint8Array(len);
|
|
9265
|
+
var u = new Uint8Array(len);
|
|
9266
|
+
var dk = new Uint8Array(dkLen);
|
|
9267
|
+
for (var i = 0; i * len < dkLen; i++) {
|
|
9268
|
+
var c = i + 1;
|
|
9269
|
+
ctr[0] = c >>> 24 & 255;
|
|
9270
|
+
ctr[1] = c >>> 16 & 255;
|
|
9271
|
+
ctr[2] = c >>> 8 & 255;
|
|
9272
|
+
ctr[3] = c >>> 0 & 255;
|
|
9273
|
+
prf.reset();
|
|
9274
|
+
prf.update(salt);
|
|
9275
|
+
prf.update(ctr);
|
|
9276
|
+
prf.finish(u);
|
|
9277
|
+
for (var j = 0; j < len; j++) {
|
|
9278
|
+
t[j] = u[j];
|
|
9279
|
+
}
|
|
9280
|
+
for (var j = 2; j <= iterations; j++) {
|
|
9281
|
+
prf.reset();
|
|
9282
|
+
prf.update(u).finish(u);
|
|
9283
|
+
for (var k = 0; k < len; k++) {
|
|
9284
|
+
t[k] ^= u[k];
|
|
9285
|
+
}
|
|
9286
|
+
}
|
|
9287
|
+
for (var j = 0; j < len && i * len + j < dkLen; j++) {
|
|
9288
|
+
dk[i * len + j] = t[j];
|
|
9289
|
+
}
|
|
9290
|
+
}
|
|
9291
|
+
for (var i = 0; i < len; i++) {
|
|
9292
|
+
t[i] = u[i] = 0;
|
|
9293
|
+
}
|
|
9294
|
+
for (var i = 0; i < 4; i++) {
|
|
9295
|
+
ctr[i] = 0;
|
|
9296
|
+
}
|
|
9297
|
+
prf.clean();
|
|
9298
|
+
return dk;
|
|
9299
|
+
}
|
|
9300
|
+
exports2.pbkdf2 = pbkdf2;
|
|
9301
|
+
});
|
|
9302
|
+
}
|
|
9303
|
+
});
|
|
9304
|
+
|
|
9305
|
+
// src/webhook/vendor/standardwebhook.ts
|
|
9306
|
+
__toESM(require_base64());
|
|
9307
|
+
__toESM(require_sha256());
|
|
9308
|
+
/**
|
|
9309
|
+
* The MIT License
|
|
9310
|
+
*
|
|
9311
|
+
* Copyright (c) 2023 Svix (https://www.svix.com)
|
|
9312
|
+
*
|
|
9313
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9314
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9315
|
+
* in the Software without restriction, including without limitation the rights
|
|
9316
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9317
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9318
|
+
* furnished to do so, subject to the following conditions:
|
|
9319
|
+
*
|
|
9320
|
+
* The above copyright notice and this permission notice shall be included in
|
|
9321
|
+
* all copies or substantial portions of the Software.
|
|
9322
|
+
*
|
|
9323
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
9324
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
9325
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
9326
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
9327
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
9328
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
9329
|
+
* THE SOFTWARE.
|
|
9330
|
+
*
|
|
9331
|
+
* @fileoverview Server-only webhook verification implementation.
|
|
9332
|
+
* @description Vendored from standardwebhooks package to avoid bundling issues.
|
|
9333
|
+
* Uses Node.js crypto module - DO NOT import in client/browser code.
|
|
9334
|
+
* @license MIT
|
|
9335
|
+
* @internal
|
|
9336
|
+
*/
|
|
9337
|
+
|
|
9338
|
+
// src/webhook/webhook.ts
|
|
7980
9339
|
async function handleWebhookPayload(payload, config, context) {
|
|
7981
9340
|
const callHandler = (handler, payload2) => {
|
|
7982
9341
|
if (!handler) return;
|
|
@@ -8033,9 +9392,6 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
8033
9392
|
if (payload.type === "subscription.renewed") {
|
|
8034
9393
|
await callHandler(config.onSubscriptionRenewed, payload);
|
|
8035
9394
|
}
|
|
8036
|
-
if (payload.type === "subscription.paused") {
|
|
8037
|
-
await callHandler(config.onSubscriptionPaused, payload);
|
|
8038
|
-
}
|
|
8039
9395
|
if (payload.type === "subscription.plan_changed") {
|
|
8040
9396
|
await callHandler(config.onSubscriptionPlanChanged, payload);
|
|
8041
9397
|
}
|
|
@@ -8054,6 +9410,30 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
8054
9410
|
if (payload.type === "license_key.created") {
|
|
8055
9411
|
await callHandler(config.onLicenseKeyCreated, payload);
|
|
8056
9412
|
}
|
|
9413
|
+
if (payload.type === "credit.added") {
|
|
9414
|
+
await callHandler(config.onCreditAdded, payload);
|
|
9415
|
+
}
|
|
9416
|
+
if (payload.type === "credit.deducted") {
|
|
9417
|
+
await callHandler(config.onCreditDeducted, payload);
|
|
9418
|
+
}
|
|
9419
|
+
if (payload.type === "credit.expired") {
|
|
9420
|
+
await callHandler(config.onCreditExpired, payload);
|
|
9421
|
+
}
|
|
9422
|
+
if (payload.type === "credit.rolled_over") {
|
|
9423
|
+
await callHandler(config.onCreditRolledOver, payload);
|
|
9424
|
+
}
|
|
9425
|
+
if (payload.type === "credit.rollover_forfeited") {
|
|
9426
|
+
await callHandler(config.onCreditRolloverForfeited, payload);
|
|
9427
|
+
}
|
|
9428
|
+
if (payload.type === "credit.overage_charged") {
|
|
9429
|
+
await callHandler(config.onCreditOverageCharged, payload);
|
|
9430
|
+
}
|
|
9431
|
+
if (payload.type === "credit.manual_adjustment") {
|
|
9432
|
+
await callHandler(config.onCreditManualAdjustment, payload);
|
|
9433
|
+
}
|
|
9434
|
+
if (payload.type === "credit.balance_low") {
|
|
9435
|
+
await callHandler(config.onCreditBalanceLow, payload);
|
|
9436
|
+
}
|
|
8057
9437
|
}
|
|
8058
9438
|
|
|
8059
9439
|
const Webhooks = ({ webhookKey, ...eventHandlers }) => {
|