Open History to see the last commit
1import * as Schema from "effect/Schema";
2import * as HttpApiSchema from "effect/http-api/HttpApiSchema";
3
4import {
5 AuthSessionId,
6 ForwardCompatibleArray,
7 ClientSurface,
8 ClientWebDeployment,
9 TrimmedNonEmptyString,
10} from "./baseSchemas.ts";
11
12export const ServerAuthPolicy = Schema.Literals([
13 "desktop-managed-local",
14 "loopback-browser",
15 "remote-reachable",
16 "unsafe-no-auth",
17]);
18export type ServerAuthPolicy = typeof ServerAuthPolicy.Type;
19
20export const ServerAuthBootstrapMethod = Schema.Literals(["desktop-bootstrap", "one-time-token"]);
21export type ServerAuthBootstrapMethod = typeof ServerAuthBootstrapMethod.Type;
22
23export const ServerAuthSessionMethod = Schema.Literals([
24 "browser-session-cookie",
25 "bearer-access-token",
26 "dpop-access-token",
27]);
28export type ServerAuthSessionMethod = typeof ServerAuthSessionMethod.Type;
29
30export const AuthOrchestrationReadScope = "orchestration:read" as const;
31export const AuthOrchestrationOperateScope = "orchestration:operate" as const;
32export const AuthSettingsWriteScope = "settings:write" as const;
33export const AuthProvidersManageScope = "providers:manage" as const;
34export const AuthEnvironmentMaintainScope = "environment:maintain" as const;
35export const AuthPreviewOperateScope = "preview:operate" as const;
36export const AuthDiagnosticsReadScope = "diagnostics:read" as const;
37export const AuthTerminalReadScope = "terminal:read" as const;
38export const AuthTerminalOperateScope = "terminal:operate" as const;
39export const AuthSourceControlWriteScope = "source-control:write" as const;
40export const AuthFilesystemReadScope = "filesystem:read" as const;
41export const AuthFilesystemWriteScope = "filesystem:write" as const;
42/** Retained for decoding existing credentials; grants no current RPC access. */
43const AuthReviewWriteScope = "review:write" as const;
44export const AuthAccessReadScope = "access:read" as const;
45export const AuthAccessWriteScope = "access:write" as const;
46export const AuthRelayReadScope = "relay:read" as const;
47export const AuthRelayWriteScope = "relay:write" as const;
48export const AuthEnvironmentScope = Schema.Literals([
49 AuthOrchestrationReadScope,
50 AuthOrchestrationOperateScope,
51 AuthSettingsWriteScope,
52 AuthProvidersManageScope,
53 AuthEnvironmentMaintainScope,
54 AuthPreviewOperateScope,
55 AuthDiagnosticsReadScope,
56 AuthTerminalReadScope,
57 AuthTerminalOperateScope,
58 AuthFilesystemReadScope,
59 AuthFilesystemWriteScope,
60 AuthReviewWriteScope,
61 AuthSourceControlWriteScope,
62 AuthAccessReadScope,
63 AuthAccessWriteScope,
64 AuthRelayReadScope,
65 AuthRelayWriteScope,
66]);
67export type AuthEnvironmentScope = typeof AuthEnvironmentScope.Type;
68export const AuthEnvironmentScopes = Schema.Array(AuthEnvironmentScope);
69export type AuthEnvironmentScopes = typeof AuthEnvironmentScopes.Type;
70
71export const AuthGrantScope = Schema.Literals(
72 AuthEnvironmentScope.literals.filter((scope) => scope !== AuthReviewWriteScope),
73);
74export type AuthGrantScope = typeof AuthGrantScope.Type;
75export const AuthGrantScopes = Schema.Array(AuthGrantScope);
76export type AuthGrantScopes = typeof AuthGrantScopes.Type;
77
78const legacyScopes = new Set<AuthEnvironmentScope>([
79 AuthOrchestrationReadScope,
80 AuthOrchestrationOperateScope,
81 AuthTerminalOperateScope,
82 AuthReviewWriteScope,
83 AuthAccessReadScope,
84 AuthAccessWriteScope,
85 AuthRelayReadScope,
86 AuthRelayWriteScope,
87]);
88
89export function authScopeResponse(scopes: ReadonlyArray<AuthEnvironmentScope>) {
90 return { scopes: scopes.filter((scope) => legacyScopes.has(scope)), permissions: scopes };
91}
92
93const authScopeResponseFields = {
94 scopes: AuthEnvironmentScopes,
95 permissions: Schema.optionalKey(ForwardCompatibleArray(AuthEnvironmentScope)),
96};
97
98// Only clients talking to an old server use these parent checks. Servers never
99// expand stored grants, and an explicitly empty permissions array grants nothing.
100const legacyParents: Partial<Record<AuthEnvironmentScope, AuthEnvironmentScope>> = {
101 [AuthFilesystemReadScope]: AuthOrchestrationReadScope,
102 [AuthDiagnosticsReadScope]: AuthOrchestrationReadScope,
103 [AuthSettingsWriteScope]: AuthOrchestrationOperateScope,
104 [AuthProvidersManageScope]: AuthOrchestrationOperateScope,
105 [AuthEnvironmentMaintainScope]: AuthOrchestrationOperateScope,
106 [AuthPreviewOperateScope]: AuthOrchestrationOperateScope,
107 [AuthSourceControlWriteScope]: AuthOrchestrationOperateScope,
108 [AuthFilesystemWriteScope]: AuthOrchestrationOperateScope,
109 [AuthTerminalReadScope]: AuthTerminalOperateScope,
110};
111
112/** Keep permission denials decodable by clients with the original scope enum. */
113export function authScopeRequiredResponse(requiredPermission: AuthEnvironmentScope) {
114 return {
115 requiredScope: legacyParents[requiredPermission] ?? requiredPermission,
116 requiredPermission,
117 };
118}
119
120export interface SessionGrantInput {
121 readonly authenticated: boolean;
122 readonly scopes?: ReadonlyArray<AuthEnvironmentScope> | undefined;
123 readonly permissions?: ReadonlyArray<AuthEnvironmentScope> | undefined;
124 readonly auth?: { readonly serverUpdateScope?: string | undefined } | undefined;
125}
126
127export function sessionGrantsScope(
128 session: SessionGrantInput,
129 scope: AuthEnvironmentScope,
130): boolean {
131 if (!session.authenticated) return false;
132 if (session.permissions !== undefined) return session.permissions.includes(scope);
133 if (session.scopes?.includes(scope)) return true;
134 if (session.auth?.serverUpdateScope !== undefined) return false;
135 const parent = legacyParents[scope];
136 return parent !== undefined && session.scopes?.includes(parent) === true;
137}
138
139export function sessionHasLegacyPermissions(session: SessionGrantInput): boolean {
140 const permissions = session.permissions;
141 return (
142 session.authenticated &&
143 permissions !== undefined &&
144 permissions.every((scope) => legacyScopes.has(scope)) &&
145 Object.values(legacyParents).some((parent) => permissions.includes(parent))
146 );
147}
148
149// Access and relay management are included because terminal:operate and
150// orchestration:operate already reach that authority through a shell or a
151// full-access agent. Narrowing a grant means choosing explicit scopes.
152export const AuthStandardClientScopes = [
153 AuthOrchestrationReadScope,
154 AuthOrchestrationOperateScope,
155 AuthSettingsWriteScope,
156 AuthProvidersManageScope,
157 AuthEnvironmentMaintainScope,
158 AuthPreviewOperateScope,
159 AuthDiagnosticsReadScope,
160 AuthTerminalReadScope,
161 AuthTerminalOperateScope,
162 AuthSourceControlWriteScope,
163 AuthFilesystemReadScope,
164 AuthFilesystemWriteScope,
165 AuthRelayReadScope,
166 AuthAccessReadScope,
167 AuthAccessWriteScope,
168 AuthRelayWriteScope,
169] as const;
170
171export const AuthTokenExchangeGrantType =
172 "urn:ietf:params:oauth:grant-type:token-exchange" as const;
173export const AuthAccessTokenType = "urn:ietf:params:oauth:token-type:access_token" as const;
174export const AuthEnvironmentBootstrapTokenType =
175 "urn:t3:params:oauth:token-type:environment-bootstrap" as const;
176
177export const ServerAuthDescriptor = Schema.Struct({
178 policy: ServerAuthPolicy,
179 bootstrapMethods: Schema.Array(ServerAuthBootstrapMethod),
180 sessionMethods: Schema.Array(ServerAuthSessionMethod),
181 sessionCookieName: TrimmedNonEmptyString,
182 /** Older servers omit this and authorize self-updates with orchestration:operate. */
183 serverUpdateScope: Schema.optionalKey(Schema.Literal(AuthEnvironmentMaintainScope)),
184});
185export type ServerAuthDescriptor = typeof ServerAuthDescriptor.Type;
186
187export const AuthBrowserSessionRequest = Schema.Struct({
188 credential: TrimmedNonEmptyString,
189});
190export type AuthBrowserSessionRequest = typeof AuthBrowserSessionRequest.Type;
191
192export const AuthBrowserSessionResult = Schema.Struct({
193 authenticated: Schema.Literal(true),
194 ...authScopeResponseFields,
195 sessionMethod: ServerAuthSessionMethod,
196 expiresAt: Schema.DateTimeUtc,
197});
198export type AuthBrowserSessionResult = typeof AuthBrowserSessionResult.Type;
199
200export const AuthClientMetadataDeviceType = Schema.Literals([
201 "desktop",
202 "mobile",
203 "tablet",
204 "bot",
205 "unknown",
206]);
207export type AuthClientMetadataDeviceType = typeof AuthClientMetadataDeviceType.Type;
208
209export const AuthClientPresentationMetadata = Schema.Struct({
210 label: Schema.optionalKey(TrimmedNonEmptyString),
211 deviceType: Schema.optionalKey(AuthClientMetadataDeviceType),
212 os: Schema.optionalKey(TrimmedNonEmptyString),
213 osMajorVersion: Schema.optionalKey(Schema.Int),
214 deviceModel: Schema.optionalKey(TrimmedNonEmptyString),
215 surface: Schema.optionalKey(ClientSurface),
216 webDeployment: Schema.optionalKey(ClientWebDeployment),
217 browser: Schema.optionalKey(TrimmedNonEmptyString),
218 appVersion: Schema.optionalKey(TrimmedNonEmptyString),
219});
220export type AuthClientPresentationMetadata = typeof AuthClientPresentationMetadata.Type;
221
222export const AuthTokenExchangeRequest = Schema.Struct({
223 grant_type: Schema.Literal(AuthTokenExchangeGrantType),
224 subject_token: TrimmedNonEmptyString,
225 subject_token_type: Schema.Literal(AuthEnvironmentBootstrapTokenType),
226 requested_token_type: Schema.Literal(AuthAccessTokenType),
227 scope: Schema.optionalKey(TrimmedNonEmptyString),
228 client_label: Schema.optionalKey(TrimmedNonEmptyString),
229 client_device_type: Schema.optionalKey(AuthClientMetadataDeviceType),
230 client_os: Schema.optionalKey(TrimmedNonEmptyString),
231}).pipe(HttpApiSchema.asFormUrlEncoded());
232export type AuthTokenExchangeRequest = typeof AuthTokenExchangeRequest.Type;
233
234export const AuthAccessTokenResult = Schema.Struct({
235 access_token: TrimmedNonEmptyString,
236 issued_token_type: Schema.Literal(AuthAccessTokenType),
237 token_type: Schema.Literals(["Bearer", "DPoP"]),
238 expires_in: Schema.Number,
239 scope: TrimmedNonEmptyString,
240});
241export type AuthAccessTokenResult = typeof AuthAccessTokenResult.Type;
242
243export const AuthWebSocketTicketResult = Schema.Struct({
244 ticket: TrimmedNonEmptyString,
245 expiresAt: Schema.DateTimeUtc,
246});
247export type AuthWebSocketTicketResult = typeof AuthWebSocketTicketResult.Type;
248
249/**
250 * The route a WebSocket ticket opens: the RPC socket, or the media routes
251 * (device hub, preview stream) that share one ticket across many requests.
252 * It is a path segment so a DPoP mint proof covers it; a query parameter is
253 * outside the proof's `htu` and could be stripped on the way to the server.
254 * Clients that predate this mint at the bare path and get tickets that open either.
255 */
256export const AuthWebSocketTicketUse = Schema.Literals(["rpc", "media"]);
257export type AuthWebSocketTicketUse = typeof AuthWebSocketTicketUse.Type;
258
259export const AuthWebSocketTicketParams = Schema.Struct({ use: AuthWebSocketTicketUse });
260
261export const AuthPairingCredentialResult = Schema.Struct({
262 id: TrimmedNonEmptyString,
263 credential: TrimmedNonEmptyString,
264 label: Schema.optionalKey(TrimmedNonEmptyString),
265 expiresAt: Schema.DateTimeUtc,
266});
267export type AuthPairingCredentialResult = typeof AuthPairingCredentialResult.Type;
268
269export const AuthPairingLink = Schema.Struct({
270 id: TrimmedNonEmptyString,
271 ...authScopeResponseFields,
272 subject: TrimmedNonEmptyString,
273 label: Schema.optionalKey(TrimmedNonEmptyString),
274 createdAt: Schema.DateTimeUtc,
275 expiresAt: Schema.DateTimeUtc,
276});
277export type AuthPairingLink = typeof AuthPairingLink.Type;
278
279export const AuthClientMetadata = Schema.Struct({
280 label: Schema.optionalKey(TrimmedNonEmptyString),
281 ipAddress: Schema.optionalKey(TrimmedNonEmptyString),
282 userAgent: Schema.optionalKey(TrimmedNonEmptyString),
283 deviceType: AuthClientMetadataDeviceType,
284 os: Schema.optionalKey(TrimmedNonEmptyString),
285 browser: Schema.optionalKey(TrimmedNonEmptyString),
286});
287export type AuthClientMetadata = typeof AuthClientMetadata.Type;
288
289export const AuthClientSession = Schema.Struct({
290 sessionId: AuthSessionId,
291 subject: TrimmedNonEmptyString,
292 ...authScopeResponseFields,
293 method: ServerAuthSessionMethod,
294 client: AuthClientMetadata,
295 issuedAt: Schema.DateTimeUtc,
296 expiresAt: Schema.DateTimeUtc,
297 lastConnectedAt: Schema.NullOr(Schema.DateTimeUtc),
298 connected: Schema.Boolean,
299 current: Schema.Boolean,
300});
301export type AuthClientSession = typeof AuthClientSession.Type;
302
303export const AuthAccessSnapshot = Schema.Struct({
304 pairingLinks: Schema.Array(AuthPairingLink),
305 clientSessions: Schema.Array(AuthClientSession),
306});
307export type AuthAccessSnapshot = typeof AuthAccessSnapshot.Type;
308
309export const AuthAccessStreamSnapshotEvent = Schema.Struct({
310 version: Schema.Literal(1),
311 revision: Schema.Number,
312 type: Schema.Literal("snapshot"),
313 payload: AuthAccessSnapshot,
314});
315export type AuthAccessStreamSnapshotEvent = typeof AuthAccessStreamSnapshotEvent.Type;
316
317export const AuthAccessStreamPairingLinkUpsertedEvent = Schema.Struct({
318 version: Schema.Literal(1),
319 revision: Schema.Number,
320 type: Schema.Literal("pairingLinkUpserted"),
321 payload: AuthPairingLink,
322});
323export type AuthAccessStreamPairingLinkUpsertedEvent =
324 typeof AuthAccessStreamPairingLinkUpsertedEvent.Type;
325
326export const AuthAccessStreamPairingLinkRemovedEvent = Schema.Struct({
327 version: Schema.Literal(1),
328 revision: Schema.Number,
329 type: Schema.Literal("pairingLinkRemoved"),
330 payload: Schema.Struct({
331 id: TrimmedNonEmptyString,
332 }),
333});
334export type AuthAccessStreamPairingLinkRemovedEvent =
335 typeof AuthAccessStreamPairingLinkRemovedEvent.Type;
336
337export class AuthAccessStreamError extends Schema.TaggedError<AuthAccessStreamError>()(
338 "AuthAccessStreamError",
339 {
340 message: Schema.String,
341 },
342) {}
343
344export class EnvironmentAuthorizationError extends Schema.TaggedError<EnvironmentAuthorizationError>()(
345 "EnvironmentAuthorizationError",
346 {
347 message: Schema.String,
348 requiredScope: AuthEnvironmentScope,
349 requiredPermission: Schema.optionalKey(Schema.String),
350 },
351) {}
352
353export const AuthAccessStreamClientUpsertedEvent = Schema.Struct({
354 version: Schema.Literal(1),
355 revision: Schema.Number,
356 type: Schema.Literal("clientUpserted"),
357 payload: AuthClientSession,
358});
359export type AuthAccessStreamClientUpsertedEvent = typeof AuthAccessStreamClientUpsertedEvent.Type;
360
361export const AuthAccessStreamClientRemovedEvent = Schema.Struct({
362 version: Schema.Literal(1),
363 revision: Schema.Number,
364 type: Schema.Literal("clientRemoved"),
365 payload: Schema.Struct({
366 sessionId: AuthSessionId,
367 }),
368});
369export type AuthAccessStreamClientRemovedEvent = typeof AuthAccessStreamClientRemovedEvent.Type;
370
371export const AuthAccessStreamEvent = Schema.Union([
372 AuthAccessStreamSnapshotEvent,
373 AuthAccessStreamPairingLinkUpsertedEvent,
374 AuthAccessStreamPairingLinkRemovedEvent,
375 AuthAccessStreamClientUpsertedEvent,
376 AuthAccessStreamClientRemovedEvent,
377]);
378export type AuthAccessStreamEvent = typeof AuthAccessStreamEvent.Type;
379
380export const AuthRevokePairingLinkInput = Schema.Struct({
381 id: TrimmedNonEmptyString,
382});
383export type AuthRevokePairingLinkInput = typeof AuthRevokePairingLinkInput.Type;
384
385export const AuthRevokeClientSessionInput = Schema.Struct({
386 sessionId: AuthSessionId,
387});
388export type AuthRevokeClientSessionInput = typeof AuthRevokeClientSessionInput.Type;
389
390export const AuthCreatePairingCredentialInput = Schema.Struct({
391 label: Schema.optionalKey(TrimmedNonEmptyString),
392 scopes: Schema.optionalKey(AuthGrantScopes),
393});
394export type AuthCreatePairingCredentialInput = typeof AuthCreatePairingCredentialInput.Type;
395
396export const AuthSessionState = Schema.Struct({
397 authenticated: Schema.Boolean,
398 auth: ServerAuthDescriptor,
399 scopes: Schema.optionalKey(AuthEnvironmentScopes),
400 permissions: authScopeResponseFields.permissions,
401 sessionMethod: Schema.optionalKey(ServerAuthSessionMethod),
402 expiresAt: Schema.optionalKey(Schema.DateTimeUtc),
403});
404export type AuthSessionState = typeof AuthSessionState.Type;
405
406export const AuthMcpClientAccess = Schema.Literals([
407 "read-only",
408 "approval-required",
409 "auto-accept-edits",
410 "auto",
411 "full-access",
412]);
413export type AuthMcpClientAccess = typeof AuthMcpClientAccess.Type;
414
415export const AuthMcpProtectedResourceMetadata = Schema.Struct({
416 resource: Schema.String,
417 authorization_servers: Schema.Array(Schema.String),
418 scopes_supported: Schema.Array(AuthEnvironmentScope),
419 bearer_methods_supported: Schema.Array(Schema.Literal("header")),
420 resource_name: Schema.String,
421});
422export type AuthMcpProtectedResourceMetadata = typeof AuthMcpProtectedResourceMetadata.Type;
423
424export const AuthMcpAuthorizationServerMetadata = Schema.Struct({
425 issuer: Schema.String,
426 authorization_endpoint: Schema.String,
427 token_endpoint: Schema.String,
428 registration_endpoint: Schema.String,
429 response_types_supported: Schema.Array(Schema.Literal("code")),
430 grant_types_supported: Schema.Array(Schema.Literal("authorization_code")),
431 code_challenge_methods_supported: Schema.Array(Schema.Literal("S256")),
432 token_endpoint_auth_methods_supported: Schema.Array(Schema.Literal("none")),
433 scopes_supported: Schema.Array(AuthEnvironmentScope),
434 authorization_response_iss_parameter_supported: Schema.Boolean,
435});
436export type AuthMcpAuthorizationServerMetadata = typeof AuthMcpAuthorizationServerMetadata.Type;
437
438export const AuthMcpClientRegistration = Schema.Struct({
439 client_name: Schema.optionalKey(Schema.String),
440 redirect_uris: Schema.optionalKey(Schema.Array(Schema.String)),
441 token_endpoint_auth_method: Schema.optionalKey(Schema.String),
442});
443export type AuthMcpClientRegistration = typeof AuthMcpClientRegistration.Type;
444
445export const AuthMcpRegisteredClient = Schema.Struct({
446 client_id: Schema.String,
447 client_name: Schema.String,
448 redirect_uris: Schema.Array(Schema.String),
449 grant_types: Schema.Array(Schema.Literal("authorization_code")),
450 response_types: Schema.Array(Schema.Literal("code")),
451 token_endpoint_auth_method: Schema.Literal("none"),
452}).pipe(HttpApiSchema.status(201));
453export type AuthMcpRegisteredClient = typeof AuthMcpRegisteredClient.Type;
454
455export class AuthMcpRegistrationError extends Schema.Error<AuthMcpRegistrationError>(
456 "AuthMcpRegistrationError",
457)(
458 {
459 error: Schema.Literals(["invalid_client_metadata", "invalid_redirect_uri"]),
460 error_description: Schema.String,
461 },
462 { httpApiStatus: 400 },
463) {
464 override get message(): string {
465 return this.error_description;
466 }
467}
468
469/**
470 * Every field is checked by the server, so all are optional here.
471 */
472export const AuthMcpAuthorizationRequest = Schema.Struct({
473 response_type: Schema.optionalKey(Schema.String),
474 client_id: Schema.optionalKey(Schema.String),
475 redirect_uri: Schema.optionalKey(Schema.String),
476 code_challenge: Schema.optionalKey(Schema.String),
477 code_challenge_method: Schema.optionalKey(Schema.String),
478 state: Schema.optionalKey(Schema.String),
479 resource: Schema.optionalKey(Schema.String),
480});
481export type AuthMcpAuthorizationRequest = typeof AuthMcpAuthorizationRequest.Type;
482
483/**
484 * The server has already validated the request; nothing here is trusted by the
485 * client except for display.
486 */
487export const AuthMcpApprovalDetails = Schema.Struct({
488 /** Self-declared by the client, so shown as such. */
489 clientName: Schema.String,
490 redirectHost: Schema.String,
491 environmentHost: Schema.String,
492 csrfToken: Schema.optionalKey(Schema.String),
493 /**
494 * What that session may approve in one click: only access whose scopes it
495 * holds. Anything else still needs a pairing code. Absent with `csrfToken`.
496 */
497 oneClickAccess: Schema.optionalKey(Schema.Array(AuthMcpClientAccess)),
498});
499export type AuthMcpApprovalDetails = typeof AuthMcpApprovalDetails.Type;
500
501export const AuthMcpApprovalRedirect = Schema.Struct({
502 redirectTo: Schema.String,
503});
504export type AuthMcpApprovalRedirect = typeof AuthMcpApprovalRedirect.Type;
505
506export const AuthMcpApprovalDecision = Schema.Union([
507 Schema.TaggedStruct("deny", {}),
508 Schema.TaggedStruct("pairing-code", {
509 access: AuthMcpClientAccess,
510 code: TrimmedNonEmptyString,
511 }),
512 Schema.TaggedStruct("browser-session", {
513 access: AuthMcpClientAccess,
514 csrfToken: Schema.String,
515 }),
516]);
517export type AuthMcpApprovalDecision = typeof AuthMcpApprovalDecision.Type;
518
519export const AuthMcpApprovalDecisionRequest = Schema.Struct({
520 authorization: AuthMcpAuthorizationRequest,
521 decision: AuthMcpApprovalDecision,
522});
523export type AuthMcpApprovalDecisionRequest = typeof AuthMcpApprovalDecisionRequest.Type;
524
525export class AuthMcpApprovalError extends Schema.TaggedError<AuthMcpApprovalError>()(
526 "AuthMcpApprovalError",
527 { message: Schema.String },
528 { httpApiStatus: 400 },
529) {}
530
531export const AuthMcpTokenRequest = Schema.Struct({
532 grant_type: Schema.optionalKey(Schema.String),
533 code: Schema.optionalKey(Schema.String),
534 redirect_uri: Schema.optionalKey(Schema.String),
535 client_id: Schema.optionalKey(Schema.String),
536 code_verifier: Schema.optionalKey(Schema.String),
537 resource: Schema.optionalKey(Schema.String),
538}).pipe(HttpApiSchema.asFormUrlEncoded());
539export type AuthMcpTokenRequest = typeof AuthMcpTokenRequest.Type;
540
541export const AuthMcpTokenResult = Schema.Struct({
542 access_token: Schema.String,
543 token_type: Schema.Literal("Bearer"),
544 expires_in: Schema.Number,
545 scope: Schema.String,
546});
547export type AuthMcpTokenResult = typeof AuthMcpTokenResult.Type;
548
549export class AuthMcpTokenError extends Schema.Error<AuthMcpTokenError>("AuthMcpTokenError")(
550 {
551 error: Schema.Literals([
552 "invalid_request",
553 "invalid_client",
554 "invalid_grant",
555 "unsupported_grant_type",
556 ]),
557 error_description: Schema.String,
558 },
559 { httpApiStatus: 400 },
560) {
561 override get message(): string {
562 return this.error_description;
563 }
564}