@fleetless/contracts 8.0.0 → 8.1.0-next.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/CHANGELOG.md CHANGED
@@ -9,6 +9,20 @@ version.
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ### Added
13
+
14
+ - Internal, additive shapes for Block D support sessions: `supportSessionInfo`,
15
+ `supportTokenRequest`, `supportTokenResponse` and `authMeSupportResponse`
16
+ (`authMeResponse` extended with an optional `support` block). New
17
+ `audience: 'internal'` routes `POST /console/support/token` (exchanges an
18
+ operator's one-time support grant for a console session scoped to one org,
19
+ server to server only, RFC 6749 §5.2 `oauthError` refusals, sixty minutes,
20
+ no refresh token) and `POST /api/auth/support/end` (ends the calling
21
+ support session; any non-support token answers `403 forbidden`). New
22
+ error codes `support_read_only` and `support_forbidden`. None of this is
23
+ in the public developer reference: the public route entries and
24
+ `authMeResponse` itself are unchanged.
25
+
12
26
  ## [8.0.0] — 2026-10-19
13
27
 
14
28
  ### Changed
@@ -168,6 +168,29 @@
168
168
  "transport": "http",
169
169
  "notes": "No Owner tier: this can only ever touch the caller's own row, so there is nothing for a tier check to gate. Saving the name already held writes nothing and records no audit event — the org activity stream reaches every developer with the console open, and an event for a no-op would misreport that something changed."
170
170
  },
171
+ {
172
+ "method": "POST",
173
+ "path": "/api/auth/support/end",
174
+ "section": "developer-auth",
175
+ "summary": "Ends the calling support session immediately, from the console side.",
176
+ "audience": "internal",
177
+ "auth": "developer",
178
+ "rateLimited": false,
179
+ "ownerTier": false,
180
+ "status": 204,
181
+ "params": [],
182
+ "query": null,
183
+ "request": null,
184
+ "response": null,
185
+ "errors": [
186
+ "unauthorized",
187
+ "token_expired",
188
+ "token_revoked",
189
+ "forbidden"
190
+ ],
191
+ "transport": "http",
192
+ "notes": "Internal: the console calls this so the person a support session is driving can end it themselves — the counterpart to the operator side's `support_session_end` command, each ending the same session through its own path. The bearer must be a support token (`kind: 'support'`, `aud: 'console'`, minted by `POST /console/support/token`); any other token, including an ordinary developer session, answers `403 forbidden`. The session row behind the token is re-read on every request rather than trusted from its own claims, so a session already ended elsewhere is reflected here immediately."
193
+ },
171
194
  {
172
195
  "method": "GET",
173
196
  "path": "/api/auth/two-factor",
@@ -3326,6 +3349,26 @@
3326
3349
  "transport": "http",
3327
3350
  "notes": "Called by the console's own server, never by a browser. Refusals use RFC 6749 §5.2's flat `oauthError` shape — it is a token endpoint, and that is the dialect a caller of one expects — so it emits none of the codes in this reference. Proof of possession is checked before the replay check, and the single-use consume is atomic, so exactly one caller ever mints. The Org Admins membership is re-read here: the code was minted earlier, and a user moved out in between must not get a console session."
3328
3351
  },
