@invect/webhooks 0.0.1 → 0.0.3

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 (39) hide show
  1. package/README.md +79 -0
  2. package/dist/backend/index.cjs +12 -3
  3. package/dist/backend/index.cjs.map +1 -1
  4. package/dist/backend/index.d.cts +115 -0
  5. package/dist/backend/index.d.cts.map +1 -0
  6. package/dist/backend/index.d.mts +115 -0
  7. package/dist/backend/index.d.mts.map +1 -0
  8. package/dist/backend/index.d.ts +1 -1
  9. package/dist/backend/index.d.ts.map +1 -1
  10. package/dist/backend/index.mjs +12 -3
  11. package/dist/backend/index.mjs.map +1 -1
  12. package/dist/backend/plugin.d.ts +9 -2
  13. package/dist/backend/plugin.d.ts.map +1 -1
  14. package/dist/backend/webhook-dedup.service.d.ts.map +1 -1
  15. package/dist/backend/webhook-signature.service.d.ts.map +1 -1
  16. package/dist/frontend/components/CreateWebhookModal.d.ts.map +1 -1
  17. package/dist/frontend/components/WebhookDetailPanel.d.ts.map +1 -1
  18. package/dist/frontend/components/WebhooksPage.d.ts.map +1 -1
  19. package/dist/frontend/hooks/useWebhookQueries.d.ts +1 -1
  20. package/dist/frontend/hooks/useWebhookQueries.d.ts.map +1 -1
  21. package/dist/frontend/index.cjs +46 -46
  22. package/dist/frontend/index.cjs.map +1 -1
  23. package/dist/frontend/index.d.cts +70 -0
  24. package/dist/frontend/index.d.cts.map +1 -0
  25. package/dist/frontend/index.d.mts +70 -0
  26. package/dist/frontend/index.d.mts.map +1 -0
  27. package/dist/frontend/index.d.ts +2 -2
  28. package/dist/frontend/index.d.ts.map +1 -1
  29. package/dist/frontend/index.mjs +28 -28
  30. package/dist/frontend/index.mjs.map +1 -1
  31. package/dist/frontend/plugins/webhooksFrontendPlugin.d.ts +2 -2
  32. package/dist/frontend/plugins/webhooksFrontendPlugin.d.ts.map +1 -1
  33. package/dist/shared/types.d.cts +2 -0
  34. package/dist/shared/types.d.mts +2 -0
  35. package/dist/types-cBOT0AqR.d.cts +83 -0
  36. package/dist/types-cBOT0AqR.d.cts.map +1 -0
  37. package/dist/types-zH7xu7mA.d.mts +83 -0
  38. package/dist/types-zH7xu7mA.d.mts.map +1 -0
  39. package/package.json +49 -50
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="../../../.github/assets/logo-light.svg">
4
+ <img alt="Invect" src="../../../.github/assets/logo-dark.svg" width="50">
5
+ </picture>
6
+ </p>
7
+
8
+ <h1 align="center">@invect/webhooks</h1>
9
+
10
+ <p align="center">
11
+ Webhook trigger plugin for Invect.
12
+ <br />
13
+ <a href="https://invect.dev/docs/plugins"><strong>Docs</strong></a>
14
+ </p>
15
+
16
+ ---
17
+
18
+ Adds webhook management, ingestion, signature verification, and rate limiting to Invect. Create webhook endpoints that trigger flow runs when external services send events.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ pnpm add @invect/webhooks
24
+ ```
25
+
26
+ ## Backend
27
+
28
+ ```ts
29
+ import { webhooksPlugin } from '@invect/webhooks';
30
+
31
+ const invectRouter = await createInvectRouter({
32
+ database: { type: 'sqlite', connectionString: 'file:./dev.db' },
33
+ encryptionKey: process.env.INVECT_ENCRYPTION_KEY!,
34
+ plugins: [webhooksPlugin()],
35
+ });
36
+
37
+ app.use('/invect', invectRouter);
38
+ ```
39
+
40
+ ### Options
41
+
42
+ ```ts
43
+ webhooksPlugin({
44
+ webhookBaseUrl: 'https://example.com/api/invect', // Base URL for webhook endpoints
45
+ rateLimitMaxRequests: 60, // Max requests per window (default: 60)
46
+ rateLimitWindowMs: 60_000, // Rate limit window in ms (default: 60s)
47
+ dedupTtlMs: 86_400_000, // Deduplication TTL in ms (default: 24h)
48
+ });
49
+ ```
50
+
51
+ ## Frontend
52
+
53
+ ```tsx
54
+ import { Invect } from '@invect/ui';
55
+ import { webhooksFrontendPlugin } from '@invect/webhooks/ui';
56
+
57
+ <Invect apiBaseUrl="/api/invect" plugins={[webhooksFrontendPlugin]} />;
58
+ ```
59
+
60
+ The plugin adds a Webhooks page to the sidebar for managing webhook triggers.
61
+
62
+ ## Features
63
+
64
+ - **Signature verification** — HMAC validation for GitHub, GitLab, Slack, and generic providers.
65
+ - **Rate limiting** — Per-IP/path rate limiting with configurable windows.
66
+ - **Deduplication** — Idempotency via event deduplication (24h TTL default).
67
+ - **IP allowlisting** — Restrict webhook sources by IP address.
68
+
69
+ ## Exports
70
+
71
+ | Entry Point | Content |
72
+ | ------------------------ | ---------------------------------------------------------- |
73
+ | `@invect/webhooks` | Backend plugin (Node.js) |
74
+ | `@invect/webhooks/ui` | Frontend plugin — `webhooksFrontendPlugin`, `WebhooksPage` |
75
+ | `@invect/webhooks/types` | Shared types |
76
+
77
+ ## License
78
+
79
+ [MIT](../../../LICENSE)
@@ -3264,7 +3264,16 @@ function generateWebhookPath() {
3264
3264
  for (let i = 0; i < 24; i++) path += chars[Math.floor(Math.random() * 36)];
3265
3265
  return path;
3266
3266
  }
3267
- function webhooksPlugin(options) {
3267
+ function webhooks(options) {
3268
+ const { frontend, ...backendOptions } = options ?? {};
3269
+ return {
3270
+ id: "webhooks",
3271
+ name: "Webhooks",
3272
+ backend: _webhooksBackendPlugin(backendOptions),
3273
+ frontend
3274
+ };
3275
+ }
3276
+ function _webhooksBackendPlugin(options) {
3268
3277
  let state = null;
3269
3278
  function createEndpoints() {
3270
3279
  return [
@@ -3490,7 +3499,7 @@ function webhooksPlugin(options) {
3490
3499
  state = null;
3491
3500
  }
3492
3501
  },
3493
- setupInstructions: "Run `npx invect generate` to generate the webhook_triggers table schema, then `npx invect migrate` to apply it."
3502
+ setupInstructions: "Run `npx invect-cli generate` to generate the webhook_triggers table schema, then `npx invect-cli migrate` to apply it."
3494
3503
  };
3495
3504
  }
3496
3505
  //#endregion
@@ -3498,6 +3507,6 @@ exports.WEBHOOK_PROVIDER_SIGNATURES = WEBHOOK_PROVIDER_SIGNATURES;
3498
3507
  exports.WebhookDedupService = WebhookDedupService;
3499
3508
  exports.WebhookRateLimiter = WebhookRateLimiter;
3500
3509
  exports.WebhookSignatureService = WebhookSignatureService;
3501
- exports.webhooksPlugin = webhooksPlugin;
3510
+ exports.webhooks = webhooks;
3502
3511
 
3503
3512
  //# sourceMappingURL=index.cjs.map