@tokenoftrust/cli 4.10.0 → 4.11.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
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",
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* input; `agency-kit/tools/lib/fixtures/analytics-declarations.json` is run through both, so a
|
|
11
11
|
* drift on either side fails a test.
|
|
12
12
|
*
|
|
13
|
-
* Messages carry no value from the file — never an id, never a key's value
|
|
14
|
-
* and a fixed explanation, so a finding is safe to print, log or forward.
|
|
13
|
+
* Messages carry no value from the file — never an id, never a key's value, never an unrecognized
|
|
14
|
+
* key — only the field path and a fixed explanation, so a finding is safe to print, log or forward.
|
|
15
|
+
* An unrecognized key is anchored by its position among the rejected keys (`$property[0]`).
|
|
15
16
|
*
|
|
16
17
|
* Pure: callers pass the file's text. `packages/cli/src/analytics-declaration.mjs` is a
|
|
17
18
|
* byte-identical copy (a test pins it).
|
|
@@ -77,6 +78,17 @@ function isPlainObject(value) {
|
|
|
77
78
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
/**
|
|
82
|
+
* The anchor for the `ordinal`-th rejected key of an object. A rejected key is untrusted text, so
|
|
83
|
+
* the path names its position among the rejected keys, never the key.
|
|
84
|
+
* @param {string} base
|
|
85
|
+
* @param {number} ordinal
|
|
86
|
+
*/
|
|
87
|
+
function rejectedKeyPath(base, ordinal) {
|
|
88
|
+
const anchor = `$property[${ordinal}]`;
|
|
89
|
+
return base ? `${base}.${anchor}` : anchor;
|
|
90
|
+
}
|
|
91
|
+
|
|
80
92
|
/**
|
|
81
93
|
* @param {Record<string, unknown>} obj
|
|
82
94
|
* @param {readonly string[]} allowed
|
|
@@ -84,9 +96,11 @@ function isPlainObject(value) {
|
|
|
84
96
|
* @param {AnalyticsViolation[]} out
|
|
85
97
|
*/
|
|
86
98
|
function unknownKeys(obj, allowed, base, out) {
|
|
99
|
+
let ordinal = 0;
|
|
87
100
|
for (const key of Object.keys(obj)) {
|
|
88
101
|
if (allowed.includes(key) || ANNOTATION_KEYS.includes(key)) continue;
|
|
89
|
-
out.push({ path: base
|
|
102
|
+
out.push({ path: rejectedKeyPath(base, ordinal), code: "unknown_field" });
|
|
103
|
+
ordinal += 1;
|
|
90
104
|
}
|
|
91
105
|
}
|
|
92
106
|
|
|
@@ -100,12 +114,14 @@ function unknownKeys(obj, allowed, base, out) {
|
|
|
100
114
|
function stageIdViolations(ids, adapter, base, out) {
|
|
101
115
|
/** @type {Map<string, string[]>} */
|
|
102
116
|
const valid = new Map();
|
|
117
|
+
let rejectedStages = 0;
|
|
103
118
|
for (const [stage, raw] of Object.entries(ids)) {
|
|
104
|
-
const at = `${base}.ids.${stage}`;
|
|
105
119
|
if (!ANALYTICS_STAGES.includes(stage)) {
|
|
106
|
-
out.push({ path:
|
|
120
|
+
out.push({ path: rejectedKeyPath(`${base}.ids`, rejectedStages), code: "unknown_enum" });
|
|
121
|
+
rejectedStages += 1;
|
|
107
122
|
continue;
|
|
108
123
|
}
|
|
124
|
+
const at = `${base}.ids.${stage}`;
|
|
109
125
|
if (!Array.isArray(raw)) {
|
|
110
126
|
out.push({ path: at, code: "type" });
|
|
111
127
|
continue;
|