3352
+ {
3353
+ "method": "POST",
3354
+ "path": "/console/support/token",
3355
+ "section": "developer-auth",
3356
+ "summary": "Exchanges an operator's one-time support grant for a console session scoped to one org.",
3357
+ "audience": "internal",
3358
+ "auth": "none",
3359
+ "rateLimited": true,
3360
+ "ownerTier": false,
3361
+ "status": 200,
3362
+ "params": [],
3363
+ "query": null,
3364
+ "request": "support-token-request",
3365
+ "response": "support-token-response",
3366
+ "errors": [
3367
+ "rate_limited"
3368
+ ],
3369
+ "transport": "http",
3370
+ "notes": "Called by the console's own server, never by a browser — server to server only, exactly like `/console/oauth/token` beside it, but rate-limited where that one is not: the grant this exchanges is short-lived and worth guessing at, which a replay of the code exchange is not. `rate_limited` is the one code in this reference it can still answer, from the limiter itself, before the route's own dialect applies. Every other refusal uses the same RFC 6749 §5.2 flat `oauthError` shape, so this emits no other code in this reference: `invalid_grant` for a grant that is unknown, already used or expired, or for a verifier that does not match. Proof of possession is checked before the replay check, and the single-use consume is atomic, so exactly one caller ever mints from a given grant. The minted access token carries `kind: 'support'` and `aud: 'console'`, lives at most sixty minutes with no extension, and carries **no refresh token**: a support session that outlives its ceiling is a new grant and a new exchange, not a renewal. The session starts in `read` mode; switching one to `edit` is the operator side's `support_session_edit` command, not anything this route does."
3371
+ },
3329
3372
  {
3330
3373
  "method": "GET",
3331
3374
  "path": "/app/:appIdentifier/logo",
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "session_id": {
6
+ "type": "string",
7
+ "format": "uuid",
8
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
9
+ "description": "The support session this token or response describes. Stable for the life of the session."
10
+ },
11
+ "mode": {
12
+ "type": "string",
13
+ "enum": [
14
+ "read",
15
+ "edit"
16
+ ],
17
+ "description": "The session's current mode. Every support session starts `read`; an operator-admin switches one session into `edit`, never the other way, and the switch is a one-way door for the life of the session."
18
+ },
19
+ "operator_name": {
20
+ "type": "string",
21
+ "minLength": 1,
22
+ "maxLength": 200,
23
+ "description": "The name of the operator-admin holding this session, for the console banner the operator-admin sees. Only the operator-admin's own console receives it; the customer's audit names every edit as Fleetless-Support, never this name."
24
+ },
25
+ "expires_at": {
26
+ "type": "string",
27
+ "format": "date-time",
28
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
29
+ "description": "When the session stops being usable regardless of activity, as an ISO 8601 timestamp. A support session has a hard ceiling; nothing extends it past this instant."
30
+ }
31
+ },
32
+ "required": [
33
+ "session_id",
34
+ "mode",
35
+ "operator_name",
36
+ "expires_at"
37
+ ],
38
+ "additionalProperties": false
39
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "grant": {
6
+ "type": "string",
7
+ "pattern": "^[A-Za-z0-9_-]{43}$",
8
+ "description": "The one-time grant minted when the support session was started: 32 random bytes, base64url, no padding. Consumed atomically by this exchange — presenting it again answers the same refusal a forged one would."
9
+ },
10
+ "code_verifier": {
11
+ "type": "string",
12
+ "pattern": "^[A-Za-z0-9._~-]{43,128}$",
13
+ "description": "The PKCE verifier whose `S256` hash was sent as the grant's challenge when the session was started. Between 43 and 128 unreserved characters, RFC 7636 §4.1's charset — the same shape `oauthCodeTokenRequest.code_verifier` checks, compared rather than parsed."
14
+ }
15
+ },
16
+ "required": [
17
+ "grant",
18
+ "code_verifier"
19
+ ],
20
+ "additionalProperties": false
21
+ }
@@ -0,0 +1,75 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "access_token": {
6
+ "type": "string",
7
+ "minLength": 1,
8
+ "description": "The token to send as `Authorization: Bearer <token>`. Short-lived: read `expires_in`, never assume a lifetime."
9
+ },
10
+ "token_type": {
11
+ "type": "string",
12
+ "const": "Bearer",
13
+ "description": "`Bearer`, the same spelling every other session token on this wire uses."
14
+ },
15
+ "expires_in": {
16
+ "type": "integer",
17
+ "minimum": 1,
18
+ "maximum": 3600,
19
+ "description": "How long the access token stays valid, in seconds from now — at most 3600 (sixty minutes), the hard ceiling of any support session. Not a timestamp, and not milliseconds."
20
+ },
21
+ "org_id": {
22
+ "type": "string",
23
+ "format": "uuid",
24
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
25
+ "description": "The organisation this session was scoped to when the grant was minted."
26
+ },
27
+ "support": {
28
+ "type": "object",
29
+ "properties": {
30
+ "session_id": {
31
+ "type": "string",
32
+ "format": "uuid",
33
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
34
+ "description": "The support session this token or response describes. Stable for the life of the session."
35
+ },
36
+ "mode": {
37
+ "type": "string",
38
+ "enum": [
39
+ "read",
40
+ "edit"
41
+ ],
42
+ "description": "The session's current mode. Every support session starts `read`; an operator-admin switches one session into `edit`, never the other way, and the switch is a one-way door for the life of the session."
43
+ },
44
+ "operator_name": {
45
+ "type": "string",
46
+ "minLength": 1,
47
+ "maxLength": 200,
48
+ "description": "The name of the operator-admin holding this session, for the console banner the operator-admin sees. Only the operator-admin's own console receives it; the customer's audit names every edit as Fleetless-Support, never this name."
49
+ },
50
+ "expires_at": {
51
+ "type": "string",
52
+ "format": "date-time",
53
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
54
+ "description": "When the session stops being usable regardless of activity, as an ISO 8601 timestamp. A support session has a hard ceiling; nothing extends it past this instant."
55
+ }
56
+ },
57
+ "required": [
58
+ "session_id",
59
+ "mode",
60
+ "operator_name",
61
+ "expires_at"
62
+ ],
63
+ "additionalProperties": false,
64
+ "description": "The session as it stands at the moment of exchange: freshly started, in `read` mode."
65
+ }
66
+ },
67
+ "required": [
68
+ "access_token",
69
+ "token_type",
70
+ "expires_in",
71
+ "org_id",
72
+ "support"
73
+ ],
74
+ "additionalProperties": false
75
+ }
package/dist/errors.d.ts CHANGED
@@ -258,5 +258,5 @@ export type BillingDocumentsUnavailableDetails = z.infer<typeof billingDocuments
258
258
  * list is the shared vocabulary, not a closed set, so a new refusal never
