@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,271 @@
1
+ export function isNativeAuthorizeRequest(value) { return check0(value); }
2
+ /** The schema's declared form-urlencoded document bound in bytes. */
3
+ export const nativeAuthorizeRequestFormMaxBytes = 16384;
4
+ /** Parses one strict NativeAuthorizeRequest form; refusal kinds match the C# codec. */
5
+ export function tryParseNativeAuthorizeRequestForm(input) {
6
+ let bytes;
7
+ if (typeof input === "string") {
8
+ if (!validText(input))
9
+ return { ok: false, failure: "malformed" };
10
+ bytes = new TextEncoder().encode(input);
11
+ }
12
+ else
13
+ bytes = input;
14
+ if (bytes.byteLength > 16384)
15
+ return { ok: false, failure: "tooLarge" };
16
+ const decoded = decodeForm(bytes);
17
+ if (decoded === undefined)
18
+ return { ok: false, failure: "malformed" };
19
+ return isNativeAuthorizeRequest(decoded) ? { ok: true, value: decoded } : { ok: false, failure: "invalid" };
20
+ }
21
+ /** Parses one strict NativeAuthorizeRequest form or throws an error carrying the refusal kind. */
22
+ export function parseNativeAuthorizeRequestForm(input) {
23
+ const result = tryParseNativeAuthorizeRequestForm(input);
24
+ if (!result.ok)
25
+ throw Object.assign(new Error(`NativeAuthorizeRequest form refused: ${result.failure}.`), { failure: result.failure });
26
+ return result.value;
27
+ }
28
+ /** Writes schema-order name=value pairs with only RFC 3986 unreserved characters unescaped and refuses output the schema rejects. */
29
+ export function serializeNativeAuthorizeRequestForm(value) {
30
+ const out = [];
31
+ for (const name of ["client_id", "redirect_uri", "response_type", "code_challenge", "code_challenge_method", "state", "installationId"]) {
32
+ const item = value[name];
33
+ if (item === undefined)
34
+ continue;
35
+ if (!validText(item))
36
+ throw Object.assign(new Error("NativeAuthorizeRequest form refused: invalid."), { failure: "invalid" });
37
+ if (out.length !== 0)
38
+ out.push("&");
39
+ encodeFormComponent(name, out);
40
+ out.push("=");
41
+ encodeFormComponent(item, out);
42
+ }
43
+ const bytes = new TextEncoder().encode(out.join(""));
44
+ const result = tryParseNativeAuthorizeRequestForm(bytes);
45
+ if (!result.ok)
46
+ throw Object.assign(new Error(`NativeAuthorizeRequest form refused: ${result.failure}.`), { failure: result.failure });
47
+ return bytes;
48
+ }
49
+ function check0(value) {
50
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
51
+ return false;
52
+ const object = value;
53
+ for (const key of Object.keys(object)) {
54
+ switch (key) {
55
+ case "client_id":
56
+ if (!check1(object[key]))
57
+ return false;
58
+ break;
59
+ case "redirect_uri":
60
+ if (!check2(object[key]))
61
+ return false;
62
+ break;
63
+ case "response_type":
64
+ if (!check3(object[key]))
65
+ return false;
66
+ break;
67
+ case "code_challenge":
68
+ if (!check4(object[key]))
69
+ return false;
70
+ break;
71
+ case "code_challenge_method":
72
+ if (!check5(object[key]))
73
+ return false;
74
+ break;
75
+ case "state":
76
+ if (!check6(object[key]))
77
+ return false;
78
+ break;
79
+ case "installationId":
80
+ if (!check7(object[key]))
81
+ return false;
82
+ break;
83
+ default: return false;
84
+ }
85
+ }
86
+ if (!Object.prototype.hasOwnProperty.call(object, "client_id"))
87
+ return false;
88
+ if (!Object.prototype.hasOwnProperty.call(object, "redirect_uri"))
89
+ return false;
90
+ if (!Object.prototype.hasOwnProperty.call(object, "response_type"))
91
+ return false;
92
+ if (!Object.prototype.hasOwnProperty.call(object, "code_challenge"))
93
+ return false;
94
+ if (!Object.prototype.hasOwnProperty.call(object, "code_challenge_method"))
95
+ return false;
96
+ if (!Object.prototype.hasOwnProperty.call(object, "state"))
97
+ return false;
98
+ if (!Object.prototype.hasOwnProperty.call(object, "installationId"))
99
+ return false;
100
+ if (!nativeClientRedirect(value))
101
+ return false;
102
+ return true;
103
+ }
104
+ function check1(value) {
105
+ if (typeof value !== 'string' || !validText(value))
106
+ return false;
107
+ if (value !== "arcscope.desktop" && value !== "companion.android" && value !== "companion.android.selfhost")
108
+ return false;
109
+ return true;
110
+ }
111
+ function check2(value) {
112
+ if (typeof value !== 'string' || !validText(value))
113
+ return false;
114
+ if ([...value].length < 1)
115
+ return false;
116
+ if ([...value].length > 2048)
117
+ return false;
118
+ if ((new RegExp("^[A-Za-z][A-Za-z0-9+.-]*:[\\x21\\x22\\x24-\\x7E]+$", 'u')).exec(value)?.[0] !== value)
119
+ return false;
120
+ return true;
121
+ }
122
+ function check3(value) {
123
+ if (typeof value !== 'string' || !validText(value))
124
+ return false;
125
+ if (value !== "code")
126
+ return false;
127
+ return true;
128
+ }
129
+ function check4(value) {
130
+ if (typeof value !== 'string' || !validText(value))
131
+ return false;
132
+ if ([...value].length < 43)
133
+ return false;
134
+ if ([...value].length > 43)
135
+ return false;
136
+ if ((new RegExp("^[A-Za-z0-9_-]{43}$", 'u')).exec(value)?.[0] !== value)
137
+ return false;
138
+ return true;
139
+ }
140
+ function check5(value) {
141
+ if (typeof value !== 'string' || !validText(value))
142
+ return false;
143
+ if (value !== "S256")
144
+ return false;
145
+ return true;
146
+ }
147
+ function check6(value) {
148
+ if (typeof value !== 'string' || !validText(value))
149
+ return false;
150
+ if ([...value].length < 1)
151
+ return false;
152
+ if ([...value].length > 128)
153
+ return false;
154
+ if ((new RegExp("^[\\x21-\\x7E]+$", 'u')).exec(value)?.[0] !== value)
155
+ return false;
156
+ return true;
157
+ }
158
+ function check7(value) {
159
+ if (typeof value !== 'string' || !validText(value))
160
+ return false;
161
+ if ([...value].length < 36)
162
+ return false;
163
+ if ([...value].length > 36)
164
+ return false;
165
+ 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)
166
+ return false;
167
+ if (value === '00000000-0000-0000-0000-000000000000')
168
+ return false;
169
+ return true;
170
+ }
171
+ function validText(value) {
172
+ for (const scalar of value) {
173
+ const point = scalar.codePointAt(0);
174
+ if (point >= 0xd800 && point <= 0xdfff)
175
+ return false;
176
+ }
177
+ return true;
178
+ }
179
+ function hexValue(byte) {
180
+ if (byte >= 0x30 && byte <= 0x39)
181
+ return byte - 0x30;
182
+ if (byte >= 0x61 && byte <= 0x66)
183
+ return byte - 0x61 + 10;
184
+ if (byte >= 0x41 && byte <= 0x46)
185
+ return byte - 0x41 + 10;
186
+ return -1;
187
+ }
188
+ function decodeFormComponent(input) {
189
+ const bytes = [];
190
+ for (let i = 0; i < input.length; i++) {
191
+ const byte = input[i];
192
+ if (byte === 0x2b) {
193
+ bytes.push(0x20);
194
+ continue;
195
+ }
196
+ if (byte === 0x25) {
197
+ if (i + 2 >= input.length)
198
+ return undefined;
199
+ const high = hexValue(input[i + 1]);
200
+ const low = hexValue(input[i + 2]);
201
+ if (high < 0 || low < 0)
202
+ return undefined;
203
+ bytes.push(high * 16 + low);
204
+ i += 2;
205
+ continue;
206
+ }
207
+ if (byte < 0x21 || byte > 0x7e)
208
+ return undefined;
209
+ bytes.push(byte);
210
+ }
211
+ let text;
212
+ try {
213
+ text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(Uint8Array.from(bytes));
214
+ }
215
+ catch {
216
+ return undefined;
217
+ }
218
+ for (const char of text) {
219
+ const point = char.codePointAt(0);
220
+ if (point < 0x20 || point === 0x7f)
221
+ return undefined;
222
+ }
223
+ return text;
224
+ }
225
+ /** Strict form syntax: printable ASCII, name=value pairs, percent escapes, UTF-8 text and no duplicate or empty names. */
226
+ function decodeForm(input) {
227
+ if (input.length === 0)
228
+ return undefined;
229
+ const out = {};
230
+ const names = new Set();
231
+ let start = 0;
232
+ for (;;) {
233
+ let end = input.indexOf(0x26, start);
234
+ const last = end < 0;
235
+ if (last)
236
+ end = input.length;
237
+ const segment = input.subarray(start, end);
238
+ const equals = segment.indexOf(0x3d);
239
+ if (equals <= 0)
240
+ return undefined;
241
+ const name = decodeFormComponent(segment.subarray(0, equals));
242
+ const value = decodeFormComponent(segment.subarray(equals + 1));
243
+ if (name === undefined || value === undefined || names.has(name))
244
+ return undefined;
245
+ names.add(name);
246
+ // defineProperty keeps names such as __proto__ as ordinary own properties.
247
+ Object.defineProperty(out, name, { value, enumerable: true, writable: true, configurable: true });
248
+ if (last)
249
+ return out;
250
+ start = end + 1;
251
+ if (start === input.length)
252
+ return undefined;
253
+ }
254
+ }
255
+ function encodeFormComponent(value, out) {
256
+ for (const byte of new TextEncoder().encode(value)) {
257
+ if ((byte >= 0x41 && byte <= 0x5a) || (byte >= 0x61 && byte <= 0x7a) || (byte >= 0x30 && byte <= 0x39) || byte === 0x2d || byte === 0x2e || byte === 0x5f || byte === 0x7e)
258
+ out.push(String.fromCharCode(byte));
259
+ else
260
+ out.push("%" + byte.toString(16).toUpperCase().padStart(2, "0"));
261
+ }
262
+ }
263
+ function nativeClientRedirect(value) {
264
+ const object = value;
265
+ switch (object.client_id) {
266
+ case "arcscope.desktop": return object.redirect_uri === "com.arcforges.arcscope:/auth/callback";
267
+ case "companion.android": return object.redirect_uri === "https://account.arcforges.com/native/android/callback";
268
+ case "companion.android.selfhost": return object.redirect_uri === "com.arcforges.mobile:/auth/callback";
269
+ default: return false;
270
+ }
271
+ }
@@ -0,0 +1,23 @@
1
+ export interface NativeTokenRequest {
2
+ grant_type: string;
3
+ code: string;
4
+ code_verifier: string;
5
+ client_id: string;
6
+ redirect_uri: string;
7
+ installationId: string;
8
+ }
9
+ export declare function isNativeTokenRequest(value: unknown): value is NativeTokenRequest;
10
+ /** The schema's declared form-urlencoded document bound in bytes. */
11
+ export declare const nativeTokenRequestFormMaxBytes = 16384;
12
+ /** Parses one strict NativeTokenRequest form; refusal kinds match the C# codec. */
13
+ export declare function tryParseNativeTokenRequestForm(input: Uint8Array | string): {
14
+ ok: true;
15
+ value: NativeTokenRequest;
16
+ } | {
17
+ ok: false;
18
+ failure: "tooLarge" | "malformed" | "invalid";
19
+ };
20
+ /** Parses one strict NativeTokenRequest form or throws an error carrying the refusal kind. */
21
+ export declare function parseNativeTokenRequestForm(input: Uint8Array | string): NativeTokenRequest;
22
+ /** Writes schema-order name=value pairs with only RFC 3986 unreserved characters unescaped and refuses output the schema rejects. */
23
+ export declare function serializeNativeTokenRequestForm(value: NativeTokenRequest): Uint8Array;
@@ -0,0 +1,258 @@
1
+ export function isNativeTokenRequest(value) { return check0(value); }
2
+ /** The schema's declared form-urlencoded document bound in bytes. */
3
+ export const nativeTokenRequestFormMaxBytes = 16384;
4
+ /** Parses one strict NativeTokenRequest form; refusal kinds match the C# codec. */
5
+ export function tryParseNativeTokenRequestForm(input) {
6
+ let bytes;
7
+ if (typeof input === "string") {
8
+ if (!validText(input))
9
+ return { ok: false, failure: "malformed" };
10
+ bytes = new TextEncoder().encode(input);
11
+ }
12
+ else
13
+ bytes = input;
14
+ if (bytes.byteLength > 16384)
15
+ return { ok: false, failure: "tooLarge" };
16
+ const decoded = decodeForm(bytes);
17
+ if (decoded === undefined)
18
+ return { ok: false, failure: "malformed" };
19
+ return isNativeTokenRequest(decoded) ? { ok: true, value: decoded } : { ok: false, failure: "invalid" };
20
+ }
21
+ /** Parses one strict NativeTokenRequest form or throws an error carrying the refusal kind. */
22
+ export function parseNativeTokenRequestForm(input) {
23
+ const result = tryParseNativeTokenRequestForm(input);
24
+ if (!result.ok)
25
+ throw Object.assign(new Error(`NativeTokenRequest form refused: ${result.failure}.`), { failure: result.failure });
26
+ return result.value;
27
+ }
28
+ /** Writes schema-order name=value pairs with only RFC 3986 unreserved characters unescaped and refuses output the schema rejects. */
29
+ export function serializeNativeTokenRequestForm(value) {
30
+ const out = [];
31
+ for (const name of ["grant_type", "code", "code_verifier", "client_id", "redirect_uri", "installationId"]) {
32
+ const item = value[name];
33
+ if (item === undefined)
34
+ continue;
35
+ if (!validText(item))
36
+ throw Object.assign(new Error("NativeTokenRequest form refused: invalid."), { failure: "invalid" });
37
+ if (out.length !== 0)
38
+ out.push("&");
39
+ encodeFormComponent(name, out);
40
+ out.push("=");
41
+ encodeFormComponent(item, out);
42
+ }
43
+ const bytes = new TextEncoder().encode(out.join(""));
44
+ const result = tryParseNativeTokenRequestForm(bytes);
45
+ if (!result.ok)
46
+ throw Object.assign(new Error(`NativeTokenRequest form refused: ${result.failure}.`), { failure: result.failure });
47
+ return bytes;
48
+ }
49
+ function check0(value) {
50
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
51
+ return false;
52
+ const object = value;
53
+ for (const key of Object.keys(object)) {
54
+ switch (key) {
55
+ case "grant_type":
56
+ if (!check1(object[key]))
57
+ return false;
58
+ break;
59
+ case "code":
60
+ if (!check2(object[key]))
61
+ return false;
62
+ break;
63
+ case "code_verifier":
64
+ if (!check3(object[key]))
65
+ return false;
66
+ break;
67
+ case "client_id":
68
+ if (!check4(object[key]))
69
+ return false;
70
+ break;
71
+ case "redirect_uri":
72
+ if (!check5(object[key]))
73
+ return false;
74
+ break;
75
+ case "installationId":
76
+ if (!check6(object[key]))
77
+ return false;
78
+ break;
79
+ default: return false;
80
+ }
81
+ }
82
+ if (!Object.prototype.hasOwnProperty.call(object, "grant_type"))
83
+ return false;
84
+ if (!Object.prototype.hasOwnProperty.call(object, "code"))
85
+ return false;
86
+ if (!Object.prototype.hasOwnProperty.call(object, "code_verifier"))
87
+ return false;
88
+ if (!Object.prototype.hasOwnProperty.call(object, "client_id"))
89
+ return false;
90
+ if (!Object.prototype.hasOwnProperty.call(object, "redirect_uri"))
91
+ return false;
92
+ if (!Object.prototype.hasOwnProperty.call(object, "installationId"))
93
+ return false;
94
+ if (!nativeClientRedirect(value))
95
+ return false;
96
+ return true;
97
+ }
98
+ function check1(value) {
99
+ if (typeof value !== 'string' || !validText(value))
100
+ return false;
101
+ if (value !== "authorization_code")
102
+ return false;
103
+ return true;
104
+ }
105
+ function check2(value) {
106
+ if (typeof value !== 'string' || !validText(value))
107
+ return false;
108
+ if ([...value].length < 43)
109
+ return false;
110
+ if ([...value].length > 43)
111
+ return false;
112
+ if ((new RegExp("^[A-Za-z0-9_-]{43}$", 'u')).exec(value)?.[0] !== value)
113
+ return false;
114
+ return true;
115
+ }
116
+ function check3(value) {
117
+ if (typeof value !== 'string' || !validText(value))
118
+ return false;
119
+ if ([...value].length < 43)
120
+ return false;
121
+ if ([...value].length > 128)
122
+ return false;
123
+ if ((new RegExp("^[A-Za-z0-9._~-]{43,128}$", 'u')).exec(value)?.[0] !== value)
124
+ return false;
125
+ return true;
126
+ }
127
+ function check4(value) {
128
+ if (typeof value !== 'string' || !validText(value))
129
+ return false;
130
+ if (value !== "arcscope.desktop" && value !== "companion.android" && value !== "companion.android.selfhost")
131
+ return false;
132
+ return true;
133
+ }
134
+ function check5(value) {
135
+ if (typeof value !== 'string' || !validText(value))
136
+ return false;
137
+ if ([...value].length < 1)
138
+ return false;
139
+ if ([...value].length > 2048)
140
+ return false;
141
+ if ((new RegExp("^[A-Za-z][A-Za-z0-9+.-]*:[\\x21\\x22\\x24-\\x7E]+$", 'u')).exec(value)?.[0] !== value)
142
+ return false;
143
+ return true;
144
+ }
145
+ function check6(value) {
146
+ if (typeof value !== 'string' || !validText(value))
147
+ return false;
148
+ if ([...value].length < 36)
149
+ return false;
150
+ if ([...value].length > 36)
151
+ return false;
152
+ 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)
153
+ return false;
154
+ if (value === '00000000-0000-0000-0000-000000000000')
155
+ return false;
156
+ return true;
157
+ }
158
+ function validText(value) {
159
+ for (const scalar of value) {
160
+ const point = scalar.codePointAt(0);
161
+ if (point >= 0xd800 && point <= 0xdfff)
162
+ return false;
163
+ }
164
+ return true;
165
+ }
166
+ function hexValue(byte) {
167
+ if (byte >= 0x30 && byte <= 0x39)
168
+ return byte - 0x30;
169
+ if (byte >= 0x61 && byte <= 0x66)
170
+ return byte - 0x61 + 10;
171
+ if (byte >= 0x41 && byte <= 0x46)
172
+ return byte - 0x41 + 10;
173
+ return -1;
174
+ }
175
+ function decodeFormComponent(input) {
176
+ const bytes = [];
177
+ for (let i = 0; i < input.length; i++) {
178
+ const byte = input[i];
179
+ if (byte === 0x2b) {
180
+ bytes.push(0x20);
181
+ continue;
182
+ }
183
+ if (byte === 0x25) {
184
+ if (i + 2 >= input.length)
185
+ return undefined;
186
+ const high = hexValue(input[i + 1]);
187
+ const low = hexValue(input[i + 2]);
188
+ if (high < 0 || low < 0)
189
+ return undefined;
190
+ bytes.push(high * 16 + low);
191
+ i += 2;
192
+ continue;
193
+ }
194
+ if (byte < 0x21 || byte > 0x7e)
195
+ return undefined;
196
+ bytes.push(byte);
197
+ }
198
+ let text;
199
+ try {
200
+ text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(Uint8Array.from(bytes));
201
+ }
202
+ catch {
203
+ return undefined;
204
+ }
205
+ for (const char of text) {
206
+ const point = char.codePointAt(0);
207
+ if (point < 0x20 || point === 0x7f)
208
+ return undefined;
209
+ }
210
+ return text;
211
+ }
212
+ /** Strict form syntax: printable ASCII, name=value pairs, percent escapes, UTF-8 text and no duplicate or empty names. */
213
+ function decodeForm(input) {
214
+ if (input.length === 0)
215
+ return undefined;
216
+ const out = {};
217
+ const names = new Set();
218
+ let start = 0;
219
+ for (;;) {
220
+ let end = input.indexOf(0x26, start);
221
+ const last = end < 0;
222
+ if (last)
223
+ end = input.length;
224
+ const segment = input.subarray(start, end);
225
+ const equals = segment.indexOf(0x3d);
226
+ if (equals <= 0)
227
+ return undefined;
228
+ const name = decodeFormComponent(segment.subarray(0, equals));
229
+ const value = decodeFormComponent(segment.subarray(equals + 1));
230
+ if (name === undefined || value === undefined || names.has(name))
231
+ return undefined;
232
+ names.add(name);
233
+ // defineProperty keeps names such as __proto__ as ordinary own properties.
234
+ Object.defineProperty(out, name, { value, enumerable: true, writable: true, configurable: true });
235
+ if (last)
236
+ return out;
237
+ start = end + 1;
238
+ if (start === input.length)
239
+ return undefined;
240
+ }
241
+ }
242
+ function encodeFormComponent(value, out) {
243
+ for (const byte of new TextEncoder().encode(value)) {
244
+ if ((byte >= 0x41 && byte <= 0x5a) || (byte >= 0x61 && byte <= 0x7a) || (byte >= 0x30 && byte <= 0x39) || byte === 0x2d || byte === 0x2e || byte === 0x5f || byte === 0x7e)
245
+ out.push(String.fromCharCode(byte));
246
+ else
247
+ out.push("%" + byte.toString(16).toUpperCase().padStart(2, "0"));
248
+ }
249
+ }
250
+ function nativeClientRedirect(value) {
251
+ const object = value;
252
+ switch (object.client_id) {
253
+ case "arcscope.desktop": return object.redirect_uri === "com.arcforges.arcscope:/auth/callback";
254
+ case "companion.android": return object.redirect_uri === "https://account.arcforges.com/native/android/callback";
255
+ case "companion.android.selfhost": return object.redirect_uri === "com.arcforges.mobile:/auth/callback";
256
+ default: return false;
257
+ }
258
+ }
@@ -0,0 +1,40 @@
1
+ export interface NativeTokenResponse {
2
+ sessionId: string;
3
+ accessToken: string;
4
+ accessExpiresAt: string;
5
+ refreshToken: string;
6
+ refreshExpiresAt: string;
7
+ device: NativeTokenDevice;
8
+ recoveryGeneration: string;
9
+ purpose: string;
10
+ }
11
+ export interface NativeTokenDevice {
12
+ deviceId: string;
13
+ name: string;
14
+ platform: string;
15
+ trust: string;
16
+ remoteEnabled: boolean;
17
+ revokedAt?: string;
18
+ revision: string;
19
+ installed?: NativeTokenInstalledProduct[];
20
+ }
21
+ export interface NativeTokenInstalledProduct {
22
+ product: string;
23
+ version: string;
24
+ installedAt?: string;
25
+ }
26
+ export declare function isNativeTokenResponse(value: unknown): value is NativeTokenResponse;
27
+ /** The schema's declared UTF-8 document bound in bytes. */
28
+ export declare const nativeTokenResponseJsonMaxBytes = 65536;
29
+ /** Parses one strict NativeTokenResponse document; refusal kinds match the C# codec. */
30
+ export declare function tryParseNativeTokenResponseJson(input: Uint8Array | string): {
31
+ ok: true;
32
+ value: NativeTokenResponse;
33
+ } | {
34
+ ok: false;
35
+ failure: "tooLarge" | "malformed" | "invalid";
36
+ };
37
+ /** Parses one strict NativeTokenResponse document or throws an error carrying the refusal kind. */
38
+ export declare function parseNativeTokenResponseJson(input: Uint8Array | string): NativeTokenResponse;
39
+ /** Writes compact UTF-8 in schema property order and refuses output the schema rejects. */
40
+ export declare function serializeNativeTokenResponseJson(value: NativeTokenResponse): Uint8Array;