@onflay/node 0.1.1
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/README.md +87 -0
- package/dist/client.d.ts +65 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +215 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +61 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +132 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/onflay.d.ts +42 -0
- package/dist/onflay.d.ts.map +1 -0
- package/dist/onflay.js +60 -0
- package/dist/onflay.js.map +1 -0
- package/dist/pagination.d.ts +19 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +61 -0
- package/dist/pagination.js.map +1 -0
- package/dist/resources/checkout-sessions.d.ts +11 -0
- package/dist/resources/checkout-sessions.d.ts.map +1 -0
- package/dist/resources/checkout-sessions.js +20 -0
- package/dist/resources/checkout-sessions.js.map +1 -0
- package/dist/resources/customers.d.ts +17 -0
- package/dist/resources/customers.d.ts.map +1 -0
- package/dist/resources/customers.js +39 -0
- package/dist/resources/customers.js.map +1 -0
- package/dist/resources/payments.d.ts +11 -0
- package/dist/resources/payments.d.ts.map +1 -0
- package/dist/resources/payments.js +27 -0
- package/dist/resources/payments.js.map +1 -0
- package/dist/resources/prices.d.ts +24 -0
- package/dist/resources/prices.d.ts.map +1 -0
- package/dist/resources/prices.js +46 -0
- package/dist/resources/prices.js.map +1 -0
- package/dist/resources/products.d.ts +18 -0
- package/dist/resources/products.d.ts.map +1 -0
- package/dist/resources/products.js +40 -0
- package/dist/resources/products.js.map +1 -0
- package/dist/resources/subscriptions.d.ts +39 -0
- package/dist/resources/subscriptions.d.ts.map +1 -0
- package/dist/resources/subscriptions.js +62 -0
- package/dist/resources/subscriptions.js.map +1 -0
- package/dist/resources/usage.d.ts +26 -0
- package/dist/resources/usage.d.ts.map +1 -0
- package/dist/resources/usage.js +43 -0
- package/dist/resources/usage.js.map +1 -0
- package/dist/resources/webhook-endpoints.d.ts +20 -0
- package/dist/resources/webhook-endpoints.d.ts.map +1 -0
- package/dist/resources/webhook-endpoints.js +47 -0
- package/dist/resources/webhook-endpoints.js.map +1 -0
- package/dist/types/checkout-sessions.d.ts +39 -0
- package/dist/types/checkout-sessions.d.ts.map +1 -0
- package/dist/types/checkout-sessions.js +3 -0
- package/dist/types/checkout-sessions.js.map +1 -0
- package/dist/types/customers.d.ts +28 -0
- package/dist/types/customers.d.ts.map +1 -0
- package/dist/types/customers.js +3 -0
- package/dist/types/customers.js.map +1 -0
- package/dist/types/events.d.ts +55 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +23 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/payments.d.ts +25 -0
- package/dist/types/payments.d.ts.map +1 -0
- package/dist/types/payments.js +3 -0
- package/dist/types/payments.js.map +1 -0
- package/dist/types/prices.d.ts +57 -0
- package/dist/types/prices.d.ts.map +1 -0
- package/dist/types/prices.js +3 -0
- package/dist/types/prices.js.map +1 -0
- package/dist/types/products.d.ts +29 -0
- package/dist/types/products.d.ts.map +1 -0
- package/dist/types/products.js +3 -0
- package/dist/types/products.js.map +1 -0
- package/dist/types/shared.d.ts +34 -0
- package/dist/types/shared.d.ts.map +1 -0
- package/dist/types/shared.js +4 -0
- package/dist/types/shared.js.map +1 -0
- package/dist/types/subscriptions.d.ts +85 -0
- package/dist/types/subscriptions.d.ts.map +1 -0
- package/dist/types/subscriptions.js +3 -0
- package/dist/types/subscriptions.js.map +1 -0
- package/dist/types/usage.d.ts +35 -0
- package/dist/types/usage.d.ts.map +1 -0
- package/dist/types/usage.js +3 -0
- package/dist/types/usage.js.map +1 -0
- package/dist/types/webhook-endpoints.d.ts +48 -0
- package/dist/types/webhook-endpoints.d.ts.map +1 -0
- package/dist/types/webhook-endpoints.js +3 -0
- package/dist/types/webhook-endpoints.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @onflay/node
|
|
2
|
+
|
|
3
|
+
Official Node.js SDK for the [Onflay](https://onflay.com) platform — Merchant
|
|
4
|
+
of Record for LATAM. Zero runtime dependencies; built on `fetch`.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @onflay/node
|
|
10
|
+
# or
|
|
11
|
+
pnpm add @onflay/node
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Requires Node.js 20+.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { Onflay } from '@onflay/node';
|
|
20
|
+
|
|
21
|
+
const onflay = new Onflay(process.env.ONFLAY_API_KEY!);
|
|
22
|
+
|
|
23
|
+
const session = await onflay.checkoutSessions.create({
|
|
24
|
+
lineItems: [{ priceId: 'price_123', quantity: 1 }],
|
|
25
|
+
successUrl: 'https://myapp.com/success',
|
|
26
|
+
cancelUrl: 'https://myapp.com/cancel',
|
|
27
|
+
});
|
|
28
|
+
console.log(session.url);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The SDK auto-routes to the correct base URL by API key prefix:
|
|
32
|
+
|
|
33
|
+
| Key prefix | Base URL |
|
|
34
|
+
|---------------------|-------------------------------------|
|
|
35
|
+
| `sk_live_*` / `pk_live_*` | `https://api.onflay.com` |
|
|
36
|
+
| `sk_test_*` / `pk_test_*` | `https://sandbox-api.onflay.com` |
|
|
37
|
+
|
|
38
|
+
Override for staging / self-host with `new Onflay(key, { baseUrl: '...' })`.
|
|
39
|
+
|
|
40
|
+
## Resources
|
|
41
|
+
|
|
42
|
+
- `onflay.products` — `create`, `retrieve`, `update`, `list`, `listAll`
|
|
43
|
+
- `onflay.prices` — same shape; immutable price upgrade flow encouraged
|
|
44
|
+
- `onflay.checkoutSessions` — `create`, `retrieve`
|
|
45
|
+
- `onflay.payments` — `retrieve`, `list`, `listAll`
|
|
46
|
+
- `onflay.subscriptions` — `create`, `retrieve`, `update` (with proration), `cancel`, `list`
|
|
47
|
+
- `onflay.customers` — full CRUD
|
|
48
|
+
- `onflay.webhookEndpoints` — manage endpoints + browse `WebhookDelivery` history
|
|
49
|
+
|
|
50
|
+
## Idempotency
|
|
51
|
+
|
|
52
|
+
Pass `{ idempotencyKey }` to any `create` / `update` / `cancel` call. Replays
|
|
53
|
+
within 48 hours return the original response.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
await onflay.subscriptions.create(params, { idempotencyKey: 'order-42' });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Errors
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { OnflayRateLimitError, OnflayInvalidRequestError } from '@onflay/node';
|
|
63
|
+
|
|
64
|
+
try { await onflay.payments.retrieve('pay_does_not_exist'); }
|
|
65
|
+
catch (err) {
|
|
66
|
+
if (err instanceof OnflayInvalidRequestError) console.log(err.code);
|
|
67
|
+
if (err instanceof OnflayRateLimitError) console.log(err.retryAfterSeconds);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The hierarchy:
|
|
72
|
+
|
|
73
|
+
- `OnflayError`
|
|
74
|
+
- `OnflayAuthenticationError` (401, 403)
|
|
75
|
+
- `OnflayInvalidRequestError` (400, 404, 422)
|
|
76
|
+
- `OnflayIdempotencyError` (409)
|
|
77
|
+
- `OnflayRateLimitError` (429, with `retryAfterSeconds`)
|
|
78
|
+
- `OnflayApiError` (5xx)
|
|
79
|
+
- `OnflayConnectionError` (network / timeout)
|
|
80
|
+
|
|
81
|
+
## Pagination
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
for await (const product of onflay.products.listAll()) {
|
|
85
|
+
console.log(product.id);
|
|
86
|
+
}
|
|
87
|
+
```
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export declare const ONFLAY_PROD_BASE_URL = "https://api.onflay.com";
|
|
2
|
+
export declare const ONFLAY_SANDBOX_BASE_URL = "https://sandbox-api.onflay.com";
|
|
3
|
+
export interface OnflayClientOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Override the auto-resolved base URL. The SDK normally picks
|
|
6
|
+
* production vs sandbox from the API key prefix; only set this for
|
|
7
|
+
* self-hosted, staging, or otherwise non-standard environments.
|
|
8
|
+
*/
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Optional HTTP timeout in milliseconds. `0` disables the timeout.
|
|
12
|
+
* Defaults to 30 seconds.
|
|
13
|
+
*/
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Maximum retry attempts on `429` and `5xx`. Defaults to `3`.
|
|
17
|
+
* Set to `0` to disable.
|
|
18
|
+
*/
|
|
19
|
+
maxRetries?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Custom `fetch` implementation. Defaults to globalThis.fetch.
|
|
22
|
+
* Mostly useful for tests and non-standard runtimes.
|
|
23
|
+
*/
|
|
24
|
+
fetch?: typeof fetch;
|
|
25
|
+
/**
|
|
26
|
+
* Optional pre-resolved `User-Agent` suffix appended after the SDK
|
|
27
|
+
* banner. Helpful for Onflay-hosted middleware (e.g. CLI) that wants
|
|
28
|
+
* to surface its own version.
|
|
29
|
+
*/
|
|
30
|
+
userAgentSuffix?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface RequestOptions {
|
|
33
|
+
/** JSON-serializable body. Skip for query-only / GET requests. */
|
|
34
|
+
body?: unknown;
|
|
35
|
+
/** Query params merged into the URL. */
|
|
36
|
+
query?: Record<string, string | number | boolean | undefined | null>;
|
|
37
|
+
/** Idempotency-Key header value. */
|
|
38
|
+
idempotencyKey?: string;
|
|
39
|
+
/** Per-request maxRetries override. */
|
|
40
|
+
maxRetries?: number;
|
|
41
|
+
/** Per-request timeout override. */
|
|
42
|
+
timeoutMs?: number;
|
|
43
|
+
/** Extra headers to attach to the request. */
|
|
44
|
+
headers?: Record<string, string>;
|
|
45
|
+
/** Optional cancellation. */
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
export declare function resolveBaseUrlFromKey(apiKey: string, override?: string): string;
|
|
49
|
+
export declare class OnflayClient {
|
|
50
|
+
readonly apiKey: string;
|
|
51
|
+
readonly baseUrl: string;
|
|
52
|
+
readonly timeoutMs: number;
|
|
53
|
+
readonly maxRetries: number;
|
|
54
|
+
private readonly fetchImpl;
|
|
55
|
+
private readonly userAgent;
|
|
56
|
+
constructor(apiKey: string, options?: OnflayClientOptions);
|
|
57
|
+
/** Returns `'sandbox'` when the key prefix targets the test plane. */
|
|
58
|
+
get environment(): 'production' | 'sandbox';
|
|
59
|
+
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
60
|
+
private executeRequest;
|
|
61
|
+
private buildHeaders;
|
|
62
|
+
private buildUrl;
|
|
63
|
+
private calculateBackoff;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAC7D,eAAO,MAAM,uBAAuB,mCAAmC,CAAC;AAKxE,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1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,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnflayClient = exports.ONFLAY_SANDBOX_BASE_URL = exports.ONFLAY_PROD_BASE_URL = void 0;
|
|
4
|
+
exports.resolveBaseUrlFromKey = resolveBaseUrlFromKey;
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
const version_1 = require("./version");
|
|
7
|
+
exports.ONFLAY_PROD_BASE_URL = 'https://api.onflay.com';
|
|
8
|
+
exports.ONFLAY_SANDBOX_BASE_URL = 'https://sandbox-api.onflay.com';
|
|
9
|
+
const TEST_KEY_PREFIXES = ['sk_test_', 'pk_test_'];
|
|
10
|
+
const LIVE_KEY_PREFIXES = ['sk_live_', 'pk_live_'];
|
|
11
|
+
function resolveBaseUrlFromKey(apiKey, override) {
|
|
12
|
+
if (override && override.length > 0)
|
|
13
|
+
return override.replace(/\/+$/, '');
|
|
14
|
+
for (const p of TEST_KEY_PREFIXES) {
|
|
15
|
+
if (apiKey.startsWith(p))
|
|
16
|
+
return exports.ONFLAY_SANDBOX_BASE_URL;
|
|
17
|
+
}
|
|
18
|
+
for (const p of LIVE_KEY_PREFIXES) {
|
|
19
|
+
if (apiKey.startsWith(p))
|
|
20
|
+
return exports.ONFLAY_PROD_BASE_URL;
|
|
21
|
+
}
|
|
22
|
+
return exports.ONFLAY_PROD_BASE_URL;
|
|
23
|
+
}
|
|
24
|
+
class OnflayClient {
|
|
25
|
+
apiKey;
|
|
26
|
+
baseUrl;
|
|
27
|
+
timeoutMs;
|
|
28
|
+
maxRetries;
|
|
29
|
+
fetchImpl;
|
|
30
|
+
userAgent;
|
|
31
|
+
constructor(apiKey, options = {}) {
|
|
32
|
+
if (!apiKey || typeof apiKey !== 'string') {
|
|
33
|
+
throw new Error('Onflay: API key must be a non-empty string');
|
|
34
|
+
}
|
|
35
|
+
this.apiKey = apiKey;
|
|
36
|
+
this.baseUrl = resolveBaseUrlFromKey(apiKey, options.baseUrl);
|
|
37
|
+
this.timeoutMs = options.timeoutMs ?? 30_000;
|
|
38
|
+
this.maxRetries = options.maxRetries ?? 3;
|
|
39
|
+
const resolvedFetch = options.fetch ?? globalThis.fetch;
|
|
40
|
+
if (!resolvedFetch) {
|
|
41
|
+
throw new Error('Onflay: global fetch is not available. Use Node 20+ or pass options.fetch.');
|
|
42
|
+
}
|
|
43
|
+
this.fetchImpl = resolvedFetch;
|
|
44
|
+
this.userAgent = options.userAgentSuffix
|
|
45
|
+
? `${version_1.SDK_USER_AGENT} ${options.userAgentSuffix}`
|
|
46
|
+
: version_1.SDK_USER_AGENT;
|
|
47
|
+
}
|
|
48
|
+
/** Returns `'sandbox'` when the key prefix targets the test plane. */
|
|
49
|
+
get environment() {
|
|
50
|
+
if (TEST_KEY_PREFIXES.some((p) => this.apiKey.startsWith(p))) {
|
|
51
|
+
return 'sandbox';
|
|
52
|
+
}
|
|
53
|
+
return 'production';
|
|
54
|
+
}
|
|
55
|
+
async request(method, path, options = {}) {
|
|
56
|
+
const url = this.buildUrl(path, options.query);
|
|
57
|
+
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
58
|
+
const timeoutMs = options.timeoutMs ?? this.timeoutMs;
|
|
59
|
+
let lastError;
|
|
60
|
+
let lastRetryAfterSeconds;
|
|
61
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
62
|
+
if (attempt > 0) {
|
|
63
|
+
await sleep(this.calculateBackoff(attempt, lastRetryAfterSeconds));
|
|
64
|
+
lastRetryAfterSeconds = undefined;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const response = await this.executeRequest(method, url, options, timeoutMs);
|
|
68
|
+
if (response.status === 429 || response.status >= 500) {
|
|
69
|
+
lastError = await errors_1.OnflayError.fromResponse(response);
|
|
70
|
+
const ra = response.headers.get('retry-after');
|
|
71
|
+
if (ra) {
|
|
72
|
+
const parsed = parseRetryAfter(ra);
|
|
73
|
+
if (parsed !== undefined)
|
|
74
|
+
lastRetryAfterSeconds = parsed;
|
|
75
|
+
}
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
throw await errors_1.OnflayError.fromResponse(response);
|
|
80
|
+
}
|
|
81
|
+
return (await parseJsonSafe(response));
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
if (err instanceof errors_1.OnflayError) {
|
|
85
|
+
if (err.statusCode === 429 || (err.statusCode ?? 0) >= 500) {
|
|
86
|
+
lastError = err;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
if (isAbortError(err)) {
|
|
92
|
+
throw new errors_1.OnflayConnectionError({
|
|
93
|
+
message: `Request timed out after ${timeoutMs}ms`,
|
|
94
|
+
code: 'request_timeout',
|
|
95
|
+
cause: err,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
lastError = new errors_1.OnflayConnectionError({
|
|
99
|
+
message: err instanceof Error ? err.message : 'Network error',
|
|
100
|
+
code: 'connection_error',
|
|
101
|
+
cause: err,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
throw (lastError ??
|
|
106
|
+
new errors_1.OnflayConnectionError({
|
|
107
|
+
message: 'Request failed after retries',
|
|
108
|
+
code: 'connection_error',
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
async executeRequest(method, url, options, timeoutMs) {
|
|
112
|
+
const controller = new AbortController();
|
|
113
|
+
const userSignal = options.signal;
|
|
114
|
+
const onAbort = () => controller.abort(userSignal?.reason);
|
|
115
|
+
if (userSignal) {
|
|
116
|
+
if (userSignal.aborted)
|
|
117
|
+
controller.abort(userSignal.reason);
|
|
118
|
+
else
|
|
119
|
+
userSignal.addEventListener('abort', onAbort, { once: true });
|
|
120
|
+
}
|
|
121
|
+
const timer = timeoutMs > 0
|
|
122
|
+
? setTimeout(() => controller.abort(new Error('Request timed out')), timeoutMs)
|
|
123
|
+
: null;
|
|
124
|
+
try {
|
|
125
|
+
const headers = this.buildHeaders(options);
|
|
126
|
+
const response = await this.fetchImpl(url, {
|
|
127
|
+
method,
|
|
128
|
+
headers,
|
|
129
|
+
body: options.body !== undefined ? JSON.stringify(options.body) : undefined,
|
|
130
|
+
signal: controller.signal,
|
|
131
|
+
});
|
|
132
|
+
return response;
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
if (timer)
|
|
136
|
+
clearTimeout(timer);
|
|
137
|
+
if (userSignal)
|
|
138
|
+
userSignal.removeEventListener('abort', onAbort);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
buildHeaders(options) {
|
|
142
|
+
const headers = {
|
|
143
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
144
|
+
'Content-Type': 'application/json',
|
|
145
|
+
Accept: 'application/json',
|
|
146
|
+
'User-Agent': this.userAgent,
|
|
147
|
+
'X-Onflay-Sdk-Version': version_1.SDK_VERSION,
|
|
148
|
+
'X-Onflay-Api-Version': version_1.ONFLAY_API_VERSION,
|
|
149
|
+
};
|
|
150
|
+
if (options.idempotencyKey) {
|
|
151
|
+
headers['Idempotency-Key'] = options.idempotencyKey;
|
|
152
|
+
}
|
|
153
|
+
if (options.headers) {
|
|
154
|
+
for (const [key, value] of Object.entries(options.headers)) {
|
|
155
|
+
if (value !== undefined && value !== null)
|
|
156
|
+
headers[key] = value;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return headers;
|
|
160
|
+
}
|
|
161
|
+
buildUrl(path, query) {
|
|
162
|
+
const cleaned = path.startsWith('/') ? path : `/${path}`;
|
|
163
|
+
const base = `${this.baseUrl}${cleaned}`;
|
|
164
|
+
if (!query)
|
|
165
|
+
return base;
|
|
166
|
+
const search = new URLSearchParams();
|
|
167
|
+
for (const [key, value] of Object.entries(query)) {
|
|
168
|
+
if (value === undefined || value === null)
|
|
169
|
+
continue;
|
|
170
|
+
search.append(key, String(value));
|
|
171
|
+
}
|
|
172
|
+
const qs = search.toString();
|
|
173
|
+
return qs.length > 0 ? `${base}?${qs}` : base;
|
|
174
|
+
}
|
|
175
|
+
calculateBackoff(attempt, retryAfterSeconds) {
|
|
176
|
+
if (retryAfterSeconds && retryAfterSeconds > 0) {
|
|
177
|
+
return Math.min(retryAfterSeconds * 1000, 30_000);
|
|
178
|
+
}
|
|
179
|
+
const exp = 250 * Math.pow(2, attempt - 1);
|
|
180
|
+
const jitter = Math.random() * 200;
|
|
181
|
+
return Math.min(exp + jitter, 30_000);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.OnflayClient = OnflayClient;
|
|
185
|
+
function sleep(ms) {
|
|
186
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
187
|
+
}
|
|
188
|
+
function parseRetryAfter(value) {
|
|
189
|
+
const numeric = Number(value);
|
|
190
|
+
if (Number.isFinite(numeric) && numeric >= 0)
|
|
191
|
+
return numeric;
|
|
192
|
+
const date = Date.parse(value);
|
|
193
|
+
if (!Number.isNaN(date)) {
|
|
194
|
+
return Math.max(0, Math.ceil((date - Date.now()) / 1000));
|
|
195
|
+
}
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
async function parseJsonSafe(response) {
|
|
199
|
+
if (response.status === 204)
|
|
200
|
+
return undefined;
|
|
201
|
+
const text = await response.text();
|
|
202
|
+
if (text.length === 0)
|
|
203
|
+
return undefined;
|
|
204
|
+
try {
|
|
205
|
+
return JSON.parse(text);
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return text;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function isAbortError(err) {
|
|
212
|
+
return (err instanceof Error &&
|
|
213
|
+
(err.name === 'AbortError' || /aborted|timed? ?out/i.test(err.message)));
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":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dist/errors.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error hierarchy returned by the Onflay SDK. Mirrors the `error.type`
|
|
3
|
+
* discriminator on the API's error envelope so consumers can branch on
|
|
4
|
+
* concrete classes (`instanceof OnflayRateLimitError`) instead of string
|
|
5
|
+
* compares.
|
|
6
|
+
*/
|
|
7
|
+
export type OnflayErrorType = 'authentication_error' | 'invalid_request' | 'api_error' | 'rate_limit_error' | 'idempotency_error' | 'connection_error';
|
|
8
|
+
export interface OnflayErrorBody {
|
|
9
|
+
error?: {
|
|
10
|
+
type?: string;
|
|
11
|
+
code?: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
param?: string;
|
|
14
|
+
requestId?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface OnflayErrorOptions {
|
|
18
|
+
message: string;
|
|
19
|
+
type: OnflayErrorType;
|
|
20
|
+
code?: string;
|
|
21
|
+
statusCode?: number;
|
|
22
|
+
requestId?: string;
|
|
23
|
+
param?: string;
|
|
24
|
+
cause?: unknown;
|
|
25
|
+
}
|
|
26
|
+
export declare class OnflayError extends Error {
|
|
27
|
+
readonly type: OnflayErrorType;
|
|
28
|
+
readonly code: string;
|
|
29
|
+
readonly statusCode?: number;
|
|
30
|
+
readonly requestId?: string;
|
|
31
|
+
readonly param?: string;
|
|
32
|
+
constructor(options: OnflayErrorOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Construct the appropriate `OnflayError` subclass from a non-2xx HTTP
|
|
35
|
+
* response. Reads the API's structured error envelope when available and
|
|
36
|
+
* falls back to a generic message otherwise.
|
|
37
|
+
*/
|
|
38
|
+
static fromResponse(response: Response): Promise<OnflayError>;
|
|
39
|
+
}
|
|
40
|
+
export declare class OnflayAuthenticationError extends OnflayError {
|
|
41
|
+
constructor(opts: Omit<OnflayErrorOptions, 'type'>);
|
|
42
|
+
}
|
|
43
|
+
export declare class OnflayInvalidRequestError extends OnflayError {
|
|
44
|
+
constructor(opts: Omit<OnflayErrorOptions, 'type'>);
|
|
45
|
+
}
|
|
46
|
+
export declare class OnflayRateLimitError extends OnflayError {
|
|
47
|
+
readonly retryAfterSeconds?: number;
|
|
48
|
+
constructor(opts: Omit<OnflayErrorOptions, 'type'> & {
|
|
49
|
+
retryAfterSeconds?: number;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export declare class OnflayApiError extends OnflayError {
|
|
53
|
+
constructor(opts: Omit<OnflayErrorOptions, 'type'>);
|
|
54
|
+
}
|
|
55
|
+
export declare class OnflayIdempotencyError extends OnflayError {
|
|
56
|
+
constructor(opts: Omit<OnflayErrorOptions, 'type'>);
|
|
57
|
+
}
|
|
58
|
+
export declare class OnflayConnectionError extends OnflayError {
|
|
59
|
+
constructor(opts: Omit<OnflayErrorOptions, 'type'>);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,eAAe,GACvB,sBAAsB,GACtB,iBAAiB,GACjB,WAAW,GACX,kBAAkB,GAClB,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;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by the Onflay SDK. Mirrors the `error.type`
|
|
4
|
+
* discriminator on the API's error envelope so consumers can branch on
|
|
5
|
+
* concrete classes (`instanceof OnflayRateLimitError`) instead of string
|
|
6
|
+
* compares.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.OnflayConnectionError = exports.OnflayIdempotencyError = exports.OnflayApiError = exports.OnflayRateLimitError = exports.OnflayInvalidRequestError = exports.OnflayAuthenticationError = exports.OnflayError = void 0;
|
|
10
|
+
class OnflayError extends Error {
|
|
11
|
+
type;
|
|
12
|
+
code;
|
|
13
|
+
statusCode;
|
|
14
|
+
requestId;
|
|
15
|
+
param;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super(options.message);
|
|
18
|
+
this.name = new.target.name;
|
|
19
|
+
this.type = options.type;
|
|
20
|
+
this.code = options.code ?? 'unknown_error';
|
|
21
|
+
if (options.statusCode !== undefined)
|
|
22
|
+
this.statusCode = options.statusCode;
|
|
23
|
+
if (options.requestId !== undefined)
|
|
24
|
+
this.requestId = options.requestId;
|
|
25
|
+
if (options.param !== undefined)
|
|
26
|
+
this.param = options.param;
|
|
27
|
+
if (options.cause !== undefined) {
|
|
28
|
+
Object.defineProperty(this, 'cause', {
|
|
29
|
+
value: options.cause,
|
|
30
|
+
enumerable: false,
|
|
31
|
+
writable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Construct the appropriate `OnflayError` subclass from a non-2xx HTTP
|
|
39
|
+
* response. Reads the API's structured error envelope when available and
|
|
40
|
+
* falls back to a generic message otherwise.
|
|
41
|
+
*/
|
|
42
|
+
static async fromResponse(response) {
|
|
43
|
+
const requestId = response.headers.get('x-request-id') ??
|
|
44
|
+
response.headers.get('request-id') ??
|
|
45
|
+
undefined;
|
|
46
|
+
let body = null;
|
|
47
|
+
let rawText;
|
|
48
|
+
try {
|
|
49
|
+
const text = await response.text();
|
|
50
|
+
rawText = text;
|
|
51
|
+
if (text.length > 0) {
|
|
52
|
+
body = JSON.parse(text);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
body = null;
|
|
57
|
+
}
|
|
58
|
+
const errBody = body?.error ?? {};
|
|
59
|
+
const message = errBody.message ??
|
|
60
|
+
rawText ??
|
|
61
|
+
`Onflay API error (HTTP ${response.status})`;
|
|
62
|
+
const baseOptions = {
|
|
63
|
+
message,
|
|
64
|
+
type: errBody.type ?? 'api_error',
|
|
65
|
+
code: errBody.code ?? `http_${response.status}`,
|
|
66
|
+
statusCode: response.status,
|
|
67
|
+
...(errBody.requestId ?? requestId
|
|
68
|
+
? { requestId: errBody.requestId ?? requestId }
|
|
69
|
+
: {}),
|
|
70
|
+
...(errBody.param !== undefined ? { param: errBody.param } : {}),
|
|
71
|
+
};
|
|
72
|
+
return classifyError(baseOptions);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.OnflayError = OnflayError;
|
|
76
|
+
class OnflayAuthenticationError extends OnflayError {
|
|
77
|
+
constructor(opts) {
|
|
78
|
+
super({ ...opts, type: 'authentication_error' });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.OnflayAuthenticationError = OnflayAuthenticationError;
|
|
82
|
+
class OnflayInvalidRequestError extends OnflayError {
|
|
83
|
+
constructor(opts) {
|
|
84
|
+
super({ ...opts, type: 'invalid_request' });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.OnflayInvalidRequestError = OnflayInvalidRequestError;
|
|
88
|
+
class OnflayRateLimitError extends OnflayError {
|
|
89
|
+
retryAfterSeconds;
|
|
90
|
+
constructor(opts) {
|
|
91
|
+
super({ ...opts, type: 'rate_limit_error' });
|
|
92
|
+
if (opts.retryAfterSeconds !== undefined) {
|
|
93
|
+
this.retryAfterSeconds = opts.retryAfterSeconds;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.OnflayRateLimitError = OnflayRateLimitError;
|
|
98
|
+
class OnflayApiError extends OnflayError {
|
|
99
|
+
constructor(opts) {
|
|
100
|
+
super({ ...opts, type: 'api_error' });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.OnflayApiError = OnflayApiError;
|
|
104
|
+
class OnflayIdempotencyError extends OnflayError {
|
|
105
|
+
constructor(opts) {
|
|
106
|
+
super({ ...opts, type: 'idempotency_error' });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.OnflayIdempotencyError = OnflayIdempotencyError;
|
|
110
|
+
class OnflayConnectionError extends OnflayError {
|
|
111
|
+
constructor(opts) {
|
|
112
|
+
super({ ...opts, type: 'connection_error' });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.OnflayConnectionError = OnflayConnectionError;
|
|
116
|
+
function classifyError(options) {
|
|
117
|
+
const status = options.statusCode ?? 0;
|
|
118
|
+
if (status === 401 || status === 403) {
|
|
119
|
+
return new OnflayAuthenticationError(options);
|
|
120
|
+
}
|
|
121
|
+
if (status === 409) {
|
|
122
|
+
return new OnflayIdempotencyError(options);
|
|
123
|
+
}
|
|
124
|
+
if (status === 429) {
|
|
125
|
+
return new OnflayRateLimitError(options);
|
|
126
|
+
}
|
|
127
|
+
if (status >= 400 && status < 500) {
|
|
128
|
+
return new OnflayInvalidRequestError(options);
|
|
129
|
+
}
|
|
130
|
+
return new OnflayApiError(options);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA8BH,MAAa,WAAY,SAAQ,KAAK;IACpB,IAAI,CAAkB;IACtB,IAAI,CAAS;IACb,UAAU,CAAU;IACpB,SAAS,CAAU;IACnB,KAAK,CAAU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AAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;QAClC,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { Onflay } from './onflay';
|
|
2
|
+
export { OnflayClient, ONFLAY_PROD_BASE_URL, ONFLAY_SANDBOX_BASE_URL, resolveBaseUrlFromKey, } from './client';
|
|
3
|
+
export type { OnflayClientOptions, RequestOptions } from './client';
|
|
4
|
+
export { OnflayError, OnflayApiError, OnflayAuthenticationError, OnflayConnectionError, OnflayIdempotencyError, OnflayInvalidRequestError, OnflayRateLimitError, } from './errors';
|
|
5
|
+
export type { OnflayErrorOptions, OnflayErrorType } from './errors';
|
|
6
|
+
export { SDK_VERSION, SDK_USER_AGENT, ONFLAY_API_VERSION } from './version';
|
|
7
|
+
export { ProductsResource } from './resources/products';
|
|
8
|
+
export { PricesResource } from './resources/prices';
|
|
9
|
+
export { CheckoutSessionsResource } from './resources/checkout-sessions';
|
|
10
|
+
export { PaymentsResource } from './resources/payments';
|
|
11
|
+
export { SubscriptionsResource } from './resources/subscriptions';
|
|
12
|
+
export { CustomersResource } from './resources/customers';
|
|
13
|
+
export { UsageResource } from './resources/usage';
|
|
14
|
+
export { WebhookEndpointsResource } from './resources/webhook-endpoints';
|
|
15
|
+
export type { CreateProductParams, ListProductsParams, OnflayProduct, UpdateProductParams, } from './types/products';
|
|
16
|
+
export type { BillingScheme, CreatePriceParams, ListPricesParams, OnflayPrice, PriceTierConfig, RecurringConfig, RecurringInterval, TiersMode, UpdatePriceParams, } from './types/prices';
|
|
17
|
+
export type { CheckoutLineItem, CreateCheckoutSessionParams, OnflayCheckoutSession, } from './types/checkout-sessions';
|
|
18
|
+
export type { ListPaymentsParams, OnflayPayment, PaymentStatus, } from './types/payments';
|
|
19
|
+
export type { CancelSubscriptionParams, CreateSubscriptionParams, ListSubscriptionsParams, OnflaySubscription, ProrationBehavior, SubscriptionItem, SubscriptionStatus, UpdateSubscriptionParams, } from './types/subscriptions';
|
|
20
|
+
export type { CreateCustomerParams, ListCustomersParams, OnflayCustomer, UpdateCustomerParams, } from './types/customers';
|
|
21
|
+
export type { CreateMeterParams, MeterAggregation, OnflayMeter, ReportUsageParams, ReportUsageResponse, } from './types/usage';
|
|
22
|
+
export type { CreatedOnflayWebhookEndpoint, CreateWebhookEndpointParams, ListWebhookDeliveriesParams, OnflayWebhookDelivery, OnflayWebhookEndpoint, UpdateWebhookEndpointParams, } from './types/webhook-endpoints';
|
|
23
|
+
export type { ListIterator, OnflayMetadata, PageMeta, PaginatedList, PaginationParams, } from './types/shared';
|
|
24
|
+
export type { DisputeEventData, OnflayEvent, OnflayEventType, OnflayWebhookEnvelope, PaymentEventData, PayoutEventData, SubscriptionEventData, } from './types/events';
|
|
25
|
+
export { ONFLAY_EVENT_TYPES } from './types/events';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,WAAW,EACX,cAAc,EACd,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACpE,OAA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