@venturekit/billing 0.0.0-dev.20260825184900
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/README.md +218 -0
- package/dist/client.d.ts +109 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +139 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +102 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +133 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +170 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +47 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +178 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +93 -0
- package/dist/provider.js.map +1 -0
- package/dist/providers/index.d.ts +15 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +15 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/mock.d.ts +79 -0
- package/dist/providers/mock.d.ts.map +1 -0
- package/dist/providers/mock.js +536 -0
- package/dist/providers/mock.js.map +1 -0
- package/dist/providers/zazu/adapter.d.ts +39 -0
- package/dist/providers/zazu/adapter.d.ts.map +1 -0
- package/dist/providers/zazu/adapter.js +233 -0
- package/dist/providers/zazu/adapter.js.map +1 -0
- package/dist/providers/zazu/client.d.ts +76 -0
- package/dist/providers/zazu/client.d.ts.map +1 -0
- package/dist/providers/zazu/client.js +163 -0
- package/dist/providers/zazu/client.js.map +1 -0
- package/dist/providers/zazu/config.d.ts +54 -0
- package/dist/providers/zazu/config.d.ts.map +1 -0
- package/dist/providers/zazu/config.js +55 -0
- package/dist/providers/zazu/config.js.map +1 -0
- package/dist/providers/zazu/correlation.d.ts +65 -0
- package/dist/providers/zazu/correlation.d.ts.map +1 -0
- package/dist/providers/zazu/correlation.js +178 -0
- package/dist/providers/zazu/correlation.js.map +1 -0
- package/dist/providers/zazu/index.d.ts +18 -0
- package/dist/providers/zazu/index.d.ts.map +1 -0
- package/dist/providers/zazu/index.js +21 -0
- package/dist/providers/zazu/index.js.map +1 -0
- package/dist/providers/zazu/maps.d.ts +36 -0
- package/dist/providers/zazu/maps.d.ts.map +1 -0
- package/dist/providers/zazu/maps.js +450 -0
- package/dist/providers/zazu/maps.js.map +1 -0
- package/dist/providers/zazu/types.d.ts +365 -0
- package/dist/providers/zazu/types.d.ts.map +1 -0
- package/dist/providers/zazu/types.js +13 -0
- package/dist/providers/zazu/types.js.map +1 -0
- package/dist/providers/zazu/webhooks.d.ts +73 -0
- package/dist/providers/zazu/webhooks.d.ts.map +1 -0
- package/dist/providers/zazu/webhooks.js +259 -0
- package/dist/providers/zazu/webhooks.js.map +1 -0
- package/dist/types.d.ts +512 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @venturekit/billing — Zazu webhook signature verification & parsing
|
|
3
|
+
*
|
|
4
|
+
* Zazu signs every webhook with HMAC-SHA256 over
|
|
5
|
+
* `${timestamp}.${rawBody}` and sends the signature in the
|
|
6
|
+
* `X-Zazu-Signature` header. Verification uses a constant-time
|
|
7
|
+
* comparison to prevent timing attacks, and rejects signatures whose
|
|
8
|
+
* timestamp falls outside a tolerance window so a captured request
|
|
9
|
+
* can't be replayed indefinitely.
|
|
10
|
+
*
|
|
11
|
+
* After verification, the raw payload is parsed and normalized into a
|
|
12
|
+
* {@link PaymentEvent} (canonical, provider-agnostic shape) so the
|
|
13
|
+
* application can publish it to its event bus without knowing it came
|
|
14
|
+
* from Zazu.
|
|
15
|
+
*
|
|
16
|
+
* Failures are split by cause: {@link WebhookSignatureError} means the
|
|
17
|
+
* request isn't provably from Zazu (auth failure), while
|
|
18
|
+
* {@link WebhookPayloadError} means it is authentic but unusable.
|
|
19
|
+
* Callers must map them to different HTTP statuses — answering 401 to
|
|
20
|
+
* an authentic-but-unmapped event makes Zazu redeliver it forever.
|
|
21
|
+
*/
|
|
22
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
23
|
+
import { WebhookPayloadError, WebhookSignatureError } from '../../errors.js';
|
|
24
|
+
import { mapCheckoutTransaction, money, nullToUndefined, } from './maps.js';
|
|
25
|
+
import { decodeCheckoutCorrelation, decodePaymentLinkCorrelation, decodeTransferCorrelation, } from './correlation.js';
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Signature verification
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
/**
|
|
30
|
+
* Default replay tolerance: a signature more than five minutes old (or
|
|
31
|
+
* five minutes in the future, allowing for clock skew) is rejected.
|
|
32
|
+
*
|
|
33
|
+
* Zazu's docs describe the HMAC construction but do not mandate a
|
|
34
|
+
* freshness check, so this is our own hardening — five minutes is the
|
|
35
|
+
* de-facto standard (Stripe, Slack, GitHub). Note that Zazu retries a
|
|
36
|
+
* failed delivery for ~28 hours, so the window must stay comfortably
|
|
37
|
+
* wider than a single delivery attempt.
|
|
38
|
+
*/
|
|
39
|
+
export const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
40
|
+
/**
|
|
41
|
+
* Verify a Zazu webhook signature. Throws {@link WebhookSignatureError}
|
|
42
|
+
* if the signature, timestamp, or secret is missing, the timestamp is
|
|
43
|
+
* outside the tolerance window, or the signature does not match.
|
|
44
|
+
*
|
|
45
|
+
* @param secret - The endpoint's signing secret.
|
|
46
|
+
* @param timestamp - `X-Zazu-Timestamp` header value (Unix seconds).
|
|
47
|
+
* @param rawBody - The raw request body exactly as received.
|
|
48
|
+
* @param signature - `X-Zazu-Signature` header value (hex digest).
|
|
49
|
+
* @param toleranceSeconds - Maximum accepted signature age. Pass `0` to
|
|
50
|
+
* disable the freshness check — only appropriate when replaying
|
|
51
|
+
* captured fixtures in tests.
|
|
52
|
+
*/
|
|
53
|
+
export function verifyZazuSignature(secret, timestamp, rawBody, signature, toleranceSeconds = DEFAULT_WEBHOOK_TOLERANCE_SECONDS) {
|
|
54
|
+
if (!secret) {
|
|
55
|
+
throw new WebhookSignatureError('Zazu webhook secret is not configured.');
|
|
56
|
+
}
|
|
57
|
+
if (!timestamp || !signature) {
|
|
58
|
+
throw new WebhookSignatureError('Missing X-Zazu-Timestamp or X-Zazu-Signature header.');
|
|
59
|
+
}
|
|
60
|
+
// Freshness first: the timestamp is inside the signed payload, so an
|
|
61
|
+
// attacker replaying a captured request keeps a valid signature
|
|
62
|
+
// forever. Only the age check stops that.
|
|
63
|
+
if (toleranceSeconds > 0) {
|
|
64
|
+
const signedAtSeconds = Number(timestamp);
|
|
65
|
+
if (!Number.isFinite(signedAtSeconds)) {
|
|
66
|
+
throw new WebhookSignatureError(`Malformed X-Zazu-Timestamp header: "${timestamp}" is not a Unix timestamp.`);
|
|
67
|
+
}
|
|
68
|
+
const ageSeconds = Math.abs(Date.now() / 1000 - signedAtSeconds);
|
|
69
|
+
if (ageSeconds > toleranceSeconds) {
|
|
70
|
+
throw new WebhookSignatureError(`Zazu webhook timestamp is outside the ${toleranceSeconds}s tolerance ` +
|
|
71
|
+
`(off by ${Math.round(ageSeconds)}s) — possible replay.`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const expected = createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex');
|
|
75
|
+
// Constant-time comparison. Lengths must match; if they don't, the
|
|
76
|
+
// signatures can't be equal and we avoid leaking via timing.
|
|
77
|
+
const a = Buffer.from(signature);
|
|
78
|
+
const b = Buffer.from(expected);
|
|
79
|
+
if (a.length !== b.length || !timingSafeEqual(a, b)) {
|
|
80
|
+
throw new WebhookSignatureError('Invalid Zazu webhook signature.');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
// Header lookup
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
/**
|
|
87
|
+
* Lower-case every header name once. API Gateway v2 already does this,
|
|
88
|
+
* but REST (v1) events, direct Lambda invocations, and tests do not —
|
|
89
|
+
* and a missed `X-Zazu-Signature` surfaces as a confusing "missing
|
|
90
|
+
* header" rejection. Same normalization the runtime applies in
|
|
91
|
+
* `getRequestHost`.
|
|
92
|
+
*/
|
|
93
|
+
function normalizeHeaders(headers) {
|
|
94
|
+
const normalized = {};
|
|
95
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
96
|
+
if (typeof value === 'string')
|
|
97
|
+
normalized[name.toLowerCase()] = value;
|
|
98
|
+
}
|
|
99
|
+
return normalized;
|
|
100
|
+
}
|
|
101
|
+
/** Read a header from an already-normalized bag. */
|
|
102
|
+
function header(headers, name) {
|
|
103
|
+
return headers[name];
|
|
104
|
+
}
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
// Parsing & normalization
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
/**
|
|
109
|
+
* Parse and normalize a verified Zazu webhook into a
|
|
110
|
+
* {@link PaymentEvent}. This does NOT verify the signature — call
|
|
111
|
+
* {@link verifyZazuSignature} first (or use {@link handleZazuWebhook}
|
|
112
|
+
* which does both).
|
|
113
|
+
*
|
|
114
|
+
* Throws {@link WebhookPayloadError} if the payload is malformed, the
|
|
115
|
+
* event id is absent, or the event type is unknown.
|
|
116
|
+
*/
|
|
117
|
+
export function parseZazuWebhook(rawBody, headers) {
|
|
118
|
+
const normalized = normalizeHeaders(headers);
|
|
119
|
+
let payload;
|
|
120
|
+
try {
|
|
121
|
+
payload = JSON.parse(rawBody);
|
|
122
|
+
}
|
|
123
|
+
catch (cause) {
|
|
124
|
+
throw new WebhookPayloadError('Malformed Zazu webhook body (invalid JSON).', cause);
|
|
125
|
+
}
|
|
126
|
+
const eventType = payload.event ?? header(normalized, 'x-zazu-event');
|
|
127
|
+
if (!eventType) {
|
|
128
|
+
throw new WebhookPayloadError('Zazu webhook missing event type.');
|
|
129
|
+
}
|
|
130
|
+
const deliveryId = header(normalized, 'x-zazu-delivery-id');
|
|
131
|
+
// `eventId` is the consumer's deduplication key (see events.ts).
|
|
132
|
+
// Defaulting it to '' would collapse every delivery onto one key and
|
|
133
|
+
// silently drop real events, so fall back to the delivery id and
|
|
134
|
+
// refuse the payload if neither is present.
|
|
135
|
+
const eventId = header(normalized, 'x-zazu-event-id') ?? deliveryId;
|
|
136
|
+
if (!eventId) {
|
|
137
|
+
throw new WebhookPayloadError('Zazu webhook missing X-Zazu-Event-Id and X-Zazu-Delivery-Id — cannot deduplicate.');
|
|
138
|
+
}
|
|
139
|
+
const createdAt = payload.created_at ?? new Date().toISOString();
|
|
140
|
+
switch (eventType) {
|
|
141
|
+
case 'checkout_session.completed': {
|
|
142
|
+
const raw = payload.data?.checkout_session;
|
|
143
|
+
if (!raw) {
|
|
144
|
+
throw new WebhookPayloadError('checkout_session.completed missing checkout_session data.');
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
type: 'checkout_session.completed',
|
|
148
|
+
provider: 'zazu',
|
|
149
|
+
eventId,
|
|
150
|
+
deliveryId,
|
|
151
|
+
createdAt,
|
|
152
|
+
correlation: decodeCheckoutCorrelation(raw.metadata),
|
|
153
|
+
objectId: raw.id,
|
|
154
|
+
amount: money(raw.amount, raw.currency_code),
|
|
155
|
+
raw,
|
|
156
|
+
data: {
|
|
157
|
+
type: 'checkout_session.completed',
|
|
158
|
+
sessionId: raw.id,
|
|
159
|
+
status: raw.status,
|
|
160
|
+
completedAt: nullToUndefined(raw.completed_at),
|
|
161
|
+
customerEmail: nullToUndefined(raw.customer_email),
|
|
162
|
+
description: nullToUndefined(raw.description),
|
|
163
|
+
transaction: raw.transaction ? mapCheckoutTransaction(raw.transaction) : undefined,
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
case 'payment_link.paid': {
|
|
168
|
+
const raw = payload.data?.payment_link;
|
|
169
|
+
if (!raw)
|
|
170
|
+
throw new WebhookPayloadError('payment_link.paid missing payment_link data.');
|
|
171
|
+
return {
|
|
172
|
+
type: 'payment_link.paid',
|
|
173
|
+
provider: 'zazu',
|
|
174
|
+
eventId,
|
|
175
|
+
deliveryId,
|
|
176
|
+
createdAt,
|
|
177
|
+
correlation: decodePaymentLinkCorrelation(raw.client_reference_id),
|
|
178
|
+
objectId: raw.id,
|
|
179
|
+
amount: money(raw.amount, raw.currency_code),
|
|
180
|
+
raw,
|
|
181
|
+
data: {
|
|
182
|
+
type: 'payment_link.paid',
|
|
183
|
+
paymentLinkId: raw.id,
|
|
184
|
+
slug: nullToUndefined(raw.slug),
|
|
185
|
+
status: raw.status,
|
|
186
|
+
linkType: nullToUndefined(raw.link_type),
|
|
187
|
+
title: nullToUndefined(raw.title),
|
|
188
|
+
description: nullToUndefined(raw.description),
|
|
189
|
+
paymentReference: nullToUndefined(raw.payment_reference),
|
|
190
|
+
paymentsCount: raw.payments_count ?? undefined,
|
|
191
|
+
paidAt: nullToUndefined(raw.paid_at),
|
|
192
|
+
customerEmail: nullToUndefined(raw.customer_email),
|
|
193
|
+
customerId: nullToUndefined(raw.customer_id),
|
|
194
|
+
customerName: nullToUndefined(raw.customer_name),
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
case 'transfer.executed': {
|
|
199
|
+
const raw = payload.data?.transfer;
|
|
200
|
+
if (!raw)
|
|
201
|
+
throw new WebhookPayloadError('transfer.executed missing transfer data.');
|
|
202
|
+
return {
|
|
203
|
+
type: 'transfer.executed',
|
|
204
|
+
provider: 'zazu',
|
|
205
|
+
eventId,
|
|
206
|
+
deliveryId,
|
|
207
|
+
createdAt,
|
|
208
|
+
correlation: decodeTransferCorrelation(raw.payment_reference),
|
|
209
|
+
objectId: raw.id,
|
|
210
|
+
amount: money(raw.amount, raw.currency_code),
|
|
211
|
+
raw,
|
|
212
|
+
data: {
|
|
213
|
+
type: 'transfer.executed',
|
|
214
|
+
transferId: raw.id,
|
|
215
|
+
// Passed through, NOT remapped: the webhook's vocabulary
|
|
216
|
+
// ("accepted") differs from the transfers API's
|
|
217
|
+
// (requested|processing|completed|failed), so running it through
|
|
218
|
+
// TRANSFER_STATUS would report an executed transfer as
|
|
219
|
+
// 'requested'. An earlier version hardcoded 'completed' here,
|
|
220
|
+
// which would have reported a non-accepted status as success.
|
|
221
|
+
providerStatus: raw.status,
|
|
222
|
+
operation: nullToUndefined(raw.operation),
|
|
223
|
+
paymentReference: nullToUndefined(raw.payment_reference),
|
|
224
|
+
postedAt: nullToUndefined(raw.posted_at),
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
case 'test.ping': {
|
|
229
|
+
return {
|
|
230
|
+
type: 'test.ping',
|
|
231
|
+
provider: 'zazu',
|
|
232
|
+
eventId,
|
|
233
|
+
deliveryId,
|
|
234
|
+
createdAt,
|
|
235
|
+
correlation: null,
|
|
236
|
+
objectId: null,
|
|
237
|
+
amount: null,
|
|
238
|
+
raw: payload.data,
|
|
239
|
+
data: { type: 'test.ping', ...payload.data },
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
default: {
|
|
243
|
+
throw new WebhookPayloadError(`Unknown Zazu webhook event type: "${eventType}".`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Verify the Zazu webhook signature and parse the payload into a
|
|
249
|
+
* normalized {@link PaymentEvent}. This is what the adapter's
|
|
250
|
+
* `handleWebhookEvent` calls.
|
|
251
|
+
*/
|
|
252
|
+
export function handleZazuWebhook(secret, request, options) {
|
|
253
|
+
const normalized = normalizeHeaders(request.headers);
|
|
254
|
+
const timestamp = header(normalized, 'x-zazu-timestamp') ?? '';
|
|
255
|
+
const signature = header(normalized, 'x-zazu-signature') ?? '';
|
|
256
|
+
verifyZazuSignature(secret ?? '', timestamp, request.rawBody, signature, options?.toleranceSeconds ?? DEFAULT_WEBHOOK_TOLERANCE_SECONDS);
|
|
257
|
+
return parseZazuWebhook(request.rawBody, normalized);
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../../src/providers/zazu/webhooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAG7E,OAAO,EACL,sBAAsB,EACtB,KAAK,EACL,eAAe,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAG1B,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAc,EACd,SAAiB,EACjB,OAAe,EACf,SAAiB,EACjB,mBAA2B,iCAAiC;IAE5D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,qBAAqB,CAAC,wCAAwC,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,qBAAqB,CAAC,sDAAsD,CAAC,CAAC;IAC1F,CAAC;IAED,qEAAqE;IACrE,gEAAgE;IAChE,0CAA0C;IAC1C,IAAI,gBAAgB,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,qBAAqB,CAC7B,u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