@oneaddress/partner-sdk 2.8.0 → 2.10.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 +81 -3
- package/README.md +54 -1
- package/dist/{chunk-PP2TM7HN.mjs → chunk-JJ2B5VFO.mjs} +147 -25
- package/dist/{chunk-BFSYMDJI.mjs → chunk-NJGZ6ISS.mjs} +268 -12
- package/dist/edge.d.mts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +311 -36
- package/dist/edge.mjs +12 -2
- package/dist/index.d.mts +239 -2
- package/dist/index.d.ts +239 -2
- package/dist/index.js +437 -36
- package/dist/index.mjs +36 -2
- package/dist/{src-P3LR7F4A.mjs → src-XBG2QHG4.mjs} +11 -1
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
isFreshTimestamp,
|
|
6
6
|
isSafeWebhookUrl,
|
|
7
7
|
verifyRegistryHead
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JJ2B5VFO.mjs";
|
|
9
9
|
|
|
10
10
|
// src/index.ts
|
|
11
11
|
import crypto from "crypto";
|
|
@@ -14,6 +14,19 @@ import crypto from "crypto";
|
|
|
14
14
|
var CURRENT_VERSION = "2026.1";
|
|
15
15
|
var SUPPORTED_VERSIONS = ["2026.1"];
|
|
16
16
|
|
|
17
|
+
// ../protocol/src/notice-period.ts
|
|
18
|
+
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
19
|
+
function isIsoDate(value) {
|
|
20
|
+
if (typeof value !== "string") return false;
|
|
21
|
+
const m = ISO_DATE.exec(value);
|
|
22
|
+
if (!m) return false;
|
|
23
|
+
const d = new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])));
|
|
24
|
+
return toIso(d) === value;
|
|
25
|
+
}
|
|
26
|
+
function toIso(d) {
|
|
27
|
+
return d.toISOString().slice(0, 10);
|
|
28
|
+
}
|
|
29
|
+
|
|
17
30
|
// ../protocol/src/d5-body.ts
|
|
18
31
|
var D5_BODY_ALWAYS = [
|
|
19
32
|
"event",
|
|
@@ -43,7 +56,18 @@ var D5_BODY_CONDITIONAL = {
|
|
|
43
56
|
*/
|
|
44
57
|
id: "key-crossover copy only",
|
|
45
58
|
/** The sibling marker naming the other key_ids this update was sealed to. */
|
|
46
|
-
crossover_key_ids: "key-crossover copy only"
|
|
59
|
+
crossover_key_ids: "key-crossover copy only",
|
|
60
|
+
/**
|
|
61
|
+
* The day the change takes effect, `YYYY-MM-DD` (31 Oct 2026). Set on every
|
|
62
|
+
* dispatch made for a SCHEDULED MOVE, which is its move date. A scheduled
|
|
63
|
+
* move sends each recipient early enough for its own notice period
|
|
64
|
+
* (`resolveRecipientSendPlan` in `notice-period.ts`), so the update can
|
|
65
|
+
* arrive days before the customer moves; a recipient that treated it as
|
|
66
|
+
* immediate could start charging at the new address from the day it arrived.
|
|
67
|
+
* Absent on an immediate update, which takes effect on receipt. Optional for
|
|
68
|
+
* receivers: an SDK that does not know the field ignores it.
|
|
69
|
+
*/
|
|
70
|
+
effective_date: "scheduled move only"
|
|
47
71
|
};
|
|
48
72
|
var D5_BODY_DRILL_ONLY = ["conformance"];
|
|
49
73
|
var D5_BODY_ADDED_AT_SEND = ["dispatch_id"];
|
|
@@ -182,6 +206,33 @@ var LOA_V2_REFUSALS = [
|
|
|
182
206
|
"loa_v2_name_mismatch"
|
|
183
207
|
];
|
|
184
208
|
|
|
209
|
+
// ../protocol/src/verification-commitment.ts
|
|
210
|
+
var VERIFICATION_COMMITMENT_VERSION = "oa-verify.v1";
|
|
211
|
+
var ASCII_WHITESPACE_RUN = /[\t\n\v\f\r ]+/g;
|
|
212
|
+
function normaliseCommitmentField(value) {
|
|
213
|
+
if (typeof value !== "string") return "";
|
|
214
|
+
const collapsed = value.replace(ASCII_WHITESPACE_RUN, " ");
|
|
215
|
+
const start = collapsed.startsWith(" ") ? 1 : 0;
|
|
216
|
+
const end = collapsed.length > start && collapsed.endsWith(" ") ? collapsed.length - 1 : collapsed.length;
|
|
217
|
+
return collapsed.slice(start, end);
|
|
218
|
+
}
|
|
219
|
+
function verificationCommitmentString(verificationId, index, record) {
|
|
220
|
+
if (!Number.isInteger(index) || index <= 0) {
|
|
221
|
+
throw new RangeError(`verification commitment index must be a positive integer, got ${String(index)}`);
|
|
222
|
+
}
|
|
223
|
+
return [
|
|
224
|
+
VERIFICATION_COMMITMENT_VERSION,
|
|
225
|
+
normaliseCommitmentField(verificationId),
|
|
226
|
+
String(index),
|
|
227
|
+
normaliseCommitmentField(record.name),
|
|
228
|
+
normaliseCommitmentField(record.street),
|
|
229
|
+
normaliseCommitmentField(record.suburb),
|
|
230
|
+
normaliseCommitmentField(record.state),
|
|
231
|
+
normaliseCommitmentField(record.postcode),
|
|
232
|
+
normaliseCommitmentField(record.country)
|
|
233
|
+
].join("\n");
|
|
234
|
+
}
|
|
235
|
+
|
|
185
236
|
// src/app-hosts.ts
|
|
186
237
|
function allowedAppHosts() {
|
|
187
238
|
const hosts = ["oneaddress.io", "app.oneaddress.io"];
|
|
@@ -215,6 +266,96 @@ function resolveAppOrigin(baseUrl, label, extraHosts) {
|
|
|
215
266
|
return parsed.origin;
|
|
216
267
|
}
|
|
217
268
|
|
|
269
|
+
// src/update-check.ts
|
|
270
|
+
var SDK_VERSION = "2.10.0";
|
|
271
|
+
var UPDATE_GUIDE_URL = "https://partners.oneaddress.io/#updating-safely";
|
|
272
|
+
var REGISTRY_URL = "https://registry.npmjs.org/@oneaddress/partner-sdk/latest";
|
|
273
|
+
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
274
|
+
var TIMEOUT_MS = 5e3;
|
|
275
|
+
function updateCheckEnabled(setting) {
|
|
276
|
+
const s = (setting ?? "").trim().toLowerCase();
|
|
277
|
+
return !(s === "off" || s === "never" || s === "0" || s === "false");
|
|
278
|
+
}
|
|
279
|
+
function parseVersion(v) {
|
|
280
|
+
if (typeof v !== "string") return null;
|
|
281
|
+
const m = /^(\d{1,6})\.(\d{1,6})\.(\d{1,6})$/.exec(v.trim());
|
|
282
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
283
|
+
}
|
|
284
|
+
function isNewerVersion(latest, running) {
|
|
285
|
+
const a = parseVersion(latest);
|
|
286
|
+
const b = parseVersion(running);
|
|
287
|
+
if (!a || !b) return false;
|
|
288
|
+
for (let i = 0; i < 3; i++) {
|
|
289
|
+
if (a[i] !== b[i]) return a[i] > b[i];
|
|
290
|
+
}
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
function updateAvailableLine(running, latest) {
|
|
294
|
+
return `update available: ${running} -> ${latest}, see ${UPDATE_GUIDE_URL}`;
|
|
295
|
+
}
|
|
296
|
+
function updateCheckMetric(result, product = "partner-sdk-ts") {
|
|
297
|
+
const latest = result.latest ?? "unknown";
|
|
298
|
+
const value = result.state === "available" ? 1 : 0;
|
|
299
|
+
return `oneaddress_update_available{product="${product}",running="${result.running}",latest="${latest}"} ${value}`;
|
|
300
|
+
}
|
|
301
|
+
async function checkForUpdate(opts = {}) {
|
|
302
|
+
const running = opts.running ?? SDK_VERSION;
|
|
303
|
+
const env = opts.env ?? (typeof process !== "undefined" ? process.env : {});
|
|
304
|
+
if (!updateCheckEnabled(env.ONEADDRESS_UPDATE_CHECK)) return { state: "disabled", running };
|
|
305
|
+
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
306
|
+
const now = opts.now ?? Date.now;
|
|
307
|
+
if (typeof fetchImpl !== "function") return { state: "unknown", running };
|
|
308
|
+
const abort = new AbortController();
|
|
309
|
+
const timer = setTimeout(() => abort.abort(), opts.timeoutMs ?? TIMEOUT_MS);
|
|
310
|
+
try {
|
|
311
|
+
const res = await fetchImpl(opts.registryUrl ?? REGISTRY_URL, { signal: abort.signal });
|
|
312
|
+
const checkedAt = now();
|
|
313
|
+
if (!res.ok) return { state: "unknown", running, checkedAt };
|
|
314
|
+
const body = await res.json();
|
|
315
|
+
if (!parseVersion(body?.version)) return { state: "unknown", running, checkedAt };
|
|
316
|
+
const latest = body.version.trim();
|
|
317
|
+
return {
|
|
318
|
+
state: isNewerVersion(latest, running) ? "available" : "current",
|
|
319
|
+
running,
|
|
320
|
+
latest,
|
|
321
|
+
checkedAt
|
|
322
|
+
};
|
|
323
|
+
} catch {
|
|
324
|
+
return { state: "unknown", running };
|
|
325
|
+
} finally {
|
|
326
|
+
clearTimeout(timer);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function startUpdateCheck(opts = {}) {
|
|
330
|
+
const running = opts.running ?? SDK_VERSION;
|
|
331
|
+
let last = { state: "unknown", running };
|
|
332
|
+
let announced = null;
|
|
333
|
+
const log = opts.log ?? ((line) => console.warn(line));
|
|
334
|
+
const env = opts.env ?? (typeof process !== "undefined" ? process.env : {});
|
|
335
|
+
if (!updateCheckEnabled(env.ONEADDRESS_UPDATE_CHECK)) {
|
|
336
|
+
last = { state: "disabled", running };
|
|
337
|
+
opts.onResult?.(last);
|
|
338
|
+
return { current: () => last, stop: () => {
|
|
339
|
+
} };
|
|
340
|
+
}
|
|
341
|
+
const run = async () => {
|
|
342
|
+
const result = await checkForUpdate({ ...opts, running, env });
|
|
343
|
+
if (result.state !== "unknown" || last.state === "unknown") last = result;
|
|
344
|
+
if (last.state === "available" && last.latest && last.latest !== announced) {
|
|
345
|
+
announced = last.latest;
|
|
346
|
+
log(updateAvailableLine(running, last.latest));
|
|
347
|
+
}
|
|
348
|
+
opts.onResult?.(last);
|
|
349
|
+
};
|
|
350
|
+
void run();
|
|
351
|
+
const every = Math.max(opts.intervalMs ?? ONE_DAY_MS, 60 * 60 * 1e3);
|
|
352
|
+
const timer = setInterval(() => {
|
|
353
|
+
void run();
|
|
354
|
+
}, every);
|
|
355
|
+
timer.unref?.();
|
|
356
|
+
return { current: () => last, stop: () => clearInterval(timer) };
|
|
357
|
+
}
|
|
358
|
+
|
|
218
359
|
// ../name-match/src/index.ts
|
|
219
360
|
function isEmailLike(value) {
|
|
220
361
|
return value.includes("@");
|
|
@@ -694,6 +835,18 @@ async function checkRegistryHead(opts) {
|
|
|
694
835
|
headExpiresAt: expires
|
|
695
836
|
};
|
|
696
837
|
}
|
|
838
|
+
if (expectedKeyId) {
|
|
839
|
+
return {
|
|
840
|
+
verdict: "names-key-we-lack",
|
|
841
|
+
checked: true,
|
|
842
|
+
alarm: true,
|
|
843
|
+
detail: `the head names ${named} as the current key for this partner id, not ${expectedKeyId}, the key this recipient is configured with. If you did not rotate to ${named}, address envelopes are being sealed to a key you cannot read: contact OneAddress through a channel that is not oneaddress.io. If you did rotate, update keyId, or pass holdsKey so a key you hold is recognised.`,
|
|
844
|
+
namedKeyId: named,
|
|
845
|
+
expectedKeyId,
|
|
846
|
+
headIssuedAt: issued,
|
|
847
|
+
headExpiresAt: expires
|
|
848
|
+
};
|
|
849
|
+
}
|
|
697
850
|
return {
|
|
698
851
|
verdict: "key-identity-unknown",
|
|
699
852
|
checked: false,
|
|
@@ -853,14 +1006,21 @@ function signPullRequest(opts) {
|
|
|
853
1006
|
};
|
|
854
1007
|
}
|
|
855
1008
|
function verifyWithGrace(rawBody, timestamp, signature, currentSecret, previousSecret, graceUntil) {
|
|
856
|
-
|
|
1009
|
+
return matchingWebhookSecret(rawBody, timestamp, signature, currentSecret, previousSecret, graceUntil) !== null;
|
|
1010
|
+
}
|
|
1011
|
+
function matchingWebhookSecret(rawBody, timestamp, signature, currentSecret, previousSecret, graceUntil) {
|
|
1012
|
+
if (verifySignature(rawBody, signature, timestamp, currentSecret)) return currentSecret;
|
|
857
1013
|
if (previousSecret && previousSecret !== currentSecret && graceUntil) {
|
|
858
1014
|
const until = typeof graceUntil === "number" ? graceUntil : Date.parse(graceUntil);
|
|
859
|
-
if (!Number.isNaN(until) && Date.now() < until) {
|
|
860
|
-
return
|
|
1015
|
+
if (!Number.isNaN(until) && Date.now() < until && verifySignature(rawBody, signature, timestamp, previousSecret)) {
|
|
1016
|
+
return previousSecret;
|
|
861
1017
|
}
|
|
862
1018
|
}
|
|
863
|
-
return
|
|
1019
|
+
return null;
|
|
1020
|
+
}
|
|
1021
|
+
function computeVerificationCommitment(secret, verificationId, index, record) {
|
|
1022
|
+
if (!secret) throw new Error("[OneAddress SDK] a verification commitment needs the webhook secret");
|
|
1023
|
+
return crypto.createHmac("sha256", secret).update(verificationCommitmentString(verificationId, index, record), "utf8").digest("hex");
|
|
864
1024
|
}
|
|
865
1025
|
function base64urlToBuffer(b64) {
|
|
866
1026
|
return Buffer.from(b64.replace(/-/g, "+").replace(/_/g, "/"), "base64");
|
|
@@ -926,15 +1086,34 @@ async function decryptAddress(payload, privateKeyPem, partnerId) {
|
|
|
926
1086
|
);
|
|
927
1087
|
return JSON.parse(new TextDecoder().decode(plaintext));
|
|
928
1088
|
}
|
|
1089
|
+
var PRODUCT_CODE_PATTERN = /^[a-z0-9][a-z0-9_-]{0,39}$/;
|
|
1090
|
+
function readSessionProduct(raw) {
|
|
1091
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
1092
|
+
const { id, code, name } = raw;
|
|
1093
|
+
if (typeof id !== "string" || typeof code !== "string" || !PRODUCT_CODE_PATTERN.test(code)) return null;
|
|
1094
|
+
return { id, code, name: typeof name === "string" && name !== "" ? name : code };
|
|
1095
|
+
}
|
|
1096
|
+
function normaliseSessionProduct(data) {
|
|
1097
|
+
if (!data || typeof data !== "object" || !("product" in data)) return data;
|
|
1098
|
+
const product = readSessionProduct(data.product);
|
|
1099
|
+
if (product === null && data.product != null) {
|
|
1100
|
+
console.warn(
|
|
1101
|
+
// NOSONAR - intentional SDK diagnostic, not user-controlled data
|
|
1102
|
+
"[OneAddress SDK] the session envelope carried a malformed product, so it is treated as absent and the update is handled as a plain account."
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
return { ...data, product };
|
|
1106
|
+
}
|
|
929
1107
|
async function decryptSession(share, envelopeB64, privateKeyPem, partnerId, expectedAlg) {
|
|
930
|
-
const { decryptSession: decryptSessionCrypto } = await import("./src-
|
|
931
|
-
|
|
1108
|
+
const { decryptSession: decryptSessionCrypto } = await import("./src-XBG2QHG4.mjs");
|
|
1109
|
+
const data = await decryptSessionCrypto(
|
|
932
1110
|
share,
|
|
933
1111
|
envelopeB64,
|
|
934
1112
|
typeof privateKeyPem === "string" ? pemToBase64(privateKeyPem) : privateKeyPem,
|
|
935
1113
|
partnerId,
|
|
936
1114
|
expectedAlg
|
|
937
1115
|
);
|
|
1116
|
+
return normaliseSessionProduct(data);
|
|
938
1117
|
}
|
|
939
1118
|
async function transformAddress(payload, privateKeyPem, partnerId, recipientSpkiPem) {
|
|
940
1119
|
const plaintext = await decryptAddress(payload, privateKeyPem, partnerId);
|
|
@@ -1010,6 +1189,13 @@ async function confirmUpdate(opts) {
|
|
|
1010
1189
|
} = opts;
|
|
1011
1190
|
if (!partnerId) return { ok: false, status: 0, error: "partnerId is required" };
|
|
1012
1191
|
if (!secret) return { ok: false, status: 0, error: "secret is required" };
|
|
1192
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(partnerId)) {
|
|
1193
|
+
return {
|
|
1194
|
+
ok: false,
|
|
1195
|
+
status: 0,
|
|
1196
|
+
error: `partnerId must be your partner UUID from the portal, received ${JSON.stringify(partnerId)}`
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1013
1199
|
const id = typeof dispatchId === "string" ? Number(dispatchId) : dispatchId;
|
|
1014
1200
|
if (!Number.isInteger(id) || id <= 0) {
|
|
1015
1201
|
return {
|
|
@@ -1042,7 +1228,11 @@ async function confirmUpdate(opts) {
|
|
|
1042
1228
|
"Content-Type": "application/json",
|
|
1043
1229
|
"X-OneAddress-Timestamp": timestamp,
|
|
1044
1230
|
"X-OneAddress-Signature": signature,
|
|
1045
|
-
[PULL_SIGNATURE_VERSION_HEADER]: "2"
|
|
1231
|
+
[PULL_SIGNATURE_VERSION_HEADER]: "2",
|
|
1232
|
+
// Which SDK sent this, so the partner portal can say when an update
|
|
1233
|
+
// exists. Software name and version only; outside the signature, and
|
|
1234
|
+
// recorded by OneAddress only after the signature verifies.
|
|
1235
|
+
"X-OneAddress-Client": `partner-sdk-ts/${SDK_VERSION}`
|
|
1046
1236
|
},
|
|
1047
1237
|
// The SAME string that was signed. Not an object, and not re-stringified.
|
|
1048
1238
|
body
|
|
@@ -1582,6 +1772,21 @@ function requirePemFor(purpose, key) {
|
|
|
1582
1772
|
`[OneAddress SDK] ${purpose} needs the raw private key; a PrivateKeyOperations delegate ("${key.name}") covers session envelopes only`
|
|
1583
1773
|
);
|
|
1584
1774
|
}
|
|
1775
|
+
var EffectiveDateMismatchError = class extends Error {
|
|
1776
|
+
constructor(sealed, body) {
|
|
1777
|
+
super(
|
|
1778
|
+
`[OneAddress SDK] effective_date in the body (${JSON.stringify(body ?? null)}) does not match the one sealed in the envelope (${JSON.stringify(sealed ?? null)}); refusing rather than applying a date the consumer did not seal`
|
|
1779
|
+
);
|
|
1780
|
+
this.sealed = sealed;
|
|
1781
|
+
this.body = body;
|
|
1782
|
+
this.name = "EffectiveDateMismatchError";
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
function assertEffectiveDateBound(sealed, body) {
|
|
1786
|
+
if (sealed === void 0 && body === void 0) return;
|
|
1787
|
+
if (sealed !== void 0 && body !== void 0 && sealed === body) return;
|
|
1788
|
+
throw new EffectiveDateMismatchError(sealed, body);
|
|
1789
|
+
}
|
|
1585
1790
|
function assertLoaBoundToEnvelope(loa, envelopeUpdateUid) {
|
|
1586
1791
|
if (typeof loa.update_uid !== "string" || typeof envelopeUpdateUid !== "string") return;
|
|
1587
1792
|
if (loa.update_uid !== envelopeUpdateUid) {
|
|
@@ -1722,7 +1927,9 @@ function createOneAddressHandler(options) {
|
|
|
1722
1927
|
customer.known_names = typedAliasesOf(loa);
|
|
1723
1928
|
}
|
|
1724
1929
|
}
|
|
1725
|
-
|
|
1930
|
+
assertEffectiveDateBound(data.effective_date, body.effective_date);
|
|
1931
|
+
const product = data.product ?? null;
|
|
1932
|
+
return { updateTypes, address, newPhone, newEmail, customer, loa, loa_ref, product, raw: data };
|
|
1726
1933
|
}
|
|
1727
1934
|
function isD5Body(body) {
|
|
1728
1935
|
return typeof body.session_envelope === "string" && !!body.session_key_share && typeof body.session_key_share === "object";
|
|
@@ -1751,7 +1958,8 @@ function createOneAddressHandler(options) {
|
|
|
1751
1958
|
headers: { "Content-Type": "application/json" }
|
|
1752
1959
|
});
|
|
1753
1960
|
}
|
|
1754
|
-
|
|
1961
|
+
const signingSecret = matchingWebhookSecret(rawBody, tsHeader, sig, webhookSecret, previousWebhookSecret, webhookSecretGraceUntil);
|
|
1962
|
+
if (signingSecret === null) {
|
|
1755
1963
|
return new Response(JSON.stringify({ error: "Invalid signature" }), {
|
|
1756
1964
|
status: 401,
|
|
1757
1965
|
headers: { "Content-Type": "application/json" }
|
|
@@ -1837,6 +2045,12 @@ function createOneAddressHandler(options) {
|
|
|
1837
2045
|
let event;
|
|
1838
2046
|
enforceLoaPresence(body);
|
|
1839
2047
|
if (isD5Body(body)) {
|
|
2048
|
+
if (body.effective_date !== void 0 && !isIsoDate(body.effective_date)) {
|
|
2049
|
+
return declared(400, {
|
|
2050
|
+
error: "invalid_effective_date",
|
|
2051
|
+
detail: "effective_date must be a YYYY-MM-DD calendar date. Nothing was processed."
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
1840
2054
|
let d5;
|
|
1841
2055
|
try {
|
|
1842
2056
|
d5 = await buildD5Pieces(body, partnerId);
|
|
@@ -1888,6 +2102,8 @@ function createOneAddressHandler(options) {
|
|
|
1888
2102
|
loa: d5.loa,
|
|
1889
2103
|
loa_ref: d5.loa_ref,
|
|
1890
2104
|
id_verification: body.id_verification,
|
|
2105
|
+
...body.effective_date !== void 0 ? { effective_date: body.effective_date } : {},
|
|
2106
|
+
product: d5.product,
|
|
1891
2107
|
raw: d5.raw
|
|
1892
2108
|
};
|
|
1893
2109
|
} else {
|
|
@@ -1956,6 +2172,8 @@ function createOneAddressHandler(options) {
|
|
|
1956
2172
|
loa,
|
|
1957
2173
|
loa_ref,
|
|
1958
2174
|
id_verification: body.id_verification,
|
|
2175
|
+
// The legacy blob predates product lines.
|
|
2176
|
+
product: null,
|
|
1959
2177
|
raw: rawAddress
|
|
1960
2178
|
};
|
|
1961
2179
|
}
|
|
@@ -1970,11 +2188,13 @@ function createOneAddressHandler(options) {
|
|
|
1970
2188
|
}
|
|
1971
2189
|
if (confirm && dispatchId) {
|
|
1972
2190
|
const status = result && typeof result === "object" && result.status ? result.status : "confirmed";
|
|
2191
|
+
const note = result && typeof result === "object" && typeof result.note === "string" ? result.note : void 0;
|
|
1973
2192
|
void confirmUpdate({
|
|
1974
2193
|
partnerId: confirm.partnerId,
|
|
1975
2194
|
secret: confirm.confirmSecret,
|
|
1976
2195
|
dispatchId,
|
|
1977
2196
|
status,
|
|
2197
|
+
...note !== void 0 ? { note } : {},
|
|
1978
2198
|
loaRef: event.loa_ref,
|
|
1979
2199
|
...confirm.oneAddressApi ? { appBaseUrl: confirm.oneAddressApi } : {},
|
|
1980
2200
|
...confirm.allowedHosts ? { allowedHosts: confirm.allowedHosts } : {},
|
|
@@ -2095,11 +2315,26 @@ function createOneAddressHandler(options) {
|
|
|
2095
2315
|
address: d5.address,
|
|
2096
2316
|
raw: d5.raw
|
|
2097
2317
|
});
|
|
2318
|
+
const index = typeof body.index === "number" ? body.index : void 0;
|
|
2319
|
+
const verificationId = typeof body.verification_id === "string" ? body.verification_id : "";
|
|
2320
|
+
let commitment;
|
|
2321
|
+
if (index !== void 0 && Number.isInteger(index) && index > 0 && verificationId) {
|
|
2322
|
+
const newAddress = d5.raw.new_address ?? {};
|
|
2323
|
+
commitment = computeVerificationCommitment(signingSecret, verificationId, index, {
|
|
2324
|
+
name: d5.raw.verified_name,
|
|
2325
|
+
street: newAddress.street,
|
|
2326
|
+
suburb: newAddress.suburb,
|
|
2327
|
+
state: newAddress.state,
|
|
2328
|
+
postcode: newAddress.postcode,
|
|
2329
|
+
country: newAddress.country
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2098
2332
|
return declared(200, {
|
|
2099
2333
|
ok: true,
|
|
2100
2334
|
test: true,
|
|
2101
2335
|
verification: true,
|
|
2102
|
-
index
|
|
2336
|
+
index,
|
|
2337
|
+
...commitment ? { commitment } : {}
|
|
2103
2338
|
});
|
|
2104
2339
|
}
|
|
2105
2340
|
const evt = typeof body.event === "string" ? body.event : "(none)";
|
|
@@ -2209,6 +2444,9 @@ async function buildSignedTestWebhook(opts) {
|
|
|
2209
2444
|
account_number: "TEST-0001",
|
|
2210
2445
|
id_verification_ref: crypto.randomUUID(),
|
|
2211
2446
|
known_names: [],
|
|
2447
|
+
// Sealed beside the body copy, as the relay's pay step does, so a
|
|
2448
|
+
// rehearsed scheduled move passes the handler's binding check.
|
|
2449
|
+
...opts.effectiveDate !== void 0 ? { effective_date: opts.effectiveDate } : {},
|
|
2212
2450
|
...opts.session ?? {}
|
|
2213
2451
|
};
|
|
2214
2452
|
const envelope = await encryptSessionForPartner(sessionData, partnerKey);
|
|
@@ -2271,6 +2509,7 @@ async function buildSignedTestWebhook(opts) {
|
|
|
2271
2509
|
key_share_expiry: keyShareExpiryIso(new Date(nowSecs * 1e3), opts.retentionPeriodDays),
|
|
2272
2510
|
id_verification: { method: "identity_document", verified_at: nowIso, verified: true, platform: "oneaddress/v1" },
|
|
2273
2511
|
...loa_encrypted ? { loa_encrypted } : {},
|
|
2512
|
+
...opts.effectiveDate !== void 0 ? { effective_date: opts.effectiveDate } : {},
|
|
2274
2513
|
// On the wire with a `null` value when no PaymentIntent backed the update,
|
|
2275
2514
|
// so the KEY is present either way.
|
|
2276
2515
|
// `id` and `crossover_key_ids` are crossover-only and therefore NOT emitted
|
|
@@ -2316,6 +2555,17 @@ export {
|
|
|
2316
2555
|
isAcceptableAlias,
|
|
2317
2556
|
acceptTypedAliases,
|
|
2318
2557
|
LOA_V2_REFUSALS,
|
|
2558
|
+
VERIFICATION_COMMITMENT_VERSION,
|
|
2559
|
+
normaliseCommitmentField,
|
|
2560
|
+
verificationCommitmentString,
|
|
2561
|
+
SDK_VERSION,
|
|
2562
|
+
UPDATE_GUIDE_URL,
|
|
2563
|
+
updateCheckEnabled,
|
|
2564
|
+
isNewerVersion,
|
|
2565
|
+
updateAvailableLine,
|
|
2566
|
+
updateCheckMetric,
|
|
2567
|
+
checkForUpdate,
|
|
2568
|
+
startUpdateCheck,
|
|
2319
2569
|
isEmailLike,
|
|
2320
2570
|
namePoolMatches,
|
|
2321
2571
|
findMatchingStoredName,
|
|
@@ -2330,7 +2580,11 @@ export {
|
|
|
2330
2580
|
verifySignature,
|
|
2331
2581
|
signPullRequest,
|
|
2332
2582
|
verifyWithGrace,
|
|
2583
|
+
matchingWebhookSecret,
|
|
2584
|
+
computeVerificationCommitment,
|
|
2333
2585
|
decryptAddress,
|
|
2586
|
+
PRODUCT_CODE_PATTERN,
|
|
2587
|
+
readSessionProduct,
|
|
2334
2588
|
decryptSession,
|
|
2335
2589
|
transformAddress,
|
|
2336
2590
|
transformSession,
|
|
@@ -2360,6 +2614,8 @@ export {
|
|
|
2360
2614
|
sendVerifyResult,
|
|
2361
2615
|
_resetOnceWarningsForTests,
|
|
2362
2616
|
DEFAULT_MAX_BODY_BYTES,
|
|
2617
|
+
EffectiveDateMismatchError,
|
|
2618
|
+
assertEffectiveDateBound,
|
|
2363
2619
|
createOneAddressHandler,
|
|
2364
2620
|
toExpressHandler,
|
|
2365
2621
|
buildSignedTestWebhook
|
package/dist/edge.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { BlindIndexField, CURRENT_VERSION, ComparableAddress, DEFAULT_REPLAY_WINDOW_SECS, EncryptedPayload, LoaV2Context, LoaV2Refusal, LoaV2RefusedError, OneAddressAccountVerifyEvent, OneAddressAddress, OneAddressCustomer, OneAddressCustomerMatch, OneAddressD5LOA, OneAddressHandlerOptions, OneAddressIdVerification, OneAddressLOA, OneAddressUpdateEvent, OneAddressVerifyEvent, SUPPORTED_VERSIONS, SessionData, SessionKeyShare, SessionUpdateType, VerifyResultCallbackParams, acceptTypedAliases, canonicalD5LoaForm, canonicalD5LoaFormV2, checkLoaV2, compareAddresses, computeBlindIndex, createOneAddressHandler, d5LoaRef, decrypt as decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, hasLoaV2, isAcceptableAlias, isEmailLike, isFreshTimestamp, loaEnvelopeSha256, loaFirstName, loaNamesMatch, loaSurname, namePoolMatches, normaliseLoaName, normalizeForBlindIndex, sendVerifyResult, transform as transformAddress, transformSession, typedAliasesOf, validateAddress, verifyD5LOA, verifyD5LOAv2, verifyLOA, verify as verifySignature, verifyGrace as verifyWithGrace } from './index.mjs';
|
|
1
|
+
export { BlindIndexField, CURRENT_VERSION, ComparableAddress, DEFAULT_REPLAY_WINDOW_SECS, EncryptedPayload, LoaV2Context, LoaV2Refusal, LoaV2RefusedError, OneAddressAccountVerifyEvent, OneAddressAddress, OneAddressCustomer, OneAddressCustomerMatch, OneAddressD5LOA, OneAddressHandlerOptions, OneAddressIdVerification, OneAddressLOA, OneAddressUpdateEvent, OneAddressVerifyEvent, SUPPORTED_VERSIONS, SessionData, SessionKeyShare, SessionUpdateType, VERIFICATION_COMMITMENT_VERSION, VerifyResultCallbackParams, acceptTypedAliases, canonicalD5LoaForm, canonicalD5LoaFormV2, checkLoaV2, compareAddresses, computeBlindIndex, computeVerificationCommitment, createOneAddressHandler, d5LoaRef, decrypt as decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, hasLoaV2, isAcceptableAlias, isEmailLike, isFreshTimestamp, loaEnvelopeSha256, loaFirstName, loaNamesMatch, loaSurname, matchingWebhookSecret, namePoolMatches, normaliseCommitmentField, normaliseLoaName, normalizeForBlindIndex, sendVerifyResult, transform as transformAddress, transformSession, typedAliasesOf, validateAddress, verificationCommitmentString, verifyD5LOA, verifyD5LOAv2, verifyLOA, verify as verifySignature, verifyGrace as verifyWithGrace } from './index.mjs';
|
package/dist/edge.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { BlindIndexField, CURRENT_VERSION, ComparableAddress, DEFAULT_REPLAY_WINDOW_SECS, EncryptedPayload, LoaV2Context, LoaV2Refusal, LoaV2RefusedError, OneAddressAccountVerifyEvent, OneAddressAddress, OneAddressCustomer, OneAddressCustomerMatch, OneAddressD5LOA, OneAddressHandlerOptions, OneAddressIdVerification, OneAddressLOA, OneAddressUpdateEvent, OneAddressVerifyEvent, SUPPORTED_VERSIONS, SessionData, SessionKeyShare, SessionUpdateType, VerifyResultCallbackParams, acceptTypedAliases, canonicalD5LoaForm, canonicalD5LoaFormV2, checkLoaV2, compareAddresses, computeBlindIndex, createOneAddressHandler, d5LoaRef, decrypt as decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, hasLoaV2, isAcceptableAlias, isEmailLike, isFreshTimestamp, loaEnvelopeSha256, loaFirstName, loaNamesMatch, loaSurname, namePoolMatches, normaliseLoaName, normalizeForBlindIndex, sendVerifyResult, transform as transformAddress, transformSession, typedAliasesOf, validateAddress, verifyD5LOA, verifyD5LOAv2, verifyLOA, verify as verifySignature, verifyGrace as verifyWithGrace } from './index.js';
|
|
1
|
+
export { BlindIndexField, CURRENT_VERSION, ComparableAddress, DEFAULT_REPLAY_WINDOW_SECS, EncryptedPayload, LoaV2Context, LoaV2Refusal, LoaV2RefusedError, OneAddressAccountVerifyEvent, OneAddressAddress, OneAddressCustomer, OneAddressCustomerMatch, OneAddressD5LOA, OneAddressHandlerOptions, OneAddressIdVerification, OneAddressLOA, OneAddressUpdateEvent, OneAddressVerifyEvent, SUPPORTED_VERSIONS, SessionData, SessionKeyShare, SessionUpdateType, VERIFICATION_COMMITMENT_VERSION, VerifyResultCallbackParams, acceptTypedAliases, canonicalD5LoaForm, canonicalD5LoaFormV2, checkLoaV2, compareAddresses, computeBlindIndex, computeVerificationCommitment, createOneAddressHandler, d5LoaRef, decrypt as decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, hasLoaV2, isAcceptableAlias, isEmailLike, isFreshTimestamp, loaEnvelopeSha256, loaFirstName, loaNamesMatch, loaSurname, matchingWebhookSecret, namePoolMatches, normaliseCommitmentField, normaliseLoaName, normalizeForBlindIndex, sendVerifyResult, transform as transformAddress, transformSession, typedAliasesOf, validateAddress, verificationCommitmentString, verifyD5LOA, verifyD5LOAv2, verifyLOA, verify as verifySignature, verifyGrace as verifyWithGrace } from './index.js';
|