@whatalo/plugin-sdk 1.2.0 → 1.2.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.
Files changed (59) hide show
  1. package/dist/adapters/express.cjs +106 -10
  2. package/dist/adapters/express.cjs.map +1 -1
  3. package/dist/adapters/express.d.cts +9 -7
  4. package/dist/adapters/express.d.ts +9 -7
  5. package/dist/adapters/express.mjs +109 -10
  6. package/dist/adapters/express.mjs.map +1 -1
  7. package/dist/adapters/hono.cjs +99 -7
  8. package/dist/adapters/hono.cjs.map +1 -1
  9. package/dist/adapters/hono.d.cts +4 -3
  10. package/dist/adapters/hono.d.ts +4 -3
  11. package/dist/adapters/hono.mjs +102 -7
  12. package/dist/adapters/hono.mjs.map +1 -1
  13. package/dist/adapters/nextjs.cjs +99 -7
  14. package/dist/adapters/nextjs.cjs.map +1 -1
  15. package/dist/adapters/nextjs.d.cts +4 -3
  16. package/dist/adapters/nextjs.d.ts +4 -3
  17. package/dist/adapters/nextjs.mjs +102 -7
  18. package/dist/adapters/nextjs.mjs.map +1 -1
  19. package/dist/bridge/index.cjs +60 -5
  20. package/dist/bridge/index.cjs.map +1 -1
  21. package/dist/bridge/index.d.cts +17 -5
  22. package/dist/bridge/index.d.ts +17 -5
  23. package/dist/bridge/index.mjs +60 -5
  24. package/dist/bridge/index.mjs.map +1 -1
  25. package/dist/client/index.cjs +33 -2
  26. package/dist/client/index.cjs.map +1 -1
  27. package/dist/client/index.d.cts +29 -1
  28. package/dist/client/index.d.ts +29 -1
  29. package/dist/client/index.mjs +33 -2
  30. package/dist/client/index.mjs.map +1 -1
  31. package/dist/index.cjs +179 -28
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +7 -4
  34. package/dist/index.d.ts +7 -4
  35. package/dist/index.mjs +179 -28
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/manifest/index.cjs +2 -17
  38. package/dist/manifest/index.cjs.map +1 -1
  39. package/dist/manifest/index.d.cts +10 -4
  40. package/dist/manifest/index.d.ts +10 -4
  41. package/dist/manifest/index.mjs +2 -17
  42. package/dist/manifest/index.mjs.map +1 -1
  43. package/dist/{types-DcmArIC2.d.ts → types-B8BAV362.d.cts} +24 -1
  44. package/dist/{types-DcmArIC2.d.cts → types-B8BAV362.d.ts} +24 -1
  45. package/dist/types-Bzee9Hvr.d.ts +25 -0
  46. package/dist/types-CDKGAQ3o.d.ts +155 -0
  47. package/dist/types-CPnSzOfX.d.cts +155 -0
  48. package/dist/types-CqyAhbXM.d.cts +25 -0
  49. package/dist/webhooks/index.cjs +83 -3
  50. package/dist/webhooks/index.cjs.map +1 -1
  51. package/dist/webhooks/index.d.cts +11 -4
  52. package/dist/webhooks/index.d.ts +11 -4
  53. package/dist/webhooks/index.mjs +83 -3
  54. package/dist/webhooks/index.mjs.map +1 -1
  55. package/package.json +4 -1
  56. package/dist/types-C9mg4aQg.d.ts +0 -19
  57. package/dist/types-DMuHSL_a.d.cts +0 -19
  58. package/dist/types-DTjA3FHe.d.ts +0 -68
  59. package/dist/types-tHUO9u-c.d.cts +0 -68
