@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.
- package/NOTICE +57 -5
- package/README.md +9 -2
- package/build-identity.json +270 -0
- package/contracts.binpb +0 -0
- package/dist/gen/http.d.ts +31 -0
- package/dist/gen/http.js +34 -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/BrowserAuthChallenge.d.ts +35 -0
- package/dist/shapes/gen/BrowserAuthChallenge.js +531 -0
- package/dist/shapes/gen/BrowserBeginAuthenticationRequest.d.ts +28 -0
- package/dist/shapes/gen/BrowserBeginAuthenticationRequest.js +384 -0
- package/dist/shapes/gen/BrowserBeginRecoveryRequest.d.ts +22 -0
- package/dist/shapes/gen/BrowserBeginRecoveryRequest.js +370 -0
- package/dist/shapes/gen/BrowserBeginStepUpRequest.d.ts +20 -0
- package/dist/shapes/gen/BrowserBeginStepUpRequest.js +279 -0
- package/dist/shapes/gen/BrowserBootstrapResponse.d.ts +37 -0
- package/dist/shapes/gen/BrowserBootstrapResponse.js +534 -0
- package/dist/shapes/gen/BrowserCompleteAuthenticationRequest.d.ts +45 -0
- package/dist/shapes/gen/BrowserCompleteAuthenticationRequest.js +564 -0
- package/dist/shapes/gen/BrowserCompleteEnrollmentRequest.d.ts +90 -0
- package/dist/shapes/gen/BrowserCompleteEnrollmentRequest.js +1145 -0
- package/dist/shapes/gen/BrowserCompleteRecoveryRequest.d.ts +22 -0
- package/dist/shapes/gen/BrowserCompleteRecoveryRequest.js +733 -0
- package/dist/shapes/gen/BrowserCompleteStepUpRequest.d.ts +20 -0
- package/dist/shapes/gen/BrowserCompleteStepUpRequest.js +564 -0
- package/dist/shapes/gen/BrowserOidcCallbackFailure.d.ts +20 -0
- package/dist/shapes/gen/BrowserOidcCallbackFailure.js +200 -0
- package/dist/shapes/gen/BrowserOidcCallbackSuccess.d.ts +19 -0
- package/dist/shapes/gen/BrowserOidcCallbackSuccess.js +185 -0
- package/dist/shapes/gen/BrowserReceipt.d.ts +20 -0
- package/dist/shapes/gen/BrowserReceipt.js +285 -0
- package/dist/shapes/gen/BrowserSessionRoutes.d.ts +17 -0
- package/dist/shapes/gen/BrowserSessionRoutes.js +13 -0
- package/dist/shapes/gen/BrowserSessionView.d.ts +25 -0
- package/dist/shapes/gen/BrowserSessionView.js +388 -0
- package/dist/shapes/gen/BrowserStepUpEvidence.d.ts +19 -0
- package/dist/shapes/gen/BrowserStepUpEvidence.js +266 -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/NativeAuthRoutes.d.ts +17 -0
- package/dist/shapes/gen/NativeAuthRoutes.js +5 -0
- package/dist/shapes/gen/NativeAuthorizeCallbackFailure.d.ts +19 -0
- package/dist/shapes/gen/NativeAuthorizeCallbackFailure.js +185 -0
- package/dist/shapes/gen/NativeAuthorizeCallbackSuccess.d.ts +19 -0
- package/dist/shapes/gen/NativeAuthorizeCallbackSuccess.js +185 -0
- package/dist/shapes/gen/NativeAuthorizeRequest.d.ts +24 -0
- package/dist/shapes/gen/NativeAuthorizeRequest.js +271 -0
- package/dist/shapes/gen/NativeTokenRequest.d.ts +23 -0
- package/dist/shapes/gen/NativeTokenRequest.js +258 -0
- package/dist/shapes/gen/NativeTokenResponse.d.ts +40 -0
- package/dist/shapes/gen/NativeTokenResponse.js +572 -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/browser.schema.json +1300 -0
- 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/native-auth.schema.json +341 -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/catalog/v1/catalog.proto +204 -0
- package/schemas/public/proto/arcforges/events/v1/events.proto +343 -0
- package/schemas/public/proto/arcforges/foundation/v1/foundation.proto +384 -0
- package/schemas/public/proto/arcforges/hello/v1/hello.proto +23 -0
- package/schemas/public/proto/arcforges/publicapi/v1/application.proto +297 -0
- package/schemas/public/proto/arcforges/publicapi/v1/chat.proto +1507 -0
- package/schemas/public/proto/arcforges/publicapi/v1/commerce.proto +542 -0
- package/schemas/public/proto/arcforges/publicapi/v1/connector.proto +172 -0
- package/schemas/public/proto/arcforges/publicapi/v1/content.proto +813 -0
- package/schemas/public/proto/arcforges/publicapi/v1/descriptors.proto +27 -0
- package/schemas/public/proto/arcforges/publicapi/v1/export.proto +112 -0
- package/schemas/public/proto/arcforges/publicapi/v1/identity.proto +1350 -0
- package/schemas/public/proto/arcforges/publicapi/v1/inprocess-values.proto +134 -0
- package/schemas/public/proto/arcforges/publicapi/v1/scope.proto +81 -0
- package/schemas/public/proto/arcforges/publicapi/v1/support.proto +242 -0
- package/schemas/public/proto/arcforges/publicapi/v1/sync.proto +459 -0
- package/schemas/public/proto/arcforges/publicapi/v1/transfer.proto +190 -0
- package/schemas/public/proto/arcforges/simulation/v1/simulation.proto +457 -0
- package/source.json +50 -11
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
export function isNativeTokenResponse(value) { return check0(value); }
|
|
2
|
+
/** The schema's declared UTF-8 document bound in bytes. */
|
|
3
|
+
export const nativeTokenResponseJsonMaxBytes = 65536;
|
|
4
|
+
/** Parses one strict NativeTokenResponse document; refusal kinds match the C# codec. */
|
|
5
|
+
export function tryParseNativeTokenResponseJson(input) {
|
|
6
|
+
const parsed = strictJson(input, 65536);
|
|
7
|
+
if (!parsed.ok)
|
|
8
|
+
return parsed;
|
|
9
|
+
return isNativeTokenResponse(parsed.value) ? { ok: true, value: parsed.value } : { ok: false, failure: "invalid" };
|
|
10
|
+
}
|
|
11
|
+
/** Parses one strict NativeTokenResponse document or throws an error carrying the refusal kind. */
|
|
12
|
+
export function parseNativeTokenResponseJson(input) {
|
|
13
|
+
const result = tryParseNativeTokenResponseJson(input);
|
|
14
|
+
if (!result.ok)
|
|
15
|
+
throw Object.assign(new Error(`NativeTokenResponse 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 serializeNativeTokenResponseJson(value) {
|
|
20
|
+
const bytes = new TextEncoder().encode(JSON.stringify(orderNativeTokenResponse(value)));
|
|
21
|
+
const result = tryParseNativeTokenResponseJson(bytes);
|
|
22
|
+
if (!result.ok)
|
|
23
|
+
throw Object.assign(new Error(`NativeTokenResponse JSON refused: ${result.failure}.`), { failure: result.failure });
|
|
24
|
+
return bytes;
|
|
25
|
+
}
|
|
26
|
+
function orderNativeTokenDevice(value) {
|
|
27
|
+
const out = {};
|
|
28
|
+
out["deviceId"] = value["deviceId"];
|
|
29
|
+
out["name"] = value["name"];
|
|
30
|
+
out["platform"] = value["platform"];
|
|
31
|
+
out["trust"] = value["trust"];
|
|
32
|
+
out["remoteEnabled"] = value["remoteEnabled"];
|
|
33
|
+
if (value["revokedAt"] !== undefined)
|
|
34
|
+
out["revokedAt"] = value["revokedAt"];
|
|
35
|
+
out["revision"] = value["revision"];
|
|
36
|
+
if (value["installed"] !== undefined)
|
|
37
|
+
out["installed"] = value["installed"].map(item => orderNativeTokenInstalledProduct(item));
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
function orderNativeTokenInstalledProduct(value) {
|
|
41
|
+
const out = {};
|
|
42
|
+
out["product"] = value["product"];
|
|
43
|
+
out["version"] = value["version"];
|
|
44
|
+
if (value["installedAt"] !== undefined)
|
|
45
|
+
out["installedAt"] = value["installedAt"];
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
function orderNativeTokenResponse(value) {
|
|
49
|
+
const out = {};
|
|
50
|
+
out["sessionId"] = value["sessionId"];
|
|
51
|
+
out["accessToken"] = value["accessToken"];
|
|
52
|
+
out["accessExpiresAt"] = value["accessExpiresAt"];
|
|
53
|
+
out["refreshToken"] = value["refreshToken"];
|
|
54
|
+
out["refreshExpiresAt"] = value["refreshExpiresAt"];
|
|
55
|
+
out["device"] = orderNativeTokenDevice(value["device"]);
|
|
56
|
+
out["recoveryGeneration"] = value["recoveryGeneration"];
|
|
57
|
+
out["purpose"] = value["purpose"];
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
function check0(value) {
|
|
61
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
62
|
+
return false;
|
|
63
|
+
const object = value;
|
|
64
|
+
for (const key of Object.keys(object)) {
|
|
65
|
+
switch (key) {
|
|
66
|
+
case "sessionId":
|
|
67
|
+
if (!check1(object[key]))
|
|
68
|
+
return false;
|
|
69
|
+
break;
|
|
70
|
+
case "accessToken":
|
|
71
|
+
if (!check2(object[key]))
|
|
72
|
+
return false;
|
|
73
|
+
break;
|
|
74
|
+
case "accessExpiresAt":
|
|
75
|
+
if (!check3(object[key]))
|
|
76
|
+
return false;
|
|
77
|
+
break;
|
|
78
|
+
case "refreshToken":
|
|
79
|
+
if (!check4(object[key]))
|
|
80
|
+
return false;
|
|
81
|
+
break;
|
|
82
|
+
case "refreshExpiresAt":
|
|
83
|
+
if (!check5(object[key]))
|
|
84
|
+
return false;
|
|
85
|
+
break;
|
|
86
|
+
case "device":
|
|
87
|
+
if (!check6(object[key]))
|
|
88
|
+
return false;
|
|
89
|
+
break;
|
|
90
|
+
case "recoveryGeneration":
|
|
91
|
+
if (!check19(object[key]))
|
|
92
|
+
return false;
|
|
93
|
+
break;
|
|
94
|
+
case "purpose":
|
|
95
|
+
if (!check20(object[key]))
|
|
96
|
+
return false;
|
|
97
|
+
break;
|
|
98
|
+
default: return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (!Object.prototype.hasOwnProperty.call(object, "sessionId"))
|
|
102
|
+
return false;
|
|
103
|
+
if (!Object.prototype.hasOwnProperty.call(object, "accessToken"))
|
|
104
|
+
return false;
|
|
105
|
+
if (!Object.prototype.hasOwnProperty.call(object, "accessExpiresAt"))
|
|
106
|
+
return false;
|
|
107
|
+
if (!Object.prototype.hasOwnProperty.call(object, "refreshToken"))
|
|
108
|
+
return false;
|
|
109
|
+
if (!Object.prototype.hasOwnProperty.call(object, "refreshExpiresAt"))
|
|
110
|
+
return false;
|
|
111
|
+
if (!Object.prototype.hasOwnProperty.call(object, "device"))
|
|
112
|
+
return false;
|
|
113
|
+
if (!Object.prototype.hasOwnProperty.call(object, "recoveryGeneration"))
|
|
114
|
+
return false;
|
|
115
|
+
if (!Object.prototype.hasOwnProperty.call(object, "purpose"))
|
|
116
|
+
return false;
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
function check1(value) {
|
|
120
|
+
if (typeof value !== 'string' || !validText(value))
|
|
121
|
+
return false;
|
|
122
|
+
if ([...value].length < 36)
|
|
123
|
+
return false;
|
|
124
|
+
if ([...value].length > 36)
|
|
125
|
+
return false;
|
|
126
|
+
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)
|
|
127
|
+
return false;
|
|
128
|
+
if (value === '00000000-0000-0000-0000-000000000000')
|
|
129
|
+
return false;
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
function check2(value) {
|
|
133
|
+
if (typeof value !== 'string' || !validText(value))
|
|
134
|
+
return false;
|
|
135
|
+
if ([...value].length < 1)
|
|
136
|
+
return false;
|
|
137
|
+
if (new TextEncoder().encode(value).byteLength > 8192)
|
|
138
|
+
return false;
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
function check3(value) {
|
|
142
|
+
if (typeof value !== 'string' || !validText(value))
|
|
143
|
+
return false;
|
|
144
|
+
if ([...value].length < 20)
|
|
145
|
+
return false;
|
|
146
|
+
if ([...value].length > 30)
|
|
147
|
+
return false;
|
|
148
|
+
if ((new RegExp("^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,9})?Z$", 'u')).exec(value)?.[0] !== value)
|
|
149
|
+
return false;
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
function check4(value) {
|
|
153
|
+
if (typeof value !== 'string' || !validText(value))
|
|
154
|
+
return false;
|
|
155
|
+
if ([...value].length < 1)
|
|
156
|
+
return false;
|
|
157
|
+
if (new TextEncoder().encode(value).byteLength > 8192)
|
|
158
|
+
return false;
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
function check5(value) {
|
|
162
|
+
if (typeof value !== 'string' || !validText(value))
|
|
163
|
+
return false;
|
|
164
|
+
if ([...value].length < 20)
|
|
165
|
+
return false;
|
|
166
|
+
if ([...value].length > 30)
|
|
167
|
+
return false;
|
|
168
|
+
if ((new RegExp("^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,9})?Z$", 'u')).exec(value)?.[0] !== value)
|
|
169
|
+
return false;
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
function check6(value) {
|
|
173
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
174
|
+
return false;
|
|
175
|
+
const object = value;
|
|
176
|
+
for (const key of Object.keys(object)) {
|
|
177
|
+
switch (key) {
|
|
178
|
+
case "deviceId":
|
|
179
|
+
if (!check7(object[key]))
|
|
180
|
+
return false;
|
|
181
|
+
break;
|
|
182
|
+
case "name":
|
|
183
|
+
if (!check8(object[key]))
|
|
184
|
+
return false;
|
|
185
|
+
break;
|
|
186
|
+
case "platform":
|
|
187
|
+
if (!check9(object[key]))
|
|
188
|
+
return false;
|
|
189
|
+
break;
|
|
190
|
+
case "trust":
|
|
191
|
+
if (!check10(object[key]))
|
|
192
|
+
return false;
|
|
193
|
+
break;
|
|
194
|
+
case "remoteEnabled":
|
|
195
|
+
if (!check11(object[key]))
|
|
196
|
+
return false;
|
|
197
|
+
break;
|
|
198
|
+
case "revokedAt":
|
|
199
|
+
if (!check12(object[key]))
|
|
200
|
+
return false;
|
|
201
|
+
break;
|
|
202
|
+
case "revision":
|
|
203
|
+
if (!check13(object[key]))
|
|
204
|
+
return false;
|
|
205
|
+
break;
|
|
206
|
+
case "installed":
|
|
207
|
+
if (!check14(object[key]))
|
|
208
|
+
return false;
|
|
209
|
+
break;
|
|
210
|
+
default: return false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (!Object.prototype.hasOwnProperty.call(object, "deviceId"))
|
|
214
|
+
return false;
|
|
215
|
+
if (!Object.prototype.hasOwnProperty.call(object, "name"))
|
|
216
|
+
return false;
|
|
217
|
+
if (!Object.prototype.hasOwnProperty.call(object, "platform"))
|
|
218
|
+
return false;
|
|
219
|
+
if (!Object.prototype.hasOwnProperty.call(object, "trust"))
|
|
220
|
+
return false;
|
|
221
|
+
if (!Object.prototype.hasOwnProperty.call(object, "remoteEnabled"))
|
|
222
|
+
return false;
|
|
223
|
+
if (!Object.prototype.hasOwnProperty.call(object, "revision"))
|
|
224
|
+
return false;
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
function check7(value) {
|
|
228
|
+
if (typeof value !== 'string' || !validText(value))
|
|
229
|
+
return false;
|
|
230
|
+
if ([...value].length < 36)
|
|
231
|
+
return false;
|
|
232
|
+
if ([...value].length > 36)
|
|
233
|
+
return false;
|
|
234
|
+
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)
|
|
235
|
+
return false;
|
|
236
|
+
if (value === '00000000-0000-0000-0000-000000000000')
|
|
237
|
+
return false;
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
function check8(value) {
|
|
241
|
+
if (typeof value !== 'string' || !validText(value))
|
|
242
|
+
return false;
|
|
243
|
+
if ([...value].length < 1)
|
|
244
|
+
return false;
|
|
245
|
+
if ([...value].length > 256)
|
|
246
|
+
return false;
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
function check9(value) {
|
|
250
|
+
if (typeof value !== 'string' || !validText(value))
|
|
251
|
+
return false;
|
|
252
|
+
if ([...value].length < 1)
|
|
253
|
+
return false;
|
|
254
|
+
if ([...value].length > 128)
|
|
255
|
+
return false;
|
|
256
|
+
if ((new RegExp("^[A-Za-z0-9._:/-]{1,128}$", 'u')).exec(value)?.[0] !== value)
|
|
257
|
+
return false;
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
function check10(value) {
|
|
261
|
+
if (typeof value !== 'string' || !validText(value))
|
|
262
|
+
return false;
|
|
263
|
+
if (value !== "untrusted" && value !== "trusted" && value !== "revoked")
|
|
264
|
+
return false;
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
function check11(value) {
|
|
268
|
+
if (typeof value !== 'boolean')
|
|
269
|
+
return false;
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
function check12(value) {
|
|
273
|
+
if (typeof value !== 'string' || !validText(value))
|
|
274
|
+
return false;
|
|
275
|
+
if ([...value].length < 20)
|
|
276
|
+
return false;
|
|
277
|
+
if ([...value].length > 30)
|
|
278
|
+
return false;
|
|
279
|
+
if ((new RegExp("^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,9})?Z$", 'u')).exec(value)?.[0] !== value)
|
|
280
|
+
return false;
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
function check13(value) {
|
|
284
|
+
if (typeof value !== 'string' || !validText(value))
|
|
285
|
+
return false;
|
|
286
|
+
if ([...value].length < 1)
|
|
287
|
+
return false;
|
|
288
|
+
if ([...value].length > 19)
|
|
289
|
+
return false;
|
|
290
|
+
if ((new RegExp("^[1-9][0-9]*$", 'u')).exec(value)?.[0] !== value)
|
|
291
|
+
return false;
|
|
292
|
+
if (BigInt(value) < -9223372036854775808n || BigInt(value) > 9223372036854775807n)
|
|
293
|
+
return false;
|
|
294
|
+
if (BigInt(value) <= 0n)
|
|
295
|
+
return false;
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
function check14(value) {
|
|
299
|
+
if (!Array.isArray(value))
|
|
300
|
+
return false;
|
|
301
|
+
if (value.length > 64)
|
|
302
|
+
return false;
|
|
303
|
+
if (!value.every(item => check15(item)))
|
|
304
|
+
return false;
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
function check15(value) {
|
|
308
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
309
|
+
return false;
|
|
310
|
+
const object = value;
|
|
311
|
+
for (const key of Object.keys(object)) {
|
|
312
|
+
switch (key) {
|
|
313
|
+
case "product":
|
|
314
|
+
if (!check16(object[key]))
|
|
315
|
+
return false;
|
|
316
|
+
break;
|
|
317
|
+
case "version":
|
|
318
|
+
if (!check17(object[key]))
|
|
319
|
+
return false;
|
|
320
|
+
break;
|
|
321
|
+
case "installedAt":
|
|
322
|
+
if (!check18(object[key]))
|
|
323
|
+
return false;
|
|
324
|
+
break;
|
|
325
|
+
default: return false;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (!Object.prototype.hasOwnProperty.call(object, "product"))
|
|
329
|
+
return false;
|
|
330
|
+
if (!Object.prototype.hasOwnProperty.call(object, "version"))
|
|
331
|
+
return false;
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
function check16(value) {
|
|
335
|
+
if (typeof value !== 'string' || !validText(value))
|
|
336
|
+
return false;
|
|
337
|
+
if (value !== "arcscope" && value !== "companion")
|
|
338
|
+
return false;
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
function check17(value) {
|
|
342
|
+
if (typeof value !== 'string' || !validText(value))
|
|
343
|
+
return false;
|
|
344
|
+
if ([...value].length < 1)
|
|
345
|
+
return false;
|
|
346
|
+
if ([...value].length > 128)
|
|
347
|
+
return false;
|
|
348
|
+
if ((new RegExp("^[A-Za-z0-9._:/-]{1,128}$", 'u')).exec(value)?.[0] !== value)
|
|
349
|
+
return false;
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
function check18(value) {
|
|
353
|
+
if (typeof value !== 'string' || !validText(value))
|
|
354
|
+
return false;
|
|
355
|
+
if ([...value].length < 20)
|
|
356
|
+
return false;
|
|
357
|
+
if ([...value].length > 30)
|
|
358
|
+
return false;
|
|
359
|
+
if ((new RegExp("^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,9})?Z$", 'u')).exec(value)?.[0] !== value)
|
|
360
|
+
return false;
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
function check19(value) {
|
|
364
|
+
if (typeof value !== 'string' || !validText(value))
|
|
365
|
+
return false;
|
|
366
|
+
if ([...value].length < 1)
|
|
367
|
+
return false;
|
|
368
|
+
if ([...value].length > 20)
|
|
369
|
+
return false;
|
|
370
|
+
if ((new RegExp("^(0|[1-9][0-9]*)$", 'u')).exec(value)?.[0] !== value)
|
|
371
|
+
return false;
|
|
372
|
+
if (BigInt(value) > 18446744073709551615n)
|
|
373
|
+
return false;
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
function check20(value) {
|
|
377
|
+
if (typeof value !== 'string' || !validText(value))
|
|
378
|
+
return false;
|
|
379
|
+
if (value !== "authenticate" && value !== "enroll" && value !== "stepUp" && value !== "recover" && value !== "cancelDeletion")
|
|
380
|
+
return false;
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
/** Strict UTF-8 JSON: no BOM, comments, trailing commas or duplicate properties; depth <= 32; integer lexemes only. */
|
|
384
|
+
function strictJson(input, maxBytes) {
|
|
385
|
+
let text;
|
|
386
|
+
if (typeof input === "string") {
|
|
387
|
+
if (!validText(input))
|
|
388
|
+
return { ok: false, failure: "malformed" };
|
|
389
|
+
if (new TextEncoder().encode(input).byteLength > maxBytes)
|
|
390
|
+
return { ok: false, failure: "tooLarge" };
|
|
391
|
+
text = input;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
if (input.byteLength > maxBytes)
|
|
395
|
+
return { ok: false, failure: "tooLarge" };
|
|
396
|
+
try {
|
|
397
|
+
text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(input);
|
|
398
|
+
}
|
|
399
|
+
catch {
|
|
400
|
+
return { ok: false, failure: "malformed" };
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
try {
|
|
404
|
+
return { ok: true, value: new StrictJsonReader(text).document() };
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
return { ok: false, failure: "malformed" };
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
class StrictJsonReader {
|
|
411
|
+
text;
|
|
412
|
+
index = 0;
|
|
413
|
+
constructor(text) {
|
|
414
|
+
this.text = text;
|
|
415
|
+
}
|
|
416
|
+
document() {
|
|
417
|
+
this.space();
|
|
418
|
+
const value = this.value(0);
|
|
419
|
+
this.space();
|
|
420
|
+
if (this.index !== this.text.length)
|
|
421
|
+
throw new SyntaxError("Trailing JSON content");
|
|
422
|
+
return value;
|
|
423
|
+
}
|
|
424
|
+
value(depth) {
|
|
425
|
+
switch (this.text[this.index]) {
|
|
426
|
+
case "{": return this.object(depth + 1);
|
|
427
|
+
case "[": return this.array(depth + 1);
|
|
428
|
+
case '"': return this.string();
|
|
429
|
+
case "t": return this.literal("true", true);
|
|
430
|
+
case "f": return this.literal("false", false);
|
|
431
|
+
case "n": return this.literal("null", null);
|
|
432
|
+
default: return this.number();
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
object(depth) {
|
|
436
|
+
if (depth > 32)
|
|
437
|
+
throw new SyntaxError("JSON depth exceeded");
|
|
438
|
+
this.index++;
|
|
439
|
+
const out = {};
|
|
440
|
+
const keys = new Set();
|
|
441
|
+
this.space();
|
|
442
|
+
if (this.text[this.index] === "}") {
|
|
443
|
+
this.index++;
|
|
444
|
+
return out;
|
|
445
|
+
}
|
|
446
|
+
for (;;) {
|
|
447
|
+
this.space();
|
|
448
|
+
if (this.text[this.index] !== '"')
|
|
449
|
+
throw new SyntaxError("Expected property name");
|
|
450
|
+
const key = this.string();
|
|
451
|
+
if (keys.has(key))
|
|
452
|
+
throw new SyntaxError("Duplicate JSON property");
|
|
453
|
+
keys.add(key);
|
|
454
|
+
this.space();
|
|
455
|
+
if (this.text[this.index++] !== ":")
|
|
456
|
+
throw new SyntaxError("Expected colon");
|
|
457
|
+
this.space();
|
|
458
|
+
// defineProperty keeps names such as __proto__ as ordinary own properties.
|
|
459
|
+
Object.defineProperty(out, key, { value: this.value(depth), enumerable: true, writable: true, configurable: true });
|
|
460
|
+
this.space();
|
|
461
|
+
const next = this.text[this.index++];
|
|
462
|
+
if (next === "}")
|
|
463
|
+
return out;
|
|
464
|
+
if (next !== ",")
|
|
465
|
+
throw new SyntaxError("Expected comma");
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
array(depth) {
|
|
469
|
+
if (depth > 32)
|
|
470
|
+
throw new SyntaxError("JSON depth exceeded");
|
|
471
|
+
this.index++;
|
|
472
|
+
const out = [];
|
|
473
|
+
this.space();
|
|
474
|
+
if (this.text[this.index] === "]") {
|
|
475
|
+
this.index++;
|
|
476
|
+
return out;
|
|
477
|
+
}
|
|
478
|
+
for (;;) {
|
|
479
|
+
this.space();
|
|
480
|
+
out.push(this.value(depth));
|
|
481
|
+
this.space();
|
|
482
|
+
const next = this.text[this.index++];
|
|
483
|
+
if (next === "]")
|
|
484
|
+
return out;
|
|
485
|
+
if (next !== ",")
|
|
486
|
+
throw new SyntaxError("Expected comma");
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
string() {
|
|
490
|
+
this.index++;
|
|
491
|
+
let out = "";
|
|
492
|
+
for (;;) {
|
|
493
|
+
const c = this.text[this.index++];
|
|
494
|
+
if (c === undefined)
|
|
495
|
+
throw new SyntaxError("Unterminated string");
|
|
496
|
+
if (c === '"')
|
|
497
|
+
break;
|
|
498
|
+
if (c < " ")
|
|
499
|
+
throw new SyntaxError("Unescaped control character");
|
|
500
|
+
if (c !== "\\") {
|
|
501
|
+
out += c;
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
const e = this.text[this.index++];
|
|
505
|
+
const simple = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: "\t" };
|
|
506
|
+
if (e !== undefined && e in simple) {
|
|
507
|
+
out += simple[e];
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
if (e !== "u" || !/^[0-9a-fA-F]{4}$/.test(this.text.slice(this.index, this.index + 4)))
|
|
511
|
+
throw new SyntaxError("Invalid escape");
|
|
512
|
+
out += String.fromCharCode(parseInt(this.text.slice(this.index, this.index + 4), 16));
|
|
513
|
+
this.index += 4;
|
|
514
|
+
}
|
|
515
|
+
if (!validText(out))
|
|
516
|
+
throw new SyntaxError("Lone surrogate escape");
|
|
517
|
+
return out;
|
|
518
|
+
}
|
|
519
|
+
number() {
|
|
520
|
+
const match = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/y;
|
|
521
|
+
match.lastIndex = this.index;
|
|
522
|
+
const found = match.exec(this.text);
|
|
523
|
+
if (found === null)
|
|
524
|
+
throw new SyntaxError("Invalid JSON value");
|
|
525
|
+
this.index = match.lastIndex;
|
|
526
|
+
// Selected schemas have no fractional numbers; fraction/exponent lexemes never satisfy an integer.
|
|
527
|
+
return found[1] !== undefined || found[2] !== undefined ? Number.NaN : Number(found[0]);
|
|
528
|
+
}
|
|
529
|
+
literal(word, value) {
|
|
530
|
+
if (this.text.slice(this.index, this.index + word.length) !== word)
|
|
531
|
+
throw new SyntaxError("Invalid JSON literal");
|
|
532
|
+
this.index += word.length;
|
|
533
|
+
return value;
|
|
534
|
+
}
|
|
535
|
+
space() {
|
|
536
|
+
while (this.text[this.index] === " " || this.text[this.index] === "\t" || this.text[this.index] === "\n" || this.text[this.index] === "\r")
|
|
537
|
+
this.index++;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function validText(value) {
|
|
541
|
+
for (const scalar of value) {
|
|
542
|
+
const point = scalar.codePointAt(0);
|
|
543
|
+
if (point >= 0xd800 && point <= 0xdfff)
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
return true;
|
|
547
|
+
}
|
|
548
|
+
function inventoryRules(value) {
|
|
549
|
+
const files = value.files;
|
|
550
|
+
const seen = new Set();
|
|
551
|
+
let previous;
|
|
552
|
+
let total = 0n;
|
|
553
|
+
for (const file of files) {
|
|
554
|
+
const path = file.path;
|
|
555
|
+
const folded = path.toUpperCase();
|
|
556
|
+
if (path.length === 0 || folded === 'INVENTORY.JSON' || folded === 'SIGNATURE.JSON' || seen.has(folded) || (previous !== undefined && previous >= path))
|
|
557
|
+
return false;
|
|
558
|
+
for (const segment of path.split('/')) {
|
|
559
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(segment) || segment === '.' || segment === '..' || segment.endsWith('.') || /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(segment))
|
|
560
|
+
return false;
|
|
561
|
+
}
|
|
562
|
+
const size = BigInt(file.size);
|
|
563
|
+
if (size > 134217728n)
|
|
564
|
+
return false;
|
|
565
|
+
total += size;
|
|
566
|
+
if (total > 1073741824n)
|
|
567
|
+
return false;
|
|
568
|
+
seen.add(folded);
|
|
569
|
+
previous = path;
|
|
570
|
+
}
|
|
571
|
+
return files.some(file => file.path === 'manifest.json');
|
|
572
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface PackageInventory {
|
|
2
|
+
schemaVersion: string;
|
|
3
|
+
files: InventoryFile[];
|
|
4
|
+
}
|
|
5
|
+
export interface InventoryFile {
|
|
6
|
+
path: string;
|
|
7
|
+
size: string;
|
|
8
|
+
sha256: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function isPackageInventory(value: unknown): value is PackageInventory;
|
|
11
|
+
/** The schema's declared UTF-8 document bound in bytes. */
|
|
12
|
+
export declare const packageInventoryJsonMaxBytes = 4194304;
|
|
13
|
+
/** Parses one strict PackageInventory document; refusal kinds match the C# codec. */
|
|
14
|
+
export declare function tryParsePackageInventoryJson(input: Uint8Array | string): {
|
|
15
|
+
ok: true;
|
|
16
|
+
value: PackageInventory;
|
|
17
|
+
} | {
|
|
18
|
+
ok: false;
|
|
19
|
+
failure: "tooLarge" | "malformed" | "invalid";
|
|
20
|
+
};
|
|
21
|
+
/** Parses one strict PackageInventory document or throws an error carrying the refusal kind. */
|
|
22
|
+
export declare function parsePackageInventoryJson(input: Uint8Array | string): PackageInventory;
|
|
23
|
+
/** Writes compact UTF-8 in schema property order and refuses output the schema rejects. */
|
|
24
|
+
export declare function serializePackageInventoryJson(value: PackageInventory): Uint8Array;
|