@tokenoftrust/cli 6.12.3 → 6.12.4
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": "6.12.
|
|
3
|
+
"version": "6.12.4",
|
|
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",
|
|
@@ -140,7 +140,7 @@ export const CAPABILITIES = [
|
|
|
140
140
|
'docs/private-apps/documentation-and-recipe-architecture.md',
|
|
141
141
|
],
|
|
142
142
|
populatedBy: 'tot-app.json manifest (`tot app scaffold` / `tot app install`; recipe://storefront-private-apps-devbook)',
|
|
143
|
-
verifiedBy: 'tot app validate, tot app
|
|
143
|
+
verifiedBy: 'tot app dev validate, tot app dev emit, and POST /api/apps/admin/test-orders on preview',
|
|
144
144
|
appliesTo: ['commerce'],
|
|
145
145
|
},
|
|
146
146
|
|
|
@@ -278,7 +278,12 @@ const HOSTNAME_PATTERN = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a
|
|
|
278
278
|
const TOP_LEVEL_KEYS = [
|
|
279
279
|
"contractVersion", "id", "name", "version", "owner", "description", "installMode",
|
|
280
280
|
"scopes", "webhooks", "widgets", "adminLinks", "telemetryMode", "retention", "hosting",
|
|
281
|
+
"clientAuth",
|
|
281
282
|
];
|
|
283
|
+
const CLIENT_AUTH_KEYS = ["method", "jwks", "jwksUri"];
|
|
284
|
+
const CLIENT_JWK_KTYS = ["RSA", "EC"];
|
|
285
|
+
const CLIENT_JWK_ALGS = ["RS256", "ES256"];
|
|
286
|
+
const PRIVATE_JWK_MEMBERS = ["d", "p", "q", "dp", "dq", "qi", "oth", "k"];
|
|
282
287
|
const OWNER_KEYS = ["name", "email", "url"];
|
|
283
288
|
const WEBHOOKS_KEYS = ["endpoint", "topics", "signatureKeyId"];
|
|
284
289
|
const WIDGET_KEYS = ["placement", "endpoint", "title"];
|
|
@@ -453,6 +458,58 @@ function validateHosting(hosting, errors) {
|
|
|
453
458
|
}
|
|
454
459
|
}
|
|
455
460
|
|
|
461
|
+
function validateClientAuth(clientAuth, errors) {
|
|
462
|
+
if (clientAuth === undefined) return;
|
|
463
|
+
if (!isPlainObject(clientAuth)) {
|
|
464
|
+
errors.push("clientAuth: must be an object");
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
rejectUnknownKeys(clientAuth, CLIENT_AUTH_KEYS, "clientAuth", errors);
|
|
468
|
+
if (clientAuth.method !== "private_key_jwt") errors.push('clientAuth.method: must be "private_key_jwt"');
|
|
469
|
+
const hasJwks = clientAuth.jwks !== undefined;
|
|
470
|
+
const hasUri = clientAuth.jwksUri !== undefined;
|
|
471
|
+
if (hasJwks === hasUri) {
|
|
472
|
+
errors.push("clientAuth: give exactly one of jwks or jwksUri");
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (hasUri) {
|
|
476
|
+
const uri = clientAuth.jwksUri;
|
|
477
|
+
checkPattern(uri, HTTPS_URI_PATTERN, "clientAuth.jwksUri", errors);
|
|
478
|
+
if (typeof uri === "string" && uri.length > 2048) errors.push("clientAuth.jwksUri: must be at most 2048 characters");
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const jwks = clientAuth.jwks;
|
|
482
|
+
if (!isPlainObject(jwks)) {
|
|
483
|
+
errors.push("clientAuth.jwks: must be an object");
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
rejectUnknownKeys(jwks, ["keys"], "clientAuth.jwks", errors);
|
|
487
|
+
const keys = jwks.keys;
|
|
488
|
+
if (!Array.isArray(keys) || keys.length === 0 || keys.length > 10) {
|
|
489
|
+
errors.push("clientAuth.jwks.keys: must be an array of 1 to 10 keys");
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
const kids = new Set();
|
|
493
|
+
keys.forEach((key, index) => {
|
|
494
|
+
const at = `clientAuth.jwks.keys[${index}]`;
|
|
495
|
+
if (!isPlainObject(key)) {
|
|
496
|
+
errors.push(`${at}: must be an object`);
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
checkEnum(key.kty, CLIENT_JWK_KTYS, `${at}.kty`, errors);
|
|
500
|
+
const kid = requireString(key, "kid", at, errors);
|
|
501
|
+
if (kid !== undefined) {
|
|
502
|
+
if (kids.has(kid)) errors.push(`${at}.kid: duplicate kid`);
|
|
503
|
+
kids.add(kid);
|
|
504
|
+
}
|
|
505
|
+
if (key.alg !== undefined) checkEnum(key.alg, CLIENT_JWK_ALGS, `${at}.alg`, errors);
|
|
506
|
+
if (key.use !== undefined && key.use !== "sig") errors.push(`${at}.use: must be "sig"`);
|
|
507
|
+
for (const member of PRIVATE_JWK_MEMBERS) {
|
|
508
|
+
if (key[member] !== undefined) errors.push(`${at}: private member "${member}" is not allowed; publish public keys only`);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
|
|
456
513
|
/**
|
|
457
514
|
* Validate a parsed `tot-app.json` manifest against the V1 contract. Returns
|
|
458
515
|
* every violation found (not just the first).
|
|
@@ -495,6 +552,7 @@ export function validateManifest(input) {
|
|
|
495
552
|
}
|
|
496
553
|
validateRetention(input.retention, errors);
|
|
497
554
|
validateHosting(input.hosting, errors);
|
|
555
|
+
validateClientAuth(input.clientAuth, errors);
|
|
498
556
|
|
|
499
557
|
if (errors.length > 0) return { ok: false, errors };
|
|
500
558
|
return { ok: true, manifest: input };
|
|
@@ -76,17 +76,14 @@ for runnable reference connectors against the v1.3 contract:
|
|
|
76
76
|
Developers holding `preview-access` or `ship-on-behalf` on a store can verify an app end-to-end on
|
|
77
77
|
the preview stage without waiting on the store owner:
|
|
78
78
|
|
|
79
|
-
1. **Seed preview catalog & stock:**
|
|
79
|
+
1. **Seed preview catalog & stock (inside a cloned store checkout):**
|
|
80
80
|
```bash
|
|
81
|
-
tot catalog seed --store <tenant> --preset general|regulated-vape|multi-warehouse
|
|
82
|
-
# or inside a cloned store checkout:
|
|
83
81
|
tot catalog seed --preset=general|regulated-vape|multi-warehouse
|
|
82
|
+
tot preview
|
|
84
83
|
```
|
|
85
84
|
2. **Self-serve install in `env="test"`:**
|
|
86
85
|
```bash
|
|
87
|
-
tot app install --
|
|
88
|
-
# or inside your app directory:
|
|
89
|
-
tot app install --tenant <tenant> --env test
|
|
86
|
+
tot app install --tenant <tenant> --env test --app .
|
|
90
87
|
```
|
|
91
88
|
Manage your test install at any time with `tot app update <installId>`,
|
|
92
89
|
`tot app rotate <installId>`, `tot app list`, and `tot app replay <deliveryId>`.
|
|
@@ -103,10 +100,10 @@ the preview stage without waiting on the store owner:
|
|
|
103
100
|
(see the Devkit's
|
|
104
101
|
[`webhooks-and-api.md`](https://github.com/tokenoftrust/storefront-devkit/blob/main/apps/private/webhooks-and-api.md)).
|
|
105
102
|
2. **Stage a `private_key_jwt` `production` candidate (`pending_approval`):**
|
|
106
|
-
POST to `POST /api/apps/admin/candidates` with `
|
|
107
|
-
|
|
103
|
+
POST to `POST /api/apps/admin/candidates` with `clientAuth: { method: "private_key_jwt", jwksUri: "https://..." }`
|
|
104
|
+
(or inline `jwks: { keys: [ <publicKeyJwk> ] }`). This records a `status: "pending_approval"`
|
|
108
105
|
production candidate with zero shared secrets to hand off.
|
|
109
106
|
3. **1-click Store Owner approval:**
|
|
110
107
|
The Store Owner reviews the requested scopes, webhook endpoint, and key metadata in
|
|
111
|
-
`/admin#integrations` and approves in 1 click (`POST /api/apps/admin/candidates/
|
|
112
|
-
activating the `production` install immediately.
|
|
108
|
+
`/admin#integrations` and approves in 1 click (`POST /api/apps/admin/candidates/decide` with
|
|
109
|
+
`decision: "approve"`), activating the `production` install immediately.
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* `recipes/fulfillment-shipstation`, `recipes/dropship-split-duoplane`).
|
|
15
15
|
*
|
|
16
16
|
* Online preview & production flow (see README.md):
|
|
17
|
-
* 1. `tot catalog seed --
|
|
18
|
-
* 2. `tot app install --
|
|
17
|
+
* 1. `tot catalog seed --preset=general|regulated-vape|multi-warehouse` (then `tot preview`)
|
|
18
|
+
* 2. `tot app install --tenant <tenant> --env test --app .`
|
|
19
19
|
* 3. `POST /api/apps/admin/test-orders` (synthetic preview orders bound to `test` install)
|
|
20
20
|
* 4. `POST /api/apps/admin/candidates` (`private_key_jwt`, `pending_approval`) ->
|
|
21
|
-
* 1-click Store Owner approval in `/admin#integrations`
|
|
21
|
+
* 1-click Store Owner approval in `/admin#integrations` (`POST /api/apps/admin/candidates/decide`)
|
|
22
22
|
*/
|
|
23
23
|
import { createServer } from "node:http";
|
|
24
24
|
import { existsSync, readFileSync } from "node:fs";
|