@arcforges/api-client 1.0.0-ci.31.1 → 1.0.0-ci.317.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 (100) hide show
  1. package/NOTICE +57 -5
  2. package/README.md +9 -2
  3. package/build-identity.json +270 -0
  4. package/contracts.binpb +0 -0
  5. package/dist/gen/http.d.ts +31 -0
  6. package/dist/gen/http.js +34 -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/BrowserAuthChallenge.d.ts +35 -0
  12. package/dist/shapes/gen/BrowserAuthChallenge.js +531 -0
  13. package/dist/shapes/gen/BrowserBeginAuthenticationRequest.d.ts +28 -0
  14. package/dist/shapes/gen/BrowserBeginAuthenticationRequest.js +384 -0
  15. package/dist/shapes/gen/BrowserBeginRecoveryRequest.d.ts +22 -0
  16. package/dist/shapes/gen/BrowserBeginRecoveryRequest.js +370 -0
  17. package/dist/shapes/gen/BrowserBeginStepUpRequest.d.ts +20 -0
  18. package/dist/shapes/gen/BrowserBeginStepUpRequest.js +279 -0
  19. package/dist/shapes/gen/BrowserBootstrapResponse.d.ts +37 -0
  20. package/dist/shapes/gen/BrowserBootstrapResponse.js +534 -0
  21. package/dist/shapes/gen/BrowserCompleteAuthenticationRequest.d.ts +45 -0
  22. package/dist/shapes/gen/BrowserCompleteAuthenticationRequest.js +564 -0
  23. package/dist/shapes/gen/BrowserCompleteEnrollmentRequest.d.ts +90 -0
  24. package/dist/shapes/gen/BrowserCompleteEnrollmentRequest.js +1145 -0
  25. package/dist/shapes/gen/BrowserCompleteRecoveryRequest.d.ts +22 -0
  26. package/dist/shapes/gen/BrowserCompleteRecoveryRequest.js +733 -0
  27. package/dist/shapes/gen/BrowserCompleteStepUpRequest.d.ts +20 -0
  28. package/dist/shapes/gen/BrowserCompleteStepUpRequest.js +564 -0
  29. package/dist/shapes/gen/BrowserOidcCallbackFailure.d.ts +20 -0
  30. package/dist/shapes/gen/BrowserOidcCallbackFailure.js +200 -0
  31. package/dist/shapes/gen/BrowserOidcCallbackSuccess.d.ts +19 -0
  32. package/dist/shapes/gen/BrowserOidcCallbackSuccess.js +185 -0
  33. package/dist/shapes/gen/BrowserReceipt.d.ts +20 -0
  34. package/dist/shapes/gen/BrowserReceipt.js +285 -0
  35. package/dist/shapes/gen/BrowserSessionRoutes.d.ts +17 -0
  36. package/dist/shapes/gen/BrowserSessionRoutes.js +13 -0
  37. package/dist/shapes/gen/BrowserSessionView.d.ts +25 -0
  38. package/dist/shapes/gen/BrowserSessionView.js +388 -0
  39. package/dist/shapes/gen/BrowserStepUpEvidence.d.ts +19 -0
  40. package/dist/shapes/gen/BrowserStepUpEvidence.js +266 -0
  41. package/dist/shapes/gen/CatalogIndex.d.ts +49 -0
  42. package/dist/shapes/gen/CatalogIndex.js +703 -0
  43. package/dist/shapes/gen/CatalogRevocations.d.ts +46 -0
  44. package/dist/shapes/gen/CatalogRevocations.js +647 -0
  45. package/dist/shapes/gen/DeclarativePanel.d.ts +154 -0
  46. package/dist/shapes/gen/DeclarativePanel.js +2988 -0
  47. package/dist/shapes/gen/ExtensionManifest.d.ts +278 -0
  48. package/dist/shapes/gen/ExtensionManifest.js +3974 -0
  49. package/dist/shapes/gen/ExtensionWorkflow.d.ts +151 -0
  50. package/dist/shapes/gen/ExtensionWorkflow.js +2251 -0
  51. package/dist/shapes/gen/NativeAuthRoutes.d.ts +17 -0
  52. package/dist/shapes/gen/NativeAuthRoutes.js +5 -0
  53. package/dist/shapes/gen/NativeAuthorizeCallbackFailure.d.ts +19 -0
  54. package/dist/shapes/gen/NativeAuthorizeCallbackFailure.js +185 -0
  55. package/dist/shapes/gen/NativeAuthorizeCallbackSuccess.d.ts +19 -0
  56. package/dist/shapes/gen/NativeAuthorizeCallbackSuccess.js +185 -0
  57. package/dist/shapes/gen/NativeAuthorizeRequest.d.ts +24 -0
  58. package/dist/shapes/gen/NativeAuthorizeRequest.js +271 -0
  59. package/dist/shapes/gen/NativeTokenRequest.d.ts +23 -0
  60. package/dist/shapes/gen/NativeTokenRequest.js +258 -0
  61. package/dist/shapes/gen/NativeTokenResponse.d.ts +40 -0
  62. package/dist/shapes/gen/NativeTokenResponse.js +572 -0
  63. package/dist/shapes/gen/PackageInventory.d.ts +24 -0
  64. package/dist/shapes/gen/PackageInventory.js +327 -0
  65. package/dist/shapes/gen/PartReceipt.d.ts +21 -0
  66. package/dist/shapes/gen/PartReceipt.js +290 -0
  67. package/dist/shapes/gen/PolicyBody.d.ts +269 -0
  68. package/dist/shapes/gen/PolicyBody.js +4188 -0
  69. package/dist/shapes/gen/RealmDescriptor.d.ts +39 -0
  70. package/dist/shapes/gen/RealmDescriptor.js +627 -0
  71. package/package.json +15 -7
  72. package/sbom.cdx.json +17 -17
  73. package/schemas/public/http/v1/browser.schema.json +1300 -0
  74. package/schemas/public/http/v1/inventory.schema.json +49 -0
  75. package/schemas/public/http/v1/manifest.schema.json +1459 -0
  76. package/schemas/public/http/v1/native-auth.schema.json +341 -0
  77. package/schemas/public/http/v1/panel.schema.json +963 -0
  78. package/schemas/public/http/v1/policy-body.schema.json +1376 -0
  79. package/schemas/public/http/v1/schema.json +30 -0
  80. package/schemas/public/http/v1/signed-formats.schema.json +748 -0
  81. package/schemas/public/http/v1/workflow.schema.json +715 -0
  82. package/schemas/public/proto/arcforges/catalog/v1/catalog.proto +204 -0
  83. package/schemas/public/proto/arcforges/events/v1/events.proto +343 -0
  84. package/schemas/public/proto/arcforges/foundation/v1/foundation.proto +384 -0
  85. package/schemas/public/proto/arcforges/hello/v1/hello.proto +23 -0
  86. package/schemas/public/proto/arcforges/publicapi/v1/application.proto +297 -0
  87. package/schemas/public/proto/arcforges/publicapi/v1/chat.proto +1507 -0
  88. package/schemas/public/proto/arcforges/publicapi/v1/commerce.proto +542 -0
  89. package/schemas/public/proto/arcforges/publicapi/v1/connector.proto +172 -0
  90. package/schemas/public/proto/arcforges/publicapi/v1/content.proto +813 -0
  91. package/schemas/public/proto/arcforges/publicapi/v1/descriptors.proto +27 -0
  92. package/schemas/public/proto/arcforges/publicapi/v1/export.proto +112 -0
  93. package/schemas/public/proto/arcforges/publicapi/v1/identity.proto +1350 -0
  94. package/schemas/public/proto/arcforges/publicapi/v1/inprocess-values.proto +134 -0
  95. package/schemas/public/proto/arcforges/publicapi/v1/scope.proto +81 -0
  96. package/schemas/public/proto/arcforges/publicapi/v1/support.proto +242 -0
  97. package/schemas/public/proto/arcforges/publicapi/v1/sync.proto +459 -0
  98. package/schemas/public/proto/arcforges/publicapi/v1/transfer.proto +190 -0
  99. package/schemas/public/proto/arcforges/simulation/v1/simulation.proto +457 -0
  100. package/source.json +50 -11
