@tokenoftrust/cli 8.4.0 → 8.4.1
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": "8.4.
|
|
3
|
+
"version": "8.4.1",
|
|
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",
|
|
@@ -23,6 +23,13 @@ import { missingGrantsOf, refusalHint } from "../../admission-hint.mjs";
|
|
|
23
23
|
import { validateManifest } from "../../vendor/private-apps-devkit.mjs";
|
|
24
24
|
import { generateCandidateKeys } from "./candidate-keys.mjs";
|
|
25
25
|
|
|
26
|
+
/** @typedef {import("../../vendor/private-apps-v1.8/admin.js").AdminInstallRequest} AdminInstallRequest */
|
|
27
|
+
/** @typedef {import("../../vendor/private-apps-v1.8/admin.js").AdminUpdateRequest} AdminUpdateRequest */
|
|
28
|
+
/** @typedef {import("../../vendor/private-apps-v1.8/admin.js").AdminInstallList} AdminInstallList */
|
|
29
|
+
/** @typedef {import("../../vendor/private-apps-v1.8/admin.js").AdminAppCandidateStage} AdminAppCandidateStage */
|
|
30
|
+
/** @typedef {import("../../vendor/private-apps-v1.8/admin.js").AdminAppCandidateList["candidates"][number]} AdminAppCandidate */
|
|
31
|
+
/** @typedef {{ id: string, version: string, scopes: string[], webhooks?: { endpoint: string }, widgets?: object[], clientAuth?: object }} ValidatedManifest */
|
|
32
|
+
|
|
26
33
|
export const DEFAULT_APP_ENV = "test";
|
|
27
34
|
const OPTION_VERBS = new Set(["install", "update", "rotate", "list", "replay", "test-order", "candidate", "suspend", "resume", "uninstall", "validate"]);
|
|
28
35
|
const TEST_ORDER_TRANSITIONS = new Map([["release", "released"], ["hold", "held"], ["cancel", "canceled"]]);
|
|
@@ -253,11 +260,11 @@ export async function runAdmin(argv, ctx, deps = {}) {
|
|
|
253
260
|
const webhookEndpoint = args.webhookEndpoint === undefined ? m.webhooks?.endpoint : args.webhookEndpoint;
|
|
254
261
|
request = {
|
|
255
262
|
method: "POST", path: "/api/apps/admin/install",
|
|
256
|
-
body: {
|
|
263
|
+
body: /** @satisfies {AdminInstallRequest} */ ({
|
|
257
264
|
appId: m.id, appVersion: m.version, env: appEnv, scopes: m.scopes || [], manifest: m,
|
|
258
265
|
...(webhookEndpoint ? { webhookEndpoint } : {}),
|
|
259
266
|
...(Array.isArray(m.widgets) && m.widgets.length ? { widgetPlacements: m.widgets } : {}),
|
|
260
|
-
},
|
|
267
|
+
}),
|
|
261
268
|
};
|
|
262
269
|
} else if (verb === "update") {
|
|
263
270
|
const installId = args.positional[0];
|
|
@@ -267,13 +274,13 @@ export async function runAdmin(argv, ctx, deps = {}) {
|
|
|
267
274
|
const m = loaded.manifest;
|
|
268
275
|
request = {
|
|
269
276
|
method: "POST", path: "/api/apps/admin/update",
|
|
270
|
-
body: {
|
|
277
|
+
body: /** @satisfies {AdminUpdateRequest} */ ({
|
|
271
278
|
installId, appVersion: m.version, scopes: m.scopes || [], manifest: m,
|
|
272
279
|
...(args.webhookEndpoint === undefined
|
|
273
280
|
? (m.webhooks?.endpoint ? { webhookEndpoint: m.webhooks.endpoint } : {})
|
|
274
281
|
: { webhookEndpoint: args.webhookEndpoint }),
|
|
275
282
|
...(Array.isArray(m.widgets) ? { widgetPlacements: m.widgets } : {}),
|
|
276
|
-
},
|
|
283
|
+
}),
|
|
277
284
|
};
|
|
278
285
|
} else if (verb === "rotate") {
|
|
279
286
|
const installId = args.positional[0];
|
|
@@ -348,14 +355,14 @@ export async function runAdmin(argv, ctx, deps = {}) {
|
|
|
348
355
|
const webhookEndpoint = args.webhookEndpoint === undefined ? m.webhooks?.endpoint : args.webhookEndpoint;
|
|
349
356
|
request = {
|
|
350
357
|
method: "POST", path: "/api/apps/admin/candidates",
|
|
351
|
-
body: {
|
|
358
|
+
body: /** @satisfies {AdminAppCandidateStage} */ ({
|
|
352
359
|
appId: m.id, appVersion: m.version, scopes: m.scopes || [], manifest: m,
|
|
353
360
|
...(webhookEndpoint ? { webhookEndpoint } : {}),
|
|
354
361
|
...(Array.isArray(m.widgets) && m.widgets.length ? { widgetPlacements: m.widgets } : {}),
|
|
355
362
|
...(args.jwksUri ? { jwksUri: args.jwksUri } : {}),
|
|
356
363
|
...(jwks ? { jwks } : {}),
|
|
357
364
|
...(args.requestConsent ? { requestConsent: true } : {}),
|
|
358
|
-
},
|
|
365
|
+
}),
|
|
359
366
|
};
|
|
360
367
|
} else {
|
|
361
368
|
const deliveryId = args.positional[0];
|
|
@@ -491,6 +498,7 @@ function runValidateManifest(args, ctx, out, err) {
|
|
|
491
498
|
return 1;
|
|
492
499
|
}
|
|
493
500
|
|
|
501
|
+
/** @param {{ candidates?: Array<Partial<AdminAppCandidate> & { id?: string }> } | null} data */
|
|
494
502
|
function renderCandidates(data, json, out) {
|
|
495
503
|
const rows = (Array.isArray(data?.candidates) ? data.candidates : []).map((c) => ({
|
|
496
504
|
candidateId: c?.candidateId ?? c?.id, appId: c?.appId, appVersion: c?.appVersion, status: c?.status,
|
|
@@ -517,7 +525,7 @@ function parseJsonBody(text) {
|
|
|
517
525
|
|
|
518
526
|
/**
|
|
519
527
|
* @param {string|null} appDir @param {any} ctx
|
|
520
|
-
* @returns {{ ok: true, manifest:
|
|
528
|
+
* @returns {{ ok: true, manifest: ValidatedManifest, dir: string } | { ok: false, message: string, next: string }}
|
|
521
529
|
*/
|
|
522
530
|
function loadManifest(appDir, ctx) {
|
|
523
531
|
const dir = resolve(appDir || ctx?.cwd || process.cwd());
|
|
@@ -576,6 +584,7 @@ function renderTestOrder(data, args, out, err) {
|
|
|
576
584
|
return 0;
|
|
577
585
|
}
|
|
578
586
|
|
|
587
|
+
/** @param {Partial<AdminInstallList> | null} data */
|
|
579
588
|
function renderList(data, json, out) {
|
|
580
589
|
const installs = Array.isArray(data?.installs) ? data.installs : [];
|
|
581
590
|
if (json) {
|
|
@@ -596,7 +605,7 @@ function renderList(data, json, out) {
|
|
|
596
605
|
return 0;
|
|
597
606
|
}
|
|
598
607
|
|
|
599
|
-
/** Only these fields ever leave a list response
|
|
608
|
+
/** Only these fields ever leave a list response. @param {AdminInstallList["installs"][number]} i */
|
|
600
609
|
function installRow(i) {
|
|
601
610
|
return {
|
|
602
611
|
installId: i?.installId, appId: i?.appId, appVersion: i?.appVersion, env: i?.env, status: i?.status,
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Storefront Devkit Private Apps OpenAPI 1.8.0, commit 86ebe41a9785b177fb6dedf7f387bd4fc3b20787.
|
|
2
|
+
// apps/private/contract/openapi.yaml, SHA-256 00cd2b2665c4fc3183f48cac1ea2c30a6fa3a1b024f02bf0fc2774f60ec54b3e.
|
|
3
|
+
|
|
4
|
+
export interface AdminInstallRequest {
|
|
5
|
+
appId: string;
|
|
6
|
+
appVersion: string;
|
|
7
|
+
env: string;
|
|
8
|
+
scopes: string[];
|
|
9
|
+
manifest: object;
|
|
10
|
+
webhookEndpoint?: string | null;
|
|
11
|
+
widgetPlacements?: object[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AdminUpdateRequest {
|
|
15
|
+
installId: string;
|
|
16
|
+
appVersion?: string;
|
|
17
|
+
scopes?: string[];
|
|
18
|
+
manifest?: object;
|
|
19
|
+
webhookEndpoint?: string | null;
|
|
20
|
+
widgetPlacements?: object[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AdminInstallList {
|
|
24
|
+
installs: AdminInstall[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface AdminInstall {
|
|
28
|
+
installId: string;
|
|
29
|
+
appId: string;
|
|
30
|
+
appVersion: string;
|
|
31
|
+
tenantId: string;
|
|
32
|
+
env: string;
|
|
33
|
+
status: "active" | "suspended" | "uninstalled";
|
|
34
|
+
scopes: string[];
|
|
35
|
+
manifest?: object;
|
|
36
|
+
webhookEndpoint?: string | null;
|
|
37
|
+
widgetPlacements?: object[];
|
|
38
|
+
installActor?: string;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface AdminErrorBody {
|
|
44
|
+
error: string;
|
|
45
|
+
code?: string;
|
|
46
|
+
denials?: string[];
|
|
47
|
+
reasons?: ("install-inactive" | "webhook-endpoint-missing" | "processor-scope-missing")[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface AdminAppCandidateList {
|
|
51
|
+
candidates: AdminAppCandidate[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface AdminAppCandidateStage {
|
|
55
|
+
appId: string;
|
|
56
|
+
appVersion: string;
|
|
57
|
+
scopes: string[];
|
|
58
|
+
manifest: object;
|
|
59
|
+
webhookEndpoint?: string | null;
|
|
60
|
+
widgetPlacements?: object[];
|
|
61
|
+
jwks?: { keys: {
|
|
62
|
+
kty: "RSA" | "EC";
|
|
63
|
+
kid: string;
|
|
64
|
+
alg?: "RS256" | "ES256";
|
|
65
|
+
use?: "sig";
|
|
66
|
+
[parameter: string]: unknown;
|
|
67
|
+
}[] };
|
|
68
|
+
jwksUri?: string;
|
|
69
|
+
requestConsent?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface AdminAppCandidate {
|
|
73
|
+
candidateId: string;
|
|
74
|
+
appId: string;
|
|
75
|
+
appVersion: string;
|
|
76
|
+
env: "production";
|
|
77
|
+
scopes: string[];
|
|
78
|
+
clientId: string;
|
|
79
|
+
keys: { kid: string; alg: "RS256" | "ES256" }[];
|
|
80
|
+
jwksHost: string | null;
|
|
81
|
+
requestConsent: boolean;
|
|
82
|
+
snapshotDigest: string;
|
|
83
|
+
status: "pending_approval" | "approved" | "rejected";
|
|
84
|
+
stagedAt: string;
|
|
85
|
+
decidedAt: string | null;
|
|
86
|
+
installId: string | null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface AdminAppCandidateDecision {
|
|
90
|
+
candidateId: string;
|
|
91
|
+
snapshotDigest: string;
|
|
92
|
+
decision: "approve" | "reject";
|
|
93
|
+
grantConsent?: boolean;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface AdminAppCandidateDecisionResult {
|
|
97
|
+
candidateId: string;
|
|
98
|
+
status: "approved" | "rejected";
|
|
99
|
+
installId: string | null;
|
|
100
|
+
appId: string;
|
|
101
|
+
appVersion: string;
|
|
102
|
+
consentGranted: boolean;
|
|
103
|
+
}
|