@@ -1,18 +1,25 @@
1
- export { W as WebhookEvent, b as WebhookEventData, a as WebhookPayload } from '../types-DTjA3FHe.js';
2
- import '../types-DcmArIC2.js';
1
+ export { e as RuntimeWebhookBasePayload, f as RuntimeWebhookEventData, R as RuntimeWebhookPayload, g as RuntimeWebhookStore, a as WEBHOOK_EVENTS, W as WebhookEvent, c as WebhookEventData, d as WebhookPayload, i as isRuntimeWebhookPayload, b as isWebhookEvent } from '../types-CDKGAQ3o.js';
2
+ import '@whatalo/protocol/events';
3
+ import '../types-B8BAV362.js';
3
4
 
4
5
  interface VerifyWebhookParams {
5
6
  /** Raw request body as a string (NOT parsed JSON) */
6
7
  payload: string;
7
8
  /** Value of the X-Webhook-Signature header */
8
9
  signature: string;
10
+ /** Value of the X-Webhook-Timestamp header (Unix epoch in seconds) */
11
+ timestamp: string | number;
9
12
  /** App's webhook secret (provided during app installation) */
10
13
  secret: string;
14
+ /** Maximum timestamp drift allowed in seconds. Defaults to 300 seconds. */
15
+ toleranceSeconds?: number;
16
+ /** Current Unix epoch time in seconds. Intended for tests. */
17
+ currentTime?: number;
11
18
  }
12
19
  /**
13
- * Verify webhook signature using HMAC-SHA256.
20
+ * Verify webhook signature using HMAC-SHA256 over `${timestamp}.${payload}`.
14
21
  * Uses timing-safe comparison to prevent timing attacks.
15
22
  */
16
- declare function verifyWebhook({ payload, signature, secret, }: VerifyWebhookParams): boolean;
23
+ declare function verifyWebhook({ payload, signature, timestamp, secret, toleranceSeconds, currentTime, }: VerifyWebhookParams): boolean;
17
24
 
18
25
  export { type VerifyWebhookParams, verifyWebhook };
@@ -1,13 +1,25 @@
1
1
  // src/webhooks/verify.ts
2
2
  import { createHmac, timingSafeEqual } from "crypto";