259
259
  * needs a contracts release before it can be reported honestly.
260
260
  */
261
- export declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "bridge_too_old", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "cancel_rejected", "job_lost", "job_unknown_to_bridge", "action_server_lost", "action_failed", "goal_rejected", "goal_send_failed", "result_failed", "goal_uncontrollable", "bridge_disconnected", "config_changed", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "dynamic_registration_disabled", "client_limit_reached", "idp_unavailable", "mcp_disabled", "tool_not_available", "capability_required", "last_owner", "role_name_taken", "role_in_use", "last_role", "target_state_conflict", "signup_closed", "draft_not_a_document", "internal_error", "not_cancellable", "unsupported_media_type", "wrong_browser", "invalid_yaml", "unstorable_yaml", "registration_closed", "domain_not_allowed", "email_unverified", "origin_not_allowed", "template_invalid", "provider_disabled", "provider_misconfigured", "invalid_redirect_uri", "interaction_expired", "invalid_code", "method_not_allowed", "plan_limit", "plan_required", "org_locked", "file_too_large", "billing_unavailable", "payment_provider_unavailable", "history_migrating", "billing_documents_unavailable"];
261
+ export declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "bridge_too_old", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "cancel_rejected", "job_lost", "job_unknown_to_bridge", "action_server_lost", "action_failed", "goal_rejected", "goal_send_failed", "result_failed", "goal_uncontrollable", "bridge_disconnected", "config_changed", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "dynamic_registration_disabled", "client_limit_reached", "idp_unavailable", "mcp_disabled", "tool_not_available", "capability_required", "last_owner", "role_name_taken", "role_in_use", "last_role", "target_state_conflict", "signup_closed", "draft_not_a_document", "internal_error", "not_cancellable", "unsupported_media_type", "wrong_browser", "invalid_yaml", "unstorable_yaml", "registration_closed", "domain_not_allowed", "email_unverified", "origin_not_allowed", "template_invalid", "provider_disabled", "provider_misconfigured", "invalid_redirect_uri", "interaction_expired", "invalid_code", "method_not_allowed", "plan_limit", "plan_required", "org_locked", "file_too_large", "billing_unavailable", "payment_provider_unavailable", "history_migrating", "billing_documents_unavailable", "support_read_only", "support_forbidden"];
262
262
  export type ErrorCode = (typeof ERROR_CODES)[number];
package/dist/errors.js CHANGED
@@ -1101,4 +1101,36 @@ export const ERROR_CODES = [
1101
1101
  * page, bytes that are not a PDF or an XML). Nothing is streamed then.
1102
1102
  */
1103
1103
  'billing_documents_unavailable',
1104
+ // 2026-10-28 — support sessions (Block D, internal operator impersonation).
1105
+ /**
1106
+ * `403`: a support session in `read` mode reached a writing route — any
1107
+ * `POST`, `PUT`, `PATCH` or `DELETE` on the developer surface — or sent a
1108
+ * realtime control frame that would write. Reading stays open throughout:
1109
+ * only the write is refused, so a session an operator has not switched to
1110
+ * `edit` can diagnose without being able to change anything.
1111
+ *
1112
+ * Distinct from `forbidden`, which is silent about existence and about a
1113
+ * caller's role: this is about the **session's mode**, not about what the
1114
+ * underlying role would otherwise permit — the same support session would
1115
+ * answer normally to the identical request once switched to `edit`.
1116
+ * Produced by the cloud's support-session policy guard on the developer
1117
+ * HTTP surface and by the realtime socket, for the control frames it
1118
+ * refuses the same way.
1119
+ */
1120
+ 'support_read_only',
1121
+ /**
1122
+ * `403`: a route a support session never reaches, in either mode — signing
1123
+ * in again, account recovery, and system operations such as deleting the
1124
+ * org or rotating another developer's credentials. A support session is a
1125
+ * narrow, time-boxed stand-in for diagnosing and fixing one org's
1126
+ * configuration; it is never a path to the account layer underneath it,
1127
+ * `edit` mode included.
1128
+ *
1129
+ * Distinct from `support_read_only`, which is about a session's mode on a
1130
+ * route it could otherwise reach: this is a route no support session
1131
+ * reaches regardless of mode. Produced by the cloud's support-session
1132
+ * policy guard on the developer HTTP surface and by the realtime socket,
1133
+ * for the control frames it refuses the same way.
1134
+ */
1135
+ 'support_forbidden',
1104
1136
  ];
