@oneaddress/conformance 3.0.0 → 3.1.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/dist/index.js +78 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3333,6 +3333,24 @@ var D5_BODY_ALL_ALLOWED = [
|
|
|
3333
3333
|
...D5_BODY_DRILL_ONLY
|
|
3334
3334
|
];
|
|
3335
3335
|
|
|
3336
|
+
// ../protocol/src/retention.ts
|
|
3337
|
+
var MIN_RETENTION_DAYS = 14;
|
|
3338
|
+
var MAX_RETENTION_DAYS = 365;
|
|
3339
|
+
var DEFAULT_RETENTION_DAYS = 90;
|
|
3340
|
+
function resolveRetentionDays(retentionPeriodDays) {
|
|
3341
|
+
if (typeof retentionPeriodDays !== "number" || !Number.isFinite(retentionPeriodDays)) {
|
|
3342
|
+
return DEFAULT_RETENTION_DAYS;
|
|
3343
|
+
}
|
|
3344
|
+
const days = Math.trunc(retentionPeriodDays);
|
|
3345
|
+
if (days < MIN_RETENTION_DAYS || days > MAX_RETENTION_DAYS) return DEFAULT_RETENTION_DAYS;
|
|
3346
|
+
return days;
|
|
3347
|
+
}
|
|
3348
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
3349
|
+
function keyShareExpiryIso(dispatchAt, retentionPeriodDays) {
|
|
3350
|
+
const days = resolveRetentionDays(retentionPeriodDays);
|
|
3351
|
+
return new Date(dispatchAt.getTime() + days * DAY_MS).toISOString();
|
|
3352
|
+
}
|
|
3353
|
+
|
|
3336
3354
|
// src/credentials.ts
|
|
3337
3355
|
var TEST_WEBHOOK_SECRET = (
|
|
3338
3356
|
// NOSONAR — intentional test credential, not a real secret
|
|
@@ -3361,7 +3379,7 @@ var CONFORMANCE_USER_ID = "conformance:drill";
|
|
|
3361
3379
|
function conformanceUpdateId() {
|
|
3362
3380
|
return import_node_crypto.default.randomInt(9e8, 901e6);
|
|
3363
3381
|
}
|
|
3364
|
-
async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address", identity) {
|
|
3382
|
+
async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address", identity, retentionPeriodDays = DEFAULT_RETENTION_DAYS) {
|
|
3365
3383
|
const partnerKey = {
|
|
3366
3384
|
partner_id: partnerId,
|
|
3367
3385
|
key_id: "conformance-key-1",
|
|
@@ -3444,7 +3462,9 @@ async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address",
|
|
|
3444
3462
|
// D5 per-partner encrypted address envelope (identity is INSIDE it).
|
|
3445
3463
|
session_envelope: envelope.session_envelope,
|
|
3446
3464
|
session_key_share: envelope.session_key_share,
|
|
3447
|
-
|
|
3465
|
+
// Derived from the same resolver the relay uses, so this is the recipient's
|
|
3466
|
+
// horizon rather than a constant. Was hard-coded to 90 days.
|
|
3467
|
+
key_share_expiry: keyShareExpiryIso(/* @__PURE__ */ new Date(), retentionPeriodDays),
|
|
3448
3468
|
id_verification: {
|
|
3449
3469
|
method: "identity_document",
|
|
3450
3470
|
verified_at: nowIso,
|
|
@@ -3926,6 +3946,62 @@ async function runChecks(urlOrOptions, secret = TEST_WEBHOOK_SECRET, partnerId =
|
|
|
3926
3946
|
detail: !reachable ? "Network error: no response" : passed ? `HTTP ${status} with crossover:true \u2014 a copy sealed to a rotation sibling key was correctly skip-acked; the copy sealed to a held key carries the update` : `HTTP ${status} \u2014 a copy naming one of this receiver's keys as a crossover sibling was not skip-acked. During a key rotation a copy sealed to your OTHER key must be skipped (a decryptable sibling copy is coming), signalled with { ok: true, skipped: true, crossover: true }. A 500 here drops one copy of a live update; a bare 200 ok:true without crossover:true is check-11's silent-loss shape. Configure your handler's key_id (or key store) so it recognises the marker, or clear "supports key crossover" until you have.`
|
|
3927
3947
|
});
|
|
3928
3948
|
}
|
|
3949
|
+
{
|
|
3950
|
+
const nonce = import_node_crypto.default.randomUUID();
|
|
3951
|
+
const body = await buildBody(partnerId, publicKeyB64, {
|
|
3952
|
+
// `event` IS LOAD-BEARING HERE and setting only the header is the bug this
|
|
3953
|
+
// check shipped with for one run. `buildBody` defaults the body event to
|
|
3954
|
+
// `address.updated`, and both the SDK and the drop-in receiver route on the
|
|
3955
|
+
// BODY, not on `X-OneAddress-Event`. With the header alone our own
|
|
3956
|
+
// reference receiver treated the record as an ordinary update, answered
|
|
3957
|
+
// `{ ok: true }`, and failed its own conformance self-test — which is
|
|
3958
|
+
// precisely the signal this check is supposed to produce for a receiver
|
|
3959
|
+
// that never handled test records. Caught by
|
|
3960
|
+
// `packages/receiver/src/conformance-self.test.ts`.
|
|
3961
|
+
//
|
|
3962
|
+
// `extraFields` is spread last, so this wins, and the two now agree as the
|
|
3963
|
+
// builder's own comment requires.
|
|
3964
|
+
event: "address.test",
|
|
3965
|
+
verification_id: `conformance-${nonce}`,
|
|
3966
|
+
index: 1,
|
|
3967
|
+
total: 1
|
|
3968
|
+
}, "address", {
|
|
3969
|
+
// `...matchable` FIRST, and it is not optional: it carries the account
|
|
3970
|
+
// reference the operator supplied, and `account-ref.test.ts` fails any
|
|
3971
|
+
// probe meant to MATCH that falls back to DEFAULT_ACCOUNT_REF. It caught
|
|
3972
|
+
// exactly that here. A verification record IS meant to match: the whole
|
|
3973
|
+
// point is that the receiver decrypts it and finds something it can place.
|
|
3974
|
+
...matchable,
|
|
3975
|
+
// Deliberately self-describing. The drop-in receiver PRINTS a verification
|
|
3976
|
+
// line for this record, so it lands in the partner's own stdout beside the
|
|
3977
|
+
// real ones. A name that says what it is stops a drill line being pasted
|
|
3978
|
+
// into a real submission, where it would parse and then mismatch.
|
|
3979
|
+
verified_name: "CONFORMANCE DRILL",
|
|
3980
|
+
known_names: ["CONFORMANCE DRILL"]
|
|
3981
|
+
});
|
|
3982
|
+
const ts = String(Math.floor(Date.now() / 1e3));
|
|
3983
|
+
const sig = sign(body, ts, secret);
|
|
3984
|
+
const { status, error, body: ackBody } = await post(
|
|
3985
|
+
targetUrl,
|
|
3986
|
+
body,
|
|
3987
|
+
buildHeaders(partnerId, ts, sig, `conformance-${nonce}-1`, "address.test")
|
|
3988
|
+
);
|
|
3989
|
+
let parsed = {};
|
|
3990
|
+
try {
|
|
3991
|
+
parsed = JSON.parse(ackBody);
|
|
3992
|
+
} catch {
|
|
3993
|
+
}
|
|
3994
|
+
const acknowledged = !error && status >= 200 && status < 300;
|
|
3995
|
+
const passed = acknowledged && parsed.verification === true;
|
|
3996
|
+
const missing = typeof parsed.missing_callback === "string" ? parsed.missing_callback : null;
|
|
3997
|
+
results.push({
|
|
3998
|
+
id: "check-16",
|
|
3999
|
+
basis: "acceptance",
|
|
4000
|
+
label: "Answers a connection-verification record (address.test)",
|
|
4001
|
+
passed,
|
|
4002
|
+
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} \u2014 verification record decrypted and acknowledged` : `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.`
|
|
4003
|
+
});
|
|
4004
|
+
}
|
|
3929
4005
|
if (customerUrl) {
|
|
3930
4006
|
const pullBase = customerUrl.replace(/\/$/, "");
|
|
3931
4007
|
{
|