@tristan2828/ui-foundation 3.30.1 → 4.1.0
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/dist/api/contracts.d.ts +6 -1
- package/dist/api/gateway/auth.d.ts +19 -1
- package/dist/api/gateway/auth.js +20 -2
- package/dist/api/gateway/client-errors.d.ts +4 -0
- package/dist/api/gateway/client-errors.js +14 -0
- package/dist/api/gateway/errors.d.ts +2 -1
- package/dist/api/gateway/errors.js +34 -1
- package/dist/api/schema.d.ts +154 -0
- package/dist/api/transport/index.d.ts +2 -0
- package/dist/api/transport/index.js +2 -2
- package/dist/auth/auth-context.d.ts +21 -1
- package/dist/auth/auth-context.js +2 -1
- package/dist/auth/auth-provider.js +16 -2
- package/dist/components/app/app-shell.js +4 -1
- package/dist/components/app/error-state.js +1 -0
- package/dist/components/app/foundation-providers.d.ts +9 -1
- package/dist/components/app/foundation-providers.js +5 -2
- package/dist/components/app/route-error-boundary.js +11 -0
- package/dist/error-reporting/error-reporting-context.d.ts +6 -0
- package/dist/error-reporting/error-reporting-context.js +16 -0
- package/dist/error-reporting/error-reporting-provider.d.ts +14 -0
- package/dist/error-reporting/error-reporting-provider.js +28 -0
- package/dist/error-reporting/reporter.d.ts +30 -0
- package/dist/error-reporting/reporter.js +126 -0
- package/dist/index.d.ts +2 -1
- package/dist/mocks/auth.d.ts +3 -0
- package/dist/mocks/auth.js +39 -0
- package/dist/mocks/client-errors.d.ts +7 -0
- package/dist/mocks/client-errors.js +24 -0
- package/dist/mocks/e2e-hooks.js +2 -2
- package/dist/mocks/index.d.ts +2 -1
- package/dist/mocks/index.js +2 -1
- package/dist/mocks/override.d.ts +2 -0
- package/dist/routes/login-schema.d.ts +7 -0
- package/dist/routes/login-schema.js +8 -0
- package/dist/routes/login.js +95 -9
- package/openapi/foundation.yaml +114 -2
- package/package.json +1 -1
package/openapi/foundation.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
openapi: 3.1.0
|
|
2
2
|
info:
|
|
3
3
|
title: UI Foundation — the contract every app shares
|
|
4
|
-
version: "
|
|
4
|
+
version: "4.1.0"
|
|
5
5
|
description: >
|
|
6
6
|
The part of an app's API contract that the foundation package's own code
|
|
7
7
|
calls: session-cookie auth under /auth/*, and the two error envelopes the
|
|
@@ -36,8 +36,43 @@ paths:
|
|
|
36
36
|
content:
|
|
37
37
|
application/json:
|
|
38
38
|
schema: { $ref: "#/components/schemas/User" }
|
|
39
|
+
"202":
|
|
40
|
+
description: >
|
|
41
|
+
The password is right and the account has a second step. No
|
|
42
|
+
session yet: sets a short-lived, single-use pending_login cookie
|
|
43
|
+
for POST /auth/login/totp.
|
|
44
|
+
content:
|
|
45
|
+
application/json:
|
|
46
|
+
schema: { $ref: "#/components/schemas/LoginNextStep" }
|
|
39
47
|
"401": { $ref: "#/components/responses/UnauthorizedError" }
|
|
40
48
|
"422": { $ref: "#/components/responses/ValidationError" }
|
|
49
|
+
"429": { $ref: "#/components/responses/RateLimitedError" }
|
|
50
|
+
"500": { $ref: "#/components/responses/ServerError" }
|
|
51
|
+
|
|
52
|
+
/auth/login/totp:
|
|
53
|
+
x-optional: true
|
|
54
|
+
post:
|
|
55
|
+
operationId: loginTotp
|
|
56
|
+
summary: The second step of a sign-in, a code from an authenticator app or a recovery code
|
|
57
|
+
description: >
|
|
58
|
+
Needs the pending_login cookie a 202 from POST /auth/login set. A
|
|
59
|
+
right code starts the session as a 200 from /auth/login does.
|
|
60
|
+
tags: [auth]
|
|
61
|
+
requestBody:
|
|
62
|
+
required: true
|
|
63
|
+
content:
|
|
64
|
+
application/json:
|
|
65
|
+
schema: { $ref: "#/components/schemas/TotpLoginRequest" }
|
|
66
|
+
responses:
|
|
67
|
+
"200":
|
|
68
|
+
description: Authenticated. Sets the session_id cookie.
|
|
69
|
+
content:
|
|
70
|
+
application/json:
|
|
71
|
+
schema: { $ref: "#/components/schemas/User" }
|
|
72
|
+
"401": { $ref: "#/components/responses/UnauthorizedError" }
|
|
73
|
+
"410": { $ref: "#/components/responses/SignInExpiredError" }
|
|
74
|
+
"422": { $ref: "#/components/responses/ValidationError" }
|
|
75
|
+
"429": { $ref: "#/components/responses/RateLimitedError" }
|
|
41
76
|
"500": { $ref: "#/components/responses/ServerError" }
|
|
42
77
|
|
|
43
78
|
/auth/register:
|
|
@@ -101,6 +136,31 @@ paths:
|
|
|
101
136
|
schema: { $ref: "#/components/schemas/DataEnvironment" }
|
|
102
137
|
"500": { $ref: "#/components/responses/ServerError" }
|
|
103
138
|
|
|
139
|
+
/client-errors:
|
|
140
|
+
x-optional: true
|
|
141
|
+
post:
|
|
142
|
+
operationId: reportClientError
|
|
143
|
+
summary: A failure in the browser, for the backend to forward to error reporting
|
|
144
|
+
description: >
|
|
145
|
+
Sent by the package when an app turns on FoundationProviders'
|
|
146
|
+
errorReporting. Needs a session, so the public can't post into it.
|
|
147
|
+
The backend may drop a report (a duplicate, too many) and still
|
|
148
|
+
answer 204. The user is the session's; the report never carries
|
|
149
|
+
request or response bodies, cookies, headers, form values or
|
|
150
|
+
query strings.
|
|
151
|
+
tags: [errors]
|
|
152
|
+
requestBody:
|
|
153
|
+
required: true
|
|
154
|
+
content:
|
|
155
|
+
application/json:
|
|
156
|
+
schema: { $ref: "#/components/schemas/ClientErrorReport" }
|
|
157
|
+
responses:
|
|
158
|
+
"204":
|
|
159
|
+
description: Received (forwarded, or dropped as a duplicate).
|
|
160
|
+
"401": { $ref: "#/components/responses/UnauthorizedError" }
|
|
161
|
+
"422": { $ref: "#/components/responses/ValidationError" }
|
|
162
|
+
"500": { $ref: "#/components/responses/ServerError" }
|
|
163
|
+
|
|
104
164
|
components:
|
|
105
165
|
schemas:
|
|
106
166
|
DataEnvironment:
|
|
@@ -127,7 +187,26 @@ components:
|
|
|
127
187
|
required: [email, password]
|
|
128
188
|
properties:
|
|
129
189
|
email: { type: string, format: email }
|
|
130
|
-
password: { type: string, minLength: 8 }
|
|
190
|
+
password: { type: string, minLength: 8, maxLength: 1024 }
|
|
191
|
+
|
|
192
|
+
LoginNextStep:
|
|
193
|
+
type: object
|
|
194
|
+
required: [next]
|
|
195
|
+
properties:
|
|
196
|
+
next:
|
|
197
|
+
type: string
|
|
198
|
+
enum: [totp]
|
|
199
|
+
description: The step the sign-in still needs.
|
|
200
|
+
|
|
201
|
+
TotpLoginRequest:
|
|
202
|
+
type: object
|
|
203
|
+
required: [code]
|
|
204
|
+
properties:
|
|
205
|
+
code:
|
|
206
|
+
type: string
|
|
207
|
+
minLength: 1
|
|
208
|
+
maxLength: 64
|
|
209
|
+
description: The 6-digit code from the authenticator app, or a recovery code.
|
|
131
210
|
|
|
132
211
|
RegisterRequest:
|
|
133
212
|
type: object
|
|
@@ -137,6 +216,25 @@ components:
|
|
|
137
216
|
name: { $ref: "#/components/schemas/User/properties/name" }
|
|
138
217
|
password: { $ref: "#/components/schemas/LoginRequest/properties/password" }
|
|
139
218
|
|
|
219
|
+
ClientErrorReport:
|
|
220
|
+
type: object
|
|
221
|
+
required: [source, type, message]
|
|
222
|
+
properties:
|
|
223
|
+
source:
|
|
224
|
+
type: string
|
|
225
|
+
enum: [route, window, unhandledrejection, query, mutation]
|
|
226
|
+
description: Where the package caught it.
|
|
227
|
+
type: { type: string, minLength: 1, maxLength: 200, description: "The error's type (TypeError, ServerError)." }
|
|
228
|
+
message: { type: string, maxLength: 2000 }
|
|
229
|
+
stack: { type: string, maxLength: 16000 }
|
|
230
|
+
route:
|
|
231
|
+
type: string
|
|
232
|
+
maxLength: 300
|
|
233
|
+
description: The route pattern (/items/:id), never the URL.
|
|
234
|
+
method: { type: string, maxLength: 10, description: The HTTP method of a failed request. }
|
|
235
|
+
status: { type: integer, minimum: 100, maximum: 599, description: The HTTP status of a failed request. }
|
|
236
|
+
release: { type: string, maxLength: 100, description: The frontend build (its commit). }
|
|
237
|
+
|
|
140
238
|
ValidationErrorBody:
|
|
141
239
|
type: object
|
|
142
240
|
description: FastAPI's default 422 shape (RequestValidationError).
|
|
@@ -178,6 +276,20 @@ components:
|
|
|
178
276
|
content:
|
|
179
277
|
application/json:
|
|
180
278
|
schema: { $ref: "#/components/schemas/HTTPErrorBody" }
|
|
279
|
+
RateLimitedError:
|
|
280
|
+
description: Too many failed attempts. Try again after Retry-After seconds.
|
|
281
|
+
headers:
|
|
282
|
+
Retry-After:
|
|
283
|
+
description: Seconds until another attempt is allowed.
|
|
284
|
+
schema: { type: integer, minimum: 1 }
|
|
285
|
+
content:
|
|
286
|
+
application/json:
|
|
287
|
+
schema: { $ref: "#/components/schemas/HTTPErrorBody" }
|
|
288
|
+
SignInExpiredError:
|
|
289
|
+
description: The pending sign-in is missing, expired or out of tries. Start again with POST /auth/login.
|
|
290
|
+
content:
|
|
291
|
+
application/json:
|
|
292
|
+
schema: { $ref: "#/components/schemas/HTTPErrorBody" }
|
|
181
293
|
ServerError:
|
|
182
294
|
description: Unhandled server error.
|
|
183
295
|
content:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|