@certen.io/sdk 0.12.0 → 0.13.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/CHANGELOG.md +38 -0
- package/README.md +33 -0
- package/dist/browser.d.ts +6 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +5 -1
- package/dist/browser.js.map +1 -1
- package/dist/errors.d.ts +26 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +18 -0
- package/dist/errors.js.map +1 -1
- package/dist/resources/webhooks.d.ts +44 -6
- package/dist/resources/webhooks.d.ts.map +1 -1
- package/dist/resources/webhooks.js +69 -11
- package/dist/resources/webhooks.js.map +1 -1
- package/dist/types.d.ts +40 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/webhook-events.d.ts +211 -0
- package/dist/webhook-events.d.ts.map +1 -0
- package/dist/webhook-events.js +75 -0
- package/dist/webhook-events.js.map +1 -0
- package/dist/webhook-signature.d.ts +258 -0
- package/dist/webhook-signature.d.ts.map +1 -0
- package/dist/webhook-signature.js +470 -0
- package/dist/webhook-signature.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signing and verifying CERTEN webhooks.
|
|
3
|
+
*
|
|
4
|
+
* The gateway has always signed every delivery, and its customer guide (`docs/verify-webhook.md`) has always told receivers to
|
|
5
|
+
* `import { verifyWebhookSignature } from '@certen.io/sdk'`. The SDK had no such export, so every receiver hand-rolled the HMAC —
|
|
6
|
+
* and the one mistake that matters here (hashing a re-serialized body instead of the bytes that arrived) is exactly what a
|
|
7
|
+
* hand-rolled receiver gets wrong, because the framework parsed the body before the handler ran.
|
|
8
|
+
*
|
|
9
|
+
* **The scheme** (gateway `src/webhooks/webhook-signature.ts` and `webhook.service.ts`; this file is checked against both):
|
|
10
|
+
*
|
|
11
|
+
* X-Certen-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + "." + body)>
|
|
12
|
+
*
|
|
13
|
+
* `body` is the request body. The gateway sends the *canonical JSON* of the payload (keys sorted at every level, no whitespace) as the
|
|
14
|
+
* body itself, so a receiver hashes the raw bytes and never has to canonicalize anything. Each attempt is signed afresh with a new `t`,
|
|
15
|
+
* which is why a delivery redelivered hours later still verifies.
|
|
16
|
+
*
|
|
17
|
+
* **What the signature covers, and what it does not.** `t` and the body, and nothing else. `X-Certen-Event`, `X-Certen-Delivery` and
|
|
18
|
+
* `X-Certen-Timestamp` are plain headers: anyone who can replay a captured (body, signature) pair inside the tolerance window can
|
|
19
|
+
* attach any of them. `ReceivedWebhook` therefore keeps them apart from the verified `payload`, and `timestamp` is the one taken from
|
|
20
|
+
* the signed header.
|
|
21
|
+
*
|
|
22
|
+
* Portable: nothing here touches `node:crypto`, `Buffer` or `process`. HMAC is built on `sha256.ts` (synchronous, so a verifier is a
|
|
23
|
+
* plain function in a Node handler, a Cloudflare Worker and the browser entry alike), and `webhook-signature.test.ts` holds it to
|
|
24
|
+
* RFC 4231 and to `node:crypto` at every length around the block boundary.
|
|
25
|
+
*/
|
|
26
|
+
import { sha256 } from './sha256.js';
|
|
27
|
+
import { bytesToHex, concatBytes, hexToBytes, utf8 } from './bytes.js';
|
|
28
|
+
import { CertenError, CertenWebhookSignatureError } from './errors.js';
|
|
29
|
+
/** The only signature version the gateway emits today. A future one arrives alongside it in the same header as `v2=…`. */
|
|
30
|
+
export const WEBHOOK_SIGNATURE_VERSION = 'v1';
|
|
31
|
+
/** How far `t` may sit from now, either side, before an authentic signature is refused as a replay. */
|
|
32
|
+
export const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
33
|
+
export const WEBHOOK_SIGNATURE_HEADER = 'X-Certen-Signature';
|
|
34
|
+
/** The event name. NOT covered by the signature. */
|
|
35
|
+
export const WEBHOOK_EVENT_HEADER = 'X-Certen-Event';
|
|
36
|
+
/** One id per delivery, stable across retries and redelivery. NOT covered by the signature. Absent on the verification ping. */
|
|
37
|
+
export const WEBHOOK_DELIVERY_HEADER = 'X-Certen-Delivery';
|
|
38
|
+
/** A copy of `t`. NOT covered by the signature — read `t` from the signature header, which is. */
|
|
39
|
+
export const WEBHOOK_TIMESTAMP_HEADER = 'X-Certen-Timestamp';
|
|
40
|
+
/** The gateway refuses to sign with less (and `rotate-secret` refuses to be given less than 16). A shorter secret is a misconfiguration. */
|
|
41
|
+
const MIN_SECRET_LENGTH = 8;
|
|
42
|
+
/** The failure diagnostics re-parse the body; bound the work an unauthenticated sender can make a verifier do. */
|
|
43
|
+
const DIAGNOSE_MAX_BYTES = 256 * 1024;
|
|
44
|
+
const MAX_TIMESTAMP_DIGITS = 15;
|
|
45
|
+
const MAX_NESTING = 512;
|
|
46
|
+
// ── HMAC-SHA256 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
47
|
+
const HMAC_BLOCK = 64;
|
|
48
|
+
/** HMAC-SHA256 (RFC 2104 / RFC 4231). Exported for the tests and for callers who need the primitive; not part of the package entry. */
|
|
49
|
+
export function hmacSha256(key, message) {
|
|
50
|
+
const k = key.length > HMAC_BLOCK ? sha256(key) : key;
|
|
51
|
+
const inner = new Uint8Array(HMAC_BLOCK);
|
|
52
|
+
const outer = new Uint8Array(HMAC_BLOCK);
|
|
53
|
+
for (let i = 0; i < HMAC_BLOCK; i++) {
|
|
54
|
+
const b = i < k.length ? k[i] : 0;
|
|
55
|
+
inner[i] = b ^ 0x36;
|
|
56
|
+
outer[i] = b ^ 0x5c;
|
|
57
|
+
}
|
|
58
|
+
return sha256(concatBytes(outer, sha256(concatBytes(inner, message))));
|
|
59
|
+
}
|
|
60
|
+
/** Equal-length byte comparison that does not stop at the first difference. Unequal lengths are unequal (a length is not a secret). */
|
|
61
|
+
function timingSafeEqual(a, b) {
|
|
62
|
+
if (a.length !== b.length)
|
|
63
|
+
return false;
|
|
64
|
+
let diff = 0;
|
|
65
|
+
for (let i = 0; i < a.length; i++)
|
|
66
|
+
diff |= a[i] ^ b[i];
|
|
67
|
+
return diff === 0;
|
|
68
|
+
}
|
|
69
|
+
// ── Canonical JSON ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
70
|
+
/**
|
|
71
|
+
* The gateway's canonical JSON: keys sorted at every object level, arrays in order, no whitespace. This is the string the gateway puts
|
|
72
|
+
* on the wire and signs, so `signWebhookPayload` needs it and a receiver that has only a parsed object can rebuild it.
|
|
73
|
+
*
|
|
74
|
+
* Matches the gateway byte for byte on JSON values (`webhook-signature.test.ts` fuzzes it against a verbatim copy of the gateway's
|
|
75
|
+
* implementation). It is STRICTER on what is not JSON: where the gateway turns a `Date`, `Map` or `Set` into `{}` — silently, so a
|
|
76
|
+
* signature over it verifies against nothing a receiver could rebuild — this throws.
|
|
77
|
+
*
|
|
78
|
+
* Prefer verifying the raw bytes. Rebuilding from a parsed object is only as faithful as the parse: a number beyond 2^53 or a duplicate
|
|
79
|
+
* key has already been altered by `JSON.parse` before this runs.
|
|
80
|
+
*/
|
|
81
|
+
export function canonicalizeWebhookPayload(value) {
|
|
82
|
+
return canonical(value, [], 0);
|
|
83
|
+
}
|
|
84
|
+
function canonical(value, ancestors, depth) {
|
|
85
|
+
if (value === null || value === undefined)
|
|
86
|
+
return 'null';
|
|
87
|
+
switch (typeof value) {
|
|
88
|
+
case 'boolean': return value ? 'true' : 'false';
|
|
89
|
+
case 'number':
|
|
90
|
+
if (!Number.isFinite(value))
|
|
91
|
+
throw new TypeError('canonicalizeWebhookPayload: NaN and Infinity are not JSON');
|
|
92
|
+
return JSON.stringify(value);
|
|
93
|
+
case 'string': return JSON.stringify(value);
|
|
94
|
+
case 'bigint': return value.toString();
|
|
95
|
+
case 'object': break;
|
|
96
|
+
default: throw new TypeError(`canonicalizeWebhookPayload: a ${typeof value} is not JSON`);
|
|
97
|
+
}
|
|
98
|
+
if (depth > MAX_NESTING)
|
|
99
|
+
throw new TypeError(`canonicalizeWebhookPayload: nested more than ${MAX_NESTING} levels deep`);
|
|
100
|
+
if (ancestors.includes(value))
|
|
101
|
+
throw new TypeError('canonicalizeWebhookPayload: circular structure');
|
|
102
|
+
ancestors.push(value);
|
|
103
|
+
try {
|
|
104
|
+
if (Array.isArray(value))
|
|
105
|
+
return `[${value.map((v) => canonical(v, ancestors, depth + 1)).join(',')}]`;
|
|
106
|
+
// Cross-realm safe (a vm context's Object.prototype is not ours), and it refuses Date / Map / Set / typed arrays outright.
|
|
107
|
+
const tag = Object.prototype.toString.call(value);
|
|
108
|
+
if (tag !== '[object Object]')
|
|
109
|
+
throw new TypeError(`canonicalizeWebhookPayload: a ${tag.slice(8, -1)} is not JSON — convert it first`);
|
|
110
|
+
const obj = value;
|
|
111
|
+
const parts = [];
|
|
112
|
+
for (const key of Object.keys(obj).sort()) {
|
|
113
|
+
const v = obj[key];
|
|
114
|
+
if (v === undefined)
|
|
115
|
+
continue; // an absent property, as JSON.stringify treats it
|
|
116
|
+
parts.push(`${JSON.stringify(key)}:${canonical(v, ancestors, depth + 1)}`);
|
|
117
|
+
}
|
|
118
|
+
return `{${parts.join(',')}}`;
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
ancestors.pop();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function misuse(code, message) {
|
|
125
|
+
return new CertenError(message, 0, code);
|
|
126
|
+
}
|
|
127
|
+
function readHeader(headers, name) {
|
|
128
|
+
if (!headers)
|
|
129
|
+
return undefined;
|
|
130
|
+
const h = headers;
|
|
131
|
+
if (typeof h.get === 'function') {
|
|
132
|
+
const v = h.get.call(headers, name);
|
|
133
|
+
return v === null || v === undefined ? undefined : String(v);
|
|
134
|
+
}
|
|
135
|
+
const want = name.toLowerCase();
|
|
136
|
+
for (const key of Object.keys(h)) {
|
|
137
|
+
if (key.toLowerCase() !== want)
|
|
138
|
+
continue;
|
|
139
|
+
const v = h[key];
|
|
140
|
+
if (Array.isArray(v))
|
|
141
|
+
return v.join(',');
|
|
142
|
+
return typeof v === 'string' ? v : undefined;
|
|
143
|
+
}
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
function toBytes(body) {
|
|
147
|
+
if (typeof body === 'string')
|
|
148
|
+
return utf8(body);
|
|
149
|
+
if (ArrayBuffer.isView(body))
|
|
150
|
+
return new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
|
|
151
|
+
if (Object.prototype.toString.call(body) === '[object ArrayBuffer]')
|
|
152
|
+
return new Uint8Array(body);
|
|
153
|
+
throw new TypeError('webhook body must be a string, a byte array (a Uint8Array, which includes a Node.js buffer) or an ArrayBuffer — the raw bytes of the request');
|
|
154
|
+
}
|
|
155
|
+
/** What the HMAC is over: `<t as written>.<body bytes>`. Bytes, not a decoded string, so a body that is not valid UTF-8 is hashed as received. */
|
|
156
|
+
function signedBytes(timestampText, body) {
|
|
157
|
+
return concatBytes(utf8(`${timestampText}.`), body);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Check the secret(s) BEFORE any comparison. The reference snippets read `process.env.CERTEN_WEBHOOK_SECRET ?? ''`; HMAC with an empty
|
|
161
|
+
* key is perfectly computable, so an unset variable would make every forged delivery verify. A secret that cannot have signed anything
|
|
162
|
+
* is a deployment error and is raised as one — on every delivery, loudly — never answered with a quiet `ok: false` that is
|
|
163
|
+
* indistinguishable from an attack. Never echoes the secret.
|
|
164
|
+
*/
|
|
165
|
+
function secretKeys(secret) {
|
|
166
|
+
const list = Array.isArray(secret) ? secret : [secret];
|
|
167
|
+
if (list.length === 0)
|
|
168
|
+
throw misuse('WEBHOOK_SECRET_INVALID', 'No webhook secret was given. Pass the signing secret returned when the endpoint was registered.');
|
|
169
|
+
const raw = [];
|
|
170
|
+
for (const [i, s] of list.entries()) {
|
|
171
|
+
if (typeof s !== 'string' || s.length === 0) {
|
|
172
|
+
throw misuse('WEBHOOK_SECRET_INVALID', `Webhook secret${list.length > 1 ? ` #${i + 1}` : ''} is ${typeof s === 'string' ? 'empty' : `${s === undefined ? 'undefined' : s === null ? 'null' : `${typeof s === 'object' ? 'an' : 'a'} ${typeof s}`}, not a string`}. `
|
|
173
|
+
+ 'Is the environment variable or secret-store entry it is read from set? Refusing to verify against it.');
|
|
174
|
+
}
|
|
175
|
+
if (s.length < MIN_SECRET_LENGTH) {
|
|
176
|
+
throw misuse('WEBHOOK_SECRET_INVALID', `Webhook secret${list.length > 1 ? ` #${i + 1}` : ''} is ${s.length} characters; the gateway never signs with fewer than ${MIN_SECRET_LENGTH}, `
|
|
177
|
+
+ 'so this is not the endpoint\'s secret. Refusing to verify against it.');
|
|
178
|
+
}
|
|
179
|
+
raw.push(s);
|
|
180
|
+
}
|
|
181
|
+
return { keys: raw.map(utf8), raw };
|
|
182
|
+
}
|
|
183
|
+
/** Throw `WEBHOOK_SECRET_INVALID` if `secret` could not have signed anything. For a caller that wants to fail before doing other work. */
|
|
184
|
+
export function assertWebhookSecret(secret) {
|
|
185
|
+
secretKeys(secret);
|
|
186
|
+
}
|
|
187
|
+
function nowSeconds(now) {
|
|
188
|
+
if (now === undefined)
|
|
189
|
+
return Math.floor(Date.now() / 1000);
|
|
190
|
+
const ms = typeof now === 'number' ? now * 1000 : typeof now?.getTime === 'function' ? now.getTime() : NaN;
|
|
191
|
+
if (!Number.isFinite(ms))
|
|
192
|
+
throw misuse('INVALID_WEBHOOK_OPTION', '`now` must be unix seconds (a number) or a Date.');
|
|
193
|
+
return Math.floor(ms / 1000);
|
|
194
|
+
}
|
|
195
|
+
function toleranceOf(seconds) {
|
|
196
|
+
if (seconds === undefined)
|
|
197
|
+
return DEFAULT_WEBHOOK_TOLERANCE_SECONDS;
|
|
198
|
+
// Infinity is refused on purpose. A verifier with no replay window accepts a captured request forever; a test that replays an old
|
|
199
|
+
// fixture says what time it is with `now`, which keeps the window honest.
|
|
200
|
+
if (typeof seconds !== 'number' || !Number.isFinite(seconds) || seconds < 0) {
|
|
201
|
+
throw misuse('INVALID_WEBHOOK_OPTION', '`toleranceSeconds` must be a finite number >= 0. To verify an old capture, pass `now` rather than widening the window.');
|
|
202
|
+
}
|
|
203
|
+
return seconds;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Split `t=<unix>,v1=<hex>[,v2=…]`. Strict about the parts that are signed over (one `t`, plain decimal digits; a `v1` that is 64 hex
|
|
207
|
+
* characters) because a lenient parse is how two parsers end up disagreeing about what was signed; ignorant of any key it does not
|
|
208
|
+
* know, so a header that gains a field keeps verifying.
|
|
209
|
+
*/
|
|
210
|
+
export function parseWebhookSignatureHeader(header) {
|
|
211
|
+
const bad = (message) => ({ ok: false, reason: 'malformed-signature', message });
|
|
212
|
+
let timestampText;
|
|
213
|
+
const signatures = [];
|
|
214
|
+
for (const raw of header.split(',')) {
|
|
215
|
+
const part = raw.trim();
|
|
216
|
+
if (part === '')
|
|
217
|
+
continue;
|
|
218
|
+
const eq = part.indexOf('=');
|
|
219
|
+
if (eq <= 0)
|
|
220
|
+
return bad(`The signature header has a part ("${part.slice(0, 24)}") that is not name=value.`);
|
|
221
|
+
const name = part.slice(0, eq).trim();
|
|
222
|
+
const value = part.slice(eq + 1).trim();
|
|
223
|
+
if (name === 't') {
|
|
224
|
+
if (timestampText !== undefined)
|
|
225
|
+
return bad('The signature header has more than one t=, so it is ambiguous what was signed.');
|
|
226
|
+
if (!new RegExp(`^[0-9]{1,${MAX_TIMESTAMP_DIGITS}}$`).test(value))
|
|
227
|
+
return bad('The signature header\'s t= is not a unix time in whole seconds.');
|
|
228
|
+
timestampText = value;
|
|
229
|
+
}
|
|
230
|
+
else if (/^v[0-9]+$/.test(name)) {
|
|
231
|
+
if (name === WEBHOOK_SIGNATURE_VERSION && !/^[0-9a-fA-F]{64}$/.test(value))
|
|
232
|
+
return bad('The signature header\'s v1= is not 64 hexadecimal characters.');
|
|
233
|
+
signatures.push({ version: name, value });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (timestampText === undefined)
|
|
237
|
+
return bad('The signature header has no t=. Expected t=<unix seconds>,v1=<hex>.');
|
|
238
|
+
if (signatures.length === 0)
|
|
239
|
+
return bad('The signature header has no v1=. Expected t=<unix seconds>,v1=<hex>.');
|
|
240
|
+
return { ok: true, timestamp: Number(timestampText), timestampText, signatures };
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Sign a payload the way the gateway signs a delivery, so a receiver can be exercised without waiting for a real event: send
|
|
244
|
+
* `canonicalPayload` as the body with `headers`, and `verifyWebhookSignature` on the far side accepts it.
|
|
245
|
+
*
|
|
246
|
+
* This produces a signature that a receiver holding the same secret will trust. It is a test tool — the gateway is the only party that
|
|
247
|
+
* signs deliveries for a real endpoint — and the secret it needs is the one you stored when the endpoint was registered.
|
|
248
|
+
*/
|
|
249
|
+
export function signWebhookPayload(secret, payload, options = {}) {
|
|
250
|
+
if (Array.isArray(secret))
|
|
251
|
+
throw misuse('WEBHOOK_SECRET_INVALID', 'signWebhookPayload signs with exactly one secret.');
|
|
252
|
+
const { keys } = secretKeys(secret);
|
|
253
|
+
const timestamp = options.timestamp ?? Math.floor(Date.now() / 1000);
|
|
254
|
+
if (!Number.isSafeInteger(timestamp) || timestamp < 0 || String(timestamp).length > MAX_TIMESTAMP_DIGITS) {
|
|
255
|
+
throw misuse('INVALID_WEBHOOK_OPTION', '`timestamp` must be a whole number of unix seconds.');
|
|
256
|
+
}
|
|
257
|
+
const canonicalPayload = canonicalizeWebhookPayload(payload);
|
|
258
|
+
const signatureHex = bytesToHex(hmacSha256(keys[0], signedBytes(String(timestamp), utf8(canonicalPayload))));
|
|
259
|
+
const header = `t=${timestamp},${WEBHOOK_SIGNATURE_VERSION}=${signatureHex}`;
|
|
260
|
+
const headers = {
|
|
261
|
+
'Content-Type': 'application/json',
|
|
262
|
+
[WEBHOOK_SIGNATURE_HEADER]: header,
|
|
263
|
+
[WEBHOOK_TIMESTAMP_HEADER]: String(timestamp),
|
|
264
|
+
};
|
|
265
|
+
if (options.event !== undefined)
|
|
266
|
+
headers[WEBHOOK_EVENT_HEADER] = options.event;
|
|
267
|
+
if (options.deliveryId !== undefined)
|
|
268
|
+
headers[WEBHOOK_DELIVERY_HEADER] = options.deliveryId;
|
|
269
|
+
return { header, timestamp, signatureHex, canonicalPayload, version: WEBHOOK_SIGNATURE_VERSION, headers };
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Is this delivery from CERTEN, intact, and recent?
|
|
273
|
+
*
|
|
274
|
+
* const v = verifyWebhookSignature({ body: rawBody, headers: req.headers, secret: process.env.CERTEN_WEBHOOK_SECRET! });
|
|
275
|
+
* if (!v.ok) return res.status(400).send(v.reason);
|
|
276
|
+
*
|
|
277
|
+
* Returns the verdict as data for the failures an attacker or a misconfigured proxy can cause (a bad header, a bad signature, a stale
|
|
278
|
+
* timestamp). THROWS for the failures only the caller can cause — no secret, a secret too short to be real, a nonsensical option —
|
|
279
|
+
* because those must not read as "someone sent a bad request".
|
|
280
|
+
*
|
|
281
|
+
* The signature is checked before the clock, so `timestamp-outside-tolerance` always means the sender holds a genuine signature: an
|
|
282
|
+
* old replay or a skewed clock, never a forgery. A match is found in constant time.
|
|
283
|
+
*/
|
|
284
|
+
export function verifyWebhookSignature(options) {
|
|
285
|
+
const { keys, raw } = secretKeys(options.secret);
|
|
286
|
+
const tolerance = toleranceOf(options.toleranceSeconds);
|
|
287
|
+
const now = nowSeconds(options.now);
|
|
288
|
+
const hasBody = options.body !== undefined;
|
|
289
|
+
const hasPayload = options.payload !== undefined;
|
|
290
|
+
if (hasBody === hasPayload)
|
|
291
|
+
throw misuse('INVALID_WEBHOOK_OPTION', 'Pass exactly one of `body` (the raw request bytes — preferred) or `payload` (an already-parsed body).');
|
|
292
|
+
const header = options.signature ?? readHeader(options.headers, WEBHOOK_SIGNATURE_HEADER);
|
|
293
|
+
if (typeof header !== 'string' || header.trim() === '') {
|
|
294
|
+
return {
|
|
295
|
+
ok: false, reason: 'missing-signature',
|
|
296
|
+
message: `No ${WEBHOOK_SIGNATURE_HEADER} header.`,
|
|
297
|
+
hint: options.signature === undefined && options.headers === undefined
|
|
298
|
+
? 'Neither `signature` nor `headers` was passed to the verifier.'
|
|
299
|
+
: 'A proxy or gateway in front of the receiver may be stripping it, or the handler is reading the wrong header name.',
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
const parsed = parseWebhookSignatureHeader(header);
|
|
303
|
+
if (!parsed.ok)
|
|
304
|
+
return { ok: false, reason: parsed.reason, message: parsed.message };
|
|
305
|
+
const candidates = parsed.signatures.filter((s) => s.version === WEBHOOK_SIGNATURE_VERSION).map((s) => hexToBytes(s.value));
|
|
306
|
+
if (candidates.length === 0) {
|
|
307
|
+
return {
|
|
308
|
+
ok: false, reason: 'unsupported-version',
|
|
309
|
+
message: `The signature header carries only ${parsed.signatures.map((s) => s.version).join(', ')}; this SDK verifies ${WEBHOOK_SIGNATURE_VERSION}.`,
|
|
310
|
+
hint: 'The gateway is newer than this SDK. Upgrade @certen.io/sdk.',
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
let bodyBytes;
|
|
314
|
+
if (hasBody) {
|
|
315
|
+
bodyBytes = toBytes(options.body);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
try {
|
|
319
|
+
bodyBytes = utf8(canonicalizeWebhookPayload(options.payload));
|
|
320
|
+
}
|
|
321
|
+
catch (err) {
|
|
322
|
+
// Nothing the gateway sent could have been this, so no signature of its can match it.
|
|
323
|
+
return { ok: false, reason: 'signature-mismatch', message: 'The parsed payload cannot be reduced to JSON.', hint: err.message };
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const signed = signedBytes(parsed.timestampText, bodyBytes);
|
|
327
|
+
let secretIndex = -1;
|
|
328
|
+
for (let i = 0; i < keys.length && secretIndex < 0; i++) {
|
|
329
|
+
const expected = hmacSha256(keys[i], signed);
|
|
330
|
+
let hit = false;
|
|
331
|
+
for (const c of candidates)
|
|
332
|
+
if (timingSafeEqual(expected, c))
|
|
333
|
+
hit = true; // no early exit between candidates
|
|
334
|
+
if (hit)
|
|
335
|
+
secretIndex = i;
|
|
336
|
+
}
|
|
337
|
+
if (secretIndex < 0) {
|
|
338
|
+
return {
|
|
339
|
+
ok: false, reason: 'signature-mismatch',
|
|
340
|
+
message: 'The signature does not match this body and secret.',
|
|
341
|
+
hint: diagnose(hasBody, bodyBytes, parsed.timestampText, keys, raw, candidates),
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
const ageSeconds = now - parsed.timestamp;
|
|
345
|
+
if (Math.abs(ageSeconds) > tolerance) {
|
|
346
|
+
return {
|
|
347
|
+
ok: false, reason: 'timestamp-outside-tolerance',
|
|
348
|
+
message: `The signature is authentic but was made ${Math.abs(ageSeconds)}s ${ageSeconds >= 0 ? 'ago' : 'in the future'}; the tolerance is ${tolerance}s.`,
|
|
349
|
+
hint: ageSeconds >= 0
|
|
350
|
+
? 'A replayed request, or this machine\'s clock is ahead of the gateway\'s.'
|
|
351
|
+
: 'This machine\'s clock is behind the gateway\'s.',
|
|
352
|
+
timestamp: parsed.timestamp, ageSeconds,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
return { ok: true, timestamp: parsed.timestamp, ageSeconds, version: WEBHOOK_SIGNATURE_VERSION, secretIndex };
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* On a mismatch, say which of the two usual mistakes it looks like. Runs only on the failure path and only on a bounded body, so it
|
|
359
|
+
* gives an unauthenticated sender no more work than verifying already did.
|
|
360
|
+
*/
|
|
361
|
+
function diagnose(hasBody, bytes, timestampText, keys, raw, candidates) {
|
|
362
|
+
const notes = [];
|
|
363
|
+
if (raw.some((s) => s !== s.trim())) {
|
|
364
|
+
notes.push('The secret has leading or trailing whitespace — a newline left on a value read from a file or a prompt is the usual cause.');
|
|
365
|
+
}
|
|
366
|
+
if (hasBody && bytes.length <= DIAGNOSE_MAX_BYTES) {
|
|
367
|
+
try {
|
|
368
|
+
const text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
369
|
+
const canon = canonicalizeWebhookPayload(JSON.parse(text));
|
|
370
|
+
if (canon !== text) {
|
|
371
|
+
const expected = keys.map((k) => hmacSha256(k, signedBytes(timestampText, utf8(canon))));
|
|
372
|
+
const hit = candidates.some((c) => expected.some((e) => timingSafeEqual(e, c)));
|
|
373
|
+
notes.push(hit
|
|
374
|
+
? 'The signature IS valid for the canonical form of this body, so the body was re-serialized before it reached the verifier (a JSON-parsing '
|
|
375
|
+
+ 'middleware ran first). Verify the raw bytes — express.raw({ type: \'application/json\' }), or request.arrayBuffer() — or pass `payload`.'
|
|
376
|
+
: 'The body is not in the gateway\'s canonical form (sorted keys, no whitespace), so it was probably re-serialized on the way. Verify the raw '
|
|
377
|
+
+ 'request bytes, not JSON.stringify of a parsed body.');
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
catch { /* not JSON: nothing more to say */ }
|
|
381
|
+
}
|
|
382
|
+
return notes.length ? notes.join(' ') : undefined;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Verify a delivery and parse it: the one call a handler needs.
|
|
386
|
+
*
|
|
387
|
+
* const hook = constructWebhookEvent({ body: rawBody, headers: req.headers, secret });
|
|
388
|
+
* if (isWebhookEvent(hook, 'transaction.completed')) await settle(hook.payload.intent_id);
|
|
389
|
+
*
|
|
390
|
+
* Throws `CertenWebhookSignatureError` (status 400, `.reason`) when the delivery is not accepted — answer 400 and nothing is
|
|
391
|
+
* processed — and `CertenError` (`WEBHOOK_SECRET_INVALID`) when the secret itself is unusable. Does not read `body` as text until the
|
|
392
|
+
* signature has held.
|
|
393
|
+
*/
|
|
394
|
+
export function constructWebhookEvent(options) {
|
|
395
|
+
const v = verifyWebhookSignature({
|
|
396
|
+
secret: options.secret, body: options.body, headers: options.headers, signature: options.signature,
|
|
397
|
+
toleranceSeconds: options.toleranceSeconds, now: options.now,
|
|
398
|
+
});
|
|
399
|
+
if (!v.ok)
|
|
400
|
+
throw new CertenWebhookSignatureError(v.message, v.reason, v.hint);
|
|
401
|
+
let payload;
|
|
402
|
+
try {
|
|
403
|
+
payload = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(toBytes(options.body)));
|
|
404
|
+
}
|
|
405
|
+
catch {
|
|
406
|
+
throw new CertenWebhookSignatureError('The signature held, but the body is not JSON.', 'invalid-payload');
|
|
407
|
+
}
|
|
408
|
+
return {
|
|
409
|
+
type: readHeader(options.headers, WEBHOOK_EVENT_HEADER) ?? null,
|
|
410
|
+
deliveryId: readHeader(options.headers, WEBHOOK_DELIVERY_HEADER) ?? null,
|
|
411
|
+
timestamp: v.timestamp,
|
|
412
|
+
payload,
|
|
413
|
+
verification: v,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* `constructWebhookEvent` for a Fetch-style request. It reads the body with `arrayBuffer()`, so the bytes are the ones that arrived and
|
|
418
|
+
* there is no parsed copy to confuse the handler (do NOT call `request.json()` first: the stream is then spent).
|
|
419
|
+
*/
|
|
420
|
+
export async function constructWebhookEventFromRequest(request, secret, options = {}) {
|
|
421
|
+
const body = new Uint8Array(await request.arrayBuffer());
|
|
422
|
+
return constructWebhookEvent({ secret, body, headers: request.headers, ...options });
|
|
423
|
+
}
|
|
424
|
+
/** Narrow a received webhook to a known event and its payload type. False for an event this SDK has no type for, which is not an error. */
|
|
425
|
+
export function isWebhookEvent(hook, type) {
|
|
426
|
+
return hook.type === type;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Reproduce the signature the gateway recorded for a delivery attempt, from the signed bytes it also recorded.
|
|
430
|
+
*
|
|
431
|
+
* This answers "is the secret I hold the one the gateway signed this with?" without waiting for the next event: a mismatch on a
|
|
432
|
+
* delivery your receiver rejected means the receiver has the wrong (or a rotated-away) secret; a match means the secret is right
|
|
433
|
+
* and the fault is in how the receiver gets the body. There is no tolerance — this is history, not a request.
|
|
434
|
+
*
|
|
435
|
+
* The record describes the LAST attempt: each attempt re-signs and overwrites it.
|
|
436
|
+
*/
|
|
437
|
+
export function checkWebhookDelivery(delivery, secret) {
|
|
438
|
+
const { keys, raw } = secretKeys(secret);
|
|
439
|
+
const { signature_hex: sig, signed_canonical_payload: payload } = delivery;
|
|
440
|
+
const at = delivery.signed_at_unix;
|
|
441
|
+
if (sig == null || payload == null || at == null) {
|
|
442
|
+
return {
|
|
443
|
+
ok: false, reason: 'not-signed',
|
|
444
|
+
message: 'This delivery has no recorded signature.',
|
|
445
|
+
hint: 'The gateway records it when it makes an attempt. A delivery that has not been attempted yet, or whose endpoint was gone, has none.',
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
const version = delivery.signature_version ?? WEBHOOK_SIGNATURE_VERSION;
|
|
449
|
+
if (version !== WEBHOOK_SIGNATURE_VERSION) {
|
|
450
|
+
return { ok: false, reason: 'unsupported-version', message: `The delivery was signed with ${version}; this SDK verifies ${WEBHOOK_SIGNATURE_VERSION}.`, hint: 'Upgrade @certen.io/sdk.' };
|
|
451
|
+
}
|
|
452
|
+
const atText = String(at);
|
|
453
|
+
if (typeof sig !== 'string' || !/^[0-9a-fA-F]{64}$/.test(sig) || typeof payload !== 'string' || !new RegExp(`^[0-9]{1,${MAX_TIMESTAMP_DIGITS}}$`).test(atText)) {
|
|
454
|
+
return { ok: false, reason: 'malformed-record', message: 'The delivery\'s signature fields are not in the shape the gateway records them.' };
|
|
455
|
+
}
|
|
456
|
+
const recorded = hexToBytes(sig);
|
|
457
|
+
const signed = signedBytes(atText, utf8(payload));
|
|
458
|
+
for (const k of keys) {
|
|
459
|
+
if (timingSafeEqual(hmacSha256(k, signed), recorded))
|
|
460
|
+
return { ok: true, timestamp: Number(atText), version: WEBHOOK_SIGNATURE_VERSION };
|
|
461
|
+
}
|
|
462
|
+
return {
|
|
463
|
+
ok: false, reason: 'signature-mismatch',
|
|
464
|
+
message: 'The recorded signature was not made with this secret.',
|
|
465
|
+
hint: raw.some((s) => s !== s.trim())
|
|
466
|
+
? 'The secret has leading or trailing whitespace.'
|
|
467
|
+
: 'This is not the secret the endpoint was signing with at that attempt — it may have been rotated since, or belong to another endpoint.',
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
//# sourceMappingURL=webhook-signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-signature.js","sourceRoot":"","sources":["../src/webhook-signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAIvE,0HAA0H;AAC1H,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,uGAAuG;AACvG,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAC;AACrD,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAC7D,oDAAoD;AACpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AACrD,gIAAgI;AAChI,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAC3D,kGAAkG;AAClG,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAE7D,4IAA4I;AAC5I,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,kHAAkH;AAClH,MAAM,kBAAkB,GAAG,GAAG,GAAG,IAAI,CAAC;AACtC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,kIAAkI;AAElI,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,uIAAuI;AACvI,MAAM,UAAU,UAAU,CAAC,GAAe,EAAE,OAAmB;IAC7D,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,C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EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC;YAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC;IAC3I,CAAC;IACD,OAAO;QACL,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,oBAAoB;QACvC,OAAO,EAAE,uDAAuD;QAChE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;YACnC,CAAC,CAAC,gDAAgD;YAClD,CAAC,CAAC,uIAAuI;KAC5I,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@certen.io/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "TypeScript client for the CERTEN Gateway API — proof-gated cross-chain execution on Accumulate",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
},
|
|
77
77
|
"//publishConfig": "Provenance is passed as --provenance by .github/workflows/release.yml. Setting it here instead would break every publish outside CI with an error that does not explain itself.",
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@certen.io/proof-verify": "^0.
|
|
79
|
+
"@certen.io/proof-verify": "^0.2.0"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"@certen.io/proof-verify": {
|