@tokenoftrust/cli 7.5.3 → 7.5.5

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.3",
3
+ "version": "7.5.5",
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",
@@ -16,7 +16,7 @@
16
16
  * A client secret is printed once, by `install` or `rotate`, and nowhere else: `list` never
17
17
  * carries one and nothing here writes it to a file or the activity log.
18
18
  */
19
- import { existsSync, readFileSync } from "node:fs";
19
+ import { existsSync, readFileSync, statSync } from "node:fs";
20
20
  import { join, resolve } from "node:path";
21
21
  import { DEFAULT_STOREFRONT_ORIGIN, resolveViewerTransport } from "../../viewer-session.mjs";
22
22
  import { missingGrantsOf, refusalHint } from "../../admission-hint.mjs";
@@ -455,9 +455,12 @@ export async function runAdmin(argv, ctx, deps = {}) {
455
455
 
456
456
  /** `tot app validate`: offline manifest lint; a refused manifest is `invalid_manifest`, exit 1. */
457
457
  function runValidateManifest(args, ctx, out, err) {
458
- const path = args.positional[0]
458
+ const candidate = args.positional[0]
459
459
  ? resolve(ctx?.cwd || process.cwd(), args.positional[0])
460
460
  : join(resolve(args.app || ctx?.cwd || process.cwd()), "tot-app.json");
461
+ const path = existsSync(candidate) && statSync(candidate).isDirectory()
462
+ ? join(candidate, "tot-app.json")
463
+ : candidate;
461
464
  if (!existsSync(path)) {
462
465
  err(`✗ no manifest at ${path}\n\n → next: pass a path, or \`tot app scaffold <name>\``);
463
466
  return 2;
@@ -1,4 +1,4 @@
1
- import { createHash, generateKeyPairSync, randomUUID, sign } from "node:crypto";
1
+ import { createHash, generateKeyPairSync, randomUUID } from "node:crypto";
2
2
  import { mkdtemp, rename, rm, writeFile } from "node:fs/promises";
3
3
  import { createServer, request as requestHttp } from "node:http";
4
4
  import { request as requestHttps } from "node:https";
@@ -12,10 +12,12 @@ import { DEFAULT_STOREFRONT_ORIGIN, TOKEN_OF_TRUST_MCP_ORIGINS } from "../../vie
12
12
  import {
13
13
  SIGNATURE_LABEL,
14
14
  WEBHOOK_SIGNATURE_COVERED_COMPONENTS,
15
+ WEBHOOK_SIGNING_HTTPSIG_ALG,
15
16
  buildSignatureBase,
16
17
  buildSignatureParamsValue,
17
18
  computeContentDigestSha256,
18
19
  } from "../../vendor/private-apps-devkit.mjs";
20
+ import { createSign } from "node:crypto";
19
21
 
20
22
  const METADATA_HOST = "127.0.0.1";
21
23
  const METADATA_PORT = 37891;
@@ -40,10 +42,11 @@ By default and for dropship, the checklist sends synthetic fulfillment and
40
42
  inventory events. label-station checks assignment events and their replay.
41
43
  inventory-sync checks inventory events and their replay.
42
44
 
43
- Configure your local Ed25519 verifier to load webhook_signing_keys from
45
+ Configure your local RS256 verifier (such as connector-kit AuthorizationMetadata)
46
+ to load webhook_signing_keys from
44
47
  ${METADATA_URL}
45
- when it receives a delivery. The command serves the ephemeral public key there
46
- for the duration of the run. The bundled RSA verifier works with tot app dev emit.
48
+ when it receives a delivery. The command serves the ephemeral RS256 public key there
49
+ for the duration of the run. The bundled RSA verifier also works with tot app dev emit.
47
50
 
48
51
  For replay, return a 2xx JSON response with {"accepted":true,"duplicate":true}
49
52
  when the same CloudEvent ID is received again. Check connector state separately
@@ -318,9 +321,9 @@ export async function runAppConformance(argv, {
318
321
  return 2;
319
322
  }
320
323
 
321
- const { privateKey, publicKey } = generateKeyPairSync("ed25519");
324
+ const { privateKey, publicKey } = generateKeyPairSync("rsa", { modulusLength: 2048 });
322
325
  const kid = `conformance-${randomUUID()}`;
323
- const jwk = { ...publicKey.export({ format: "jwk" }), kid, alg: "EdDSA", use: "sig" };
326
+ const jwk = { ...publicKey.export({ format: "jwk" }), kid, alg: "RS256", use: "sig" };
324
327
  const metadata = JSON.stringify({ webhook_signing_keys: { keys: [jwk] } });
325
328
  const server = makeServer((req, res) => {
326
329
  if (req.method === "GET" && req.url === METADATA_PATH) {
@@ -346,14 +349,15 @@ export async function runAppConformance(argv, {
346
349
  const replay = acknowledgment === "replay";
347
350
  const digest = await computeContentDigestSha256(body);
348
351
  const params = buildSignatureParamsValue(WEBHOOK_SIGNATURE_COVERED_COMPONENTS, {
349
- created: Math.floor(now() / 1000), keyid: kid, alg: "ed25519",
352
+ created: Math.floor(now() / 1000), keyid: kid, alg: WEBHOOK_SIGNING_HTTPSIG_ALG,
350
353
  });
351
354
  const base = buildSignatureBase([["@method", "POST"], ["@target-uri", target.href], ["content-digest", digest]], params);
355
+ const sig = createSign("RSA-SHA256").update(base).sign(privateKey).toString("base64");
352
356
  const headers = {
353
357
  "content-type": "application/cloudevents+json",
354
358
  "content-digest": digest,
355
359
  "signature-input": `${SIGNATURE_LABEL}=${params}`,
356
- signature: `${SIGNATURE_LABEL}=:${sign(null, Buffer.from(base), privateKey).toString("base64")}:`,
360
+ signature: `${SIGNATURE_LABEL}=:${sig}:`,
357
361
  };
358
362
  let finding;
359
363
  try {
@@ -17,7 +17,7 @@
17
17
  * own `server.js` (which imports the SAME functions from its copy at
18
18
  * `lib/private-apps-devkit.mjs`) verifies exactly what this harness signs.
19
19
  */
20
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
20
+ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
21
21
  import { dirname, join, resolve } from "node:path";
22
22
  import { fail } from "../../errors.mjs";
23
23
  import {
@@ -93,7 +93,10 @@ function readInput(pathOrDash) {
93
93
  // ── validate ─────────────────────────────────────────────────────────────
94
94
 
95
95
  function runValidate(argv, { appDir }) {
96
- const manifestPath = resolve(argv[0] || join(appDir, "tot-app.json"));
96
+ const candidate = resolve(argv[0] || join(appDir, "tot-app.json"));
97
+ const manifestPath = existsSync(candidate) && statSync(candidate).isDirectory()
98
+ ? join(candidate, "tot-app.json")
99
+ : candidate;
97
100
  if (!existsSync(manifestPath)) {
98
101
  console.error(fail(`no manifest at ${manifestPath}`, "tot app scaffold <name>, or pass a path"));
99
102
  return 2;