@arcforges/api-client 1.0.0-ci.19.1 → 1.0.0-ci.201.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/NOTICE +57 -5
- package/README.md +9 -2
- package/build-identity.json +192 -0
- package/contracts.binpb +0 -0
- package/dist/gen/http.d.ts +10 -0
- package/dist/gen/http.js +13 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +20 -2
- package/dist/shapes/gen/AndroidUpdate.d.ts +41 -0
- package/dist/shapes/gen/AndroidUpdate.js +620 -0
- package/dist/shapes/gen/CatalogIndex.d.ts +49 -0
- package/dist/shapes/gen/CatalogIndex.js +703 -0
- package/dist/shapes/gen/CatalogRevocations.d.ts +46 -0
- package/dist/shapes/gen/CatalogRevocations.js +647 -0
- package/dist/shapes/gen/DeclarativePanel.d.ts +154 -0
- package/dist/shapes/gen/DeclarativePanel.js +2988 -0
- package/dist/shapes/gen/ExtensionManifest.d.ts +278 -0
- package/dist/shapes/gen/ExtensionManifest.js +3974 -0
- package/dist/shapes/gen/ExtensionWorkflow.d.ts +151 -0
- package/dist/shapes/gen/ExtensionWorkflow.js +2251 -0
- package/dist/shapes/gen/PackageInventory.d.ts +24 -0
- package/dist/shapes/gen/PackageInventory.js +327 -0
- package/dist/shapes/gen/PartReceipt.d.ts +21 -0
- package/dist/shapes/gen/PartReceipt.js +290 -0
- package/dist/shapes/gen/PolicyBody.d.ts +269 -0
- package/dist/shapes/gen/PolicyBody.js +4188 -0
- package/dist/shapes/gen/RealmDescriptor.d.ts +39 -0
- package/dist/shapes/gen/RealmDescriptor.js +627 -0
- package/package.json +15 -7
- package/sbom.cdx.json +17 -17
- package/schemas/public/http/v1/inventory.schema.json +49 -0
- package/schemas/public/http/v1/manifest.schema.json +1459 -0
- package/schemas/public/http/v1/panel.schema.json +963 -0
- package/schemas/public/http/v1/policy-body.schema.json +1376 -0
- package/schemas/public/http/v1/schema.json +30 -0
- package/schemas/public/http/v1/signed-formats.schema.json +748 -0
- package/schemas/public/http/v1/workflow.schema.json +715 -0
- package/schemas/public/proto/arcforges/events/v1/events.proto +14 -0
- package/schemas/public/proto/arcforges/foundation/v1/foundation.proto +373 -0
- package/schemas/public/proto/arcforges/hello/v1/hello.proto +23 -0
- package/schemas/public/proto/arcforges/publicapi/v1/content.proto +767 -0
- package/schemas/public/proto/arcforges/publicapi/v1/descriptors.proto +27 -0
- package/source.json +35 -10
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface CatalogRevocations {
|
|
2
|
+
schemaVersion: string;
|
|
3
|
+
realmId: string;
|
|
4
|
+
channel: string;
|
|
5
|
+
revision: string;
|
|
6
|
+
issuedAt: string;
|
|
7
|
+
expiresAt: string;
|
|
8
|
+
keyId: string;
|
|
9
|
+
bodyHash: string;
|
|
10
|
+
body: RevocationBody;
|
|
11
|
+
signature: string;
|
|
12
|
+
}
|
|
13
|
+
export type RevocationBody = RevocationEntries | RevocationShards;
|
|
14
|
+
export interface RevocationEntries {
|
|
15
|
+
entries: RevocationEntry[];
|
|
16
|
+
}
|
|
17
|
+
export interface RevocationEntry {
|
|
18
|
+
packageId: string;
|
|
19
|
+
version: string;
|
|
20
|
+
digest: string;
|
|
21
|
+
reason: string;
|
|
22
|
+
revokedAt: string;
|
|
23
|
+
}
|
|
24
|
+
export interface RevocationShards {
|
|
25
|
+
shards: RevocationShard[];
|
|
26
|
+
}
|
|
27
|
+
export interface RevocationShard {
|
|
28
|
+
url: string;
|
|
29
|
+
count: number;
|
|
30
|
+
sha256: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function isCatalogRevocations(value: unknown): value is CatalogRevocations;
|
|
33
|
+
/** The schema's declared UTF-8 document bound in bytes. */
|
|
34
|
+
export declare const catalogRevocationsJsonMaxBytes = 1048576;
|
|
35
|
+
/** Parses one strict CatalogRevocations document; refusal kinds match the C# codec. */
|
|
36
|
+
export declare function tryParseCatalogRevocationsJson(input: Uint8Array | string): {
|
|
37
|
+
ok: true;
|
|
38
|
+
value: CatalogRevocations;
|
|
39
|
+
} | {
|
|
40
|
+
ok: false;
|
|
41
|
+
failure: "tooLarge" | "malformed" | "invalid";
|
|
42
|
+
};
|
|
43
|
+
/** Parses one strict CatalogRevocations document or throws an error carrying the refusal kind. */
|
|
44
|
+
export declare function parseCatalogRevocationsJson(input: Uint8Array | string): CatalogRevocations;
|
|
45
|
+
/** Writes compact UTF-8 in schema property order and refuses output the schema rejects. */
|
|
46
|
+
export declare function serializeCatalogRevocationsJson(value: CatalogRevocations): Uint8Array;
|
|
@@ -0,0 +1,647 @@
|
|
|
1
|
+
export function isCatalogRevocations(value) { return check0(value); }
|
|
2
|
+
/** The schema's declared UTF-8 document bound in bytes. */
|
|
3
|
+
export const catalogRevocationsJsonMaxBytes = 1048576;
|
|
4
|
+
/** Parses one strict CatalogRevocations document; refusal kinds match the C# codec. */
|
|
5
|
+
export function tryParseCatalogRevocationsJson(input) {
|
|
6
|
+
const parsed = strictJson(input, 1048576);
|
|
7
|
+
if (!parsed.ok)
|
|
8
|
+
return parsed;
|
|
9
|
+
return isCatalogRevocations(parsed.value) ? { ok: true, value: parsed.value } : { ok: false, failure: "invalid" };
|
|
10
|
+
}
|
|
11
|
+
/** Parses one strict CatalogRevocations document or throws an error carrying the refusal kind. */
|
|
12
|
+
export function parseCatalogRevocationsJson(input) {
|
|
13
|
+
const result = tryParseCatalogRevocationsJson(input);
|
|
14
|
+
if (!result.ok)
|
|
15
|
+
throw Object.assign(new Error(`CatalogRevocations JSON refused: ${result.failure}.`), { failure: result.failure });
|
|
16
|
+
return result.value;
|
|
17
|
+
}
|
|
18
|
+
/** Writes compact UTF-8 in schema property order and refuses output the schema rejects. */
|
|
19
|
+
export function serializeCatalogRevocationsJson(value) {
|
|
20
|
+
const bytes = new TextEncoder().encode(JSON.stringify(orderCatalogRevocations(value)));
|
|
21
|
+
const result = tryParseCatalogRevocationsJson(bytes);
|
|
22
|
+
if (!result.ok)
|
|
23
|
+
throw Object.assign(new Error(`CatalogRevocations JSON refused: ${result.failure}.`), { failure: result.failure });
|
|
24
|
+
return bytes;
|
|
25
|
+
}
|
|
26
|
+
function orderCatalogRevocations(value) {
|
|
27
|
+
const out = {};
|
|
28
|
+
out["schemaVersion"] = value["schemaVersion"];
|
|
29
|
+
out["realmId"] = value["realmId"];
|
|
30
|
+
out["channel"] = value["channel"];
|
|
31
|
+
out["revision"] = value["revision"];
|
|
32
|
+
out["issuedAt"] = value["issuedAt"];
|
|
33
|
+
out["expiresAt"] = value["expiresAt"];
|
|
34
|
+
out["keyId"] = value["keyId"];
|
|
35
|
+
out["bodyHash"] = value["bodyHash"];
|
|
36
|
+
out["body"] = orderRevocationBody(value["body"]);
|
|
37
|
+
out["signature"] = value["signature"];
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
function orderRevocationBody(value) {
|
|
41
|
+
if (check10(value))
|
|
42
|
+
return orderRevocationEntries(value);
|
|
43
|
+
if (check18(value))
|
|
44
|
+
return orderRevocationShards(value);
|
|
45
|
+
throw new TypeError('Invalid closed union');
|
|
46
|
+
}
|
|
47
|
+
function orderRevocationEntries(value) {
|
|
48
|
+
const out = {};
|
|
49
|
+
out["entries"] = value["entries"].map(item => orderRevocationEntry(item));
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
function orderRevocationEntry(value) {
|
|
53
|
+
const out = {};
|
|
54
|
+
out["packageId"] = value["packageId"];
|
|
55
|
+
out["version"] = value["version"];
|
|
56
|
+
out["digest"] = value["digest"];
|
|
57
|
+
out["reason"] = value["reason"];
|
|
58
|
+
out["revokedAt"] = value["revokedAt"];
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
function orderRevocationShard(value) {
|
|
62
|
+
const out = {};
|
|
63
|
+
out["url"] = value["url"];
|
|
64
|
+
out["count"] = value["count"];
|
|
65
|
+
out["sha256"] = value["sha256"];
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
function orderRevocationShards(value) {
|
|
69
|
+
const out = {};
|
|
70
|
+
out["shards"] = value["shards"].map(item => orderRevocationShard(item));
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
function check0(value) {
|
|
74
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
75
|
+
return false;
|
|
76
|
+
const object = value;
|
|
77
|
+
for (const key of Object.keys(object)) {
|
|
78
|
+
switch (key) {
|
|
79
|
+
case "schemaVersion":
|
|
80
|
+
if (!check1(object[key]))
|
|
81
|
+
return false;
|
|
82
|
+
break;
|
|
83
|
+
case "realmId":
|
|
84
|
+
if (!check2(object[key]))
|
|
85
|
+
return false;
|
|
86
|
+
break;
|
|
87
|
+
case "channel":
|
|
88
|
+
if (!check3(object[key]))
|
|
89
|
+
return false;
|
|
90
|
+
break;
|
|
91
|
+
case "revision":
|
|
92
|
+
if (!check4(object[key]))
|
|
93
|
+
return false;
|
|
94
|
+
break;
|
|
95
|
+
case "issuedAt":
|
|
96
|
+
if (!check5(object[key]))
|
|
97
|
+
return false;
|
|
98
|
+
break;
|
|
99
|
+
case "expiresAt":
|
|
100
|
+
if (!check6(object[key]))
|
|
101
|
+
return false;
|
|
102
|
+
break;
|
|
103
|
+
case "keyId":
|
|
104
|
+
if (!check7(object[key]))
|
|
105
|
+
return false;
|
|
106
|
+
break;
|
|
107
|
+
case "bodyHash":
|
|
108
|
+
if (!check8(object[key]))
|
|
109
|
+
return false;
|
|
110
|
+
break;
|
|
111
|
+
case "body":
|
|
112
|
+
if (!check9(object[key]))
|
|
113
|
+
return false;
|
|
114
|
+
break;
|
|
115
|
+
case "signature":
|
|
116
|
+
if (!check24(object[key]))
|
|
117
|
+
return false;
|
|
118
|
+
break;
|
|
119
|
+
default: return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!Object.prototype.hasOwnProperty.call(object, "schemaVersion"))
|
|
123
|
+
return false;
|
|
124
|
+
if (!Object.prototype.hasOwnProperty.call(object, "realmId"))
|
|
125
|
+
return false;
|
|
126
|
+
if (!Object.prototype.hasOwnProperty.call(object, "channel"))
|
|
127
|
+
return false;
|
|
128
|
+
if (!Object.prototype.hasOwnProperty.call(object, "revision"))
|
|
129
|
+
return false;
|
|
130
|
+
if (!Object.prototype.hasOwnProperty.call(object, "issuedAt"))
|
|
131
|
+
return false;
|
|
132
|
+
if (!Object.prototype.hasOwnProperty.call(object, "expiresAt"))
|
|
133
|
+
return false;
|
|
134
|
+
if (!Object.prototype.hasOwnProperty.call(object, "keyId"))
|
|
135
|
+
return false;
|
|
136
|
+
if (!Object.prototype.hasOwnProperty.call(object, "bodyHash"))
|
|
137
|
+
return false;
|
|
138
|
+
if (!Object.prototype.hasOwnProperty.call(object, "body"))
|
|
139
|
+
return false;
|
|
140
|
+
if (!Object.prototype.hasOwnProperty.call(object, "signature"))
|
|
141
|
+
return false;
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
function check1(value) {
|
|
145
|
+
if (typeof value !== 'string' || !validText(value))
|
|
146
|
+
return false;
|
|
147
|
+
if (value !== "catalog-revocations.v1")
|
|
148
|
+
return false;
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
function check2(value) {
|
|
152
|
+
if (typeof value !== 'string' || !validText(value))
|
|
153
|
+
return false;
|
|
154
|
+
if ([...value].length < 1)
|
|
155
|
+
return false;
|
|
156
|
+
if ([...value].length > 36)
|
|
157
|
+
return false;
|
|
158
|
+
if ((new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", 'u')).exec(value)?.[0] !== value)
|
|
159
|
+
return false;
|
|
160
|
+
if (value === '00000000-0000-0000-0000-000000000000')
|
|
161
|
+
return false;
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
function check3(value) {
|
|
165
|
+
if (typeof value !== 'string' || !validText(value))
|
|
166
|
+
return false;
|
|
167
|
+
if ([...value].length < 1)
|
|
168
|
+
return false;
|
|
169
|
+
if ([...value].length > 128)
|
|
170
|
+
return false;
|
|
171
|
+
if ((new RegExp("^[A-Za-z0-9][A-Za-z0-9._-]*$", 'u')).exec(value)?.[0] !== value)
|
|
172
|
+
return false;
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
function check4(value) {
|
|
176
|
+
if (typeof value !== 'string' || !validText(value))
|
|
177
|
+
return false;
|
|
178
|
+
if ([...value].length < 1)
|
|
179
|
+
return false;
|
|
180
|
+
if ([...value].length > 20)
|
|
181
|
+
return false;
|
|
182
|
+
if ((new RegExp("^(0|[1-9][0-9]*)$", 'u')).exec(value)?.[0] !== value)
|
|
183
|
+
return false;
|
|
184
|
+
if (BigInt(value) > 18446744073709551615n)
|
|
185
|
+
return false;
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
function check5(value) {
|
|
189
|
+
if (typeof value !== 'string' || !validText(value))
|
|
190
|
+
return false;
|
|
191
|
+
if ([...value].length < 1)
|
|
192
|
+
return false;
|
|
193
|
+
if ([...value].length > 32)
|
|
194
|
+
return false;
|
|
195
|
+
if ((new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.[0-9]{1,6})?Z$", 'u')).exec(value)?.[0] !== value)
|
|
196
|
+
return false;
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
function check6(value) {
|
|
200
|
+
if (typeof value !== 'string' || !validText(value))
|
|
201
|
+
return false;
|
|
202
|
+
if ([...value].length < 1)
|
|
203
|
+
return false;
|
|
204
|
+
if ([...value].length > 32)
|
|
205
|
+
return false;
|
|
206
|
+
if ((new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.[0-9]{1,6})?Z$", 'u')).exec(value)?.[0] !== value)
|
|
207
|
+
return false;
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
function check7(value) {
|
|
211
|
+
if (typeof value !== 'string' || !validText(value))
|
|
212
|
+
return false;
|
|
213
|
+
if ([...value].length < 1)
|
|
214
|
+
return false;
|
|
215
|
+
if ([...value].length > 128)
|
|
216
|
+
return false;
|
|
217
|
+
if ((new RegExp("^[A-Za-z0-9][A-Za-z0-9._-]*$", 'u')).exec(value)?.[0] !== value)
|
|
218
|
+
return false;
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
function check8(value) {
|
|
222
|
+
if (typeof value !== 'string' || !validText(value))
|
|
223
|
+
return false;
|
|
224
|
+
if ([...value].length < 1)
|
|
225
|
+
return false;
|
|
226
|
+
if ([...value].length > 64)
|
|
227
|
+
return false;
|
|
228
|
+
if ((new RegExp("^[0-9a-f]{64}$", 'u')).exec(value)?.[0] !== value)
|
|
229
|
+
return false;
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
function check9(value) {
|
|
233
|
+
if ((check10(value) ? 1 : 0) + (check18(value) ? 1 : 0) !== 1)
|
|
234
|
+
return false;
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
function check10(value) {
|
|
238
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
239
|
+
return false;
|
|
240
|
+
const object = value;
|
|
241
|
+
for (const key of Object.keys(object)) {
|
|
242
|
+
switch (key) {
|
|
243
|
+
case "entries":
|
|
244
|
+
if (!check11(object[key]))
|
|
245
|
+
return false;
|
|
246
|
+
break;
|
|
247
|
+
default: return false;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (!Object.prototype.hasOwnProperty.call(object, "entries"))
|
|
251
|
+
return false;
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
function check11(value) {
|
|
255
|
+
if (!Array.isArray(value))
|
|
256
|
+
return false;
|
|
257
|
+
if (value.length < 0)
|
|
258
|
+
return false;
|
|
259
|
+
if (value.length > 1000)
|
|
260
|
+
return false;
|
|
261
|
+
if (!value.every(item => check12(item)))
|
|
262
|
+
return false;
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
function check12(value) {
|
|
266
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
267
|
+
return false;
|
|
268
|
+
const object = value;
|
|
269
|
+
for (const key of Object.keys(object)) {
|
|
270
|
+
switch (key) {
|
|
271
|
+
case "packageId":
|
|
272
|
+
if (!check13(object[key]))
|
|
273
|
+
return false;
|
|
274
|
+
break;
|
|
275
|
+
case "version":
|
|
276
|
+
if (!check14(object[key]))
|
|
277
|
+
return false;
|
|
278
|
+
break;
|
|
279
|
+
case "digest":
|
|
280
|
+
if (!check15(object[key]))
|
|
281
|
+
return false;
|
|
282
|
+
break;
|
|
283
|
+
case "reason":
|
|
284
|
+
if (!check16(object[key]))
|
|
285
|
+
return false;
|
|
286
|
+
break;
|
|
287
|
+
case "revokedAt":
|
|
288
|
+
if (!check17(object[key]))
|
|
289
|
+
return false;
|
|
290
|
+
break;
|
|
291
|
+
default: return false;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (!Object.prototype.hasOwnProperty.call(object, "packageId"))
|
|
295
|
+
return false;
|
|
296
|
+
if (!Object.prototype.hasOwnProperty.call(object, "version"))
|
|
297
|
+
return false;
|
|
298
|
+
if (!Object.prototype.hasOwnProperty.call(object, "digest"))
|
|
299
|
+
return false;
|
|
300
|
+
if (!Object.prototype.hasOwnProperty.call(object, "reason"))
|
|
301
|
+
return false;
|
|
302
|
+
if (!Object.prototype.hasOwnProperty.call(object, "revokedAt"))
|
|
303
|
+
return false;
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
function check13(value) {
|
|
307
|
+
if (typeof value !== 'string' || !validText(value))
|
|
308
|
+
return false;
|
|
309
|
+
if ([...value].length < 1)
|
|
310
|
+
return false;
|
|
311
|
+
if ([...value].length > 128)
|
|
312
|
+
return false;
|
|
313
|
+
if ((new RegExp("^[A-Za-z0-9][A-Za-z0-9._-]*$", 'u')).exec(value)?.[0] !== value)
|
|
314
|
+
return false;
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
function check14(value) {
|
|
318
|
+
if (typeof value !== 'string' || !validText(value))
|
|
319
|
+
return false;
|
|
320
|
+
if ([...value].length < 1)
|
|
321
|
+
return false;
|
|
322
|
+
if ([...value].length > 128)
|
|
323
|
+
return false;
|
|
324
|
+
if ((new RegExp("^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$", 'u')).exec(value)?.[0] !== value)
|
|
325
|
+
return false;
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
function check15(value) {
|
|
329
|
+
if (typeof value !== 'string' || !validText(value))
|
|
330
|
+
return false;
|
|
331
|
+
if ([...value].length < 1)
|
|
332
|
+
return false;
|
|
333
|
+
if ([...value].length > 64)
|
|
334
|
+
return false;
|
|
335
|
+
if ((new RegExp("^[0-9a-f]{64}$", 'u')).exec(value)?.[0] !== value)
|
|
336
|
+
return false;
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
function check16(value) {
|
|
340
|
+
if (typeof value !== 'string' || !validText(value))
|
|
341
|
+
return false;
|
|
342
|
+
if ([...value].length < 1)
|
|
343
|
+
return false;
|
|
344
|
+
if ([...value].length > 1024)
|
|
345
|
+
return false;
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
function check17(value) {
|
|
349
|
+
if (typeof value !== 'string' || !validText(value))
|
|
350
|
+
return false;
|
|
351
|
+
if ([...value].length < 1)
|
|
352
|
+
return false;
|
|
353
|
+
if ([...value].length > 32)
|
|
354
|
+
return false;
|
|
355
|
+
if ((new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.[0-9]{1,6})?Z$", 'u')).exec(value)?.[0] !== value)
|
|
356
|
+
return false;
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
function check18(value) {
|
|
360
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
361
|
+
return false;
|
|
362
|
+
const object = value;
|
|
363
|
+
for (const key of Object.keys(object)) {
|
|
364
|
+
switch (key) {
|
|
365
|
+
case "shards":
|
|
366
|
+
if (!check19(object[key]))
|
|
367
|
+
return false;
|
|
368
|
+
break;
|
|
369
|
+
default: return false;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (!Object.prototype.hasOwnProperty.call(object, "shards"))
|
|
373
|
+
return false;
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
function check19(value) {
|
|
377
|
+
if (!Array.isArray(value))
|
|
378
|
+
return false;
|
|
379
|
+
if (value.length < 1)
|
|
380
|
+
return false;
|
|
381
|
+
if (value.length > 1000)
|
|
382
|
+
return false;
|
|
383
|
+
if (!value.every(item => check20(item)))
|
|
384
|
+
return false;
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
387
|
+
function check20(value) {
|
|
388
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
389
|
+
return false;
|
|
390
|
+
const object = value;
|
|
391
|
+
for (const key of Object.keys(object)) {
|
|
392
|
+
switch (key) {
|
|
393
|
+
case "url":
|
|
394
|
+
if (!check21(object[key]))
|
|
395
|
+
return false;
|
|
396
|
+
break;
|
|
397
|
+
case "count":
|
|
398
|
+
if (!check22(object[key]))
|
|
399
|
+
return false;
|
|
400
|
+
break;
|
|
401
|
+
case "sha256":
|
|
402
|
+
if (!check23(object[key]))
|
|
403
|
+
return false;
|
|
404
|
+
break;
|
|
405
|
+
default: return false;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (!Object.prototype.hasOwnProperty.call(object, "url"))
|
|
409
|
+
return false;
|
|
410
|
+
if (!Object.prototype.hasOwnProperty.call(object, "count"))
|
|
411
|
+
return false;
|
|
412
|
+
if (!Object.prototype.hasOwnProperty.call(object, "sha256"))
|
|
413
|
+
return false;
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
function check21(value) {
|
|
417
|
+
if (typeof value !== 'string' || !validText(value))
|
|
418
|
+
return false;
|
|
419
|
+
if ([...value].length < 1)
|
|
420
|
+
return false;
|
|
421
|
+
if ([...value].length > 2048)
|
|
422
|
+
return false;
|
|
423
|
+
if ((new RegExp("^https://[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*(?::(?:6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}))?(/[^\\s#]*)?$", 'u')).exec(value)?.[0] !== value)
|
|
424
|
+
return false;
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
function check22(value) {
|
|
428
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value))
|
|
429
|
+
return false;
|
|
430
|
+
if (value < 0)
|
|
431
|
+
return false;
|
|
432
|
+
if (value > 1000)
|
|
433
|
+
return false;
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
function check23(value) {
|
|
437
|
+
if (typeof value !== 'string' || !validText(value))
|
|
438
|
+
return false;
|
|
439
|
+
if ([...value].length < 1)
|
|
440
|
+
return false;
|
|
441
|
+
if ([...value].length > 64)
|
|
442
|
+
return false;
|
|
443
|
+
if ((new RegExp("^[0-9a-f]{64}$", 'u')).exec(value)?.[0] !== value)
|
|
444
|
+
return false;
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
function check24(value) {
|
|
448
|
+
if (typeof value !== 'string' || !validText(value))
|
|
449
|
+
return false;
|
|
450
|
+
if ([...value].length < 1)
|
|
451
|
+
return false;
|
|
452
|
+
if ([...value].length > 86)
|
|
453
|
+
return false;
|
|
454
|
+
if ((new RegExp("^[A-Za-z0-9_-]{85}[AQgw]$", 'u')).exec(value)?.[0] !== value)
|
|
455
|
+
return false;
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
/** Strict UTF-8 JSON: no BOM, comments, trailing commas or duplicate properties; depth <= 32; integer lexemes only. */
|
|
459
|
+
function strictJson(input, maxBytes) {
|
|
460
|
+
let text;
|
|
461
|
+
if (typeof input === "string") {
|
|
462
|
+
if (!validText(input))
|
|
463
|
+
return { ok: false, failure: "malformed" };
|
|
464
|
+
if (new TextEncoder().encode(input).byteLength > maxBytes)
|
|
465
|
+
return { ok: false, failure: "tooLarge" };
|
|
466
|
+
text = input;
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
if (input.byteLength > maxBytes)
|
|
470
|
+
return { ok: false, failure: "tooLarge" };
|
|
471
|
+
try {
|
|
472
|
+
text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(input);
|
|
473
|
+
}
|
|
474
|
+
catch {
|
|
475
|
+
return { ok: false, failure: "malformed" };
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
try {
|
|
479
|
+
return { ok: true, value: new StrictJsonReader(text).document() };
|
|
480
|
+
}
|
|
481
|
+
catch {
|
|
482
|
+
return { ok: false, failure: "malformed" };
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
class StrictJsonReader {
|
|
486
|
+
text;
|
|
487
|
+
index = 0;
|
|
488
|
+
constructor(text) {
|
|
489
|
+
this.text = text;
|
|
490
|
+
}
|
|
491
|
+
document() {
|
|
492
|
+
this.space();
|
|
493
|
+
const value = this.value(0);
|
|
494
|
+
this.space();
|
|
495
|
+
if (this.index !== this.text.length)
|
|
496
|
+
throw new SyntaxError("Trailing JSON content");
|
|
497
|
+
return value;
|
|
498
|
+
}
|
|
499
|
+
value(depth) {
|
|
500
|
+
switch (this.text[this.index]) {
|
|
501
|
+
case "{": return this.object(depth + 1);
|
|
502
|
+
case "[": return this.array(depth + 1);
|
|
503
|
+
case '"': return this.string();
|
|
504
|
+
case "t": return this.literal("true", true);
|
|
505
|
+
case "f": return this.literal("false", false);
|
|
506
|
+
case "n": return this.literal("null", null);
|
|
507
|
+
default: return this.number();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
object(depth) {
|
|
511
|
+
if (depth > 32)
|
|
512
|
+
throw new SyntaxError("JSON depth exceeded");
|
|
513
|
+
this.index++;
|
|
514
|
+
const out = {};
|
|
515
|
+
const keys = new Set();
|
|
516
|
+
this.space();
|
|
517
|
+
if (this.text[this.index] === "}") {
|
|
518
|
+
this.index++;
|
|
519
|
+
return out;
|
|
520
|
+
}
|
|
521
|
+
for (;;) {
|
|
522
|
+
this.space();
|
|
523
|
+
if (this.text[this.index] !== '"')
|
|
524
|
+
throw new SyntaxError("Expected property name");
|
|
525
|
+
const key = this.string();
|
|
526
|
+
if (keys.has(key))
|
|
527
|
+
throw new SyntaxError("Duplicate JSON property");
|
|
528
|
+
keys.add(key);
|
|
529
|
+
this.space();
|
|
530
|
+
if (this.text[this.index++] !== ":")
|
|
531
|
+
throw new SyntaxError("Expected colon");
|
|
532
|
+
this.space();
|
|
533
|
+
// defineProperty keeps names such as __proto__ as ordinary own properties.
|
|
534
|
+
Object.defineProperty(out, key, { value: this.value(depth), enumerable: true, writable: true, configurable: true });
|
|
535
|
+
this.space();
|
|
536
|
+
const next = this.text[this.index++];
|
|
537
|
+
if (next === "}")
|
|
538
|
+
return out;
|
|
539
|
+
if (next !== ",")
|
|
540
|
+
throw new SyntaxError("Expected comma");
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
array(depth) {
|
|
544
|
+
if (depth > 32)
|
|
545
|
+
throw new SyntaxError("JSON depth exceeded");
|
|
546
|
+
this.index++;
|
|
547
|
+
const out = [];
|
|
548
|
+
this.space();
|
|
549
|
+
if (this.text[this.index] === "]") {
|
|
550
|
+
this.index++;
|
|
551
|
+
return out;
|
|
552
|
+
}
|
|
553
|
+
for (;;) {
|
|
554
|
+
this.space();
|
|
555
|
+
out.push(this.value(depth));
|
|
556
|
+
this.space();
|
|
557
|
+
const next = this.text[this.index++];
|
|
558
|
+
if (next === "]")
|
|
559
|
+
return out;
|
|
560
|
+
if (next !== ",")
|
|
561
|
+
throw new SyntaxError("Expected comma");
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
string() {
|
|
565
|
+
this.index++;
|
|
566
|
+
let out = "";
|
|
567
|
+
for (;;) {
|
|
568
|
+
const c = this.text[this.index++];
|
|
569
|
+
if (c === undefined)
|
|
570
|
+
throw new SyntaxError("Unterminated string");
|
|
571
|
+
if (c === '"')
|
|
572
|
+
break;
|
|
573
|
+
if (c < " ")
|
|
574
|
+
throw new SyntaxError("Unescaped control character");
|
|
575
|
+
if (c !== "\\") {
|
|
576
|
+
out += c;
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
const e = this.text[this.index++];
|
|
580
|
+
const simple = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: "\t" };
|
|
581
|
+
if (e !== undefined && e in simple) {
|
|
582
|
+
out += simple[e];
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
if (e !== "u" || !/^[0-9a-fA-F]{4}$/.test(this.text.slice(this.index, this.index + 4)))
|
|
586
|
+
throw new SyntaxError("Invalid escape");
|
|
587
|
+
out += String.fromCharCode(parseInt(this.text.slice(this.index, this.index + 4), 16));
|
|
588
|
+
this.index += 4;
|
|
589
|
+
}
|
|
590
|
+
if (!validText(out))
|
|
591
|
+
throw new SyntaxError("Lone surrogate escape");
|
|
592
|
+
return out;
|
|
593
|
+
}
|
|
594
|
+
number() {
|
|
595
|
+
const match = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/y;
|
|
596
|
+
match.lastIndex = this.index;
|
|
597
|
+
const found = match.exec(this.text);
|
|
598
|
+
if (found === null)
|
|
599
|
+
throw new SyntaxError("Invalid JSON value");
|
|
600
|
+
this.index = match.lastIndex;
|
|
601
|
+
// Selected schemas have no fractional numbers; fraction/exponent lexemes never satisfy an integer.
|
|
602
|
+
return found[1] !== undefined || found[2] !== undefined ? Number.NaN : Number(found[0]);
|
|
603
|
+
}
|
|
604
|
+
literal(word, value) {
|
|
605
|
+
if (this.text.slice(this.index, this.index + word.length) !== word)
|
|
606
|
+
throw new SyntaxError("Invalid JSON literal");
|
|
607
|
+
this.index += word.length;
|
|
608
|
+
return value;
|
|
609
|
+
}
|
|
610
|
+
space() {
|
|
611
|
+
while (this.text[this.index] === " " || this.text[this.index] === "\t" || this.text[this.index] === "\n" || this.text[this.index] === "\r")
|
|
612
|
+
this.index++;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function validText(value) {
|
|
616
|
+
for (const scalar of value) {
|
|
617
|
+
const point = scalar.codePointAt(0);
|
|
618
|
+
if (point >= 0xd800 && point <= 0xdfff)
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
return true;
|
|
622
|
+
}
|
|
623
|
+
function inventoryRules(value) {
|
|
624
|
+
const files = value.files;
|
|
625
|
+
const seen = new Set();
|
|
626
|
+
let previous;
|
|
627
|
+
let total = 0n;
|
|
628
|
+
for (const file of files) {
|
|
629
|
+
const path = file.path;
|
|
630
|
+
const folded = path.toUpperCase();
|
|
631
|
+
if (path.length === 0 || folded === 'INVENTORY.JSON' || folded === 'SIGNATURE.JSON' || seen.has(folded) || (previous !== undefined && previous >= path))
|
|
632
|
+
return false;
|
|
633
|
+
for (const segment of path.split('/')) {
|
|
634
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(segment) || segment === '.' || segment === '..' || segment.endsWith('.') || /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(segment))
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
const size = BigInt(file.size);
|
|
638
|
+
if (size > 134217728n)
|
|
639
|
+
return false;
|
|
640
|
+
total += size;
|
|
641
|
+
if (total > 1073741824n)
|
|
642
|
+
return false;
|
|
643
|
+
seen.add(folded);
|
|
644
|
+
previous = path;
|
|
645
|
+
}
|
|
646
|
+
return files.some(file => file.path === 'manifest.json');
|
|
647
|
+
}
|