@sixb/server 0.0.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/LICENSE +21 -0
- package/README.md +123 -0
- package/dist/auth/access-token-boundary.d.ts +23 -0
- package/dist/auth/access-token-boundary.d.ts.map +1 -0
- package/dist/auth/application-access.d.ts +4 -0
- package/dist/auth/application-access.d.ts.map +1 -0
- package/dist/auth/browser-origin.d.ts +62 -0
- package/dist/auth/browser-origin.d.ts.map +1 -0
- package/dist/auth/csrf.d.ts +2 -0
- package/dist/auth/csrf.d.ts.map +1 -0
- package/dist/auth/guard.d.ts +35 -0
- package/dist/auth/guard.d.ts.map +1 -0
- package/dist/auth/public-routes.d.ts +8 -0
- package/dist/auth/public-routes.d.ts.map +1 -0
- package/dist/auth/responses.d.ts +11 -0
- package/dist/auth/responses.d.ts.map +1 -0
- package/dist/auth/return-to.d.ts +3 -0
- package/dist/auth/return-to.d.ts.map +1 -0
- package/dist/auth/scope.d.ts +43 -0
- package/dist/auth/scope.d.ts.map +1 -0
- package/dist/auth/session-activity.d.ts +4 -0
- package/dist/auth/session-activity.d.ts.map +1 -0
- package/dist/auth/session-cookies.d.ts +12 -0
- package/dist/auth/session-cookies.d.ts.map +1 -0
- package/dist/files/content.d.ts +141 -0
- package/dist/files/content.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11522 -0
- package/dist/index.js.map +78 -0
- package/dist/openapi/security.d.ts +26 -0
- package/dist/openapi/security.d.ts.map +1 -0
- package/dist/openapi/tags.d.ts +151 -0
- package/dist/openapi/tags.d.ts.map +1 -0
- package/dist/registerRoutes.d.ts +31 -0
- package/dist/registerRoutes.d.ts.map +1 -0
- package/dist/routes/action-runs.d.ts +244 -0
- package/dist/routes/action-runs.d.ts.map +1 -0
- package/dist/routes/actions.d.ts +183 -0
- package/dist/routes/actions.d.ts.map +1 -0
- package/dist/routes/agent-api-gateway.d.ts +4 -0
- package/dist/routes/agent-api-gateway.d.ts.map +1 -0
- package/dist/routes/agents.d.ts +1061 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/auth.d.ts +1366 -0
- package/dist/routes/auth.d.ts.map +1 -0
- package/dist/routes/connectors.d.ts +108 -0
- package/dist/routes/connectors.d.ts.map +1 -0
- package/dist/routes/datasets.d.ts +339 -0
- package/dist/routes/datasets.d.ts.map +1 -0
- package/dist/routes/events.d.ts +116 -0
- package/dist/routes/events.d.ts.map +1 -0
- package/dist/routes/files.d.ts +340 -0
- package/dist/routes/files.d.ts.map +1 -0
- package/dist/routes/links.d.ts +175 -0
- package/dist/routes/links.d.ts.map +1 -0
- package/dist/routes/logs.d.ts +88 -0
- package/dist/routes/logs.d.ts.map +1 -0
- package/dist/routes/objects.d.ts +450 -0
- package/dist/routes/objects.d.ts.map +1 -0
- package/dist/routes/ontology.d.ts +240 -0
- package/dist/routes/ontology.d.ts.map +1 -0
- package/dist/routes/pipelines.d.ts +399 -0
- package/dist/routes/pipelines.d.ts.map +1 -0
- package/dist/routes/project.d.ts +56 -0
- package/dist/routes/project.d.ts.map +1 -0
- package/dist/routes/projections.d.ts +916 -0
- package/dist/routes/projections.d.ts.map +1 -0
- package/dist/routes/rules.d.ts +165 -0
- package/dist/routes/rules.d.ts.map +1 -0
- package/dist/routes/status.d.ts +81 -0
- package/dist/routes/status.d.ts.map +1 -0
- package/dist/routes/syncs.d.ts +294 -0
- package/dist/routes/syncs.d.ts.map +1 -0
- package/dist/routes/telemetry.d.ts +241 -0
- package/dist/routes/telemetry.d.ts.map +1 -0
- package/dist/routes/webhook-runs.d.ts +89 -0
- package/dist/routes/webhook-runs.d.ts.map +1 -0
- package/dist/routes/webhooks.d.ts +60 -0
- package/dist/routes/webhooks.d.ts.map +1 -0
- package/dist/routes/workflows.d.ts +973 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/ws/agents.d.ts +99 -0
- package/dist/routes/ws/agents.d.ts.map +1 -0
- package/dist/routes/ws/events.d.ts +89 -0
- package/dist/routes/ws/events.d.ts.map +1 -0
- package/dist/routes/ws/index.d.ts +31 -0
- package/dist/routes/ws/index.d.ts.map +1 -0
- package/dist/routes/ws/log-subscription-hub.d.ts +47 -0
- package/dist/routes/ws/log-subscription-hub.d.ts.map +1 -0
- package/dist/routes/ws/logs.d.ts +110 -0
- package/dist/routes/ws/logs.d.ts.map +1 -0
- package/dist/schemas/actions.d.ts +644 -0
- package/dist/schemas/actions.d.ts.map +1 -0
- package/dist/schemas/agents.d.ts +3157 -0
- package/dist/schemas/agents.d.ts.map +1 -0
- package/dist/schemas/auth.d.ts +2023 -0
- package/dist/schemas/auth.d.ts.map +1 -0
- package/dist/schemas/common.d.ts +30 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/connectors.d.ts +82 -0
- package/dist/schemas/connectors.d.ts.map +1 -0
- package/dist/schemas/datasets.d.ts +744 -0
- package/dist/schemas/datasets.d.ts.map +1 -0
- package/dist/schemas/event-payloads.d.ts +477 -0
- package/dist/schemas/event-payloads.d.ts.map +1 -0
- package/dist/schemas/events.d.ts +665 -0
- package/dist/schemas/events.d.ts.map +1 -0
- package/dist/schemas/files.d.ts +241 -0
- package/dist/schemas/files.d.ts.map +1 -0
- package/dist/schemas/links.d.ts +90 -0
- package/dist/schemas/links.d.ts.map +1 -0
- package/dist/schemas/logs.d.ts +231 -0
- package/dist/schemas/logs.d.ts.map +1 -0
- package/dist/schemas/objects.d.ts +288 -0
- package/dist/schemas/objects.d.ts.map +1 -0
- package/dist/schemas/ontology.d.ts +778 -0
- package/dist/schemas/ontology.d.ts.map +1 -0
- package/dist/schemas/pipelines.d.ts +1373 -0
- package/dist/schemas/pipelines.d.ts.map +1 -0
- package/dist/schemas/project.d.ts +9 -0
- package/dist/schemas/project.d.ts.map +1 -0
- package/dist/schemas/projections.d.ts +6992 -0
- package/dist/schemas/projections.d.ts.map +1 -0
- package/dist/schemas/rules.d.ts +204 -0
- package/dist/schemas/rules.d.ts.map +1 -0
- package/dist/schemas/status.d.ts +189 -0
- package/dist/schemas/status.d.ts.map +1 -0
- package/dist/schemas/syncs.d.ts +538 -0
- package/dist/schemas/syncs.d.ts.map +1 -0
- package/dist/schemas/telemetry.d.ts +265 -0
- package/dist/schemas/telemetry.d.ts.map +1 -0
- package/dist/schemas/webhook-runs.d.ts +169 -0
- package/dist/schemas/webhook-runs.d.ts.map +1 -0
- package/dist/schemas/workflows.d.ts +1720 -0
- package/dist/schemas/workflows.d.ts.map +1 -0
- package/dist/server.d.ts +64 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/tsconfig.json +5 -0
- package/dist/utils/http.d.ts +23 -0
- package/dist/utils/http.d.ts.map +1 -0
- package/dist/utils/request-body.d.ts +15 -0
- package/dist/utils/request-body.d.ts.map +1 -0
- package/dist/utils/ws.d.ts +10 -0
- package/dist/utils/ws.d.ts.map +1 -0
- package/package.json +68 -0
- package/src/auth/access-token-boundary.ts +68 -0
- package/src/auth/application-access.ts +16 -0
- package/src/auth/browser-origin.ts +367 -0
- package/src/auth/csrf.ts +1 -0
- package/src/auth/guard.ts +169 -0
- package/src/auth/public-routes.ts +87 -0
- package/src/auth/responses.ts +54 -0
- package/src/auth/return-to.ts +21 -0
- package/src/auth/scope.ts +64 -0
- package/src/auth/session-activity.ts +19 -0
- package/src/auth/session-cookies.ts +43 -0
- package/src/files/content.ts +419 -0
- package/src/index.ts +2 -0
- package/src/openapi/security.ts +37 -0
- package/src/openapi/tags.ts +151 -0
- package/src/registerRoutes.ts +49 -0
- package/src/routes/action-runs.ts +238 -0
- package/src/routes/actions.ts +126 -0
- package/src/routes/agent-api-gateway.ts +260 -0
- package/src/routes/agents.ts +943 -0
- package/src/routes/auth.ts +2233 -0
- package/src/routes/connectors.ts +69 -0
- package/src/routes/datasets.ts +402 -0
- package/src/routes/events.ts +55 -0
- package/src/routes/files.ts +675 -0
- package/src/routes/links.ts +143 -0
- package/src/routes/logs.ts +65 -0
- package/src/routes/objects.ts +838 -0
- package/src/routes/ontology.ts +138 -0
- package/src/routes/pipelines.ts +332 -0
- package/src/routes/project.ts +16 -0
- package/src/routes/projections.ts +251 -0
- package/src/routes/rules.ts +124 -0
- package/src/routes/status.ts +53 -0
- package/src/routes/syncs.ts +243 -0
- package/src/routes/telemetry.ts +207 -0
- package/src/routes/webhook-runs.ts +81 -0
- package/src/routes/webhooks.ts +508 -0
- package/src/routes/workflows.ts +1333 -0
- package/src/routes/ws/agents.ts +301 -0
- package/src/routes/ws/events.ts +278 -0
- package/src/routes/ws/index.ts +12 -0
- package/src/routes/ws/log-subscription-hub.ts +375 -0
- package/src/routes/ws/logs.ts +117 -0
- package/src/schemas/actions.ts +123 -0
- package/src/schemas/agents.ts +293 -0
- package/src/schemas/auth.ts +317 -0
- package/src/schemas/common.ts +60 -0
- package/src/schemas/connectors.ts +21 -0
- package/src/schemas/datasets.ts +107 -0
- package/src/schemas/event-payloads.ts +79 -0
- package/src/schemas/events.ts +117 -0
- package/src/schemas/files.ts +82 -0
- package/src/schemas/links.ts +38 -0
- package/src/schemas/logs.ts +76 -0
- package/src/schemas/objects.ts +759 -0
- package/src/schemas/ontology.ts +77 -0
- package/src/schemas/pipelines.ts +150 -0
- package/src/schemas/project.ts +5 -0
- package/src/schemas/projections.ts +144 -0
- package/src/schemas/rules.ts +98 -0
- package/src/schemas/status.ts +51 -0
- package/src/schemas/syncs.ts +83 -0
- package/src/schemas/telemetry.ts +59 -0
- package/src/schemas/webhook-runs.ts +40 -0
- package/src/schemas/workflows.ts +229 -0
- package/src/server.ts +383 -0
- package/src/utils/http.ts +108 -0
- package/src/utils/request-body.ts +62 -0
- package/src/utils/ws.ts +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sixb contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# @sixb/server
|
|
2
|
+
|
|
3
|
+
Sixb API server. Owns the REST API, auth routes, WebSocket API, and OpenAPI docs. The built-in
|
|
4
|
+
Atlas UI is served by `@sixb/atlas`.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
bun add @sixb/server
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { createSixb } from "@sixb/core"
|
|
16
|
+
import { createSixbServer } from "@sixb/server"
|
|
17
|
+
|
|
18
|
+
const sixb = await createSixb({ /* providers, ontology, ... */ })
|
|
19
|
+
|
|
20
|
+
const server = createSixbServer({
|
|
21
|
+
sixb,
|
|
22
|
+
port: 3002,
|
|
23
|
+
browser: {
|
|
24
|
+
publicOrigin: "https://api.example.com",
|
|
25
|
+
allowedOrigins: [
|
|
26
|
+
{ origin: "https://atlas.example.com", audience: "atlas" },
|
|
27
|
+
{ origin: "https://app.example.com", audience: "app" },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
await server.start()
|
|
32
|
+
// Server running at http://0.0.0.0:3002
|
|
33
|
+
// OpenAPI docs at http://0.0.0.0:3002/docs
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Each configured audience identifies the browser application for exactly one origin. Configured
|
|
37
|
+
origins are shown as invitation destinations and participate in `can.access(applications.atlas)` or
|
|
38
|
+
`can.access(applications.app)` authorization.
|
|
39
|
+
|
|
40
|
+
## API Routes
|
|
41
|
+
|
|
42
|
+
### REST Endpoints
|
|
43
|
+
|
|
44
|
+
| Method | Path | Description |
|
|
45
|
+
|--------|------|-------------|
|
|
46
|
+
| `GET` | `/api/project` | Project metadata |
|
|
47
|
+
| `GET` | `/api/status` | Runtime status (object type and function counts) |
|
|
48
|
+
| `GET` | `/api/actions` | List registered actions |
|
|
49
|
+
| `GET` | `/api/actions/:actionId` | Get action metadata |
|
|
50
|
+
| `POST` | `/api/actions/:actionId` | Request an action (`subject` is optional for global actions) |
|
|
51
|
+
| `GET` | `/api/object-types` | List registered object types |
|
|
52
|
+
| `GET` | `/api/object-types/:objectTypeId` | Get object type definition |
|
|
53
|
+
| `GET` | `/api/objects` | List objects (`?objectTypeId=&idPrefix=&limit=&offset=&orderBy=&order=`) |
|
|
54
|
+
| `GET` | `/api/objects/:objectTypeId/:objectKey` | Get object by key |
|
|
55
|
+
| `PUT` | `/api/objects/:objectTypeId/:objectKey` | Create or update object |
|
|
56
|
+
| `GET` | `/api/objects/:objectTypeId/:objectKey/links` | List object links (`?linkId=`) |
|
|
57
|
+
| `PUT` | `/api/objects/:objectTypeId/:objectKey/links/:linkId` | Create or update link |
|
|
58
|
+
| `DELETE` | `/api/objects/:objectTypeId/:objectKey/links/:linkId` | Remove link (`?targetTypeId=&targetKey=`) |
|
|
59
|
+
| `POST` | `/api/objects/:objectTypeId/:objectKey/telemetry/:propertyId` | Append telemetry point |
|
|
60
|
+
| `GET` | `/api/objects/:objectTypeId/:objectKey/telemetry/:propertyId/history` | Get telemetry history (`?from=&to=&limit=&order=`) |
|
|
61
|
+
| `GET` | `/api/objects/:objectTypeId/:objectKey/telemetry/:propertyId/latest` | Get latest telemetry point |
|
|
62
|
+
| `GET` | `/api/events` | Read domain events (`?topic=&type=&afterCursor=&limit=`) |
|
|
63
|
+
| `POST` | `/api/files` | Upload a file in one request |
|
|
64
|
+
| `POST` | `/api/files/uploads` | Open an upload session for a large or client-uploaded file |
|
|
65
|
+
| `PUT` | `/api/files/uploads/:uploadId/content` | Send session content through the API |
|
|
66
|
+
| `POST` | `/api/files/uploads/:uploadId/parts/:partNumber` | Sign one part for direct upload to blob storage |
|
|
67
|
+
| `POST` | `/api/files/uploads/:uploadId/complete` | Complete the session and return the file reference |
|
|
68
|
+
| `POST` | `/api/files/uploads/:uploadId/abort` | Discard the session |
|
|
69
|
+
| `GET` | `/api/objects/:objectTypeId/:objectKey/files/content` | Download a `fileRef` property (`?path=/properties/scan`) |
|
|
70
|
+
|
|
71
|
+
Upload sessions default to an in-memory store: neither `@sixb/pg` nor `@sixb/sqlite` implements
|
|
72
|
+
`fileUploadSessions` in the pre-0.1 line, so a session does not survive a restart and is not shared
|
|
73
|
+
across replicas. Single-request `POST /api/files` is unaffected.
|
|
74
|
+
|
|
75
|
+
### WebSocket
|
|
76
|
+
|
|
77
|
+
**`/ws/events`** -- Real-time domain event streaming. On connect, the server sends a `connected` message and waits for an explicit subscription.
|
|
78
|
+
|
|
79
|
+
Send messages to control the subscription:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{ "type": "subscribe", "topic": "telemetry", "types": ["telemetry.appended"], "afterCursor": "42" }
|
|
83
|
+
{ "type": "unsubscribe" }
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- `topic` -- Filter by topic: `objects`, `telemetry`, `links`, `actions`, `schedules`, `syncs`, `pipelines`, `workflows`, `datasets`, or `rules`.
|
|
87
|
+
- `types` -- Filter by event type, for example `object.updated`, `link.created`, `telemetry.appended`, `action.requested`, or `workflow.run.finished`.
|
|
88
|
+
- `afterCursor` -- Start streaming after a broker cursor. Defaults to the cursor captured when the socket opened.
|
|
89
|
+
|
|
90
|
+
Events are delivered as:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{ "type": "event", "event": { "cursor": "42", "type": "telemetry.appended", "payload": { ... }, "occurredAt": "..." } }
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Exports
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { createSixbServer, SixbServer } from "@sixb/server"
|
|
100
|
+
import type { SixbServerOptions } from "@sixb/server"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- **`createSixbServer(options)`** -- Entrypoint for starting the API/auth/ws/docs server.
|
|
104
|
+
- **`SixbServer`** -- Manages the server lifecycle (`start`, `stop`).
|
|
105
|
+
- **`SixbServerOptions`** -- Config: `sixb` and `browser` (required), `port` (default 3000), `host` (default `"0.0.0.0"`), `quiet`.
|
|
106
|
+
|
|
107
|
+
## OpenAPI
|
|
108
|
+
|
|
109
|
+
The server auto-generates an OpenAPI spec from route definitions. Interactive docs are served at `/docs`. To extract the spec as JSON:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
bun run generate:openapi
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Client Package
|
|
116
|
+
|
|
117
|
+
`@sixb/client` is auto-generated from this server's OpenAPI spec. After modifying routes, regenerate with:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
bun generate:client
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Always set `detail.operationId` on routes to keep generated function names stable.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RouteAccess } from "./public-routes";
|
|
2
|
+
export type AuthCredentialSource = "session" | "accessToken";
|
|
3
|
+
export interface AccessTokenRoute {
|
|
4
|
+
readonly operationId: string;
|
|
5
|
+
readonly method: string;
|
|
6
|
+
readonly path: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const ACCESS_TOKEN_ROUTES: readonly AccessTokenRoute[];
|
|
9
|
+
/**
|
|
10
|
+
* OpenAPI security requirement for a bearer-capable route, derived from the
|
|
11
|
+
* canonical table. Reads (CSRF-exempt methods) accept a bearer token only;
|
|
12
|
+
* mutations accept either a CSRF token (cookie sessions) or a bearer token.
|
|
13
|
+
* Throws when the operation is not a registered bearer route, so a route can
|
|
14
|
+
* never claim bearer access without being added to the boundary.
|
|
15
|
+
*/
|
|
16
|
+
export declare function bearerSecurityRequirement(operationId: string): ({
|
|
17
|
+
sixbCsrf: string[];
|
|
18
|
+
} | {
|
|
19
|
+
sixbBearer: string[];
|
|
20
|
+
})[];
|
|
21
|
+
export declare function isAccessTokenRoute(request: Request): boolean;
|
|
22
|
+
export declare function shouldVerifyCsrfForAuthSource(route: RouteAccess, source: AuthCredentialSource): boolean;
|
|
23
|
+
//# sourceMappingURL=access-token-boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-token-boundary.d.ts","sourceRoot":"","sources":["../../src/auth/access-token-boundary.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,aAAa,CAAA;AAE5D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAYD,eAAO,MAAM,mBAAmB,EAAE,SAAS,gBAAgB,EAEmC,CAAA;AAE9F;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM;;;;KAW5D;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAQ5D;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAIT"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type AuthSessionAudience, type OntologySource, type Sixb } from "@sixb/core";
|
|
2
|
+
import type { AuthenticatedRequestAuthSession } from "@sixb/core/internal/auth";
|
|
3
|
+
export declare function sessionCanAccessApplication(sixb: Sixb<readonly OntologySource[]>, session: AuthenticatedRequestAuthSession, audience: AuthSessionAudience): boolean;
|
|
4
|
+
//# sourceMappingURL=application-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-access.d.ts","sourceRoot":"","sources":["../../src/auth/application-access.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,cAAc,EACnB,KAAK,IAAI,EACV,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAA;AAE/E,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,CAAC,SAAS,cAAc,EAAE,CAAC,EACrC,OAAO,EAAE,+BAA+B,EACxC,QAAQ,EAAE,mBAAmB,GAC5B,OAAO,CAGT"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type AuthSessionAudience } from "@sixb/core";
|
|
2
|
+
export interface SixbBrowserOrigin {
|
|
3
|
+
readonly origin: string;
|
|
4
|
+
readonly audience: AuthSessionAudience;
|
|
5
|
+
}
|
|
6
|
+
export interface SixbApiBrowserPolicy {
|
|
7
|
+
readonly publicOrigin?: string;
|
|
8
|
+
readonly allowedOrigins: readonly SixbBrowserOrigin[];
|
|
9
|
+
readonly apiOriginAudience?: AuthSessionAudience;
|
|
10
|
+
}
|
|
11
|
+
export interface ResolvedSixbBrowserOrigin {
|
|
12
|
+
readonly origin: string;
|
|
13
|
+
readonly audience: AuthSessionAudience;
|
|
14
|
+
}
|
|
15
|
+
export interface ResolvedSixbApiBrowserPolicy {
|
|
16
|
+
readonly publicOrigin?: string;
|
|
17
|
+
readonly apiOriginAudience: AuthSessionAudience;
|
|
18
|
+
readonly allowedOrigins: readonly ResolvedSixbBrowserOrigin[];
|
|
19
|
+
}
|
|
20
|
+
export interface RequestAuthContext {
|
|
21
|
+
readonly audience: AuthSessionAudience;
|
|
22
|
+
readonly browserOrigin?: string;
|
|
23
|
+
readonly absoluteReturnTo?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface AuthInvitationDestination {
|
|
26
|
+
readonly id: AuthSessionAudience;
|
|
27
|
+
readonly label: string;
|
|
28
|
+
}
|
|
29
|
+
export interface AuthInvitationDestinationOptions {
|
|
30
|
+
readonly destinations: readonly AuthInvitationDestination[];
|
|
31
|
+
readonly defaultDestinationId?: AuthSessionAudience;
|
|
32
|
+
}
|
|
33
|
+
export interface AuthInvitationRedirectInput {
|
|
34
|
+
readonly destinationId?: AuthSessionAudience;
|
|
35
|
+
readonly returnTo?: string;
|
|
36
|
+
}
|
|
37
|
+
export type AuthInvitationRedirectContext = AuthRedirectContext;
|
|
38
|
+
export type ResolveRequestAuthContext = (request: Request) => RequestAuthContext;
|
|
39
|
+
export interface AuthRedirectInput {
|
|
40
|
+
readonly audience?: string | null;
|
|
41
|
+
readonly returnTo?: string | null;
|
|
42
|
+
readonly fallbackReturnToOrigin?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface AuthRedirectContext {
|
|
45
|
+
readonly audience: AuthSessionAudience;
|
|
46
|
+
readonly returnTo: string;
|
|
47
|
+
readonly requestOrigin: string;
|
|
48
|
+
}
|
|
49
|
+
export type ResolveAuthRedirectContext = (request: Request, input: AuthRedirectInput) => AuthRedirectContext;
|
|
50
|
+
export declare class BrowserOriginError extends Error {
|
|
51
|
+
readonly name = "BrowserOriginError";
|
|
52
|
+
}
|
|
53
|
+
export declare function resolveApiBrowserPolicy(policy: SixbApiBrowserPolicy): ResolvedSixbApiBrowserPolicy;
|
|
54
|
+
export declare function createApiBrowserAuthContextResolver(policy: ResolvedSixbApiBrowserPolicy): ResolveRequestAuthContext;
|
|
55
|
+
export declare function createApiBrowserAuthRedirectContextResolver(policy: ResolvedSixbApiBrowserPolicy): ResolveAuthRedirectContext;
|
|
56
|
+
export declare function resolveApiBrowserAuthContext(policy: ResolvedSixbApiBrowserPolicy, request: Request): RequestAuthContext;
|
|
57
|
+
export declare function isAllowedApiBrowserOrigin(policy: ResolvedSixbApiBrowserPolicy, request: Request): boolean;
|
|
58
|
+
export declare function resolveApiBrowserAuthRedirectContext(policy: ResolvedSixbApiBrowserPolicy, request: Request, input: AuthRedirectInput): AuthRedirectContext;
|
|
59
|
+
export declare function getApiBrowserInvitationDestinationOptions(policy: ResolvedSixbApiBrowserPolicy): AuthInvitationDestinationOptions;
|
|
60
|
+
export declare function resolveApiBrowserInvitationRedirectContext(policy: ResolvedSixbApiBrowserPolicy, request: Request, input: AuthInvitationRedirectInput): AuthInvitationRedirectContext;
|
|
61
|
+
export declare function resolveApiBrowserPublicOrigin(policy: ResolvedSixbApiBrowserPolicy, request: Request): string;
|
|
62
|
+
//# sourceMappingURL=browser-origin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-origin.d.ts","sourceRoot":"","sources":["../../src/auth/browser-origin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAKzB,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAA;CACvC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC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,CAER"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csrf.d.ts","sourceRoot":"","sources":["../../src/auth/csrf.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { OntologySource, Sixb } from "@sixb/core";
|
|
2
|
+
import { type AuthenticatedRequestAuthSession } from "@sixb/core/internal/auth";
|
|
3
|
+
import { type ResolveRequestAuthContext } from "./browser-origin";
|
|
4
|
+
export interface ServerAuthGuardOptions {
|
|
5
|
+
readonly sixb: Sixb<readonly OntologySource[]>;
|
|
6
|
+
readonly resolveAuthContext: ResolveRequestAuthContext;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Per-request authentication decision.
|
|
10
|
+
*
|
|
11
|
+
* `deny` carries the short-circuit response. `allow` carries the resolved
|
|
12
|
+
* session so downstream handlers can use it without resolving it again
|
|
13
|
+
* (null when auth is disabled or the route is public).
|
|
14
|
+
*/
|
|
15
|
+
export type ServerAuthGuardDecision = {
|
|
16
|
+
readonly kind: "deny";
|
|
17
|
+
readonly response: Response;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "allow";
|
|
20
|
+
readonly session: AuthenticatedRequestAuthSession | null;
|
|
21
|
+
};
|
|
22
|
+
export declare class ServerAuthGuard {
|
|
23
|
+
private readonly sixb;
|
|
24
|
+
private readonly resolveAuthContext;
|
|
25
|
+
constructor(options: ServerAuthGuardOptions);
|
|
26
|
+
isAuthEnabled(): boolean;
|
|
27
|
+
assertCanServeHttp(params: {
|
|
28
|
+
readonly production: boolean;
|
|
29
|
+
}): void;
|
|
30
|
+
resolve(request: Request): Promise<ServerAuthGuardDecision>;
|
|
31
|
+
getCsrfCookieName(request: Request): string;
|
|
32
|
+
verifyCsrf(request: Request, _session: AuthenticatedRequestAuthSession): boolean;
|
|
33
|
+
private tryResolveAuthContext;
|
|
34
|
+
}
|
|
35
|
+
//# sourceM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-0,0 +1,8 @@
|
|
|
1
|
+
export type RouteAccessKind = "public" | "api" | "html" | "websocket";
|
|
2
|
+
export interface RouteAccess {
|
|
3
|
+
readonly kind: RouteAccessKind;
|
|
4
|
+
readonly csrfProtected: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function classifyRoute(request: Request): RouteAccess;
|
|
7
|
+
export declare function isPublicRoute(pathname: string, method: string): boolean;
|
|
8
|
+
//# sourceMappingURL=public-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-routes.d.ts","sourceRoot":"","sources":["../../src/auth/public-routes.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,WAAW,CAAA;AAErE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;IAC9B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;CAChC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAwB3D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAkDvE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AuthSessionAudience } from "@sixb/core";
|
|
2
|
+
export declare function jsonAuthRequiredResponse(): Response;
|
|
3
|
+
export declare function jsonCsrfFailedResponse(): Response;
|
|
4
|
+
export declare function jsonForbiddenResponse(message?: string): Response;
|
|
5
|
+
export declare function htmlAuthRedirectResponse(request: Request, options?: {
|
|
6
|
+
readonly absoluteReturnTo?: boolean;
|
|
7
|
+
readonly audience?: AuthSessionAudience;
|
|
8
|
+
}): Response;
|
|
9
|
+
export declare function websocketAuthFailedResponse(): Response;
|
|
10
|
+
export declare function jsonResponse(body: unknown, status?: number, headers?: HeadersInit): Response;
|
|
11
|
+
//# sourceMappingURL=responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/auth/responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAGrD,wBAAgB,wBAAwB,IAAI,QAAQ,CAEnD;AAED,wBAAgB,sBAAsB,IAAI,QAAQ,CAEjD;AAED,wBAAgB,qBAAqB,CAAC,OAAO,SAAc,GAAG,QAAQ,CAErE;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE;IACP,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAA;CACnC,GACL,QAAQ,CAiBV;AAED,wBAAgB,2BAA2B,IAAI,QAAQ,CAEtD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,SAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,CASzF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"return-to.d.ts","sourceRoot":"","sources":["../../src/auth/return-to.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAezE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAG3D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AuthorizationContext, OntologySource, ScopedSixb } from "@sixb/core";
|
|
2
|
+
import type { AgentRunRecord } from "@sixb/core/storage";
|
|
3
|
+
/**
|
|
4
|
+
* Per-request authorization state attached by the server's auth derive.
|
|
5
|
+
*
|
|
6
|
+
* Both fields are null when auth is disabled or the route is public — those
|
|
7
|
+
* requests run against the privileged runtime, preserving authenticated-only
|
|
8
|
+
* behavior for surfaces that are not grant-enforced yet.
|
|
9
|
+
*
|
|
10
|
+
* SECURITY — privileged is the silent default. The core runtime treats a
|
|
11
|
+
* missing authorization context as fully privileged (workers, syncs, tests
|
|
12
|
+
* need that). A scoped principal therefore gains no protection unless the route
|
|
13
|
+
* actively routes through `scoped`. Concretely:
|
|
14
|
+
*
|
|
15
|
+
* - A grant-enforced read/list/query/action/workflow handler MUST use
|
|
16
|
+
* `scoped` (falling back to the raw `sixb` only when `scoped` is null).
|
|
17
|
+
* Using the raw `sixb` on a path an authenticated principal can reach is a
|
|
18
|
+
* silent god-mode bypass — it will not fail to compile or to run.
|
|
19
|
+
* - Surfaces with no grant family yet (object/link/telemetry writes,
|
|
20
|
+
* auth admin) stay authenticated-only by design and use the raw `sixb`
|
|
21
|
+
* deliberately, not by omission. Add such a route consciously, and lock it
|
|
22
|
+
* down when its grant family lands.
|
|
23
|
+
*
|
|
24
|
+
* This implicit default is a known V1 trade-off (kept for runtime ergonomics);
|
|
25
|
+
* if it proves error-prone, make privileged access explicit at this boundary.
|
|
26
|
+
*/
|
|
27
|
+
export interface RequestAuthState {
|
|
28
|
+
readonly authz: AuthorizationContext | null;
|
|
29
|
+
readonly scoped: ScopedSixb<readonly OntologySource[]> | null;
|
|
30
|
+
/** Present for requests proxied through the run-scoped agent API gateway. */
|
|
31
|
+
readonly agentRun?: AgentRunRecord;
|
|
32
|
+
}
|
|
33
|
+
export declare function registerInternalRequestAuthState(request: Request, authState: RequestAuthState): void;
|
|
34
|
+
export declare function consumeInternalRequestAuthState(request: Request): RequestAuthState | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Read the derived auth state from a route handler's context.
|
|
37
|
+
*
|
|
38
|
+
* Route registrars type `app` as plain `Elysia`, so the derived properties are
|
|
39
|
+
* not visible to handler signatures; this helper is the single typed access
|
|
40
|
+
* point until route registration carries the derived context type.
|
|
41
|
+
*/
|
|
42
|
+
export declare function requestAuthState(context: unknown): RequestAuthState;
|
|
43
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/auth/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAA;IAC3C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,cAAc,EAAE,CAAC,GAAG,IAAI,CAAA;IAC7D,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;CACnC;AAID,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,gBAAgB,GAC1B,IAAI,CAEN;AAED,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,GAAG,SAAS,CAM9F;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAGnE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const SESSION_ACTIVITY_HEADER_NAME = "x-sixb-session-activity";
|
|
2
|
+
export declare function hasForegroundSessionActivity(request: Request): boolean;
|
|
3
|
+
export declare function isSessionTerminationRequest(request: Request): boolean;
|
|
4
|
+
//# sourceMappingURL=session-activity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-activity.d.ts","sourceRoot":"","sources":["../../src/auth/session-activity.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,4BAA4B,CAAA;AAGrE,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEtE;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAWrE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OntologySource, Sixb } from "@sixb/core";
|
|
2
|
+
import { type AuthenticatedAuthSession } from "@sixb/core/internal/auth";
|
|
3
|
+
export declare function createSessionRenewalCookieHeaders(input: {
|
|
4
|
+
readonly sixb: Sixb<readonly OntologySource[]>;
|
|
5
|
+
readonly request: Request;
|
|
6
|
+
readonly session: AuthenticatedAuthSession;
|
|
7
|
+
readonly csrfToken?: string;
|
|
8
|
+
}): {
|
|
9
|
+
readonly csrfToken: string;
|
|
10
|
+
readonly headers: readonly [string, string];
|
|
11
|
+
} | null;
|
|
12
|
+
//# sourceMappingURL=session-cookies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-cookies.d.ts","sourceRoot":"","sources":["../../src/auth/session-cookies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EACL,KAAK,wBAAwB,EAK9B,MAAM,0BAA0B,CAAA;AAEjC,wBAAgB,iCAAiC,CAAC,KAAK,EAAE;IACvD,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,cAAc,EAAE,CAAC,CAAA;IAC9C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAA;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,CA4BrF"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { type BlobStorage, type FileRef } from "@sixb/core";
|
|
2
|
+
export type FileContentDisposition = "inline" | "attachment";
|
|
3
|
+
export interface FileContentResponseInput {
|
|
4
|
+
readonly blobStorage: BlobStorage;
|
|
5
|
+
readonly fileRef: FileRef;
|
|
6
|
+
readonly disposition?: FileContentDisposition;
|
|
7
|
+
readonly head?: boolean;
|
|
8
|
+
readonly rangeHeader?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface FileContentQuery {
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly disposition?: FileContentDisposition;
|
|
13
|
+
}
|
|
14
|
+
export interface ContextualFileContentResponseInput<TQuery extends FileContentQuery> {
|
|
15
|
+
readonly blobStorage: BlobStorage;
|
|
16
|
+
readonly query: unknown;
|
|
17
|
+
readonly querySchema: {
|
|
18
|
+
parse(value: unknown): TQuery;
|
|
19
|
+
};
|
|
20
|
+
readonly request: Request;
|
|
21
|
+
readonly set: {
|
|
22
|
+
status?: number | string;
|
|
23
|
+
};
|
|
24
|
+
readonly head?: boolean;
|
|
25
|
+
readonly resolveRoot: (query: TQuery) => Promise<unknown | null | undefined> | unknown | null;
|
|
26
|
+
readonly hideError?: (error: unknown) => boolean;
|
|
27
|
+
readonly missingMessage?: string;
|
|
28
|
+
readonly invalidQueryMessage?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface FileContentResponsesOptions {
|
|
31
|
+
/** Add the 501 the route returns when its storage role is absent. */
|
|
32
|
+
readonly optionalStorage?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare function fileContentGetResponses(options?: FileContentResponsesOptions): {
|
|
35
|
+
readonly 501?: {
|
|
36
|
+
readonly description: "The storage role backing this content is not configured";
|
|
37
|
+
readonly content: {
|
|
38
|
+
readonly "application/json": {
|
|
39
|
+
readonly schema: {
|
|
40
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
} | undefined;
|
|
45
|
+
readonly 200: {
|
|
46
|
+
readonly description: "File content";
|
|
47
|
+
readonly content: {
|
|
48
|
+
readonly "application/octet-stream": {
|
|
49
|
+
readonly schema: {
|
|
50
|
+
readonly type: "string";
|
|
51
|
+
readonly format: "binary";
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
readonly 206: {
|
|
57
|
+
readonly description: "Partial file content";
|
|
58
|
+
readonly content: {
|
|
59
|
+
readonly "application/octet-stream": {
|
|
60
|
+
readonly schema: {
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
readonly format: "binary";
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
readonly 400: {
|
|
68
|
+
readonly description: "Response for status 400";
|
|
69
|
+
readonly content: {
|
|
70
|
+
readonly "application/json": {
|
|
71
|
+
readonly schema: {
|
|
72
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
readonly 404: {
|
|
78
|
+
readonly description: "Response for status 404";
|
|
79
|
+
readonly content: {
|
|
80
|
+
readonly "application/json": {
|
|
81
|
+
readonly schema: {
|
|
82
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
readonly 416: {
|
|
88
|
+
readonly description: "Requested byte range is not satisfiable";
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export declare function fileContentHeadResponses(options?: FileContentResponsesOptions): {
|
|
92
|
+
readonly 501?: {
|
|
93
|
+
readonly description: "The storage role backing this content is not configured";
|
|
94
|
+
readonly content: {
|
|
95
|
+
readonly "application/json": {
|
|
96
|
+
readonly schema: {
|
|
97
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
} | undefined;
|
|
102
|
+
readonly 200: {
|
|
103
|
+
readonly description: "File content headers";
|
|
104
|
+
};
|
|
105
|
+
readonly 206: {
|
|
106
|
+
readonly description: "Partial file content headers";
|
|
107
|
+
};
|
|
108
|
+
readonly 400: {
|
|
109
|
+
readonly description: "Response for status 400";
|
|
110
|
+
readonly content: {
|
|
111
|
+
readonly "application/json": {
|
|
112
|
+
readonly schema: {
|
|
113
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
readonly 404: {
|
|
119
|
+
readonly description: "Response for status 404";
|
|
120
|
+
readonly content: {
|
|
121
|
+
readonly "application/json": {
|
|
122
|
+
readonly schema: {
|
|
123
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
readonly 416: {
|
|
129
|
+
readonly description: "Requested byte range is not satisfiable";
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export declare function createFileContentResponse(input: FileContentResponseInput): Promise<Response | null>;
|
|
133
|
+
/**
|
|
134
|
+
* Serve a FileRef only through the record that contains it. Callers authorize the containing
|
|
135
|
+
* context first, then this helper validates the content-addressed FileRef before streaming.
|
|
136
|
+
*/
|
|
137
|
+
export declare function createContextualFileContentResponse<TQuery extends FileContentQuery>(input: ContextualFileContentResponseInput<TQuery>): Promise<Response | {
|
|
138
|
+
readonly error: string;
|
|
139
|
+
}>;
|
|
140
|
+
export declare function resolveFileRefAtPath(root: unknown, path: string): FileRef | null;
|
|
141
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/files/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,OAAO,EAAa,MAAM,YAAY,CAAA;AAIrF,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,YAAY,CAAA;AAE5D,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IACjC,QA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