@oneaddress/conformance 3.3.0 → 3.5.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 +36 -16
- package/dist/checks.d.ts +244 -13
- package/dist/checks.js +540 -84
- package/dist/index.js +559 -98
- package/dist/plan.d.ts +2 -0
- package/dist/plan.js +2 -0
- package/package.json +1 -1
package/dist/checks.js
CHANGED
|
@@ -32,10 +32,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32
32
|
// src/checks.ts
|
|
33
33
|
var checks_exports = {};
|
|
34
34
|
__export(checks_exports, {
|
|
35
|
+
CONFORMANCE_ADDRESS: () => CONFORMANCE_ADDRESS,
|
|
35
36
|
DEFAULT_ACCOUNT_REF: () => DEFAULT_ACCOUNT_REF,
|
|
36
37
|
DEFAULT_CONFORMANCE_KEY_ID: () => DEFAULT_CONFORMANCE_KEY_ID,
|
|
38
|
+
LoaSignerError: () => LoaSignerError,
|
|
39
|
+
MAX_PRODUCT_LINES_PROBED: () => MAX_PRODUCT_LINES_PROBED,
|
|
40
|
+
UNSIGNED_LOA_NOTE: () => UNSIGNED_LOA_NOTE,
|
|
41
|
+
annotateUnsignedLoa: () => annotateUnsignedLoa,
|
|
37
42
|
asConformanceKey: () => asConformanceKey,
|
|
38
43
|
buildBody: () => buildBody,
|
|
44
|
+
conformanceCommitmentCheck: () => conformanceCommitmentCheck,
|
|
45
|
+
describeFetchError: () => describeFetchError,
|
|
46
|
+
drillLoa: () => drillLoa,
|
|
47
|
+
drillLoaV1Canonical: () => drillLoaV1Canonical,
|
|
48
|
+
drillLoaV2Canonical: () => drillLoaV2Canonical,
|
|
49
|
+
localDrillLoaSigner: () => localDrillLoaSigner,
|
|
39
50
|
markUnprovenChecks: () => markUnprovenChecks,
|
|
40
51
|
plannedCoreCheckIds: () => plannedCoreCheckIds,
|
|
41
52
|
runChecks: () => runChecks,
|
|
@@ -43,7 +54,7 @@ __export(checks_exports, {
|
|
|
43
54
|
signPullV2: () => signPullV2
|
|
44
55
|
});
|
|
45
56
|
module.exports = __toCommonJS(checks_exports);
|
|
46
|
-
var
|
|
57
|
+
var import_node_crypto2 = __toESM(require("crypto"));
|
|
47
58
|
|
|
48
59
|
// ../../node_modules/@noble/hashes/utils.js
|
|
49
60
|
function isBytes(a) {
|
|
@@ -3939,12 +3950,25 @@ var ENDPOINT_STALE_AFTER_MINUTES = ENDPOINT_PROBE_INTERVAL_MINUTES * 4;
|
|
|
3939
3950
|
var ENDPOINT_UNUSABLE_AFTER_MINUTES = ENDPOINT_PROBE_INTERVAL_MINUTES * 24;
|
|
3940
3951
|
|
|
3941
3952
|
// ../crypto/src/registry-root-pin.ts
|
|
3942
|
-
var
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
})
|
|
3953
|
+
var PRODUCTION_REGISTRY_HOSTS = Object.freeze([
|
|
3954
|
+
"oneaddress.io",
|
|
3955
|
+
"www.oneaddress.io",
|
|
3956
|
+
"app.oneaddress.io"
|
|
3947
3957
|
]);
|
|
3958
|
+
var PRODUCTION_ROOT = Object.freeze({
|
|
3959
|
+
root_key_id: "rk1_251368ec9b0a84ae",
|
|
3960
|
+
spki_sha256: "251368ec9b0a84ae9881533bd1687efb7d439edd927aef47c1bb3bb069b3dc1d"
|
|
3961
|
+
});
|
|
3962
|
+
var REGISTRY_ROOT_PINS = Object.freeze({
|
|
3963
|
+
production: Object.freeze([PRODUCTION_ROOT]),
|
|
3964
|
+
preview: Object.freeze([
|
|
3965
|
+
Object.freeze({
|
|
3966
|
+
root_key_id: "rk1_4690d67464893d48",
|
|
3967
|
+
spki_sha256: "4690d67464893d48ebb335bcd29f3203fbacefbc69afd8a047b639521296bfab"
|
|
3968
|
+
})
|
|
3969
|
+
])
|
|
3970
|
+
});
|
|
3971
|
+
var PINNED_REGISTRY_ROOTS = REGISTRY_ROOT_PINS.production;
|
|
3948
3972
|
|
|
3949
3973
|
// ../crypto/src/vault-pin-hardening.ts
|
|
3950
3974
|
var oprf = ristretto255_oprf.oprf;
|
|
@@ -4197,7 +4221,6 @@ var D5_BODY_ALWAYS = [
|
|
|
4197
4221
|
"partner_id",
|
|
4198
4222
|
"session_envelope",
|
|
4199
4223
|
"session_key_share",
|
|
4200
|
-
"stripe_session_id",
|
|
4201
4224
|
"timestamp",
|
|
4202
4225
|
"update_id",
|
|
4203
4226
|
"user_id"
|
|
@@ -4218,7 +4241,18 @@ var D5_BODY_CONDITIONAL = {
|
|
|
4218
4241
|
*/
|
|
4219
4242
|
id: "key-crossover copy only",
|
|
4220
4243
|
/** The sibling marker naming the other key_ids this update was sealed to. */
|
|
4221
|
-
crossover_key_ids: "key-crossover copy only"
|
|
4244
|
+
crossover_key_ids: "key-crossover copy only",
|
|
4245
|
+
/**
|
|
4246
|
+
* The day the change takes effect, `YYYY-MM-DD` (31 Oct 2026). Set on every
|
|
4247
|
+
* dispatch made for a SCHEDULED MOVE, which is its move date. A scheduled
|
|
4248
|
+
* move sends each recipient early enough for its own notice period
|
|
4249
|
+
* (`resolveRecipientSendPlan` in `notice-period.ts`), so the update can
|
|
4250
|
+
* arrive days before the customer moves; a recipient that treated it as
|
|
4251
|
+
* immediate could start charging at the new address from the day it arrived.
|
|
4252
|
+
* Absent on an immediate update, which takes effect on receipt. Optional for
|
|
4253
|
+
* receivers: an SDK that does not know the field ignores it.
|
|
4254
|
+
*/
|
|
4255
|
+
effective_date: "scheduled move only"
|
|
4222
4256
|
};
|
|
4223
4257
|
var D5_BODY_DRILL_ONLY = ["conformance"];
|
|
4224
4258
|
var D5_BODY_ADDED_AT_SEND = ["dispatch_id"];
|
|
@@ -4247,6 +4281,155 @@ function keyShareExpiryIso(dispatchAt, retentionPeriodDays) {
|
|
|
4247
4281
|
return new Date(dispatchAt.getTime() + days * DAY_MS).toISOString();
|
|
4248
4282
|
}
|
|
4249
4283
|
|
|
4284
|
+
// ../protocol/src/loa-v2.ts
|
|
4285
|
+
var LOA_V2_VERSION_TAG = "oneaddress-loa/2";
|
|
4286
|
+
var LOA_V2_LEGACY_ENVELOPE_TAG = "oneaddress-legacy-envelope/1";
|
|
4287
|
+
var LOA_V2_FIELD_ORDER = [
|
|
4288
|
+
"consumer_name",
|
|
4289
|
+
"authorisation_date",
|
|
4290
|
+
"scope",
|
|
4291
|
+
"update_uid",
|
|
4292
|
+
"partner_id",
|
|
4293
|
+
"envelope_sha256"
|
|
4294
|
+
];
|
|
4295
|
+
var LOA_MAX_TYPED_ALIASES = 3;
|
|
4296
|
+
var LoaV2FieldError = class extends Error {
|
|
4297
|
+
constructor(field, reason) {
|
|
4298
|
+
super(`LOA v2 field ${field} ${reason}`);
|
|
4299
|
+
this.field = field;
|
|
4300
|
+
this.name = "LoaV2FieldError";
|
|
4301
|
+
}
|
|
4302
|
+
};
|
|
4303
|
+
var CONTROL_RE = /[\u0000-\u001F\u007F]/;
|
|
4304
|
+
var LONE_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
4305
|
+
function utf8Length(s) {
|
|
4306
|
+
return new TextEncoder().encode(s).length;
|
|
4307
|
+
}
|
|
4308
|
+
function encodeField(name, value) {
|
|
4309
|
+
if (typeof value !== "string") throw new LoaV2FieldError(name, "is not a string");
|
|
4310
|
+
if (CONTROL_RE.test(value)) throw new LoaV2FieldError(name, "contains a control character");
|
|
4311
|
+
if (LONE_SURROGATE_RE.test(value)) throw new LoaV2FieldError(name, "is not well-formed Unicode");
|
|
4312
|
+
return `${utf8Length(value)}:${value}
|
|
4313
|
+
`;
|
|
4314
|
+
}
|
|
4315
|
+
function canonicalLoaV2(fields) {
|
|
4316
|
+
let out = encodeField("version", LOA_V2_VERSION_TAG);
|
|
4317
|
+
for (const f of LOA_V2_FIELD_ORDER) out += encodeField(f, fields[f]);
|
|
4318
|
+
const aliases = fields.consumer_typed_aliases;
|
|
4319
|
+
if (!Array.isArray(aliases)) throw new LoaV2FieldError("consumer_typed_aliases", "is not a list");
|
|
4320
|
+
if (aliases.length > LOA_MAX_TYPED_ALIASES) {
|
|
4321
|
+
throw new LoaV2FieldError("consumer_typed_aliases", `has more than ${LOA_MAX_TYPED_ALIASES} entries`);
|
|
4322
|
+
}
|
|
4323
|
+
out += encodeField("consumer_typed_aliases", String(aliases.length));
|
|
4324
|
+
for (const a of aliases) out += encodeField("consumer_typed_aliases", a);
|
|
4325
|
+
return out;
|
|
4326
|
+
}
|
|
4327
|
+
function loaV2EnvelopeDigestInput(envelope) {
|
|
4328
|
+
if (typeof envelope === "string") return envelope;
|
|
4329
|
+
if (!envelope || typeof envelope !== "object") {
|
|
4330
|
+
throw new LoaV2FieldError("envelope", "is neither a session_envelope string nor an address_encrypted object");
|
|
4331
|
+
}
|
|
4332
|
+
return encodeField("tag", LOA_V2_LEGACY_ENVELOPE_TAG) + encodeField("ephemeralPublicKey", envelope.ephemeralPublicKey) + encodeField("iv", envelope.iv) + encodeField("ciphertext", envelope.ciphertext) + encodeField("hkdfSalt", envelope.hkdfSalt ?? "");
|
|
4333
|
+
}
|
|
4334
|
+
var ASCII_WS_RE = /[ \t\n\v\f\r]+/;
|
|
4335
|
+
var MARK_RE = /\p{M}/gu;
|
|
4336
|
+
function normaliseLoaName(name) {
|
|
4337
|
+
return name.normalize("NFKD").replace(MARK_RE, "").toLowerCase().replace(/\u03C2/g, "\u03C3").split(ASCII_WS_RE).filter((t) => t.length > 0).join(" ");
|
|
4338
|
+
}
|
|
4339
|
+
function loaFirstName(name) {
|
|
4340
|
+
const tokens = normaliseLoaName(name).split(" ").filter((t) => t.length > 0);
|
|
4341
|
+
return tokens.length > 0 ? tokens[0] : "";
|
|
4342
|
+
}
|
|
4343
|
+
var LOA_MIN_SHORT_FORM_LETTERS = 3;
|
|
4344
|
+
function codePoints(s) {
|
|
4345
|
+
return Array.from(s).length;
|
|
4346
|
+
}
|
|
4347
|
+
function isAcceptableAlias(verifiedName, alias) {
|
|
4348
|
+
const vFirst = loaFirstName(verifiedName);
|
|
4349
|
+
const aFirst = loaFirstName(alias);
|
|
4350
|
+
if (!vFirst || !aFirst) return false;
|
|
4351
|
+
if (aFirst === vFirst) return true;
|
|
4352
|
+
const [shorter, longer] = codePoints(aFirst) <= codePoints(vFirst) ? [aFirst, vFirst] : [vFirst, aFirst];
|
|
4353
|
+
return codePoints(shorter) >= LOA_MIN_SHORT_FORM_LETTERS && longer.startsWith(shorter);
|
|
4354
|
+
}
|
|
4355
|
+
function acceptTypedAliases(verifiedName, aliases) {
|
|
4356
|
+
const out = [];
|
|
4357
|
+
if (!Array.isArray(aliases)) return out;
|
|
4358
|
+
const seen = /* @__PURE__ */ new Set([normaliseLoaName(verifiedName)]);
|
|
4359
|
+
for (const a of aliases) {
|
|
4360
|
+
if (out.length >= LOA_MAX_TYPED_ALIASES) break;
|
|
4361
|
+
if (typeof a !== "string") continue;
|
|
4362
|
+
if (CONTROL_RE.test(a) || LONE_SURROGATE_RE.test(a)) continue;
|
|
4363
|
+
const n = normaliseLoaName(a);
|
|
4364
|
+
if (!n || seen.has(n)) continue;
|
|
4365
|
+
if (!isAcceptableAlias(verifiedName, a)) continue;
|
|
4366
|
+
seen.add(n);
|
|
4367
|
+
out.push(a);
|
|
4368
|
+
}
|
|
4369
|
+
return out;
|
|
4370
|
+
}
|
|
4371
|
+
|
|
4372
|
+
// ../protocol/src/drill-loa.ts
|
|
4373
|
+
var DRILL_LOA_CONSUMER_NAME = "CONFORMANCE DRILL";
|
|
4374
|
+
var DRILL_LOA_SCOPE = "CONFORMANCE DRILL. Issued by OneAddress for a receiver conformance run. Authorises no change to any record.";
|
|
4375
|
+
var ONEADDRESS_LOA_ACN = "696 078 869";
|
|
4376
|
+
var DRILL_UPDATE_UID_MIN = 9e8;
|
|
4377
|
+
var DRILL_UPDATE_UID_MAX = 901e6;
|
|
4378
|
+
function drillLoaTypedAliases(aliases) {
|
|
4379
|
+
return acceptTypedAliases(DRILL_LOA_CONSUMER_NAME, aliases);
|
|
4380
|
+
}
|
|
4381
|
+
function canonicalDrillLoaV2(loa) {
|
|
4382
|
+
return canonicalLoaV2({
|
|
4383
|
+
consumer_name: loa.consumer_name,
|
|
4384
|
+
authorisation_date: loa.authorisation_date,
|
|
4385
|
+
scope: loa.scope,
|
|
4386
|
+
update_uid: loa.update_uid,
|
|
4387
|
+
partner_id: loa.partner_id,
|
|
4388
|
+
envelope_sha256: loa.envelope_sha256,
|
|
4389
|
+
consumer_typed_aliases: loa.consumer_typed_aliases
|
|
4390
|
+
});
|
|
4391
|
+
}
|
|
4392
|
+
function canonicalD5LoaString(loa) {
|
|
4393
|
+
return [loa.consumer_name, loa.authorisation_date, loa.scope, loa.update_uid, loa.oneaddress_acn].join("|");
|
|
4394
|
+
}
|
|
4395
|
+
function isWellFormedDrillLoa(loa, request) {
|
|
4396
|
+
if (!loa || typeof loa !== "object") return false;
|
|
4397
|
+
const l = loa;
|
|
4398
|
+
const aliases = l.consumer_typed_aliases;
|
|
4399
|
+
const wantAliases = drillLoaTypedAliases(request.typedAliases);
|
|
4400
|
+
return l.consumer_name === DRILL_LOA_CONSUMER_NAME && l.scope === DRILL_LOA_SCOPE && l.oneaddress_acn === ONEADDRESS_LOA_ACN && l.update_uid === request.updateUid && l.partner_id === request.partnerId && l.envelope_sha256 === request.envelopeSha256 && Array.isArray(aliases) && aliases.length === wantAliases.length && aliases.every((a, i) => a === wantAliases[i]) && l.signature_algorithm === "ECDSA-P256" && typeof l.oneaddress_signature === "string" && /^[0-9a-f]{128}$/.test(l.oneaddress_signature) && typeof l.oneaddress_signature_v2 === "string" && /^[0-9a-f]{128}$/.test(l.oneaddress_signature_v2) && typeof l.authorisation_date === "string" && !Number.isNaN(Date.parse(l.authorisation_date));
|
|
4401
|
+
}
|
|
4402
|
+
|
|
4403
|
+
// ../protocol/src/verification-commitment.ts
|
|
4404
|
+
var VERIFICATION_COMMITMENT_VERSION = "oa-verify.v1";
|
|
4405
|
+
var ASCII_WHITESPACE_RUN = /[\t\n\v\f\r ]+/g;
|
|
4406
|
+
function normaliseCommitmentField(value) {
|
|
4407
|
+
if (typeof value !== "string") return "";
|
|
4408
|
+
const collapsed = value.replace(ASCII_WHITESPACE_RUN, " ");
|
|
4409
|
+
const start = collapsed.startsWith(" ") ? 1 : 0;
|
|
4410
|
+
const end = collapsed.length > start && collapsed.endsWith(" ") ? collapsed.length - 1 : collapsed.length;
|
|
4411
|
+
return collapsed.slice(start, end);
|
|
4412
|
+
}
|
|
4413
|
+
function verificationCommitmentString(verificationId, index, record) {
|
|
4414
|
+
if (!Number.isInteger(index) || index <= 0) {
|
|
4415
|
+
throw new RangeError(`verification commitment index must be a positive integer, got ${String(index)}`);
|
|
4416
|
+
}
|
|
4417
|
+
return [
|
|
4418
|
+
VERIFICATION_COMMITMENT_VERSION,
|
|
4419
|
+
normaliseCommitmentField(verificationId),
|
|
4420
|
+
String(index),
|
|
4421
|
+
normaliseCommitmentField(record.name),
|
|
4422
|
+
normaliseCommitmentField(record.street),
|
|
4423
|
+
normaliseCommitmentField(record.suburb),
|
|
4424
|
+
normaliseCommitmentField(record.state),
|
|
4425
|
+
normaliseCommitmentField(record.postcode),
|
|
4426
|
+
normaliseCommitmentField(record.country)
|
|
4427
|
+
].join("\n");
|
|
4428
|
+
}
|
|
4429
|
+
function isWellFormedCommitment(value) {
|
|
4430
|
+
return typeof value === "string" && /^[0-9a-f]{64}$/.test(value);
|
|
4431
|
+
}
|
|
4432
|
+
|
|
4250
4433
|
// src/plan.ts
|
|
4251
4434
|
function plannedCoreCheckIds(opts2) {
|
|
4252
4435
|
const ids = [
|
|
@@ -4265,10 +4448,50 @@ function plannedCoreCheckIds(opts2) {
|
|
|
4265
4448
|
if (opts2.verifiesAccountReference && opts2.hasKey) ids.push("check-14");
|
|
4266
4449
|
if (opts2.supportsKeyCrossover && opts2.hasKey) ids.push("check-15");
|
|
4267
4450
|
ids.push("check-16");
|
|
4451
|
+
if (opts2.hasKey) ids.push("check-17");
|
|
4452
|
+
if (opts2.hasKey && opts2.hasProductLines) ids.push("check-18");
|
|
4268
4453
|
if (opts2.hasCustomerUrl) ids.push("check-12", "check-13");
|
|
4269
4454
|
return ids;
|
|
4270
4455
|
}
|
|
4271
4456
|
|
|
4457
|
+
// src/loa-forms.ts
|
|
4458
|
+
var import_node_crypto = __toESM(require("crypto"));
|
|
4459
|
+
var DRILL_LOA_SCOPE2 = "Authority to update address records on file.";
|
|
4460
|
+
var PLACEHOLDER_SIGNATURE = "00".repeat(64);
|
|
4461
|
+
function drillLoaV1Canonical(l) {
|
|
4462
|
+
return [l.consumer_name, l.authorisation_date, l.scope, l.update_uid, l.oneaddress_acn].join("|");
|
|
4463
|
+
}
|
|
4464
|
+
function drillLoaV2Canonical(l) {
|
|
4465
|
+
return canonicalLoaV2({
|
|
4466
|
+
consumer_name: l.consumer_name,
|
|
4467
|
+
authorisation_date: l.authorisation_date,
|
|
4468
|
+
scope: l.scope,
|
|
4469
|
+
update_uid: l.update_uid,
|
|
4470
|
+
partner_id: l.partner_id,
|
|
4471
|
+
envelope_sha256: l.envelope_sha256,
|
|
4472
|
+
consumer_typed_aliases: l.consumer_typed_aliases
|
|
4473
|
+
});
|
|
4474
|
+
}
|
|
4475
|
+
function drillLoa(opts2) {
|
|
4476
|
+
const base = {
|
|
4477
|
+
consumer_name: opts2.consumerName,
|
|
4478
|
+
authorisation_date: opts2.authorisationDate,
|
|
4479
|
+
scope: DRILL_LOA_SCOPE2,
|
|
4480
|
+
update_uid: opts2.updateUid,
|
|
4481
|
+
oneaddress_acn: "696 078 869",
|
|
4482
|
+
partner_id: opts2.partnerId,
|
|
4483
|
+
envelope_sha256: import_node_crypto.default.createHash("sha256").update(loaV2EnvelopeDigestInput(opts2.envelope), "utf8").digest("hex"),
|
|
4484
|
+
consumer_typed_aliases: acceptTypedAliases(opts2.consumerName, opts2.knownNames ?? [])
|
|
4485
|
+
};
|
|
4486
|
+
const sign2 = opts2.sign ?? (() => PLACEHOLDER_SIGNATURE);
|
|
4487
|
+
return {
|
|
4488
|
+
...base,
|
|
4489
|
+
oneaddress_signature: sign2(drillLoaV1Canonical(base)),
|
|
4490
|
+
signature_algorithm: "ECDSA-P256",
|
|
4491
|
+
oneaddress_signature_v2: sign2(drillLoaV2Canonical(base))
|
|
4492
|
+
};
|
|
4493
|
+
}
|
|
4494
|
+
|
|
4272
4495
|
// src/credentials.ts
|
|
4273
4496
|
var TEST_WEBHOOK_SECRET = (
|
|
4274
4497
|
// NOSONAR — intentional test credential, not a real secret
|
|
@@ -4279,7 +4502,7 @@ var TEST_PARTNER_PUBLIC_KEY_SPKI_B64 = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqFmY
|
|
|
4279
4502
|
|
|
4280
4503
|
// src/checks.ts
|
|
4281
4504
|
function sign(body, timestamp, secret) {
|
|
4282
|
-
return
|
|
4505
|
+
return import_node_crypto2.default.createHmac("sha256", secret).update(`${timestamp}.${body}`).digest("hex");
|
|
4283
4506
|
}
|
|
4284
4507
|
function buildHeaders(partnerId, timestamp, signature, dispatchId, event = "address.updated") {
|
|
4285
4508
|
return {
|
|
@@ -4293,6 +4516,7 @@ function buildHeaders(partnerId, timestamp, signature, dispatchId, event = "addr
|
|
|
4293
4516
|
};
|
|
4294
4517
|
}
|
|
4295
4518
|
var DEFAULT_ACCOUNT_REF = "CONF-0001";
|
|
4519
|
+
var MAX_PRODUCT_LINES_PROBED = 5;
|
|
4296
4520
|
var DEFAULT_CONFORMANCE_KEY_ID = "conformance-key-1";
|
|
4297
4521
|
function asConformanceKey(key) {
|
|
4298
4522
|
if (!key) return null;
|
|
@@ -4303,15 +4527,102 @@ function asConformanceKey(key) {
|
|
|
4303
4527
|
}
|
|
4304
4528
|
var CONFORMANCE_USER_ID = "conformance:drill";
|
|
4305
4529
|
function conformanceUpdateId() {
|
|
4306
|
-
return
|
|
4530
|
+
return import_node_crypto2.default.randomInt(DRILL_UPDATE_UID_MIN, DRILL_UPDATE_UID_MAX);
|
|
4531
|
+
}
|
|
4532
|
+
var LoaSignerError = class extends Error {
|
|
4533
|
+
constructor(message) {
|
|
4534
|
+
super(message);
|
|
4535
|
+
this.name = "LoaSignerError";
|
|
4536
|
+
}
|
|
4537
|
+
};
|
|
4538
|
+
function localDrillLoaSigner(privateKeyPem) {
|
|
4539
|
+
const key = import_node_crypto2.default.createPrivateKey(privateKeyPem);
|
|
4540
|
+
if (key.asymmetricKeyType !== "ec" || key.asymmetricKeyDetails?.namedCurve !== "prime256v1") {
|
|
4541
|
+
throw new LoaSignerError("the LOA signing key must be an EC P-256 private key (PKCS#8 PEM)");
|
|
4542
|
+
}
|
|
4543
|
+
return async (request) => {
|
|
4544
|
+
const unsigned = {
|
|
4545
|
+
consumer_name: DRILL_LOA_CONSUMER_NAME,
|
|
4546
|
+
authorisation_date: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4547
|
+
scope: DRILL_LOA_SCOPE,
|
|
4548
|
+
update_uid: request.updateUid,
|
|
4549
|
+
oneaddress_acn: ONEADDRESS_LOA_ACN
|
|
4550
|
+
};
|
|
4551
|
+
const sign2 = (text) => import_node_crypto2.default.sign(
|
|
4552
|
+
"SHA256",
|
|
4553
|
+
Buffer.from(text, "utf8"),
|
|
4554
|
+
{ key, dsaEncoding: "ieee-p1363" }
|
|
4555
|
+
).toString("hex");
|
|
4556
|
+
const v2 = {
|
|
4557
|
+
partner_id: request.partnerId,
|
|
4558
|
+
envelope_sha256: request.envelopeSha256,
|
|
4559
|
+
consumer_typed_aliases: drillLoaTypedAliases(request.typedAliases)
|
|
4560
|
+
};
|
|
4561
|
+
return {
|
|
4562
|
+
...unsigned,
|
|
4563
|
+
oneaddress_signature: sign2(canonicalD5LoaString(unsigned)),
|
|
4564
|
+
signature_algorithm: "ECDSA-P256",
|
|
4565
|
+
...v2,
|
|
4566
|
+
oneaddress_signature_v2: sign2(canonicalDrillLoaV2({ ...unsigned, ...v2 }))
|
|
4567
|
+
};
|
|
4568
|
+
};
|
|
4307
4569
|
}
|
|
4308
|
-
async function
|
|
4570
|
+
async function drillLoaFor(request, nowIso, plan) {
|
|
4571
|
+
const mode = plan?.mode ?? "signed";
|
|
4572
|
+
if (mode === "omitted") return null;
|
|
4573
|
+
if (!plan?.signer) {
|
|
4574
|
+
const v2 = {
|
|
4575
|
+
partner_id: request.partnerId,
|
|
4576
|
+
envelope_sha256: request.envelopeSha256,
|
|
4577
|
+
consumer_typed_aliases: drillLoaTypedAliases(request.typedAliases)
|
|
4578
|
+
};
|
|
4579
|
+
return {
|
|
4580
|
+
consumer_name: DRILL_LOA_CONSUMER_NAME,
|
|
4581
|
+
authorisation_date: nowIso,
|
|
4582
|
+
scope: DRILL_LOA_SCOPE,
|
|
4583
|
+
update_uid: request.updateUid,
|
|
4584
|
+
oneaddress_acn: ONEADDRESS_LOA_ACN,
|
|
4585
|
+
oneaddress_signature: "00".repeat(64),
|
|
4586
|
+
signature_algorithm: "ECDSA-P256",
|
|
4587
|
+
...v2,
|
|
4588
|
+
oneaddress_signature_v2: "00".repeat(64)
|
|
4589
|
+
};
|
|
4590
|
+
}
|
|
4591
|
+
let loa;
|
|
4592
|
+
try {
|
|
4593
|
+
loa = await plan.signer(request);
|
|
4594
|
+
} catch (err) {
|
|
4595
|
+
if (err instanceof LoaSignerError) throw err;
|
|
4596
|
+
throw new LoaSignerError(`the drill LOA signer failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
4597
|
+
}
|
|
4598
|
+
if (!isWellFormedDrillLoa(loa, request)) {
|
|
4599
|
+
throw new LoaSignerError("the drill LOA signer returned something that is not a drill LOA for this update");
|
|
4600
|
+
}
|
|
4601
|
+
if (mode === "forged") {
|
|
4602
|
+
return { ...loa, scope: `${DRILL_LOA_SCOPE} ALTERED` };
|
|
4603
|
+
}
|
|
4604
|
+
return loa;
|
|
4605
|
+
}
|
|
4606
|
+
var CONFORMANCE_ADDRESS = {
|
|
4607
|
+
street: "42 Collins Street",
|
|
4608
|
+
suburb: "Melbourne",
|
|
4609
|
+
state: "VIC",
|
|
4610
|
+
postcode: "3000",
|
|
4611
|
+
country: "AU"
|
|
4612
|
+
};
|
|
4613
|
+
function conformanceCommitmentCheck(answer, secret, verificationId, index, name) {
|
|
4614
|
+
if (answer === void 0 || answer === null) return "absent";
|
|
4615
|
+
if (!isWellFormedCommitment(answer)) return "mismatch";
|
|
4616
|
+
const expected = import_node_crypto2.default.createHmac("sha256", secret).update(verificationCommitmentString(verificationId, index, { name, ...CONFORMANCE_ADDRESS }), "utf8").digest("hex");
|
|
4617
|
+
return import_node_crypto2.default.timingSafeEqual(Buffer.from(answer, "hex"), Buffer.from(expected, "hex")) ? "match" : "mismatch";
|
|
4618
|
+
}
|
|
4619
|
+
async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address", identity, retentionPeriodDays = DEFAULT_RETENTION_DAYS, loaPlan) {
|
|
4309
4620
|
const key = asConformanceKey(publicKeyB64);
|
|
4310
4621
|
const partnerKey = key && {
|
|
4311
4622
|
partner_id: partnerId,
|
|
4312
4623
|
key_id: key.keyId,
|
|
4313
4624
|
public_key_b64: key.publicKeyB64,
|
|
4314
|
-
algorithm: "ECDH-P256-AES-GCM-256"
|
|
4625
|
+
algorithm: key.algorithm ?? "ECDH-P256-AES-GCM-256"
|
|
4315
4626
|
};
|
|
4316
4627
|
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
4317
4628
|
const updateIdNum = conformanceUpdateId();
|
|
@@ -4320,38 +4631,30 @@ async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address",
|
|
|
4320
4631
|
v: 2,
|
|
4321
4632
|
update_uid: updateUid,
|
|
4322
4633
|
dispatch_timestamp: nowIso,
|
|
4323
|
-
|
|
4634
|
+
// The drill name, because the drill LOA names it (it is fixed at the
|
|
4635
|
+
// signer) and a v2 receiver refuses an envelope whose name differs.
|
|
4636
|
+
verified_name: DRILL_LOA_CONSUMER_NAME,
|
|
4324
4637
|
...kind === "address" ? {
|
|
4325
|
-
new_address: {
|
|
4326
|
-
street: "42 Collins Street",
|
|
4327
|
-
suburb: "Melbourne",
|
|
4328
|
-
state: "VIC",
|
|
4329
|
-
postcode: "3000",
|
|
4330
|
-
country: "AU"
|
|
4331
|
-
}
|
|
4638
|
+
new_address: { ...CONFORMANCE_ADDRESS }
|
|
4332
4639
|
} : {},
|
|
4333
4640
|
...kind === "phone" ? { new_phone: "+61412345678" } : {},
|
|
4334
4641
|
...kind === "email" ? { new_email: "conformance@example.com" } : {},
|
|
4335
4642
|
update_types: [kind],
|
|
4336
4643
|
account_number: DEFAULT_ACCOUNT_REF,
|
|
4337
|
-
id_verification_ref:
|
|
4644
|
+
id_verification_ref: import_node_crypto2.default.randomUUID(),
|
|
4338
4645
|
known_names: ["Conformance Tester"],
|
|
4339
4646
|
// Applied last so an override wins over the defaults above, including
|
|
4340
4647
|
// `verified_name`, which is set before the address block.
|
|
4341
4648
|
...identity ?? {}
|
|
4342
4649
|
};
|
|
4343
4650
|
const envelope = partnerKey ? await encryptSessionForPartner(sessionData, partnerKey) : { session_envelope: null, session_key_share: null };
|
|
4344
|
-
const loa = {
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
// placeholder r||s hex (128 chars)
|
|
4352
|
-
signature_algorithm: "ECDSA-P256"
|
|
4353
|
-
};
|
|
4354
|
-
const loaEnvelope = partnerKey ? await encryptEnvelopeForPartner(loa, partnerKey) : null;
|
|
4651
|
+
const loa = partnerKey && envelope.session_envelope ? await drillLoaFor({
|
|
4652
|
+
updateUid,
|
|
4653
|
+
partnerId,
|
|
4654
|
+
envelopeSha256: import_node_crypto2.default.createHash("sha256").update(loaV2EnvelopeDigestInput(envelope.session_envelope), "utf8").digest("hex"),
|
|
4655
|
+
typedAliases: sessionData.known_names ?? []
|
|
4656
|
+
}, nowIso, loaPlan) : null;
|
|
4657
|
+
const loaEnvelope = partnerKey && loa ? await encryptEnvelopeForPartner(loa, partnerKey) : null;
|
|
4355
4658
|
return JSON.stringify({
|
|
4356
4659
|
// Body event and `X-OneAddress-Event` must agree — the relay derives both
|
|
4357
4660
|
// from the same rule, and a receiver may route on either. An address-
|
|
@@ -4407,9 +4710,7 @@ async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address",
|
|
|
4407
4710
|
session_key_share: loaEnvelope.session_key_share
|
|
4408
4711
|
}
|
|
4409
4712
|
} : {},
|
|
4410
|
-
//
|
|
4411
|
-
// so the KEY is what a receiver sees either way.
|
|
4412
|
-
stripe_session_id: null,
|
|
4713
|
+
// No `stripe_session_id`: the relay stopped sending it on 24 Oct 2026.
|
|
4413
4714
|
/**
|
|
4414
4715
|
* THIS DISPATCH IS A DRILL, AND IT SAYS SO IN THE SIGNED BODY.
|
|
4415
4716
|
*
|
|
@@ -4440,12 +4741,20 @@ async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address",
|
|
|
4440
4741
|
...extraFields
|
|
4441
4742
|
});
|
|
4442
4743
|
}
|
|
4443
|
-
|
|
4744
|
+
function describeFetchError(err) {
|
|
4745
|
+
const cause = err?.cause;
|
|
4746
|
+
const text = `${String(err)} ${cause ? String(cause.message ?? cause) : ""}`;
|
|
4747
|
+
if (/redirect/i.test(text)) {
|
|
4748
|
+
return "the endpoint answered with a redirect (3xx). Conformance does not follow redirects, because OneAddress dispatches do not: point it at the final URL";
|
|
4749
|
+
}
|
|
4750
|
+
return String(err);
|
|
4751
|
+
}
|
|
4752
|
+
async function post(url, body, headers, timeoutMs = 12e3, fetchImpl = fetch) {
|
|
4444
4753
|
const controller = new AbortController();
|
|
4445
4754
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
4446
4755
|
const start = Date.now();
|
|
4447
4756
|
try {
|
|
4448
|
-
const res = await
|
|
4757
|
+
const res = await fetchImpl(url, {
|
|
4449
4758
|
method: "POST",
|
|
4450
4759
|
headers,
|
|
4451
4760
|
body,
|
|
@@ -4455,14 +4764,14 @@ async function post(url, body, headers, timeoutMs = 12e3) {
|
|
|
4455
4764
|
const text = await res.text().catch(() => "");
|
|
4456
4765
|
return { status: res.status, durationMs: Date.now() - start, body: text };
|
|
4457
4766
|
} catch (err) {
|
|
4458
|
-
return { status: 0, durationMs: Date.now() - start, body: "", error:
|
|
4767
|
+
return { status: 0, durationMs: Date.now() - start, body: "", error: describeFetchError(err) };
|
|
4459
4768
|
} finally {
|
|
4460
4769
|
clearTimeout(timer);
|
|
4461
4770
|
}
|
|
4462
4771
|
}
|
|
4463
4772
|
function signPullV2(timestamp, secret, url, method = "GET", body = "") {
|
|
4464
4773
|
const u = new URL(url);
|
|
4465
|
-
return
|
|
4774
|
+
return import_node_crypto2.default.createHmac("sha256", secret).update(`v2.${timestamp}.${method.toUpperCase()}.${u.pathname}${u.search}.${body}`).digest("hex");
|
|
4466
4775
|
}
|
|
4467
4776
|
async function get(url, headers, timeoutMs = 12e3) {
|
|
4468
4777
|
const controller = new AbortController();
|
|
@@ -4480,7 +4789,7 @@ async function get(url, headers, timeoutMs = 12e3) {
|
|
|
4480
4789
|
res.headers.forEach((v, k) => resHdrs.set(k.toLowerCase(), v));
|
|
4481
4790
|
return { status: res.status, headers: resHdrs, body, durationMs: Date.now() - start };
|
|
4482
4791
|
} catch (err) {
|
|
4483
|
-
return { status: 0, headers: /* @__PURE__ */ new Map(), body: "", durationMs: Date.now() - start, error:
|
|
4792
|
+
return { status: 0, headers: /* @__PURE__ */ new Map(), body: "", durationMs: Date.now() - start, error: describeFetchError(err) };
|
|
4484
4793
|
} finally {
|
|
4485
4794
|
clearTimeout(timer);
|
|
4486
4795
|
}
|
|
@@ -4491,10 +4800,14 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4491
4800
|
let acceptedUpdateTypes = [];
|
|
4492
4801
|
let verifiesAccountReference = false;
|
|
4493
4802
|
let supportsKeyCrossover = false;
|
|
4803
|
+
let productLines = [];
|
|
4494
4804
|
let accountRef = DEFAULT_ACCOUNT_REF;
|
|
4495
4805
|
let recipientKey;
|
|
4496
4806
|
let retentionPeriodDays;
|
|
4807
|
+
let loaSigner = null;
|
|
4808
|
+
let targetFetch = fetch;
|
|
4497
4809
|
if (typeof urlOrOptions === "object") {
|
|
4810
|
+
targetFetch = urlOrOptions.fetchImpl ?? fetch;
|
|
4498
4811
|
targetUrl = urlOrOptions.targetUrl;
|
|
4499
4812
|
secret = urlOrOptions.secret ?? TEST_WEBHOOK_SECRET;
|
|
4500
4813
|
partnerId = urlOrOptions.partnerId ?? TEST_PARTNER_ID;
|
|
@@ -4503,22 +4816,30 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4503
4816
|
acceptedUpdateTypes = urlOrOptions.acceptedUpdateTypes ?? [];
|
|
4504
4817
|
verifiesAccountReference = urlOrOptions.verifiesAccountReference === true;
|
|
4505
4818
|
supportsKeyCrossover = urlOrOptions.supportsKeyCrossover === true;
|
|
4819
|
+
productLines = (urlOrOptions.productLines ?? []).slice(0, MAX_PRODUCT_LINES_PROBED);
|
|
4506
4820
|
accountRef = urlOrOptions.accountRef?.trim() || DEFAULT_ACCOUNT_REF;
|
|
4507
4821
|
recipientKey = "key" in urlOrOptions ? urlOrOptions.key ?? null : asConformanceKey(publicKeyB64);
|
|
4508
4822
|
retentionPeriodDays = urlOrOptions.retentionPeriodDays;
|
|
4823
|
+
loaSigner = urlOrOptions.loaSigner ?? null;
|
|
4509
4824
|
} else {
|
|
4510
4825
|
targetUrl = urlOrOptions;
|
|
4511
4826
|
recipientKey = asConformanceKey(publicKeyB64);
|
|
4512
4827
|
}
|
|
4513
4828
|
const results = [];
|
|
4829
|
+
const informational = [];
|
|
4830
|
+
const postTarget = (u, b, h, t) => post(u, b, h, t, targetFetch);
|
|
4831
|
+
const signedLoa = { signer: loaSigner };
|
|
4514
4832
|
const matchable = { account_number: accountRef };
|
|
4515
|
-
const
|
|
4833
|
+
const runId = import_node_crypto2.default.randomUUID().slice(0, 8);
|
|
4834
|
+
const runBase = 1e9 + import_node_crypto2.default.randomInt(0, 1e9);
|
|
4835
|
+
const runDispatch = (n) => String(runBase + n);
|
|
4836
|
+
const sharedBody = await buildBody(partnerId, recipientKey, void 0, "address", matchable, retentionPeriodDays, signedLoa);
|
|
4516
4837
|
let declaration = readAcceptedUpdateKindsFromAck(null);
|
|
4517
4838
|
let check1Accepted;
|
|
4518
4839
|
{
|
|
4519
4840
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4520
4841
|
const sig = sign(sharedBody, ts, secret);
|
|
4521
|
-
const { status, error, body: ackBody } = await
|
|
4842
|
+
const { status, error, body: ackBody } = await postTarget(targetUrl, sharedBody, buildHeaders(partnerId, ts, sig, runDispatch(1)));
|
|
4522
4843
|
const passed = !error && status >= 200 && status < 300;
|
|
4523
4844
|
check1Accepted = passed;
|
|
4524
4845
|
if (passed) declaration = readAcceptedUpdateKindsFromAck(ackBody);
|
|
@@ -4527,14 +4848,14 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4527
4848
|
basis: "acceptance",
|
|
4528
4849
|
label: "Accepts correctly signed webhook",
|
|
4529
4850
|
passed,
|
|
4530
|
-
detail: error ? `Network error: ${error}` : status === 401 ? "HTTP 401, expected 2xx. Your receiver is running and refused our signature, so the
|
|
4851
|
+
detail: error ? `Network error: ${error}` : status === 401 ? "HTTP 401, expected 2xx. Your receiver is running and refused our signature, so the webhook signing secret it holds (WEBHOOK_SECRET in a setup scaffold, OA_WEBHOOK_SECRET in the drop-in receiver, webhookSecret in the SDK) is not the one on this account's Webhook screen. Check it was set up for THIS partner account (its partner id should match yours), then restart it. Every check below depends on this one." : `HTTP ${status} \u2014 expected 2xx`
|
|
4531
4852
|
});
|
|
4532
4853
|
}
|
|
4533
4854
|
{
|
|
4534
4855
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4535
4856
|
const sig = sign(sharedBody, ts, secret);
|
|
4536
4857
|
const badSig = sig.slice(0, -1) + (sig.endsWith("a") ? "b" : "a");
|
|
4537
|
-
const { status, error } = await
|
|
4858
|
+
const { status, error } = await postTarget(targetUrl, sharedBody, buildHeaders(partnerId, ts, badSig, runDispatch(2)));
|
|
4538
4859
|
const passed = !error && status >= 400 && status < 500;
|
|
4539
4860
|
results.push({
|
|
4540
4861
|
id: "check-2",
|
|
@@ -4547,7 +4868,7 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4547
4868
|
{
|
|
4548
4869
|
const staleTs = String(Math.floor(Date.now() / 1e3) - 600);
|
|
4549
4870
|
const staleSig = sign(sharedBody, staleTs, secret);
|
|
4550
|
-
const { status, error } = await
|
|
4871
|
+
const { status, error } = await postTarget(targetUrl, sharedBody, buildHeaders(partnerId, staleTs, staleSig, runDispatch(3)));
|
|
4551
4872
|
const passed = !error && status >= 400 && status < 500;
|
|
4552
4873
|
results.push({
|
|
4553
4874
|
id: "check-3",
|
|
@@ -4560,7 +4881,7 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4560
4881
|
{
|
|
4561
4882
|
const futureTs = String(Math.floor(Date.now() / 1e3) + 600);
|
|
4562
4883
|
const futureSig = sign(sharedBody, futureTs, secret);
|
|
4563
|
-
const { status, error } = await
|
|
4884
|
+
const { status, error } = await postTarget(targetUrl, sharedBody, buildHeaders(partnerId, futureTs, futureSig, runDispatch(4)));
|
|
4564
4885
|
const passed = !error && status >= 400 && status < 500;
|
|
4565
4886
|
results.push({
|
|
4566
4887
|
id: "check-4",
|
|
@@ -4573,7 +4894,7 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4573
4894
|
{
|
|
4574
4895
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4575
4896
|
const sig = sign(sharedBody, ts, secret);
|
|
4576
|
-
const { durationMs, error } = await
|
|
4897
|
+
const { durationMs, error } = await postTarget(targetUrl, sharedBody, buildHeaders(partnerId, ts, sig, runDispatch(5)));
|
|
4577
4898
|
const passed = !error && durationMs < 1e4;
|
|
4578
4899
|
results.push({
|
|
4579
4900
|
id: "check-5",
|
|
@@ -4590,11 +4911,12 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4590
4911
|
{ future_field: "ignored", future_object: { x: 1 } },
|
|
4591
4912
|
"address",
|
|
4592
4913
|
matchable,
|
|
4593
|
-
retentionPeriodDays
|
|
4914
|
+
retentionPeriodDays,
|
|
4915
|
+
signedLoa
|
|
4594
4916
|
);
|
|
4595
4917
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4596
4918
|
const sig = sign(futureBody, ts, secret);
|
|
4597
|
-
const { status, error } = await
|
|
4919
|
+
const { status, error } = await postTarget(targetUrl, futureBody, buildHeaders(partnerId, ts, sig, runDispatch(6)));
|
|
4598
4920
|
const passed = !error && status >= 200 && status < 300;
|
|
4599
4921
|
results.push({
|
|
4600
4922
|
id: "check-6",
|
|
@@ -4613,10 +4935,10 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4613
4935
|
});
|
|
4614
4936
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4615
4937
|
const sig = sign(unknownBody, ts, secret);
|
|
4616
|
-
const { status, error } = await
|
|
4938
|
+
const { status, error } = await postTarget(
|
|
4617
4939
|
targetUrl,
|
|
4618
4940
|
unknownBody,
|
|
4619
|
-
buildHeaders(partnerId, ts, sig,
|
|
4941
|
+
buildHeaders(partnerId, ts, sig, runDispatch(7), "address.future_event")
|
|
4620
4942
|
);
|
|
4621
4943
|
const passed = !error && status >= 200 && status < 300;
|
|
4622
4944
|
results.push({
|
|
@@ -4630,8 +4952,8 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4630
4952
|
{
|
|
4631
4953
|
const ts1 = String(Math.floor(Date.now() / 1e3));
|
|
4632
4954
|
const sig1 = sign(sharedBody, ts1, secret);
|
|
4633
|
-
const dedupId =
|
|
4634
|
-
const { status: s1, error: e1 } = await
|
|
4955
|
+
const dedupId = import_node_crypto2.default.randomUUID().slice(0, 8);
|
|
4956
|
+
const { status: s1, error: e1 } = await postTarget(
|
|
4635
4957
|
targetUrl,
|
|
4636
4958
|
sharedBody,
|
|
4637
4959
|
buildHeaders(partnerId, ts1, sig1, `dedup-${dedupId}`)
|
|
@@ -4639,11 +4961,12 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4639
4961
|
await new Promise((r) => setTimeout(r, 200));
|
|
4640
4962
|
const ts2 = String(Math.floor(Date.now() / 1e3));
|
|
4641
4963
|
const sig2 = sign(sharedBody, ts2, secret);
|
|
4642
|
-
const res2 = await
|
|
4964
|
+
const res2 = await targetFetch(targetUrl, {
|
|
4643
4965
|
redirect: "error",
|
|
4644
4966
|
method: "POST",
|
|
4645
4967
|
headers: buildHeaders(partnerId, ts2, sig2, `dedup-${dedupId}`),
|
|
4646
|
-
body: sharedBody
|
|
4968
|
+
body: sharedBody,
|
|
4969
|
+
signal: AbortSignal.timeout(12e3)
|
|
4647
4970
|
}).catch(() => null);
|
|
4648
4971
|
const s2 = res2?.status ?? 0;
|
|
4649
4972
|
const body2Text = res2 ? await res2.text().catch(() => "") : "";
|
|
@@ -4667,7 +4990,7 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4667
4990
|
const badBody = "this is not { valid json";
|
|
4668
4991
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4669
4992
|
const sig = sign(badBody, ts, secret);
|
|
4670
|
-
const { status, error } = await
|
|
4993
|
+
const { status, error } = await postTarget(targetUrl, badBody, buildHeaders(partnerId, ts, sig, `bad-json-${runId}`));
|
|
4671
4994
|
const passed = !error && status >= 400 && status < 500;
|
|
4672
4995
|
results.push({
|
|
4673
4996
|
id: "check-9",
|
|
@@ -4680,10 +5003,10 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4680
5003
|
{
|
|
4681
5004
|
const nearEdgeTs = String(Math.floor(Date.now() / 1e3) - 295);
|
|
4682
5005
|
const nearEdgeSig = sign(sharedBody, nearEdgeTs, secret);
|
|
4683
|
-
const { status, error } = await
|
|
5006
|
+
const { status, error } = await postTarget(
|
|
4684
5007
|
targetUrl,
|
|
4685
5008
|
sharedBody,
|
|
4686
|
-
buildHeaders(partnerId, nearEdgeTs, nearEdgeSig,
|
|
5009
|
+
buildHeaders(partnerId, nearEdgeTs, nearEdgeSig, `near-edge-${runId}`)
|
|
4687
5010
|
);
|
|
4688
5011
|
const passed = !error && status >= 200 && status < 300;
|
|
4689
5012
|
results.push({
|
|
@@ -4695,7 +5018,7 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4695
5018
|
});
|
|
4696
5019
|
}
|
|
4697
5020
|
if (recipientKey) {
|
|
4698
|
-
const throwaway =
|
|
5021
|
+
const throwaway = import_node_crypto2.default.generateKeyPairSync("ec", { namedCurve: "prime256v1" });
|
|
4699
5022
|
const foreignKey = throwaway.publicKey.export({ type: "spki", format: "der" }).toString("base64");
|
|
4700
5023
|
const foreignBody = await buildBody(
|
|
4701
5024
|
partnerId,
|
|
@@ -4712,10 +5035,10 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4712
5035
|
);
|
|
4713
5036
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4714
5037
|
const sig = sign(foreignBody, ts, secret);
|
|
4715
|
-
const res = await
|
|
5038
|
+
const res = await targetFetch(targetUrl, {
|
|
4716
5039
|
redirect: "error",
|
|
4717
5040
|
method: "POST",
|
|
4718
|
-
headers: buildHeaders(partnerId, ts, sig, `undecryptable-${
|
|
5041
|
+
headers: buildHeaders(partnerId, ts, sig, `undecryptable-${import_node_crypto2.default.randomUUID().slice(0, 8)}`),
|
|
4719
5042
|
body: foreignBody,
|
|
4720
5043
|
signal: AbortSignal.timeout(12e3)
|
|
4721
5044
|
}).catch(() => null);
|
|
@@ -4735,19 +5058,19 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4735
5058
|
basis: "rejection",
|
|
4736
5059
|
label: "Reports undecryptable payload as a failure (not 200 ok:true)",
|
|
4737
5060
|
passed,
|
|
4738
|
-
detail: !reachable ? "Network error: no response" : passed ? `HTTP ${status}${bodyFailure ? " with ok:false" : ""} \u2014 correctly reported as a failed delivery. This probe is now held by your receiver, which is how the check was passed: it is one undecryptable dispatch, not a fault in your setup. Clear it
|
|
5061
|
+
detail: !reachable ? "Network error: no response" : passed ? `HTTP ${status}${bodyFailure ? " with ok:false" : ""} \u2014 correctly reported as a failed delivery. This probe is now held by your receiver, which is how the check was passed: it is one undecryptable dispatch, not a fault in your setup. Clear it wherever your receiver keeps refused dispatches (on the setup scaffold's dashboard, press [d]).` : `HTTP ${status} without ok:false \u2014 a payload this receiver CANNOT decrypt was reported as delivered. OneAddress will mark it delivered and never retry it. Return a 4xx/5xx, or 200 with { ok: false }, when decryption fails.`
|
|
4739
5062
|
});
|
|
4740
5063
|
}
|
|
4741
5064
|
if (verifiesAccountReference && recipientKey) {
|
|
4742
|
-
const nonce =
|
|
5065
|
+
const nonce = import_node_crypto2.default.randomUUID();
|
|
4743
5066
|
const body = await buildBody(partnerId, recipientKey, void 0, "address", {
|
|
4744
5067
|
account_number: `CONF-NOSUCH-${nonce}`,
|
|
4745
5068
|
verified_name: `Nomatch ${nonce.slice(0, 8)}`,
|
|
4746
5069
|
known_names: [`Nomatch ${nonce.slice(0, 8)}`]
|
|
4747
|
-
}, retentionPeriodDays);
|
|
5070
|
+
}, retentionPeriodDays, signedLoa);
|
|
4748
5071
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4749
5072
|
const sig = sign(body, ts, secret);
|
|
4750
|
-
const res = await
|
|
5073
|
+
const res = await targetFetch(targetUrl, {
|
|
4751
5074
|
redirect: "error",
|
|
4752
5075
|
method: "POST",
|
|
4753
5076
|
headers: buildHeaders(partnerId, ts, sig, `nomatch-${nonce.slice(0, 8)}`),
|
|
@@ -4786,10 +5109,10 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4786
5109
|
const contactKinds = plan.accept;
|
|
4787
5110
|
for (const kind of contactKinds) {
|
|
4788
5111
|
const article = kind === "email" ? "an" : "a";
|
|
4789
|
-
const body = await buildBody(partnerId, recipientKey, void 0, kind, matchable, retentionPeriodDays);
|
|
5112
|
+
const body = await buildBody(partnerId, recipientKey, void 0, kind, matchable, retentionPeriodDays, signedLoa);
|
|
4790
5113
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4791
5114
|
const sig = sign(body, ts, secret);
|
|
4792
|
-
const res = await
|
|
5115
|
+
const res = await targetFetch(targetUrl, {
|
|
4793
5116
|
redirect: "error",
|
|
4794
5117
|
method: "POST",
|
|
4795
5118
|
// `contact.updated`, matching what the relay now sends for a dispatch
|
|
@@ -4807,7 +5130,7 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4807
5130
|
partnerId,
|
|
4808
5131
|
ts,
|
|
4809
5132
|
sig,
|
|
4810
|
-
`contact-${kind}-${
|
|
5133
|
+
`contact-${kind}-${import_node_crypto2.default.randomUUID().slice(0, 8)}`,
|
|
4811
5134
|
"contact.updated"
|
|
4812
5135
|
),
|
|
4813
5136
|
body,
|
|
@@ -4840,20 +5163,26 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4840
5163
|
});
|
|
4841
5164
|
if (plan.refuse !== null) {
|
|
4842
5165
|
const probe = plan.refuse;
|
|
4843
|
-
const body = await buildBody(partnerId, recipientKey, void 0, probe, matchable, retentionPeriodDays);
|
|
5166
|
+
const body = await buildBody(partnerId, recipientKey, void 0, probe, matchable, retentionPeriodDays, signedLoa);
|
|
4844
5167
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4845
5168
|
const sig = sign(body, ts, secret);
|
|
4846
|
-
const res = await
|
|
5169
|
+
const res = await targetFetch(targetUrl, {
|
|
4847
5170
|
method: "POST",
|
|
4848
5171
|
headers: buildHeaders(
|
|
4849
5172
|
partnerId,
|
|
4850
5173
|
ts,
|
|
4851
5174
|
sig,
|
|
4852
|
-
`refuse-${probe}-${
|
|
5175
|
+
`refuse-${probe}-${import_node_crypto2.default.randomUUID().slice(0, 8)}`,
|
|
4853
5176
|
"contact.updated"
|
|
4854
5177
|
),
|
|
4855
5178
|
body,
|
|
4856
|
-
signal: AbortSignal.timeout(12e3)
|
|
5179
|
+
signal: AbortSignal.timeout(12e3),
|
|
5180
|
+
// Every probe in this file refuses redirects. This one is the signed
|
|
5181
|
+
// body most worth stealing: a receiver that answers 307 would have
|
|
5182
|
+
// fetch re-POST it, signature and all, to whatever host the Location
|
|
5183
|
+
// names, including an internal metadata address. Guarded by
|
|
5184
|
+
// fetch-redirect-guard.test.ts.
|
|
5185
|
+
redirect: "error"
|
|
4857
5186
|
}).catch(() => null);
|
|
4858
5187
|
const status = res?.status ?? 0;
|
|
4859
5188
|
if (res) await res.text().catch(() => "");
|
|
@@ -4863,12 +5192,12 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4863
5192
|
basis: "rejection",
|
|
4864
5193
|
label: `Refuses an update kind it did not declare (${probe})`,
|
|
4865
5194
|
passed,
|
|
4866
|
-
detail: res === null ? "Network error: no response" : passed ? `HTTP ${status}, a dispatch carrying an undeclared kind was refused, so nothing it did not promise to handle can be acknowledged and dropped.` : `HTTP ${status}, this receiver ACKNOWLEDGED a dispatch carrying a kind (${probe}) it never declared. That is the silent-loss shape: the consumer is told the update was delivered and the value went nowhere. Refuse it with a 4xx (the SDK answers 422 update_type_not_accepted) so OneAddress retries once you have widened acceptedUpdateTypes.`
|
|
5195
|
+
detail: res === null ? "Network error: no response" : passed ? `HTTP ${status}, a dispatch carrying an undeclared kind was refused, so nothing it did not promise to handle can be acknowledged and dropped.` : status >= 500 ? `HTTP ${status}: the receiver errored on a dispatch carrying a kind (${probe}) it never declared, rather than refusing it. A 5xx is retried as an outage; refuse it with a 4xx (the SDK answers 422 update_type_not_accepted).` : `HTTP ${status}, this receiver ACKNOWLEDGED a dispatch carrying a kind (${probe}) it never declared. That is the silent-loss shape: the consumer is told the update was delivered and the value went nowhere. Refuse it with a 4xx (the SDK answers 422 update_type_not_accepted) so OneAddress retries once you have widened acceptedUpdateTypes.`
|
|
4867
5196
|
});
|
|
4868
5197
|
}
|
|
4869
5198
|
if (supportsKeyCrossover && recipientKey) {
|
|
4870
5199
|
const stagedKeyId = "conformance-crossover-staged";
|
|
4871
|
-
const throwaway =
|
|
5200
|
+
const throwaway = import_node_crypto2.default.generateKeyPairSync("ec", { namedCurve: "prime256v1" });
|
|
4872
5201
|
const foreignKey = throwaway.publicKey.export({ type: "spki", format: "der" }).toString("base64");
|
|
4873
5202
|
const base = JSON.parse(await buildBody(
|
|
4874
5203
|
partnerId,
|
|
@@ -4884,11 +5213,14 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4884
5213
|
const body = JSON.stringify(base);
|
|
4885
5214
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4886
5215
|
const sig = sign(body, ts, secret);
|
|
4887
|
-
const res = await
|
|
5216
|
+
const res = await targetFetch(targetUrl, {
|
|
4888
5217
|
method: "POST",
|
|
4889
|
-
headers: buildHeaders(partnerId, ts, sig, `crossover-${
|
|
5218
|
+
headers: buildHeaders(partnerId, ts, sig, `crossover-${import_node_crypto2.default.randomUUID().slice(0, 8)}`),
|
|
4890
5219
|
body,
|
|
4891
|
-
signal: AbortSignal.timeout(12e3)
|
|
5220
|
+
signal: AbortSignal.timeout(12e3),
|
|
5221
|
+
// Same reason as the refusal probe: a followed 307 re-sends a signed
|
|
5222
|
+
// body to a host nobody declared.
|
|
5223
|
+
redirect: "error"
|
|
4892
5224
|
}).catch(() => null);
|
|
4893
5225
|
const status = res?.status ?? 0;
|
|
4894
5226
|
const bodyText = res ? await res.text().catch(() => "") : "";
|
|
@@ -4908,7 +5240,7 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4908
5240
|
});
|
|
4909
5241
|
}
|
|
4910
5242
|
{
|
|
4911
|
-
const nonce =
|
|
5243
|
+
const nonce = import_node_crypto2.default.randomUUID();
|
|
4912
5244
|
const body = await buildBody(partnerId, recipientKey, {
|
|
4913
5245
|
// `event` IS LOAD-BEARING HERE and setting only the header is the bug this
|
|
4914
5246
|
// check shipped with for one run. `buildBody` defaults the body event to
|
|
@@ -4939,10 +5271,10 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4939
5271
|
// into a real submission, where it would parse and then mismatch.
|
|
4940
5272
|
verified_name: "CONFORMANCE DRILL",
|
|
4941
5273
|
known_names: ["CONFORMANCE DRILL"]
|
|
4942
|
-
});
|
|
5274
|
+
}, retentionPeriodDays, signedLoa);
|
|
4943
5275
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
4944
5276
|
const sig = sign(body, ts, secret);
|
|
4945
|
-
const { status, error, body: ackBody } = await
|
|
5277
|
+
const { status, error, body: ackBody } = await postTarget(
|
|
4946
5278
|
targetUrl,
|
|
4947
5279
|
body,
|
|
4948
5280
|
buildHeaders(partnerId, ts, sig, `conformance-${nonce}-1`, "address.test")
|
|
@@ -4952,17 +5284,118 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
4952
5284
|
parsed = JSON.parse(ackBody);
|
|
4953
5285
|
} catch {
|
|
4954
5286
|
}
|
|
5287
|
+
const commitment = conformanceCommitmentCheck(
|
|
5288
|
+
parsed.commitment,
|
|
5289
|
+
secret,
|
|
5290
|
+
`conformance-${nonce}`,
|
|
5291
|
+
1,
|
|
5292
|
+
"CONFORMANCE DRILL"
|
|
5293
|
+
);
|
|
4955
5294
|
const acknowledged = !error && status >= 200 && status < 300;
|
|
4956
|
-
const passed = acknowledged && parsed.verification === true;
|
|
5295
|
+
const passed = acknowledged && parsed.verification === true && commitment !== "mismatch";
|
|
4957
5296
|
const missing = typeof parsed.missing_callback === "string" ? parsed.missing_callback : null;
|
|
4958
5297
|
results.push({
|
|
4959
5298
|
id: "check-16",
|
|
4960
5299
|
basis: "acceptance",
|
|
4961
5300
|
label: "Answers a connection-verification record (address.test)",
|
|
4962
5301
|
passed,
|
|
4963
|
-
detail: error ? `Network error: ${error}` : !acknowledged ? `HTTP ${status} \u2014 expected 2xx. A test record is a real signed, encrypted dispatch; refusing it will fail connection verification.` : missing ? `HTTP ${status}, and your receiver reported no \`${missing}\` callback, so the record was acknowledged and SKIPPED. OneAddress sends five of these before go-live and counts how many you decrypt; with no \`${missing}\` you will score zero while every delivery looks clean. Add \`${missing}\` to createOneAddressHandler.` : parsed.verification === true ? `HTTP ${status}
|
|
5302
|
+
detail: error ? `Network error: ${error}` : !acknowledged ? `HTTP ${status} \u2014 expected 2xx. A test record is a real signed, encrypted dispatch; refusing it will fail connection verification.` : missing ? `HTTP ${status}, and your receiver reported no \`${missing}\` callback, so the record was acknowledged and SKIPPED. OneAddress sends five of these before go-live and counts how many you decrypt; with no \`${missing}\` you will score zero while every delivery looks clean. Add \`${missing}\` to createOneAddressHandler.` : parsed.verification === true && commitment === "mismatch" ? `HTTP ${status}, and the response said it decrypted the record, but its signed answer (\`commitment\`) does not match what was sent. OneAddress refuses that answer when you go live. Check the receiver keys it with the webhook secret that verified the request and builds it from the decrypted name and address, not a formatted copy.` : parsed.verification === true && commitment === "match" ? `HTTP ${status}: verification record decrypted, and its signed answer matches what was sent` : parsed.verification === true ? `HTTP ${status}: verification record decrypted and acknowledged, but with no signed answer (\`commitment\`). Going live will need one: update to the current OneAddress SDK or setup wizard, or, while older receivers are still accepted, ask us to run a connection verification and send back the block it prints.` : `HTTP ${status}, but the response did not carry { verification: true }. OneAddress counts that field as proof you decrypted the record, so without it a working receiver still reads as "decrypted 0 of 5" on the real run. Echo it from your test-record handler.`
|
|
4964
5303
|
});
|
|
4965
5304
|
}
|
|
5305
|
+
if (recipientKey) {
|
|
5306
|
+
const body = await buildBody(partnerId, recipientKey, void 0, "address", {
|
|
5307
|
+
...matchable,
|
|
5308
|
+
x_conformance_unknown: "ignore me"
|
|
5309
|
+
}, retentionPeriodDays, signedLoa);
|
|
5310
|
+
const ts = String(Math.floor(Date.now() / 1e3));
|
|
5311
|
+
const sig = sign(body, ts, secret);
|
|
5312
|
+
const { status, error } = await postTarget(targetUrl, body, buildHeaders(partnerId, ts, sig, `sealed-unknown-${runId}`));
|
|
5313
|
+
const passed = !error && status >= 200 && status < 300;
|
|
5314
|
+
results.push({
|
|
5315
|
+
id: "check-17",
|
|
5316
|
+
basis: "acceptance",
|
|
5317
|
+
label: "Handles an unknown field inside the sealed envelope",
|
|
5318
|
+
passed,
|
|
5319
|
+
detail: error ? `Network error: ${error}` : passed ? `HTTP ${status}: an envelope carrying a field this receiver cannot know was acknowledged` : `HTTP ${status}, expected 2xx. The only difference from check-1 is an extra field inside the decrypted envelope. OneAddress adds optional envelope fields without a version change, so a receiver that refuses unknown fields will start refusing real updates. Ignore fields you do not read.`
|
|
5320
|
+
});
|
|
5321
|
+
}
|
|
5322
|
+
if (recipientKey && productLines.length > 0) {
|
|
5323
|
+
const refused = [];
|
|
5324
|
+
for (const line of productLines) {
|
|
5325
|
+
const body = await buildBody(partnerId, recipientKey, void 0, "address", {
|
|
5326
|
+
...matchable,
|
|
5327
|
+
product: { id: line.id, code: line.code, name: line.name }
|
|
5328
|
+
}, retentionPeriodDays, signedLoa);
|
|
5329
|
+
const ts = String(Math.floor(Date.now() / 1e3));
|
|
5330
|
+
const sig = sign(body, ts, secret);
|
|
5331
|
+
const { status, error } = await postTarget(targetUrl, body, buildHeaders(partnerId, ts, sig, `product-${line.code}-${runId}`));
|
|
5332
|
+
if (error || status < 200 || status >= 300) refused.push(`${line.code} (${error ? `network error: ${error}` : `HTTP ${status}`})`);
|
|
5333
|
+
}
|
|
5334
|
+
const codes = productLines.map((l) => l.code).join(", ");
|
|
5335
|
+
results.push({
|
|
5336
|
+
id: "check-18",
|
|
5337
|
+
basis: "acceptance",
|
|
5338
|
+
label: "Accepts every product line",
|
|
5339
|
+
passed: refused.length === 0,
|
|
5340
|
+
detail: refused.length === 0 ? `Acknowledged an envelope for each product line: ${codes}` : `Not acknowledged: ${refused.join("; ")}. Each envelope matched check-1 apart from its \`product\`, so a receiver that routes on product.code has no route for these codes. Add one, or a default for codes it does not know.`
|
|
5341
|
+
});
|
|
5342
|
+
}
|
|
5343
|
+
if (loaSigner && recipientKey) {
|
|
5344
|
+
const acceptedSignedLoa = check1Accepted;
|
|
5345
|
+
const probes = [
|
|
5346
|
+
{
|
|
5347
|
+
id: "check-loa-forged",
|
|
5348
|
+
mode: "forged",
|
|
5349
|
+
label: "Refuses a consent proof (LOA) whose signature does not verify",
|
|
5350
|
+
what: "a LOA whose signed content was altered after signing"
|
|
5351
|
+
},
|
|
5352
|
+
{
|
|
5353
|
+
id: "check-loa-missing",
|
|
5354
|
+
mode: "omitted",
|
|
5355
|
+
label: "Refuses a dispatch carrying no consent proof (LOA)",
|
|
5356
|
+
what: "a dispatch with no loa_encrypted at all"
|
|
5357
|
+
}
|
|
5358
|
+
];
|
|
5359
|
+
for (const probe of probes) {
|
|
5360
|
+
const body = await buildBody(
|
|
5361
|
+
partnerId,
|
|
5362
|
+
recipientKey,
|
|
5363
|
+
void 0,
|
|
5364
|
+
"address",
|
|
5365
|
+
matchable,
|
|
5366
|
+
retentionPeriodDays,
|
|
5367
|
+
{ signer: loaSigner, mode: probe.mode }
|
|
5368
|
+
);
|
|
5369
|
+
const ts = String(Math.floor(Date.now() / 1e3));
|
|
5370
|
+
const sig = sign(body, ts, secret);
|
|
5371
|
+
const res = await targetFetch(targetUrl, {
|
|
5372
|
+
method: "POST",
|
|
5373
|
+
headers: buildHeaders(partnerId, ts, sig, `${probe.id.slice(6)}-${import_node_crypto2.default.randomUUID().slice(0, 8)}`),
|
|
5374
|
+
body,
|
|
5375
|
+
signal: AbortSignal.timeout(12e3),
|
|
5376
|
+
// Same reason as every probe in this file: a followed 307 re-sends a
|
|
5377
|
+
// signed body to a host nobody declared.
|
|
5378
|
+
redirect: "error"
|
|
5379
|
+
}).catch(() => null);
|
|
5380
|
+
const status = res?.status ?? 0;
|
|
5381
|
+
const bodyText = res ? await res.text().catch(() => "") : "";
|
|
5382
|
+
let parsed = {};
|
|
5383
|
+
try {
|
|
5384
|
+
parsed = JSON.parse(bodyText);
|
|
5385
|
+
} catch {
|
|
5386
|
+
}
|
|
5387
|
+
const refused = res !== null && (status >= 400 || parsed.ok === false);
|
|
5388
|
+
const passed = refused && acceptedSignedLoa;
|
|
5389
|
+
informational.push({
|
|
5390
|
+
id: probe.id,
|
|
5391
|
+
basis: "rejection",
|
|
5392
|
+
informational: true,
|
|
5393
|
+
label: probe.label,
|
|
5394
|
+
passed,
|
|
5395
|
+
detail: res === null ? "Network error: no response. Informational, does not affect go-live." : !acceptedSignedLoa ? `HTTP ${status}. Not proven: check-1, which carried a valid signed LOA, was not accepted, so a refusal here demonstrates nothing. Informational, does not affect go-live.` : refused ? `HTTP ${status}${parsed.ok === false ? " with ok:false" : ""}: ${probe.what} was refused, so this receiver verifies the consent proof before it applies an update.` : `HTTP ${status}: ${probe.what} was ACCEPTED, so this receiver applies updates without verifying OneAddress's consent proof. Informational for now, and it does not affect go-live. @oneaddress/partner-sdk 2.8.0 and later verify it by default; on an earlier version set loaPublicKeyPem (from fetchLoaPublicKey, or /.well-known/oneaddress-loa-key.pem), and remove any requireLoa: false.`
|
|
5396
|
+
});
|
|
5397
|
+
}
|
|
5398
|
+
}
|
|
4966
5399
|
if (customerUrl) {
|
|
4967
5400
|
const pullBase = customerUrl.replace(/\/$/, "");
|
|
4968
5401
|
{
|
|
@@ -5004,7 +5437,7 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
5004
5437
|
if (!resSig || !resTs) {
|
|
5005
5438
|
detail = `Response missing X-OneAddress-Signature or X-OneAddress-Timestamp headers`;
|
|
5006
5439
|
} else {
|
|
5007
|
-
const expected =
|
|
5440
|
+
const expected = import_node_crypto2.default.createHmac("sha256", secret).update(`${resTs}.${resBody}`).digest("hex");
|
|
5008
5441
|
if (resSig === expected) {
|
|
5009
5442
|
passed = true;
|
|
5010
5443
|
detail = `HTTP 200, response signature verified`;
|
|
@@ -5022,8 +5455,20 @@ async function runChecksDetailed(urlOrOptions, secret = TEST_WEBHOOK_SECRET, par
|
|
|
5022
5455
|
});
|
|
5023
5456
|
}
|
|
5024
5457
|
}
|
|
5025
|
-
|
|
5458
|
+
const checks = markUnprovenChecks(loaSigner ? results : annotateUnsignedLoa(results));
|
|
5459
|
+
return { checks, declaration, informational, loaSigned: loaSigner !== null };
|
|
5460
|
+
}
|
|
5461
|
+
var LOA_BEARING_ACCEPTANCE = /* @__PURE__ */ new Set(["check-1", "check-6", "check-8", "check-10", "check-16", "check-17", "check-18"]);
|
|
5462
|
+
function annotateUnsignedLoa(results) {
|
|
5463
|
+
return results.map((r) => {
|
|
5464
|
+
if (r.passed) return r;
|
|
5465
|
+
if (!LOA_BEARING_ACCEPTANCE.has(r.id) && !r.id.startsWith("check-contact-")) return r;
|
|
5466
|
+
return { ...r, detail: `${r.detail}
|
|
5467
|
+
|
|
5468
|
+
${UNSIGNED_LOA_NOTE}` };
|
|
5469
|
+
});
|
|
5026
5470
|
}
|
|
5471
|
+
var UNSIGNED_LOA_NOTE = "THIS DRILL'S CONSENT PROOF (LOA) WAS UNSIGNED. If your receiver verifies LOAs (the default since @oneaddress/partner-sdk 2.8.0, and the drop-in receiver's OA_REQUIRE_LOA=1), it is RIGHT to refuse this: the CLI cannot sign with OneAddress's key. Either pass --loa-signing-key <file> with a P-256 test key whose public half your receiver is configured with for this run, or run the go-live check in the partner portal, which sends a LOA signed by OneAddress. Do not turn verification off to pass.";
|
|
5027
5472
|
async function runChecks(urlOrOptions, secret, partnerId, publicKeyB64) {
|
|
5028
5473
|
const run = typeof urlOrOptions === "string" ? await runChecksDetailed(
|
|
5029
5474
|
urlOrOptions,
|
|
@@ -5051,10 +5496,21 @@ function markUnprovenChecks(results) {
|
|
|
5051
5496
|
}
|
|
5052
5497
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5053
5498
|
0 && (module.exports = {
|
|
5499
|
+
CONFORMANCE_ADDRESS,
|
|
5054
5500
|
DEFAULT_ACCOUNT_REF,
|
|
5055
5501
|
DEFAULT_CONFORMANCE_KEY_ID,
|
|
5502
|
+
LoaSignerError,
|
|
5503
|
+
MAX_PRODUCT_LINES_PROBED,
|
|
5504
|
+
UNSIGNED_LOA_NOTE,
|
|
5505
|
+
annotateUnsignedLoa,
|
|
5056
5506
|
asConformanceKey,
|
|
5057
5507
|
buildBody,
|
|
5508
|
+
conformanceCommitmentCheck,
|
|
5509
|
+
describeFetchError,
|
|
5510
|
+
drillLoa,
|
|
5511
|
+
drillLoaV1Canonical,
|
|
5512
|
+
drillLoaV2Canonical,
|
|
5513
|
+
localDrillLoaSigner,
|
|
5058
5514
|
markUnprovenChecks,
|
|
5059
5515
|
plannedCoreCheckIds,
|
|
5060
5516
|
runChecks,
|