3
+ var DEFAULT_TOLERANCE_SECONDS = 300;
3
4
  function verifyWebhook({
4
5
  payload,
5
6
  signature,
6
- secret
7
+ timestamp,
8
+ secret,
9
+ toleranceSeconds = DEFAULT_TOLERANCE_SECONDS,
10
+ currentTime = Math.floor(Date.now() / 1e3)
7
11
  }) {
8
- if (!payload || !signature || !secret) return false;
9
- const expected = createHmac("sha256", secret).update(payload, "utf8").digest("hex");
12
+ if (!payload || !signature || !secret || timestamp === "") return false;
13
+ const timestampString = String(timestamp);
14
+ const timestampValue = typeof timestamp === "number" ? timestamp : Number(timestamp);
15
+ if (!Number.isInteger(timestampValue)) return false;
16
+ if (!Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) return false;
17
+ if (!Number.isFinite(currentTime)) return false;
18
+ const ageSeconds = Math.abs(currentTime - timestampValue);
19
+ if (ageSeconds > toleranceSeconds) return false;
20
+ const expected = createHmac("sha256", secret).update(`${timestampString}.${payload}`, "utf8").digest("hex");
10
21
  if (expected.length !== signature.length) return false;
22
+ if (!/^[a-f0-9]+$/i.test(signature)) return false;
11
23
  try {
12
24
  return timingSafeEqual(
13
25
  Buffer.from(expected, "hex"),
@@ -17,7 +29,75 @@ function verifyWebhook({
17
29
  return false;
18
30
  }
19
31
  }
32
+
33
+ // src/webhooks/types.ts
34
+ import {
35
+ PUBLIC_WEBHOOK_EVENTS,
36
+ isPublicWebhookEvent
37
+ } from "@whatalo/protocol/events";
38
+ var WEBHOOK_EVENTS = PUBLIC_WEBHOOK_EVENTS;
39
+ function isWebhookEvent(value) {
40
+ return isPublicWebhookEvent(value);
41
+ }
42
+ function isRecord(value) {
43
+ return typeof value === "object" && value !== null && !Array.isArray(value);
44
+ }
45
+ function hasStringId(value) {
46
+ return isRecord(value) && typeof value.id === "string";
47
+ }
48
+ function isOptionalString(value, key) {
49
+ return value[key] === void 0 || typeof value[key] === "string";
50
+ }
51
+ function isRuntimeWebhookStore(value) {
52
+ return isRecord(value) && typeof value.id === "string" && typeof value.timezone === "string" && (value.name === void 0 || typeof value.name === "string");
53
+ }
54
+ function hasValidBasePayloadFields(value) {
55
+ if (!isOptionalString(value, "event_id")) return false;
56
+ if (!isOptionalString(value, "occurred_at")) return false;
57
+ return isRuntimeWebhookStore(value.store);
58
+ }
59
+ function isRuntimeOrderWebhookPayload(value) {
60
+ return hasValidBasePayloadFields(value) && hasStringId(value.order) && (value.customer === void 0 || hasStringId(value.customer));
61
+ }
62
+ function isRuntimeProductWebhookPayload(value) {
63
+ return hasValidBasePayloadFields(value) && hasStringId(value.product);
64
+ }
65
+ function isRuntimeCustomerWebhookPayload(value) {
66
+ return hasValidBasePayloadFields(value) && hasStringId(value.customer);
67
+ }
68
+ function isRuntimeCheckoutCompletedWebhookPayload(value) {
69
+ return hasValidBasePayloadFields(value) && hasStringId(value.order) && hasStringId(value.customer) && isRuntimeWebhookStore(value.store);
70
+ }
71
+ function isRuntimeCheckoutAbandonedWebhookPayload(value) {
72
+ return hasValidBasePayloadFields(value) && hasStringId(value.checkout) && isRuntimeWebhookStore(value.store);
73
+ }
74
+ function isRuntimeWebhookPayload(value, event) {
75
+ if (!isRecord(value)) return false;
76
+ switch (event) {
77
+ case WEBHOOK_EVENTS.ORDER_CREATED:
78
+ case WEBHOOK_EVENTS.ORDER_UPDATED:
79
+ case WEBHOOK_EVENTS.ORDER_CANCELLED:
80
+ case WEBHOOK_EVENTS.ORDER_COMPLETED:
81
+ return isRuntimeOrderWebhookPayload(value);
82
+ case WEBHOOK_EVENTS.PRODUCT_CREATED:
83
+ case WEBHOOK_EVENTS.PRODUCT_UPDATED:
84
+ case WEBHOOK_EVENTS.PRODUCT_DELETED:
85
+ return isRuntimeProductWebhookPayload(value);
86
+ case WEBHOOK_EVENTS.CUSTOMER_CREATED:
87
+ case WEBHOOK_EVENTS.CUSTOMER_UPDATED:
88
+ return isRuntimeCustomerWebhookPayload(value);
89
+ case WEBHOOK_EVENTS.CHECKOUT_COMPLETED:
90
+ return isRuntimeCheckoutCompletedWebhookPayload(value);
91
+ case WEBHOOK_EVENTS.CHECKOUT_ABANDONED:
92
+ return isRuntimeCheckoutAbandonedWebhookPayload(value);
93
+ default:
94
+ return false;
95
+ }
96
+ }
20
97
  export {
98
+ WEBHOOK_EVENTS,
99
+ isRuntimeWebhookPayload,
100
+ isWebhookEvent,
21
101
  verifyWebhook
22
102
  };
23
103
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/webhooks/verify.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from \"node:crypto\";\n\nexport interface VerifyWebhookParams {\n /** Raw request body as a string (NOT parsed JSON) */\n payload: string;\n /** Value of the X-Webhook-Signature header */\n signature: string;\n /** App's webhook secret (provided during app installation) */\n secret: string;\n}\n\n/**\n * Verify webhook signature using HMAC-SHA256.\n * Uses timing-safe comparison to prevent timing attacks.\n */\nexport function verifyWebhook({\n payload,\n signature,\n secret,\n}: VerifyWebhookParams): boolean {\n if (!payload || !signature || !secret) return false;\n\n const expected = createHmac(\"sha256\", secret)\n .update(payload, \"utf8\")\n .digest(\"hex\");\n\n if (expected.length !== signature.length) return false;\n\n try {\n return timingSafeEqual(\n Buffer.from(expected, \"hex\"),\n Buffer.from(signature, \"hex\")\n );\n } catch {\n return false;\n }\n}\n"],"mappings":";AAAA,SAAS,YAAY,uBAAuB;AAerC,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF,GAAiC;AAC/B,MAAI,CAAC,WAAW,CAAC,aAAa,CAAC,OAAQ,QAAO;AAE9C,QAAM,WAAW,WAAW,UAAU,MAAM,EACzC,OAAO,SAAS,MAAM,EACtB,OAAO,KAAK;AAEf,MAAI,SAAS,WAAW,UAAU,OAAQ,QAAO;AAEjD,MAAI;AACF,WAAO;AAAA,MACL,OAAO,KAAK,UAAU,KAAK;AAAA,MAC3B,OAAO,KAAK,WAAW,KAAK;AAAA,IAC9B;AAAA,EACF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/webhooks/verify.ts","../../src/webhooks/types.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from \"node:crypto\";\n\nconst DEFAULT_TOLERANCE_SECONDS = 300;\n\nexport interface VerifyWebhookParams {\n /** Raw request body as a string (NOT parsed JSON) */\n payload: string;\n /** Value of the X-Webhook-Signature header */\n signature: string;\n /** Value of the X-Webhook-Timestamp header (Unix epoch in seconds) */\n timestamp: string | number;\n /** App's webhook secret (provided during app installation) */\n secret: string;\n /** Maximum timestamp drift allowed in seconds. Defaults to 300 seconds. */\n toleranceSeconds?: number;\n /** Current Unix epoch time in seconds. Intended for tests. */\n currentTime?: number;\n}\n\n/**\n * Verify webhook signature using HMAC-SHA256 over `${timestamp}.${payload}`.\n * Uses timing-safe comparison to prevent timing attacks.\n */\nexport function verifyWebhook({\n payload,\n signature,\n timestamp,\n secret,\n toleranceSeconds = DEFAULT_TOLERANCE_SECONDS,\n currentTime = Math.floor(Date.now() / 1000),\n}: VerifyWebhookParams): boolean {\n if (!payload || !signature || !secret || timestamp === \"\") return false;\n\n const timestampString = String(timestamp);\n const timestampValue =\n typeof timestamp === \"number\" ? timestamp : Number(timestamp);\n\n if (!Number.isInteger(timestampValue)) return false;\n if (!Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) return false;\n if (!Number.isFinite(currentTime)) return false;\n\n const ageSeconds = Math.abs(currentTime - timestampValue);\n if (ageSeconds > toleranceSeconds) return false;\n\n const expected = createHmac(\"sha256\", secret)\n .update(`${timestampString}.${payload}`, \"utf8\")\n .digest(\"hex\");\n\n if (expected.length !== signature.length) return false;\n if (!/^[a-f0-9]+$/i.test(signature)) return false;\n\n try {\n return timingSafeEqual(\n Buffer.from(expected, \"hex\"),\n Buffer.from(signature, \"hex\")\n );\n } catch {\n return false;\n }\n}\n","import {\n PUBLIC_WEBHOOK_EVENTS,\n isPublicWebhookEvent,\n type PublicWebhookEvent,\n} from \"@whatalo/protocol/events\";\nimport type { Product, Order, Customer } from \"../client/types.js\";\n\nexport const WEBHOOK_EVENTS = PUBLIC_WEBHOOK_EVENTS;\n\n/** All supported webhook event types */\nexport type WebhookEvent = PublicWebhookEvent;\n\n/** Validate an event header against the public runtime webhook event set. */\nexport function isWebhookEvent(value: string): value is WebhookEvent {\n return isPublicWebhookEvent(value);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction hasStringId(value: unknown): value is { id: string } {\n return isRecord(value) && typeof value.id === \"string\";\n}\n\nfunction isOptionalString(\n value: Record<string, unknown>,\n key: string\n): boolean {\n return value[key] === undefined || typeof value[key] === \"string\";\n}\n\nfunction isRuntimeWebhookStore(value: unknown): value is RuntimeWebhookStore {\n return (\n isRecord(value) &&\n typeof value.id === \"string\" &&\n typeof value.timezone === \"string\" &&\n (value.name === undefined || typeof value.name === \"string\")\n );\n}\n\nfunction hasValidBasePayloadFields(value: Record<string, unknown>): boolean {\n if (!isOptionalString(value, \"event_id\")) return false;\n if (!isOptionalString(value, \"occurred_at\")) return false;\n\n return isRuntimeWebhookStore(value.store);\n}\n\nfunction isRuntimeOrderWebhookPayload(value: Record<string, unknown>): boolean {\n return (\n hasValidBasePayloadFields(value) &&\n hasStringId(value.order) &&\n (value.customer === undefined || hasStringId(value.customer))\n );\n}\n\nfunction isRuntimeProductWebhookPayload(value: Record<string, unknown>): boolean {\n return hasValidBasePayloadFields(value) && hasStringId(value.product);\n}\n\nfunction isRuntimeCustomerWebhookPayload(value: Record<string, unknown>): boolean {\n return hasValidBasePayloadFields(value) && hasStringId(value.customer);\n}\n\nfunction isRuntimeCheckoutCompletedWebhookPayload(\n value: Record<string, unknown>\n): boolean {\n return (\n hasValidBasePayloadFields(value) &&\n hasStringId(value.order) &&\n hasStringId(value.customer) &&\n isRuntimeWebhookStore(value.store)\n );\n}\n\nfunction isRuntimeCheckoutAbandonedWebhookPayload(\n value: Record<string, unknown>\n): boolean {\n // An abandoned draft is pre-customer, so `customer` carries no `id` and is not required.\n return (\n hasValidBasePayloadFields(value) &&\n hasStringId(value.checkout) &&\n isRuntimeWebhookStore(value.store)\n );\n}\n\nexport interface OrderCreatedWebhookData {\n order: Order;\n}\n\nexport interface OrderUpdatedWebhookData {\n order: Order;\n changes: string[];\n}\n\nexport interface OrderCancelledWebhookData {\n orderId: string;\n reason?: string;\n}\n\nexport interface OrderCompletedWebhookData {\n order: Order;\n}\n\nexport interface ProductCreatedWebhookData {\n product: Product;\n}\n\nexport interface ProductUpdatedWebhookData {\n product: Product;\n changes: string[];\n}\n\nexport interface ProductDeletedWebhookProduct {\n id: string;\n}\n\nexport interface ProductDeletedWebhookData {\n product: ProductDeletedWebhookProduct;\n}\n\nexport interface CustomerCreatedWebhookData {\n customer: Customer;\n}\n\nexport interface CustomerUpdatedWebhookData {\n customer: Customer;\n changes: string[];\n}\n\nexport interface CheckoutCompletedWebhookData {\n order: RuntimeWebhookOrder;\n customer: RuntimeWebhookCustomer;\n store: RuntimeWebhookStore;\n}\n\n/** Contact captured on an abandoned draft. No `id` — the draft is pre-customer. */\nexport interface CheckoutAbandonedWebhookCustomer {\n name: string | null;\n email: string | null;\n phone: string | null;\n}\n\nexport interface CheckoutAbandonedWebhookData {\n checkout: RuntimeWebhookCheckout;\n customer: CheckoutAbandonedWebhookCustomer;\n store: RuntimeWebhookStore;\n}\n\n/** Map of webhook events to their payload data shapes */\nexport interface WebhookEventData {\n \"order.created\": OrderCreatedWebhookData;\n \"order.updated\": OrderUpdatedWebhookData;\n \"order.cancelled\": OrderCancelledWebhookData;\n \"order.completed\": OrderCompletedWebhookData;\n \"product.created\": ProductCreatedWebhookData;\n \"product.updated\": ProductUpdatedWebhookData;\n \"product.deleted\": ProductDeletedWebhookData;\n \"customer.created\": CustomerCreatedWebhookData;\n \"customer.updated\": CustomerUpdatedWebhookData;\n \"checkout.completed\": CheckoutCompletedWebhookData;\n \"checkout.abandoned\": CheckoutAbandonedWebhookData;\n}\n\n/** Legacy envelope payload. Runtime webhook deliveries do not include the event field in the body. */\nexport interface WebhookPayload<E extends WebhookEvent = WebhookEvent> {\n event: E;\n timestamp: string;\n storeId: string;\n data: WebhookEventData[E];\n}\n\nexport interface RuntimeWebhookStore {\n id: string;\n name?: string;\n timezone: string;\n}\n\nexport interface RuntimeWebhookBasePayload {\n event_id?: string;\n occurred_at?: string;\n store: RuntimeWebhookStore;\n}\n\nexport interface RuntimeWebhookOrder {\n id: string;\n [key: string]: unknown;\n}\n\nexport interface RuntimeWebhookProduct {\n id: string;\n [key: string]: unknown;\n}\n\nexport interface RuntimeWebhookCustomer {\n id: string;\n [key: string]: unknown;\n}\n\nexport interface RuntimeWebhookCheckout {\n id: string;\n [key: string]: unknown;\n}\n\nexport interface RuntimeOrderWebhookPayload extends RuntimeWebhookBasePayload {\n order: RuntimeWebhookOrder;\n customer?: RuntimeWebhookCustomer;\n}\n\nexport interface RuntimeProductWebhookPayload extends RuntimeWebhookBasePayload {\n product: RuntimeWebhookProduct;\n}\n\nexport interface RuntimeCustomerWebhookPayload extends RuntimeWebhookBasePayload {\n customer: RuntimeWebhookCustomer;\n}\n\nexport interface RuntimeCheckoutCompletedWebhookPayload\n extends RuntimeWebhookBasePayload {\n order: RuntimeWebhookOrder;\n customer: RuntimeWebhookCustomer;\n store: RuntimeWebhookStore;\n}\n\nexport interface RuntimeCheckoutAbandonedWebhookPayload\n extends RuntimeWebhookBasePayload {\n checkout: RuntimeWebhookCheckout;\n // Pre-customer draft: contact fields only, no customer id.\n customer?: CheckoutAbandonedWebhookCustomer;\n}\n\nexport interface RuntimeWebhookEventData {\n \"order.created\": RuntimeOrderWebhookPayload;\n \"order.updated\": RuntimeOrderWebhookPayload;\n \"order.cancelled\": RuntimeOrderWebhookPayload;\n \"order.completed\": RuntimeOrderWebhookPayload;\n \"product.created\": RuntimeProductWebhookPayload;\n \"product.updated\": RuntimeProductWebhookPayload;\n \"product.deleted\": RuntimeProductWebhookPayload;\n \"customer.created\": RuntimeCustomerWebhookPayload;\n \"customer.updated\": RuntimeCustomerWebhookPayload;\n \"checkout.completed\": RuntimeCheckoutCompletedWebhookPayload;\n \"checkout.abandoned\": RuntimeCheckoutAbandonedWebhookPayload;\n}\n\n/** Runtime body delivered to subscriber endpoints. The event comes from X-Webhook-Event. */\nexport type RuntimeWebhookPayload<E extends WebhookEvent = WebhookEvent> =\n RuntimeWebhookEventData[E];\n\n/** Validate the minimum runtime payload shape before invoking typed handlers. */\nexport function isRuntimeWebhookPayload<E extends WebhookEvent>(\n value: unknown,\n event: E\n): value is RuntimeWebhookPayload<E> {\n if (!isRecord(value)) return false;\n\n switch (event) {\n case WEBHOOK_EVENTS.ORDER_CREATED:\n case WEBHOOK_EVENTS.ORDER_UPDATED:\n case WEBHOOK_EVENTS.ORDER_CANCELLED:\n case WEBHOOK_EVENTS.ORDER_COMPLETED:\n return isRuntimeOrderWebhookPayload(value);\n case WEBHOOK_EVENTS.PRODUCT_CREATED:\n case WEBHOOK_EVENTS.PRODUCT_UPDATED:\n case WEBHOOK_EVENTS.PRODUCT_DELETED:\n return isRuntimeProductWebhookPayload(value);\n case WEBHOOK_EVENTS.CUSTOMER_CREATED:\n case WEBHOOK_EVENTS.CUSTOMER_UPDATED:\n return isRuntimeCustomerWebhookPayload(value);\n case WEBHOOK_EVENTS.CHECKOUT_COMPLETED:\n return isRuntimeCheckoutCompletedWebhookPayload(value);\n case WEBHOOK_EVENTS.CHECKOUT_ABANDONED:\n return isRuntimeCheckoutAbandonedWebhookPayload(value);\n default:\n return false;\n }\n}\n"],"mappings":"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","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatalo/plugin-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Official TypeScript SDK for building Whatalo plugins",
@@ -74,6 +74,9 @@
74
74
  "latam",
75
75
  "cod"
76
76
  ],