@@ -0,0 +1,370 @@
1
+ export function isBrowserBeginRecoveryRequest(value) { return check0(value); }
2
+ /** The schema's declared UTF-8 document bound in bytes. */
3
+ export const browserBeginRecoveryRequestJsonMaxBytes = 8192;
4
+ /** Parses one strict BrowserBeginRecoveryRequest document; refusal kinds match the C# codec. */
5
+ export function tryParseBrowserBeginRecoveryRequestJson(input) {
6
+ const parsed = strictJson(input, 8192);
7
+ if (!parsed.ok)
8
+ return parsed;
9
+ return isBrowserBeginRecoveryRequest(parsed.value) ? { ok: true, value: parsed.value } : { ok: false, failure: "invalid" };
10
+ }
11
+ /** Parses one strict BrowserBeginRecoveryRequest document or throws an error carrying the refusal kind. */
12
+ export function parseBrowserBeginRecoveryRequestJson(input) {
13
+ const result = tryParseBrowserBeginRecoveryRequestJson(input);
14
+ if (!result.ok)
15
+ throw Object.assign(new Error(`BrowserBeginRecoveryRequest 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 serializeBrowserBeginRecoveryRequestJson(value) {
20
+ const bytes = new TextEncoder().encode(JSON.stringify(orderBrowserBeginRecoveryRequest(value)));
21
+ const result = tryParseBrowserBeginRecoveryRequestJson(bytes);
22
+ if (!result.ok)
23
+ throw Object.assign(new Error(`BrowserBeginRecoveryRequest JSON refused: ${result.failure}.`), { failure: result.failure });
24
+ return bytes;
25
+ }
26
+ function orderBrowserBeginRecoveryRequest(value) {
27
+ const out = {};
28
+ if (value["email"] !== undefined)
29
+ out["email"] = value["email"];
30
+ out["method"] = value["method"];
31
+ if (value["accountHint"] !== undefined)
32
+ out["accountHint"] = value["accountHint"];
33
+ out["installation"] = orderBrowserInstallationClaim(value["installation"]);
34
+ return out;
35
+ }
36
+ function orderBrowserInstallationClaim(value) {
37
+ const out = {};
38
+ out["installationId"] = value["installationId"];
39
+ out["product"] = value["product"];
40
+ out["platform"] = value["platform"];
41
+ out["appVersion"] = value["appVersion"];
42
+ return out;
43
+ }
44
+ function check0(value) {
45
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
46
+ return false;
47
+ const object = value;
48
+ for (const key of Object.keys(object)) {
49
+ switch (key) {
50
+ case "email":
51
+ if (!check1(object[key]))
52
+ return false;
53
+ break;
54
+ case "method":
55
+ if (!check2(object[key]))
56
+ return false;
57
+ break;
58
+ case "accountHint":
59
+ if (!check3(object[key]))
60
+ return false;
61
+ break;
62
+ case "installation":
63
+ if (!check4(object[key]))
64
+ return false;
65
+ break;
66
+ default: return false;
67
+ }
68
+ }
69
+ if (!Object.prototype.hasOwnProperty.call(object, "method"))
70
+ return false;
71
+ if (!Object.prototype.hasOwnProperty.call(object, "installation"))
72
+ return false;
73
+ return true;
74
+ }
75
+ function check1(value) {
76
+ if (typeof value !== 'string' || !validText(value))
77
+ return false;
78
+ if ([...value].length < 3)
79
+ return false;
80
+ if ([...value].length > 320)
81
+ return false;
82
+ if ((new RegExp("^[\\x21-\\x3F\\x41-\\x7E]+@[\\x21-\\x3F\\x41-\\x7E]+$", 'u')).exec(value)?.[0] !== value)
83
+ return false;
84
+ return true;
85
+ }
86
+ function check2(value) {
87
+ if (typeof value !== 'string' || !validText(value))
88
+ return false;
89
+ if (value !== "emailCode" && value !== "recoveryCode" && value !== "passkey" && value !== "adminGrant")
90
+ return false;
91
+ return true;
92
+ }
93
+ function check3(value) {
94
+ if (typeof value !== 'string' || !validText(value))
95
+ return false;
96
+ if ([...value].length < 1)
97
+ return false;
98
+ if ([...value].length > 128)
99
+ return false;
100
+ if ((new RegExp("^[A-Za-z0-9._:/-]{1,128}$", 'u')).exec(value)?.[0] !== value)
101
+ return false;
102
+ return true;
103
+ }
104
+ function check4(value) {
105
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
106
+ return false;
107
+ const object = value;
108
+ for (const key of Object.keys(object)) {
109
+ switch (key) {
110
+ case "installationId":
111
+ if (!check5(object[key]))
112
+ return false;
113
+ break;
114
+ case "product":
115
+ if (!check6(object[key]))
116
+ return false;
117
+ break;
118
+ case "platform":
119
+ if (!check7(object[key]))
120
+ return false;
121
+ break;
122
+ case "appVersion":
123
+ if (!check8(object[key]))
124
+ return false;
125
+ break;
126
+ default: return false;
127
+ }
128
+ }
129
+ if (!Object.prototype.hasOwnProperty.call(object, "installationId"))
130
+ return false;
131
+ if (!Object.prototype.hasOwnProperty.call(object, "product"))
132
+ return false;
133
+ if (!Object.prototype.hasOwnProperty.call(object, "platform"))
134
+ return false;
135
+ if (!Object.prototype.hasOwnProperty.call(object, "appVersion"))
136
+ return false;
137
+ return true;
138
+ }
139
+ function check5(value) {
140
+ if (typeof value !== 'string' || !validText(value))
141
+ return false;
142
+ if ([...value].length < 36)
143
+ return false;
144
+ if ([...value].length > 36)
145
+ return false;
146
+ 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)
147
+ return false;
148
+ if (value === '00000000-0000-0000-0000-000000000000')
149
+ return false;
150
+ return true;
151
+ }
152
+ function check6(value) {
153
+ if (typeof value !== 'string' || !validText(value))
154
+ return false;
155
+ if (value !== "arcscope" && value !== "companion")
156
+ return false;
157
+ return true;
158
+ }
159
+ function check7(value) {
160
+ if (typeof value !== 'string' || !validText(value))
161
+ return false;
162
+ if ([...value].length < 1)
163
+ return false;
164
+ if ([...value].length > 128)
165
+ return false;
166
+ if ((new RegExp("^[A-Za-z0-9._:/-]{1,128}$", 'u')).exec(value)?.[0] !== value)
167
+ return false;
168
+ return true;
169
+ }
170
+ function check8(value) {
171
+ if (typeof value !== 'string' || !validText(value))
172
+ return false;
173
+ if ([...value].length < 1)
174
+ return false;
175
+ if ([...value].length > 128)
176
+ return false;
177
+ if ((new RegExp("^[A-Za-z0-9._:/-]{1,128}$", 'u')).exec(value)?.[0] !== value)
178
+ return false;
179
+ return true;
180
+ }
181
+ /** Strict UTF-8 JSON: no BOM, comments, trailing commas or duplicate properties; depth <= 32; integer lexemes only. */
182
+ function strictJson(input, maxBytes) {
183
+ let text;
184
+ if (typeof input === "string") {
185
+ if (!validText(input))
186
+ return { ok: false, failure: "malformed" };
187
+ if (new TextEncoder().encode(input).byteLength > maxBytes)
188
+ return { ok: false, failure: "tooLarge" };
189
+ text = input;
190
+ }
191
+ else {
192
+ if (input.byteLength > maxBytes)
193
+ return { ok: false, failure: "tooLarge" };
194
+ try {
195
+ text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(input);
196
+ }
197
+ catch {
198
+ return { ok: false, failure: "malformed" };
199
+ }
200
+ }
201
+ try {
202
+ return { ok: true, value: new StrictJsonReader(text).document() };
203
+ }
204
+ catch {
205
+ return { ok: false, failure: "malformed" };
206
+ }
207
+ }
208
+ class StrictJsonReader {
209
+ text;
210
+ index = 0;
211
+ constructor(text) {
212
+ this.text = text;
213
+ }
214
+ document() {
215
+ this.space();
216
+ const value = this.value(0);
217
+ this.space();
218
+ if (this.index !== this.text.length)
219
+ throw new SyntaxError("Trailing JSON content");
220
+ return value;
221
+ }
222
+ value(depth) {
223
+ switch (this.text[this.index]) {
224
+ case "{": return this.object(depth + 1);
225
+ case "[": return this.array(depth + 1);
226
+ case '"': return this.string();
227
+ case "t": return this.literal("true", true);
228
+ case "f": return this.literal("false", false);
229
+ case "n": return this.literal("null", null);
230
+ default: return this.number();
231
+ }
232
+ }
233
+ object(depth) {
234
+ if (depth > 32)
235
+ throw new SyntaxError("JSON depth exceeded");
236
+ this.index++;
237
+ const out = {};
238
+ const keys = new Set();
239
+ this.space();
240
+ if (this.text[this.index] === "}") {
241
+ this.index++;
242
+ return out;
243
+ }
244
+ for (;;) {
245
+ this.space();
246
+ if (this.text[this.index] !== '"')
247
+ throw new SyntaxError("Expected property name");
248
+ const key = this.string();
249
+ if (keys.has(key))
250
+ throw new SyntaxError("Duplicate JSON property");
251
+ keys.add(key);
252
+ this.space();
253
+ if (this.text[this.index++] !== ":")
254
+ throw new SyntaxError("Expected colon");
255
+ this.space();
256
+ // defineProperty keeps names such as __proto__ as ordinary own properties.
257
+ Object.defineProperty(out, key, { value: this.value(depth), enumerable: true, writable: true, configurable: true });
258
+ this.space();
259
+ const next = this.text[this.index++];
260
+ if (next === "}")
261
+ return out;
262
+ if (next !== ",")
263
+ throw new SyntaxError("Expected comma");
264
+ }
265
+ }
266
+ array(depth) {
267
+ if (depth > 32)
268
+ throw new SyntaxError("JSON depth exceeded");
269
+ this.index++;
270
+ const out = [];
271
+ this.space();
272
+ if (this.text[this.index] === "]") {
273
+ this.index++;
274
+ return out;
275
+ }
276
+ for (;;) {
277
+ this.space();
278
+ out.push(this.value(depth));
279
+ this.space();
280
+ const next = this.text[this.index++];
281
+ if (next === "]")
282
+ return out;
283
+ if (next !== ",")
284
+ throw new SyntaxError("Expected comma");
285
+ }
286
+ }
287
+ string() {
288
+ this.index++;
289
+ let out = "";
290
+ for (;;) {
291
+ const c = this.text[this.index++];
292
+ if (c === undefined)
293
+ throw new SyntaxError("Unterminated string");
294
+ if (c === '"')
295
+ break;
296
+ if (c < " ")
297
+ throw new SyntaxError("Unescaped control character");
298
+ if (c !== "\\") {
299
+ out += c;
300
+ continue;
301
+ }
302
+ const e = this.text[this.index++];
303
+ const simple = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: "\t" };
304
+ if (e !== undefined && e in simple) {
305
+ out += simple[e];
306
+ continue;
307
+ }
308
+ if (e !== "u" || !/^[0-9a-fA-F]{4}$/.test(this.text.slice(this.index, this.index + 4)))
309
+ throw new SyntaxError("Invalid escape");
310
+ out += String.fromCharCode(parseInt(this.text.slice(this.index, this.index + 4), 16));
311
+ this.index += 4;
312
+ }
313
+ if (!validText(out))
314
+ throw new SyntaxError("Lone surrogate escape");
315
+ return out;
316
+ }
317
+ number() {
318
+ const match = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/y;
319
+ match.lastIndex = this.index;
320
+ const found = match.exec(this.text);
321
+ if (found === null)
322
+ throw new SyntaxError("Invalid JSON value");
323
+ this.index = match.lastIndex;
324
+ // Selected schemas have no fractional numbers; fraction/exponent lexemes never satisfy an integer.
325
+ return found[1] !== undefined || found[2] !== undefined ? Number.NaN : Number(found[0]);
326
+ }
327
+ literal(word, value) {
328
+ if (this.text.slice(this.index, this.index + word.length) !== word)
329
+ throw new SyntaxError("Invalid JSON literal");
330
+ this.index += word.length;
331
+ return value;
332
+ }
333
+ space() {
334
+ while (this.text[this.index] === " " || this.text[this.index] === "\t" || this.text[this.index] === "\n" || this.text[this.index] === "\r")
335
+ this.index++;
336
+ }
337
+ }
338
+ function validText(value) {
339
+ for (const scalar of value) {
340
+ const point = scalar.codePointAt(0);
341
+ if (point >= 0xd800 && point <= 0xdfff)
342
+ return false;
343
+ }
344
+ return true;
345
+ }
346
+ function inventoryRules(value) {
347
+ const files = value.files;
348
+ const seen = new Set();
349
+ let previous;
350
+ let total = 0n;
351
+ for (const file of files) {
352
+ const path = file.path;
353
+ const folded = path.toUpperCase();
354
+ if (path.length === 0 || folded === 'INVENTORY.JSON' || folded === 'SIGNATURE.JSON' || seen.has(folded) || (previous !== undefined && previous >= path))
355
+ return false;
356
+ for (const segment of path.split('/')) {
357
+ if (!/^[A-Za-z0-9_.-]+$/.test(segment) || segment === '.' || segment === '..' || segment.endsWith('.') || /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(segment))
358
+ return false;
359
+ }
360
+ const size = BigInt(file.size);
361
+ if (size > 134217728n)
362
+ return false;
363
+ total += size;
364
+ if (total > 1073741824n)
365
+ return false;
366
+ seen.add(folded);
367
+ previous = path;
368
+ }
369
+ return files.some(file => file.path === 'manifest.json');
370
+ }
@@ -0,0 +1,20 @@
1
+ export interface BrowserBeginStepUpRequest {
2
+ operationClass: string;
3
+ method: string;
4
+ targetHash?: string;
5
+ }
6
+ export declare function isBrowserBeginStepUpRequest(value: unknown): value is BrowserBeginStepUpRequest;
7
+ /** The schema's declared UTF-8 document bound in bytes. */
8
+ export declare const browserBeginStepUpRequestJsonMaxBytes = 4096;
9
+ /** Parses one strict BrowserBeginStepUpRequest document; refusal kinds match the C# codec. */
10
+ export declare function tryParseBrowserBeginStepUpRequestJson(input: Uint8Array | string): {
11
+ ok: true;
12
+ value: BrowserBeginStepUpRequest;
13
+ } | {
14
+ ok: false;
15
+ failure: "tooLarge" | "malformed" | "invalid";
16
+ };
17
+ /** Parses one strict BrowserBeginStepUpRequest document or throws an error carrying the refusal kind. */
18
+ export declare function parseBrowserBeginStepUpRequestJson(input: Uint8Array | string): BrowserBeginStepUpRequest;
19
+ /** Writes compact UTF-8 in schema property order and refuses output the schema rejects. */
20
+ export declare function serializeBrowserBeginStepUpRequestJson(value: BrowserBeginStepUpRequest): Uint8Array;
@@ -0,0 +1,279 @@
1
+ export function isBrowserBeginStepUpRequest(value) { return check0(value); }
2
+ /** The schema's declared UTF-8 document bound in bytes. */
3
+ export const browserBeginStepUpRequestJsonMaxBytes = 4096;
4
+ /** Parses one strict BrowserBeginStepUpRequest document; refusal kinds match the C# codec. */
5
+ export function tryParseBrowserBeginStepUpRequestJson(input) {
6
+ const parsed = strictJson(input, 4096);
7
+ if (!parsed.ok)
8
+ return parsed;
9
+ return isBrowserBeginStepUpRequest(parsed.value) ? { ok: true, value: parsed.value } : { ok: false, failure: "invalid" };
10
+ }
11
+ /** Parses one strict BrowserBeginStepUpRequest document or throws an error carrying the refusal kind. */
12
+ export function parseBrowserBeginStepUpRequestJson(input) {
13
+ const result = tryParseBrowserBeginStepUpRequestJson(input);
14
+ if (!result.ok)
15
+ throw Object.assign(new Error(`BrowserBeginStepUpRequest 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 serializeBrowserBeginStepUpRequestJson(value) {
20
+ const bytes = new TextEncoder().encode(JSON.stringify(orderBrowserBeginStepUpRequest(value)));
21
+ const result = tryParseBrowserBeginStepUpRequestJson(bytes);
22
+ if (!result.ok)
23
+ throw Object.assign(new Error(`BrowserBeginStepUpRequest JSON refused: ${result.failure}.`), { failure: result.failure });
24
+ return bytes;
25
+ }
26
+ function orderBrowserBeginStepUpRequest(value) {
27
+ const out = {};
28
+ out["operationClass"] = value["operationClass"];
29
+ out["method"] = value["method"];
30
+ if (value["targetHash"] !== undefined)
31
+ out["targetHash"] = value["targetHash"];
32
+ return out;
33
+ }
34
+ function check0(value) {
35
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
36
+ return false;
37
+ const object = value;
38
+ for (const key of Object.keys(object)) {
39
+ switch (key) {
40
+ case "operationClass":
41
+ if (!check1(object[key]))
42
+ return false;
43
+ break;
44
+ case "method":
45
+ if (!check2(object[key]))
46
+ return false;
47
+ break;
48
+ case "targetHash":
49
+ if (!check3(object[key]))
50
+ return false;
51
+ break;
52
+ default: return false;
53
+ }
54
+ }
55
+ if (!Object.prototype.hasOwnProperty.call(object, "operationClass"))
56
+ return false;
57
+ if (!Object.prototype.hasOwnProperty.call(object, "method"))
58
+ return false;
59
+ return true;
60
+ }
61
+ function check1(value) {
62
+ if (typeof value !== 'string' || !validText(value))
63
+ return false;
64
+ if ([...value].length < 1)
65
+ return false;
66
+ if ([...value].length > 128)
67
+ return false;
68
+ if ((new RegExp("^[A-Za-z0-9._:/-]{1,128}$", 'u')).exec(value)?.[0] !== value)
69
+ return false;
70
+ return true;
71
+ }
72
+ function check2(value) {
73
+ if (typeof value !== 'string' || !validText(value))
74
+ return false;
75
+ if (value !== "passkey" && value !== "email" && value !== "password" && value !== "oidc")
76
+ return false;
77
+ return true;
78
+ }
79
+ function check3(value) {
80
+ if (typeof value !== 'string' || !validText(value))
81
+ return false;
82
+ if ([...value].length < 64)
83
+ return false;
84
+ if ([...value].length > 64)
85
+ return false;
86
+ if ((new RegExp("^[0-9a-f]{64}$", 'u')).exec(value)?.[0] !== value)
87
+ return false;
88
+ return true;
89
+ }
90
+ /** Strict UTF-8 JSON: no BOM, comments, trailing commas or duplicate properties; depth <= 32; integer lexemes only. */
91
+ function strictJson(input, maxBytes) {
92
+ let text;
93
+ if (typeof input === "string") {
94
+ if (!validText(input))
95
+ return { ok: false, failure: "malformed" };
96
+ if (new TextEncoder().encode(input).byteLength > maxBytes)
97
+ return { ok: false, failure: "tooLarge" };
98
+ text = input;
99
+ }
100
+ else {
101
+ if (input.byteLength > maxBytes)
102
+ return { ok: false, failure: "tooLarge" };
103
+ try {
104
+ text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(input);
105
+ }
106
+ catch {
107
+ return { ok: false, failure: "malformed" };
108
+ }
109
+ }
110
+ try {
111
+ return { ok: true, value: new StrictJsonReader(text).document() };
112
+ }
113
+ catch {
114
+ return { ok: false, failure: "malformed" };
115
+ }
116
+ }
117
+ class StrictJsonReader {
118
+ text;
119
+ index = 0;
120
+ constructor(text) {
121
+ this.text = text;
122
+ }
123
+ document() {
124
+ this.space();
125
+ const value = this.value(0);
126
+ this.space();
127
+ if (this.index !== this.text.length)
128
+ throw new SyntaxError("Trailing JSON content");
129
+ return value;
130
+ }
131
+ value(depth) {
132
+ switch (this.text[this.index]) {
133
+ case "{": return this.object(depth + 1);
134
+ case "[": return this.array(depth + 1);
135
+ case '"': return this.string();
136
+ case "t": return this.literal("true", true);
137
+ case "f": return this.literal("false", false);
138
+ case "n": return this.literal("null", null);
139
+ default: return this.number();
140
+ }
141
+ }
142
+ object(depth) {
143
+ if (depth > 32)
144
+ throw new SyntaxError("JSON depth exceeded");
145
+ this.index++;
146
+ const out = {};
147
+ const keys = new Set();
148
+ this.space();
149
+ if (this.text[this.index] === "}") {
150
+ this.index++;
151
+ return out;
152
+ }
153
+ for (;;) {
154
+ this.space();
155
+ if (this.text[this.index] !== '"')
156
+ throw new SyntaxError("Expected property name");
157
+ const key = this.string();
158
+ if (keys.has(key))
159
+ throw new SyntaxError("Duplicate JSON property");
160
+ keys.add(key);
161
+ this.space();
162
+ if (this.text[this.index++] !== ":")
163
+ throw new SyntaxError("Expected colon");
164
+ this.space();
165
+ // defineProperty keeps names such as __proto__ as ordinary own properties.
166
+ Object.defineProperty(out, key, { value: this.value(depth), enumerable: true, writable: true, configurable: true });
167
+ this.space();
168
+ const next = this.text[this.index++];
169
+ if (next === "}")
170
+ return out;
171
+ if (next !== ",")
172
+ throw new SyntaxError("Expected comma");
173
+ }
174
+ }
175
+ array(depth) {
176
+ if (depth > 32)
177
+ throw new SyntaxError("JSON depth exceeded");
178
+ this.index++;
179
+ const out = [];
180
+ this.space();
181
+ if (this.text[this.index] === "]") {
182
+ this.index++;
183
+ return out;
184
+ }
185
+ for (;;) {
186
+ this.space();
187
+ out.push(this.value(depth));
188
+ this.space();
189
+ const next = this.text[this.index++];
190
+ if (next === "]")
191
+ return out;
192
+ if (next !== ",")
193
+ throw new SyntaxError("Expected comma");
194
+ }
195
+ }
196
+ string() {
197
+ this.index++;
198
+ let out = "";
199
+ for (;;) {
200
+ const c = this.text[this.index++];
201
+ if (c === undefined)
202
+ throw new SyntaxError("Unterminated string");
203
+ if (c === '"')
204
+ break;
205
+ if (c < " ")
206
+ throw new SyntaxError("Unescaped control character");
207
+ if (c !== "\\") {
208
+ out += c;
209
+ continue;
210
+ }
211
+ const e = this.text[this.index++];
212
+ const simple = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: "\t" };
213
+ if (e !== undefined && e in simple) {
214
+ out += simple[e];
215
+ continue;
216
+ }
217
+ if (e !== "u" || !/^[0-9a-fA-F]{4}$/.test(this.text.slice(this.index, this.index + 4)))
218
+ throw new SyntaxError("Invalid escape");
219
+ out += String.fromCharCode(parseInt(this.text.slice(this.index, this.index + 4), 16));
220
+ this.index += 4;
221
+ }
222
+ if (!validText(out))
223
+ throw new SyntaxError("Lone surrogate escape");
224
+ return out;
225
+ }
226
+ number() {
227
+ const match = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/y;
228
+ match.lastIndex = this.index;
229
+ const found = match.exec(this.text);
230
+ if (found === null)
231
+ throw new SyntaxError("Invalid JSON value");
232
+ this.index = match.lastIndex;
233
+ // Selected schemas have no fractional numbers; fraction/exponent lexemes never satisfy an integer.
234
+ return found[1] !== undefined || found[2] !== undefined ? Number.NaN : Number(found[0]);
235
+ }
236
+ literal(word, value) {
237
+ if (this.text.slice(this.index, this.index + word.length) !== word)
238
+ throw new SyntaxError("Invalid JSON literal");
239
+ this.index += word.length;
240
+ return value;
241
+ }
242
+ space() {
243
+ while (this.text[this.index] === " " || this.text[this.index] === "\t" || this.text[this.index] === "\n" || this.text[this.index] === "\r")
244
+ this.index++;
245
+ }
246
+ }
247
+ function validText(value) {
248
+ for (const scalar of value) {
249
+ const point = scalar.codePointAt(0);
250
+ if (point >= 0xd800 && point <= 0xdfff)
251
+ return false;
252
+ }
253
+ return true;
254
+ }
255
+ function inventoryRules(value) {
256
+ const files = value.files;
257
+ const seen = new Set();
258
+ let previous;
259
+ let total = 0n;
260
+ for (const file of files) {
261
+ const path = file.path;
262
+ const folded = path.toUpperCase();
263
+ if (path.length === 0 || folded === 'INVENTORY.JSON' || folded === 'SIGNATURE.JSON' || seen.has(folded) || (previous !== undefined && previous >= path))
264
+ return false;
265
+ for (const segment of path.split('/')) {
266
+ if (!/^[A-Za-z0-9_.-]+$/.test(segment) || segment === '.' || segment === '..' || segment.endsWith('.') || /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(segment))
267
+ return false;
268
+ }
269
+ const size = BigInt(file.size);
270
+ if (size > 134217728n)
271
+ return false;
272
+ total += size;
273
+ if (total > 1073741824n)
274
+ return false;
275
+ seen.add(folded);
276
+ previous = path;
277
+ }
278
+ return files.some(file => file.path === 'manifest.json');
279
+ }