@onflay/node 0.2.1 → 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 -26
- package/dist/index.js +2990 -40
- 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 -42
- package/dist/onflay.d.ts.map +0 -1
- package/dist/onflay.js +0 -60
- 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/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 -95
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/events.js +0 -24
- package/dist/types/events.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,75 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkMMMUKAI6js = require('../chunk-MMMUKAI6.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkAFAU2FH2js = require('../chunk-AFAU2FH2.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkW6AEPYUGjs = require('../chunk-W6AEPYUG.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
var _chunkI2IVHBFAjs = require('../chunk-I2IVHBFA.js');
|
|
23
|
+
|
|
24
|
+
// src/webhooks/events.ts
|
|
25
|
+
var ONFLAY_EVENT_TYPES = [
|
|
26
|
+
"payment.completed",
|
|
27
|
+
"payment.refunded",
|
|
28
|
+
"payout.scheduled",
|
|
29
|
+
"payout.completed",
|
|
30
|
+
"payout.failed",
|
|
31
|
+
"dispute.opened",
|
|
32
|
+
"dispute.resolved",
|
|
33
|
+
"subscription.created",
|
|
34
|
+
"subscription.renewed",
|
|
35
|
+
"subscription.cancel_scheduled",
|
|
36
|
+
"subscription.uncanceled",
|
|
37
|
+
"subscription.canceled",
|
|
38
|
+
"subscription.updated",
|
|
39
|
+
"subscription.expired",
|
|
40
|
+
"subscription.dunning",
|
|
41
|
+
"invoice.created",
|
|
42
|
+
"invoice.finalized",
|
|
43
|
+
"invoice.paid",
|
|
44
|
+
"invoice.payment_failed",
|
|
45
|
+
"customer.access_changed",
|
|
46
|
+
"catalog.product.updated",
|
|
47
|
+
"catalog.plan.updated",
|
|
48
|
+
"credits.granted",
|
|
49
|
+
"license_key.created",
|
|
50
|
+
"license_key.revoked"
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
// src/webhooks/index.ts
|
|
54
|
+
function unwrap(rawBody, headers, options) {
|
|
55
|
+
return _chunkI2IVHBFAjs.verifyWebhookSignature.call(void 0, rawBody, headers, options).event;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
exports.DEFAULT_REPLAY_TOLERANCE_SECONDS = _chunkI2IVHBFAjs.DEFAULT_REPLAY_TOLERANCE_SECONDS; exports.ONFLAY_EVENT_TYPES = ONFLAY_EVENT_TYPES; exports.ONFLAY_SIGNATURE_HEADER = _chunkI2IVHBFAjs.ONFLAY_SIGNATURE_HEADER; exports.OnflaySignatureError = _chunkI2IVHBFAjs.OnflaySignatureError; exports.STANDARD_WEBHOOK_ID_HEADER = _chunkI2IVHBFAjs.STANDARD_WEBHOOK_ID_HEADER; exports.STANDARD_WEBHOOK_SIGNATURE_HEADER = _chunkI2IVHBFAjs.STANDARD_WEBHOOK_SIGNATURE_HEADER; exports.STANDARD_WEBHOOK_TIMESTAMP_HEADER = _chunkI2IVHBFAjs.STANDARD_WEBHOOK_TIMESTAMP_HEADER; exports.createExpressWebhookHandler = _chunkAFAU2FH2js.createExpressWebhookHandler; exports.createHonoWebhookHandler = _chunkW6AEPYUGjs.createHonoWebhookHandler; exports.createNextWebhookHandler = _chunkMMMUKAI6js.createNextWebhookHandler; exports.unwrap = unwrap; exports.verifyExpressWebhook = _chunkAFAU2FH2js.verifyExpressWebhook; exports.verifyHonoWebhook = _chunkW6AEPYUGjs.verifyHonoWebhook; exports.verifyNextWebhook = _chunkMMMUKAI6js.verifyNextWebhook; exports.verifyStandardWebhook = _chunkI2IVHBFAjs.verifyStandardWebhook; exports.verifyWebhookSignature = _chunkI2IVHBFAjs.verifyWebhookSignature;
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/onflay/onflay/sdks/node/dist/webhooks/index.js","../../src/webhooks/events.ts","../../src/webhooks/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,uDAA6B;AAC7B;AACA;ACoDO,IAAM,mBAAA,EAAqB;AAAA,EAChC,mBAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,kBAAA;AAAA,EACA,sBAAA;AAAA,EACA,sBAAA;AAAA,EACA,+BAAA;AAAA,EACA,yBAAA;AAAA,EACA,uBAAA;AAAA,EACA,sBAAA;AAAA,EACA,sBAAA;AAAA,EACA,sBAAA;AAAA,EACA,iBAAA;AAAA,EACA,mBAAA;AAAA,EACA,cAAA;AAAA,EACA,wBAAA;AAAA,EACA,yBAAA;AAAA,EACA,yBAAA;AAAA,EACA,sBAAA;AAAA,EACA,iBAAA;AAAA,EACA,qBAAA;AAAA,EACA;AACF,CAAA;ADlDA;AACA;AEiBO,SAAS,MAAA,CAA6B,OAAA,EAAiB,OAAA,EAAyB,OAAA,EAAuC;AAC5H,EAAA,OAAO,qDAAA,OAA+B,EAAS,OAAA,EAAS,OAAO,CAAA,CAAE,KAAA;AACnE;AFfA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,mpCAAC","file":"/home/runner/work/onflay/onflay/sdks/node/dist/webhooks/index.js","sourcesContent":[null,"/**\n * Webhook event payloads. Onflay's public OpenAPI spec (3.0) has no `webhooks`\n * section, so these types are hand-written here, next to signature verification.\n * They moved from `@onflay/node` 0.x, which re-exports them from\n * `@onflay/node/webhooks` in 1.x.\n */\n\nexport interface OnflayMetadata {\n [key: string]: string | number | boolean | null;\n}\n\nexport type SubscriptionStatus =\n | 'active'\n | 'past_due'\n | 'canceled'\n | 'unpaid'\n | 'expired'\n | 'trialing'\n | 'incomplete';\n\n/** Customer summary embedded in subscriptions and payments. */\nexport interface OnflayCustomerRef {\n id: string;\n /** Your app's id for the customer (checkout `externalCustomerId`). */\n externalCustomerId: string | null;\n email: string;\n}\n\n/** Product summary; `key` is the catalog key. */\nexport interface OnflayProductRef {\n id: string;\n key: string | null;\n name: string;\n}\n\n/** Plan summary. */\nexport interface OnflayPlanRef {\n key: string | null;\n name: string;\n}\n\n/** The Price row a subscription is pinned to. */\nexport interface OnflaySubscriptionPrice {\n id: string;\n /** Null for tiered or usage-based prices. */\n amountInCents: number | null;\n currency: string;\n interval: 'day' | 'week' | 'month' | 'year' | null;\n intervalCount: number | null;\n}\n\n/** A subscription as embedded in `subscription.*` events (dates are ISO strings). */\nexport interface OnflaySubscription {\n id: string;\n object: 'subscription';\n status: SubscriptionStatus;\n customer: OnflayCustomerRef;\n product: OnflayProductRef;\n plan: OnflayPlanRef | null;\n price: OnflaySubscriptionPrice | null;\n currentPeriodStart: string;\n currentPeriodEnd: string;\n /** `status` stays `active` (or `trialing`) until the period ends. */\n cancelAtPeriodEnd: boolean;\n canceledAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\n/**\n * Public webhook event names. These are the values consumers should pin\n * their handlers to. Adding a new value here is a breaking change for\n * receivers that exhaustively `switch` on `event.type` — bump the SDK\n * minor and call it out in the changelog.\n */\nexport const ONFLAY_EVENT_TYPES = [\n 'payment.completed',\n 'payment.refunded',\n 'payout.scheduled',\n 'payout.completed',\n 'payout.failed',\n 'dispute.opened',\n 'dispute.resolved',\n 'subscription.created',\n 'subscription.renewed',\n 'subscription.cancel_scheduled',\n 'subscription.uncanceled',\n 'subscription.canceled',\n 'subscription.updated',\n 'subscription.expired',\n 'subscription.dunning',\n 'invoice.created',\n 'invoice.finalized',\n 'invoice.paid',\n 'invoice.payment_failed',\n 'customer.access_changed',\n 'catalog.product.updated',\n 'catalog.plan.updated',\n 'credits.granted',\n 'license_key.created',\n 'license_key.revoked',\n] as const;\n\nexport type OnflayEventType = (typeof ONFLAY_EVENT_TYPES)[number];\n\nexport interface OnflayWebhookEnvelope<TData = unknown> {\n /** Public event ID (`evt_...`). */\n id: string;\n type: OnflayEventType | string;\n /** Unix seconds. */\n createdAt: number;\n /** `false` for sandbox, `true` for production. */\n livemode: boolean;\n /** Schema version of `data`. */\n apiVersion: string;\n data: TData;\n}\n\n/**\n * Actual runtime shape of `event.data` for `payment.completed` and\n * `payment.refunded` events. Matches the fields emitted by\n * `TransactionCompletedPayload` in `@onflay/contracts`.\n *\n * Note: the `object` field is always `\"payment\"` and is injected by the\n * webhook dispatch layer.\n */\nexport interface PaymentEventData {\n object: 'payment';\n transactionId: string;\n creatorId: string;\n customerId: string;\n listingId: string;\n listingType: string;\n /** Pre-fee charged amount in cents. */\n grossAmountInCents: number;\n currency: string;\n /**\n * True when the checkout session was created with a developer-supplied\n * `customPrice` override via the SDK.\n */\n isCustomPrice?: boolean;\n /**\n * Variant list price at the time of checkout. Only present when\n * `isCustomPrice` is true.\n */\n basePriceInCents?: number;\n /** Developer note passed in `customPrice.description`, if any. */\n customPriceDescription?: string;\n}\n\nexport interface PaymentRefundedEventData {\n object: 'payment';\n transactionId: string;\n refundId: string;\n creatorId: string;\n amountInCents: number;\n isFullRefund: boolean;\n currency: string;\n}\n\nexport interface PayoutEventData {\n payoutId: string;\n creatorId: string;\n amountInCents: number;\n externalTransferId?: string;\n scheduledFor?: string;\n failureReason?: string;\n metadata?: OnflayMetadata;\n}\n\nexport interface DisputeEventData {\n disputeId: string;\n transactionId: string;\n externalDisputeId?: string;\n amountInCents: number;\n resolution?: string;\n metadata?: OnflayMetadata;\n}\n\n/**\n * Enriched payload for cancel / uncancel / plan-change subscription webhooks.\n */\nexport interface SubscriptionLifecycleEventData {\n object: 'subscription';\n subscriptionId: string;\n creatorId: string;\n customerId: string;\n externalCustomerId?: string;\n status: string;\n cancelAtPeriodEnd: boolean;\n cancelAt?: string | null;\n currentPeriodEnd: string;\n accessUntil: string | null;\n catalogKey?: string;\n planKey?: string;\n interval?: 'month' | 'year' | null;\n previousPlanKey?: string;\n previousInterval?: string | null;\n}\n\nexport interface SubscriptionEventData extends OnflaySubscription {\n /** Sub-event detail surfaced by the dispatch listener (e.g. dunning attempt #). */\n detail?: Record<string, unknown>;\n}\n\nexport interface InvoiceLineItem {\n description: string;\n amountInCents: number;\n quantity?: number;\n unitAmountInCents?: number;\n}\n\nexport interface InvoiceEventData {\n object: 'billing_invoice';\n id: string;\n externalInvoiceId: string | null;\n status: 'open' | 'paid' | 'failed' | 'voided';\n source: 'developer_push' | 'usage_metered';\n currency: string;\n totalInCents: number;\n lineItems: InvoiceLineItem[];\n periodStart: string | null;\n periodEnd: string | null;\n customerId: string;\n subscriptionId: string | null;\n createdAt: string;\n}\n\nexport interface CustomerAccessChangedEventData {\n object: 'customer_access_changed';\n externalCustomerId: string;\n accessVersion: number;\n changedSections: readonly string[];\n timestamp: string;\n}\n\n/**\n * Thin catalog change notification. Re-fetch\n * `GET /v1/catalog/products/{productKey}` for the current state.\n */\nexport interface CatalogChangedEventData {\n object: 'catalog_changed';\n productKey: string;\n /** Present for `catalog.plan.updated`. */\n planKey?: string;\n change: 'created' | 'updated' | 'deleted';\n source: 'dashboard' | 'api' | 'code';\n timestamp: string;\n}\n\n/**\n * Thin `credits.granted`: a purchase or a positive adjustment added credits.\n * Re-fetch `GET /v1/credits/{externalCustomerId}` for the current balances.\n */\nexport interface CreditsGrantedEventData {\n object: 'credits_granted';\n /** Null when the customer was never linked to your app's id. */\n externalCustomerId: string | null;\n key: string;\n amount: number;\n /** Balance right after the grant. */\n balance: number;\n reason: 'purchase' | 'adjustment';\n /** Credit ledger entry id. */\n entryId: string;\n /** Payment that granted the credits (purchases only). */\n paymentId?: string;\n subscriptionId?: string;\n timestamp: string;\n}\n\n/**\n * Thin `license_key.created` / `license_key.revoked`. Never carries the key itself:\n * fetch it with `GET /v1/license-keys/{licenseKeyId}`.\n */\nexport interface LicenseKeyChangedEventData {\n object: 'license_key_changed';\n licenseKeyId: string;\n externalCustomerId: string | null;\n productKey: string | null;\n planKey: string | null;\n status: 'active' | 'revoked' | 'expired';\n expiresAt: string | null;\n /** Payment that issued the key. */\n paymentId?: string;\n subscriptionId?: string;\n timestamp: string;\n}\n\nexport type OnflayEvent =\n | (OnflayWebhookEnvelope<PaymentEventData> & { type: 'payment.completed' })\n | (OnflayWebhookEnvelope<PaymentRefundedEventData> & { type: 'payment.refunded' })\n | (OnflayWebhookEnvelope<PayoutEventData> & {\n type: 'payout.scheduled' | 'payout.completed' | 'payout.failed';\n })\n | (OnflayWebhookEnvelope<DisputeEventData> & {\n type: 'dispute.opened' | 'dispute.resolved';\n })\n | (OnflayWebhookEnvelope<SubscriptionEventData> & {\n type:\n | 'subscription.created'\n | 'subscription.renewed'\n | 'subscription.expired'\n | 'subscription.dunning';\n })\n | (OnflayWebhookEnvelope<SubscriptionLifecycleEventData> & {\n type:\n | 'subscription.cancel_scheduled'\n | 'subscription.uncanceled'\n | 'subscription.canceled'\n | 'subscription.updated';\n })\n | (OnflayWebhookEnvelope<InvoiceEventData> & {\n type: 'invoice.created' | 'invoice.finalized' | 'invoice.paid' | 'invoice.payment_failed';\n })\n | (OnflayWebhookEnvelope<CustomerAccessChangedEventData> & {\n type: 'customer.access_changed';\n })\n | (OnflayWebhookEnvelope<CatalogChangedEventData> & {\n type: 'catalog.product.updated' | 'catalog.plan.updated';\n })\n | (OnflayWebhookEnvelope<CreditsGrantedEventData> & { type: 'credits.granted' })\n | (OnflayWebhookEnvelope<LicenseKeyChangedEventData> & {\n type: 'license_key.created' | 'license_key.revoked';\n });\n","/**\n * Webhook signature verification, framework adapters and event types\n * (Standard Webhooks, with the legacy `X-Onflay-Signature` fallback).\n *\n * ```ts\n * import { unwrap } from '@onflay/node/webhooks';\n *\n * export async function POST(req: Request) {\n * const event = unwrap(await req.text(), req.headers, { secret: process.env.ONFLAY_WEBHOOK_SECRET! });\n * if (event.type === 'customer.access_changed') {\n * // refresh the customer's access\n * }\n * return new Response('ok');\n * }\n * ```\n *\n * Framework handlers also have their own entry points: `@onflay/node/webhooks/next`,\n * `@onflay/node/webhooks/express` and `@onflay/node/webhooks/hono`.\n */\nimport { verifyWebhookSignature, type VerifyWebhookOptions, type WebhookHeaders } from './verify';\nimport type { OnflayEvent } from './events';\nexport {\n verifyWebhookSignature,\n verifyStandardWebhook,\n OnflaySignatureError,\n ONFLAY_SIGNATURE_HEADER,\n STANDARD_WEBHOOK_ID_HEADER,\n STANDARD_WEBHOOK_TIMESTAMP_HEADER,\n STANDARD_WEBHOOK_SIGNATURE_HEADER,\n DEFAULT_REPLAY_TOLERANCE_SECONDS,\n} from './verify';\nexport type { VerifyWebhookOptions, VerifiedWebhook, WebhookHeaders } from './verify';\n\nexport { verifyExpressWebhook, createExpressWebhookHandler } from './adapters/express';\nexport { verifyNextWebhook, createNextWebhookHandler } from './adapters/next';\nexport { verifyHonoWebhook, createHonoWebhookHandler } from './adapters/hono';\n\n// Webhook event payload types.\nexport type {\n OnflayEvent,\n OnflayEventType,\n OnflayWebhookEnvelope,\n OnflayMetadata,\n OnflaySubscription,\n OnflayCustomerRef,\n OnflayProductRef,\n OnflayPlanRef,\n OnflaySubscriptionPrice,\n SubscriptionStatus,\n PaymentEventData,\n PaymentRefundedEventData,\n PayoutEventData,\n DisputeEventData,\n SubscriptionEventData,\n SubscriptionLifecycleEventData,\n InvoiceEventData,\n InvoiceLineItem,\n CustomerAccessChangedEventData,\n CatalogChangedEventData,\n CreditsGrantedEventData,\n LicenseKeyChangedEventData,\n} from './events';\nexport { ONFLAY_EVENT_TYPES } from './events';\n\n/**\n * Verifies a webhook delivery and returns its event. Throws `OnflaySignatureError` when the\n * signature is missing, invalid or outside the replay window. `rawBody` must be the exact\n * request body (do not re-serialize parsed JSON).\n */\nexport function unwrap<TEvent = OnflayEvent>(rawBody: string, headers: WebhookHeaders, options: VerifyWebhookOptions): TEvent {\n return verifyWebhookSignature<TEvent>(rawBody, headers, options).event;\n}\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createNextWebhookHandler,
|
|
3
|
+
verifyNextWebhook
|
|
4
|
+
} from "../chunk-JQPANXLV.mjs";
|
|
5
|
+
import {
|
|
6
|
+
createExpressWebhookHandler,
|
|
7
|
+
verifyExpressWebhook
|
|
8
|
+
} from "../chunk-63KSRMJG.mjs";
|
|
9
|
+
import {
|
|
10
|
+
createHonoWebhookHandler,
|
|
11
|
+
verifyHonoWebhook
|
|
12
|
+
} from "../chunk-J4MYKTPN.mjs";
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_REPLAY_TOLERANCE_SECONDS,
|
|
15
|
+
ONFLAY_SIGNATURE_HEADER,
|
|
16
|
+
OnflaySignatureError,
|
|
17
|
+
STANDARD_WEBHOOK_ID_HEADER,
|
|
18
|
+
STANDARD_WEBHOOK_SIGNATURE_HEADER,
|
|
19
|
+
STANDARD_WEBHOOK_TIMESTAMP_HEADER,
|
|
20
|
+
verifyStandardWebhook,
|
|
21
|
+
verifyWebhookSignature
|
|
22
|
+
} from "../chunk-7LYAEZCT.mjs";
|
|
23
|
+
|
|
24
|
+
// src/webhooks/events.ts
|
|
25
|
+
var ONFLAY_EVENT_TYPES = [
|
|
26
|
+
"payment.completed",
|
|
27
|
+
"payment.refunded",
|
|
28
|
+
"payout.scheduled",
|
|
29
|
+
"payout.completed",
|
|
30
|
+
"payout.failed",
|
|
31
|
+
"dispute.opened",
|
|
32
|
+
"dispute.resolved",
|
|
33
|
+
"subscription.created",
|
|
34
|
+
"subscription.renewed",
|
|
35
|
+
"subscription.cancel_scheduled",
|
|
36
|
+
"subscription.uncanceled",
|
|
37
|
+
"subscription.canceled",
|
|
38
|
+
"subscription.updated",
|
|
39
|
+
"subscription.expired",
|
|
40
|
+
"subscription.dunning",
|
|
41
|
+
"invoice.created",
|
|
42
|
+
"invoice.finalized",
|
|
43
|
+
"invoice.paid",
|
|
44
|
+
"invoice.payment_failed",
|
|
45
|
+
"customer.access_changed",
|
|
46
|
+
"catalog.product.updated",
|
|
47
|
+
"catalog.plan.updated",
|
|
48
|
+
"credits.granted",
|
|
49
|
+
"license_key.created",
|
|
50
|
+
"license_key.revoked"
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
// src/webhooks/index.ts
|
|
54
|
+
function unwrap(rawBody, headers, options) {
|
|
55
|
+
return verifyWebhookSignature(rawBody, headers, options).event;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
DEFAULT_REPLAY_TOLERANCE_SECONDS,
|
|
59
|
+
ONFLAY_EVENT_TYPES,
|
|
60
|
+
ONFLAY_SIGNATURE_HEADER,
|
|
61
|
+
OnflaySignatureError,
|
|
62
|
+
STANDARD_WEBHOOK_ID_HEADER,
|
|
63
|
+
STANDARD_WEBHOOK_SIGNATURE_HEADER,
|
|
64
|
+
STANDARD_WEBHOOK_TIMESTAMP_HEADER,
|
|
65
|
+
createExpressWebhookHandler,
|
|
66
|
+
createHonoWebhookHandler,
|
|
67
|
+
createNextWebhookHandler,
|
|
68
|
+
unwrap,
|
|
69
|
+
verifyExpressWebhook,
|
|
70
|
+
verifyHonoWebhook,
|
|
71
|
+
verifyNextWebhook,
|
|
72
|
+
verifyStandardWebhook,
|
|
73
|
+
verifyWebhookSignature
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/webhooks/events.ts","../../src/webhooks/index.ts"],"sourcesContent":["/**\n * Webhook event payloads. Onflay's public OpenAPI spec (3.0) has no `webhooks`\n * section, so these types are hand-written here, next to signature verification.\n * They moved from `@onflay/node` 0.x, which re-exports them from\n * `@onflay/node/webhooks` in 1.x.\n */\n\nexport interface OnflayMetadata {\n [key: string]: string | number | boolean | null;\n}\n\nexport type SubscriptionStatus =\n | 'active'\n | 'past_due'\n | 'canceled'\n | 'unpaid'\n | 'expired'\n | 'trialing'\n | 'incomplete';\n\n/** Customer summary embedded in subscriptions and payments. */\nexport interface OnflayCustomerRef {\n id: string;\n /** Your app's id for the customer (checkout `externalCustomerId`). */\n externalCustomerId: string | null;\n email: string;\n}\n\n/** Product summary; `key` is the catalog key. */\nexport interface OnflayProductRef {\n id: string;\n key: string | null;\n name: string;\n}\n\n/** Plan summary. */\nexport interface OnflayPlanRef {\n key: string | null;\n name: string;\n}\n\n/** The Price row a subscription is pinned to. */\nexport interface OnflaySubscriptionPrice {\n id: string;\n /** Null for tiered or usage-based prices. */\n amountInCents: number | null;\n currency: string;\n interval: 'day' | 'week' | 'month' | 'year' | null;\n intervalCount: number | null;\n}\n\n/** A subscription as embedded in `subscription.*` events (dates are ISO strings). */\nexport interface OnflaySubscription {\n id: string;\n object: 'subscription';\n status: SubscriptionStatus;\n customer: OnflayCustomerRef;\n product: OnflayProductRef;\n plan: OnflayPlanRef | null;\n price: OnflaySubscriptionPrice | null;\n currentPeriodStart: string;\n currentPeriodEnd: string;\n /** `status` stays `active` (or `trialing`) until the period ends. */\n cancelAtPeriodEnd: boolean;\n canceledAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\n/**\n * Public webhook event names. These are the values consumers should pin\n * their handlers to. Adding a new value here is a breaking change for\n * receivers that exhaustively `switch` on `event.type` — bump the SDK\n * minor and call it out in the changelog.\n */\nexport const ONFLAY_EVENT_TYPES = [\n 'payment.completed',\n 'payment.refunded',\n 'payout.scheduled',\n 'payout.completed',\n 'payout.failed',\n 'dispute.opened',\n 'dispute.resolved',\n 'subscription.created',\n 'subscription.renewed',\n 'subscription.cancel_scheduled',\n 'subscription.uncanceled',\n 'subscription.canceled',\n 'subscription.updated',\n 'subscription.expired',\n 'subscription.dunning',\n 'invoice.created',\n 'invoice.finalized',\n 'invoice.paid',\n 'invoice.payment_failed',\n 'customer.access_changed',\n 'catalog.product.updated',\n 'catalog.plan.updated',\n 'credits.granted',\n 'license_key.created',\n 'license_key.revoked',\n] as const;\n\nexport type OnflayEventType = (typeof ONFLAY_EVENT_TYPES)[number];\n\nexport interface OnflayWebhookEnvelope<TData = unknown> {\n /** Public event ID (`evt_...`). */\n id: string;\n type: OnflayEventType | string;\n /** Unix seconds. */\n createdAt: number;\n /** `false` for sandbox, `true` for production. */\n livemode: boolean;\n /** Schema version of `data`. */\n apiVersion: string;\n data: TData;\n}\n\n/**\n * Actual runtime shape of `event.data` for `payment.completed` and\n * `payment.refunded` events. Matches the fields emitted by\n * `TransactionCompletedPayload` in `@onflay/contracts`.\n *\n * Note: the `object` field is always `\"payment\"` and is injected by the\n * webhook dispatch layer.\n */\nexport interface PaymentEventData {\n object: 'payment';\n transactionId: string;\n creatorId: string;\n customerId: string;\n listingId: string;\n listingType: string;\n /** Pre-fee charged amount in cents. */\n grossAmountInCents: number;\n currency: string;\n /**\n * True when the checkout session was created with a developer-supplied\n * `customPrice` override via the SDK.\n */\n isCustomPrice?: boolean;\n /**\n * Variant list price at the time of checkout. Only present when\n * `isCustomPrice` is true.\n */\n basePriceInCents?: number;\n /** Developer note passed in `customPrice.description`, if any. */\n customPriceDescription?: string;\n}\n\nexport interface PaymentRefundedEventData {\n object: 'payment';\n transactionId: string;\n refundId: string;\n creatorId: string;\n amountInCents: number;\n isFullRefund: boolean;\n currency: string;\n}\n\nexport interface PayoutEventData {\n payoutId: string;\n creatorId: string;\n amountInCents: number;\n externalTransferId?: string;\n scheduledFor?: string;\n failureReason?: string;\n metadata?: OnflayMetadata;\n}\n\nexport interface DisputeEventData {\n disputeId: string;\n transactionId: string;\n externalDisputeId?: string;\n amountInCents: number;\n resolution?: string;\n metadata?: OnflayMetadata;\n}\n\n/**\n * Enriched payload for cancel / uncancel / plan-change subscription webhooks.\n */\nexport interface SubscriptionLifecycleEventData {\n object: 'subscription';\n subscriptionId: string;\n creatorId: string;\n customerId: string;\n externalCustomerId?: string;\n status: string;\n cancelAtPeriodEnd: boolean;\n cancelAt?: string | null;\n currentPeriodEnd: string;\n accessUntil: string | null;\n catalogKey?: string;\n planKey?: string;\n interval?: 'month' | 'year' | null;\n previousPlanKey?: string;\n previousInterval?: string | null;\n}\n\nexport interface SubscriptionEventData extends OnflaySubscription {\n /** Sub-event detail surfaced by the dispatch listener (e.g. dunning attempt #). */\n detail?: Record<string, unknown>;\n}\n\nexport interface InvoiceLineItem {\n description: string;\n amountInCents: number;\n quantity?: number;\n unitAmountInCents?: number;\n}\n\nexport interface InvoiceEventData {\n object: 'billing_invoice';\n id: string;\n externalInvoiceId: string | null;\n status: 'open' | 'paid' | 'failed' | 'voided';\n source: 'developer_push' | 'usage_metered';\n currency: string;\n totalInCents: number;\n lineItems: InvoiceLineItem[];\n periodStart: string | null;\n periodEnd: string | null;\n customerId: string;\n subscriptionId: string | null;\n createdAt: string;\n}\n\nexport interface CustomerAccessChangedEventData {\n object: 'customer_access_changed';\n externalCustomerId: string;\n accessVersion: number;\n changedSections: readonly string[];\n timestamp: string;\n}\n\n/**\n * Thin catalog change notification. Re-fetch\n * `GET /v1/catalog/products/{productKey}` for the current state.\n */\nexport interface CatalogChangedEventData {\n object: 'catalog_changed';\n productKey: string;\n /** Present for `catalog.plan.updated`. */\n planKey?: string;\n change: 'created' | 'updated' | 'deleted';\n source: 'dashboard' | 'api' | 'code';\n timestamp: string;\n}\n\n/**\n * Thin `credits.granted`: a purchase or a positive adjustment added credits.\n * Re-fetch `GET /v1/credits/{externalCustomerId}` for the current balances.\n */\nexport interface CreditsGrantedEventData {\n object: 'credits_granted';\n /** Null when the customer was never linked to your app's id. */\n externalCustomerId: string | null;\n key: string;\n amount: number;\n /** Balance right after the grant. */\n balance: number;\n reason: 'purchase' | 'adjustment';\n /** Credit ledger entry id. */\n entryId: string;\n /** Payment that granted the credits (purchases only). */\n paymentId?: string;\n subscriptionId?: string;\n timestamp: string;\n}\n\n/**\n * Thin `license_key.created` / `license_key.revoked`. Never carries the key itself:\n * fetch it with `GET /v1/license-keys/{licenseKeyId}`.\n */\nexport interface LicenseKeyChangedEventData {\n object: 'license_key_changed';\n licenseKeyId: string;\n externalCustomerId: string | null;\n productKey: string | null;\n planKey: string | null;\n status: 'active' | 'revoked' | 'expired';\n expiresAt: string | null;\n /** Payment that issued the key. */\n paymentId?: string;\n subscriptionId?: string;\n timestamp: string;\n}\n\nexport type OnflayEvent =\n | (OnflayWebhookEnvelope<PaymentEventData> & { type: 'payment.completed' })\n | (OnflayWebhookEnvelope<PaymentRefundedEventData> & { type: 'payment.refunded' })\n | (OnflayWebhookEnvelope<PayoutEventData> & {\n type: 'payout.scheduled' | 'payout.completed' | 'payout.failed';\n })\n | (OnflayWebhookEnvelope<DisputeEventData> & {\n type: 'dispute.opened' | 'dispute.resolved';\n })\n | (OnflayWebhookEnvelope<SubscriptionEventData> & {\n type:\n | 'subscription.created'\n | 'subscription.renewed'\n | 'subscription.expired'\n | 'subscription.dunning';\n })\n | (OnflayWebhookEnvelope<SubscriptionLifecycleEventData> & {\n type:\n | 'subscription.cancel_scheduled'\n | 'subscription.uncanceled'\n | 'subscription.canceled'\n | 'subscription.updated';\n })\n | (OnflayWebhookEnvelope<InvoiceEventData> & {\n type: 'invoice.created' | 'invoice.finalized' | 'invoice.paid' | 'invoice.payment_failed';\n })\n | (OnflayWebhookEnvelope<CustomerAccessChangedEventData> & {\n type: 'customer.access_changed';\n })\n | (OnflayWebhookEnvelope<CatalogChangedEventData> & {\n type: 'catalog.product.updated' | 'catalog.plan.updated';\n })\n | (OnflayWebhookEnvelope<CreditsGrantedEventData> & { type: 'credits.granted' })\n | (OnflayWebhookEnvelope<LicenseKeyChangedEventData> & {\n type: 'license_key.created' | 'license_key.revoked';\n });\n","/**\n * Webhook signature verification, framework adapters and event types\n * (Standard Webhooks, with the legacy `X-Onflay-Signature` fallback).\n *\n * ```ts\n * import { unwrap } from '@onflay/node/webhooks';\n *\n * export async function POST(req: Request) {\n * const event = unwrap(await req.text(), req.headers, { secret: process.env.ONFLAY_WEBHOOK_SECRET! });\n * if (event.type === 'customer.access_changed') {\n * // refresh the customer's access\n * }\n * return new Response('ok');\n * }\n * ```\n *\n * Framework handlers also have their own entry points: `@onflay/node/webhooks/next`,\n * `@onflay/node/webhooks/express` and `@onflay/node/webhooks/hono`.\n */\nimport { verifyWebhookSignature, type VerifyWebhookOptions, type WebhookHeaders } from './verify';\nimport type { OnflayEvent } from './events';\nexport {\n verifyWebhookSignature,\n verifyStandardWebhook,\n OnflaySignatureError,\n ONFLAY_SIGNATURE_HEADER,\n STANDARD_WEBHOOK_ID_HEADER,\n STANDARD_WEBHOOK_TIMESTAMP_HEADER,\n STANDARD_WEBHOOK_SIGNATURE_HEADER,\n DEFAULT_REPLAY_TOLERANCE_SECONDS,\n} from './verify';\nexport type { VerifyWebhookOptions, VerifiedWebhook, WebhookHeaders } from './verify';\n\nexport { verifyExpressWebhook, createExpressWebhookHandler } from './adapters/express';\nexport { verifyNextWebhook, createNextWebhookHandler } from './adapters/next';\nexport { verifyHonoWebhook, createHonoWebhookHandler } from './adapters/hono';\n\n// Webhook event payload types.\nexport type {\n OnflayEvent,\n OnflayEventType,\n OnflayWebhookEnvelope,\n OnflayMetadata,\n OnflaySubscription,\n OnflayCustomerRef,\n OnflayProductRef,\n OnflayPlanRef,\n OnflaySubscriptionPrice,\n SubscriptionStatus,\n PaymentEventData,\n PaymentRefundedEventData,\n PayoutEventData,\n DisputeEventData,\n SubscriptionEventData,\n SubscriptionLifecycleEventData,\n InvoiceEventData,\n InvoiceLineItem,\n CustomerAccessChangedEventData,\n CatalogChangedEventData,\n CreditsGrantedEventData,\n LicenseKeyChangedEventData,\n} from './events';\nexport { ONFLAY_EVENT_TYPES } from './events';\n\n/**\n * Verifies a webhook delivery and returns its event. Throws `OnflaySignatureError` when the\n * signature is missing, invalid or outside the replay window. `rawBody` must be the exact\n * request body (do not re-serialize parsed JSON).\n */\nexport function unwrap<TEvent = OnflayEvent>(rawBody: string, headers: WebhookHeaders, options: VerifyWebhookOptions): TEvent {\n return verifyWebhookSignature<TEvent>(rawBody, headers, options).event;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2EO,IAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;AChCO,SAAS,OAA6B,SAAiB,SAAyB,SAAuC;AAC5H,SAAO,uBAA+B,SAAS,SAAS,OAAO,EAAE;AACnE;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { V as VerifyWebhookOptions, O as OnflayEvent, w as VerifiedWebhook, l as OnflaySignatureError } from '../verify-tF2BsJK6.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Verify the signature of an inbound Next.js App Router `Request`. Reads
|
|
5
|
+
* the raw text body once; subsequent attempts to parse the body in your
|
|
6
|
+
* handler will fail since the stream is consumed.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { verifyNextWebhook } from '@onflay/node/webhooks/next';
|
|
10
|
+
*
|
|
11
|
+
* export async function POST(req: Request) {
|
|
12
|
+
* const { event } = await verifyNextWebhook(req, {
|
|
13
|
+
* secret: process.env.ONFLAY_WEBHOOK_SECRET!,
|
|
14
|
+
* });
|
|
15
|
+
* // handle event…
|
|
16
|
+
* return new Response('ok');
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function verifyNextWebhook<TEvent = OnflayEvent>(request: Request, options: VerifyWebhookOptions): Promise<VerifiedWebhook<TEvent>>;
|
|
21
|
+
interface NextHandlerOptions extends VerifyWebhookOptions {
|
|
22
|
+
onEvent: (event: OnflayEvent, raw: VerifiedWebhook<OnflayEvent>) => unknown | Promise<unknown>;
|
|
23
|
+
onError?: (error: OnflaySignatureError | Error) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns a Next.js Route Handler `(req: Request) => Response` that
|
|
27
|
+
* verifies the signature and dispatches to your `onEvent` callback.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* export const POST = createNextWebhookHandler({
|
|
31
|
+
* secret: process.env.ONFLAY_WEBHOOK_SECRET!,
|
|
32
|
+
* onEvent: async (event) => { …handle… },
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function createNextWebhookHandler(opts: NextHandlerOptions): (request: Request) => Promise<Response>;
|
|
37
|
+
|
|
38
|
+
export { createNextWebhookHandler, verifyNextWebhook };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { V as VerifyWebhookOptions, O as OnflayEvent, w as VerifiedWebhook, l as OnflaySignatureError } from '../verify-tF2BsJK6.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Verify the signature of an inbound Next.js App Router `Request`. Reads
|
|
5
|
+
* the raw text body once; subsequent attempts to parse the body in your
|
|
6
|
+
* handler will fail since the stream is consumed.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { verifyNextWebhook } from '@onflay/node/webhooks/next';
|
|
10
|
+
*
|
|
11
|
+
* export async function POST(req: Request) {
|
|
12
|
+
* const { event } = await verifyNextWebhook(req, {
|
|
13
|
+
* secret: process.env.ONFLAY_WEBHOOK_SECRET!,
|
|
14
|
+
* });
|
|
15
|
+
* // handle event…
|
|
16
|
+
* return new Response('ok');
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function verifyNextWebhook<TEvent = OnflayEvent>(request: Request, options: VerifyWebhookOptions): Promise<VerifiedWebhook<TEvent>>;
|
|
21
|
+
interface NextHandlerOptions extends VerifyWebhookOptions {
|
|
22
|
+
onEvent: (event: OnflayEvent, raw: VerifiedWebhook<OnflayEvent>) => unknown | Promise<unknown>;
|
|
23
|
+
onError?: (error: OnflaySignatureError | Error) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns a Next.js Route Handler `(req: Request) => Response` that
|
|
27
|
+
* verifies the signature and dispatches to your `onEvent` callback.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* export const POST = createNextWebhookHandler({
|
|
31
|
+
* secret: process.env.ONFLAY_WEBHOOK_SECRET!,
|
|
32
|
+
* onEvent: async (event) => { …handle… },
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function createNextWebhookHandler(opts: NextHandlerOptions): (request: Request) => Promise<Response>;
|
|
37
|
+
|
|
38
|
+
export { createNextWebhookHandler, verifyNextWebhook };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkMMMUKAI6js = require('../chunk-MMMUKAI6.js');
|
|
5
|
+
require('../chunk-I2IVHBFA.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.createNextWebhookHandler = _chunkMMMUKAI6js.createNextWebhookHandler; exports.verifyNextWebhook = _chunkMMMUKAI6js.verifyNextWebhook;
|
|
10
|
+
//# sourceMappingURL=next.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/onflay/onflay/sdks/node/dist/webhooks/next.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,6IAAC","file":"/home/runner/work/onflay/onflay/sdks/node/dist/webhooks/next.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,27 +1,281 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onflay/node",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Official
|
|
3
|
+
"version": "1.0.0-staging-20261206080029",
|
|
4
|
+
"description": "Official TypeScript SDK for the Onflay API (payments, subscriptions, catalog, customer access, webhooks).",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"./models/errors": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/models/errors/index.d.mts",
|
|
23
|
+
"default": "./dist/models/errors/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/models/errors/index.d.ts",
|
|
27
|
+
"default": "./dist/models/errors/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"./models/errors/index.js": {
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/models/errors/index.d.mts",
|
|
33
|
+
"default": "./dist/models/errors/index.mjs"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/models/errors/index.d.ts",
|
|
37
|
+
"default": "./dist/models/errors/index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"./models/components": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/models/components/index.d.mts",
|
|
43
|
+
"default": "./dist/models/components/index.mjs"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/models/components/index.d.ts",
|
|
47
|
+
"default": "./dist/models/components/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"./models/components/index.js": {
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/models/components/index.d.mts",
|
|
53
|
+
"default": "./dist/models/components/index.mjs"
|
|
54
|
+
},
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./dist/models/components/index.d.ts",
|
|
57
|
+
"default": "./dist/models/components/index.js"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"./models/operations": {
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/models/operations/index.d.mts",
|
|
63
|
+
"default": "./dist/models/operations/index.mjs"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/models/operations/index.d.ts",
|
|
67
|
+
"default": "./dist/models/operations/index.js"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"./models/operations/index.js": {
|
|
71
|
+
"import": {
|
|
72
|
+
"types": "./dist/models/operations/index.d.mts",
|
|
73
|
+
"default": "./dist/models/operations/index.mjs"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./dist/models/operations/index.d.ts",
|
|
77
|
+
"default": "./dist/models/operations/index.js"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"./lib/config": {
|
|
81
|
+
"import": {
|
|
82
|
+
"types": "./dist/lib/config.d.mts",
|
|
83
|
+
"default": "./dist/lib/config.mjs"
|
|
84
|
+
},
|
|
85
|
+
"require": {
|
|
86
|
+
"types": "./dist/lib/config.d.ts",
|
|
87
|
+
"default": "./dist/lib/config.js"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"./lib/config.js": {
|
|
91
|
+
"import": {
|
|
92
|
+
"types": "./dist/lib/config.d.mts",
|
|
93
|
+
"default": "./dist/lib/config.mjs"
|
|
94
|
+
},
|
|
95
|
+
"require": {
|
|
96
|
+
"types": "./dist/lib/config.d.ts",
|
|
97
|
+
"default": "./dist/lib/config.js"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"./lib/http": {
|
|
101
|
+
"import": {
|
|
102
|
+
"types": "./dist/lib/http.d.mts",
|
|
103
|
+
"default": "./dist/lib/http.mjs"
|
|
104
|
+
},
|
|
105
|
+
"require": {
|
|
106
|
+
"types": "./dist/lib/http.d.ts",
|
|
107
|
+
"default": "./dist/lib/http.js"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"./lib/http.js": {
|
|
111
|
+
"import": {
|
|
112
|
+
"types": "./dist/lib/http.d.mts",
|
|
113
|
+
"default": "./dist/lib/http.mjs"
|
|
114
|
+
},
|
|
115
|
+
"require": {
|
|
116
|
+
"types": "./dist/lib/http.d.ts",
|
|
117
|
+
"default": "./dist/lib/http.js"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"./lib/retries": {
|
|
121
|
+
"import": {
|
|
122
|
+
"types": "./dist/lib/retries.d.mts",
|
|
123
|
+
"default": "./dist/lib/retries.mjs"
|
|
124
|
+
},
|
|
125
|
+
"require": {
|
|
126
|
+
"types": "./dist/lib/retries.d.ts",
|
|
127
|
+
"default": "./dist/lib/retries.js"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"./lib/retries.js": {
|
|
131
|
+
"import": {
|
|
132
|
+
"types": "./dist/lib/retries.d.mts",
|
|
133
|
+
"default": "./dist/lib/retries.mjs"
|
|
134
|
+
},
|
|
135
|
+
"require": {
|
|
136
|
+
"types": "./dist/lib/retries.d.ts",
|
|
137
|
+
"default": "./dist/lib/retries.js"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"./lib/sdks": {
|
|
141
|
+
"import": {
|
|
142
|
+
"types": "./dist/lib/sdks.d.mts",
|
|
143
|
+
"default": "./dist/lib/sdks.mjs"
|
|
144
|
+
},
|
|
145
|
+
"require": {
|
|
146
|
+
"types": "./dist/lib/sdks.d.ts",
|
|
147
|
+
"default": "./dist/lib/sdks.js"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"./lib/sdks.js": {
|
|
151
|
+
"import": {
|
|
152
|
+
"types": "./dist/lib/sdks.d.mts",
|
|
153
|
+
"default": "./dist/lib/sdks.mjs"
|
|
154
|
+
},
|
|
155
|
+
"require": {
|
|
156
|
+
"types": "./dist/lib/sdks.d.ts",
|
|
157
|
+
"default": "./dist/lib/sdks.js"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"./types": {
|
|
161
|
+
"import": {
|
|
162
|
+
"types": "./dist/types/index.d.mts",
|
|
163
|
+
"default": "./dist/types/index.mjs"
|
|
164
|
+
},
|
|
165
|
+
"require": {
|
|
166
|
+
"types": "./dist/types/index.d.ts",
|
|
167
|
+
"default": "./dist/types/index.js"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"./types/index.js": {
|
|
171
|
+
"import": {
|
|
172
|
+
"types": "./dist/types/index.d.mts",
|
|
173
|
+
"default": "./dist/types/index.mjs"
|
|
174
|
+
},
|
|
175
|
+
"require": {
|
|
176
|
+
"types": "./dist/types/index.d.ts",
|
|
177
|
+
"default": "./dist/types/index.js"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"./webhooks": {
|
|
181
|
+
"import": {
|
|
182
|
+
"types": "./dist/webhooks/index.d.mts",
|
|
183
|
+
"default": "./dist/webhooks/index.mjs"
|
|
184
|
+
},
|
|
185
|
+
"require": {
|
|
186
|
+
"types": "./dist/webhooks/index.d.ts",
|
|
187
|
+
"default": "./dist/webhooks/index.js"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"./webhooks.js": {
|
|
191
|
+
"import": {
|
|
192
|
+
"types": "./dist/webhooks/index.d.mts",
|
|
193
|
+
"default": "./dist/webhooks/index.mjs"
|
|
194
|
+
},
|
|
195
|
+
"require": {
|
|
196
|
+
"types": "./dist/webhooks/index.d.ts",
|
|
197
|
+
"default": "./dist/webhooks/index.js"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"./webhooks/next": {
|
|
201
|
+
"import": {
|
|
202
|
+
"types": "./dist/webhooks/next.d.mts",
|
|
203
|
+
"default": "./dist/webhooks/next.mjs"
|
|
204
|
+
},
|
|
205
|
+
"require": {
|
|
206
|
+
"types": "./dist/webhooks/next.d.ts",
|
|
207
|
+
"default": "./dist/webhooks/next.js"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"./webhooks/express": {
|
|
211
|
+
"import": {
|
|
212
|
+
"types": "./dist/webhooks/express.d.mts",
|
|
213
|
+
"default": "./dist/webhooks/express.mjs"
|
|
214
|
+
},
|
|
215
|
+
"require": {
|
|
216
|
+
"types": "./dist/webhooks/express.d.ts",
|
|
217
|
+
"default": "./dist/webhooks/express.js"
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
"./webhooks/hono": {
|
|
221
|
+
"import": {
|
|
222
|
+
"types": "./dist/webhooks/hono.d.mts",
|
|
223
|
+
"default": "./dist/webhooks/hono.mjs"
|
|
224
|
+
},
|
|
225
|
+
"require": {
|
|
226
|
+
"types": "./dist/webhooks/hono.d.ts",
|
|
227
|
+
"default": "./dist/webhooks/hono.js"
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
"./package.json": "./package.json"
|
|
231
|
+
},
|
|
232
|
+
"typesVersions": {
|
|
233
|
+
"*": {
|
|
234
|
+
"models/errors": [
|
|
235
|
+
"./dist/models/errors/index.d.ts"
|
|
236
|
+
],
|
|
237
|
+
"models/components": [
|
|
238
|
+
"./dist/models/components/index.d.ts"
|
|
239
|
+
],
|
|
240
|
+
"models/operations": [
|
|
241
|
+
"./dist/models/operations/index.d.ts"
|
|
242
|
+
],
|
|
243
|
+
"lib/config": [
|
|
244
|
+
"./dist/lib/config.d.ts"
|
|
245
|
+
],
|
|
246
|
+
"lib/http": [
|
|
247
|
+
"./dist/lib/http.d.ts"
|
|
248
|
+
],
|
|
249
|
+
"lib/retries": [
|
|
250
|
+
"./dist/lib/retries.d.ts"
|
|
251
|
+
],
|
|
252
|
+
"lib/sdks": [
|
|
253
|
+
"./dist/lib/sdks.d.ts"
|
|
254
|
+
],
|
|
255
|
+
"types": [
|
|
256
|
+
"./dist/types/index.d.ts"
|
|
257
|
+
],
|
|
258
|
+
"webhooks": [
|
|
259
|
+
"./dist/webhooks.d.ts"
|
|
260
|
+
]
|
|
13
261
|
}
|
|
14
262
|
},
|
|
15
263
|
"files": [
|
|
16
264
|
"dist",
|
|
17
|
-
"README.md"
|
|
265
|
+
"README.md",
|
|
266
|
+
"CHANGELOG.md"
|
|
18
267
|
],
|
|
19
268
|
"engines": {
|
|
20
269
|
"node": ">=20.0.0"
|
|
21
270
|
},
|
|
271
|
+
"sideEffects": false,
|
|
22
272
|
"devDependencies": {
|
|
273
|
+
"@hey-api/openapi-ts": "0.99.0",
|
|
23
274
|
"@types/node": "^22.0.0",
|
|
24
|
-
"
|
|
275
|
+
"standardwebhooks": "^1.3.0",
|
|
276
|
+
"tsup": "^8.5.0",
|
|
277
|
+
"typescript": "^5.7.0",
|
|
278
|
+
"vitest": "^3"
|
|
25
279
|
},
|
|
26
280
|
"publishConfig": {
|
|
27
281
|
"access": "public"
|
|
@@ -31,13 +285,18 @@
|
|
|
31
285
|
"payments",
|
|
32
286
|
"subscriptions",
|
|
33
287
|
"merchant-of-record",
|
|
34
|
-
"sdk"
|
|
288
|
+
"sdk",
|
|
289
|
+
"typescript",
|
|
290
|
+
"webhooks"
|
|
35
291
|
],
|
|
36
292
|
"scripts": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
293
|
+
"generate": "node scripts/generate.mjs",
|
|
294
|
+
"generate:check": "node scripts/generate.mjs --check",
|
|
295
|
+
"build": "node scripts/gen-version.mjs && tsup",
|
|
296
|
+
"dev": "node scripts/gen-version.mjs && tsup --watch",
|
|
297
|
+
"typecheck": "node scripts/gen-version.mjs && tsc -p tsconfig.json",
|
|
39
298
|
"clean": "rm -rf dist .turbo",
|
|
40
|
-
"test": "
|
|
41
|
-
"lint": "
|
|
299
|
+
"test": "node scripts/gen-version.mjs && vitest run",
|
|
300
|
+
"lint": "tsc -p tsconfig.json"
|
|
42
301
|
}
|
|
43
302
|
}
|