77
+ "dependencies": {
78
+ "@whatalo/protocol": "1.0.0"
79
+ },
77
80
  "peerDependencies": {
78
81
  "react": ">=18",
79
82
  "react-dom": ">=18"
@@ -1,19 +0,0 @@
1
- import { W as WebhookEvent, a as WebhookPayload } from './types-DTjA3FHe.js';
2
-
3
- /** Handler function for a specific webhook event */
4
- type WebhookEventHandler<E extends WebhookEvent> = (payload: WebhookPayload<E>) => Promise<void> | void;
5
- /** Map of event names to handler functions */
6
- type WebhookHandlers = {
7
- [E in WebhookEvent]?: WebhookEventHandler<E>;
8
- };
9
- /** Options for creating a webhook handler */
10
- interface WebhookHandlerOptions {
11
- /** The webhook signing secret */
12
- secret: string;
13
- /** Event handler map */
14
- handlers: WebhookHandlers;
15
- /** Called when an event has no registered handler */
16
- onUnhandledEvent?: (event: string, payload: WebhookPayload) => Promise<void> | void;
17
- }
18
-
19
- export type { WebhookHandlerOptions as W };
@@ -1,19 +0,0 @@
1
- import { W as WebhookEvent, a as WebhookPayload } from './types-tHUO9u-c.cjs';
2
-
3
- /** Handler function for a specific webhook event */
4
- type WebhookEventHandler<E extends WebhookEvent> = (payload: WebhookPayload<E>) => Promise<void> | void;
5
- /** Map of event names to handler functions */
6
- type WebhookHandlers = {
7
- [E in WebhookEvent]?: WebhookEventHandler<E>;
8
- };
9
- /** Options for creating a webhook handler */
10
- interface WebhookHandlerOptions {
11
- /** The webhook signing secret */
12
- secret: string;
13
- /** Event handler map */
14
- handlers: WebhookHandlers;
15
- /** Called when an event has no registered handler */
16
- onUnhandledEvent?: (event: string, payload: WebhookPayload) => Promise<void> | void;
17
- }
18
-
19
- export type { WebhookHandlerOptions as W };
@@ -1,68 +0,0 @@
1
- import { O as Order, a as Product, f as Customer } from './types-DcmArIC2.js';
2
-
3
- /** All supported webhook event types */
4
- type WebhookEvent = "order.created" | "order.updated" | "order.status_changed" | "order.cancelled" | "product.created" | "product.updated" | "product.deleted" | "customer.created" | "customer.updated" | "inventory.low" | "inventory.adjusted" | "app.installed" | "app.uninstalled";
5
- /** Map of webhook events to their payload data shapes */
6
- interface WebhookEventData {
7
- "order.created": {
8
- order: Order;
9
- };
10
- "order.updated": {
11
- order: Order;
12
- changes: string[];
13
- };
14
- "order.status_changed": {
15
- orderId: string;
16
- previousStatus: string;
17
- newStatus: string;
18
- };
19
- "order.cancelled": {
20
- orderId: string;
21
- reason?: string;
22
- };
23
- "product.created": {
24
- product: Product;
25
- };
26
- "product.updated": {
27
- product: Product;
28
- changes: string[];
29
- };
30
- "product.deleted": {
31
- productId: string;
32
- };
33
- "customer.created": {
34
- customer: Customer;
35
- };
36
- "customer.updated": {
37
- customer: Customer;
38
- changes: string[];
39
- };
40
- "inventory.low": {
41
- productId: string;
42
- currentQuantity: number;
43
- threshold: number;
44
- };
45
- "inventory.adjusted": {
46
- productId: string;
47
- previousQuantity: number;
48
- newQuantity: number;
49
- reason: string;
50
- };
51
- "app.installed": {
52
- storeId: string;
53
- installedAt: string;
54
- };
55
- "app.uninstalled": {
56
- storeId: string;
57
- uninstalledAt: string;
58
- };
59
- }
60
- /** Typed webhook payload delivered to subscriber endpoints */
61
- interface WebhookPayload<E extends WebhookEvent = WebhookEvent> {
62
- event: E;
63
- timestamp: string;
64
- storeId: string;
65
- data: WebhookEventData[E];
66
- }
67
-
68
- export type { WebhookEvent as W, WebhookPayload as a, WebhookEventData as b };
@@ -1,68 +0,0 @@
1
- import { O as Order, a as Product, f as Customer } from './types-DcmArIC2.cjs';
2
-
3
- /** All supported webhook event types */
4
- type WebhookEvent = "order.created" | "order.updated" | "order.status_changed" | "order.cancelled" | "product.created" | "product.updated" | "product.deleted" | "customer.created" | "customer.updated" | "inventory.low" | "inventory.adjusted" | "app.installed" | "app.uninstalled";
5
- /** Map of webhook events to their payload data shapes */
6
- interface WebhookEventData {
7
- "order.created": {
8
- order: Order;
9
- };
10
- "order.updated": {
11
- order: Order;
12
- changes: string[];
13
- };
14
- "order.status_changed": {
15
- orderId: string;
16
- previousStatus: string;
17
- newStatus: string;
18
- };
19
- "order.cancelled": {
20
- orderId: string;
21
- reason?: string;
22
- };
23
- "product.created": {
24
- product: Product;
25
- };
26
- "product.updated": {
27
- product: Product;
28
- changes: string[];
29
- };
30
- "product.deleted": {
31
- productId: string;
32
- };
33
- "customer.created": {
34
- customer: Customer;
35
- };
36
- "customer.updated": {
37
- customer: Customer;
38
- changes: string[];
39
- };
40
- "inventory.low": {
41
- productId: string;
42
- currentQuantity: number;
43
- threshold: number;
44
- };
45
- "inventory.adjusted": {
46
- productId: string;
47
- previousQuantity: number;
48
- newQuantity: number;
49
- reason: string;
50
- };
51
- "app.installed": {
52
- storeId: string;
53
- installedAt: string;
54
- };
55
- "app.uninstalled": {
56
- storeId: string;
57
- uninstalledAt: string;
58
- };
59
- }
60
- /** Typed webhook payload delivered to subscriber endpoints */
61
- interface WebhookPayload<E extends WebhookEvent = WebhookEvent> {
62
- event: E;
63
- timestamp: string;
64
- storeId: string;
65
- data: WebhookEventData[E];
66
- }
67
-
68
- export type { WebhookEvent as W, WebhookPayload as a, WebhookEventData as b };