@polar-sh/sdk 0.29.0 → 0.29.2
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/FUNCTIONS.md +5 -1
- package/README.md +48 -12
- package/bin/mcp-server.js +866 -148
- package/bin/mcp-server.js.map +29 -14
- package/dist/commonjs/funcs/customersGetState.d.ts +27 -0
- package/dist/commonjs/funcs/customersGetState.d.ts.map +1 -0
- package/dist/commonjs/funcs/customersGetState.js +121 -0
- package/dist/commonjs/funcs/customersGetState.js.map +1 -0
- package/dist/commonjs/funcs/customersGetStateExternal.d.ts +27 -0
- package/dist/commonjs/funcs/customersGetStateExternal.d.ts.map +1 -0
- package/dist/commonjs/funcs/customersGetStateExternal.js +121 -0
- package/dist/commonjs/funcs/customersGetStateExternal.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/mcp-server/mcp-server.js +1 -1
- package/dist/commonjs/mcp-server/server.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/server.js +5 -1
- package/dist/commonjs/mcp-server/server.js.map +1 -1
- package/dist/commonjs/mcp-server/tools/customersGetState.d.ts +7 -0
- package/dist/commonjs/mcp-server/tools/customersGetState.d.ts.map +1 -0
- package/dist/commonjs/mcp-server/tools/customersGetState.js +40 -0
- package/dist/commonjs/mcp-server/tools/customersGetState.js.map +1 -0
- package/dist/commonjs/mcp-server/tools/customersGetStateExternal.d.ts +7 -0
- package/dist/commonjs/mcp-server/tools/customersGetStateExternal.d.ts.map +1 -0
- package/dist/commonjs/mcp-server/tools/customersGetStateExternal.js +40 -0
- package/dist/commonjs/mcp-server/tools/customersGetStateExternal.js.map +1 -0
- package/dist/commonjs/models/components/customer.d.ts +11 -5
- package/dist/commonjs/models/components/customer.d.ts.map +1 -1
- package/dist/commonjs/models/components/customer.js +2 -2
- package/dist/commonjs/models/components/customer.js.map +1 -1
- package/dist/commonjs/models/components/customercreate.d.ts +3 -0
- package/dist/commonjs/models/components/customercreate.d.ts.map +1 -1
- package/dist/commonjs/models/components/customercreate.js.map +1 -1
- package/dist/commonjs/models/components/customerordersubscription.d.ts +39 -0
- package/dist/commonjs/models/components/customerordersubscription.d.ts.map +1 -1
- package/dist/commonjs/models/components/customerordersubscription.js.map +1 -1
- package/dist/commonjs/models/components/customerstate.d.ts +143 -0
- package/dist/commonjs/models/components/customerstate.d.ts.map +1 -0
- package/dist/commonjs/models/components/customerstate.js +162 -0
- package/dist/commonjs/models/components/customerstate.js.map +1 -0
- package/dist/commonjs/models/components/customerstatebenefitgrant.d.ts +86 -0
- package/dist/commonjs/models/components/customerstatebenefitgrant.d.ts.map +1 -0
- package/dist/commonjs/models/components/customerstatebenefitgrant.js +141 -0
- package/dist/commonjs/models/components/customerstatebenefitgrant.js.map +1 -0
- package/dist/commonjs/models/components/customerstatesubscription.d.ts +162 -0
- package/dist/commonjs/models/components/customerstatesubscription.d.ts.map +1 -0
- package/dist/commonjs/models/components/customerstatesubscription.js +193 -0
- package/dist/commonjs/models/components/customerstatesubscription.js.map +1 -0
- package/dist/commonjs/models/components/customersubscription.d.ts +9 -0
- package/dist/commonjs/models/components/customersubscription.d.ts.map +1 -1
- package/dist/commonjs/models/components/customersubscription.js.map +1 -1
- package/dist/commonjs/models/components/customerupdate.d.ts +3 -0
- package/dist/commonjs/models/components/customerupdate.d.ts.map +1 -1
- package/dist/commonjs/models/components/customerupdate.js.map +1 -1
- package/dist/commonjs/models/components/licensekeycustomer.d.ts +11 -5
- package/dist/commonjs/models/components/licensekeycustomer.d.ts.map +1 -1
- package/dist/commonjs/models/components/licensekeycustomer.js +2 -2
- package/dist/commonjs/models/components/licensekeycustomer.js.map +1 -1
- package/dist/commonjs/models/components/ordercustomer.d.ts +11 -5
- package/dist/commonjs/models/components/ordercustomer.d.ts.map +1 -1
- package/dist/commonjs/models/components/ordercustomer.js +2 -2
- package/dist/commonjs/models/components/ordercustomer.js.map +1 -1
- package/dist/commonjs/models/components/ordersubscription.d.ts +39 -0
- package/dist/commonjs/models/components/ordersubscription.d.ts.map +1 -1
- package/dist/commonjs/models/components/ordersubscription.js.map +1 -1
- package/dist/commonjs/models/components/subscription.d.ts +39 -0
- package/dist/commonjs/models/components/subscription.d.ts.map +1 -1
- package/dist/commonjs/models/components/subscription.js.map +1 -1
- package/dist/commonjs/models/components/subscriptioncustomer.d.ts +11 -5
- package/dist/commonjs/models/components/subscriptioncustomer.d.ts.map +1 -1
- package/dist/commonjs/models/components/subscriptioncustomer.js +2 -2
- package/dist/commonjs/models/components/subscriptioncustomer.js.map +1 -1
- package/dist/commonjs/models/components/webhookcustomercreatedpayload.d.ts +47 -0
- package/dist/commonjs/models/components/webhookcustomercreatedpayload.d.ts.map +1 -0
- package/dist/commonjs/models/components/webhookcustomercreatedpayload.js +62 -0
- package/dist/commonjs/models/components/webhookcustomercreatedpayload.js.map +1 -0
- package/dist/commonjs/models/components/webhookcustomerdeletedpayload.d.ts +42 -0
- package/dist/commonjs/models/components/webhookcustomerdeletedpayload.d.ts.map +1 -0
- package/dist/commonjs/models/components/webhookcustomerdeletedpayload.js +62 -0
- package/dist/commonjs/models/components/webhookcustomerdeletedpayload.js.map +1 -0
- package/dist/commonjs/models/components/webhookcustomerstatechangedpayload.d.ts +53 -0
- package/dist/commonjs/models/components/webhookcustomerstatechangedpayload.d.ts.map +1 -0
- package/dist/commonjs/models/components/webhookcustomerstatechangedpayload.js +62 -0
- package/dist/commonjs/models/components/webhookcustomerstatechangedpayload.js.map +1 -0
- package/dist/commonjs/models/components/webhookcustomerupdatedpayload.d.ts +46 -0
- package/dist/commonjs/models/components/webhookcustomerupdatedpayload.d.ts.map +1 -0
- package/dist/commonjs/models/components/webhookcustomerupdatedpayload.js +62 -0
- package/dist/commonjs/models/components/webhookcustomerupdatedpayload.js.map +1 -0
- package/dist/commonjs/models/components/webhookordercreatedpayload.d.ts +7 -0
- package/dist/commonjs/models/components/webhookordercreatedpayload.d.ts.map +1 -1
- package/dist/commonjs/models/components/webhookordercreatedpayload.js.map +1 -1
- package/dist/commonjs/models/components/webhooksubscriptioncreatedpayload.d.ts +2 -0
- package/dist/commonjs/models/components/webhooksubscriptioncreatedpayload.d.ts.map +1 -1
- package/dist/commonjs/models/components/webhooksubscriptioncreatedpayload.js.map +1 -1
- package/dist/commonjs/models/operations/customersgetstate.d.ts +32 -0
- package/dist/commonjs/models/operations/customersgetstate.d.ts.map +1 -0
- package/dist/commonjs/models/operations/customersgetstate.js +59 -0
- package/dist/commonjs/models/operations/customersgetstate.js.map +1 -0
- package/dist/commonjs/models/operations/customersgetstateexternal.d.ts +32 -0
- package/dist/commonjs/models/operations/customersgetstateexternal.d.ts.map +1 -0
- package/dist/commonjs/models/operations/customersgetstateexternal.js +68 -0
- package/dist/commonjs/models/operations/customersgetstateexternal.js.map +1 -0
- package/dist/commonjs/sdk/customers.d.ts +33 -0
- package/dist/commonjs/sdk/customers.d.ts.map +1 -1
- package/dist/commonjs/sdk/customers.js +36 -0
- package/dist/commonjs/sdk/customers.js.map +1 -1
- package/dist/commonjs/webhooks.d.ts +2 -2
- package/dist/commonjs/webhooks.d.ts.map +1 -1
- package/dist/commonjs/webhooks.js +36 -24
- package/dist/commonjs/webhooks.js.map +1 -1
- package/dist/esm/funcs/customersGetState.d.ts +27 -0
- package/dist/esm/funcs/customersGetState.d.ts.map +1 -0
- package/dist/esm/funcs/customersGetState.js +95 -0
- package/dist/esm/funcs/customersGetState.js.map +1 -0
- package/dist/esm/funcs/customersGetStateExternal.d.ts +27 -0
- package/dist/esm/funcs/customersGetStateExternal.d.ts.map +1 -0
- package/dist/esm/funcs/customersGetStateExternal.js +95 -0
- package/dist/esm/funcs/customersGetStateExternal.js.map +1 -0
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/mcp-server/mcp-server.js +1 -1
- package/dist/esm/mcp-server/server.d.ts.map +1 -1
- package/dist/esm/mcp-server/server.js +5 -1
- package/dist/esm/mcp-server/server.js.map +1 -1
- package/dist/esm/mcp-server/tools/customersGetState.d.ts +7 -0
- package/dist/esm/mcp-server/tools/customersGetState.d.ts.map +1 -0
- package/dist/esm/mcp-server/tools/customersGetState.js +37 -0
- package/dist/esm/mcp-server/tools/customersGetState.js.map +1 -0
- package/dist/esm/mcp-server/tools/customersGetStateExternal.d.ts +7 -0
- package/dist/esm/mcp-server/tools/customersGetStateExternal.d.ts.map +1 -0
- package/dist/esm/mcp-server/tools/customersGetStateExternal.js +37 -0
- package/dist/esm/mcp-server/tools/customersGetStateExternal.js.map +1 -0
- package/dist/esm/models/components/customer.d.ts +11 -5
- package/dist/esm/models/components/customer.d.ts.map +1 -1
- package/dist/esm/models/components/customer.js +2 -2
- package/dist/esm/models/components/customer.js.map +1 -1
- package/dist/esm/models/components/customercreate.d.ts +3 -0
- package/dist/esm/models/components/customercreate.d.ts.map +1 -1
- package/dist/esm/models/components/customercreate.js.map +1 -1
- package/dist/esm/models/components/customerordersubscription.d.ts +39 -0
- package/dist/esm/models/components/customerordersubscription.d.ts.map +1 -1
- package/dist/esm/models/components/customerordersubscription.js.map +1 -1
- package/dist/esm/models/components/customerstate.d.ts +143 -0
- package/dist/esm/models/components/customerstate.d.ts.map +1 -0
- package/dist/esm/models/components/customerstate.js +130 -0
- package/dist/esm/models/components/customerstate.js.map +1 -0
- package/dist/esm/models/components/customerstatebenefitgrant.d.ts +86 -0
- package/dist/esm/models/components/customerstatebenefitgrant.d.ts.map +1 -0
- package/dist/esm/models/components/customerstatebenefitgrant.js +111 -0
- package/dist/esm/models/components/customerstatebenefitgrant.js.map +1 -0
- package/dist/esm/models/components/customerstatesubscription.d.ts +162 -0
- package/dist/esm/models/components/customerstatesubscription.d.ts.map +1 -0
- package/dist/esm/models/components/customerstatesubscription.js +161 -0
- package/dist/esm/models/components/customerstatesubscription.js.map +1 -0
- package/dist/esm/models/components/customersubscription.d.ts +9 -0
- package/dist/esm/models/components/customersubscription.d.ts.map +1 -1
- package/dist/esm/models/components/customersubscription.js.map +1 -1
- package/dist/esm/models/components/customerupdate.d.ts +3 -0
- package/dist/esm/models/components/customerupdate.d.ts.map +1 -1
- package/dist/esm/models/components/customerupdate.js.map +1 -1
- package/dist/esm/models/components/licensekeycustomer.d.ts +11 -5
- package/dist/esm/models/components/licensekeycustomer.d.ts.map +1 -1
- package/dist/esm/models/components/licensekeycustomer.js +2 -2
- package/dist/esm/models/components/licensekeycustomer.js.map +1 -1
- package/dist/esm/models/components/ordercustomer.d.ts +11 -5
- package/dist/esm/models/components/ordercustomer.d.ts.map +1 -1
- package/dist/esm/models/components/ordercustomer.js +2 -2
- package/dist/esm/models/components/ordercustomer.js.map +1 -1
- package/dist/esm/models/components/ordersubscription.d.ts +39 -0
- package/dist/esm/models/components/ordersubscription.d.ts.map +1 -1
- package/dist/esm/models/components/ordersubscription.js.map +1 -1
- package/dist/esm/models/components/subscription.d.ts +39 -0
- package/dist/esm/models/components/subscription.d.ts.map +1 -1
- package/dist/esm/models/components/subscription.js.map +1 -1
- package/dist/esm/models/components/subscriptioncustomer.d.ts +11 -5
- package/dist/esm/models/components/subscriptioncustomer.d.ts.map +1 -1
- package/dist/esm/models/components/subscriptioncustomer.js +2 -2
- package/dist/esm/models/components/subscriptioncustomer.js.map +1 -1
- package/dist/esm/models/components/webhookcustomercreatedpayload.d.ts +47 -0
- package/dist/esm/models/components/webhookcustomercreatedpayload.d.ts.map +1 -0
- package/dist/esm/models/components/webhookcustomercreatedpayload.js +34 -0
- package/dist/esm/models/components/webhookcustomercreatedpayload.js.map +1 -0
- package/dist/esm/models/components/webhookcustomerdeletedpayload.d.ts +42 -0
- package/dist/esm/models/components/webhookcustomerdeletedpayload.d.ts.map +1 -0
- package/dist/esm/models/components/webhookcustomerdeletedpayload.js +34 -0
- package/dist/esm/models/components/webhookcustomerdeletedpayload.js.map +1 -0
- package/dist/esm/models/components/webhookcustomerstatechangedpayload.d.ts +53 -0
- package/dist/esm/models/components/webhookcustomerstatechangedpayload.d.ts.map +1 -0
- package/dist/esm/models/components/webhookcustomerstatechangedpayload.js +34 -0
- package/dist/esm/models/components/webhookcustomerstatechangedpayload.js.map +1 -0
- package/dist/esm/models/components/webhookcustomerupdatedpayload.d.ts +46 -0
- package/dist/esm/models/components/webhookcustomerupdatedpayload.d.ts.map +1 -0
- package/dist/esm/models/components/webhookcustomerupdatedpayload.js +34 -0
- package/dist/esm/models/components/webhookcustomerupdatedpayload.js.map +1 -0
- package/dist/esm/models/components/webhookordercreatedpayload.d.ts +7 -0
- package/dist/esm/models/components/webhookordercreatedpayload.d.ts.map +1 -1
- package/dist/esm/models/components/webhookordercreatedpayload.js.map +1 -1
- package/dist/esm/models/components/webhooksubscriptioncreatedpayload.d.ts +2 -0
- package/dist/esm/models/components/webhooksubscriptioncreatedpayload.d.ts.map +1 -1
- package/dist/esm/models/components/webhooksubscriptioncreatedpayload.js.map +1 -1
- package/dist/esm/models/operations/customersgetstate.d.ts +32 -0
- package/dist/esm/models/operations/customersgetstate.d.ts.map +1 -0
- package/dist/esm/models/operations/customersgetstate.js +31 -0
- package/dist/esm/models/operations/customersgetstate.js.map +1 -0
- package/dist/esm/models/operations/customersgetstateexternal.d.ts +32 -0
- package/dist/esm/models/operations/customersgetstateexternal.d.ts.map +1 -0
- package/dist/esm/models/operations/customersgetstateexternal.js +40 -0
- package/dist/esm/models/operations/customersgetstateexternal.js.map +1 -0
- package/dist/esm/sdk/customers.d.ts +33 -0
- package/dist/esm/sdk/customers.d.ts.map +1 -1
- package/dist/esm/sdk/customers.js +36 -0
- package/dist/esm/sdk/customers.js.map +1 -1
- package/dist/esm/webhooks.d.ts +2 -2
- package/dist/esm/webhooks.d.ts.map +1 -1
- package/dist/esm/webhooks.js +39 -27
- package/dist/esm/webhooks.js.map +1 -1
- package/docs/sdks/benefitgrants/README.md +10 -2
- package/docs/sdks/benefits/README.md +12 -2
- package/docs/sdks/checkoutlinks/README.md +10 -2
- package/docs/sdks/checkouts/README.md +16 -2
- package/docs/sdks/customers/README.md +206 -4
- package/docs/sdks/customfields/README.md +12 -2
- package/docs/sdks/discounts/README.md +12 -2
- package/docs/sdks/downloadables/README.md +10 -2
- package/docs/sdks/events/README.md +14 -2
- package/docs/sdks/externalorganizations/README.md +10 -2
- package/docs/sdks/files/README.md +8 -2
- package/docs/sdks/licensekeys/README.md +10 -2
- package/docs/sdks/meters/README.md +12 -2
- package/docs/sdks/metrics/README.md +6 -0
- package/docs/sdks/orders/README.md +10 -2
- package/docs/sdks/organizations/README.md +4 -4
- package/docs/sdks/polarlicensekeys/README.md +10 -2
- package/docs/sdks/polarorders/README.md +10 -2
- package/docs/sdks/polarsubscriptions/README.md +10 -2
- package/docs/sdks/products/README.md +12 -2
- package/docs/sdks/refunds/README.md +10 -2
- package/docs/sdks/repositories/README.md +10 -2
- package/docs/sdks/subscriptions/README.md +20 -4
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/customersGetState.ts +195 -0
- package/src/funcs/customersGetStateExternal.ts +197 -0
- package/src/lib/config.ts +2 -2
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +5 -1
- package/src/mcp-server/tools/customersGetState.ts +46 -0
- package/src/mcp-server/tools/customersGetStateExternal.ts +46 -0
- package/src/models/components/customer.ts +13 -7
- package/src/models/components/customercreate.ts +3 -0
- package/src/models/components/customerordersubscription.ts +39 -0
- package/src/models/components/customerstate.ts +308 -0
- package/src/models/components/customerstatebenefitgrant.ts +261 -0
- package/src/models/components/customerstatesubscription.ts +389 -0
- package/src/models/components/customersubscription.ts +9 -0
- package/src/models/components/customerupdate.ts +3 -0
- package/src/models/components/licensekeycustomer.ts +13 -7
- package/src/models/components/ordercustomer.ts +13 -7
- package/src/models/components/ordersubscription.ts +39 -0
- package/src/models/components/subscription.ts +39 -0
- package/src/models/components/subscriptioncustomer.ts +13 -7
- package/src/models/components/webhookcustomercreatedpayload.ts +93 -0
- package/src/models/components/webhookcustomerdeletedpayload.ts +88 -0
- package/src/models/components/webhookcustomerstatechangedpayload.ts +103 -0
- package/src/models/components/webhookcustomerupdatedpayload.ts +92 -0
- package/src/models/components/webhookordercreatedpayload.ts +7 -0
- package/src/models/components/webhooksubscriptioncreatedpayload.ts +2 -0
- package/src/models/operations/customersgetstate.ts +69 -0
- package/src/models/operations/customersgetstateexternal.ts +80 -0
- package/src/sdk/customers.ts +55 -0
- package/src/webhooks.ts +95 -78
package/src/webhooks.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Webhook, WebhookVerificationError as _WebhookVerificationError } from "standardwebhooks"
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Webhook,
|
|
3
|
+
WebhookVerificationError as _WebhookVerificationError,
|
|
4
|
+
} from "standardwebhooks";
|
|
5
|
+
|
|
6
|
+
import { WebhookBenefitCreatedPayload$inboundSchema } from "./models/components/webhookbenefitcreatedpayload.js";
|
|
6
7
|
import { WebhookBenefitGrantCreatedPayload$inboundSchema } from "./models/components/webhookbenefitgrantcreatedpayload.js";
|
|
7
8
|
import { WebhookBenefitGrantRevokedPayload$inboundSchema } from "./models/components/webhookbenefitgrantrevokedpayload.js";
|
|
8
9
|
import { WebhookBenefitGrantUpdatedPayload$inboundSchema } from "./models/components/webhookbenefitgrantupdatedpayload.js";
|
|
@@ -22,88 +23,104 @@ import { WebhookSubscriptionActivePayload$inboundSchema } from "./models/compone
|
|
|
22
23
|
import { WebhookSubscriptionCanceledPayload$inboundSchema } from "./models/components/webhooksubscriptioncanceledpayload.js";
|
|
23
24
|
import { WebhookSubscriptionCreatedPayload$inboundSchema } from "./models/components/webhooksubscriptioncreatedpayload.js";
|
|
24
25
|
import { WebhookSubscriptionRevokedPayload$inboundSchema } from "./models/components/webhooksubscriptionrevokedpayload.js";
|
|
25
|
-
import { WebhookSubscriptionUncanceledPayload$inboundSchema} from "./models/components/webhooksubscriptionuncanceledpayload.js";
|
|
26
|
+
import { WebhookSubscriptionUncanceledPayload$inboundSchema } from "./models/components/webhooksubscriptionuncanceledpayload.js";
|
|
26
27
|
import { WebhookSubscriptionUpdatedPayload$inboundSchema } from "./models/components/webhooksubscriptionupdatedpayload.js";
|
|
28
|
+
import { WebhookCustomerCreatedPayload$inboundSchema } from "./models/components/webhookcustomercreatedpayload.js";
|
|
29
|
+
import { WebhookCustomerUpdatedPayload$inboundSchema } from "./models/components/webhookcustomerupdatedpayload.js";
|
|
30
|
+
import { WebhookCustomerDeletedPayload$inboundSchema } from "./models/components/webhookcustomerdeletedpayload.js";
|
|
31
|
+
import { WebhookCustomerStateChangedPayload$inboundSchema } from "./models/components/webhookcustomerstatechangedpayload.js";
|
|
27
32
|
import { SDKValidationError } from "./models/errors/sdkvalidationerror.js";
|
|
28
33
|
|
|
29
|
-
|
|
30
34
|
class WebhookVerificationError extends Error {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
constructor(message: string) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.message = message;
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
const parseEvent = (parsed: any) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
42
|
+
try {
|
|
43
|
+
switch (parsed.type) {
|
|
44
|
+
case "customer.created":
|
|
45
|
+
return WebhookCustomerCreatedPayload$inboundSchema.parse(parsed);
|
|
46
|
+
case "customer.updated":
|
|
47
|
+
return WebhookCustomerUpdatedPayload$inboundSchema.parse(parsed);
|
|
48
|
+
case "customer.deleted":
|
|
49
|
+
return WebhookCustomerDeletedPayload$inboundSchema.parse(parsed);
|
|
50
|
+
case "customer.state_changed":
|
|
51
|
+
return WebhookCustomerStateChangedPayload$inboundSchema.parse(parsed);
|
|
52
|
+
case "benefit.created":
|
|
53
|
+
return WebhookBenefitCreatedPayload$inboundSchema.parse(parsed);
|
|
54
|
+
case "benefit_grant.created":
|
|
55
|
+
return WebhookBenefitGrantCreatedPayload$inboundSchema.parse(parsed);
|
|
56
|
+
case "benefit_grant.revoked":
|
|
57
|
+
return WebhookBenefitGrantRevokedPayload$inboundSchema.parse(parsed);
|
|
58
|
+
case "benefit_grant.updated":
|
|
59
|
+
return WebhookBenefitGrantUpdatedPayload$inboundSchema.parse(parsed);
|
|
60
|
+
case "benefit.updated":
|
|
61
|
+
return WebhookBenefitUpdatedPayload$inboundSchema.parse(parsed);
|
|
62
|
+
case "checkout.created":
|
|
63
|
+
return WebhookCheckoutCreatedPayload$inboundSchema.parse(parsed);
|
|
64
|
+
case "checkout.updated":
|
|
65
|
+
return WebhookCheckoutUpdatedPayload$inboundSchema.parse(parsed);
|
|
66
|
+
case "order.created":
|
|
67
|
+
return WebhookOrderCreatedPayload$inboundSchema.parse(parsed);
|
|
68
|
+
case "order.refunded":
|
|
69
|
+
return WebhookOrderRefundedPayload$inboundSchema.parse(parsed);
|
|
70
|
+
case "organization.updated":
|
|
71
|
+
return WebhookOrganizationUpdatedPayload$inboundSchema.parse(parsed);
|
|
72
|
+
case "pledge.created":
|
|
73
|
+
return WebhookPledgeCreatedPayload$inboundSchema.parse(parsed);
|
|
74
|
+
case "pledge.updated":
|
|
75
|
+
return WebhookPledgeUpdatedPayload$inboundSchema.parse(parsed);
|
|
76
|
+
case "product.created":
|
|
77
|
+
return WebhookProductCreatedPayload$inboundSchema.parse(parsed);
|
|
78
|
+
case "product.updated":
|
|
79
|
+
return WebhookProductUpdatedPayload$inboundSchema.parse(parsed);
|
|
80
|
+
case "refund.created":
|
|
81
|
+
return WebhookRefundCreatedPayload$inboundSchema.parse(parsed);
|
|
82
|
+
case "refund.updated":
|
|
83
|
+
return WebhookRefundUpdatedPayload$inboundSchema.parse(parsed);
|
|
84
|
+
case "subscription.active":
|
|
85
|
+
return WebhookSubscriptionActivePayload$inboundSchema.parse(parsed);
|
|
86
|
+
case "subscription.canceled":
|
|
87
|
+
return WebhookSubscriptionCanceledPayload$inboundSchema.parse(parsed);
|
|
88
|
+
case "subscription.created":
|
|
89
|
+
return WebhookSubscriptionCreatedPayload$inboundSchema.parse(parsed);
|
|
90
|
+
case "subscription.revoked":
|
|
91
|
+
return WebhookSubscriptionRevokedPayload$inboundSchema.parse(parsed);
|
|
92
|
+
case "subscription.uncanceled":
|
|
93
|
+
return WebhookSubscriptionUncanceledPayload$inboundSchema.parse(parsed);
|
|
94
|
+
case "subscription.updated":
|
|
95
|
+
return WebhookSubscriptionUpdatedPayload$inboundSchema.parse(parsed);
|
|
96
|
+
default:
|
|
97
|
+
throw new SDKValidationError(
|
|
98
|
+
`Unknown event type: ${parsed.type}`,
|
|
99
|
+
parsed.type,
|
|
100
|
+
parsed,
|
|
101
|
+
);
|
|
89
102
|
}
|
|
90
|
-
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
throw new SDKValidationError("Failed to parse event", error, parsed);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
91
107
|
|
|
92
|
-
const validateEvent = (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
const validateEvent = (
|
|
109
|
+
body: string | Buffer,
|
|
110
|
+
headers: Record<string, string>,
|
|
111
|
+
secret: string,
|
|
112
|
+
) => {
|
|
113
|
+
const base64Secret = Buffer.from(secret, "utf-8").toString("base64");
|
|
114
|
+
const webhook = new Webhook(base64Secret);
|
|
115
|
+
try {
|
|
116
|
+
const parsed = webhook.verify(body, headers);
|
|
117
|
+
return parseEvent(parsed);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
if (error instanceof _WebhookVerificationError) {
|
|
120
|
+
throw new WebhookVerificationError(error.message);
|
|
103
121
|
}
|
|
104
|
-
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
105
125
|
|
|
106
|
-
export {
|
|
107
|
-
validateEvent,
|
|
108
|
-
WebhookVerificationError,
|
|
109
|
-
}
|
|
126
|
+
export { validateEvent, WebhookVerificationError };
|