@arcforges/api-client 1.0.0-ci.3.1 → 1.0.0-ci.306.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 (99) hide show
  1. package/NOTICE +57 -5
  2. package/README.md +9 -2
  3. package/build-identity.json +266 -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/content.proto +813 -0
  90. package/schemas/public/proto/arcforges/publicapi/v1/descriptors.proto +27 -0
  91. package/schemas/public/proto/arcforges/publicapi/v1/export.proto +112 -0
  92. package/schemas/public/proto/arcforges/publicapi/v1/identity.proto +1350 -0
  93. package/schemas/public/proto/arcforges/publicapi/v1/inprocess-values.proto +134 -0
  94. package/schemas/public/proto/arcforges/publicapi/v1/scope.proto +81 -0
  95. package/schemas/public/proto/arcforges/publicapi/v1/support.proto +242 -0
  96. package/schemas/public/proto/arcforges/publicapi/v1/sync.proto +459 -0
  97. package/schemas/public/proto/arcforges/publicapi/v1/transfer.proto +190 -0
  98. package/schemas/public/proto/arcforges/simulation/v1/simulation.proto +413 -0
  99. package/source.json +49 -6
@@ -0,0 +1,17 @@
1
+ /** One closed NativeAuth HTTP exception route. */
2
+ export interface NativeAuthRoute {
3
+ readonly id: string;
4
+ readonly method: "GET" | "POST";
5
+ readonly path: string;
6
+ readonly credential: string;
7
+ readonly origin: string;
8
+ readonly csrf: string;
9
+ readonly setCookie: string;
10
+ readonly cache: string;
11
+ readonly requestWire: "none" | "json" | "form-urlencoded";
12
+ readonly requestRoots: readonly string[];
13
+ readonly responseWire: "none" | "json" | "form-urlencoded";
14
+ readonly responseRoots: readonly string[];
15
+ }
16
+ /** Closed routes of the NativeAuth bundle in schema order. */
17
+ export declare const nativeAuthRoutes: readonly NativeAuthRoute[];
@@ -0,0 +1,5 @@
1
+ /** Closed routes of the NativeAuth bundle in schema order. */
2
+ export const nativeAuthRoutes = Object.freeze([
3
+ Object.freeze({ id: "native.authorize", method: "GET", path: "/session/v1/native/authorize", credential: "browser-login", origin: "none", csrf: "none", setCookie: "none", cache: "no-store", requestWire: "form-urlencoded", requestRoots: Object.freeze(["NativeAuthorizeRequest"]), responseWire: "none", responseRoots: Object.freeze([]) }),
4
+ Object.freeze({ id: "native.token", method: "POST", path: "/session/v1/native/token", credential: "authorization-code", origin: "none", csrf: "none", setCookie: "none", cache: "no-store", requestWire: "form-urlencoded", requestRoots: Object.freeze(["NativeTokenRequest"]), responseWire: "json", responseRoots: Object.freeze(["NativeTokenResponse"]) }),
5
+ ]);
@@ -0,0 +1,19 @@
1
+ export interface NativeAuthorizeCallbackFailure {
2
+ error: string;
3
+ state: string;
4
+ }
5
+ export declare function isNativeAuthorizeCallbackFailure(value: unknown): value is NativeAuthorizeCallbackFailure;
6
+ /** The schema's declared form-urlencoded document bound in bytes. */
7
+ export declare const nativeAuthorizeCallbackFailureFormMaxBytes = 16384;
8
+ /** Parses one strict NativeAuthorizeCallbackFailure form; refusal kinds match the C# codec. */
9
+ export declare function tryParseNativeAuthorizeCallbackFailureForm(input: Uint8Array | string): {
10
+ ok: true;
11
+ value: NativeAuthorizeCallbackFailure;
12
+ } | {
13
+ ok: false;
14
+ failure: "tooLarge" | "malformed" | "invalid";
15
+ };
16
+ /** Parses one strict NativeAuthorizeCallbackFailure form or throws an error carrying the refusal kind. */
17
+ export declare function parseNativeAuthorizeCallbackFailureForm(input: Uint8Array | string): NativeAuthorizeCallbackFailure;
18
+ /** Writes schema-order name=value pairs with only RFC 3986 unreserved characters unescaped and refuses output the schema rejects. */
19
+ export declare function serializeNativeAuthorizeCallbackFailureForm(value: NativeAuthorizeCallbackFailure): Uint8Array;
@@ -0,0 +1,185 @@
1
+ export function isNativeAuthorizeCallbackFailure(value) { return check0(value); }
2
+ /** The schema's declared form-urlencoded document bound in bytes. */
3
+ export const nativeAuthorizeCallbackFailureFormMaxBytes = 16384;
4
+ /** Parses one strict NativeAuthorizeCallbackFailure form; refusal kinds match the C# codec. */
5
+ export function tryParseNativeAuthorizeCallbackFailureForm(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 isNativeAuthorizeCallbackFailure(decoded) ? { ok: true, value: decoded } : { ok: false, failure: "invalid" };
20
+ }
21
+ /** Parses one strict NativeAuthorizeCallbackFailure form or throws an error carrying the refusal kind. */
22
+ export function parseNativeAuthorizeCallbackFailureForm(input) {
23
+ const result = tryParseNativeAuthorizeCallbackFailureForm(input);
24
+ if (!result.ok)
25
+ throw Object.assign(new Error(`NativeAuthorizeCallbackFailure 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 serializeNativeAuthorizeCallbackFailureForm(value) {
30
+ const out = [];
31
+ for (const name of ["error", "state"]) {
32
+ const item = value[name];
33
+ if (item === undefined)
34
+ continue;
35
+ if (!validText(item))
36
+ throw Object.assign(new Error("NativeAuthorizeCallbackFailure 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 = tryParseNativeAuthorizeCallbackFailureForm(bytes);
45
+ if (!result.ok)
46
+ throw Object.assign(new Error(`NativeAuthorizeCallbackFailure 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 "error":
56
+ if (!check1(object[key]))
57
+ return false;
58
+ break;
59
+ case "state":
60
+ if (!check2(object[key]))
61
+ return false;
62
+ break;
63
+ default: return false;
64
+ }
65
+ }
66
+ if (!Object.prototype.hasOwnProperty.call(object, "error"))
67
+ return false;
68
+ if (!Object.prototype.hasOwnProperty.call(object, "state"))
69
+ return false;
70
+ return true;
71
+ }
72
+ function check1(value) {
73
+ if (typeof value !== 'string' || !validText(value))
74
+ return false;
75
+ if ([...value].length < 1)
76
+ return false;
77
+ if ([...value].length > 64)
78
+ return false;
79
+ if ((new RegExp("^[a-z][a-z_]*$", 'u')).exec(value)?.[0] !== value)
80
+ return false;
81
+ return true;
82
+ }
83
+ function check2(value) {
84
+ if (typeof value !== 'string' || !validText(value))
85
+ return false;
86
+ if ([...value].length < 1)
87
+ return false;
88
+ if ([...value].length > 128)
89
+ return false;
90
+ if ((new RegExp("^[\\x21-\\x7E]+$", 'u')).exec(value)?.[0] !== value)
91
+ return false;
92
+ return true;
93
+ }
94
+ function validText(value) {
95
+ for (const scalar of value) {
96
+ const point = scalar.codePointAt(0);
97
+ if (point >= 0xd800 && point <= 0xdfff)
98
+ return false;
99
+ }
100
+ return true;
101
+ }
102
+ function hexValue(byte) {
103
+ if (byte >= 0x30 && byte <= 0x39)
104
+ return byte - 0x30;
105
+ if (byte >= 0x61 && byte <= 0x66)
106
+ return byte - 0x61 + 10;
107
+ if (byte >= 0x41 && byte <= 0x46)
108
+ return byte - 0x41 + 10;
109
+ return -1;
110
+ }
111
+ function decodeFormComponent(input) {
112
+ const bytes = [];
113
+ for (let i = 0; i < input.length; i++) {
114
+ const byte = input[i];
115
+ if (byte === 0x2b) {
116
+ bytes.push(0x20);
117
+ continue;
118
+ }
119
+ if (byte === 0x25) {
120
+ if (i + 2 >= input.length)
121
+ return undefined;
122
+ const high = hexValue(input[i + 1]);
123
+ const low = hexValue(input[i + 2]);
124
+ if (high < 0 || low < 0)
125
+ return undefined;
126
+ bytes.push(high * 16 + low);
127
+ i += 2;
128
+ continue;
129
+ }
130
+ if (byte < 0x21 || byte > 0x7e)
131
+ return undefined;
132
+ bytes.push(byte);
133
+ }
134
+ let text;
135
+ try {
136
+ text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(Uint8Array.from(bytes));
137
+ }
138
+ catch {
139
+ return undefined;
140
+ }
141
+ for (const char of text) {
142
+ const point = char.codePointAt(0);
143
+ if (point < 0x20 || point === 0x7f)
144
+ return undefined;
145
+ }
146
+ return text;
147
+ }
148
+ /** Strict form syntax: printable ASCII, name=value pairs, percent escapes, UTF-8 text and no duplicate or empty names. */
149
+ function decodeForm(input) {
150
+ if (input.length === 0)
151
+ return undefined;
152
+ const out = {};
153
+ const names = new Set();
154
+ let start = 0;
155
+ for (;;) {
156
+ let end = input.indexOf(0x26, start);
157
+ const last = end < 0;
158
+ if (last)
159
+ end = input.length;
160
+ const segment = input.subarray(start, end);
161
+ const equals = segment.indexOf(0x3d);
162
+ if (equals <= 0)
163
+ return undefined;
164
+ const name = decodeFormComponent(segment.subarray(0, equals));
165
+ const value = decodeFormComponent(segment.subarray(equals + 1));
166
+ if (name === undefined || value === undefined || names.has(name))
167
+ return undefined;
168
+ names.add(name);
169
+ // defineProperty keeps names such as __proto__ as ordinary own properties.
170
+ Object.defineProperty(out, name, { value, enumerable: true, writable: true, configurable: true });
171
+ if (last)
172
+ return out;
173
+ start = end + 1;
174
+ if (start === input.length)
175
+ return undefined;
176
+ }
177
+ }
178
+ function encodeFormComponent(value, out) {
179
+ for (const byte of new TextEncoder().encode(value)) {
180
+ if ((byte >= 0x41 && byte <= 0x5a) || (byte >= 0x61 && byte <= 0x7a) || (byte >= 0x30 && byte <= 0x39) || byte === 0x2d || byte === 0x2e || byte === 0x5f || byte === 0x7e)
181
+ out.push(String.fromCharCode(byte));
182
+ else
183
+ out.push("%" + byte.toString(16).toUpperCase().padStart(2, "0"));
184
+ }
185
+ }
@@ -0,0 +1,19 @@
1
+ export interface NativeAuthorizeCallbackSuccess {
2
+ code: string;
3
+ state: string;
4
+ }
5
+ export declare function isNativeAuthorizeCallbackSuccess(value: unknown): value is NativeAuthorizeCallbackSuccess;
6
+ /** The schema's declared form-urlencoded document bound in bytes. */
7
+ export declare const nativeAuthorizeCallbackSuccessFormMaxBytes = 16384;
8
+ /** Parses one strict NativeAuthorizeCallbackSuccess form; refusal kinds match the C# codec. */
9
+ export declare function tryParseNativeAuthorizeCallbackSuccessForm(input: Uint8Array | string): {
10
+ ok: true;
11
+ value: NativeAuthorizeCallbackSuccess;
12
+ } | {
13
+ ok: false;
14
+ failure: "tooLarge" | "malformed" | "invalid";
15
+ };
16
+ /** Parses one strict NativeAuthorizeCallbackSuccess form or throws an error carrying the refusal kind. */
17
+ export declare function parseNativeAuthorizeCallbackSuccessForm(input: Uint8Array | string): NativeAuthorizeCallbackSuccess;
18
+ /** Writes schema-order name=value pairs with only RFC 3986 unreserved characters unescaped and refuses output the schema rejects. */
19
+ export declare function serializeNativeAuthorizeCallbackSuccessForm(value: NativeAuthorizeCallbackSuccess): Uint8Array;
@@ -0,0 +1,185 @@
1
+ export function isNativeAuthorizeCallbackSuccess(value) { return check0(value); }
2
+ /** The schema's declared form-urlencoded document bound in bytes. */
3
+ export const nativeAuthorizeCallbackSuccessFormMaxBytes = 16384;
4
+ /** Parses one strict NativeAuthorizeCallbackSuccess form; refusal kinds match the C# codec. */
5
+ export function tryParseNativeAuthorizeCallbackSuccessForm(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 isNativeAuthorizeCallbackSuccess(decoded) ? { ok: true, value: decoded } : { ok: false, failure: "invalid" };
20
+ }
21
+ /** Parses one strict NativeAuthorizeCallbackSuccess form or throws an error carrying the refusal kind. */
22
+ export function parseNativeAuthorizeCallbackSuccessForm(input) {
23
+ const result = tryParseNativeAuthorizeCallbackSuccessForm(input);
24
+ if (!result.ok)
25
+ throw Object.assign(new Error(`NativeAuthorizeCallbackSuccess 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 serializeNativeAuthorizeCallbackSuccessForm(value) {
30
+ const out = [];
31
+ for (const name of ["code", "state"]) {
32
+ const item = value[name];
33
+ if (item === undefined)
34
+ continue;
35
+ if (!validText(item))
36
+ throw Object.assign(new Error("NativeAuthorizeCallbackSuccess 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 = tryParseNativeAuthorizeCallbackSuccessForm(bytes);
45
+ if (!result.ok)
46
+ throw Object.assign(new Error(`NativeAuthorizeCallbackSuccess 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 "code":
56
+ if (!check1(object[key]))
57
+ return false;
58
+ break;
59
+ case "state":
60
+ if (!check2(object[key]))
61
+ return false;
62
+ break;
63
+ default: return false;
64
+ }
65
+ }
66
+ if (!Object.prototype.hasOwnProperty.call(object, "code"))
67
+ return false;
68
+ if (!Object.prototype.hasOwnProperty.call(object, "state"))
69
+ return false;
70
+ return true;
71
+ }
72
+ function check1(value) {
73
+ if (typeof value !== 'string' || !validText(value))
74
+ return false;
75
+ if ([...value].length < 43)
76
+ return false;
77
+ if ([...value].length > 43)
78
+ return false;
79
+ if ((new RegExp("^[A-Za-z0-9_-]{43}$", 'u')).exec(value)?.[0] !== value)
80
+ return false;
81
+ return true;
82
+ }
83
+ function check2(value) {
84
+ if (typeof value !== 'string' || !validText(value))
85
+ return false;
86
+ if ([...value].length < 1)
87
+ return false;
88
+ if ([...value].length > 128)
89
+ return false;
90
+ if ((new RegExp("^[\\x21-\\x7E]+$", 'u')).exec(value)?.[0] !== value)
91
+ return false;
92
+ return true;
93
+ }
94
+ function validText(value) {
95
+ for (const scalar of value) {
96
+ const point = scalar.codePointAt(0);
97
+ if (point >= 0xd800 && point <= 0xdfff)
98
+ return false;
99
+ }
100
+ return true;
101
+ }
102
+ function hexValue(byte) {
103
+ if (byte >= 0x30 && byte <= 0x39)
104
+ return byte - 0x30;
105
+ if (byte >= 0x61 && byte <= 0x66)
106
+ return byte - 0x61 + 10;
107
+ if (byte >= 0x41 && byte <= 0x46)
108
+ return byte - 0x41 + 10;
109
+ return -1;
110
+ }
111
+ function decodeFormComponent(input) {
112
+ const bytes = [];
113
+ for (let i = 0; i < input.length; i++) {
114
+ const byte = input[i];
115
+ if (byte === 0x2b) {
116
+ bytes.push(0x20);
117
+ continue;
118
+ }
119
+ if (byte === 0x25) {
120
+ if (i + 2 >= input.length)
121
+ return undefined;
122
+ const high = hexValue(input[i + 1]);
123
+ const low = hexValue(input[i + 2]);
124
+ if (high < 0 || low < 0)
125
+ return undefined;
126
+ bytes.push(high * 16 + low);
127
+ i += 2;
128
+ continue;
129
+ }
130
+ if (byte < 0x21 || byte > 0x7e)
131
+ return undefined;
132
+ bytes.push(byte);
133
+ }
134
+ let text;
135
+ try {
136
+ text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(Uint8Array.from(bytes));
137
+ }
138
+ catch {
139
+ return undefined;
140
+ }
141
+ for (const char of text) {
142
+ const point = char.codePointAt(0);
143
+ if (point < 0x20 || point === 0x7f)
144
+ return undefined;
145
+ }
146
+ return text;
147
+ }
148
+ /** Strict form syntax: printable ASCII, name=value pairs, percent escapes, UTF-8 text and no duplicate or empty names. */
149
+ function decodeForm(input) {
150
+ if (input.length === 0)
151
+ return undefined;
152
+ const out = {};
153
+ const names = new Set();
154
+ let start = 0;
155
+ for (;;) {
156
+ let end = input.indexOf(0x26, start);
157
+ const last = end < 0;
158
+ if (last)
159
+ end = input.length;
160
+ const segment = input.subarray(start, end);
161
+ const equals = segment.indexOf(0x3d);
162
+ if (equals <= 0)
163
+ return undefined;
164
+ const name = decodeFormComponent(segment.subarray(0, equals));
165
+ const value = decodeFormComponent(segment.subarray(equals + 1));
166
+ if (name === undefined || value === undefined || names.has(name))
167
+ return undefined;
168
+ names.add(name);
169
+ // defineProperty keeps names such as __proto__ as ordinary own properties.
170
+ Object.defineProperty(out, name, { value, enumerable: true, writable: true, configurable: true });
171
+ if (last)
172
+ return out;
173
+ start = end + 1;
174
+ if (start === input.length)
175
+ return undefined;
176
+ }
177
+ }
178
+ function encodeFormComponent(value, out) {
179
+ for (const byte of new TextEncoder().encode(value)) {
180
+ if ((byte >= 0x41 && byte <= 0x5a) || (byte >= 0x61 && byte <= 0x7a) || (byte >= 0x30 && byte <= 0x39) || byte === 0x2d || byte === 0x2e || byte === 0x5f || byte === 0x7e)
181
+ out.push(String.fromCharCode(byte));
182
+ else
183
+ out.push("%" + byte.toString(16).toUpperCase().padStart(2, "0"));
184
+ }
185
+ }
@@ -0,0 +1,24 @@
1
+ export interface NativeAuthorizeRequest {
2
+ client_id: string;
3
+ redirect_uri: string;
4
+ response_type: string;
5
+ code_challenge: string;
6
+ code_challenge_method: string;
7
+ state: string;
8
+ installationId: string;
9
+ }
10
+ export declare function isNativeAuthorizeRequest(value: unknown): value is NativeAuthorizeRequest;
11
+ /** The schema's declared form-urlencoded document bound in bytes. */
12
+ export declare const nativeAuthorizeRequestFormMaxBytes = 16384;
13
+ /** Parses one strict NativeAuthorizeRequest form; refusal kinds match the C# codec. */
14
+ export declare function tryParseNativeAuthorizeRequestForm(input: Uint8Array | string): {
15
+ ok: true;
16
+ value: NativeAuthorizeRequest;
17
+ } | {
18
+ ok: false;
19
+ failure: "tooLarge" | "malformed" | "invalid";
20
+ };
21
+ /** Parses one strict NativeAuthorizeRequest form or throws an error carrying the refusal kind. */
22
+ export declare function parseNativeAuthorizeRequestForm(input: Uint8Array | string): NativeAuthorizeRequest;
23
+ /** Writes schema-order name=value pairs with only RFC 3986 unreserved characters unescaped and refuses output the schema rejects. */
24
+ export declare function serializeNativeAuthorizeRequestForm(value: NativeAuthorizeRequest): Uint8Array;