package/dist/index.d.ts CHANGED
@@ -33,6 +33,8 @@ export { password, org, patchOrgResponse, sessionTokens, refreshRequest, waitlis
33
33
  export type { Org, PatchOrgResponse, SessionTokens, RefreshRequest, WaitlistRequest, OrgAdminTier, FleetlessUser, FleetlessUserListResponse, CreateTeamInviteRequest, TeamInvite, PendingTeamInvite, PendingTeamInviteListResponse, AcceptTeamInviteRequest, PatchFleetlessUserRequest, TierChangeRequest, MailStatus, TierRequiredDetails, PasswordChangeRequest, IdpIssuer, TwoFactorSetupResponse, WebauthnOptionsResponse, DeveloperPasskey, DeveloperTwoFactor, CreatePasskeyRequest, CreatePasskeyResponse, RenamePasskeyRequest, TotpConfirmRequest, TotpConfirmResponse, RecoveryCodesResponse, AuthMeResponse, PatchOrgRequest, PatchAuthMeRequest, } from './identity.js';
34
34
  export { FEEDBACK_KINDS, FEEDBACK_MESSAGE_MAX, feedbackKind, feedbackRequest, feedbackResponse } from './feedback.js';
35
35
  export type { FeedbackKind, FeedbackRequest, FeedbackResponse } from './feedback.js';
36
+ export { supportSessionInfo, supportTokenRequest, supportTokenResponse, authMeSupportResponse } from './support.js';
37
+ export type { SupportSessionInfo, SupportTokenRequest, SupportTokenResponse, AuthMeSupportResponse } from './support.js';
36
38
  export { appIdentifier, app, appListResponse, appDeletionSummary, createAppRequest, updateAppRequest, serverKeyToken, serverKey, serverKeyListResponse, createServerKeyResponse, role, roleListResponse, rolePermissions, roleRenameRequest, roleDeleteQuery, roleInUseDetails, } from './apps.js';
37
39
  export type { App, AppListResponse, AppDeletionSummary, CreateAppRequest, UpdateAppRequest, ServerKey, ServerKeyListResponse, CreateServerKeyResponse, Role, RoleListResponse, RolePermissions, RoleRenameRequest, RoleDeleteQuery, RoleInUseDetails, } from './apps.js';
38
40
  export { clientLoginRequest, clientRefreshRequest, clientLogoutRequest, clientRegisterRequest, clientVerifyEmailRequest, clientResendVerificationRequest, clientPasswordResetRequest, clientPasswordResetConfirmRequest, clientAcceptInvitationRequest, CLIENT_OIDC_CALLBACK_PATH, clientProviderListQuery, clientProviderListResponse, clientOidcStartQuery, clientOidcCallbackQuery, clientOidcExchangeRequest, clientOidcErrorCode, clientMcpInteraction, clientMcpInteractionDecisionResponse, mcpConsentGrant, mcpConsentGrantListResponse, clientIdentity, clientLoginCodeRequest, clientLoginCodeVerifyRequest, twoFactorChallenge, clientSignInResult, clientTwoFactorVerifyRequest, clientTwoFactorSetupRequest, clientTwoFactorSetupConfirmRequest, clientTwoFactorSetupConfirmResponse, clientTwoFactorDisableRequest, } from './client-auth.js';
package/dist/index.js CHANGED
@@ -44,6 +44,8 @@ webauthnJson, webauthnOptionsResponse, developerPasskey, developerTwoFactor, cre
44
44
  authMeResponse, patchOrgRequest, patchAuthMeRequest, } from './identity.js';
45
45
  // 2026-09-30 — the console's feedback modal.
46
46
  export { FEEDBACK_KINDS, FEEDBACK_MESSAGE_MAX, feedbackKind, feedbackRequest, feedbackResponse } from './feedback.js';
47
+ // Support sessions: an operator temporarily holding a console session for one org (internal, additive).
48
+ export { supportSessionInfo, supportTokenRequest, supportTokenResponse, authMeSupportResponse } from './support.js';
47
49
  export { appIdentifier, app, appListResponse, appDeletionSummary, createAppRequest, updateAppRequest, serverKeyToken, serverKey, serverKeyListResponse, createServerKeyResponse, role, roleListResponse, rolePermissions, roleRenameRequest, roleDeleteQuery, roleInUseDetails, } from './apps.js';
