@squaredr/fieldcraft-webhook 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.
- package/LICENSE +21 -0
- package/README.md +125 -0
- package/dist/index.d.mts +39 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +117 -0
- package/dist/index.mjs +77 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present SquaredR
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# @squaredr/fieldcraft-webhook
|
|
2
|
+
|
|
3
|
+
Webhook delivery adapter for [FieldCraft](https://squaredr.tech/products/fieldcraft). POST form responses to any endpoint with HMAC-SHA256 signing and configurable retry with exponential backoff.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @squaredr/fieldcraft-webhook
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Peer dependency:** Requires `@squaredr/fieldcraft-core` v1.0.0+.
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { createWebhookAdapter } from '@squaredr/fieldcraft-webhook'
|
|
17
|
+
|
|
18
|
+
const adapter = createWebhookAdapter({
|
|
19
|
+
url: 'https://api.example.com/form-submissions',
|
|
20
|
+
secret: process.env.WEBHOOK_SECRET,
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Pass the adapter to your form engine's `onSubmit`:
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
<FormEngineRenderer
|
|
28
|
+
schema={schema}
|
|
29
|
+
onSubmit={(response) => adapter.submit(response)}
|
|
30
|
+
/>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## HMAC-SHA256 Signing
|
|
34
|
+
|
|
35
|
+
Every request includes an `X-FormEngine-Signature` header with a SHA256 HMAC of the payload body. Verify it on your server:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { signPayload } from '@squaredr/fieldcraft-webhook'
|
|
39
|
+
|
|
40
|
+
// On your server:
|
|
41
|
+
const expected = signPayload(requestBody, secret)
|
|
42
|
+
const received = req.headers['x-formengine-signature'].replace('sha256=', '')
|
|
43
|
+
|
|
44
|
+
if (expected !== received) {
|
|
45
|
+
return res.status(401).json({ error: 'Invalid signature' })
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Retries
|
|
50
|
+
|
|
51
|
+
The adapter retries failed requests with configurable backoff:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const adapter = createWebhookAdapter({
|
|
55
|
+
url: 'https://api.example.com/submissions',
|
|
56
|
+
secret: process.env.WEBHOOK_SECRET,
|
|
57
|
+
retries: 5, // max retry attempts (default: 3)
|
|
58
|
+
retryDelayMs: 2000, // base delay in ms (default: 1000)
|
|
59
|
+
retryBackoff: 'exponential', // 'linear' or 'exponential' (default: 'exponential')
|
|
60
|
+
timeoutMs: 15000, // request timeout (default: 30000)
|
|
61
|
+
onRetry: (attempt, delay) => {
|
|
62
|
+
console.log(`Retry ${attempt}, waiting ${delay}ms`)
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Payload Transform
|
|
68
|
+
|
|
69
|
+
Customize the request body shape before sending:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const adapter = createWebhookAdapter({
|
|
73
|
+
url: 'https://api.example.com/submissions',
|
|
74
|
+
secret: process.env.WEBHOOK_SECRET,
|
|
75
|
+
transform: (response) => ({
|
|
76
|
+
form_id: response.schemaId,
|
|
77
|
+
answers: response.values,
|
|
78
|
+
submitted: response.submittedAt,
|
|
79
|
+
}),
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Custom Headers
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const adapter = createWebhookAdapter({
|
|
87
|
+
url: 'https://api.example.com/submissions',
|
|
88
|
+
secret: process.env.WEBHOOK_SECRET,
|
|
89
|
+
headers: {
|
|
90
|
+
'Authorization': `Bearer ${process.env.API_TOKEN}`,
|
|
91
|
+
'X-Custom-Header': 'value',
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Configuration
|
|
97
|
+
|
|
98
|
+
| Option | Type | Required | Description |
|
|
99
|
+
|---|---|---|---|
|
|
100
|
+
| `url` | `string` | Yes | Webhook endpoint URL |
|
|
101
|
+
| `secret` | `string` | Yes | HMAC-SHA256 signing secret |
|
|
102
|
+
| `retries` | `number` | No | Max retry attempts (default: 3) |
|
|
103
|
+
| `retryDelayMs` | `number` | No | Base delay in ms (default: 1000) |
|
|
104
|
+
| `retryBackoff` | `'linear' \| 'exponential'` | No | Backoff strategy (default: `'exponential'`) |
|
|
105
|
+
| `timeoutMs` | `number` | No | Request timeout in ms (default: 30000) |
|
|
106
|
+
| `headers` | `Record<string, string>` | No | Custom HTTP headers |
|
|
107
|
+
| `transform` | `(response) => any` | No | Payload transform function |
|
|
108
|
+
| `onSuccess` | `(response, status) => void` | No | Callback after successful delivery |
|
|
109
|
+
| `onError` | `(error, attempt) => void` | No | Callback on delivery failure |
|
|
110
|
+
| `onRetry` | `(attempt, delay) => void` | No | Callback before each retry |
|
|
111
|
+
|
|
112
|
+
## Request Headers
|
|
113
|
+
|
|
114
|
+
Every webhook request includes:
|
|
115
|
+
|
|
116
|
+
| Header | Value |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `Content-Type` | `application/json` |
|
|
119
|
+
| `X-FormEngine-Signature` | `sha256={hmac}` |
|
|
120
|
+
| `X-FormEngine-Event` | `submit` |
|
|
121
|
+
| `X-FormEngine-Timestamp` | ISO 8601 timestamp |
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FormResponse, SubmitAdapter } from '@squaredr/fieldcraft-core';
|
|
2
|
+
|
|
3
|
+
type WebhookAdapterConfig = {
|
|
4
|
+
/** Webhook endpoint URL (HTTPS recommended) */
|
|
5
|
+
url: string;
|
|
6
|
+
/** HMAC signing secret */
|
|
7
|
+
secret: string;
|
|
8
|
+
/** Max retries (default: 3) */
|
|
9
|
+
retries?: number;
|
|
10
|
+
/** Base retry delay in ms (default: 1000) */
|
|
11
|
+
retryDelayMs?: number;
|
|
12
|
+
/** Backoff strategy (default: "exponential") */
|
|
13
|
+
retryBackoff?: "linear" | "exponential";
|
|
14
|
+
/** Request timeout in ms (default: 30000) */
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
/** Additional headers to send */
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
/** Transform the response before sending */
|
|
19
|
+
transform?: (response: FormResponse) => unknown;
|
|
20
|
+
/** Called after successful delivery */
|
|
21
|
+
onSuccess?: (response: FormResponse, statusCode: number) => void;
|
|
22
|
+
/** Called on each error */
|
|
23
|
+
onError?: (error: Error, attempt: number) => void;
|
|
24
|
+
/** Called before each retry */
|
|
25
|
+
onRetry?: (attempt: number, delay: number) => void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** Create a webhook submit adapter with HMAC signing and retries. */
|
|
29
|
+
declare function createWebhookAdapter(config: WebhookAdapterConfig): SubmitAdapter;
|
|
30
|
+
|
|
31
|
+
/** Sign a JSON payload string with HMAC-SHA256. Returns hex digest. */
|
|
32
|
+
declare function signPayload(payload: string, secret: string): string;
|
|
33
|
+
|
|
34
|
+
/** Calculate delay for a retry attempt. */
|
|
35
|
+
declare function calculateDelay(attempt: number, baseDelay: number, backoff: "linear" | "exponential"): number;
|
|
36
|
+
/** Sleep for a given number of milliseconds. */
|
|
37
|
+
declare function sleep(ms: number): Promise<void>;
|
|
38
|
+
|
|
39
|
+
export { type WebhookAdapterConfig, calculateDelay, createWebhookAdapter, signPayload, sleep };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FormResponse, SubmitAdapter } from '@squaredr/fieldcraft-core';
|
|
2
|
+
|
|
3
|
+
type WebhookAdapterConfig = {
|
|
4
|
+
/** Webhook endpoint URL (HTTPS recommended) */
|
|
5
|
+
url: string;
|
|
6
|
+
/** HMAC signing secret */
|
|
7
|
+
secret: string;
|
|
8
|
+
/** Max retries (default: 3) */
|
|
9
|
+
retries?: number;
|
|
10
|
+
/** Base retry delay in ms (default: 1000) */
|
|
11
|
+
retryDelayMs?: number;
|
|
12
|
+
/** Backoff strategy (default: "exponential") */
|
|
13
|
+
retryBackoff?: "linear" | "exponential";
|
|
14
|
+
/** Request timeout in ms (default: 30000) */
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
/** Additional headers to send */
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
/** Transform the response before sending */
|
|
19
|
+
transform?: (response: FormResponse) => unknown;
|
|
20
|
+
/** Called after successful delivery */
|
|
21
|
+
onSuccess?: (response: FormResponse, statusCode: number) => void;
|
|
22
|
+
/** Called on each error */
|
|
23
|
+
onError?: (error: Error, attempt: number) => void;
|
|
24
|
+
/** Called before each retry */
|
|
25
|
+
onRetry?: (attempt: number, delay: number) => void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** Create a webhook submit adapter with HMAC signing and retries. */
|
|
29
|
+
declare function createWebhookAdapter(config: WebhookAdapterConfig): SubmitAdapter;
|
|
30
|
+
|
|
31
|
+
/** Sign a JSON payload string with HMAC-SHA256. Returns hex digest. */
|
|
32
|
+
declare function signPayload(payload: string, secret: string): string;
|
|
33
|
+
|
|
34
|
+
/** Calculate delay for a retry attempt. */
|
|
35
|
+
declare function calculateDelay(attempt: number, baseDelay: number, backoff: "linear" | "exponential"): number;
|
|
36
|
+
/** Sleep for a given number of milliseconds. */
|
|
37
|
+
declare function sleep(ms: number): Promise<void>;
|
|
38
|
+
|
|
39
|
+
export { type WebhookAdapterConfig, calculateDelay, createWebhookAdapter, signPayload, sleep };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
calculateDelay: () => calculateDelay,
|
|
34
|
+
createWebhookAdapter: () => createWebhookAdapter,
|
|
35
|
+
signPayload: () => signPayload,
|
|
36
|
+
sleep: () => sleep
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
39
|
+
|
|
40
|
+
// src/signer.ts
|
|
41
|
+
var import_node_crypto = __toESM(require("crypto"));
|
|
42
|
+
function signPayload(payload, secret) {
|
|
43
|
+
return import_node_crypto.default.createHmac("sha256", secret).update(payload).digest("hex");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/retry.ts
|
|
47
|
+
function calculateDelay(attempt, baseDelay, backoff) {
|
|
48
|
+
if (backoff === "linear") return baseDelay * attempt;
|
|
49
|
+
const delay = baseDelay * Math.pow(2, attempt - 1);
|
|
50
|
+
const jitter = Math.random() * delay * 0.1;
|
|
51
|
+
return Math.floor(delay + jitter);
|
|
52
|
+
}
|
|
53
|
+
function sleep(ms) {
|
|
54
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/webhook-adapter.ts
|
|
58
|
+
function createWebhookAdapter(config) {
|
|
59
|
+
const maxRetries = config.retries ?? 3;
|
|
60
|
+
const baseDelay = config.retryDelayMs ?? 1e3;
|
|
61
|
+
const backoff = config.retryBackoff ?? "exponential";
|
|
62
|
+
const timeoutMs = config.timeoutMs ?? 3e4;
|
|
63
|
+
return {
|
|
64
|
+
name: "webhook",
|
|
65
|
+
async submit(response) {
|
|
66
|
+
const payload = config.transform ? config.transform(response) : response;
|
|
67
|
+
const body = JSON.stringify(payload);
|
|
68
|
+
const signature = signPayload(body, config.secret);
|
|
69
|
+
for (let attempt = 1; attempt <= maxRetries + 1; attempt++) {
|
|
70
|
+
try {
|
|
71
|
+
const controller = new AbortController();
|
|
72
|
+
const timeout = setTimeout(
|
|
73
|
+
() => controller.abort(),
|
|
74
|
+
timeoutMs
|
|
75
|
+
);
|
|
76
|
+
const res = await fetch(config.url, {
|
|
77
|
+
method: "POST",
|
|
78
|
+
headers: {
|
|
79
|
+
"Content-Type": "application/json",
|
|
80
|
+
"X-FormEngine-Signature": `sha256=${signature}`,
|
|
81
|
+
"X-FormEngine-Event": "submit",
|
|
82
|
+
"X-FormEngine-Timestamp": (/* @__PURE__ */ new Date()).toISOString(),
|
|
83
|
+
...config.headers
|
|
84
|
+
},
|
|
85
|
+
body,
|
|
86
|
+
signal: controller.signal
|
|
87
|
+
});
|
|
88
|
+
clearTimeout(timeout);
|
|
89
|
+
if (res.ok) {
|
|
90
|
+
config.onSuccess?.(response, res.status);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
throw new Error(
|
|
94
|
+
`Webhook returned ${res.status}: ${res.statusText}`
|
|
95
|
+
);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
config.onError?.(error, attempt);
|
|
98
|
+
if (attempt <= maxRetries) {
|
|
99
|
+
const delay = calculateDelay(attempt, baseDelay, backoff);
|
|
100
|
+
config.onRetry?.(attempt, delay);
|
|
101
|
+
await sleep(delay);
|
|
102
|
+
} else {
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
onError: config.onError ? (err) => config.onError(err, 0) : void 0
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
calculateDelay,
|
|
114
|
+
createWebhookAdapter,
|
|
115
|
+
signPayload,
|
|
116
|
+
sleep
|
|
117
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/signer.ts
|
|
2
|
+
import crypto from "crypto";
|
|
3
|
+
function signPayload(payload, secret) {
|
|
4
|
+
return crypto.createHmac("sha256", secret).update(payload).digest("hex");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// src/retry.ts
|
|
8
|
+
function calculateDelay(attempt, baseDelay, backoff) {
|
|
9
|
+
if (backoff === "linear") return baseDelay * attempt;
|
|
10
|
+
const delay = baseDelay * Math.pow(2, attempt - 1);
|
|
11
|
+
const jitter = Math.random() * delay * 0.1;
|
|
12
|
+
return Math.floor(delay + jitter);
|
|
13
|
+
}
|
|
14
|
+
function sleep(ms) {
|
|
15
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/webhook-adapter.ts
|
|
19
|
+
function createWebhookAdapter(config) {
|
|
20
|
+
const maxRetries = config.retries ?? 3;
|
|
21
|
+
const baseDelay = config.retryDelayMs ?? 1e3;
|
|
22
|
+
const backoff = config.retryBackoff ?? "exponential";
|
|
23
|
+
const timeoutMs = config.timeoutMs ?? 3e4;
|
|
24
|
+
return {
|
|
25
|
+
name: "webhook",
|
|
26
|
+
async submit(response) {
|
|
27
|
+
const payload = config.transform ? config.transform(response) : response;
|
|
28
|
+
const body = JSON.stringify(payload);
|
|
29
|
+
const signature = signPayload(body, config.secret);
|
|
30
|
+
for (let attempt = 1; attempt <= maxRetries + 1; attempt++) {
|
|
31
|
+
try {
|
|
32
|
+
const controller = new AbortController();
|
|
33
|
+
const timeout = setTimeout(
|
|
34
|
+
() => controller.abort(),
|
|
35
|
+
timeoutMs
|
|
36
|
+
);
|
|
37
|
+
const res = await fetch(config.url, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
"X-FormEngine-Signature": `sha256=${signature}`,
|
|
42
|
+
"X-FormEngine-Event": "submit",
|
|
43
|
+
"X-FormEngine-Timestamp": (/* @__PURE__ */ new Date()).toISOString(),
|
|
44
|
+
...config.headers
|
|
45
|
+
},
|
|
46
|
+
body,
|
|
47
|
+
signal: controller.signal
|
|
48
|
+
});
|
|
49
|
+
clearTimeout(timeout);
|
|
50
|
+
if (res.ok) {
|
|
51
|
+
config.onSuccess?.(response, res.status);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Webhook returned ${res.status}: ${res.statusText}`
|
|
56
|
+
);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
config.onError?.(error, attempt);
|
|
59
|
+
if (attempt <= maxRetries) {
|
|
60
|
+
const delay = calculateDelay(attempt, baseDelay, backoff);
|
|
61
|
+
config.onRetry?.(attempt, delay);
|
|
62
|
+
await sleep(delay);
|
|
63
|
+
} else {
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
onError: config.onError ? (err) => config.onError(err, 0) : void 0
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
calculateDelay,
|
|
74
|
+
createWebhookAdapter,
|
|
75
|
+
signPayload,
|
|
76
|
+
sleep
|
|
77
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@squaredr/fieldcraft-webhook",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "FieldCraft webhook delivery adapter with HMAC-SHA256 signing and exponential backoff retries",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": ["dist", "LICENSE"],
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"clean": "rm -rf dist"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@squaredr/fieldcraft-core": "^1.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^22",
|
|
28
|
+
"typescript": "^5.5",
|
|
29
|
+
"tsup": "^8.0",
|
|
30
|
+
"vitest": "^2.0"
|
|
31
|
+
},
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"author": "SquaredR",
|
|
34
|
+
"homepage": "https://squaredr.tech/products/fieldcraft",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/SquaredR98/fieldcraft/issues"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/SquaredR98/fieldcraft.git",
|
|
41
|
+
"directory": "packages/adapters/webhook"
|
|
42
|
+
},
|
|
43
|
+
"keywords": ["fieldcraft", "form-engine", "webhook", "hmac", "adapter", "retry"],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
}
|
|
47
|
+
}
|