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