@oneaddress/conformance 2.1.0 → 3.0.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 +24 -3
- package/dist/index.js +216 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,17 +77,38 @@ oneaddress-conformance test https://api.mycompany.com/oneaddress \
|
|
|
77
77
|
oneaddress-conformance test https://api.mycompany.com/oneaddress \
|
|
78
78
|
--secret whsec_xxx \
|
|
79
79
|
--partner-id aaa... \
|
|
80
|
+
--public-key <base64-SPKI-of-your-ECDH-public-key> \
|
|
80
81
|
--customer-url https://oneaddress.io
|
|
81
82
|
```
|
|
82
83
|
|
|
84
|
+
**All three credentials, or none.** A partial set is refused, and the refusal is
|
|
85
|
+
the point: supplying only the secret makes every signature check pass while the
|
|
86
|
+
payload stays sealed to this suite's built-in test key, so the failures land on
|
|
87
|
+
the acceptance checks and read as a decrypt fault in your receiver. Supplying
|
|
88
|
+
none is correct against a `npx @oneaddress/setup` scaffold, which is built
|
|
89
|
+
around those same test values. `--customer-url` only *adds* checks 9 and 10; the
|
|
90
|
+
webhook checks still encrypt to `--public-key`, which is why it belongs in the
|
|
91
|
+
pull-API example too.
|
|
92
|
+
|
|
93
|
+
The safer way to pass them keeps the secret out of your shell history and out of
|
|
94
|
+
`ps`, where any other process on the box can read it:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
export ONEADDRESS_WEBHOOK_SECRET=whsec_xxx
|
|
98
|
+
export ONEADDRESS_PARTNER_ID=aaa...
|
|
99
|
+
export ONEADDRESS_PUBLIC_KEY=MFkw...
|
|
100
|
+
oneaddress-conformance test https://api.mycompany.com/oneaddress --accept address,phone
|
|
101
|
+
```
|
|
102
|
+
|
|
83
103
|
### Flags
|
|
84
104
|
|
|
85
105
|
| Flag | Default | Purpose |
|
|
86
106
|
|------|---------|---------|
|
|
87
|
-
| `--secret` | Built-in synthetic test secret (used when partner is testing the wizard scaffold) | Your HMAC webhook secret |
|
|
88
|
-
| `--partner-id` | Built-in test UUID | Your partner UUID |
|
|
89
|
-
| `--public-key` | Built-in test ECDH SPKI | Your ECDH P-256 public key, base64 SPKI |
|
|
107
|
+
| `--secret` | Built-in synthetic test secret (used when partner is testing the wizard scaffold) | Your HMAC webhook secret. Also `ONEADDRESS_WEBHOOK_SECRET`. **Give all three of these or none** — a partial set is refused |
|
|
108
|
+
| `--partner-id` | Built-in test UUID | Your partner UUID. Also `ONEADDRESS_PARTNER_ID` |
|
|
109
|
+
| `--public-key` | Built-in test ECDH SPKI | Your ECDH P-256 public key, base64 SPKI. Also `ONEADDRESS_PUBLIC_KEY` |
|
|
90
110
|
| `--customer-url` | — | Customer-app base URL; when set, adds pull-API checks |
|
|
111
|
+
| `--account-ref` | `CONF-0001` | The account reference every matching probe carries. Also `ONEADDRESS_ACCOUNT_REF`. Matters only if your receiver matches dispatches to your own customer records: it holds no `CONF-0001`, so it answers `no_match` — correctly — and the run cannot go green however good it is. Point this at a customer you already hold rather than writing test data into your system of record. The no-match probe does **not** derive from it; it sends `CONF-NOSUCH-<nonce>`, which cannot exist whatever you configure here |
|
|
91
112
|
| `--accept` | `address` | Comma-separated update kinds you accept in the partner portal (`address,phone,email`). Adds one contact probe per kind and is compared against what your receiver declares. Match it to the portal: the portal governs what OneAddress sends, this governs what gets tested. |
|
|
92
113
|
|
|
93
114
|
## Exit codes
|
package/dist/index.js
CHANGED
|
@@ -3294,6 +3294,45 @@ function kindProbePlan(declaration, acceptedInPortal) {
|
|
|
3294
3294
|
return { accept, refuse: undeclared ?? UNDEFINED_PROBE_KIND, consentBeyondDeclaration };
|
|
3295
3295
|
}
|
|
3296
3296
|
|
|
3297
|
+
// ../protocol/src/d5-body.ts
|
|
3298
|
+
var D5_BODY_ALWAYS = [
|
|
3299
|
+
"event",
|
|
3300
|
+
"id_verification",
|
|
3301
|
+
"key_share_expiry",
|
|
3302
|
+
"oneaddress_version",
|
|
3303
|
+
"partner_id",
|
|
3304
|
+
"session_envelope",
|
|
3305
|
+
"session_key_share",
|
|
3306
|
+
"stripe_session_id",
|
|
3307
|
+
"timestamp",
|
|
3308
|
+
"update_id",
|
|
3309
|
+
"user_id"
|
|
3310
|
+
];
|
|
3311
|
+
var D5_BODY_CONDITIONAL = {
|
|
3312
|
+
/**
|
|
3313
|
+
* The signed Letter of Authority, sealed to the same key_id as the session.
|
|
3314
|
+
* Present whenever the partner has a usable key — i.e. on every dispatch a
|
|
3315
|
+
* live partner receives. Omitted best-effort when no key is available, which
|
|
3316
|
+
* is a state a live partner is never in.
|
|
3317
|
+
*/
|
|
3318
|
+
loa_encrypted: "partner has a usable encryption key",
|
|
3319
|
+
/**
|
|
3320
|
+
* The shared webhook event id. Set ONLY on a key-crossover copy, where every
|
|
3321
|
+
* copy of one update carries the same id so a receiver holding more than one
|
|
3322
|
+
* rotation key applies it once. Absent on an ordinary dispatch, whose
|
|
3323
|
+
* receiver idempotency falls back to the `X-OneAddress-Dispatch` header.
|
|
3324
|
+
*/
|
|
3325
|
+
id: "key-crossover copy only",
|
|
3326
|
+
/** The sibling marker naming the other key_ids this update was sealed to. */
|
|
3327
|
+
crossover_key_ids: "key-crossover copy only"
|
|
3328
|
+
};
|
|
3329
|
+
var D5_BODY_DRILL_ONLY = ["conformance"];
|
|
3330
|
+
var D5_BODY_ALL_ALLOWED = [
|
|
3331
|
+
...D5_BODY_ALWAYS,
|
|
3332
|
+
...Object.keys(D5_BODY_CONDITIONAL),
|
|
3333
|
+
...D5_BODY_DRILL_ONLY
|
|
3334
|
+
];
|
|
3335
|
+
|
|
3297
3336
|
// src/credentials.ts
|
|
3298
3337
|
var TEST_WEBHOOK_SECRET = (
|
|
3299
3338
|
// NOSONAR — intentional test credential, not a real secret
|
|
@@ -3317,6 +3356,11 @@ function buildHeaders(partnerId, timestamp, signature, dispatchId, event = "addr
|
|
|
3317
3356
|
"X-OneAddress-Dispatch": dispatchId
|
|
3318
3357
|
};
|
|
3319
3358
|
}
|
|
3359
|
+
var DEFAULT_ACCOUNT_REF = "CONF-0001";
|
|
3360
|
+
var CONFORMANCE_USER_ID = "conformance:drill";
|
|
3361
|
+
function conformanceUpdateId() {
|
|
3362
|
+
return import_node_crypto.default.randomInt(9e8, 901e6);
|
|
3363
|
+
}
|
|
3320
3364
|
async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address", identity) {
|
|
3321
3365
|
const partnerKey = {
|
|
3322
3366
|
partner_id: partnerId,
|
|
@@ -3325,7 +3369,8 @@ async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address",
|
|
|
3325
3369
|
algorithm: "ECDH-P256-AES-GCM-256"
|
|
3326
3370
|
};
|
|
3327
3371
|
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
3328
|
-
const
|
|
3372
|
+
const updateIdNum = conformanceUpdateId();
|
|
3373
|
+
const updateUid = String(updateIdNum);
|
|
3329
3374
|
const sessionData = {
|
|
3330
3375
|
v: 2,
|
|
3331
3376
|
update_uid: updateUid,
|
|
@@ -3343,7 +3388,7 @@ async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address",
|
|
|
3343
3388
|
...kind === "phone" ? { new_phone: "+61412345678" } : {},
|
|
3344
3389
|
...kind === "email" ? { new_email: "conformance@example.com" } : {},
|
|
3345
3390
|
update_types: [kind],
|
|
3346
|
-
account_number:
|
|
3391
|
+
account_number: DEFAULT_ACCOUNT_REF,
|
|
3347
3392
|
id_verification_ref: import_node_crypto.default.randomUUID(),
|
|
3348
3393
|
known_names: ["Conformance Tester"],
|
|
3349
3394
|
// Applied last so an override wins over the defaults above, including
|
|
@@ -3368,20 +3413,52 @@ async function buildBody(partnerId, publicKeyB64, extraFields, kind = "address",
|
|
|
3368
3413
|
// bearing dispatch stays `address.updated` for every existing integration.
|
|
3369
3414
|
event: kind === "address" ? "address.updated" : "contact.updated",
|
|
3370
3415
|
oneaddress_version: CURRENT_VERSION,
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3416
|
+
/**
|
|
3417
|
+
* ── THIS LIST IS THE D5 CONTRACT (`D5_BODY_ALWAYS`), NOT AN APPROXIMATION ─
|
|
3418
|
+
*
|
|
3419
|
+
* Measured on 25 Sep 2026 by executing this builder beside the relay's own
|
|
3420
|
+
* `composeD5OutgoingPayload`, it sent `version`, `id` and
|
|
3421
|
+
* `encryption_status`, which no D5 dispatch carries; omitted `user_id`,
|
|
3422
|
+
* `key_share_expiry`, `id_verification` and `stripe_session_id`, which every
|
|
3423
|
+
* one carries; sent `update_id` as a UUID where the relay sends the integer
|
|
3424
|
+
* `user_updates.id`; and sent `timestamp` as Unix-epoch seconds where the
|
|
3425
|
+
* relay sends ISO 8601 — the header's format, in the body, which is how the
|
|
3426
|
+
* mistake happened.
|
|
3427
|
+
*
|
|
3428
|
+
* Three of those fail in the silent direction. A receiver gated on
|
|
3429
|
+
* `encryption_status === 'encrypted'`, pinned to `body.version`, or keyed
|
|
3430
|
+
* for idempotency on `body.id` passed this suite and would then have
|
|
3431
|
+
* dropped — or double-written — every real update.
|
|
3432
|
+
*
|
|
3433
|
+
* `src/__tests__/body-contract.test.ts` executes this function and compares
|
|
3434
|
+
* it against `@oneaddress/protocol`'s lists; the customer app executes the
|
|
3435
|
+
* RELAY against the same lists. Neither half can bless a drift on its own.
|
|
3436
|
+
*/
|
|
3437
|
+
update_id: updateIdNum,
|
|
3375
3438
|
partner_id: partnerId,
|
|
3439
|
+
// Real on every dispatch. A drill has no consumer, so it announces itself
|
|
3440
|
+
// under a reserved subject rather than omitting the key and teaching a
|
|
3441
|
+
// receiver that the field is optional.
|
|
3442
|
+
user_id: CONFORMANCE_USER_ID,
|
|
3443
|
+
timestamp: nowIso,
|
|
3376
3444
|
// D5 per-partner encrypted address envelope (identity is INSIDE it).
|
|
3377
3445
|
session_envelope: envelope.session_envelope,
|
|
3378
3446
|
session_key_share: envelope.session_key_share,
|
|
3447
|
+
key_share_expiry: new Date(Date.now() + 90 * 24 * 60 * 60 * 1e3).toISOString(),
|
|
3448
|
+
id_verification: {
|
|
3449
|
+
method: "identity_document",
|
|
3450
|
+
verified_at: nowIso,
|
|
3451
|
+
verified: true,
|
|
3452
|
+
platform: "oneaddress/v1"
|
|
3453
|
+
},
|
|
3379
3454
|
// D5 per-partner encrypted signed LOA. No cleartext letter_of_authority.
|
|
3380
3455
|
loa_encrypted: {
|
|
3381
3456
|
session_envelope: loaEnvelope.session_envelope,
|
|
3382
3457
|
session_key_share: loaEnvelope.session_key_share
|
|
3383
3458
|
},
|
|
3384
|
-
|
|
3459
|
+
// On the wire with a `null` value when no PaymentIntent backed the update,
|
|
3460
|
+
// so the KEY is what a receiver sees either way.
|
|
3461
|
+
stripe_session_id: null,
|
|
3385
3462
|
/**
|
|
3386
3463
|
* THIS DISPATCH IS A DRILL, AND IT SAYS SO IN THE SIGNED BODY.
|
|
3387
3464
|
*
|
|
@@ -3462,6 +3539,7 @@ async function runChecks(urlOrOptions, secret = TEST_WEBHOOK_SECRET, partnerId =
|
|
|
3462
3539
|
let acceptedUpdateTypes = [];
|
|
3463
3540
|
let verifiesAccountReference = false;
|
|
3464
3541
|
let supportsKeyCrossover = false;
|
|
3542
|
+
let accountRef = DEFAULT_ACCOUNT_REF;
|
|
3465
3543
|
if (typeof urlOrOptions === "object") {
|
|
3466
3544
|
targetUrl = urlOrOptions.targetUrl;
|
|
3467
3545
|
secret = urlOrOptions.secret ?? TEST_WEBHOOK_SECRET;
|
|
@@ -3471,11 +3549,13 @@ async function runChecks(urlOrOptions, secret = TEST_WEBHOOK_SECRET, partnerId =
|
|
|
3471
3549
|
acceptedUpdateTypes = urlOrOptions.acceptedUpdateTypes ?? [];
|
|
3472
3550
|
verifiesAccountReference = urlOrOptions.verifiesAccountReference === true;
|
|
3473
3551
|
supportsKeyCrossover = urlOrOptions.supportsKeyCrossover === true;
|
|
3552
|
+
accountRef = urlOrOptions.accountRef?.trim() || DEFAULT_ACCOUNT_REF;
|
|
3474
3553
|
} else {
|
|
3475
3554
|
targetUrl = urlOrOptions;
|
|
3476
3555
|
}
|
|
3477
3556
|
const results = [];
|
|
3478
|
-
const
|
|
3557
|
+
const matchable = { account_number: accountRef };
|
|
3558
|
+
const sharedBody = await buildBody(partnerId, publicKeyB64, void 0, "address", matchable);
|
|
3479
3559
|
let declaration = readAcceptedUpdateKindsFromAck(null);
|
|
3480
3560
|
let check1Accepted;
|
|
3481
3561
|
{
|
|
@@ -3547,7 +3627,13 @@ async function runChecks(urlOrOptions, secret = TEST_WEBHOOK_SECRET, partnerId =
|
|
|
3547
3627
|
});
|
|
3548
3628
|
}
|
|
3549
3629
|
{
|
|
3550
|
-
const futureBody = await buildBody(
|
|
3630
|
+
const futureBody = await buildBody(
|
|
3631
|
+
partnerId,
|
|
3632
|
+
publicKeyB64,
|
|
3633
|
+
{ future_field: "ignored", future_object: { x: 1 } },
|
|
3634
|
+
"address",
|
|
3635
|
+
matchable
|
|
3636
|
+
);
|
|
3551
3637
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
3552
3638
|
const sig = sign(futureBody, ts, secret);
|
|
3553
3639
|
const { status, error } = await post(targetUrl, futureBody, buildHeaders(partnerId, ts, sig, "6"));
|
|
@@ -3564,9 +3650,7 @@ async function runChecks(urlOrOptions, secret = TEST_WEBHOOK_SECRET, partnerId =
|
|
|
3564
3650
|
const unknownBody = JSON.stringify({
|
|
3565
3651
|
event: "address.future_event",
|
|
3566
3652
|
oneaddress_version: CURRENT_VERSION,
|
|
3567
|
-
|
|
3568
|
-
id: import_node_crypto.default.randomUUID(),
|
|
3569
|
-
timestamp: String(Math.floor(Date.now() / 1e3)),
|
|
3653
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3570
3654
|
partner_id: partnerId
|
|
3571
3655
|
});
|
|
3572
3656
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
@@ -3712,7 +3796,9 @@ async function runChecks(urlOrOptions, secret = TEST_WEBHOOK_SECRET, partnerId =
|
|
|
3712
3796
|
basis: "rejection",
|
|
3713
3797
|
label: "Refuses an account reference that matches no record (no name fallback)",
|
|
3714
3798
|
passed,
|
|
3715
|
-
detail: !reachable ? "Network error: no response" : passed ? `HTTP ${status}${parsed.ok === false ? " with ok:false" : ""} \u2014 an unmatchable account reference was not reported as applied` : `HTTP ${status} with ok:true \u2014 an account reference matching NO record was reported as successfully applied. If your matching falls back to the customer's NAME when the account number misses, you will write one customer's address onto another customer's record. An account number that matches nothing must be a hard no-match: do not fall back to name, and do not accept a matching account number whose name disagrees with that record. Answer the webhook with ok:false so the consumer is told, which is what they were promised before they paid, and confirm the dispatch as "no_match" rather than "failed": "failed" means YOUR system broke and makes the update refundable at your expense, while "no_match" says the person is simply not on your books. This check reads the webhook response only, so it cannot see which status you send; getting it wrong costs you money rather than failing here
|
|
3799
|
+
detail: !reachable ? "Network error: no response" : passed ? `HTTP ${status}${parsed.ok === false ? " with ok:false" : ""} \u2014 an unmatchable account reference was not reported as applied` : `HTTP ${status} with ok:true \u2014 an account reference matching NO record was reported as successfully applied. If your matching falls back to the customer's NAME when the account number misses, you will write one customer's address onto another customer's record. An account number that matches nothing must be a hard no-match: do not fall back to name, and do not accept a matching account number whose name disagrees with that record. Answer the webhook with ok:false so the consumer is told, which is what they were promised before they paid, and confirm the dispatch as "no_match" rather than "failed": "failed" means YOUR system broke and makes the update refundable at your expense, while "no_match" says the person is simply not on your books. This check reads the webhook response only, so it cannot see which status you send; getting it wrong costs you money rather than failing here.
|
|
3800
|
+
|
|
3801
|
+
THERE IS A SECOND READING, and it is the likelier one on a first run: if this receiver does not match dispatches to customer records AT ALL \u2014 no lookup configured, it just queues what arrives \u2014 then the FLAG is wrong, not the receiver. This check asks a question only a matching receiver can answer, so drop --verifies-account-reference (and untick the same declaration in your partner portal, so the two agree) and run again. Nothing out here can tell the two apart: both look like ok:true to an unmatchable reference.`
|
|
3716
3802
|
});
|
|
3717
3803
|
}
|
|
3718
3804
|
const plan = kindProbePlan(declaration, acceptedUpdateTypes);
|
|
@@ -3727,7 +3813,7 @@ async function runChecks(urlOrOptions, secret = TEST_WEBHOOK_SECRET, partnerId =
|
|
|
3727
3813
|
const contactKinds = plan.accept;
|
|
3728
3814
|
for (const kind of contactKinds) {
|
|
3729
3815
|
const article = kind === "email" ? "an" : "a";
|
|
3730
|
-
const body = await buildBody(partnerId, publicKeyB64, void 0, kind);
|
|
3816
|
+
const body = await buildBody(partnerId, publicKeyB64, void 0, kind, matchable);
|
|
3731
3817
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
3732
3818
|
const sig = sign(body, ts, secret);
|
|
3733
3819
|
const res = await fetch(targetUrl, {
|
|
@@ -3780,7 +3866,7 @@ async function runChecks(urlOrOptions, secret = TEST_WEBHOOK_SECRET, partnerId =
|
|
|
3780
3866
|
});
|
|
3781
3867
|
if (plan.refuse !== null) {
|
|
3782
3868
|
const probe = plan.refuse;
|
|
3783
|
-
const body = await buildBody(partnerId, publicKeyB64, void 0, probe);
|
|
3869
|
+
const body = await buildBody(partnerId, publicKeyB64, void 0, probe, matchable);
|
|
3784
3870
|
const ts = String(Math.floor(Date.now() / 1e3));
|
|
3785
3871
|
const sig = sign(body, ts, secret);
|
|
3786
3872
|
const res = await fetch(targetUrl, {
|
|
@@ -3975,6 +4061,12 @@ function exitCode(results) {
|
|
|
3975
4061
|
}
|
|
3976
4062
|
|
|
3977
4063
|
// src/resolve-credentials.ts
|
|
4064
|
+
var import_node_crypto2 = require("crypto");
|
|
4065
|
+
var FLAG_FOR = {
|
|
4066
|
+
ONEADDRESS_WEBHOOK_SECRET: "--secret",
|
|
4067
|
+
ONEADDRESS_PARTNER_ID: "--partner-id",
|
|
4068
|
+
ONEADDRESS_PUBLIC_KEY: "--public-key"
|
|
4069
|
+
};
|
|
3978
4070
|
function resolveOne(flag, envVar, env, fallback) {
|
|
3979
4071
|
if (flag !== void 0 && flag !== "") return { value: flag, source: "flag", envVar };
|
|
3980
4072
|
const fromEnv = env[envVar]?.trim();
|
|
@@ -3997,6 +4089,66 @@ function resolveCredentials(flags, env = process.env) {
|
|
|
3997
4089
|
allBuiltIn: [secret, partnerId, publicKeyB64].every((c) => c.source === "built-in test value")
|
|
3998
4090
|
};
|
|
3999
4091
|
}
|
|
4092
|
+
function publicKeyProblem(c) {
|
|
4093
|
+
const cred = c.publicKeyB64;
|
|
4094
|
+
if (cred.source === "built-in test value") return null;
|
|
4095
|
+
const where = `${cred.envVar} (--public-key)`;
|
|
4096
|
+
if (/BEGIN[^-]*PRIVATE/.test(cred.value)) {
|
|
4097
|
+
return `${where} is a PRIVATE key. That one belongs on your RECEIVER and must never leave it; this flag takes the PUBLIC half, as base64 of the DER SPKI form.`;
|
|
4098
|
+
}
|
|
4099
|
+
let der;
|
|
4100
|
+
try {
|
|
4101
|
+
der = Buffer.from(cred.value, "base64");
|
|
4102
|
+
if (der.length === 0 || der.toString("base64").replace(/=+$/, "") !== cred.value.trim().replace(/=+$/, "")) {
|
|
4103
|
+
return `${where} is not valid base64. Copy it again from your partner portal \u2014 a line break or a stray space is the usual cause.`;
|
|
4104
|
+
}
|
|
4105
|
+
} catch {
|
|
4106
|
+
return `${where} is not valid base64.`;
|
|
4107
|
+
}
|
|
4108
|
+
try {
|
|
4109
|
+
const key = (0, import_node_crypto2.createPublicKey)({ key: der, format: "der", type: "spki" });
|
|
4110
|
+
if (key.asymmetricKeyType !== "ec") {
|
|
4111
|
+
return `${where} is a ${key.asymmetricKeyType ?? "non-EC"} key. OneAddress envelopes use ECDH P-256, so this key cannot unwrap them.`;
|
|
4112
|
+
}
|
|
4113
|
+
const curve = key.asymmetricKeyDetails?.namedCurve;
|
|
4114
|
+
if (curve && curve !== "prime256v1") {
|
|
4115
|
+
return `${where} is on curve ${curve}, not P-256 (prime256v1).`;
|
|
4116
|
+
}
|
|
4117
|
+
} catch {
|
|
4118
|
+
return `${where} is valid base64 but not an SPKI public key. Expect the BASE64 of the DER SPKI form \u2014 not a PEM, not a private key, and not the key id.`;
|
|
4119
|
+
}
|
|
4120
|
+
return null;
|
|
4121
|
+
}
|
|
4122
|
+
function partialCredentials(c) {
|
|
4123
|
+
if (c.allBuiltIn) return [];
|
|
4124
|
+
return [c.secret, c.partnerId, c.publicKeyB64].filter((x) => x.source === "built-in test value");
|
|
4125
|
+
}
|
|
4126
|
+
function partialCredentialRefusal(c) {
|
|
4127
|
+
const missing = partialCredentials(c);
|
|
4128
|
+
if (missing.length === 0) return null;
|
|
4129
|
+
const named = missing.map((x) => `${x.envVar} (${FLAG_FOR[x.envVar]})`);
|
|
4130
|
+
return [
|
|
4131
|
+
"\u2717 INCOMPLETE CREDENTIALS \u2014 refusing to run.",
|
|
4132
|
+
"",
|
|
4133
|
+
`Some credentials were supplied and some were not: ${named.join(", ")} ${missing.length === 1 ? "is" : "are"} still a built-in test value.`,
|
|
4134
|
+
"",
|
|
4135
|
+
"Against a real receiver a partial set fails the same way a WRONG one does:",
|
|
4136
|
+
"the signature checks pass, so the run looks half-healthy, while the payload",
|
|
4137
|
+
"is sealed to this suite's test key that your receiver cannot decrypt. The",
|
|
4138
|
+
"failures land on the acceptance checks and read as a fault in your code.",
|
|
4139
|
+
"",
|
|
4140
|
+
"Supply all three, or none:",
|
|
4141
|
+
"",
|
|
4142
|
+
" export ONEADDRESS_WEBHOOK_SECRET=whsec_...",
|
|
4143
|
+
" export ONEADDRESS_PARTNER_ID=...",
|
|
4144
|
+
" export ONEADDRESS_PUBLIC_KEY=...",
|
|
4145
|
+
"",
|
|
4146
|
+
"Supplying none is correct for a scaffold from `npx @oneaddress/setup`,",
|
|
4147
|
+
"which is built around the same test values. If you truly mean the test",
|
|
4148
|
+
"value for one of these, pass it explicitly and this will run.",
|
|
4149
|
+
""
|
|
4150
|
+
];
|
|
4151
|
+
}
|
|
4000
4152
|
function describeCredentials(c) {
|
|
4001
4153
|
if (c.allBuiltIn) {
|
|
4002
4154
|
return [
|
|
@@ -4007,19 +4159,15 @@ function describeCredentials(c) {
|
|
|
4007
4159
|
"around these same values. A REAL receiver will reject every request, including",
|
|
4008
4160
|
"the well-formed one, because it validates against its own secret. Your partner",
|
|
4009
4161
|
"portal has the values, and the safer way to pass them keeps the secret out of",
|
|
4010
|
-
"your shell history and out of `ps
|
|
4162
|
+
"your shell history and out of `ps`. ALL THREE, or the run is refused:",
|
|
4011
4163
|
"",
|
|
4012
4164
|
" export ONEADDRESS_WEBHOOK_SECRET=whsec_...",
|
|
4165
|
+
" export ONEADDRESS_PARTNER_ID=...",
|
|
4166
|
+
" export ONEADDRESS_PUBLIC_KEY=...",
|
|
4013
4167
|
""
|
|
4014
4168
|
];
|
|
4015
4169
|
}
|
|
4016
|
-
|
|
4017
|
-
if (missing.length === 0) return [];
|
|
4018
|
-
return [
|
|
4019
|
-
`Some credentials were supplied and some were not: ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} still a built-in test value.`,
|
|
4020
|
-
"Against a real receiver a partial set fails the same way a wrong one does.",
|
|
4021
|
-
""
|
|
4022
|
-
];
|
|
4170
|
+
return [];
|
|
4023
4171
|
}
|
|
4024
4172
|
|
|
4025
4173
|
// src/index.ts
|
|
@@ -4036,7 +4184,16 @@ Options:
|
|
|
4036
4184
|
ONEADDRESS_WEBHOOK_SECRET same as --secret
|
|
4037
4185
|
ONEADDRESS_PARTNER_ID same as --partner-id
|
|
4038
4186
|
ONEADDRESS_PUBLIC_KEY same as --public-key
|
|
4187
|
+
Supply ALL THREE or none: a partial set is refused, because it passes every
|
|
4188
|
+
signature check while the payload stays sealed to the built-in test key, so
|
|
4189
|
+
the failures land on the acceptance checks and read as a fault in your code.
|
|
4039
4190
|
--customer-url <url> Customer app URL for pull API checks (adds checks 9 + 10)
|
|
4191
|
+
--account-ref <ref> The account reference the dispatches carry (default: CONF-0001,
|
|
4192
|
+
which every scaffold seeds). Only matters if your receiver
|
|
4193
|
+
matches dispatches to your own customer records: it holds no
|
|
4194
|
+
CONF-0001, so it answers no_match \u2014 correctly \u2014 and the run
|
|
4195
|
+
cannot go green. Point this at a customer you already hold
|
|
4196
|
+
rather than writing test data into your system of record.
|
|
4040
4197
|
--accept <kinds> Comma-separated update kinds you accept: address,phone,email.
|
|
4041
4198
|
Adds a check per contact kind. Match this to your accept-set
|
|
4042
4199
|
in the partner portal \u2014 a phone update carries NO address,
|
|
@@ -4052,15 +4209,20 @@ Options:
|
|
|
4052
4209
|
report a defect it cannot have.
|
|
4053
4210
|
|
|
4054
4211
|
Example:
|
|
4212
|
+
# The wizard scaffold: no credentials at all, which is a meaningful run
|
|
4055
4213
|
oneaddress-conformance test http://localhost:3001/webhook
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4214
|
+
|
|
4215
|
+
# A real receiver: all three, kept out of argv and shell history
|
|
4216
|
+
export ONEADDRESS_WEBHOOK_SECRET=whsec_xxx
|
|
4217
|
+
export ONEADDRESS_PARTNER_ID=aaa...
|
|
4218
|
+
export ONEADDRESS_PUBLIC_KEY=MFkw...
|
|
4219
|
+
oneaddress-conformance test https://api.mycompany.com/oneaddress --accept address,phone
|
|
4220
|
+
oneaddress-conformance test https://api.mycompany.com/oneaddress --verifies-account-reference
|
|
4221
|
+
oneaddress-conformance test https://api.mycompany.com/oneaddress --customer-url https://oneaddress.io
|
|
4222
|
+
|
|
4223
|
+
# The same on one line, if you accept the secret landing in \`ps\`
|
|
4062
4224
|
oneaddress-conformance test https://api.mycompany.com/oneaddress \\
|
|
4063
|
-
--secret whsec_xxx --partner-id aaa... --
|
|
4225
|
+
--secret whsec_xxx --partner-id aaa... --public-key MFkw...
|
|
4064
4226
|
`.trim();
|
|
4065
4227
|
async function main() {
|
|
4066
4228
|
const args = process.argv.slice(2);
|
|
@@ -4082,6 +4244,7 @@ async function main() {
|
|
|
4082
4244
|
const partnerId = creds.partnerId.value;
|
|
4083
4245
|
const publicKey = creds.publicKeyB64.value;
|
|
4084
4246
|
const customerUrl = getFlag("--customer-url");
|
|
4247
|
+
const accountRef = getFlag("--account-ref")?.trim() || process.env.ONEADDRESS_ACCOUNT_REF?.trim() || DEFAULT_ACCOUNT_REF;
|
|
4085
4248
|
const acceptedUpdateTypes = (getFlag("--accept") ?? "").split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
|
|
4086
4249
|
const verifiesAccountReference = args.includes("--verifies-account-reference");
|
|
4087
4250
|
const UNKNOWN = acceptedUpdateTypes.filter((t) => !["address", "phone", "email"].includes(t));
|
|
@@ -4118,6 +4281,27 @@ async function main() {
|
|
|
4118
4281
|
if (parsedTarget.protocol === "http:" && isLocalhost) {
|
|
4119
4282
|
console.warn("\n ! HTTP detected \u2014 acceptable for local testing only.\n");
|
|
4120
4283
|
}
|
|
4284
|
+
const refusal = partialCredentialRefusal(creds);
|
|
4285
|
+
if (refusal) {
|
|
4286
|
+
console.error("");
|
|
4287
|
+
for (const line of refusal) console.error(line ? ` ${line}` : "");
|
|
4288
|
+
process.exit(1);
|
|
4289
|
+
}
|
|
4290
|
+
const keyProblem = publicKeyProblem(creds);
|
|
4291
|
+
if (keyProblem) {
|
|
4292
|
+
console.error("");
|
|
4293
|
+
console.error(" \u2717 UNUSABLE PUBLIC KEY \u2014 refusing to run.");
|
|
4294
|
+
console.error("");
|
|
4295
|
+
console.error(` ${keyProblem}`);
|
|
4296
|
+
console.error("");
|
|
4297
|
+
process.exit(1);
|
|
4298
|
+
}
|
|
4299
|
+
if (verifiesAccountReference) {
|
|
4300
|
+
console.log(
|
|
4301
|
+
accountRef === DEFAULT_ACCOUNT_REF ? ` This run sends account reference ${DEFAULT_ACCOUNT_REF}. Your receiver matches references itself, so it needs a customer with that reference, or pass --account-ref <one of yours>.` : ` Account reference: ${accountRef}. It must exist in your system of record, or the matching checks fail on a receiver that is behaving correctly.`
|
|
4302
|
+
);
|
|
4303
|
+
console.log("");
|
|
4304
|
+
}
|
|
4121
4305
|
console.log(`
|
|
4122
4306
|
Running conformance checks against: ${targetUrl}`);
|
|
4123
4307
|
if (customerUrl) console.log(`Pull API checks against: ${customerUrl}`);
|
|
@@ -4130,7 +4314,8 @@ Running conformance checks against: ${targetUrl}`);
|
|
|
4130
4314
|
publicKeyB64: publicKey,
|
|
4131
4315
|
customerUrl,
|
|
4132
4316
|
acceptedUpdateTypes,
|
|
4133
|
-
verifiesAccountReference
|
|
4317
|
+
verifiesAccountReference,
|
|
4318
|
+
accountRef
|
|
4134
4319
|
});
|
|
4135
4320
|
printReport(results);
|
|
4136
4321
|
const code = exitCode(results);
|