@oneaddress/partner-sdk 2.9.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 +45 -1
- package/README.md +35 -0
- package/dist/{chunk-PP2TM7HN.mjs → chunk-JJ2B5VFO.mjs} +147 -25
- package/dist/{chunk-OKPEOGR5.mjs → chunk-NJGZ6ISS.mjs} +193 -11
- package/dist/edge.d.mts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +254 -35
- package/dist/edge.mjs +12 -2
- package/dist/index.d.mts +186 -1
- package/dist/index.d.ts +186 -1
- package/dist/index.js +360 -35
- package/dist/index.mjs +32 -2
- package/dist/{src-P3LR7F4A.mjs → src-XBG2QHG4.mjs} +11 -1
- package/package.json +1 -1
package/dist/edge.js
CHANGED
|
@@ -4095,6 +4095,16 @@ var init_replay_window = __esm({
|
|
|
4095
4095
|
}
|
|
4096
4096
|
});
|
|
4097
4097
|
|
|
4098
|
+
// ../crypto/src/refund-review-notify.ts
|
|
4099
|
+
function refundReviewNotifySigningString(timestamp, rawBody) {
|
|
4100
|
+
return `oneaddress.refund-review-notify.v1.${timestamp}.${rawBody}`;
|
|
4101
|
+
}
|
|
4102
|
+
var init_refund_review_notify = __esm({
|
|
4103
|
+
"../crypto/src/refund-review-notify.ts"() {
|
|
4104
|
+
"use strict";
|
|
4105
|
+
}
|
|
4106
|
+
});
|
|
4107
|
+
|
|
4098
4108
|
// ../crypto/src/safe-url.ts
|
|
4099
4109
|
function parseIPv4Component(raw) {
|
|
4100
4110
|
if (raw.length === 0) return null;
|
|
@@ -4476,11 +4486,29 @@ var init_partner_key_attestation = __esm({
|
|
|
4476
4486
|
});
|
|
4477
4487
|
|
|
4478
4488
|
// ../crypto/src/registry-root-pin.ts
|
|
4489
|
+
function registryEnvironmentForOrigin(origin) {
|
|
4490
|
+
let o = origin ?? "";
|
|
4491
|
+
if (!o) {
|
|
4492
|
+
const loc = globalThis.location;
|
|
4493
|
+
o = loc?.origin ?? "";
|
|
4494
|
+
}
|
|
4495
|
+
if (!o) return "preview";
|
|
4496
|
+
try {
|
|
4497
|
+
const host = new URL(o).hostname.toLowerCase().replace(/\.$/, "");
|
|
4498
|
+
return PRODUCTION_REGISTRY_HOSTS.includes(host) ? "production" : "preview";
|
|
4499
|
+
} catch {
|
|
4500
|
+
return "preview";
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4479
4503
|
function __setPinnedRegistryRootsForTests(pins) {
|
|
4480
4504
|
overrideForTests = pins;
|
|
4481
4505
|
}
|
|
4482
|
-
function pinnedRegistryRoots() {
|
|
4483
|
-
|
|
4506
|
+
function pinnedRegistryRoots(env = "production") {
|
|
4507
|
+
if (overrideForTests) {
|
|
4508
|
+
if (Array.isArray(overrideForTests)) return overrideForTests;
|
|
4509
|
+
return overrideForTests[env] ?? [];
|
|
4510
|
+
}
|
|
4511
|
+
return REGISTRY_ROOT_PINS[env];
|
|
4484
4512
|
}
|
|
4485
4513
|
function b64ToBytes2(b64) {
|
|
4486
4514
|
const normalised = b64.replace(/-/g, "+").replace(/_/g, "/");
|
|
@@ -4493,34 +4521,47 @@ async function spkiSha256HexFromB64(spkiB64) {
|
|
|
4493
4521
|
const digest = await crypto.subtle.digest("SHA-256", b64ToBytes2(spkiB64));
|
|
4494
4522
|
return bytesToHex3(new Uint8Array(digest));
|
|
4495
4523
|
}
|
|
4496
|
-
async function rootIsPinned(root) {
|
|
4524
|
+
async function rootIsPinned(root, env = "production") {
|
|
4497
4525
|
try {
|
|
4498
4526
|
const digest = await spkiSha256HexFromB64(root.public_key_b64);
|
|
4499
|
-
return pinnedRegistryRoots().some(
|
|
4527
|
+
return pinnedRegistryRoots(env).some(
|
|
4500
4528
|
(p) => p.root_key_id === root.root_key_id && p.spki_sha256 === digest
|
|
4501
4529
|
);
|
|
4502
4530
|
} catch {
|
|
4503
4531
|
return false;
|
|
4504
4532
|
}
|
|
4505
4533
|
}
|
|
4506
|
-
async function unpinnedRootIds(roots) {
|
|
4534
|
+
async function unpinnedRootIds(roots, env = "production") {
|
|
4507
4535
|
const out = [];
|
|
4508
4536
|
for (const root of roots) {
|
|
4509
|
-
if (!await rootIsPinned(root)) out.push(String(root?.root_key_id ?? "(no id)"));
|
|
4537
|
+
if (!await rootIsPinned(root, env)) out.push(String(root?.root_key_id ?? "(no id)"));
|
|
4510
4538
|
}
|
|
4511
4539
|
return out;
|
|
4512
4540
|
}
|
|
4513
|
-
var PINNED_REGISTRY_ROOTS, overrideForTests;
|
|
4541
|
+
var PRODUCTION_REGISTRY_HOSTS, PRODUCTION_ROOT, REGISTRY_ROOT_PINS, PINNED_REGISTRY_ROOTS, overrideForTests;
|
|
4514
4542
|
var init_registry_root_pin = __esm({
|
|
4515
4543
|
"../crypto/src/registry-root-pin.ts"() {
|
|
4516
4544
|
"use strict";
|
|
4517
4545
|
init_partner_key_attestation();
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
})
|
|
4546
|
+
PRODUCTION_REGISTRY_HOSTS = Object.freeze([
|
|
4547
|
+
"oneaddress.io",
|
|
4548
|
+
"www.oneaddress.io",
|
|
4549
|
+
"app.oneaddress.io"
|
|
4523
4550
|
]);
|
|
4551
|
+
PRODUCTION_ROOT = Object.freeze({
|
|
4552
|
+
root_key_id: "rk1_251368ec9b0a84ae",
|
|
4553
|
+
spki_sha256: "251368ec9b0a84ae9881533bd1687efb7d439edd927aef47c1bb3bb069b3dc1d"
|
|
4554
|
+
});
|
|
4555
|
+
REGISTRY_ROOT_PINS = Object.freeze({
|
|
4556
|
+
production: Object.freeze([PRODUCTION_ROOT]),
|
|
4557
|
+
preview: Object.freeze([
|
|
4558
|
+
Object.freeze({
|
|
4559
|
+
root_key_id: "rk1_4690d67464893d48",
|
|
4560
|
+
spki_sha256: "4690d67464893d48ebb335bcd29f3203fbacefbc69afd8a047b639521296bfab"
|
|
4561
|
+
})
|
|
4562
|
+
])
|
|
4563
|
+
});
|
|
4564
|
+
PINNED_REGISTRY_ROOTS = REGISTRY_ROOT_PINS.production;
|
|
4524
4565
|
overrideForTests = null;
|
|
4525
4566
|
}
|
|
4526
4567
|
});
|
|
@@ -4711,6 +4752,30 @@ var init_registry_head = __esm({
|
|
|
4711
4752
|
});
|
|
4712
4753
|
|
|
4713
4754
|
// ../crypto/src/verify-partner-keys.ts
|
|
4755
|
+
function localStorageHeadHighWater(key = "oa-registry-head-issued-at") {
|
|
4756
|
+
return {
|
|
4757
|
+
read() {
|
|
4758
|
+
try {
|
|
4759
|
+
return globalThis.localStorage?.getItem(key) ?? null;
|
|
4760
|
+
} catch {
|
|
4761
|
+
return null;
|
|
4762
|
+
}
|
|
4763
|
+
},
|
|
4764
|
+
write(issuedAt) {
|
|
4765
|
+
try {
|
|
4766
|
+
globalThis.localStorage?.setItem(key, issuedAt);
|
|
4767
|
+
} catch {
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
};
|
|
4771
|
+
}
|
|
4772
|
+
function isOlderThan(candidate, mark) {
|
|
4773
|
+
if (!mark) return false;
|
|
4774
|
+
const m = Date.parse(mark);
|
|
4775
|
+
const c = Date.parse(candidate);
|
|
4776
|
+
if (Number.isNaN(m)) return false;
|
|
4777
|
+
return Number.isNaN(c) || c < m;
|
|
4778
|
+
}
|
|
4714
4779
|
async function saysRootNotConfigured(res) {
|
|
4715
4780
|
if (res.status !== 503) return false;
|
|
4716
4781
|
try {
|
|
@@ -4746,19 +4811,61 @@ async function crossoverOutcomeFor(partnerId, crossover, reg) {
|
|
|
4746
4811
|
if (!reg.head) return "head-unusable";
|
|
4747
4812
|
return await headNamesStagedKey(reg.head, partnerId, crossover.key_id, crossover.public_key_b64) ? "ok" : "not-authorised";
|
|
4748
4813
|
}
|
|
4814
|
+
function refuseAll(keys, outcome) {
|
|
4815
|
+
const blocked = {};
|
|
4816
|
+
const crossoverBlocked = {};
|
|
4817
|
+
try {
|
|
4818
|
+
for (const [partnerId, key] of Object.entries(keys ?? {})) {
|
|
4819
|
+
blocked[partnerId] = outcome;
|
|
4820
|
+
if (key?.crossover) crossoverBlocked[partnerId] = "head-unusable";
|
|
4821
|
+
}
|
|
4822
|
+
} catch {
|
|
4823
|
+
}
|
|
4824
|
+
return { blocked, crossoverBlocked };
|
|
4825
|
+
}
|
|
4749
4826
|
function createPartnerKeyVerifier(env = {}) {
|
|
4750
4827
|
const baseUrl = env.baseUrl ?? "";
|
|
4751
|
-
const report =
|
|
4752
|
-
|
|
4828
|
+
const report = (context, detail) => {
|
|
4829
|
+
try {
|
|
4830
|
+
env.report?.(context, detail);
|
|
4831
|
+
} catch {
|
|
4832
|
+
}
|
|
4833
|
+
};
|
|
4753
4834
|
let registryPromise = null;
|
|
4754
4835
|
function worthCaching(load) {
|
|
4755
4836
|
return load.ok && load.registry.head !== null;
|
|
4756
4837
|
}
|
|
4838
|
+
async function readMark() {
|
|
4839
|
+
try {
|
|
4840
|
+
const v = await env.headHighWater?.read();
|
|
4841
|
+
return typeof v === "string" ? v : null;
|
|
4842
|
+
} catch {
|
|
4843
|
+
return null;
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
async function writeMark(issuedAt) {
|
|
4847
|
+
try {
|
|
4848
|
+
await env.headHighWater?.write(issuedAt);
|
|
4849
|
+
} catch {
|
|
4850
|
+
}
|
|
4851
|
+
}
|
|
4852
|
+
async function judgeHead(headRes, roots) {
|
|
4853
|
+
if (!headRes.ok) return { head: null, headVerdict: "absent" };
|
|
4854
|
+
let head;
|
|
4855
|
+
try {
|
|
4856
|
+
head = await headRes.json();
|
|
4857
|
+
} catch {
|
|
4858
|
+
return { head: null, headVerdict: "unreadable" };
|
|
4859
|
+
}
|
|
4860
|
+
const headVerdict = await verifyRegistryHead(head, roots);
|
|
4861
|
+
return headVerdict === "ok" ? { head, headVerdict } : { head: null, headVerdict };
|
|
4862
|
+
}
|
|
4757
4863
|
async function loadRegistry() {
|
|
4758
4864
|
try {
|
|
4865
|
+
const headUrl = baseUrl + "/.well-known/oneaddress-key-registry-head.json";
|
|
4759
4866
|
const [rootsRes, headRes] = await Promise.all([
|
|
4760
4867
|
fetch(baseUrl + "/.well-known/oneaddress-key-registry.json", { cache: "no-cache" }),
|
|
4761
|
-
fetch(
|
|
4868
|
+
fetch(headUrl, { cache: "no-cache" })
|
|
4762
4869
|
]);
|
|
4763
4870
|
if (!rootsRes.ok) {
|
|
4764
4871
|
const configured = await saysRootNotConfigured(rootsRes);
|
|
@@ -4780,16 +4887,30 @@ function createPartnerKeyVerifier(env = {}) {
|
|
|
4780
4887
|
if (roots.length === 0) {
|
|
4781
4888
|
return { ok: false, failure: { reason: "roots-empty", status: rootsRes.status } };
|
|
4782
4889
|
}
|
|
4783
|
-
const unpinnedRoots = await unpinnedRootIds(roots);
|
|
4890
|
+
const unpinnedRoots = await unpinnedRootIds(roots, registryEnvironmentForOrigin(baseUrl));
|
|
4784
4891
|
if (unpinnedRoots.length > 0) {
|
|
4785
4892
|
return { ok: true, registry: { roots: [], head: null, headVerdict: "root-unpinned", unpinnedRoots } };
|
|
4786
4893
|
}
|
|
4787
|
-
let head =
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
head
|
|
4791
|
-
|
|
4792
|
-
|
|
4894
|
+
let { head, headVerdict } = await judgeHead(headRes, roots);
|
|
4895
|
+
if (head) {
|
|
4896
|
+
const mark = await readMark();
|
|
4897
|
+
if (isOlderThan(head.issued_at, mark)) {
|
|
4898
|
+
let fresh = { head: null, headVerdict: "absent" };
|
|
4899
|
+
try {
|
|
4900
|
+
fresh = await judgeHead(
|
|
4901
|
+
await fetch(`${headUrl}?fresh=${Date.now()}`, { cache: "reload" }),
|
|
4902
|
+
roots
|
|
4903
|
+
);
|
|
4904
|
+
} catch {
|
|
4905
|
+
}
|
|
4906
|
+
if (fresh.head && !isOlderThan(fresh.head.issued_at, mark)) {
|
|
4907
|
+
({ head, headVerdict } = fresh);
|
|
4908
|
+
} else {
|
|
4909
|
+
head = null;
|
|
4910
|
+
headVerdict = "rolled-back";
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
4913
|
+
if (head && head.issued_at !== mark) await writeMark(head.issued_at);
|
|
4793
4914
|
}
|
|
4794
4915
|
return { ok: true, registry: { roots, head, headVerdict, unpinnedRoots: [] } };
|
|
4795
4916
|
} catch {
|
|
@@ -4802,8 +4923,8 @@ function createPartnerKeyVerifier(env = {}) {
|
|
|
4802
4923
|
const load = await pending;
|
|
4803
4924
|
if (!worthCaching(load)) registryPromise = null;
|
|
4804
4925
|
if (!load.ok) {
|
|
4805
|
-
report(context, { registry: "unavailable", enforced:
|
|
4806
|
-
return
|
|
4926
|
+
report(context, { registry: "unavailable", enforced: true, ...load.failure });
|
|
4927
|
+
return refuseAll(keys, "registry-unavailable");
|
|
4807
4928
|
}
|
|
4808
4929
|
const reg = load.registry;
|
|
4809
4930
|
let bound = EMPTY_BOUND;
|
|
@@ -4824,6 +4945,7 @@ function createPartnerKeyVerifier(env = {}) {
|
|
|
4824
4945
|
"not-in-head": [],
|
|
4825
4946
|
"head-unusable": [],
|
|
4826
4947
|
"root-unpinned": [],
|
|
4948
|
+
"registry-unavailable": [],
|
|
4827
4949
|
"error": []
|
|
4828
4950
|
};
|
|
4829
4951
|
const blocked = {};
|
|
@@ -4875,8 +4997,8 @@ function createPartnerKeyVerifier(env = {}) {
|
|
|
4875
4997
|
}
|
|
4876
4998
|
return { blocked, crossoverBlocked };
|
|
4877
4999
|
} catch {
|
|
4878
|
-
report(context, { registry: "verifier-error", enforced:
|
|
4879
|
-
return
|
|
5000
|
+
report(context, { registry: "verifier-error", enforced: true });
|
|
5001
|
+
return refuseAll(keys, "error");
|
|
4880
5002
|
}
|
|
4881
5003
|
}
|
|
4882
5004
|
function __resetRegistryCacheForTests() {
|
|
@@ -5077,9 +5199,11 @@ __export(src_exports, {
|
|
|
5077
5199
|
PARTNER_KEY_REFUSED_MESSAGE: () => PARTNER_KEY_REFUSED_MESSAGE,
|
|
5078
5200
|
PINNED_REGISTRY_ROOTS: () => PINNED_REGISTRY_ROOTS,
|
|
5079
5201
|
PIN_HARDENING_VERSION: () => PIN_HARDENING_VERSION,
|
|
5202
|
+
PRODUCTION_REGISTRY_HOSTS: () => PRODUCTION_REGISTRY_HOSTS,
|
|
5080
5203
|
REGISTRY_HEAD_ALG: () => REGISTRY_HEAD_ALG,
|
|
5081
5204
|
REGISTRY_HEAD_V1: () => REGISTRY_HEAD_V1,
|
|
5082
5205
|
REGISTRY_HEAD_V2: () => REGISTRY_HEAD_V2,
|
|
5206
|
+
REGISTRY_ROOT_PINS: () => REGISTRY_ROOT_PINS,
|
|
5083
5207
|
SENDER_HELD_KEY_ALGORITHM: () => SENDER_HELD_KEY_ALGORITHM,
|
|
5084
5208
|
__setPinnedRegistryRootsForTests: () => __setPinnedRegistryRootsForTests,
|
|
5085
5209
|
blockedPublicKeyReason: () => blockedPublicKeyReason,
|
|
@@ -5113,6 +5237,7 @@ __export(src_exports, {
|
|
|
5113
5237
|
isIpLiteralHost: () => isIpLiteralHost,
|
|
5114
5238
|
isSafeWebhookUrl: () => isSafeWebhookUrl,
|
|
5115
5239
|
keyIdForPublicKey: () => keyIdForPublicKey,
|
|
5240
|
+
localStorageHeadHighWater: () => localStorageHeadHighWater,
|
|
5116
5241
|
memorySenderHeldKeyStore: () => memorySenderHeldKeyStore,
|
|
5117
5242
|
normaliseAddress: () => normaliseAddress,
|
|
5118
5243
|
normalizeForBlindIndex: () => normalizeForBlindIndex,
|
|
@@ -5120,6 +5245,8 @@ __export(src_exports, {
|
|
|
5120
5245
|
parseOprfSeed: () => parseOprfSeed,
|
|
5121
5246
|
partnerKeyFingerprint: () => partnerKeyFingerprint,
|
|
5122
5247
|
pinnedRegistryRoots: () => pinnedRegistryRoots,
|
|
5248
|
+
refundReviewNotifySigningString: () => refundReviewNotifySigningString,
|
|
5249
|
+
registryEnvironmentForOrigin: () => registryEnvironmentForOrigin,
|
|
5123
5250
|
rootIsPinned: () => rootIsPinned,
|
|
5124
5251
|
rootKeyIdFromSpki: () => rootKeyIdFromSpki,
|
|
5125
5252
|
rootKeyIdFromSpkiB64: () => rootKeyIdFromSpkiB64,
|
|
@@ -5752,6 +5879,7 @@ var init_src = __esm({
|
|
|
5752
5879
|
"use strict";
|
|
5753
5880
|
init_hybrid();
|
|
5754
5881
|
init_replay_window();
|
|
5882
|
+
init_refund_review_notify();
|
|
5755
5883
|
init_safe_url();
|
|
5756
5884
|
init_blocked_public_keys();
|
|
5757
5885
|
init_endpoint_health();
|
|
@@ -5803,12 +5931,14 @@ __export(edge_exports, {
|
|
|
5803
5931
|
DEFAULT_REPLAY_WINDOW_SECS: () => DEFAULT_REPLAY_WINDOW_SECS,
|
|
5804
5932
|
LoaV2RefusedError: () => LoaV2RefusedError,
|
|
5805
5933
|
SUPPORTED_VERSIONS: () => SUPPORTED_VERSIONS,
|
|
5934
|
+
VERIFICATION_COMMITMENT_VERSION: () => VERIFICATION_COMMITMENT_VERSION,
|
|
5806
5935
|
acceptTypedAliases: () => acceptTypedAliases,
|
|
5807
5936
|
canonicalD5LoaForm: () => canonicalD5LoaForm,
|
|
5808
5937
|
canonicalD5LoaFormV2: () => canonicalD5LoaFormV2,
|
|
5809
5938
|
checkLoaV2: () => checkLoaV2,
|
|
5810
5939
|
compareAddresses: () => compareAddresses,
|
|
5811
5940
|
computeBlindIndex: () => computeBlindIndex,
|
|
5941
|
+
computeVerificationCommitment: () => computeVerificationCommitment,
|
|
5812
5942
|
createOneAddressHandler: () => createOneAddressHandler,
|
|
5813
5943
|
d5LoaRef: () => d5LoaRef,
|
|
5814
5944
|
decryptAddress: () => decryptAddress2,
|
|
@@ -5824,7 +5954,9 @@ __export(edge_exports, {
|
|
|
5824
5954
|
loaFirstName: () => loaFirstName,
|
|
5825
5955
|
loaNamesMatch: () => loaNamesMatch,
|
|
5826
5956
|
loaSurname: () => loaSurname,
|
|
5957
|
+
matchingWebhookSecret: () => matchingWebhookSecret,
|
|
5827
5958
|
namePoolMatches: () => namePoolMatches,
|
|
5959
|
+
normaliseCommitmentField: () => normaliseCommitmentField,
|
|
5828
5960
|
normaliseLoaName: () => normaliseLoaName,
|
|
5829
5961
|
normalizeForBlindIndex: () => normalizeForBlindIndex,
|
|
5830
5962
|
sendVerifyResult: () => sendVerifyResult,
|
|
@@ -5832,6 +5964,7 @@ __export(edge_exports, {
|
|
|
5832
5964
|
transformSession: () => transformSession,
|
|
5833
5965
|
typedAliasesOf: () => typedAliasesOf,
|
|
5834
5966
|
validateAddress: () => validateAddress,
|
|
5967
|
+
verificationCommitmentString: () => verificationCommitmentString,
|
|
5835
5968
|
verifyD5LOA: () => verifyD5LOA,
|
|
5836
5969
|
verifyD5LOAv2: () => verifyD5LOAv2,
|
|
5837
5970
|
verifyLOA: () => verifyLOA,
|
|
@@ -6017,6 +6150,33 @@ function acceptTypedAliases(verifiedName, aliases) {
|
|
|
6017
6150
|
return out;
|
|
6018
6151
|
}
|
|
6019
6152
|
|
|
6153
|
+
// ../protocol/src/verification-commitment.ts
|
|
6154
|
+
var VERIFICATION_COMMITMENT_VERSION = "oa-verify.v1";
|
|
6155
|
+
var ASCII_WHITESPACE_RUN = /[\t\n\v\f\r ]+/g;
|
|
6156
|
+
function normaliseCommitmentField(value) {
|
|
6157
|
+
if (typeof value !== "string") return "";
|
|
6158
|
+
const collapsed = value.replace(ASCII_WHITESPACE_RUN, " ");
|
|
6159
|
+
const start = collapsed.startsWith(" ") ? 1 : 0;
|
|
6160
|
+
const end = collapsed.length > start && collapsed.endsWith(" ") ? collapsed.length - 1 : collapsed.length;
|
|
6161
|
+
return collapsed.slice(start, end);
|
|
6162
|
+
}
|
|
6163
|
+
function verificationCommitmentString(verificationId, index, record) {
|
|
6164
|
+
if (!Number.isInteger(index) || index <= 0) {
|
|
6165
|
+
throw new RangeError(`verification commitment index must be a positive integer, got ${String(index)}`);
|
|
6166
|
+
}
|
|
6167
|
+
return [
|
|
6168
|
+
VERIFICATION_COMMITMENT_VERSION,
|
|
6169
|
+
normaliseCommitmentField(verificationId),
|
|
6170
|
+
String(index),
|
|
6171
|
+
normaliseCommitmentField(record.name),
|
|
6172
|
+
normaliseCommitmentField(record.street),
|
|
6173
|
+
normaliseCommitmentField(record.suburb),
|
|
6174
|
+
normaliseCommitmentField(record.state),
|
|
6175
|
+
normaliseCommitmentField(record.postcode),
|
|
6176
|
+
normaliseCommitmentField(record.country)
|
|
6177
|
+
].join("\n");
|
|
6178
|
+
}
|
|
6179
|
+
|
|
6020
6180
|
// src/app-hosts.ts
|
|
6021
6181
|
function allowedAppHosts() {
|
|
6022
6182
|
const hosts = ["oneaddress.io", "app.oneaddress.io"];
|
|
@@ -6050,6 +6210,10 @@ function resolveAppOrigin(baseUrl, label, extraHosts) {
|
|
|
6050
6210
|
return parsed.origin;
|
|
6051
6211
|
}
|
|
6052
6212
|
|
|
6213
|
+
// src/update-check.ts
|
|
6214
|
+
var SDK_VERSION = "2.10.0";
|
|
6215
|
+
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
6216
|
+
|
|
6053
6217
|
// src/index.ts
|
|
6054
6218
|
init_src();
|
|
6055
6219
|
init_src();
|
|
@@ -6126,14 +6290,21 @@ function verifySignature(rawBody, signature, timestamp, secret) {
|
|
|
6126
6290
|
return import_crypto2.default.timingSafeEqual(sigBuffer, expBuffer);
|
|
6127
6291
|
}
|
|
6128
6292
|
function verifyWithGrace(rawBody, timestamp, signature, currentSecret, previousSecret, graceUntil) {
|
|
6129
|
-
|
|
6293
|
+
return matchingWebhookSecret(rawBody, timestamp, signature, currentSecret, previousSecret, graceUntil) !== null;
|
|
6294
|
+
}
|
|
6295
|
+
function matchingWebhookSecret(rawBody, timestamp, signature, currentSecret, previousSecret, graceUntil) {
|
|
6296
|
+
if (verifySignature(rawBody, signature, timestamp, currentSecret)) return currentSecret;
|
|
6130
6297
|
if (previousSecret && previousSecret !== currentSecret && graceUntil) {
|
|
6131
6298
|
const until = typeof graceUntil === "number" ? graceUntil : Date.parse(graceUntil);
|
|
6132
|
-
if (!Number.isNaN(until) && Date.now() < until) {
|
|
6133
|
-
return
|
|
6299
|
+
if (!Number.isNaN(until) && Date.now() < until && verifySignature(rawBody, signature, timestamp, previousSecret)) {
|
|
6300
|
+
return previousSecret;
|
|
6134
6301
|
}
|
|
6135
6302
|
}
|
|
6136
|
-
return
|
|
6303
|
+
return null;
|
|
6304
|
+
}
|
|
6305
|
+
function computeVerificationCommitment(secret, verificationId, index, record) {
|
|
6306
|
+
if (!secret) throw new Error("[OneAddress SDK] a verification commitment needs the webhook secret");
|
|
6307
|
+
return import_crypto2.default.createHmac("sha256", secret).update(verificationCommitmentString(verificationId, index, record), "utf8").digest("hex");
|
|
6137
6308
|
}
|
|
6138
6309
|
function base64urlToBuffer(b64) {
|
|
6139
6310
|
return Buffer.from(b64.replace(/-/g, "+").replace(/_/g, "/"), "base64");
|
|
@@ -6199,15 +6370,34 @@ async function decryptAddress2(payload, privateKeyPem, partnerId) {
|
|
|
6199
6370
|
);
|
|
6200
6371
|
return JSON.parse(new TextDecoder().decode(plaintext));
|
|
6201
6372
|
}
|
|
6373
|
+
var PRODUCT_CODE_PATTERN = /^[a-z0-9][a-z0-9_-]{0,39}$/;
|
|
6374
|
+
function readSessionProduct(raw) {
|
|
6375
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
6376
|
+
const { id, code, name } = raw;
|
|
6377
|
+
if (typeof id !== "string" || typeof code !== "string" || !PRODUCT_CODE_PATTERN.test(code)) return null;
|
|
6378
|
+
return { id, code, name: typeof name === "string" && name !== "" ? name : code };
|
|
6379
|
+
}
|
|
6380
|
+
function normaliseSessionProduct(data) {
|
|
6381
|
+
if (!data || typeof data !== "object" || !("product" in data)) return data;
|
|
6382
|
+
const product = readSessionProduct(data.product);
|
|
6383
|
+
if (product === null && data.product != null) {
|
|
6384
|
+
console.warn(
|
|
6385
|
+
// NOSONAR - intentional SDK diagnostic, not user-controlled data
|
|
6386
|
+
"[OneAddress SDK] the session envelope carried a malformed product, so it is treated as absent and the update is handled as a plain account."
|
|
6387
|
+
);
|
|
6388
|
+
}
|
|
6389
|
+
return { ...data, product };
|
|
6390
|
+
}
|
|
6202
6391
|
async function decryptSession2(share, envelopeB64, privateKeyPem, partnerId, expectedAlg) {
|
|
6203
6392
|
const { decryptSession: decryptSessionCrypto } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
6204
|
-
|
|
6393
|
+
const data = await decryptSessionCrypto(
|
|
6205
6394
|
share,
|
|
6206
6395
|
envelopeB64,
|
|
6207
6396
|
typeof privateKeyPem === "string" ? pemToBase64(privateKeyPem) : privateKeyPem,
|
|
6208
6397
|
partnerId,
|
|
6209
6398
|
expectedAlg
|
|
6210
6399
|
);
|
|
6400
|
+
return normaliseSessionProduct(data);
|
|
6211
6401
|
}
|
|
6212
6402
|
async function transformAddress(payload, privateKeyPem, partnerId, recipientSpkiPem) {
|
|
6213
6403
|
const plaintext = await decryptAddress2(payload, privateKeyPem, partnerId);
|
|
@@ -6322,7 +6512,11 @@ async function confirmUpdate(opts2) {
|
|
|
6322
6512
|
"Content-Type": "application/json",
|
|
6323
6513
|
"X-OneAddress-Timestamp": timestamp,
|
|
6324
6514
|
"X-OneAddress-Signature": signature,
|
|
6325
|
-
[PULL_SIGNATURE_VERSION_HEADER]: "2"
|
|
6515
|
+
[PULL_SIGNATURE_VERSION_HEADER]: "2",
|
|
6516
|
+
// Which SDK sent this, so the partner portal can say when an update
|
|
6517
|
+
// exists. Software name and version only; outside the signature, and
|
|
6518
|
+
// recorded by OneAddress only after the signature verifies.
|
|
6519
|
+
"X-OneAddress-Client": `partner-sdk-ts/${SDK_VERSION}`
|
|
6326
6520
|
},
|
|
6327
6521
|
// The SAME string that was signed. Not an object, and not re-stringified.
|
|
6328
6522
|
body
|
|
@@ -6982,7 +7176,8 @@ function createOneAddressHandler(options) {
|
|
|
6982
7176
|
}
|
|
6983
7177
|
}
|
|
6984
7178
|
assertEffectiveDateBound(data.effective_date, body.effective_date);
|
|
6985
|
-
|
|
7179
|
+
const product = data.product ?? null;
|
|
7180
|
+
return { updateTypes, address, newPhone, newEmail, customer, loa, loa_ref, product, raw: data };
|
|
6986
7181
|
}
|
|
6987
7182
|
function isD5Body(body) {
|
|
6988
7183
|
return typeof body.session_envelope === "string" && !!body.session_key_share && typeof body.session_key_share === "object";
|
|
@@ -7011,7 +7206,8 @@ function createOneAddressHandler(options) {
|
|
|
7011
7206
|
headers: { "Content-Type": "application/json" }
|
|
7012
7207
|
});
|
|
7013
7208
|
}
|
|
7014
|
-
|
|
7209
|
+
const signingSecret = matchingWebhookSecret(rawBody, tsHeader, sig, webhookSecret, previousWebhookSecret, webhookSecretGraceUntil);
|
|
7210
|
+
if (signingSecret === null) {
|
|
7015
7211
|
return new Response(JSON.stringify({ error: "Invalid signature" }), {
|
|
7016
7212
|
status: 401,
|
|
7017
7213
|
headers: { "Content-Type": "application/json" }
|
|
@@ -7155,6 +7351,7 @@ function createOneAddressHandler(options) {
|
|
|
7155
7351
|
loa_ref: d5.loa_ref,
|
|
7156
7352
|
id_verification: body.id_verification,
|
|
7157
7353
|
...body.effective_date !== void 0 ? { effective_date: body.effective_date } : {},
|
|
7354
|
+
product: d5.product,
|
|
7158
7355
|
raw: d5.raw
|
|
7159
7356
|
};
|
|
7160
7357
|
} else {
|
|
@@ -7223,6 +7420,8 @@ function createOneAddressHandler(options) {
|
|
|
7223
7420
|
loa,
|
|
7224
7421
|
loa_ref,
|
|
7225
7422
|
id_verification: body.id_verification,
|
|
7423
|
+
// The legacy blob predates product lines.
|
|
7424
|
+
product: null,
|
|
7226
7425
|
raw: rawAddress
|
|
7227
7426
|
};
|
|
7228
7427
|
}
|
|
@@ -7364,11 +7563,26 @@ function createOneAddressHandler(options) {
|
|
|
7364
7563
|
address: d5.address,
|
|
7365
7564
|
raw: d5.raw
|
|
7366
7565
|
});
|
|
7566
|
+
const index = typeof body.index === "number" ? body.index : void 0;
|
|
7567
|
+
const verificationId = typeof body.verification_id === "string" ? body.verification_id : "";
|
|
7568
|
+
let commitment;
|
|
7569
|
+
if (index !== void 0 && Number.isInteger(index) && index > 0 && verificationId) {
|
|
7570
|
+
const newAddress = d5.raw.new_address ?? {};
|
|
7571
|
+
commitment = computeVerificationCommitment(signingSecret, verificationId, index, {
|
|
7572
|
+
name: d5.raw.verified_name,
|
|
7573
|
+
street: newAddress.street,
|
|
7574
|
+
suburb: newAddress.suburb,
|
|
7575
|
+
state: newAddress.state,
|
|
7576
|
+
postcode: newAddress.postcode,
|
|
7577
|
+
country: newAddress.country
|
|
7578
|
+
});
|
|
7579
|
+
}
|
|
7367
7580
|
return declared(200, {
|
|
7368
7581
|
ok: true,
|
|
7369
7582
|
test: true,
|
|
7370
7583
|
verification: true,
|
|
7371
|
-
index
|
|
7584
|
+
index,
|
|
7585
|
+
...commitment ? { commitment } : {}
|
|
7372
7586
|
});
|
|
7373
7587
|
}
|
|
7374
7588
|
const evt = typeof body.event === "string" ? body.event : "(none)";
|
|
@@ -7428,12 +7642,14 @@ function createOneAddressHandler(options) {
|
|
|
7428
7642
|
DEFAULT_REPLAY_WINDOW_SECS,
|
|
7429
7643
|
LoaV2RefusedError,
|
|
7430
7644
|
SUPPORTED_VERSIONS,
|
|
7645
|
+
VERIFICATION_COMMITMENT_VERSION,
|
|
7431
7646
|
acceptTypedAliases,
|
|
7432
7647
|
canonicalD5LoaForm,
|
|
7433
7648
|
canonicalD5LoaFormV2,
|
|
7434
7649
|
checkLoaV2,
|
|
7435
7650
|
compareAddresses,
|
|
7436
7651
|
computeBlindIndex,
|
|
7652
|
+
computeVerificationCommitment,
|
|
7437
7653
|
createOneAddressHandler,
|
|
7438
7654
|
d5LoaRef,
|
|
7439
7655
|
decryptAddress,
|
|
@@ -7449,7 +7665,9 @@ function createOneAddressHandler(options) {
|
|
|
7449
7665
|
loaFirstName,
|
|
7450
7666
|
loaNamesMatch,
|
|
7451
7667
|
loaSurname,
|
|
7668
|
+
matchingWebhookSecret,
|
|
7452
7669
|
namePoolMatches,
|
|
7670
|
+
normaliseCommitmentField,
|
|
7453
7671
|
normaliseLoaName,
|
|
7454
7672
|
normalizeForBlindIndex,
|
|
7455
7673
|
sendVerifyResult,
|
|
@@ -7457,6 +7675,7 @@ function createOneAddressHandler(options) {
|
|
|
7457
7675
|
transformSession,
|
|
7458
7676
|
typedAliasesOf,
|
|
7459
7677
|
validateAddress,
|
|
7678
|
+
verificationCommitmentString,
|
|
7460
7679
|
verifyD5LOA,
|
|
7461
7680
|
verifyD5LOAv2,
|
|
7462
7681
|
verifyLOA,
|
package/dist/edge.mjs
CHANGED
|
@@ -2,11 +2,13 @@ import {
|
|
|
2
2
|
CURRENT_VERSION,
|
|
3
3
|
LoaV2RefusedError,
|
|
4
4
|
SUPPORTED_VERSIONS,
|
|
5
|
+
VERIFICATION_COMMITMENT_VERSION,
|
|
5
6
|
acceptTypedAliases,
|
|
6
7
|
canonicalD5LoaForm,
|
|
7
8
|
canonicalD5LoaFormV2,
|
|
8
9
|
checkLoaV2,
|
|
9
10
|
compareAddresses,
|
|
11
|
+
computeVerificationCommitment,
|
|
10
12
|
createOneAddressHandler,
|
|
11
13
|
d5LoaRef,
|
|
12
14
|
decryptAddress,
|
|
@@ -21,36 +23,41 @@ import {
|
|
|
21
23
|
loaFirstName,
|
|
22
24
|
loaNamesMatch,
|
|
23
25
|
loaSurname,
|
|
26
|
+
matchingWebhookSecret,
|
|
24
27
|
namePoolMatches,
|
|
28
|
+
normaliseCommitmentField,
|
|
25
29
|
normaliseLoaName,
|
|
26
30
|
sendVerifyResult,
|
|
27
31
|
transformAddress,
|
|
28
32
|
transformSession,
|
|
29
33
|
typedAliasesOf,
|
|
30
34
|
validateAddress,
|
|
35
|
+
verificationCommitmentString,
|
|
31
36
|
verifyD5LOA,
|
|
32
37
|
verifyD5LOAv2,
|
|
33
38
|
verifyLOA,
|
|
34
39
|
verifySignature,
|
|
35
40
|
verifyWithGrace
|
|
36
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-NJGZ6ISS.mjs";
|
|
37
42
|
import {
|
|
38
43
|
DEFAULT_REPLAY_WINDOW_SECS,
|
|
39
44
|
computeBlindIndex,
|
|
40
45
|
isFreshTimestamp,
|
|
41
46
|
normalizeForBlindIndex
|
|
42
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-JJ2B5VFO.mjs";
|
|
43
48
|
export {
|
|
44
49
|
CURRENT_VERSION,
|
|
45
50
|
DEFAULT_REPLAY_WINDOW_SECS,
|
|
46
51
|
LoaV2RefusedError,
|
|
47
52
|
SUPPORTED_VERSIONS,
|
|
53
|
+
VERIFICATION_COMMITMENT_VERSION,
|
|
48
54
|
acceptTypedAliases,
|
|
49
55
|
canonicalD5LoaForm,
|
|
50
56
|
canonicalD5LoaFormV2,
|
|
51
57
|
checkLoaV2,
|
|
52
58
|
compareAddresses,
|
|
53
59
|
computeBlindIndex,
|
|
60
|
+
computeVerificationCommitment,
|
|
54
61
|
createOneAddressHandler,
|
|
55
62
|
d5LoaRef,
|
|
56
63
|
decryptAddress,
|
|
@@ -66,7 +73,9 @@ export {
|
|
|
66
73
|
loaFirstName,
|
|
67
74
|
loaNamesMatch,
|
|
68
75
|
loaSurname,
|
|
76
|
+
matchingWebhookSecret,
|
|
69
77
|
namePoolMatches,
|
|
78
|
+
normaliseCommitmentField,
|
|
70
79
|
normaliseLoaName,
|
|
71
80
|
normalizeForBlindIndex,
|
|
72
81
|
sendVerifyResult,
|
|
@@ -74,6 +83,7 @@ export {
|
|
|
74
83
|
transformSession,
|
|
75
84
|
typedAliasesOf,
|
|
76
85
|
validateAddress,
|
|
86
|
+
verificationCommitmentString,
|
|
77
87
|
verifyD5LOA,
|
|
78
88
|
verifyD5LOAv2,
|
|
79
89
|
verifyLOA,
|