48
50
  export { clientLoginRequest, clientRefreshRequest, clientLogoutRequest, clientRegisterRequest, clientVerifyEmailRequest, clientResendVerificationRequest, clientPasswordResetRequest, clientPasswordResetConfirmRequest, clientAcceptInvitationRequest, CLIENT_OIDC_CALLBACK_PATH, clientProviderListQuery, clientProviderListResponse, clientOidcStartQuery, clientOidcCallbackQuery, clientOidcExchangeRequest, clientOidcErrorCode, clientMcpInteraction, clientMcpInteractionDecisionResponse, mcpConsentGrant, mcpConsentGrantListResponse, clientIdentity, clientLoginCodeRequest, clientLoginCodeVerifyRequest, twoFactorChallenge, clientSignInResult, clientTwoFactorVerifyRequest, clientTwoFactorSetupRequest, clientTwoFactorSetupConfirmRequest, clientTwoFactorSetupConfirmResponse, clientTwoFactorDisableRequest, } from './client-auth.js';
49
51
  export { clientRobotListItem, clientRobotListResponse } from './client-robots.js';
package/dist/routes.js CHANGED
@@ -12,6 +12,7 @@ import { jobRunListResponse, jobRunQuery, jobRunSummary, jobRunSummaryQuery } fr
12
12
  import { MCP_APP_PATHS, mcpRobotDatasheet, mcpRolePreviewResponse } from './mcp.js';
13
13
  import { authorizationServerMetadata, dynamicClientRegistrationRequest, dynamicClientRegistrationResponse, oauthAuthorizeQuery, oauthRedirectResponse, oauthTokenRequest, oauthTokenResponse, protectedResourceMetadata, } from './oauth.js';
14
14
  import { adminPlanChangeRequest, orgPlan, planChangeRequest } from './plans.js';
15
+ import { supportTokenRequest, supportTokenResponse } from './support.js';
15
16
  import { purchaseIntentLookupQuery, purchaseIntentConfirmRequest, purchaseIntentResponse, invoicePayRequest, billingCancelRequest, billingChangeRequest, billingChangeResponse, billingDetailsUpdate, billingDocumentDetail, billingDocumentFileQuery, billingDocumentList, billingView, chargePayRequest, checkoutRequest, checkoutResponse, checkoutStatus, paymentMethodChangeRequest, vatIdCheckRequest, vatIdCheckResponse, } from './billing.js';
16
17
  import { cameraListResponse, cancelRequest, configDraftResponse, configVersionResponse, configVersionsResponse, createRobotRequest, createRobotResponse, datapointListResponse, datapointValue, exposureListResponse, fetchTypesRequest, fetchTypesResponse, historyQuery, historyResponse, introspectionResponse, invokeOrServiceResponse, invokeRequest, jobResponse, liveSessionResponse, orgHealthQuery, orgLatencyQuery, orgLatencyResponse, orgQuotaUsage, orgUsageQuery, orgUsageResponse, patchRobotRequest, patchRobotResponse, publishConfigResponse, publishRequest, putConfigDraftRequest, putRobotDetailsRequest, putRobotDetailsResponse, robotTokenRotateResponse, jointStatePutRequest, jointStatePutResponse, releaseLiveQuery, renameSlugRequest, renameSlugResponse, robotDeleteQuery, resourceHealthListResponse, robotDeletionSummary, robotDetailResponse, robotJobsResponse, robotListResponse, slugUsageResponse, snapshotMetaResponse, typesResponse, } from './rest.js';
