@oneaddress/partner-sdk 1.1.0 → 1.2.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/README.md +158 -0
- package/dist/{chunk-BCAOUGA6.mjs → chunk-EHR6T6MA.mjs} +106 -18
- package/dist/chunk-TGLIJMGK.mjs +498 -0
- package/dist/edge.d.mts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +76 -16
- package/dist/edge.mjs +5 -3
- package/dist/index.d.mts +241 -3
- package/dist/index.d.ts +241 -3
- package/dist/index.js +634 -22
- package/dist/index.mjs +9 -3
- package/dist/src-NUBMOPDK.mjs +30 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,15 +30,536 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// ../crypto/src/replay-window.ts
|
|
34
|
+
function isFreshTimestamp(timestampHeader, toleranceSecs = DEFAULT_REPLAY_WINDOW_SECS, nowSecs) {
|
|
35
|
+
if (typeof timestampHeader !== "string" || timestampHeader.length === 0) return false;
|
|
36
|
+
if (!/^\d+$/.test(timestampHeader)) return false;
|
|
37
|
+
const ts = Number(timestampHeader);
|
|
38
|
+
if (!Number.isFinite(ts) || ts < 0) return false;
|
|
39
|
+
const now = typeof nowSecs === "number" ? nowSecs : Math.floor(Date.now() / 1e3);
|
|
40
|
+
return Math.abs(now - ts) <= toleranceSecs;
|
|
41
|
+
}
|
|
42
|
+
var DEFAULT_REPLAY_WINDOW_SECS;
|
|
43
|
+
var init_replay_window = __esm({
|
|
44
|
+
"../crypto/src/replay-window.ts"() {
|
|
45
|
+
"use strict";
|
|
46
|
+
DEFAULT_REPLAY_WINDOW_SECS = 300;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// ../crypto/src/safe-url.ts
|
|
51
|
+
function isBlockedIPv4(host) {
|
|
52
|
+
const parts = host.split(".");
|
|
53
|
+
if (parts.length !== 4) return false;
|
|
54
|
+
const octets = parts.map((p) => /^\d{1,3}$/.test(p) ? Number(p) : NaN);
|
|
55
|
+
if (octets.some((n) => !Number.isInteger(n) || n < 0 || n > 255)) return false;
|
|
56
|
+
const [a, b] = octets;
|
|
57
|
+
if (a === 0) return true;
|
|
58
|
+
if (a === 127) return true;
|
|
59
|
+
if (a === 10) return true;
|
|
60
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
61
|
+
if (a === 192 && b === 168) return true;
|
|
62
|
+
if (a === 169 && b === 254) return true;
|
|
63
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
function v4FromHexPair(highHex, lowHex) {
|
|
67
|
+
const high = parseInt(highHex, 16);
|
|
68
|
+
const low = parseInt(lowHex, 16);
|
|
69
|
+
if (!Number.isInteger(high) || !Number.isInteger(low)) return null;
|
|
70
|
+
const a = high >> 8 & 255;
|
|
71
|
+
const b = high & 255;
|
|
72
|
+
const c = low >> 8 & 255;
|
|
73
|
+
const d = low & 255;
|
|
74
|
+
return `${a}.${b}.${c}.${d}`;
|
|
75
|
+
}
|
|
76
|
+
function isBlockedIPv6(host) {
|
|
77
|
+
let clean = host.toLowerCase();
|
|
78
|
+
if (clean.startsWith("[") && clean.endsWith("]")) {
|
|
79
|
+
clean = clean.slice(1, -1);
|
|
80
|
+
}
|
|
81
|
+
clean = clean.split("%")[0];
|
|
82
|
+
if (!clean.includes(":")) return false;
|
|
83
|
+
if (clean === "::1") return true;
|
|
84
|
+
if (clean === "::") return true;
|
|
85
|
+
if (clean.startsWith("fe80:")) return true;
|
|
86
|
+
if (clean.startsWith("fc") || clean.startsWith("fd")) return true;
|
|
87
|
+
const mappedDotted = /^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(clean);
|
|
88
|
+
if (mappedDotted) return isBlockedIPv4(mappedDotted[1]);
|
|
89
|
+
const mappedHex = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(clean);
|
|
90
|
+
if (mappedHex) {
|
|
91
|
+
const v4 = v4FromHexPair(mappedHex[1], mappedHex[2]);
|
|
92
|
+
if (v4) return isBlockedIPv4(v4);
|
|
93
|
+
}
|
|
94
|
+
const compatibleDotted = /^::(\d+\.\d+\.\d+\.\d+)$/.exec(clean);
|
|
95
|
+
if (compatibleDotted) return isBlockedIPv4(compatibleDotted[1]);
|
|
96
|
+
const compatibleHex = /^::([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(clean);
|
|
97
|
+
if (compatibleHex) {
|
|
98
|
+
const v4 = v4FromHexPair(compatibleHex[1], compatibleHex[2]);
|
|
99
|
+
if (v4) return isBlockedIPv4(v4);
|
|
100
|
+
}
|
|
101
|
+
if (clean.startsWith("64:ff9b:")) {
|
|
102
|
+
const nat64Dotted = /^64:ff9b:(?:1:)?:(\d+\.\d+\.\d+\.\d+)$/.exec(clean);
|
|
103
|
+
if (nat64Dotted) return isBlockedIPv4(nat64Dotted[1]);
|
|
104
|
+
const nat64Hex = /^64:ff9b:(?:1:)?:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(clean);
|
|
105
|
+
if (nat64Hex) {
|
|
106
|
+
const v4 = v4FromHexPair(nat64Hex[1], nat64Hex[2]);
|
|
107
|
+
if (v4) return isBlockedIPv4(v4);
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
function isSafeWebhookUrl(url, opts = {}) {
|
|
114
|
+
let parsed;
|
|
115
|
+
try {
|
|
116
|
+
parsed = new URL(url);
|
|
117
|
+
} catch {
|
|
118
|
+
return { ok: false, reason: "Invalid URL" };
|
|
119
|
+
}
|
|
120
|
+
if (!["http:", "https:"].includes(parsed.protocol)) {
|
|
121
|
+
return { ok: false, reason: `Protocol ${parsed.protocol} not allowed \u2014 use http(s)` };
|
|
122
|
+
}
|
|
123
|
+
if (opts.requireHttps && parsed.protocol !== "https:") {
|
|
124
|
+
return { ok: false, reason: "Webhook URL must use https://" };
|
|
125
|
+
}
|
|
126
|
+
const host = parsed.hostname.toLowerCase();
|
|
127
|
+
if (BLOCKED_HOSTNAMES.has(host)) {
|
|
128
|
+
return { ok: false, reason: `Hostname ${host} is not allowed as a webhook target` };
|
|
129
|
+
}
|
|
130
|
+
if (host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local")) {
|
|
131
|
+
return { ok: false, reason: `Hostname ${host} resolves to local network` };
|
|
132
|
+
}
|
|
133
|
+
if (isBlockedIPv4(host)) {
|
|
134
|
+
return { ok: false, reason: `IPv4 address ${host} is in a private/reserved range` };
|
|
135
|
+
}
|
|
136
|
+
if (isBlockedIPv6(host)) {
|
|
137
|
+
return { ok: false, reason: `IPv6 address ${host} is in a private/reserved range` };
|
|
138
|
+
}
|
|
139
|
+
return { ok: true };
|
|
140
|
+
}
|
|
141
|
+
var BLOCKED_HOSTNAMES;
|
|
142
|
+
var init_safe_url = __esm({
|
|
143
|
+
"../crypto/src/safe-url.ts"() {
|
|
144
|
+
"use strict";
|
|
145
|
+
BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
146
|
+
"localhost",
|
|
147
|
+
"ip6-localhost",
|
|
148
|
+
"ip6-loopback",
|
|
149
|
+
"metadata.google.internal",
|
|
150
|
+
"metadata.goog",
|
|
151
|
+
"metadata"
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// ../crypto/src/index.ts
|
|
157
|
+
var src_exports = {};
|
|
158
|
+
__export(src_exports, {
|
|
159
|
+
DEFAULT_REPLAY_WINDOW_SECS: () => DEFAULT_REPLAY_WINDOW_SECS,
|
|
160
|
+
decryptAddress: () => decryptAddress,
|
|
161
|
+
decryptSession: () => decryptSession,
|
|
162
|
+
encryptAddressForAll: () => encryptAddressForAll,
|
|
163
|
+
encryptAddressForPartner: () => encryptAddressForPartner,
|
|
164
|
+
encryptSessionForAll: () => encryptSessionForAll,
|
|
165
|
+
encryptSessionForPartner: () => encryptSessionForPartner,
|
|
166
|
+
generatePartnerKeyPair: () => generatePartnerKeyPair,
|
|
167
|
+
isFreshTimestamp: () => isFreshTimestamp,
|
|
168
|
+
isSafeWebhookUrl: () => isSafeWebhookUrl,
|
|
169
|
+
normaliseAddress: () => normaliseAddress,
|
|
170
|
+
signWebhookPayload: () => signWebhookPayload,
|
|
171
|
+
verifyWebhookSignature: () => verifyWebhookSignature
|
|
172
|
+
});
|
|
173
|
+
function b64ToBytes(b64) {
|
|
174
|
+
const binary = atob(b64);
|
|
175
|
+
const bytes = new Uint8Array(binary.length);
|
|
176
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.codePointAt(i) ?? 0;
|
|
177
|
+
return bytes;
|
|
178
|
+
}
|
|
179
|
+
function bytesToB64(bytes) {
|
|
180
|
+
return btoa(String.fromCharCode(...bytes));
|
|
181
|
+
}
|
|
182
|
+
function toTitleCase(s) {
|
|
183
|
+
return s.trim().replace(
|
|
184
|
+
/\S+/g,
|
|
185
|
+
(w) => /^\d/.test(w) ? w : w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
function normaliseAddress(addr) {
|
|
189
|
+
const rawState = (addr.state ?? "").trim();
|
|
190
|
+
const stateKey = rawState.toLowerCase();
|
|
191
|
+
const normState = AU_STATE_FULL[stateKey] ?? rawState.toUpperCase();
|
|
192
|
+
const rawCountry = (addr.country ?? "").trim();
|
|
193
|
+
const normCountry = rawCountry.toLowerCase() === "australia" ? "AU" : rawCountry.toUpperCase();
|
|
194
|
+
return {
|
|
195
|
+
...addr,
|
|
196
|
+
street: toTitleCase(addr.street ?? ""),
|
|
197
|
+
suburb: toTitleCase(addr.suburb ?? ""),
|
|
198
|
+
state: normState,
|
|
199
|
+
postcode: (addr.postcode ?? "").trim(),
|
|
200
|
+
country: normCountry
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
async function generatePartnerKeyPair() {
|
|
204
|
+
const keypair = await subtle().generateKey(
|
|
205
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
206
|
+
true,
|
|
207
|
+
// extractable
|
|
208
|
+
["deriveKey", "deriveBits"]
|
|
209
|
+
);
|
|
210
|
+
const [pubRaw, privRaw] = await Promise.all([
|
|
211
|
+
subtle().exportKey("spki", keypair.publicKey),
|
|
212
|
+
subtle().exportKey("pkcs8", keypair.privateKey)
|
|
213
|
+
]);
|
|
214
|
+
return {
|
|
215
|
+
publicKeyB64: bytesToB64(new Uint8Array(pubRaw)),
|
|
216
|
+
privateKeyB64: bytesToB64(new Uint8Array(privRaw))
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
async function encryptAddressForPartner(address, partner) {
|
|
220
|
+
const address_ = normaliseAddress(address);
|
|
221
|
+
const partnerPubKey = await subtle().importKey(
|
|
222
|
+
"spki",
|
|
223
|
+
b64ToBytes(partner.publicKeyB64),
|
|
224
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
225
|
+
false,
|
|
226
|
+
[]
|
|
227
|
+
// public key — no usages
|
|
228
|
+
);
|
|
229
|
+
const ephemeral = await subtle().generateKey(
|
|
230
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
231
|
+
true,
|
|
232
|
+
["deriveBits"]
|
|
233
|
+
);
|
|
234
|
+
const hkdfSaltBytes = globalThis.crypto.getRandomValues(new Uint8Array(32));
|
|
235
|
+
const ecdhBits = await subtle().deriveBits(
|
|
236
|
+
{ name: "ECDH", public: partnerPubKey },
|
|
237
|
+
ephemeral.privateKey,
|
|
238
|
+
256
|
|
239
|
+
);
|
|
240
|
+
const hkdfKey = await subtle().importKey("raw", ecdhBits, "HKDF", false, ["deriveBits"]);
|
|
241
|
+
const aesRaw = await subtle().deriveBits(
|
|
242
|
+
{
|
|
243
|
+
name: "HKDF",
|
|
244
|
+
hash: "SHA-256",
|
|
245
|
+
salt: hkdfSaltBytes,
|
|
246
|
+
info: new TextEncoder().encode(`oneaddress:${partner.partnerId}`)
|
|
247
|
+
},
|
|
248
|
+
hkdfKey,
|
|
249
|
+
256
|
|
250
|
+
);
|
|
251
|
+
const aesKey = await subtle().importKey(
|
|
252
|
+
"raw",
|
|
253
|
+
aesRaw,
|
|
254
|
+
{ name: "AES-GCM" },
|
|
255
|
+
false,
|
|
256
|
+
["encrypt"]
|
|
257
|
+
);
|
|
258
|
+
const iv = globalThis.crypto.getRandomValues(new Uint8Array(12));
|
|
259
|
+
const plaintext = new TextEncoder().encode(JSON.stringify(address_));
|
|
260
|
+
const ciphertextBuf = await subtle().encrypt(
|
|
261
|
+
{ name: "AES-GCM", iv },
|
|
262
|
+
aesKey,
|
|
263
|
+
plaintext
|
|
264
|
+
);
|
|
265
|
+
const ephPubRaw = await subtle().exportKey("raw", ephemeral.publicKey);
|
|
266
|
+
return {
|
|
267
|
+
ciphertext: bytesToB64(new Uint8Array(ciphertextBuf)),
|
|
268
|
+
iv: bytesToB64(iv),
|
|
269
|
+
ephemeralPublicKey: bytesToB64(new Uint8Array(ephPubRaw)),
|
|
270
|
+
partnerId: partner.partnerId,
|
|
271
|
+
encryptedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
272
|
+
hkdfSalt: bytesToB64(hkdfSaltBytes)
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
async function encryptAddressForAll(address, partners) {
|
|
276
|
+
const results = await Promise.all(
|
|
277
|
+
partners.map((p) => encryptAddressForPartner(address, p))
|
|
278
|
+
);
|
|
279
|
+
return Object.fromEntries(results.map((r) => [r.partnerId, r]));
|
|
280
|
+
}
|
|
281
|
+
async function decryptAddress(encrypted, privateKeyB64) {
|
|
282
|
+
const privateKey = await subtle().importKey(
|
|
283
|
+
"pkcs8",
|
|
284
|
+
b64ToBytes(privateKeyB64),
|
|
285
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
286
|
+
false,
|
|
287
|
+
["deriveBits"]
|
|
288
|
+
);
|
|
289
|
+
const ephemeralPub = await subtle().importKey(
|
|
290
|
+
"raw",
|
|
291
|
+
b64ToBytes(encrypted.ephemeralPublicKey),
|
|
292
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
293
|
+
false,
|
|
294
|
+
[]
|
|
295
|
+
);
|
|
296
|
+
const bits = await subtle().deriveBits(
|
|
297
|
+
{ name: "ECDH", public: ephemeralPub },
|
|
298
|
+
privateKey,
|
|
299
|
+
256
|
|
300
|
+
);
|
|
301
|
+
const hkdfSalt = encrypted.hkdfSalt ? b64ToBytes(encrypted.hkdfSalt) : new Uint8Array(32);
|
|
302
|
+
const aesKey = await subtle().importKey(
|
|
303
|
+
"raw",
|
|
304
|
+
await subtle().deriveBits(
|
|
305
|
+
{
|
|
306
|
+
name: "HKDF",
|
|
307
|
+
hash: "SHA-256",
|
|
308
|
+
salt: hkdfSalt,
|
|
309
|
+
info: new TextEncoder().encode(`oneaddress:${encrypted.partnerId}`)
|
|
310
|
+
},
|
|
311
|
+
await subtle().importKey("raw", bits, "HKDF", false, ["deriveBits"]),
|
|
312
|
+
256
|
|
313
|
+
),
|
|
314
|
+
{ name: "AES-GCM" },
|
|
315
|
+
false,
|
|
316
|
+
["decrypt"]
|
|
317
|
+
);
|
|
318
|
+
const plainBuf = await subtle().decrypt(
|
|
319
|
+
{ name: "AES-GCM", iv: b64ToBytes(encrypted.iv) },
|
|
320
|
+
aesKey,
|
|
321
|
+
b64ToBytes(encrypted.ciphertext)
|
|
322
|
+
);
|
|
323
|
+
return JSON.parse(new TextDecoder().decode(plainBuf));
|
|
324
|
+
}
|
|
325
|
+
function sessionWrapInfo(partnerId) {
|
|
326
|
+
return new TextEncoder().encode(`oneaddress:session-key-wrap:${partnerId}`);
|
|
327
|
+
}
|
|
328
|
+
function concat(...parts) {
|
|
329
|
+
const total = parts.reduce((n, p) => n + p.length, 0);
|
|
330
|
+
const out = new Uint8Array(total);
|
|
331
|
+
let off = 0;
|
|
332
|
+
for (const p of parts) {
|
|
333
|
+
out.set(p, off);
|
|
334
|
+
off += p.length;
|
|
335
|
+
}
|
|
336
|
+
return out;
|
|
337
|
+
}
|
|
338
|
+
function bytesToB64Url(bytes) {
|
|
339
|
+
return bytesToB64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
340
|
+
}
|
|
341
|
+
function b64UrlToBytes(b64url) {
|
|
342
|
+
const pad = b64url.length % 4 === 0 ? "" : "=".repeat(4 - b64url.length % 4);
|
|
343
|
+
return b64ToBytes(b64url.replace(/-/g, "+").replace(/_/g, "/") + pad);
|
|
344
|
+
}
|
|
345
|
+
async function encryptSessionForPartner(session_data, partner) {
|
|
346
|
+
const sk = await subtle().generateKey(
|
|
347
|
+
{ name: "AES-GCM", length: SESSION_KEY_BITS },
|
|
348
|
+
true,
|
|
349
|
+
["encrypt"]
|
|
350
|
+
);
|
|
351
|
+
const sessionIv = globalThis.crypto.getRandomValues(new Uint8Array(SESSION_IV_LENGTH));
|
|
352
|
+
const plaintext = new TextEncoder().encode(JSON.stringify(session_data));
|
|
353
|
+
const sessionCt = new Uint8Array(
|
|
354
|
+
await subtle().encrypt({ name: "AES-GCM", iv: sessionIv }, sk, plaintext)
|
|
355
|
+
);
|
|
356
|
+
const session_envelope = bytesToB64Url(concat(sessionIv, sessionCt));
|
|
357
|
+
const partnerPub = await subtle().importKey(
|
|
358
|
+
"spki",
|
|
359
|
+
b64ToBytes(partner.public_key_b64),
|
|
360
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
361
|
+
false,
|
|
362
|
+
[]
|
|
363
|
+
);
|
|
364
|
+
const ephemeral = await subtle().generateKey(
|
|
365
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
366
|
+
true,
|
|
367
|
+
["deriveBits"]
|
|
368
|
+
);
|
|
369
|
+
const sharedSecret = await subtle().deriveBits(
|
|
370
|
+
{ name: "ECDH", public: partnerPub },
|
|
371
|
+
ephemeral.privateKey,
|
|
372
|
+
256
|
|
373
|
+
);
|
|
374
|
+
const wrapSalt = globalThis.crypto.getRandomValues(new Uint8Array(WRAP_SALT_LENGTH));
|
|
375
|
+
const wrapKeyRaw = await subtle().deriveBits(
|
|
376
|
+
{
|
|
377
|
+
name: "HKDF",
|
|
378
|
+
hash: "SHA-256",
|
|
379
|
+
salt: wrapSalt,
|
|
380
|
+
info: sessionWrapInfo(partner.partner_id)
|
|
381
|
+
},
|
|
382
|
+
await subtle().importKey("raw", sharedSecret, "HKDF", false, ["deriveBits"]),
|
|
383
|
+
256
|
|
384
|
+
);
|
|
385
|
+
const wrapKey = await subtle().importKey(
|
|
386
|
+
"raw",
|
|
387
|
+
wrapKeyRaw,
|
|
388
|
+
{ name: "AES-GCM" },
|
|
389
|
+
false,
|
|
390
|
+
["encrypt"]
|
|
391
|
+
);
|
|
392
|
+
const skRaw = new Uint8Array(await subtle().exportKey("raw", sk));
|
|
393
|
+
const wrapIv = globalThis.crypto.getRandomValues(new Uint8Array(WRAP_IV_LENGTH));
|
|
394
|
+
const wrappedSkBytes = new Uint8Array(
|
|
395
|
+
await subtle().encrypt({ name: "AES-GCM", iv: wrapIv }, wrapKey, skRaw)
|
|
396
|
+
);
|
|
397
|
+
skRaw.fill(0);
|
|
398
|
+
const wrapped_key = bytesToB64Url(concat(wrapSalt, wrapIv, wrappedSkBytes));
|
|
399
|
+
const epkSpki = new Uint8Array(await subtle().exportKey("spki", ephemeral.publicKey));
|
|
400
|
+
const epk = bytesToB64Url(epkSpki);
|
|
401
|
+
return {
|
|
402
|
+
partner_id: partner.partner_id,
|
|
403
|
+
session_envelope,
|
|
404
|
+
session_key_share: {
|
|
405
|
+
key_id: partner.key_id,
|
|
406
|
+
wrapped_key,
|
|
407
|
+
epk,
|
|
408
|
+
alg: "ECDH-ES+HKDF-SHA256+A256GCM",
|
|
409
|
+
v: 2
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
async function encryptSessionForAll(partners) {
|
|
414
|
+
const results = await Promise.all(
|
|
415
|
+
partners.map(({ session_data, partner }) => encryptSessionForPartner(session_data, partner))
|
|
416
|
+
);
|
|
417
|
+
return Object.fromEntries(results.map((r) => [r.partner_id, r]));
|
|
418
|
+
}
|
|
419
|
+
async function decryptSession(share, envelopeB64, privateKeyB64, partnerId) {
|
|
420
|
+
if (share.alg !== "ECDH-ES+HKDF-SHA256+A256GCM") {
|
|
421
|
+
throw new Error(`decryptSession: unsupported alg ${share.alg}`);
|
|
422
|
+
}
|
|
423
|
+
if (share.v !== 2) {
|
|
424
|
+
throw new Error(`decryptSession: unsupported share version ${share.v}`);
|
|
425
|
+
}
|
|
426
|
+
const privateKey = await subtle().importKey(
|
|
427
|
+
"pkcs8",
|
|
428
|
+
b64ToBytes(privateKeyB64),
|
|
429
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
430
|
+
false,
|
|
431
|
+
["deriveBits"]
|
|
432
|
+
);
|
|
433
|
+
const ephemeralPub = await subtle().importKey(
|
|
434
|
+
"spki",
|
|
435
|
+
b64UrlToBytes(share.epk),
|
|
436
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
437
|
+
false,
|
|
438
|
+
[]
|
|
439
|
+
);
|
|
440
|
+
const sharedSecret = await subtle().deriveBits(
|
|
441
|
+
{ name: "ECDH", public: ephemeralPub },
|
|
442
|
+
privateKey,
|
|
443
|
+
256
|
|
444
|
+
);
|
|
445
|
+
const wrappedBytes = b64UrlToBytes(share.wrapped_key);
|
|
446
|
+
if (wrappedBytes.length < WRAP_SALT_LENGTH + WRAP_IV_LENGTH + 16) {
|
|
447
|
+
throw new Error("decryptSession: wrapped_key too short");
|
|
448
|
+
}
|
|
449
|
+
const wrapSalt = wrappedBytes.slice(0, WRAP_SALT_LENGTH);
|
|
450
|
+
const wrapIv = wrappedBytes.slice(WRAP_SALT_LENGTH, WRAP_SALT_LENGTH + WRAP_IV_LENGTH);
|
|
451
|
+
const wrappedSkBytes = wrappedBytes.slice(WRAP_SALT_LENGTH + WRAP_IV_LENGTH);
|
|
452
|
+
const wrapKeyRaw = await subtle().deriveBits(
|
|
453
|
+
{
|
|
454
|
+
name: "HKDF",
|
|
455
|
+
hash: "SHA-256",
|
|
456
|
+
salt: wrapSalt,
|
|
457
|
+
info: sessionWrapInfo(partnerId)
|
|
458
|
+
},
|
|
459
|
+
await subtle().importKey("raw", sharedSecret, "HKDF", false, ["deriveBits"]),
|
|
460
|
+
256
|
|
461
|
+
);
|
|
462
|
+
const wrapKey = await subtle().importKey(
|
|
463
|
+
"raw",
|
|
464
|
+
wrapKeyRaw,
|
|
465
|
+
{ name: "AES-GCM" },
|
|
466
|
+
false,
|
|
467
|
+
["decrypt"]
|
|
468
|
+
);
|
|
469
|
+
const skRawBuf = await subtle().decrypt(
|
|
470
|
+
{ name: "AES-GCM", iv: wrapIv },
|
|
471
|
+
wrapKey,
|
|
472
|
+
wrappedSkBytes
|
|
473
|
+
);
|
|
474
|
+
const sk = await subtle().importKey(
|
|
475
|
+
"raw",
|
|
476
|
+
skRawBuf,
|
|
477
|
+
{ name: "AES-GCM" },
|
|
478
|
+
false,
|
|
479
|
+
["decrypt"]
|
|
480
|
+
);
|
|
481
|
+
const envBytes = b64UrlToBytes(envelopeB64);
|
|
482
|
+
if (envBytes.length < SESSION_IV_LENGTH + 16) {
|
|
483
|
+
throw new Error("decryptSession: envelope too short");
|
|
484
|
+
}
|
|
485
|
+
const sessionIv = envBytes.slice(0, SESSION_IV_LENGTH);
|
|
486
|
+
const sessionCt = envBytes.slice(SESSION_IV_LENGTH);
|
|
487
|
+
const plainBuf = await subtle().decrypt(
|
|
488
|
+
{ name: "AES-GCM", iv: sessionIv },
|
|
489
|
+
sk,
|
|
490
|
+
sessionCt
|
|
491
|
+
);
|
|
492
|
+
return JSON.parse(new TextDecoder().decode(plainBuf));
|
|
493
|
+
}
|
|
494
|
+
async function signWebhookPayload(payload, secret) {
|
|
495
|
+
const key = await subtle().importKey(
|
|
496
|
+
"raw",
|
|
497
|
+
new TextEncoder().encode(secret),
|
|
498
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
499
|
+
false,
|
|
500
|
+
["sign"]
|
|
501
|
+
);
|
|
502
|
+
const sig = await subtle().sign("HMAC", key, new TextEncoder().encode(payload));
|
|
503
|
+
return Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
504
|
+
}
|
|
505
|
+
async function verifyWebhookSignature(payload, signature, secret) {
|
|
506
|
+
if (!/^[0-9a-f]{64}$/i.test(signature)) return false;
|
|
507
|
+
const sigBytes = new Uint8Array(32);
|
|
508
|
+
for (let i = 0; i < 32; i++) sigBytes[i] = Number.parseInt(signature.slice(i * 2, i * 2 + 2), 16);
|
|
509
|
+
const enc = new TextEncoder();
|
|
510
|
+
const key = await subtle().importKey(
|
|
511
|
+
"raw",
|
|
512
|
+
enc.encode(secret),
|
|
513
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
514
|
+
false,
|
|
515
|
+
["verify"]
|
|
516
|
+
);
|
|
517
|
+
return subtle().verify("HMAC", key, sigBytes, enc.encode(payload));
|
|
518
|
+
}
|
|
519
|
+
var subtle, AU_STATE_FULL, SESSION_KEY_BITS, SESSION_IV_LENGTH, WRAP_SALT_LENGTH, WRAP_IV_LENGTH;
|
|
520
|
+
var init_src = __esm({
|
|
521
|
+
"../crypto/src/index.ts"() {
|
|
522
|
+
"use strict";
|
|
523
|
+
init_replay_window();
|
|
524
|
+
init_safe_url();
|
|
525
|
+
subtle = () => globalThis.crypto.subtle;
|
|
526
|
+
AU_STATE_FULL = {
|
|
527
|
+
"new south wales": "NSW",
|
|
528
|
+
"victoria": "VIC",
|
|
529
|
+
"queensland": "QLD",
|
|
530
|
+
"south australia": "SA",
|
|
531
|
+
"western australia": "WA",
|
|
532
|
+
"tasmania": "TAS",
|
|
533
|
+
"northern territory": "NT",
|
|
534
|
+
"australian capital territory": "ACT",
|
|
535
|
+
// Common shorthands people type
|
|
536
|
+
"act": "ACT",
|
|
537
|
+
"nsw": "NSW",
|
|
538
|
+
"vic": "VIC",
|
|
539
|
+
"qld": "QLD",
|
|
540
|
+
"sa": "SA",
|
|
541
|
+
"wa": "WA",
|
|
542
|
+
"tas": "TAS",
|
|
543
|
+
"nt": "NT"
|
|
544
|
+
};
|
|
545
|
+
SESSION_KEY_BITS = 256;
|
|
546
|
+
SESSION_IV_LENGTH = 12;
|
|
547
|
+
WRAP_SALT_LENGTH = 32;
|
|
548
|
+
WRAP_IV_LENGTH = 12;
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
30
552
|
// src/index.ts
|
|
31
553
|
var index_exports = {};
|
|
32
554
|
__export(index_exports, {
|
|
33
555
|
CURRENT_VERSION: () => CURRENT_VERSION,
|
|
34
556
|
DEFAULT_REPLAY_WINDOW_SECS: () => DEFAULT_REPLAY_WINDOW_SECS,
|
|
35
557
|
SUPPORTED_VERSIONS: () => SUPPORTED_VERSIONS,
|
|
558
|
+
compareAddresses: () => compareAddresses,
|
|
36
559
|
createOneAddressHandler: () => createOneAddressHandler,
|
|
37
|
-
decrypt: () =>
|
|
38
|
-
decryptAddress: () =>
|
|
560
|
+
decrypt: () => decryptAddress2,
|
|
561
|
+
decryptAddress: () => decryptAddress2,
|
|
562
|
+
decryptSession: () => decryptSession2,
|
|
39
563
|
fetchLoaPublicKey: () => fetchLoaPublicKey,
|
|
40
564
|
isFreshTimestamp: () => isFreshTimestamp,
|
|
41
565
|
transform: () => transformAddress,
|
|
@@ -49,24 +573,16 @@ __export(index_exports, {
|
|
|
49
573
|
});
|
|
50
574
|
module.exports = __toCommonJS(index_exports);
|
|
51
575
|
var import_crypto = __toESM(require("crypto"));
|
|
52
|
-
|
|
53
|
-
// ../crypto/src/replay-window.ts
|
|
54
|
-
var DEFAULT_REPLAY_WINDOW_SECS = 300;
|
|
55
|
-
function isFreshTimestamp(timestampHeader, toleranceSecs = DEFAULT_REPLAY_WINDOW_SECS, nowSecs) {
|
|
56
|
-
if (typeof timestampHeader !== "string" || timestampHeader.length === 0) return false;
|
|
57
|
-
if (!/^\d+$/.test(timestampHeader)) return false;
|
|
58
|
-
const ts = Number(timestampHeader);
|
|
59
|
-
if (!Number.isFinite(ts) || ts < 0) return false;
|
|
60
|
-
const now = typeof nowSecs === "number" ? nowSecs : Math.floor(Date.now() / 1e3);
|
|
61
|
-
return Math.abs(now - ts) <= toleranceSecs;
|
|
62
|
-
}
|
|
576
|
+
init_src();
|
|
63
577
|
|
|
64
578
|
// ../protocol/src/types.ts
|
|
65
579
|
var CURRENT_VERSION = "2026.1";
|
|
66
580
|
var SUPPORTED_VERSIONS = ["2026.1"];
|
|
67
581
|
|
|
68
582
|
// src/index.ts
|
|
583
|
+
init_src();
|
|
69
584
|
function verifySignature(rawBody, signature, timestamp, secret) {
|
|
585
|
+
if (!/^[0-9a-f]{64}$/i.test(signature)) return false;
|
|
70
586
|
const sigPayload = `${timestamp}.${rawBody}`;
|
|
71
587
|
const expected = import_crypto.default.createHmac("sha256", secret).update(sigPayload).digest("hex");
|
|
72
588
|
const sigBuffer = Buffer.from(signature, "hex");
|
|
@@ -76,7 +592,7 @@ function verifySignature(rawBody, signature, timestamp, secret) {
|
|
|
76
592
|
}
|
|
77
593
|
function verifyWithGrace(rawBody, timestamp, signature, currentSecret, previousSecret, graceUntil) {
|
|
78
594
|
if (verifySignature(rawBody, signature, timestamp, currentSecret)) return true;
|
|
79
|
-
if (previousSecret && graceUntil) {
|
|
595
|
+
if (previousSecret && previousSecret !== currentSecret && graceUntil) {
|
|
80
596
|
const until = typeof graceUntil === "number" ? graceUntil : Date.parse(graceUntil);
|
|
81
597
|
if (!Number.isNaN(until) && Date.now() < until) {
|
|
82
598
|
return verifySignature(rawBody, signature, timestamp, previousSecret);
|
|
@@ -90,7 +606,7 @@ function base64urlToBuffer(b64) {
|
|
|
90
606
|
function pemToBuffer(pem) {
|
|
91
607
|
return Buffer.from(pem.replace(/-----[^-]+-----/g, "").replace(/\s/g, ""), "base64");
|
|
92
608
|
}
|
|
93
|
-
async function
|
|
609
|
+
async function decryptAddress2(payload, privateKeyPem, partnerId) {
|
|
94
610
|
const { ephemeralPublicKey, iv, ciphertext, hkdfSalt } = payload;
|
|
95
611
|
const privateKey = await import_crypto.default.subtle.importKey(
|
|
96
612
|
"pkcs8",
|
|
@@ -112,7 +628,18 @@ async function decryptAddress(payload, privateKeyPem, partnerId) {
|
|
|
112
628
|
256
|
|
113
629
|
);
|
|
114
630
|
const hkdfKey = await import_crypto.default.subtle.importKey("raw", sharedBits, "HKDF", false, ["deriveBits"]);
|
|
115
|
-
|
|
631
|
+
let salt;
|
|
632
|
+
if (hkdfSalt) {
|
|
633
|
+
const saltBytes = base64urlToBuffer(hkdfSalt);
|
|
634
|
+
if (saltBytes.byteLength !== 32) {
|
|
635
|
+
throw new Error(
|
|
636
|
+
`[OneAddress SDK] hkdfSalt must be 32 bytes, received ${saltBytes.byteLength}. This may indicate a protocol version mismatch or a tampered payload.`
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
salt = saltBytes;
|
|
640
|
+
} else {
|
|
641
|
+
salt = new Uint8Array(32);
|
|
642
|
+
}
|
|
116
643
|
const info = new TextEncoder().encode(`oneaddress:${partnerId}`);
|
|
117
644
|
const aesKeyBits = await import_crypto.default.subtle.deriveBits(
|
|
118
645
|
{ name: "HKDF", hash: "SHA-256", salt, info },
|
|
@@ -127,8 +654,13 @@ async function decryptAddress(payload, privateKeyPem, partnerId) {
|
|
|
127
654
|
);
|
|
128
655
|
return JSON.parse(new TextDecoder().decode(plaintext));
|
|
129
656
|
}
|
|
657
|
+
async function decryptSession2(share, envelopeB64, privateKeyPem, partnerId) {
|
|
658
|
+
const { decryptSession: decryptSessionCrypto } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
659
|
+
const privateKeyB64 = privateKeyPem.replace(/-----[^-]+-----/g, "").replace(/\s/g, "");
|
|
660
|
+
return decryptSessionCrypto(share, envelopeB64, privateKeyB64, partnerId);
|
|
661
|
+
}
|
|
130
662
|
async function transformAddress(payload, privateKeyPem, partnerId, recipientSpkiPem) {
|
|
131
|
-
const plaintext = await
|
|
663
|
+
const plaintext = await decryptAddress2(payload, privateKeyPem, partnerId);
|
|
132
664
|
const plaintextBytes = new TextEncoder().encode(JSON.stringify(plaintext));
|
|
133
665
|
const recipientKey = await import_crypto.default.subtle.importKey(
|
|
134
666
|
"spki",
|
|
@@ -149,7 +681,7 @@ async function transformAddress(payload, privateKeyPem, partnerId, recipientSpki
|
|
|
149
681
|
);
|
|
150
682
|
const hkdfSaltBytes = import_crypto.default.getRandomValues(new Uint8Array(32));
|
|
151
683
|
const hkdfKey = await import_crypto.default.subtle.importKey("raw", sharedBits, "HKDF", false, ["deriveBits"]);
|
|
152
|
-
const info = new TextEncoder().encode(`oneaddress:transform`);
|
|
684
|
+
const info = new TextEncoder().encode(`oneaddress:transform:${partnerId}`);
|
|
153
685
|
const aesKeyBits = await import_crypto.default.subtle.deriveBits(
|
|
154
686
|
{ name: "HKDF", hash: "SHA-256", salt: hkdfSaltBytes, info },
|
|
155
687
|
hkdfKey,
|
|
@@ -170,8 +702,8 @@ async function transformAddress(payload, privateKeyPem, partnerId, recipientSpki
|
|
|
170
702
|
hkdfSalt: Buffer.from(hkdfSaltBytes).toString("base64")
|
|
171
703
|
};
|
|
172
704
|
}
|
|
173
|
-
var OA_APP_BASE_URL = "https://
|
|
174
|
-
var ALLOWED_LOA_HOSTS = /* @__PURE__ */ new Set(["app.oneaddress.io", "localhost", "127.0.0.1"]);
|
|
705
|
+
var OA_APP_BASE_URL = "https://oneaddress.io";
|
|
706
|
+
var ALLOWED_LOA_HOSTS = /* @__PURE__ */ new Set(["oneaddress.io", "app.oneaddress.io", "localhost", "127.0.0.1"]);
|
|
175
707
|
async function fetchLoaPublicKey(appBaseUrl = OA_APP_BASE_URL) {
|
|
176
708
|
let parsedBase;
|
|
177
709
|
try {
|
|
@@ -240,6 +772,63 @@ function validateAddress(raw) {
|
|
|
240
772
|
}
|
|
241
773
|
return obj;
|
|
242
774
|
}
|
|
775
|
+
var STREET_SUFFIX_MAP = {
|
|
776
|
+
st: "street",
|
|
777
|
+
str: "street",
|
|
778
|
+
rd: "road",
|
|
779
|
+
ave: "avenue",
|
|
780
|
+
av: "avenue",
|
|
781
|
+
blvd: "boulevard",
|
|
782
|
+
dr: "drive",
|
|
783
|
+
ct: "court",
|
|
784
|
+
cres: "crescent",
|
|
785
|
+
cr: "crescent",
|
|
786
|
+
pl: "place",
|
|
787
|
+
ln: "lane",
|
|
788
|
+
hwy: "highway",
|
|
789
|
+
pde: "parade",
|
|
790
|
+
pkwy: "parkway",
|
|
791
|
+
ter: "terrace",
|
|
792
|
+
cl: "close"
|
|
793
|
+
};
|
|
794
|
+
function expandSuffixes(line) {
|
|
795
|
+
return line.split(/\s+/).map((tok) => {
|
|
796
|
+
const lower = tok.toLowerCase().replace(/[.,]$/, "");
|
|
797
|
+
return STREET_SUFFIX_MAP[lower] ?? tok.replace(/[.,]$/, "").toLowerCase();
|
|
798
|
+
}).join(" ");
|
|
799
|
+
}
|
|
800
|
+
function normaliseLine(value) {
|
|
801
|
+
if (!value) return "";
|
|
802
|
+
const collapsed = value.toLowerCase().trim().replace(/\s+/g, " ");
|
|
803
|
+
return expandSuffixes(collapsed);
|
|
804
|
+
}
|
|
805
|
+
function normaliseToken(value) {
|
|
806
|
+
return (value ?? "").toLowerCase().trim().replace(/\s+/g, " ");
|
|
807
|
+
}
|
|
808
|
+
function normalisePostcode(value) {
|
|
809
|
+
const trimmed = (value ?? "").trim();
|
|
810
|
+
if (!trimmed) return "";
|
|
811
|
+
if (/^\d{1,4}$/.test(trimmed)) return trimmed.padStart(4, "0");
|
|
812
|
+
return trimmed.toLowerCase();
|
|
813
|
+
}
|
|
814
|
+
function compareAddresses(a, b) {
|
|
815
|
+
const aStreet = normaliseLine(a.street ?? a.address_line1);
|
|
816
|
+
const bStreet = normaliseLine(b.street ?? b.address_line1);
|
|
817
|
+
if (!aStreet || !bStreet || aStreet !== bStreet) return false;
|
|
818
|
+
const aSuburb = normaliseToken(a.suburb);
|
|
819
|
+
const bSuburb = normaliseToken(b.suburb);
|
|
820
|
+
if (!aSuburb || !bSuburb || aSuburb !== bSuburb) return false;
|
|
821
|
+
const aState = normaliseToken(a.state);
|
|
822
|
+
const bState = normaliseToken(b.state);
|
|
823
|
+
if (!aState || !bState || aState !== bState) return false;
|
|
824
|
+
const aPost = normalisePostcode(a.postcode);
|
|
825
|
+
const bPost = normalisePostcode(b.postcode);
|
|
826
|
+
if (!aPost || !bPost || aPost !== bPost) return false;
|
|
827
|
+
const aCountry = normaliseToken(a.country);
|
|
828
|
+
const bCountry = normaliseToken(b.country);
|
|
829
|
+
if (aCountry && bCountry && aCountry !== bCountry) return false;
|
|
830
|
+
return true;
|
|
831
|
+
}
|
|
243
832
|
function createOneAddressHandler(options) {
|
|
244
833
|
const {
|
|
245
834
|
webhookSecret,
|
|
@@ -248,6 +837,7 @@ function createOneAddressHandler(options) {
|
|
|
248
837
|
privateKeyPem,
|
|
249
838
|
onUpdate,
|
|
250
839
|
onVerify,
|
|
840
|
+
onAccountVerify,
|
|
251
841
|
timestampToleranceSecs = 300,
|
|
252
842
|
idempotencyStore
|
|
253
843
|
} = options;
|
|
@@ -312,7 +902,7 @@ function createOneAddressHandler(options) {
|
|
|
312
902
|
});
|
|
313
903
|
}
|
|
314
904
|
const encrypted = body.address_encrypted;
|
|
315
|
-
const rawAddress = await
|
|
905
|
+
const rawAddress = await decryptAddress2(encrypted, privateKeyPem, partnerId);
|
|
316
906
|
const event = {
|
|
317
907
|
event: "address.updated",
|
|
318
908
|
version: body.oneaddress_version ?? body.version ?? "1",
|
|
@@ -323,6 +913,7 @@ function createOneAddressHandler(options) {
|
|
|
323
913
|
customer: body.customer,
|
|
324
914
|
address: validateAddress(rawAddress),
|
|
325
915
|
loa: body.loa,
|
|
916
|
+
id_verification: body.id_verification,
|
|
326
917
|
raw: rawAddress
|
|
327
918
|
};
|
|
328
919
|
const result = await onUpdate(event);
|
|
@@ -345,7 +936,7 @@ function createOneAddressHandler(options) {
|
|
|
345
936
|
});
|
|
346
937
|
}
|
|
347
938
|
const encrypted = body.address_encrypted;
|
|
348
|
-
const rawAddress = await
|
|
939
|
+
const rawAddress = await decryptAddress2(encrypted, privateKeyPem, partnerId);
|
|
349
940
|
const event = {
|
|
350
941
|
event: "address.verify",
|
|
351
942
|
version: body.oneaddress_version ?? body.version ?? "1",
|
|
@@ -358,6 +949,7 @@ function createOneAddressHandler(options) {
|
|
|
358
949
|
customer: body.customer ?? {},
|
|
359
950
|
address: validateAddress(rawAddress),
|
|
360
951
|
loa: body.loa,
|
|
952
|
+
id_verification: body.id_verification,
|
|
361
953
|
raw: rawAddress
|
|
362
954
|
};
|
|
363
955
|
const result = await onVerify(event);
|
|
@@ -366,6 +958,24 @@ function createOneAddressHandler(options) {
|
|
|
366
958
|
headers: { "Content-Type": "application/json" }
|
|
367
959
|
});
|
|
368
960
|
}
|
|
961
|
+
if (body.event === "account.verify" && onAccountVerify) {
|
|
962
|
+
const event = {
|
|
963
|
+
event: "account.verify",
|
|
964
|
+
version: body.oneaddress_version ?? body.version ?? "1",
|
|
965
|
+
id: body.id ?? "",
|
|
966
|
+
timestamp: tsNum,
|
|
967
|
+
partner_id: partnerId,
|
|
968
|
+
dispatchId,
|
|
969
|
+
user_id: body.user_id ?? "",
|
|
970
|
+
customer: body.customer ?? {},
|
|
971
|
+
raw: body
|
|
972
|
+
};
|
|
973
|
+
const result = await onAccountVerify(event);
|
|
974
|
+
return new Response(JSON.stringify({ ok: true, ...result }), {
|
|
975
|
+
status: 200,
|
|
976
|
+
headers: { "Content-Type": "application/json" }
|
|
977
|
+
});
|
|
978
|
+
}
|
|
369
979
|
return new Response(JSON.stringify({ ok: true, skipped: true }), {
|
|
370
980
|
status: 200,
|
|
371
981
|
headers: { "Content-Type": "application/json" }
|
|
@@ -385,9 +995,11 @@ function createOneAddressHandler(options) {
|
|
|
385
995
|
CURRENT_VERSION,
|
|
386
996
|
DEFAULT_REPLAY_WINDOW_SECS,
|
|
387
997
|
SUPPORTED_VERSIONS,
|
|
998
|
+
compareAddresses,
|
|
388
999
|
createOneAddressHandler,
|
|
389
1000
|
decrypt,
|
|
390
1001
|
decryptAddress,
|
|
1002
|
+
decryptSession,
|
|
391
1003
|
fetchLoaPublicKey,
|
|
392
1004
|
isFreshTimestamp,
|
|
393
1005
|
transform,
|