@noresponse/node 6.0.0 → 6.0.1
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/CHANGELOG.md +4 -0
- package/README.md +6 -6
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -276,18 +276,18 @@ await nr.webhookEndpoints.sendTestEvent(endpoint.endpointId, "assessment.updated
|
|
|
276
276
|
Verify the exact bytes you received, then act on the typed event. `secrets` maps each `whk_` key id to its secret; hold both during a rotation.
|
|
277
277
|
|
|
278
278
|
```ts
|
|
279
|
-
import { constructEvent,
|
|
279
|
+
import { constructEvent, WebhookVerificationError } from "@noresponse/node";
|
|
280
280
|
|
|
281
281
|
// Express: app.post("/webhooks/noresponse", express.raw({ type: "*/*" }), handler)
|
|
282
282
|
async function handler(req, res) {
|
|
283
283
|
let event;
|
|
284
284
|
try {
|
|
285
|
-
event = constructEvent(req.body, req.headers, { [process.env.NORESPONSE_WEBHOOK_KEY_ID]: process.env.NORESPONSE_WEBHOOK_SECRET });
|
|
285
|
+
event = await constructEvent(req.body, req.headers, { [process.env.NORESPONSE_WEBHOOK_KEY_ID]: process.env.NORESPONSE_WEBHOOK_SECRET });
|
|
286
286
|
} catch (error) {
|
|
287
287
|
if (error instanceof WebhookVerificationError) return res.status(400).end();
|
|
288
288
|
throw error;
|
|
289
289
|
}
|
|
290
|
-
if (event.type === "endpoint.verification") return res.json(
|
|
290
|
+
if (event.type === "endpoint.verification") return res.json({ challenge: event.data.challenge });
|
|
291
291
|
if (event.type === "account.deleted") {
|
|
292
292
|
// You erased it with accounts.delete: drop what was created at or before deletedAt,
|
|
293
293
|
// and ignore late updates of those assessments. A newer assessment of the account stays.
|
|
@@ -310,8 +310,8 @@ async function handler(req, res) {
|
|
|
310
310
|
applyDecisions(event.data.account.id, event.data.account.decisionsByFlow);
|
|
311
311
|
return res.status(204).end();
|
|
312
312
|
}
|
|
313
|
-
if (
|
|
314
|
-
forget(event.data.assessmentId); // GET now answers 404
|
|
313
|
+
if ("assessmentId" in event.data) {
|
|
314
|
+
forget(event.data.assessmentId); // the terminal expiry notice: GET now answers 404
|
|
315
315
|
} else if (event.test) {
|
|
316
316
|
// sendTestEvent's fixed example assessment: apply nothing
|
|
317
317
|
} else if (isNewer(event.data)) { // keep the highest detail.assessmentVersion per assessment
|
|
@@ -321,7 +321,7 @@ async function handler(req, res) {
|
|
|
321
321
|
}
|
|
322
322
|
```
|
|
323
323
|
|
|
324
|
-
`constructEvent(payload, headers, secrets, { toleranceSeconds })` takes the raw body (a `Buffer`, `Uint8Array` or the exact text), any header object (Fetch `Headers`, Node `IncomingHttpHeaders`, a plain object or entries) and refuses a repeated signature header, a delivery older than 300 seconds, an unknown key id or a bad signature with a `WebhookVerificationError` whose `code` says which. Deliveries are at least once: deduplicate on `event.id`. The same
|
|
324
|
+
`constructEvent(payload, headers, secrets, { toleranceSeconds })` returns a promise. It takes the raw body (a `Buffer`, `Uint8Array` or the exact text), any header object (Fetch `Headers`, Node `IncomingHttpHeaders`, a plain object or entries) and refuses a repeated signature header, a delivery older than 300 seconds, an unknown key id or a bad signature with a `WebhookVerificationError` whose `code` says which. Deliveries are at least once: deduplicate on `event.id`. The same function is on `NoResponse.webhooks` and `nr.webhooks`. It uses Web Crypto.
|
|
325
325
|
|
|
326
326
|
### Late results
|
|
327
327
|
|
|
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
31
31
|
export declare const SDK_METADATA: {
|
|
32
32
|
readonly language: "typescript";
|
|
33
33
|
readonly openapiDocVersion: "1";
|
|
34
|
-
readonly sdkVersion: "6.0.
|
|
34
|
+
readonly sdkVersion: "6.0.1";
|
|
35
35
|
readonly genVersion: "internal";
|
|
36
|
-
readonly userAgent: "noresponse-sdk/typescript 6.0.
|
|
36
|
+
readonly userAgent: "noresponse-sdk/typescript 6.0.1 internal 1 @noresponse/node";
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -28,8 +28,8 @@ function serverURLFromOptions(options) {
|
|
|
28
28
|
exports.SDK_METADATA = {
|
|
29
29
|
language: "typescript",
|
|
30
30
|
openapiDocVersion: "1",
|
|
31
|
-
sdkVersion: "6.0.
|
|
31
|
+
sdkVersion: "6.0.1",
|
|
32
32
|
genVersion: "internal",
|
|
33
|
-
userAgent: "noresponse-sdk/typescript 6.0.
|
|
33
|
+
userAgent: "noresponse-sdk/typescript 6.0.1 internal 1 @noresponse/node",
|
|
34
34
|
};
|
|
35
35
|
//# sourceMappingURL=config.js.map
|
package/dist/esm/lib/config.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
31
31
|
export declare const SDK_METADATA: {
|
|
32
32
|
readonly language: "typescript";
|
|
33
33
|
readonly openapiDocVersion: "1";
|
|
34
|
-
readonly sdkVersion: "6.0.
|
|
34
|
+
readonly sdkVersion: "6.0.1";
|
|
35
35
|
readonly genVersion: "internal";
|
|
36
|
-
readonly userAgent: "noresponse-sdk/typescript 6.0.
|
|
36
|
+
readonly userAgent: "noresponse-sdk/typescript 6.0.1 internal 1 @noresponse/node";
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/esm/lib/config.js
CHANGED
|
@@ -24,8 +24,8 @@ export function serverURLFromOptions(options) {
|
|
|
24
24
|
export const SDK_METADATA = {
|
|
25
25
|
language: "typescript",
|
|
26
26
|
openapiDocVersion: "1",
|
|
27
|
-
sdkVersion: "6.0.
|
|
27
|
+
sdkVersion: "6.0.1",
|
|
28
28
|
genVersion: "internal",
|
|
29
|
-
userAgent: "noresponse-sdk/typescript 6.0.
|
|
29
|
+
userAgent: "noresponse-sdk/typescript 6.0.1 internal 1 @noresponse/node",
|
|
30
30
|
};
|
|
31
31
|
//# sourceMappingURL=config.js.map
|