@onflay/node 0.3.0 → 1.0.0-staging-20261206080029
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/CHANGELOG.md +74 -0
- package/README.md +211 -48
- package/dist/chunk-4RUPPDC2.mjs +121 -0
- package/dist/chunk-4RUPPDC2.mjs.map +1 -0
- package/dist/chunk-63KSRMJG.mjs +47 -0
- package/dist/chunk-63KSRMJG.mjs.map +1 -0
- package/dist/chunk-7LYAEZCT.mjs +197 -0
- package/dist/chunk-7LYAEZCT.mjs.map +1 -0
- package/dist/chunk-A3TRCKHK.mjs +60 -0
- package/dist/chunk-A3TRCKHK.mjs.map +1 -0
- package/dist/chunk-AFAU2FH2.js +47 -0
- package/dist/chunk-AFAU2FH2.js.map +1 -0
- package/dist/chunk-DBE2YZWE.mjs +38 -0
- package/dist/chunk-DBE2YZWE.mjs.map +1 -0
- package/dist/chunk-EOHFYWFQ.mjs +154 -0
- package/dist/chunk-EOHFYWFQ.mjs.map +1 -0
- package/dist/chunk-I2IVHBFA.js +197 -0
- package/dist/chunk-I2IVHBFA.js.map +1 -0
- package/dist/chunk-J4MYKTPN.mjs +37 -0
- package/dist/chunk-J4MYKTPN.mjs.map +1 -0
- package/dist/chunk-JQPANXLV.mjs +37 -0
- package/dist/chunk-JQPANXLV.mjs.map +1 -0
- package/dist/chunk-JXP6V2P2.mjs +1057 -0
- package/dist/chunk-JXP6V2P2.mjs.map +1 -0
- package/dist/chunk-M52GW7GQ.js +1057 -0
- package/dist/chunk-M52GW7GQ.js.map +1 -0
- package/dist/chunk-MMMUKAI6.js +37 -0
- package/dist/chunk-MMMUKAI6.js.map +1 -0
- package/dist/chunk-NSR4UQLV.js +87 -0
- package/dist/chunk-NSR4UQLV.js.map +1 -0
- package/dist/chunk-SUONZUVK.js +154 -0
- package/dist/chunk-SUONZUVK.js.map +1 -0
- package/dist/chunk-T26CPULH.js +121 -0
- package/dist/chunk-T26CPULH.js.map +1 -0
- package/dist/chunk-V2XJ4GZU.js +38 -0
- package/dist/chunk-V2XJ4GZU.js.map +1 -0
- package/dist/chunk-W6AEPYUG.js +37 -0
- package/dist/chunk-W6AEPYUG.js.map +1 -0
- package/dist/chunk-YHQ7XIC6.js +60 -0
- package/dist/chunk-YHQ7XIC6.js.map +1 -0
- package/dist/chunk-YSXUZYUY.mjs +87 -0
- package/dist/chunk-YSXUZYUY.mjs.map +1 -0
- package/dist/index-C1KFW_9r.d.mts +3989 -0
- package/dist/index-C1KFW_9r.d.ts +3989 -0
- package/dist/index.d.mts +918 -0
- package/dist/index.d.ts +918 -29
- package/dist/index.js +2990 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2991 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/config.d.mts +59 -0
- package/dist/lib/config.d.ts +59 -0
- package/dist/lib/config.js +15 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/config.mjs +15 -0
- package/dist/lib/config.mjs.map +1 -0
- package/dist/lib/http.d.mts +51 -0
- package/dist/lib/http.d.ts +51 -0
- package/dist/lib/http.js +13 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/http.mjs +13 -0
- package/dist/lib/http.mjs.map +1 -0
- package/dist/lib/retries.d.mts +41 -0
- package/dist/lib/retries.d.ts +41 -0
- package/dist/lib/retries.js +16 -0
- package/dist/lib/retries.js.map +1 -0
- package/dist/lib/retries.mjs +16 -0
- package/dist/lib/retries.mjs.map +1 -0
- package/dist/lib/sdks.d.mts +61 -0
- package/dist/lib/sdks.d.ts +61 -0
- package/dist/lib/sdks.js +12 -0
- package/dist/lib/sdks.js.map +1 -0
- package/dist/lib/sdks.mjs +12 -0
- package/dist/lib/sdks.mjs.map +1 -0
- package/dist/models/components/index.d.mts +1 -0
- package/dist/models/components/index.d.ts +1 -0
- package/dist/models/components/index.js +1 -0
- package/dist/models/components/index.js.map +1 -0
- package/dist/models/components/index.mjs +1 -0
- package/dist/models/components/index.mjs.map +1 -0
- package/dist/models/errors/index.d.mts +161 -0
- package/dist/models/errors/index.d.ts +161 -0
- package/dist/models/errors/index.js +29 -0
- package/dist/models/errors/index.js.map +1 -0
- package/dist/models/errors/index.mjs +29 -0
- package/dist/models/errors/index.mjs.map +1 -0
- package/dist/models/operations/index.d.mts +769 -0
- package/dist/models/operations/index.d.ts +769 -0
- package/dist/models/operations/index.js +1 -0
- package/dist/models/operations/index.js.map +1 -0
- package/dist/models/operations/index.mjs +1 -0
- package/dist/models/operations/index.mjs.map +1 -0
- package/dist/types/index.d.mts +26 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/verify-tF2BsJK6.d.mts +325 -0
- package/dist/verify-tF2BsJK6.d.ts +325 -0
- package/dist/webhooks/express.d.mts +39 -0
- package/dist/webhooks/express.d.ts +39 -0
- package/dist/webhooks/express.js +10 -0
- package/dist/webhooks/express.js.map +1 -0
- package/dist/webhooks/express.mjs +10 -0
- package/dist/webhooks/express.mjs.map +1 -0
- package/dist/webhooks/hono.d.mts +33 -0
- package/dist/webhooks/hono.d.ts +33 -0
- package/dist/webhooks/hono.js +10 -0
- package/dist/webhooks/hono.js.map +1 -0
- package/dist/webhooks/hono.mjs +10 -0
- package/dist/webhooks/hono.mjs.map +1 -0
- package/dist/webhooks/index.d.mts +34 -0
- package/dist/webhooks/index.d.ts +34 -0
- package/dist/webhooks/index.js +75 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/index.mjs +75 -0
- package/dist/webhooks/index.mjs.map +1 -0
- package/dist/webhooks/next.d.mts +38 -0
- package/dist/webhooks/next.d.ts +38 -0
- package/dist/webhooks/next.js +10 -0
- package/dist/webhooks/next.js.map +1 -0
- package/dist/webhooks/next.mjs +10 -0
- package/dist/webhooks/next.mjs.map +1 -0
- package/package.json +273 -14
- package/dist/client.d.ts +0 -65
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -216
- package/dist/client.js.map +0 -1
- package/dist/errors.d.ts +0 -61
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -134
- package/dist/errors.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/onflay.d.ts +0 -44
- package/dist/onflay.d.ts.map +0 -1
- package/dist/onflay.js +0 -63
- package/dist/onflay.js.map +0 -1
- package/dist/pagination.d.ts +0 -19
- package/dist/pagination.d.ts.map +0 -1
- package/dist/pagination.js +0 -61
- package/dist/pagination.js.map +0 -1
- package/dist/resources/checkout-sessions.d.ts +0 -11
- package/dist/resources/checkout-sessions.d.ts.map +0 -1
- package/dist/resources/checkout-sessions.js +0 -20
- package/dist/resources/checkout-sessions.js.map +0 -1
- package/dist/resources/customers.d.ts +0 -17
- package/dist/resources/customers.d.ts.map +0 -1
- package/dist/resources/customers.js +0 -39
- package/dist/resources/customers.js.map +0 -1
- package/dist/resources/invoices.d.ts +0 -60
- package/dist/resources/invoices.d.ts.map +0 -1
- package/dist/resources/invoices.js +0 -69
- package/dist/resources/invoices.js.map +0 -1
- package/dist/resources/payments.d.ts +0 -11
- package/dist/resources/payments.d.ts.map +0 -1
- package/dist/resources/payments.js +0 -27
- package/dist/resources/payments.js.map +0 -1
- package/dist/resources/prices.d.ts +0 -24
- package/dist/resources/prices.d.ts.map +0 -1
- package/dist/resources/prices.js +0 -46
- package/dist/resources/prices.js.map +0 -1
- package/dist/resources/products.d.ts +0 -18
- package/dist/resources/products.d.ts.map +0 -1
- package/dist/resources/products.js +0 -40
- package/dist/resources/products.js.map +0 -1
- package/dist/resources/subscriptions.d.ts +0 -39
- package/dist/resources/subscriptions.d.ts.map +0 -1
- package/dist/resources/subscriptions.js +0 -62
- package/dist/resources/subscriptions.js.map +0 -1
- package/dist/resources/usage.d.ts +0 -26
- package/dist/resources/usage.d.ts.map +0 -1
- package/dist/resources/usage.js +0 -43
- package/dist/resources/usage.js.map +0 -1
- package/dist/resources/webhook-endpoints.d.ts +0 -20
- package/dist/resources/webhook-endpoints.d.ts.map +0 -1
- package/dist/resources/webhook-endpoints.js +0 -47
- package/dist/resources/webhook-endpoints.js.map +0 -1
- package/dist/types/checkout-sessions.d.ts +0 -67
- package/dist/types/checkout-sessions.d.ts.map +0 -1
- package/dist/types/checkout-sessions.js +0 -3
- package/dist/types/checkout-sessions.js.map +0 -1
- package/dist/types/customers.d.ts +0 -28
- package/dist/types/customers.d.ts.map +0 -1
- package/dist/types/customers.js +0 -3
- package/dist/types/customers.js.map +0 -1
- package/dist/types/events.d.ts +0 -118
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/events.js +0 -28
- package/dist/types/events.js.map +0 -1
- package/dist/types/invoices.d.ts +0 -65
- package/dist/types/invoices.d.ts.map +0 -1
- package/dist/types/invoices.js +0 -3
- package/dist/types/invoices.js.map +0 -1
- package/dist/types/payments.d.ts +0 -25
- package/dist/types/payments.d.ts.map +0 -1
- package/dist/types/payments.js +0 -3
- package/dist/types/payments.js.map +0 -1
- package/dist/types/prices.d.ts +0 -57
- package/dist/types/prices.d.ts.map +0 -1
- package/dist/types/prices.js +0 -3
- package/dist/types/prices.js.map +0 -1
- package/dist/types/products.d.ts +0 -29
- package/dist/types/products.d.ts.map +0 -1
- package/dist/types/products.js +0 -3
- package/dist/types/products.js.map +0 -1
- package/dist/types/shared.d.ts +0 -34
- package/dist/types/shared.d.ts.map +0 -1
- package/dist/types/shared.js +0 -4
- package/dist/types/shared.js.map +0 -1
- package/dist/types/subscriptions.d.ts +0 -85
- package/dist/types/subscriptions.d.ts.map +0 -1
- package/dist/types/subscriptions.js +0 -3
- package/dist/types/subscriptions.js.map +0 -1
- package/dist/types/usage.d.ts +0 -35
- package/dist/types/usage.d.ts.map +0 -1
- package/dist/types/usage.js +0 -3
- package/dist/types/usage.js.map +0 -1
- package/dist/types/webhook-endpoints.d.ts +0 -48
- package/dist/types/webhook-endpoints.d.ts.map +0 -1
- package/dist/types/webhook-endpoints.js +0 -3
- package/dist/types/webhook-endpoints.js.map +0 -1
- package/dist/version.d.ts +0 -4
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -7
- package/dist/version.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/onflay/onflay/sdks/node/dist/models/operations/index.js"],"names":[],"mappings":"AAAA","file":"/home/runner/work/onflay/onflay/sdks/node/dist/models/operations/index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination types, shaped like Speakeasy's `PageIterator`.
|
|
3
|
+
*
|
|
4
|
+
* A paginated method resolves to its first page, which is also an async iterable over
|
|
5
|
+
* every page (the first one included), following `nextCursor`:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const result = await onflay.customers.list({ limit: 50 });
|
|
9
|
+
* console.log(result.result.data); // first page
|
|
10
|
+
*
|
|
11
|
+
* for await (const page of result) {
|
|
12
|
+
* for (const customer of page.result.data) console.log(customer.id);
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* const second = await result.next(); // null on the last page
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/** Returns the next page, or `null` when there is none. */
|
|
19
|
+
type Paginator<V> = () => Promise<PageIterator<V>> | null;
|
|
20
|
+
type PageIterator<V, PageState = unknown> = V & {
|
|
21
|
+
next: Paginator<V>;
|
|
22
|
+
[Symbol.asyncIterator]: () => AsyncIterableIterator<V>;
|
|
23
|
+
'~next'?: PageState | undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type { PageIterator, Paginator };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination types, shaped like Speakeasy's `PageIterator`.
|
|
3
|
+
*
|
|
4
|
+
* A paginated method resolves to its first page, which is also an async iterable over
|
|
5
|
+
* every page (the first one included), following `nextCursor`:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const result = await onflay.customers.list({ limit: 50 });
|
|
9
|
+
* console.log(result.result.data); // first page
|
|
10
|
+
*
|
|
11
|
+
* for await (const page of result) {
|
|
12
|
+
* for (const customer of page.result.data) console.log(customer.id);
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* const second = await result.next(); // null on the last page
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/** Returns the next page, or `null` when there is none. */
|
|
19
|
+
type Paginator<V> = () => Promise<PageIterator<V>> | null;
|
|
20
|
+
type PageIterator<V, PageState = unknown> = V & {
|
|
21
|
+
next: Paginator<V>;
|
|
22
|
+
[Symbol.asyncIterator]: () => AsyncIterableIterator<V>;
|
|
23
|
+
'~next'?: PageState | undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type { PageIterator, Paginator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/onflay/onflay/sdks/node/dist/types/index.js"],"names":[],"mappings":"AAAA","file":"/home/runner/work/onflay/onflay/sdks/node/dist/types/index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook event payloads. Onflay's public OpenAPI spec (3.0) has no `webhooks`
|
|
3
|
+
* section, so these types are hand-written here, next to signature verification.
|
|
4
|
+
* They moved from `@onflay/node` 0.x, which re-exports them from
|
|
5
|
+
* `@onflay/node/webhooks` in 1.x.
|
|
6
|
+
*/
|
|
7
|
+
interface OnflayMetadata {
|
|
8
|
+
[key: string]: string | number | boolean | null;
|
|
9
|
+
}
|
|
10
|
+
type SubscriptionStatus = 'active' | 'past_due' | 'canceled' | 'unpaid' | 'expired' | 'trialing' | 'incomplete';
|
|
11
|
+
/** Customer summary embedded in subscriptions and payments. */
|
|
12
|
+
interface OnflayCustomerRef {
|
|
13
|
+
id: string;
|
|
14
|
+
/** Your app's id for the customer (checkout `externalCustomerId`). */
|
|
15
|
+
externalCustomerId: string | null;
|
|
16
|
+
email: string;
|
|
17
|
+
}
|
|
18
|
+
/** Product summary; `key` is the catalog key. */
|
|
19
|
+
interface OnflayProductRef {
|
|
20
|
+
id: string;
|
|
21
|
+
key: string | null;
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
/** Plan summary. */
|
|
25
|
+
interface OnflayPlanRef {
|
|
26
|
+
key: string | null;
|
|
27
|
+
name: string;
|
|
28
|
+
}
|
|
29
|
+
/** The Price row a subscription is pinned to. */
|
|
30
|
+
interface OnflaySubscriptionPrice {
|
|
31
|
+
id: string;
|
|
32
|
+
/** Null for tiered or usage-based prices. */
|
|
33
|
+
amountInCents: number | null;
|
|
34
|
+
currency: string;
|
|
35
|
+
interval: 'day' | 'week' | 'month' | 'year' | null;
|
|
36
|
+
intervalCount: number | null;
|
|
37
|
+
}
|
|
38
|
+
/** A subscription as embedded in `subscription.*` events (dates are ISO strings). */
|
|
39
|
+
interface OnflaySubscription {
|
|
40
|
+
id: string;
|
|
41
|
+
object: 'subscription';
|
|
42
|
+
status: SubscriptionStatus;
|
|
43
|
+
customer: OnflayCustomerRef;
|
|
44
|
+
product: OnflayProductRef;
|
|
45
|
+
plan: OnflayPlanRef | null;
|
|
46
|
+
price: OnflaySubscriptionPrice | null;
|
|
47
|
+
currentPeriodStart: string;
|
|
48
|
+
currentPeriodEnd: string;
|
|
49
|
+
/** `status` stays `active` (or `trialing`) until the period ends. */
|
|
50
|
+
cancelAtPeriodEnd: boolean;
|
|
51
|
+
canceledAt: string | null;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Public webhook event names. These are the values consumers should pin
|
|
57
|
+
* their handlers to. Adding a new value here is a breaking change for
|
|
58
|
+
* receivers that exhaustively `switch` on `event.type` — bump the SDK
|
|
59
|
+
* minor and call it out in the changelog.
|
|
60
|
+
*/
|
|
61
|
+
declare const ONFLAY_EVENT_TYPES: readonly ["payment.completed", "payment.refunded", "payout.scheduled", "payout.completed", "payout.failed", "dispute.opened", "dispute.resolved", "subscription.created", "subscription.renewed", "subscription.cancel_scheduled", "subscription.uncanceled", "subscription.canceled", "subscription.updated", "subscription.expired", "subscription.dunning", "invoice.created", "invoice.finalized", "invoice.paid", "invoice.payment_failed", "customer.access_changed", "catalog.product.updated", "catalog.plan.updated", "credits.granted", "license_key.created", "license_key.revoked"];
|
|
62
|
+
type OnflayEventType = (typeof ONFLAY_EVENT_TYPES)[number];
|
|
63
|
+
interface OnflayWebhookEnvelope<TData = unknown> {
|
|
64
|
+
/** Public event ID (`evt_...`). */
|
|
65
|
+
id: string;
|
|
66
|
+
type: OnflayEventType | string;
|
|
67
|
+
/** Unix seconds. */
|
|
68
|
+
createdAt: number;
|
|
69
|
+
/** `false` for sandbox, `true` for production. */
|
|
70
|
+
livemode: boolean;
|
|
71
|
+
/** Schema version of `data`. */
|
|
72
|
+
apiVersion: string;
|
|
73
|
+
data: TData;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Actual runtime shape of `event.data` for `payment.completed` and
|
|
77
|
+
* `payment.refunded` events. Matches the fields emitted by
|
|
78
|
+
* `TransactionCompletedPayload` in `@onflay/contracts`.
|
|
79
|
+
*
|
|
80
|
+
* Note: the `object` field is always `"payment"` and is injected by the
|
|
81
|
+
* webhook dispatch layer.
|
|
82
|
+
*/
|
|
83
|
+
interface PaymentEventData {
|
|
84
|
+
object: 'payment';
|
|
85
|
+
transactionId: string;
|
|
86
|
+
creatorId: string;
|
|
87
|
+
customerId: string;
|
|
88
|
+
listingId: string;
|
|
89
|
+
listingType: string;
|
|
90
|
+
/** Pre-fee charged amount in cents. */
|
|
91
|
+
grossAmountInCents: number;
|
|
92
|
+
currency: string;
|
|
93
|
+
/**
|
|
94
|
+
* True when the checkout session was created with a developer-supplied
|
|
95
|
+
* `customPrice` override via the SDK.
|
|
96
|
+
*/
|
|
97
|
+
isCustomPrice?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Variant list price at the time of checkout. Only present when
|
|
100
|
+
* `isCustomPrice` is true.
|
|
101
|
+
*/
|
|
102
|
+
basePriceInCents?: number;
|
|
103
|
+
/** Developer note passed in `customPrice.description`, if any. */
|
|
104
|
+
customPriceDescription?: string;
|
|
105
|
+
}
|
|
106
|
+
interface PaymentRefundedEventData {
|
|
107
|
+
object: 'payment';
|
|
108
|
+
transactionId: string;
|
|
109
|
+
refundId: string;
|
|
110
|
+
creatorId: string;
|
|
111
|
+
amountInCents: number;
|
|
112
|
+
isFullRefund: boolean;
|
|
113
|
+
currency: string;
|
|
114
|
+
}
|
|
115
|
+
interface PayoutEventData {
|
|
116
|
+
payoutId: string;
|
|
117
|
+
creatorId: string;
|
|
118
|
+
amountInCents: number;
|
|
119
|
+
externalTransferId?: string;
|
|
120
|
+
scheduledFor?: string;
|
|
121
|
+
failureReason?: string;
|
|
122
|
+
metadata?: OnflayMetadata;
|
|
123
|
+
}
|
|
124
|
+
interface DisputeEventData {
|
|
125
|
+
disputeId: string;
|
|
126
|
+
transactionId: string;
|
|
127
|
+
externalDisputeId?: string;
|
|
128
|
+
amountInCents: number;
|
|
129
|
+
resolution?: string;
|
|
130
|
+
metadata?: OnflayMetadata;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Enriched payload for cancel / uncancel / plan-change subscription webhooks.
|
|
134
|
+
*/
|
|
135
|
+
interface SubscriptionLifecycleEventData {
|
|
136
|
+
object: 'subscription';
|
|
137
|
+
subscriptionId: string;
|
|
138
|
+
creatorId: string;
|
|
139
|
+
customerId: string;
|
|
140
|
+
externalCustomerId?: string;
|
|
141
|
+
status: string;
|
|
142
|
+
cancelAtPeriodEnd: boolean;
|
|
143
|
+
cancelAt?: string | null;
|
|
144
|
+
currentPeriodEnd: string;
|
|
145
|
+
accessUntil: string | null;
|
|
146
|
+
catalogKey?: string;
|
|
147
|
+
planKey?: string;
|
|
148
|
+
interval?: 'month' | 'year' | null;
|
|
149
|
+
previousPlanKey?: string;
|
|
150
|
+
previousInterval?: string | null;
|
|
151
|
+
}
|
|
152
|
+
interface SubscriptionEventData extends OnflaySubscription {
|
|
153
|
+
/** Sub-event detail surfaced by the dispatch listener (e.g. dunning attempt #). */
|
|
154
|
+
detail?: Record<string, unknown>;
|
|
155
|
+
}
|
|
156
|
+
interface InvoiceLineItem {
|
|
157
|
+
description: string;
|
|
158
|
+
amountInCents: number;
|
|
159
|
+
quantity?: number;
|
|
160
|
+
unitAmountInCents?: number;
|
|
161
|
+
}
|
|
162
|
+
interface InvoiceEventData {
|
|
163
|
+
object: 'billing_invoice';
|
|
164
|
+
id: string;
|
|
165
|
+
externalInvoiceId: string | null;
|
|
166
|
+
status: 'open' | 'paid' | 'failed' | 'voided';
|
|
167
|
+
source: 'developer_push' | 'usage_metered';
|
|
168
|
+
currency: string;
|
|
169
|
+
totalInCents: number;
|
|
170
|
+
lineItems: InvoiceLineItem[];
|
|
171
|
+
periodStart: string | null;
|
|
172
|
+
periodEnd: string | null;
|
|
173
|
+
customerId: string;
|
|
174
|
+
subscriptionId: string | null;
|
|
175
|
+
createdAt: string;
|
|
176
|
+
}
|
|
177
|
+
interface CustomerAccessChangedEventData {
|
|
178
|
+
object: 'customer_access_changed';
|
|
179
|
+
externalCustomerId: string;
|
|
180
|
+
accessVersion: number;
|
|
181
|
+
changedSections: readonly string[];
|
|
182
|
+
timestamp: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Thin catalog change notification. Re-fetch
|
|
186
|
+
* `GET /v1/catalog/products/{productKey}` for the current state.
|
|
187
|
+
*/
|
|
188
|
+
interface CatalogChangedEventData {
|
|
189
|
+
object: 'catalog_changed';
|
|
190
|
+
productKey: string;
|
|
191
|
+
/** Present for `catalog.plan.updated`. */
|
|
192
|
+
planKey?: string;
|
|
193
|
+
change: 'created' | 'updated' | 'deleted';
|
|
194
|
+
source: 'dashboard' | 'api' | 'code';
|
|
195
|
+
timestamp: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Thin `credits.granted`: a purchase or a positive adjustment added credits.
|
|
199
|
+
* Re-fetch `GET /v1/credits/{externalCustomerId}` for the current balances.
|
|
200
|
+
*/
|
|
201
|
+
interface CreditsGrantedEventData {
|
|
202
|
+
object: 'credits_granted';
|
|
203
|
+
/** Null when the customer was never linked to your app's id. */
|
|
204
|
+
externalCustomerId: string | null;
|
|
205
|
+
key: string;
|
|
206
|
+
amount: number;
|
|
207
|
+
/** Balance right after the grant. */
|
|
208
|
+
balance: number;
|
|
209
|
+
reason: 'purchase' | 'adjustment';
|
|
210
|
+
/** Credit ledger entry id. */
|
|
211
|
+
entryId: string;
|
|
212
|
+
/** Payment that granted the credits (purchases only). */
|
|
213
|
+
paymentId?: string;
|
|
214
|
+
subscriptionId?: string;
|
|
215
|
+
timestamp: string;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Thin `license_key.created` / `license_key.revoked`. Never carries the key itself:
|
|
219
|
+
* fetch it with `GET /v1/license-keys/{licenseKeyId}`.
|
|
220
|
+
*/
|
|
221
|
+
interface LicenseKeyChangedEventData {
|
|
222
|
+
object: 'license_key_changed';
|
|
223
|
+
licenseKeyId: string;
|
|
224
|
+
externalCustomerId: string | null;
|
|
225
|
+
productKey: string | null;
|
|
226
|
+
planKey: string | null;
|
|
227
|
+
status: 'active' | 'revoked' | 'expired';
|
|
228
|
+
expiresAt: string | null;
|
|
229
|
+
/** Payment that issued the key. */
|
|
230
|
+
paymentId?: string;
|
|
231
|
+
subscriptionId?: string;
|
|
232
|
+
timestamp: string;
|
|
233
|
+
}
|
|
234
|
+
type OnflayEvent = (OnflayWebhookEnvelope<PaymentEventData> & {
|
|
235
|
+
type: 'payment.completed';
|
|
236
|
+
}) | (OnflayWebhookEnvelope<PaymentRefundedEventData> & {
|
|
237
|
+
type: 'payment.refunded';
|
|
238
|
+
}) | (OnflayWebhookEnvelope<PayoutEventData> & {
|
|
239
|
+
type: 'payout.scheduled' | 'payout.completed' | 'payout.failed';
|
|
240
|
+
}) | (OnflayWebhookEnvelope<DisputeEventData> & {
|
|
241
|
+
type: 'dispute.opened' | 'dispute.resolved';
|
|
242
|
+
}) | (OnflayWebhookEnvelope<SubscriptionEventData> & {
|
|
243
|
+
type: 'subscription.created' | 'subscription.renewed' | 'subscription.expired' | 'subscription.dunning';
|
|
244
|
+
}) | (OnflayWebhookEnvelope<SubscriptionLifecycleEventData> & {
|
|
245
|
+
type: 'subscription.cancel_scheduled' | 'subscription.uncanceled' | 'subscription.canceled' | 'subscription.updated';
|
|
246
|
+
}) | (OnflayWebhookEnvelope<InvoiceEventData> & {
|
|
247
|
+
type: 'invoice.created' | 'invoice.finalized' | 'invoice.paid' | 'invoice.payment_failed';
|
|
248
|
+
}) | (OnflayWebhookEnvelope<CustomerAccessChangedEventData> & {
|
|
249
|
+
type: 'customer.access_changed';
|
|
250
|
+
}) | (OnflayWebhookEnvelope<CatalogChangedEventData> & {
|
|
251
|
+
type: 'catalog.product.updated' | 'catalog.plan.updated';
|
|
252
|
+
}) | (OnflayWebhookEnvelope<CreditsGrantedEventData> & {
|
|
253
|
+
type: 'credits.granted';
|
|
254
|
+
}) | (OnflayWebhookEnvelope<LicenseKeyChangedEventData> & {
|
|
255
|
+
type: 'license_key.created' | 'license_key.revoked';
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
declare const ONFLAY_SIGNATURE_HEADER = "x-onflay-signature";
|
|
259
|
+
declare const STANDARD_WEBHOOK_ID_HEADER = "webhook-id";
|
|
260
|
+
declare const STANDARD_WEBHOOK_TIMESTAMP_HEADER = "webhook-timestamp";
|
|
261
|
+
declare const STANDARD_WEBHOOK_SIGNATURE_HEADER = "webhook-signature";
|
|
262
|
+
declare const DEFAULT_REPLAY_TOLERANCE_SECONDS = 300;
|
|
263
|
+
/**
|
|
264
|
+
* Request headers in any common shape: a Fetch `Headers` instance (Next.js,
|
|
265
|
+
* Hono, Workers) or a plain object such as Node/Express `req.headers`.
|
|
266
|
+
* Plain-object lookups are case-insensitive.
|
|
267
|
+
*/
|
|
268
|
+
type WebhookHeaders = {
|
|
269
|
+
get(name: string): string | null;
|
|
270
|
+
} | Record<string, string | string[] | null | undefined>;
|
|
271
|
+
declare class OnflaySignatureError extends Error {
|
|
272
|
+
readonly code: 'missing_signature' | 'malformed_signature' | 'invalid_signature' | 'expired_signature' | 'missing_payload';
|
|
273
|
+
constructor(code: OnflaySignatureError['code'], message: string);
|
|
274
|
+
}
|
|
275
|
+
interface VerifyWebhookOptions {
|
|
276
|
+
/** Per-endpoint signing secret (`whsec_…`). */
|
|
277
|
+
secret: string;
|
|
278
|
+
/**
|
|
279
|
+
* Replay window in seconds. Reject events older than this. Defaults to
|
|
280
|
+
* 300 (5 minutes); set to 0 to disable.
|
|
281
|
+
*/
|
|
282
|
+
toleranceSeconds?: number;
|
|
283
|
+
/** Inject a clock for tests. Defaults to `Date.now`. */
|
|
284
|
+
now?: () => Date;
|
|
285
|
+
}
|
|
286
|
+
interface VerifiedWebhook<TEvent = unknown> {
|
|
287
|
+
/** The parsed JSON envelope. */
|
|
288
|
+
event: TEvent;
|
|
289
|
+
/** Raw bytes that were verified (the body field passed in). */
|
|
290
|
+
rawBody: string;
|
|
291
|
+
/** Signature timestamp (unix seconds). */
|
|
292
|
+
timestamp: number;
|
|
293
|
+
/** Which signature scheme verified the request. */
|
|
294
|
+
scheme: 'standard' | 'legacy';
|
|
295
|
+
/** Standard Webhooks message id (`webhook-id`); set when `scheme` is `standard`. */
|
|
296
|
+
webhookId?: string;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Verify an inbound Onflay webhook against the raw request body and a
|
|
300
|
+
* per-endpoint secret. Returns the parsed event envelope on success;
|
|
301
|
+
* throws `OnflaySignatureError` for any verification failure.
|
|
302
|
+
*
|
|
303
|
+
* The second argument is either:
|
|
304
|
+
* - the request headers (`Headers` or a plain object): Standard Webhooks
|
|
305
|
+
* (`webhook-id` / `webhook-timestamp` / `webhook-signature`) is tried
|
|
306
|
+
* first, then the legacy `X-Onflay-Signature` header; or
|
|
307
|
+
* - the `X-Onflay-Signature` header value alone (legacy scheme only, the
|
|
308
|
+
* original signature of this function).
|
|
309
|
+
*
|
|
310
|
+
* IMPORTANT: pass the raw body bytes (string), NOT a re-serialized JSON
|
|
311
|
+
* object. Re-serializing changes whitespace/property order and breaks the
|
|
312
|
+
* HMAC.
|
|
313
|
+
*/
|
|
314
|
+
declare function verifyWebhookSignature<TEvent = unknown>(rawBody: string, signatureHeaderOrHeaders: string | string[] | null | undefined | WebhookHeaders, options: VerifyWebhookOptions): VerifiedWebhook<TEvent>;
|
|
315
|
+
/**
|
|
316
|
+
* Verify a Standard Webhooks signature (https://www.standardwebhooks.com):
|
|
317
|
+
* `webhook-signature` holds one or more space-separated `v1,<base64>`
|
|
318
|
+
* entries, each an HMAC-SHA256 over `{webhook-id}.{webhook-timestamp}.{body}`
|
|
319
|
+
* keyed with the base64 decode of the secret after its `whsec_` prefix.
|
|
320
|
+
* Rejects timestamps more than `toleranceSeconds` (default 300) away from
|
|
321
|
+
* now in either direction.
|
|
322
|
+
*/
|
|
323
|
+
declare function verifyStandardWebhook<TEvent = unknown>(rawBody: string, headers: WebhookHeaders, options: VerifyWebhookOptions): VerifiedWebhook<TEvent>;
|
|
324
|
+
|
|
325
|
+
export { type CatalogChangedEventData as C, DEFAULT_REPLAY_TOLERANCE_SECONDS as D, type InvoiceEventData as I, type LicenseKeyChangedEventData as L, type OnflayEvent as O, type PaymentEventData as P, STANDARD_WEBHOOK_ID_HEADER as S, type VerifyWebhookOptions as V, type WebhookHeaders as W, type CreditsGrantedEventData as a, type CustomerAccessChangedEventData as b, type DisputeEventData as c, type InvoiceLineItem as d, ONFLAY_EVENT_TYPES as e, ONFLAY_SIGNATURE_HEADER as f, type OnflayCustomerRef as g, type OnflayEventType as h, type OnflayMetadata as i, type OnflayPlanRef as j, type OnflayProductRef as k, OnflaySignatureError as l, type OnflaySubscription as m, type OnflaySubscriptionPrice as n, type OnflayWebhookEnvelope as o, type PaymentRefundedEventData as p, type PayoutEventData as q, STANDARD_WEBHOOK_SIGNATURE_HEADER as r, STANDARD_WEBHOOK_TIMESTAMP_HEADER as s, type SubscriptionEventData as t, type SubscriptionLifecycleEventData as u, type SubscriptionStatus as v, type VerifiedWebhook as w, verifyStandardWebhook as x, verifyWebhookSignature as y };
|