@whatalo/plugin-sdk 1.0.0

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 (55) hide show
  1. package/dist/adapters/express.cjs +87 -0
  2. package/dist/adapters/express.cjs.map +1 -0
  3. package/dist/adapters/express.d.cts +17 -0
  4. package/dist/adapters/express.d.ts +17 -0
  5. package/dist/adapters/express.mjs +60 -0
  6. package/dist/adapters/express.mjs.map +1 -0
  7. package/dist/adapters/hono.cjs +79 -0
  8. package/dist/adapters/hono.cjs.map +1 -0
  9. package/dist/adapters/hono.d.cts +15 -0
  10. package/dist/adapters/hono.d.ts +15 -0
  11. package/dist/adapters/hono.mjs +52 -0
  12. package/dist/adapters/hono.mjs.map +1 -0
  13. package/dist/adapters/nextjs.cjs +79 -0
  14. package/dist/adapters/nextjs.cjs.map +1 -0
  15. package/dist/adapters/nextjs.d.cts +7 -0
  16. package/dist/adapters/nextjs.d.ts +7 -0
  17. package/dist/adapters/nextjs.mjs +52 -0
  18. package/dist/adapters/nextjs.mjs.map +1 -0
  19. package/dist/bridge/index.cjs +290 -0
  20. package/dist/bridge/index.cjs.map +1 -0
  21. package/dist/bridge/index.d.cts +236 -0
  22. package/dist/bridge/index.d.ts +236 -0
  23. package/dist/bridge/index.mjs +260 -0
  24. package/dist/bridge/index.mjs.map +1 -0
  25. package/dist/client/index.cjs +423 -0
  26. package/dist/client/index.cjs.map +1 -0
  27. package/dist/client/index.d.cts +131 -0
  28. package/dist/client/index.d.ts +131 -0
  29. package/dist/client/index.mjs +396 -0
  30. package/dist/client/index.mjs.map +1 -0
  31. package/dist/index.cjs +843 -0
  32. package/dist/index.cjs.map +1 -0
  33. package/dist/index.d.cts +57 -0
  34. package/dist/index.d.ts +57 -0
  35. package/dist/index.mjs +801 -0
  36. package/dist/index.mjs.map +1 -0
  37. package/dist/manifest/index.cjs +145 -0
  38. package/dist/manifest/index.cjs.map +1 -0
  39. package/dist/manifest/index.d.cts +78 -0
  40. package/dist/manifest/index.d.ts +78 -0
  41. package/dist/manifest/index.mjs +117 -0
  42. package/dist/manifest/index.mjs.map +1 -0
  43. package/dist/types-D2Efg3EG.d.ts +19 -0
  44. package/dist/types-DZ659i6f.d.ts +68 -0
  45. package/dist/types-Db_BeRCj.d.cts +19 -0
  46. package/dist/types-DdqKKyqX.d.cts +68 -0
  47. package/dist/types-M1eLMz6w.d.cts +279 -0
  48. package/dist/types-M1eLMz6w.d.ts +279 -0
  49. package/dist/webhooks/index.cjs +50 -0
  50. package/dist/webhooks/index.cjs.map +1 -0
  51. package/dist/webhooks/index.d.cts +18 -0
  52. package/dist/webhooks/index.d.ts +18 -0
  53. package/dist/webhooks/index.mjs +23 -0
  54. package/dist/webhooks/index.mjs.map +1 -0
  55. package/package.json +94 -0
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/webhooks/index.ts
21
+ var webhooks_exports = {};
22
+ __export(webhooks_exports, {
23
+ verifyWebhook: () => verifyWebhook
24
+ });
25
+ module.exports = __toCommonJS(webhooks_exports);
26
+
27
+ // src/webhooks/verify.ts
28
+ var import_node_crypto = require("crypto");
29
+ function verifyWebhook({
30
+ payload,
31
+ signature,
32
+ secret
33
+ }) {
34
+ if (!payload || !signature || !secret) return false;
35
+ const expected = (0, import_node_crypto.createHmac)("sha256", secret).update(payload, "utf8").digest("hex");
36
+ if (expected.length !== signature.length) return false;
37
+ try {
38
+ return (0, import_node_crypto.timingSafeEqual)(
39
+ Buffer.from(expected, "hex"),
40
+ Buffer.from(signature, "hex")
41
+ );
42
+ } catch {
43
+ return false;
44
+ }
45
+ }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ verifyWebhook
49
+ });
50
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/webhooks/index.ts","../../src/webhooks/verify.ts"],"sourcesContent":["export { verifyWebhook } from \"./verify.js\";\nexport type { VerifyWebhookParams } from \"./verify.js\";\nexport type {\n WebhookEvent,\n WebhookEventData,\n WebhookPayload,\n} from \"./types.js\";\n","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;AAAA;AAAA;AAAA;AAAA;;;ACAA,yBAA4C;AAerC,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF,GAAiC;AAC/B,MAAI,CAAC,WAAW,CAAC,aAAa,CAAC,OAAQ,QAAO;AAE9C,QAAM,eAAW,+BAAW,UAAU,MAAM,EACzC,OAAO,SAAS,MAAM,EACtB,OAAO,KAAK;AAEf,MAAI,SAAS,WAAW,UAAU,OAAQ,QAAO;AAEjD,MAAI;AACF,eAAO;AAAA,MACL,OAAO,KAAK,UAAU,KAAK;AAAA,MAC3B,OAAO,KAAK,WAAW,KAAK;AAAA,IAC9B;AAAA,EACF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,18 @@
1
+ export { W as WebhookEvent, b as WebhookEventData, a as WebhookPayload } from '../types-DdqKKyqX.cjs';
2
+ import '../types-M1eLMz6w.cjs';
3
+
4
+ interface VerifyWebhookParams {
5
+ /** Raw request body as a string (NOT parsed JSON) */
6
+ payload: string;
7
+ /** Value of the X-Webhook-Signature header */
8
+ signature: string;
9
+ /** App's webhook secret (provided during app installation) */
10
+ secret: string;
11
+ }
12
+ /**
13
+ * Verify webhook signature using HMAC-SHA256.
14
+ * Uses timing-safe comparison to prevent timing attacks.
15
+ */
16
+ declare function verifyWebhook({ payload, signature, secret, }: VerifyWebhookParams): boolean;
17
+
18
+ export { type VerifyWebhookParams, verifyWebhook };
@@ -0,0 +1,18 @@
1
+ export { W as WebhookEvent, b as WebhookEventData, a as WebhookPayload } from '../types-DZ659i6f.js';
2
+ import '../types-M1eLMz6w.js';
3
+
4
+ interface VerifyWebhookParams {
5
+ /** Raw request body as a string (NOT parsed JSON) */
6
+ payload: string;
7
+ /** Value of the X-Webhook-Signature header */
8
+ signature: string;
9
+ /** App's webhook secret (provided during app installation) */
10
+ secret: string;
11
+ }
12
+ /**
13
+ * Verify webhook signature using HMAC-SHA256.
14
+ * Uses timing-safe comparison to prevent timing attacks.
15
+ */
16
+ declare function verifyWebhook({ payload, signature, secret, }: VerifyWebhookParams): boolean;
17
+
18
+ export { type VerifyWebhookParams, verifyWebhook };
@@ -0,0 +1,23 @@
1
+ // src/webhooks/verify.ts
2
+ import { createHmac, timingSafeEqual } from "crypto";
3
+ function verifyWebhook({
4
+ payload,
5
+ signature,
6
+ secret
7
+ }) {
8
+ if (!payload || !signature || !secret) return false;
9
+ const expected = createHmac("sha256", secret).update(payload, "utf8").digest("hex");
10
+ if (expected.length !== signature.length) return false;
11
+ try {
12
+ return timingSafeEqual(
13
+ Buffer.from(expected, "hex"),
14
+ Buffer.from(signature, "hex")
15
+ );
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+ export {
21
+ verifyWebhook
22
+ };
23
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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":[]}
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@whatalo/plugin-sdk",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "Official TypeScript SDK for building Whatalo plugins",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.mjs",
9
+ "types": "./dist/index.d.ts",
10
+ "sideEffects": false,
11
+ "engines": {
12
+ "node": ">=18"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.mjs",
18
+ "require": "./dist/index.cjs"
19
+ },
20
+ "./adapters/nextjs": {
21
+ "types": "./dist/adapters/nextjs.d.ts",
22
+ "import": "./dist/adapters/nextjs.mjs",
23
+ "require": "./dist/adapters/nextjs.cjs"
24
+ },
25
+ "./adapters/hono": {
26
+ "types": "./dist/adapters/hono.d.ts",
27
+ "import": "./dist/adapters/hono.mjs",
28
+ "require": "./dist/adapters/hono.cjs"
29
+ },
30
+ "./adapters/express": {
31
+ "types": "./dist/adapters/express.d.ts",
32
+ "import": "./dist/adapters/express.mjs",
33
+ "require": "./dist/adapters/express.cjs"
34
+ },
35
+ "./webhooks": {
36
+ "types": "./dist/webhooks/index.d.ts",
37
+ "import": "./dist/webhooks/index.mjs",
38
+ "require": "./dist/webhooks/index.cjs"
39
+ },
40
+ "./manifest": {
41
+ "types": "./dist/manifest/index.d.ts",
42
+ "import": "./dist/manifest/index.mjs",
43
+ "require": "./dist/manifest/index.cjs"
44
+ },
45
+ "./bridge": {
46
+ "types": "./dist/bridge/index.d.ts",
47
+ "import": "./dist/bridge/index.mjs",
48
+ "require": "./dist/bridge/index.cjs"
49
+ }
50
+ },
51
+ "files": [
52
+ "dist",
53
+ "README.md",
54
+ "LICENSE"
55
+ ],
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "keywords": [
60
+ "whatalo",
61
+ "plugin-sdk",
62
+ "api",
63
+ "ecommerce",
64
+ "latam",
65
+ "cod"
66
+ ],
67
+ "peerDependencies": {
68
+ "react": ">=18",
69
+ "react-dom": ">=18"
70
+ },
71
+ "peerDependenciesMeta": {
72
+ "react": {
73
+ "optional": false
74
+ },
75
+ "react-dom": {
76
+ "optional": false
77
+ }
78
+ },
79
+ "devDependencies": {
80
+ "@types/react": "^19.0.0",
81
+ "tsup": "^8.0.0",
82
+ "typescript": "^5.7.0",
83
+ "vitest": "^3.2.4"
84
+ },
85
+ "scripts": {
86
+ "build": "tsup",
87
+ "dev": "tsup --watch",
88
+ "vitest": "vitest",
89
+ "test": "vitest run",
90
+ "test:watch": "vitest",
91
+ "type-check": "tsc --noEmit",
92
+ "clean": "rm -rf dist"
93
+ }
94
+ }