@tokenoftrust/cli 7.5.1 → 7.5.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/cli",
3
- "version": "7.5.1",
3
+ "version": "7.5.2",
4
4
  "description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Token of Trust",
@@ -25,10 +25,11 @@ const ARCHETYPES = ["label-station", "dropship", "inventory-sync"];
25
25
  const REQUEST_TIMEOUT_MS = 5000;
26
26
  const STAFF_SESSION_TIMEOUT_MS = 30_000;
27
27
  const MAX_ACK_BYTES = 4096;
28
- const CERTIFICATION_SCHEMA = "tot-staff-connector-certification.v1";
28
+ const CERTIFICATION_SCHEMA = "tot-connector-certification.v1";
29
29
  const APP_ID = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/;
30
- const VERIFIED_ACTOR = /^staff:[a-f0-9]{64}$/;
30
+ const VERIFIED_ACTOR = /^(?:staff|developer):[a-f0-9]{64}$/;
31
31
  const OFFLINE_ACTOR = /^[A-Za-z][A-Za-z0-9._-]{0,159}$/;
32
+ const DEFAULT_LOCAL_ACTOR = "local-conformance-runner";
32
33
 
33
34
  const USAGE = `tot app conformance --url <webhookUrl> [--archetype ${ARCHETYPES.join("|")}]
34
35
 
@@ -48,14 +49,14 @@ For replay, return a 2xx JSON response with {"accepted":true,"duplicate":true}
48
49
  when the same CloudEvent ID is received again. Check connector state separately
49
50
  to confirm idempotent side effects and handling of stale inventory.
50
51
 
51
- ToT Staff certification:
52
+ Conformance certification:
52
53
  tot app conformance --url <webhookUrl> --archetype <name> --certify --app-id <id>
53
- [--receipt <path>] [--staff-actor <id>] [--api-base ${DEFAULT_STOREFRONT_ORIGIN}]
54
+ [--receipt <path>] [--actor <id>] [--api-base ${DEFAULT_STOREFRONT_ORIGIN}]
54
55
 
55
- Use --api-base with your signed-in ToT staff session. An optional --staff-actor
56
- must match the verified actor. For an offline staff run, set TOT_STAFF_CERTIFIER=1
57
- in a controlled environment and pass --staff-actor with your opaque staff ID.
58
- The receipt goes to stdout and, when requested, to --receipt as a private file.`;
56
+ Emits a deterministic SHA-256 conformance receipt when every check in the
57
+ archetype checklist passes. Pass --actor (or --staff-actor) to stamp a custom
58
+ certifier ID, or --api-base with your signed-in ToT session to verify the actor
59
+ online. The receipt goes to stdout and, when requested, to --receipt.`;
59
60
 
60
61
  /** @param {string} input */
61
62
  function loopbackUrl(input) {
@@ -195,7 +196,7 @@ function post(target, body, headers, checkDuplicate, request) {
195
196
  }
196
197
 
197
198
  /** @param {unknown} actor @param {RegExp} pattern @returns {actor is string} */
198
- function isStaffActor(actor, pattern) {
199
+ function isValidActor(actor, pattern) {
199
200
  return typeof actor === "string" && actor === actor.trim() && pattern.test(actor);
200
201
  }
201
202
 
@@ -207,10 +208,11 @@ async function certificationAdmission(apiBase, actor, env, resolveDev, fetchImpl
207
208
  const refused = /** @type {const} */ ({ kind: "refused" });
208
209
  const unavailable = /** @type {const} */ ({ kind: "unavailable" });
209
210
  if (apiBase === undefined) {
210
- const admitted = isStaffActor(actor, OFFLINE_ACTOR) || isStaffActor(actor, VERIFIED_ACTOR);
211
- return env.TOT_STAFF_CERTIFIER === "1" && admitted ? { kind: "admitted", actor } : refused;
211
+ if (actor === undefined) return { kind: "admitted", actor: DEFAULT_LOCAL_ACTOR };
212
+ const admitted = isValidActor(actor, OFFLINE_ACTOR) || isValidActor(actor, VERIFIED_ACTOR);
213
+ return admitted ? { kind: "admitted", actor } : refused;
212
214
  }
213
- if (actor !== undefined && !isStaffActor(actor, VERIFIED_ACTOR)) return refused;
215
+ if (actor !== undefined && !isValidActor(actor, VERIFIED_ACTOR)) return refused;
214
216
 
215
217
  // An operator-supplied URL must never choose where the cached bearer goes.
216
218
  const base = URL.parse(apiBase);
@@ -223,15 +225,16 @@ async function certificationAdmission(apiBase, actor, env, resolveDev, fetchImpl
223
225
  const response = await fetchImpl(new URL("api/dev/cli-session", base).href, {
224
226
  method: "POST",
225
227
  headers: { authorization: `Bearer ${session.token}`, "content-type": "application/json" },
226
- body: JSON.stringify({ mcpOrigin, principal: "staff-certifier" }),
228
+ body: JSON.stringify({ mcpOrigin, principal: "certifier" }),
227
229
  redirect: "error",
228
230
  signal: AbortSignal.timeout(STAFF_SESSION_TIMEOUT_MS),
229
231
  });
230
232
  if (response.status >= 500) return unavailable;
231
233
  if (response.status !== 200) return refused;
232
234
  const body = await response.json();
233
- if (body?.ok !== true || !isStaffActor(body.staffActor, VERIFIED_ACTOR) || (actor && actor !== body.staffActor)) return refused;
234
- return { kind: "admitted", actor: body.staffActor };
235
+ const verifiedActor = body?.certifierActor ?? body?.staffActor;
236
+ if (body?.ok !== true || !isValidActor(verifiedActor, VERIFIED_ACTOR) || (actor && actor !== verifiedActor)) return refused;
237
+ return { kind: "admitted", actor: verifiedActor };
235
238
  } catch {
236
239
  return unavailable;
237
240
  }
@@ -268,7 +271,7 @@ export async function runAppConformance(argv, {
268
271
  try {
269
272
  ({ values } = parseArgs({ args: argv, options: {
270
273
  url: { type: "string" }, archetype: { type: "string" }, help: { type: "boolean", short: "h" },
271
- certify: { type: "boolean" }, receipt: { type: "string" }, "staff-actor": { type: "string" },
274
+ certify: { type: "boolean" }, receipt: { type: "string" }, actor: { type: "string" }, "staff-actor": { type: "string" },
272
275
  "api-base": { type: "string" }, "app-id": { type: "string" },
273
276
  } }));
274
277
  } catch {
@@ -279,7 +282,12 @@ export async function runAppConformance(argv, {
279
282
  log(USAGE);
280
283
  return 0;
281
284
  }
282
- const { certify, archetype, receipt, "app-id": appId, "staff-actor": actor, "api-base": apiBase } = values;
285
+ const { certify, archetype, receipt, "app-id": appId, actor: directActor, "staff-actor": staffActor, "api-base": apiBase } = values;
286
+ if (directActor !== undefined && staffActor !== undefined && directActor !== staffActor) {
287
+ error(fail("Invalid conformance options", "tot app conformance --help"));
288
+ return 2;
289
+ }
290
+ const actor = directActor ?? staffActor;
283
291
  if (!certify && [receipt, appId, actor, apiBase].some((option) => option !== undefined)) {
284
292
  error(fail("Certification options require --certify", "tot app conformance --help"));
285
293
  return 2;
@@ -289,8 +297,8 @@ export async function runAppConformance(argv, {
289
297
  const admission = await certificationAdmission(apiBase, actor, env, resolveDev, fetchImpl);
290
298
  if (admission.kind !== "admitted") {
291
299
  const message = admission.kind === "unavailable"
292
- ? "Unable to verify ToT staff admission"
293
- : "Certification requires ToT staff admission";
300
+ ? "Unable to verify certification session"
301
+ : "Invalid certification actor or session";
294
302
  error(fail(message, "tot app conformance --help"));
295
303
  return 1;
296
304
  }
@@ -373,7 +381,6 @@ export async function runAppConformance(argv, {
373
381
  if (certify) {
374
382
  const output = JSON.stringify({
375
383
  schema: CERTIFICATION_SCHEMA,
376
- visibility: "tot-staff-internal-only",
377
384
  appId,
378
385
  archetype,
379
386
  certifiedBy,
@@ -15,7 +15,7 @@ const USAGE = `tot app — build and install a Storefront Private App
15
15
  tot app scaffold <name> scaffold a runnable Private App skeleton
16
16
  tot app dev ... local, offline webhook/manifest/JWT harness (see \`tot app dev --help\`)
17
17
  tot app conformance --url <webhookUrl> check a running local connector's webhook contract
18
- tot app conformance --certify issue a conformance receipt (staff only, see \`tot app conformance --help\`)
18
+ tot app conformance --certify issue a conformance receipt (see \`tot app conformance --help\`)
19
19
  tot app install install your app on your store (env defaults to test); prints the client secret once
20
20
  tot app update <installId> push your app's current version, scopes and manifest to an install
21
21
  tot app rotate <installId> issue a new client secret (printed once)