17
18
  export const ROUTE_SECTIONS = [
@@ -343,6 +344,18 @@ export const ROUTES = [
343
344
  'held writes nothing and records no audit event — the org activity stream reaches every developer with the console open, and an event ' +
344
345
  'for a no-op would misreport that something changed.',
345
346
  },
347
+ {
348
+ method: 'POST', path: '/api/auth/support/end', section: 'developer-auth',
349
+ summary: 'Ends the calling support session immediately, from the console side.',
350
+ audience: 'internal', auth: 'developer', rateLimited: false, ownerTier: false, status: 204,
351
+ params: [], query: null, request: null, response: null,
352
+ errors: [...DEVELOPER_GUARD, 'forbidden'], transport: 'http',
353
+ notes: 'Internal: the console calls this so the person a support session is driving can end it themselves — the counterpart to the operator ' +
354
+ 'side\'s `support_session_end` command, each ending the same session through its own path. The bearer must be a support token ' +
355
+ '(`kind: \'support\'`, `aud: \'console\'`, minted by `POST /console/support/token`); any other token, including an ordinary developer ' +
356
+ 'session, answers `403 forbidden`. The session row behind the token is re-read on every request rather than trusted from its own ' +
357
+ 'claims, so a session already ended elsewhere is reflected here immediately.',
358
+ },
346
359
  /* ------------------------------------ a developer's own second factors */
347
360
  {
348
361
  method: 'GET', path: '/api/auth/two-factor', section: 'developer-auth',
@@ -1484,6 +1497,21 @@ export const ROUTES = [
1484
1497
  'the replay check, and the single-use consume is atomic, so exactly one caller ever mints. The Org Admins membership is re-read here: the ' +
1485
1498
  'code was minted earlier, and a user moved out in between must not get a console session.',
1486
1499
  },
1500
+ {
1501
+ method: 'POST', path: '/console/support/token', section: 'developer-auth',
1502
+ summary: "Exchanges an operator's one-time support grant for a console session scoped to one org.",
1503
+ audience: 'internal', auth: 'none', rateLimited: true, ownerTier: false, status: 200,
1504
+ params: [], query: null, request: supportTokenRequest, response: supportTokenResponse, errors: ['rate_limited'], transport: 'http',
1505
+ notes: 'Called by the console\'s own server, never by a browser — server to server only, exactly like `/console/oauth/token` beside it, but ' +
1506
+ 'rate-limited where that one is not: the grant this exchanges is short-lived and worth guessing at, which a replay of the code exchange ' +
1507
+ 'is not. `rate_limited` is the one code in this reference it can still answer, from the limiter itself, before the route\'s own dialect ' +
1508
+ 'applies. Every other refusal uses the same RFC 6749 §5.2 flat `oauthError` shape, so this emits no other code in this reference: ' +
1509
+ '`invalid_grant` for a grant that is unknown, already used or expired, or for a verifier that does not match. Proof of possession is checked before the replay ' +
1510
+ 'check, and the single-use consume is atomic, so exactly one caller ever mints from a given grant. The minted access token carries ' +
1511
+ '`kind: \'support\'` and `aud: \'console\'`, lives at most sixty minutes with no extension, and carries **no refresh token**: a support ' +
1512
+ 'session that outlives its ceiling is a new grant and a new exchange, not a renewal. The session starts in `read` mode; switching one to ' +
1513
+ '`edit` is the operator side\'s `support_session_edit` command, not anything this route does.',
1514
+ },
1487
1515
  /* --------------------------------- the Fleetless-hosted app pages */
1488
1516
  ...HOSTED_APP_ROUTES,
1489
1517
  /* ---------------------------------------------------- mcp (the endpoint) */
@@ -0,0 +1,126 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { z } from 'zod';
3
+ /**
4
+ * **Support sessions: an operator temporarily holding a console session for
5
+ * one org, under that org's own audit trail.**
6
+ *
7
+ * The operator app mints a one-time grant for an org (its own command surface,
8
+ * outside this package) and sends the browser to the console, whose server
9
+ * redeems it through
10
+ * `POST /console/support/token`, which exchanges it for an ordinary-looking
11
+ * developer session scoped to that org. From the console's own point of view
12
+ * it is just a session: the same `GET /api/auth/me` it always calls, extended
13
+ * with a `support` block so the console can show who is driving and let the
14
+ * person end the session themselves.
15
+ *
16
+ * This whole surface is **internal and additive** — `audience: 'internal'` on
17
+ * both routes, nothing here replaces or narrows the public developer
18
+ * reference. Every shape in this file is read by the console and the cloud;
19
+ * none of it is published documentation for an outside integrator, which is
20
+ * also why `authMeResponse` itself is left untouched and `authMeSupportResponse`
21
+ * exists beside it instead.
22
+ */
23
+ /**
24
+ * What a support session tells the console about itself: who is holding it,
25
+ * in which mode, and until when. Carried inside `supportTokenResponse` at the
26
+ * start of the session and inside `authMeSupportResponse` on every later call,
27
+ * because the session row — mode, expiry, whether it has since ended — is
28
+ * re-read from storage each time rather than trusted from the token's claims.
29
+ */
30
+ export declare const supportSessionInfo: z.ZodObject<{
31
+ session_id: z.ZodUUID;
32
+ mode: z.ZodEnum<{
33
+ read: "read";
34
+ edit: "edit";
35
+ }>;
36
+ operator_name: z.ZodString;
37
+ expires_at: z.ZodISODateTime;
38
+ }, z.core.$strict>;
39
+ export type SupportSessionInfo = z.infer<typeof supportSessionInfo>;
40
+ /**
41
+ * `POST /console/support/token`'s request: a one-time grant, proven with the
42
+ * PKCE verifier bound to it when it was minted.
43
+ *
44
+ * **Server to server only** — the console's own server calls this, never a
45
+ * browser — and the grant is single-use: a second presentation of the same
46
+ * grant, a grant that has expired, or a verifier that does not match is every
47
+ * one of them `invalid_grant`, the same RFC 6749 §5.2 dialect
48
+ * `POST /console/oauth/token` already answers in.
49
+ */
50
+ export declare const supportTokenRequest: z.ZodObject<{
51
+ grant: z.ZodString;
52
+ code_verifier: z.ZodString;
53
+ }, z.core.$strict>;
54
+ export type SupportTokenRequest = z.infer<typeof supportTokenRequest>;
55
+ /**
56
+ * `POST /console/support/token`'s response: a bearer token scoped to the org
57
+ * the grant was minted for, **and no refresh token**.
58
+ *
59
+ * A support session is bounded (sixty minutes, no extension) by design, so
60
+ * there is nothing for a refresh to buy back — a refresh token here would be
61
+ * a second way to outlive the ceiling `supportSessionInfo.expires_at` already
62
+ * states. When the access token expires the session is over; starting
63
+ * another one is a new grant, a new exchange, and a new audit trail.
64
+ */
65
+ export declare const supportTokenResponse: z.ZodObject<{
66
+ access_token: z.ZodString;
67
+ token_type: z.ZodLiteral<"Bearer">;
68
+ expires_in: z.ZodNumber;
69
+ org_id: z.ZodUUID;
70
+ support: z.ZodObject<{
71
+ session_id: z.ZodUUID;
72
+ mode: z.ZodEnum<{
73
+ read: "read";
74
+ edit: "edit";
75
+ }>;
76
+ operator_name: z.ZodString;
77
+ expires_at: z.ZodISODateTime;
78
+ }, z.core.$strict>;
79
+ }, z.core.$strict>;
80
+ export type SupportTokenResponse = z.infer<typeof supportTokenResponse>;
81
+ /**
82
+ * What `GET /api/auth/me` answers **to a support token** — `authMeResponse`
83
+ * with one more, optional field. The public route entry keeps `authMeResponse`
84
+ * itself, so this block stays out of the public reference and the ordinary
85
+ * developer session answer is unchanged; the console validates the actual
86
+ * response it receives against this shape instead, and reads `support` to
87
+ * decide whether to render the "someone is holding this session" banner at
88
+ * all.
89
+ *
90
+ * `support` is **absent, not null**, for an ordinary developer session: the
91
+ * field means "this is a support session" by its own presence, and an
92
+ * ordinary session has never had anything to put there.
93
+ */
94
+ export declare const authMeSupportResponse: z.ZodObject<{
95
+ org: z.ZodObject<{
96
+ id: z.ZodUUID;
97
+ name: z.ZodString;
98
+ require_two_factor: z.ZodBoolean;
99
+ created_at: z.ZodISODateTime;
100
+ }, z.core.$strip>;
101
+ user: z.ZodObject<{
102
+ id: z.ZodUUID;
103
+ org_id: z.ZodUUID;
104
+ email: z.ZodEmail;
105
+ display_name: z.ZodNullable<z.ZodString>;
106
+ tier: z.ZodEnum<{
107
+ owner: "owner";
108
+ developer: "developer";
109
+ }>;
110
+ two_factor: z.ZodObject<{
111
+ passkeys: z.ZodNumber;
112
+ authenticator: z.ZodBoolean;
113
+ }, z.core.$strip>;
114
+ created_at: z.ZodISODateTime;
115
+ }, z.core.$strip>;
116
+ support: z.ZodOptional<z.ZodObject<{
117
+ session_id: z.ZodUUID;
118
+ mode: z.ZodEnum<{
119
+ read: "read";
120
+ edit: "edit";
121
+ }>;
122
+ operator_name: z.ZodString;
123
+ expires_at: z.ZodISODateTime;
124
+ }, z.core.$strict>>;
125
+ }, z.core.$strip>;
126
+ export type AuthMeSupportResponse = z.infer<typeof authMeSupportResponse>;
@@ -0,0 +1,109 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { z } from 'zod';
3
+ import { authMeResponse } from './identity.js';
4
+ /**
5
+ * **Support sessions: an operator temporarily holding a console session for
6
+ * one org, under that org's own audit trail.**
7
+ *
8
+ * The operator app mints a one-time grant for an org (its own command surface,
9
+ * outside this package) and sends the browser to the console, whose server
10
+ * redeems it through
11
+ * `POST /console/support/token`, which exchanges it for an ordinary-looking
12
+ * developer session scoped to that org. From the console's own point of view
13
+ * it is just a session: the same `GET /api/auth/me` it always calls, extended
14
+ * with a `support` block so the console can show who is driving and let the
15
+ * person end the session themselves.
16
+ *
17
+ * This whole surface is **internal and additive** — `audience: 'internal'` on
18
+ * both routes, nothing here replaces or narrows the public developer
19
+ * reference. Every shape in this file is read by the console and the cloud;
20
+ * none of it is published documentation for an outside integrator, which is
21
+ * also why `authMeResponse` itself is left untouched and `authMeSupportResponse`
22
+ * exists beside it instead.
23
+ */
24
+ /**
25
+ * What a support session tells the console about itself: who is holding it,
26
+ * in which mode, and until when. Carried inside `supportTokenResponse` at the
27
+ * start of the session and inside `authMeSupportResponse` on every later call,
28
+ * because the session row — mode, expiry, whether it has since ended — is
29
+ * re-read from storage each time rather than trusted from the token's claims.
30
+ */
31
+ export const supportSessionInfo = z
32
+ .object({
33
+ session_id: z.uuid().meta({
34
+ description: 'The support session this token or response describes. Stable for the life of the session.',
35
+ }),
36
+ mode: z.enum(['read', 'edit']).meta({
37
+ description: "The session's current mode. Every support session starts `read`; an operator-admin switches one session into `edit`, never the other way, and the switch is a one-way door for the life of the session.",
38
+ }),
39
+ operator_name: z.string().min(1).max(200).meta({
40
+ description: 'The name of the operator-admin holding this session, for the console banner the operator-admin sees. Only the operator-admin\'s own console receives it; the customer\'s audit names every edit as Fleetless-Support, never this name.',
41
+ }),
42
+ expires_at: z.iso.datetime().meta({
43
+ description: 'When the session stops being usable regardless of activity, as an ISO 8601 timestamp. A support session has a hard ceiling; nothing extends it past this instant.',
44
+ }),
45
+ })
46
+ .strict();
47
+ /**
48
+ * `POST /console/support/token`'s request: a one-time grant, proven with the
49
+ * PKCE verifier bound to it when it was minted.
50
+ *
51
+ * **Server to server only** — the console's own server calls this, never a
52
+ * browser — and the grant is single-use: a second presentation of the same
53
+ * grant, a grant that has expired, or a verifier that does not match is every
54
+ * one of them `invalid_grant`, the same RFC 6749 §5.2 dialect
55
+ * `POST /console/oauth/token` already answers in.
56
+ */
57
+ export const supportTokenRequest = z
58
+ .object({
59
+ grant: z.string().regex(/^[A-Za-z0-9_-]{43}$/).meta({
60
+ description: 'The one-time grant minted when the support session was started: 32 random bytes, base64url, no padding. Consumed atomically by this exchange — presenting it again answers the same refusal a forged one would.',
61
+ }),
62
+ code_verifier: z.string().regex(/^[A-Za-z0-9._~-]{43,128}$/).meta({
63
+ description: 'The PKCE verifier whose `S256` hash was sent as the grant\'s challenge when the session was started. Between 43 and 128 unreserved characters, RFC 7636 §4.1\'s charset — the same shape `oauthCodeTokenRequest.code_verifier` checks, compared rather than parsed.',
64
+ }),
65
+ })
66
+ .strict();
67
+ /**
68
+ * `POST /console/support/token`'s response: a bearer token scoped to the org
69
+ * the grant was minted for, **and no refresh token**.
70
+ *
71
+ * A support session is bounded (sixty minutes, no extension) by design, so
72
+ * there is nothing for a refresh to buy back — a refresh token here would be
73
+ * a second way to outlive the ceiling `supportSessionInfo.expires_at` already
74
+ * states. When the access token expires the session is over; starting
75
+ * another one is a new grant, a new exchange, and a new audit trail.
76
+ */
77
+ export const supportTokenResponse = z
78
+ .object({
79
+ access_token: z.string().min(1).meta({
80
+ description: 'The token to send as `Authorization: Bearer <token>`. Short-lived: read `expires_in`, never assume a lifetime.',
81
+ }),
82
+ token_type: z.literal('Bearer').meta({
83
+ description: '`Bearer`, the same spelling every other session token on this wire uses.',
84
+ }),
85
+ expires_in: z.number().int().min(1).max(3600).meta({
86
+ description: 'How long the access token stays valid, in seconds from now — at most 3600 (sixty minutes), the hard ceiling of any support session. Not a timestamp, and not milliseconds.',
87
+ }),
88
+ org_id: z.uuid().meta({
89
+ description: 'The organisation this session was scoped to when the grant was minted.',
90
+ }),
91
+ support: supportSessionInfo.meta({
92
+ description: 'The session as it stands at the moment of exchange: freshly started, in `read` mode.',
93
+ }),
94
+ })
95
+ .strict();
96
+ /**
97
+ * What `GET /api/auth/me` answers **to a support token** — `authMeResponse`
98
+ * with one more, optional field. The public route entry keeps `authMeResponse`
99
+ * itself, so this block stays out of the public reference and the ordinary
100
+ * developer session answer is unchanged; the console validates the actual
101
+ * response it receives against this shape instead, and reads `support` to
102
+ * decide whether to render the "someone is holding this session" banner at
103
+ * all.
104
+ *
105
+ * `support` is **absent, not null**, for an ordinary developer session: the
106
+ * field means "this is a support session" by its own presence, and an
107
+ * ordinary session has never had anything to put there.
108
+ */
109
+ export const authMeSupportResponse = authMeResponse.extend({ support: supportSessionInfo.optional() });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetless/contracts",
3
- "version": "8.0.0",
3
+ "version": "8.1.0-next.1",
4
4
  "description": "Fleetless wire contracts: the bridge-cloud protocol, the REST API schemas and the error codes, as zod schemas with generated JSON Schema and OpenAPI artifacts.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Dehne Robotik GmbH",