@fleetless/contracts 7.1.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 +33 -0
- package/artifacts/openapi.json +1013 -27
- package/artifacts/routes.json +80 -3
- package/artifacts/schema/billing-change-response.schema.json +469 -7
- package/artifacts/schema/billing-charge-invoice.schema.json +54 -0
- package/artifacts/schema/billing-charge.schema.json +216 -0
- package/artifacts/schema/billing-issuer.schema.json +8 -0
- package/artifacts/schema/billing-view.schema.json +232 -3
- package/artifacts/schema/checkout-response.schema.json +5 -1
- package/artifacts/schema/purchase-conflict-details.schema.json +5 -1
- package/artifacts/schema/purchase-hold-reason.schema.json +5 -1
- package/artifacts/schema/purchase-intent-response.schema.json +237 -4
- package/artifacts/schema/support-session-info.schema.json +39 -0
- package/artifacts/schema/support-token-request.schema.json +21 -0
- package/artifacts/schema/support-token-response.schema.json +75 -0
- package/dist/billing.d.ts +229 -0
- package/dist/billing.js +88 -4
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +32 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -1
- package/dist/routes.js +51 -4
- package/dist/support.d.ts +126 -0
- package/dist/support.js +109 -0
- package/package.json +1 -1
package/dist/routes.js
CHANGED
|
@@ -12,7 +12,8 @@ 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 {
|
|
15
|
+
import { supportTokenRequest, supportTokenResponse } from './support.js';
|
|
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 = [
|
|
18
19
|
{ id: 'health', title: 'Health' },
|
|
@@ -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) */
|
|
@@ -3011,7 +3039,9 @@ export const ROUTES = [
|
|
|
3011
3039
|
query: null, request: null, response: null, contentType: 'application/pdf',
|
|
3012
3040
|
errors: [...DEVELOPER_GUARD, 'tier_required', 'not_found'], transport: 'http',
|
|
3013
3041
|
notes: 'Rendered once, with `pdfkit`, when the invoice is issued, and stored as bytes — an issued invoice never changes, so this always ' +
|
|
3014
|
-
'answers the same PDF for the same id. `404 not_found` for an unknown id or one from another org.'
|
|
3042
|
+
'answers the same PDF for the same id. `404 not_found` for an unknown id or one from another org. This reads historical Cloud ' +
|
|
3043
|
+
"invoices only: a due charge has no PDF of its own here — its eventual Lexware invoice is a document, read through " +
|
|
3044
|
+
'`GET /api/billing/documents/:id/file`.',
|
|
3015
3045
|
},
|
|
3016
3046
|
/* --- billing documents (2026-10-19, fleetless/fleetless#544) -------
|
|
3017
3047
|
*
|
|
@@ -3062,11 +3092,28 @@ export const ROUTES = [
|
|
|
3062
3092
|
method: 'POST', path: '/api/billing/invoices/:id/pay', section: 'billing',
|
|
3063
3093
|
summary: "Records an owner-confirmed payment intent for an open invoice or due charge.",
|
|
3064
3094
|
audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 201,
|
|
3065
|
-
params: [{ name: 'id', description: 'The invoice id, from `billingInvoice.id`, of the open invoice to pay — or a due charge\'s id, from `dunning.invoice_id`.' }],
|
|
3095
|
+
params: [{ name: 'id', description: 'The invoice id, from `billingInvoice.id`, of the open invoice to pay — or, before the issuer cutover, a due charge\'s id, from `dunning.invoice_id`.' }],
|
|
3066
3096
|
query: null, request: invoicePayRequest, response: checkoutResponse,
|
|
3067
3097
|
errors: ['validation_error', ...DEVELOPER_GUARD, 'tier_required', 'not_found', 'target_state_conflict', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
|
|
3068
3098
|
transport: 'http',
|
|
3069
|
-
notes: "The required operation_key binds the org, invoice and request; reuse with changed input is 409 target_state_conflict (purchaseConflictDetails). :id may be an issued invoice or a due charge with no number. Recheck current buyer eligibility, VIES, invoice status, owed amount and original currency before every new provider call. Invalid VAT is state invalid_vat_id with rule vat_id_invalid, without a payment. Pending/eligible/held has no redirect; after VIES recovers, the owner must confirm the current quote. An issued USD invoice remains held/legacy_usd_invoice: never convert it or call the provider anew until the integration decision resolves the conflict. Already-created payments retain recorded currency/amount and are looked up/reconciled, never replaced. Under the org lock, confirmation checks the current owed amount and returns the same payment identity on retries. invoice_not_open is a typed conflict; 404 not_found for unknown/foreign invoice. Pending itself never pays an invoice, lifts a lock or resets dunning.",
|
|
3099
|
+
notes: "The required operation_key binds the org, invoice and request; reuse with changed input is 409 target_state_conflict (purchaseConflictDetails). :id may be an issued invoice or a due charge with no number. Recheck current buyer eligibility, VIES, invoice status, owed amount and original currency before every new provider call. Invalid VAT is state invalid_vat_id with rule vat_id_invalid, without a payment. Pending/eligible/held has no redirect; after VIES recovers, the owner must confirm the current quote. An issued USD invoice remains held/legacy_usd_invoice: never convert it or call the provider anew until the integration decision resolves the conflict. Already-created payments retain recorded currency/amount and are looked up/reconciled, never replaced. Under the org lock, confirmation checks the current owed amount and returns the same payment identity on retries. invoice_not_open is a typed conflict; 404 not_found for unknown/foreign invoice. Pending itself never pays an invoice, lifts a lock or resets dunning. After the issuer cutover, :id names a historical open FL-… invoice only; a due charge after the cutover answers 404 not_found here — pay it with POST /api/billing/charges/:id/pay instead.",
|
|
3100
|
+
},
|
|
3101
|
+
{
|
|
3102
|
+
method: 'POST', path: '/api/billing/charges/:id/pay', section: 'billing',
|
|
3103
|
+
summary: 'Records an owner-confirmed payment intent for a due Lexware-issuer charge.',
|
|
3104
|
+
audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 201,
|
|
3105
|
+
params: [{ name: 'id', description: 'The due charge id, from `billingCharge.id` in `GET /api/billing`\'s `charges`.' }],
|
|
3106
|
+
query: null, request: chargePayRequest, response: checkoutResponse,
|
|
3107
|
+
errors: ['validation_error', ...DEVELOPER_GUARD, 'tier_required', 'not_found', 'target_state_conflict', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
|
|
3108
|
+
transport: 'http',
|
|
3109
|
+
notes: 'The required operation_key binds the org, charge and request, exactly like POST /api/billing/invoices/:id/pay; reuse with ' +
|
|
3110
|
+
'changed input is 409 target_state_conflict (purchaseConflictDetails). :id is a due charge\'s own id (billingCharge.id) — never ' +
|
|
3111
|
+
'a historical Cloud invoice; an invoice id, an unknown id or one from another org all answer 404 not_found alike. Recheck ' +
|
|
3112
|
+
"current buyer eligibility, the charge's own status and the owed amount before every new provider call: a charge already paid, " +
|
|
3113
|
+
'cancelled or uncollectible is invoice_not_open, a typed 409 conflict. Pending/eligible/held has no redirect; after recovery ' +
|
|
3114
|
+
'the owner must confirm the current quote. Already-created payments retain their recorded currency/amount and are looked ' +
|
|
3115
|
+
'up/reconciled, never replaced. Under the org lock, confirmation checks the current owed amount and returns the same payment ' +
|
|
3116
|
+
'identity on retries.',
|
|
3070
3117
|
},
|
|
3071
3118
|
{
|
|
3072
3119
|
method: 'POST', path: '/api/billing/mollie/webhook', section: 'billing',
|
|
@@ -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>;
|
package/dist/support.js
ADDED
|
@@ -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": "
|
|
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",
|