@lostgradient/backchannel 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +62 -2
- package/dist/access-policy-metadata.d.ts +92 -0
- package/dist/access-policy-metadata.js +87 -0
- package/dist/asyncapi-channels.d.ts +46 -0
- package/dist/asyncapi-channels.js +399 -0
- package/dist/asyncapi.d.ts +40 -0
- package/dist/asyncapi.js +165 -0
- package/dist/authentication/api-key.d.ts +4 -0
- package/dist/authentication/api-key.js +114 -0
- package/dist/authentication/audit.d.ts +115 -0
- package/dist/authentication/audit.js +75 -0
- package/dist/authentication/credential-verifiers.d.ts +60 -0
- package/dist/authentication/credential-verifiers.js +102 -0
- package/dist/authentication/crypto.d.ts +7 -0
- package/dist/authentication/crypto.js +140 -0
- package/dist/authentication/index.d.ts +80 -0
- package/dist/authentication/index.js +212 -0
- package/dist/authentication/rate-limiter.d.ts +133 -0
- package/dist/authentication/rate-limiter.js +124 -0
- package/dist/authentication/redaction.d.ts +72 -0
- package/dist/authentication/redaction.js +118 -0
- package/dist/authentication/rotating-api-key-store.d.ts +127 -0
- package/dist/authentication/rotating-api-key-store.js +126 -0
- package/dist/authentication/types.d.ts +337 -0
- package/dist/authentication/types.js +26 -0
- package/dist/authentication.d.ts +1 -0
- package/dist/authentication.js +1 -0
- package/dist/authorization-scope.d.ts +109 -0
- package/dist/authorization-scope.js +144 -0
- package/dist/authorization.d.ts +55 -0
- package/dist/authorization.js +134 -0
- package/dist/bind-feed-lifetime.d.ts +45 -0
- package/dist/bind-feed-lifetime.js +55 -0
- package/dist/byte-arrays.d.ts +5 -0
- package/dist/byte-arrays.js +9 -0
- package/dist/client/catalog-client.d.ts +285 -0
- package/dist/client/catalog-client.js +74 -0
- package/dist/client/in-process-transport.d.ts +19 -0
- package/dist/client/in-process-transport.js +136 -0
- package/dist/client/index.d.ts +14 -0
- package/dist/client/index.js +14 -0
- package/dist/client/json-rpc-http-transport.d.ts +118 -0
- package/dist/client/json-rpc-http-transport.js +127 -0
- package/dist/client/server-sent-event-parser.d.ts +55 -0
- package/dist/client/server-sent-event-parser.js +78 -0
- package/dist/client/sse-subscription-transport.d.ts +72 -0
- package/dist/client/sse-subscription-transport.js +224 -0
- package/dist/client/subscription-client.d.ts +122 -0
- package/dist/client/subscription-client.js +28 -0
- package/dist/connection-lease.d.ts +10 -0
- package/dist/connection-lease.js +8 -0
- package/dist/discovery-filter.d.ts +13 -0
- package/dist/discovery-filter.js +16 -0
- package/dist/discovery-info.d.ts +94 -0
- package/dist/discovery-info.js +38 -0
- package/dist/event-selector.d.ts +7 -0
- package/dist/event-selector.js +7 -0
- package/dist/fault-code.d.ts +84 -0
- package/dist/fault-code.js +114 -0
- package/dist/fault-remediation.d.ts +30 -0
- package/dist/fault-remediation.js +52 -0
- package/dist/fault-to-http.d.ts +11 -0
- package/dist/fault-to-http.js +13 -0
- package/dist/fault-to-json-rpc.d.ts +53 -0
- package/dist/fault-to-json-rpc.js +143 -0
- package/dist/fault-wire-safety.d.ts +45 -0
- package/dist/fault-wire-safety.js +72 -0
- package/dist/generator.d.ts +9 -0
- package/dist/generator.js +9 -0
- package/dist/handler/auth-context-principal.d.ts +37 -0
- package/dist/handler/auth-context-principal.js +67 -0
- package/dist/handler/authentication-responses.d.ts +23 -0
- package/dist/handler/authentication-responses.js +34 -0
- package/dist/handler/json-responses.d.ts +15 -0
- package/dist/handler/json-responses.js +32 -0
- package/dist/handler/operation-handler-authentication.d.ts +64 -0
- package/dist/handler/operation-handler-authentication.js +58 -0
- package/dist/handler/operation-handler-discovery.d.ts +29 -0
- package/dist/handler/operation-handler-discovery.js +55 -0
- package/dist/handler/operation-handler-mounts.d.ts +100 -0
- package/dist/handler/operation-handler-mounts.js +134 -0
- package/dist/handler/operation-handler-subscription.d.ts +34 -0
- package/dist/handler/operation-handler-subscription.js +112 -0
- package/dist/handler/operation-handler.d.ts +162 -0
- package/dist/handler/operation-handler.js +236 -0
- package/dist/handler/workspace-release.d.ts +6 -0
- package/dist/handler/workspace-release.js +75 -0
- package/dist/in-memory-replay-live-backend.d.ts +47 -0
- package/dist/in-memory-replay-live-backend.js +129 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +30 -0
- package/dist/internal/cryptography/encryption.d.ts +108 -0
- package/dist/internal/cryptography/encryption.js +241 -0
- package/dist/internal/cryptography/hash.d.ts +72 -0
- package/dist/internal/cryptography/hash.js +233 -0
- package/dist/internal/cryptography/index.d.ts +4 -0
- package/dist/internal/cryptography/index.js +2 -0
- package/dist/internals.d.ts +58 -0
- package/dist/internals.js +54 -0
- package/dist/json-rpc-dispatch.d.ts +88 -0
- package/dist/json-rpc-dispatch.js +154 -0
- package/dist/json-rpc-framing.d.ts +42 -0
- package/dist/json-rpc-framing.js +50 -0
- package/dist/json-rpc-http.d.ts +36 -0
- package/dist/json-rpc-http.js +191 -0
- package/dist/json-rpc-parse.d.ts +69 -0
- package/dist/json-rpc-parse.js +206 -0
- package/dist/json-rpc-protocol.d.ts +76 -0
- package/dist/json-rpc-protocol.js +54 -0
- package/dist/json-rpc-session-runtime.d.ts +55 -0
- package/dist/json-rpc-session-runtime.js +111 -0
- package/dist/json-rpc-websocket-subscription-pump.d.ts +9 -0
- package/dist/json-rpc-websocket-subscription-pump.js +46 -0
- package/dist/json-rpc-websocket-subscriptions.d.ts +10 -0
- package/dist/json-rpc-websocket-subscriptions.js +33 -0
- package/dist/json-rpc-websocket-types.d.ts +34 -0
- package/dist/json-rpc-websocket-types.js +1 -0
- package/dist/json-rpc-websocket-validation.d.ts +45 -0
- package/dist/json-rpc-websocket-validation.js +154 -0
- package/dist/json-rpc-websocket.d.ts +20 -0
- package/dist/json-rpc-websocket.js +363 -0
- package/dist/json-schema-utilities.d.ts +5 -0
- package/dist/json-schema-utilities.js +17 -0
- package/dist/mcp-discovery-names.d.ts +11 -0
- package/dist/mcp-discovery-names.js +11 -0
- package/dist/openapi-canonical-json.d.ts +10 -0
- package/dist/openapi-canonical-json.js +23 -0
- package/dist/openapi-error-responses.d.ts +15 -0
- package/dist/openapi-error-responses.js +104 -0
- package/dist/openapi-schemas.d.ts +17 -0
- package/dist/openapi-schemas.js +94 -0
- package/dist/openapi.d.ts +60 -0
- package/dist/openapi.js +351 -0
- package/dist/openrpc-document-schema.d.ts +255 -0
- package/dist/openrpc-document-schema.js +84 -0
- package/dist/openrpc-errors.d.ts +93 -0
- package/dist/openrpc-errors.js +134 -0
- package/dist/openrpc.d.ts +66 -0
- package/dist/openrpc.js +260 -0
- package/dist/operation-catalog/behavior-types.d.ts +34 -0
- package/dist/operation-catalog/behavior-types.js +1 -0
- package/dist/operation-catalog/behavior-validation.d.ts +3 -0
- package/dist/operation-catalog/behavior-validation.js +298 -0
- package/dist/operation-catalog/dispatch-allowlist.d.ts +4 -0
- package/dist/operation-catalog/dispatch-allowlist.js +7 -0
- package/dist/operation-catalog/dispatch-preparation.d.ts +24 -0
- package/dist/operation-catalog/dispatch-preparation.js +49 -0
- package/dist/operation-catalog/index.d.ts +19 -0
- package/dist/operation-catalog/index.js +17 -0
- package/dist/operation-catalog/operation-dispatch.d.ts +14 -0
- package/dist/operation-catalog/operation-dispatch.js +115 -0
- package/dist/operation-catalog/operation-interceptors.d.ts +15 -0
- package/dist/operation-catalog/operation-interceptors.js +1 -0
- package/dist/operation-catalog/operation-metadata.d.ts +5 -0
- package/dist/operation-catalog/operation-metadata.js +104 -0
- package/dist/operation-catalog/pipeline-helpers.d.ts +70 -0
- package/dist/operation-catalog/pipeline-helpers.js +242 -0
- package/dist/operation-catalog/pipeline-stages.d.ts +23 -0
- package/dist/operation-catalog/pipeline-stages.js +226 -0
- package/dist/operation-catalog/pipeline.d.ts +7 -0
- package/dist/operation-catalog/pipeline.js +33 -0
- package/dist/operation-catalog/registry.d.ts +17 -0
- package/dist/operation-catalog/registry.js +132 -0
- package/dist/operation-catalog/stream-pipeline.d.ts +37 -0
- package/dist/operation-catalog/stream-pipeline.js +129 -0
- package/dist/operation-catalog/subscription-lifecycle.d.ts +6 -0
- package/dist/operation-catalog/subscription-lifecycle.js +27 -0
- package/dist/operation-catalog/types.d.ts +392 -0
- package/dist/operation-catalog/types.js +40 -0
- package/dist/operation-catalog/universal-faults.d.ts +11 -0
- package/dist/operation-catalog/universal-faults.js +15 -0
- package/dist/operation-catalog-snapshot.d.ts +215 -0
- package/dist/operation-catalog-snapshot.js +128 -0
- package/dist/operation-catalog.d.ts +1 -0
- package/dist/operation-catalog.js +1 -0
- package/dist/operation-description-audit.d.ts +44 -0
- package/dist/operation-description-audit.js +90 -0
- package/dist/operation-fault-helpers.d.ts +21 -0
- package/dist/operation-fault-helpers.js +32 -0
- package/dist/operation-fault.d.ts +245 -0
- package/dist/operation-fault.js +235 -0
- package/dist/operation-registry.d.ts +46 -0
- package/dist/operation-registry.js +46 -0
- package/dist/operations/closable-iterable.d.ts +23 -0
- package/dist/operations/closable-iterable.js +51 -0
- package/dist/operations/get-principal.d.ts +106 -0
- package/dist/operations/get-principal.js +107 -0
- package/dist/operations/sse-stream.d.ts +67 -0
- package/dist/operations/sse-stream.js +264 -0
- package/dist/principal.d.ts +253 -0
- package/dist/principal.js +254 -0
- package/dist/replay-live-feed-internals.d.ts +47 -0
- package/dist/replay-live-feed-internals.js +215 -0
- package/dist/replay-live-feed-types.d.ts +66 -0
- package/dist/replay-live-feed-types.js +7 -0
- package/dist/replay-live-feed.d.ts +49 -0
- package/dist/replay-live-feed.js +126 -0
- package/dist/rest-binding.d.ts +215 -0
- package/dist/rest-binding.js +95 -0
- package/dist/rest-body.d.ts +17 -0
- package/dist/rest-body.js +95 -0
- package/dist/route-model.d.ts +305 -0
- package/dist/route-model.js +320 -0
- package/dist/runtime/cors.d.ts +161 -0
- package/dist/runtime/cors.js +265 -0
- package/dist/scripts/generate-operation-client.d.ts +186 -0
- package/dist/scripts/generate-operation-client.js +561 -0
- package/dist/scripts/operation-behaviors.d.ts +3 -0
- package/dist/scripts/operation-behaviors.js +16 -0
- package/dist/scripts/operation-client-aliases.d.ts +32 -0
- package/dist/scripts/operation-client-aliases.js +255 -0
- package/dist/scripts/operation-client-domains.d.ts +21 -0
- package/dist/scripts/operation-client-domains.js +74 -0
- package/dist/scripts/operation-client-schema.d.ts +46 -0
- package/dist/scripts/operation-client-schema.js +310 -0
- package/dist/scripts/operation-client-svelte.d.ts +3 -0
- package/dist/scripts/operation-client-svelte.js +61 -0
- package/dist/sequence-cursor.d.ts +46 -0
- package/dist/sequence-cursor.js +62 -0
- package/dist/sse-error-payload-schema.d.ts +12 -0
- package/dist/sse-error-payload-schema.js +33 -0
- package/dist/stdio-session.d.ts +71 -0
- package/dist/stdio-session.js +347 -0
- package/dist/zod-json-schema.d.ts +22 -0
- package/dist/zod-json-schema.js +49 -0
- package/package.json +38 -3
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { compareStrings } from "./json-schema-utilities.js";
|
|
2
|
+
import { externalApiPath, JSON_RPC_PATH } from "./route-model.js";
|
|
3
|
+
import { sseErrorPayloadSchema } from "./sse-error-payload-schema.js";
|
|
4
|
+
const JSON_RPC_VERSION = '2.0';
|
|
5
|
+
const EVENT_DELIVER_METHOD = 'weft.events.deliver';
|
|
6
|
+
const EVENTS_TERMINATED_METHOD = 'weft.events.terminated';
|
|
7
|
+
const WORKFLOW_SUBSCRIPTION_OPERATION_NAME = 'weft.workflows.events';
|
|
8
|
+
const WORKFLOW_SUBSCRIPTION_REQUEST_METHOD = 'weft.workflows.subscribe';
|
|
9
|
+
const UNSUBSCRIBE_METHOD = 'weft.workflows.unsubscribe';
|
|
10
|
+
// Accepts string | number for normal request/response correlation, plus
|
|
11
|
+
// `null` because the WebSocket handler emits `id: request.id ?? null` for
|
|
12
|
+
// JSON-RPC error responses to malformed frames where no caller id is known.
|
|
13
|
+
const JSON_RPC_ID_SCHEMA = {
|
|
14
|
+
oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'null' }],
|
|
15
|
+
};
|
|
16
|
+
// Mirrors the exact reason strings emitted by `json-rpc-websocket.ts`.
|
|
17
|
+
// Adding entries here without an emit site (or removing one without
|
|
18
|
+
// updating the emitter) makes `/asyncapi.json` lie about the wire.
|
|
19
|
+
// `engine-error` and `overflow` were specified speculatively but the
|
|
20
|
+
// session collapses both cases into `server-closed` (with a `fault`
|
|
21
|
+
// payload), so they are intentionally absent from this enum.
|
|
22
|
+
const SUBSCRIPTION_TERMINATION_REASON_SCHEMA = {
|
|
23
|
+
enum: ['client-unsubscribed', 'server-closed', 'validation-failed'],
|
|
24
|
+
type: 'string',
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Build the AsyncAPI channel object for a WebSocket subscription operation.
|
|
28
|
+
*/
|
|
29
|
+
export function buildWebSocketChannel(operation) {
|
|
30
|
+
const messageNames = webSocketMessageNames(operation);
|
|
31
|
+
return {
|
|
32
|
+
// External wire address: the JSON-RPC WebSocket is served under the `/api`
|
|
33
|
+
// prefix. Internal routing matches the canonical `/jsonrpc` after the front
|
|
34
|
+
// door strips the prefix.
|
|
35
|
+
address: externalApiPath(JSON_RPC_PATH),
|
|
36
|
+
bindings: {
|
|
37
|
+
ws: {
|
|
38
|
+
method: 'GET',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
description: `JSON-RPC WebSocket subscription channel for ${operation.name}.`,
|
|
42
|
+
messages: messageReferenceMap(messageNames),
|
|
43
|
+
title: operation.summary,
|
|
44
|
+
'x-weft-operation-name': operation.name,
|
|
45
|
+
'x-weft-transport': 'json-rpc-websocket',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build the AsyncAPI channel object for an SSE stream operation.
|
|
50
|
+
*
|
|
51
|
+
* `restBindingPath` MUST be the operation's REST binding path translated to
|
|
52
|
+
* OpenAPI path-parameter syntax (e.g. `/v1/workflows/{id}/sse`). Without it
|
|
53
|
+
* the channel address falls back to a synthetic dotted-name-to-path
|
|
54
|
+
* conversion that does not match any wire endpoint — kept only as a
|
|
55
|
+
* non-failing default so a misconfigured registry produces a recognizable
|
|
56
|
+
* synthetic address rather than throwing during document generation.
|
|
57
|
+
*/
|
|
58
|
+
export function buildSseChannel(operation, restBindingPath,
|
|
59
|
+
/**
|
|
60
|
+
* Maps the binding path to its wire address. Defaults to the `/api`
|
|
61
|
+
* external prefix `serve()` mounts; the engine-independent handler has no
|
|
62
|
+
* front door and passes the path through unchanged.
|
|
63
|
+
*/
|
|
64
|
+
toWireAddress = externalApiPath) {
|
|
65
|
+
const messageNames = sseMessageNames(operation);
|
|
66
|
+
// Real REST binding paths are served under `/api`; the synthetic
|
|
67
|
+
// unbound-fallback is not a wire endpoint, so it is left unprefixed.
|
|
68
|
+
const address = restBindingPath !== undefined
|
|
69
|
+
? toWireAddress(restBindingPath)
|
|
70
|
+
: `/x-weft-unbound/${operation.name.replaceAll('.', '/')}`;
|
|
71
|
+
return {
|
|
72
|
+
address,
|
|
73
|
+
description: `Server-Sent Events stream channel for ${operation.name}. ` +
|
|
74
|
+
'Responses use text/event-stream; charset=utf-8.',
|
|
75
|
+
messages: messageReferenceMap(messageNames),
|
|
76
|
+
title: operation.summary,
|
|
77
|
+
'x-weft-operation-name': operation.name,
|
|
78
|
+
'x-weft-transport': 'server-sent-events',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Build named component messages for a WebSocket subscription operation.
|
|
83
|
+
*/
|
|
84
|
+
export function buildWebSocketMessages(operation, definitionSchemaToJsonSchema) {
|
|
85
|
+
const names = webSocketMessageNames(operation);
|
|
86
|
+
const inputSchema = definitionSchemaToJsonSchema(operation.inputSchema);
|
|
87
|
+
const outputSchema = definitionSchemaToJsonSchema(operation.outputSchema, 'output');
|
|
88
|
+
const eventSchema = eventJsonSchema(operation, definitionSchemaToJsonSchema);
|
|
89
|
+
return {
|
|
90
|
+
[names.subscribeRequest]: {
|
|
91
|
+
name: names.subscribeRequest,
|
|
92
|
+
contentType: 'application/json',
|
|
93
|
+
payload: jsonRpcRequestPayload(subscriptionRequestMethod(operation), inputSchema),
|
|
94
|
+
summary: `Subscribe to ${operation.name}.`,
|
|
95
|
+
},
|
|
96
|
+
[names.subscribeAck]: {
|
|
97
|
+
name: names.subscribeAck,
|
|
98
|
+
contentType: 'application/json',
|
|
99
|
+
payload: jsonRpcSuccessPayload(outputSchema),
|
|
100
|
+
summary: `Subscription acknowledgement for ${operation.name}.`,
|
|
101
|
+
},
|
|
102
|
+
[names.eventDeliver]: {
|
|
103
|
+
name: names.eventDeliver,
|
|
104
|
+
contentType: 'application/json',
|
|
105
|
+
payload: eventDeliverPayload(eventSchema),
|
|
106
|
+
summary: `Event delivery notification for ${operation.name}.`,
|
|
107
|
+
},
|
|
108
|
+
[names.unsubscribeRequest]: {
|
|
109
|
+
name: names.unsubscribeRequest,
|
|
110
|
+
contentType: 'application/json',
|
|
111
|
+
payload: jsonRpcRequestPayload(UNSUBSCRIBE_METHOD, {
|
|
112
|
+
additionalProperties: false,
|
|
113
|
+
properties: {
|
|
114
|
+
subscriptionId: { type: 'string' },
|
|
115
|
+
},
|
|
116
|
+
required: ['subscriptionId'],
|
|
117
|
+
type: 'object',
|
|
118
|
+
}),
|
|
119
|
+
summary: `Unsubscribe from ${operation.name}.`,
|
|
120
|
+
},
|
|
121
|
+
[names.terminated]: {
|
|
122
|
+
name: names.terminated,
|
|
123
|
+
contentType: 'application/json',
|
|
124
|
+
payload: terminatedPayload(),
|
|
125
|
+
summary: `Subscription termination notification for ${operation.name}.`,
|
|
126
|
+
},
|
|
127
|
+
[names.errorFrame]: {
|
|
128
|
+
name: names.errorFrame,
|
|
129
|
+
contentType: 'application/json',
|
|
130
|
+
payload: jsonRpcErrorPayload(),
|
|
131
|
+
summary: `JSON-RPC error response for ${operation.name}.`,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Build named component messages for an SSE stream operation.
|
|
137
|
+
*
|
|
138
|
+
* The token message's `data:` line carries the operation's wire-encoded
|
|
139
|
+
* token text — for the only SSE operation today (`weft.workflows.streams.sse`)
|
|
140
|
+
* that is the raw `token` string from `mapTokenChunkToText`, NOT a JSON
|
|
141
|
+
* encoding of the operation's `eventSchema`. The `eventSchema` describes
|
|
142
|
+
* the logical per-element type for non-SSE callers (JSON-RPC envelopes
|
|
143
|
+
* carry the full object); SSE is a separate, plain-text wire.
|
|
144
|
+
*
|
|
145
|
+
* The schema below reflects the actual SSE wire. The `x-weft-event-schema`
|
|
146
|
+
* extension surfaces the logical schema for clients that need it.
|
|
147
|
+
*/
|
|
148
|
+
export function buildSseMessages(operation, definitionSchemaToJsonSchema) {
|
|
149
|
+
const logicalEventSchema = eventJsonSchema(operation, definitionSchemaToJsonSchema);
|
|
150
|
+
if (!isTokenSseOperation(operation)) {
|
|
151
|
+
const eventNames = eventSseMessageNames(operation);
|
|
152
|
+
return {
|
|
153
|
+
[eventNames.eventEnvelopeEvent]: {
|
|
154
|
+
name: eventNames.eventEnvelopeEvent,
|
|
155
|
+
contentType: 'text/event-stream',
|
|
156
|
+
payload: logicalEventSchema,
|
|
157
|
+
summary: `SSE event envelope for ${operation.name}.`,
|
|
158
|
+
bindings: {
|
|
159
|
+
http: {
|
|
160
|
+
event: '<envelope.kind>',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
'x-weft-sse-frame': 'id: <cursor>\\nevent: <envelope.kind>\\ndata: <JSON event envelope>\\n\\n',
|
|
164
|
+
},
|
|
165
|
+
[eventNames.pingEvent]: {
|
|
166
|
+
name: eventNames.pingEvent,
|
|
167
|
+
contentType: 'text/event-stream',
|
|
168
|
+
payload: {
|
|
169
|
+
additionalProperties: false,
|
|
170
|
+
properties: {
|
|
171
|
+
emittedAtMs: { type: 'number' },
|
|
172
|
+
// Present, and always `true`, on the one ping a subscription sends
|
|
173
|
+
// after the replay of already-recorded events has been delivered.
|
|
174
|
+
replayComplete: { const: true, type: 'boolean' },
|
|
175
|
+
},
|
|
176
|
+
required: ['emittedAtMs'],
|
|
177
|
+
type: 'object',
|
|
178
|
+
},
|
|
179
|
+
summary: `SSE ping keepalive for ${operation.name}.`,
|
|
180
|
+
bindings: {
|
|
181
|
+
http: {
|
|
182
|
+
event: 'ping',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
'x-weft-sse-frame': 'event: ping\\ndata: {"emittedAtMs":<timestamp>[,"replayComplete":true]}\\n\\n',
|
|
186
|
+
},
|
|
187
|
+
[eventNames.errorEvent]: {
|
|
188
|
+
name: eventNames.errorEvent,
|
|
189
|
+
contentType: 'text/event-stream',
|
|
190
|
+
payload: sseErrorPayloadSchema(),
|
|
191
|
+
summary: `SSE error event for ${operation.name}.`,
|
|
192
|
+
bindings: {
|
|
193
|
+
http: {
|
|
194
|
+
event: 'error',
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
'x-weft-sse-frame': 'event: error\\ndata: <JSON Error>\\n\\n',
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const tokenNames = tokenSseMessageNames(operation);
|
|
202
|
+
return {
|
|
203
|
+
[tokenNames.tokenEvent]: {
|
|
204
|
+
name: tokenNames.tokenEvent,
|
|
205
|
+
contentType: 'text/event-stream',
|
|
206
|
+
payload: { type: 'string' },
|
|
207
|
+
summary: `SSE token event for ${operation.name}. The data: line carries the token text.`,
|
|
208
|
+
bindings: {
|
|
209
|
+
http: {
|
|
210
|
+
event: 'token',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
'x-weft-sse-frame': 'event: token\\nid: <sequence>\\ndata: <token-text>\\n\\n',
|
|
214
|
+
'x-weft-event-schema': logicalEventSchema,
|
|
215
|
+
},
|
|
216
|
+
[tokenNames.doneEvent]: {
|
|
217
|
+
name: tokenNames.doneEvent,
|
|
218
|
+
contentType: 'text/event-stream',
|
|
219
|
+
payload: {
|
|
220
|
+
additionalProperties: false,
|
|
221
|
+
properties: {},
|
|
222
|
+
type: 'object',
|
|
223
|
+
},
|
|
224
|
+
summary: `SSE completion event for ${operation.name}.`,
|
|
225
|
+
bindings: {
|
|
226
|
+
http: {
|
|
227
|
+
event: 'done',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
'x-weft-sse-frame': 'event: done\\n\\n',
|
|
231
|
+
},
|
|
232
|
+
[tokenNames.errorEvent]: {
|
|
233
|
+
name: tokenNames.errorEvent,
|
|
234
|
+
contentType: 'text/event-stream',
|
|
235
|
+
payload: sseErrorPayloadSchema(),
|
|
236
|
+
summary: `SSE error event for ${operation.name}.`,
|
|
237
|
+
bindings: {
|
|
238
|
+
http: {
|
|
239
|
+
event: 'error',
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
'x-weft-sse-frame': 'event: error\\ndata: <JSON Error>\\n\\n',
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Build an AsyncAPI operation entry for a stream or subscription operation.
|
|
248
|
+
*/
|
|
249
|
+
export function buildOperationEntry(operation, channelName, kind) {
|
|
250
|
+
const messageNames = kind === 'subscription'
|
|
251
|
+
? Object.values(webSocketMessageNames(operation))
|
|
252
|
+
: Object.values(sseMessageNames(operation));
|
|
253
|
+
return {
|
|
254
|
+
action: 'receive',
|
|
255
|
+
channel: { $ref: `#/channels/${jsonPointerEscape(channelName)}` },
|
|
256
|
+
messages: messageNames.map((name) => ({ $ref: `#/components/messages/${name}` })),
|
|
257
|
+
operationId: operation.name.replaceAll('.', '_'),
|
|
258
|
+
summary: operation.summary,
|
|
259
|
+
tags: [...operation.tags].toSorted().map((name) => ({ name })),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function operationPrefix(operation) {
|
|
263
|
+
return operation.name.replaceAll('.', '_');
|
|
264
|
+
}
|
|
265
|
+
function subscriptionRequestMethod(operation) {
|
|
266
|
+
return operation.name === WORKFLOW_SUBSCRIPTION_OPERATION_NAME
|
|
267
|
+
? WORKFLOW_SUBSCRIPTION_REQUEST_METHOD
|
|
268
|
+
: operation.name;
|
|
269
|
+
}
|
|
270
|
+
function webSocketMessageNames(operation) {
|
|
271
|
+
const prefix = operationPrefix(operation);
|
|
272
|
+
return {
|
|
273
|
+
subscribeRequest: `${prefix}_subscribeRequest`,
|
|
274
|
+
subscribeAck: `${prefix}_subscribeAck`,
|
|
275
|
+
eventDeliver: `${prefix}_eventDeliver`,
|
|
276
|
+
unsubscribeRequest: `${prefix}_unsubscribeRequest`,
|
|
277
|
+
terminated: `${prefix}_terminated`,
|
|
278
|
+
errorFrame: `${prefix}_errorFrame`,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function sseMessageNames(operation) {
|
|
282
|
+
return isTokenSseOperation(operation)
|
|
283
|
+
? tokenSseMessageNames(operation)
|
|
284
|
+
: eventSseMessageNames(operation);
|
|
285
|
+
}
|
|
286
|
+
function eventSseMessageNames(operation) {
|
|
287
|
+
const prefix = operationPrefix(operation);
|
|
288
|
+
return {
|
|
289
|
+
eventEnvelopeEvent: `${prefix}_eventEnvelopeEvent`,
|
|
290
|
+
pingEvent: `${prefix}_pingEvent`,
|
|
291
|
+
errorEvent: `${prefix}_errorEvent`,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
function tokenSseMessageNames(operation) {
|
|
295
|
+
const prefix = operationPrefix(operation);
|
|
296
|
+
return {
|
|
297
|
+
tokenEvent: `${prefix}_tokenEvent`,
|
|
298
|
+
doneEvent: `${prefix}_doneEvent`,
|
|
299
|
+
errorEvent: `${prefix}_errorEvent`,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function isTokenSseOperation(operation) {
|
|
303
|
+
return operation.name === 'weft.workflows.streams.sse';
|
|
304
|
+
}
|
|
305
|
+
function messageReferenceMap(names) {
|
|
306
|
+
const references = {};
|
|
307
|
+
for (const [key, name] of Object.entries(names).toSorted(([left], [right]) => compareStrings(left, right))) {
|
|
308
|
+
references[key] = { $ref: `#/components/messages/${name}` };
|
|
309
|
+
}
|
|
310
|
+
return references;
|
|
311
|
+
}
|
|
312
|
+
function jsonRpcRequestPayload(method, paramsSchema) {
|
|
313
|
+
return {
|
|
314
|
+
additionalProperties: false,
|
|
315
|
+
properties: {
|
|
316
|
+
id: JSON_RPC_ID_SCHEMA,
|
|
317
|
+
jsonrpc: { const: JSON_RPC_VERSION, type: 'string' },
|
|
318
|
+
method: { const: method, type: 'string' },
|
|
319
|
+
params: paramsSchema,
|
|
320
|
+
},
|
|
321
|
+
required: ['jsonrpc', 'id', 'method', 'params'],
|
|
322
|
+
type: 'object',
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
function jsonRpcSuccessPayload(resultSchema) {
|
|
326
|
+
return {
|
|
327
|
+
additionalProperties: false,
|
|
328
|
+
properties: {
|
|
329
|
+
id: JSON_RPC_ID_SCHEMA,
|
|
330
|
+
jsonrpc: { const: JSON_RPC_VERSION, type: 'string' },
|
|
331
|
+
result: resultSchema,
|
|
332
|
+
},
|
|
333
|
+
required: ['jsonrpc', 'id', 'result'],
|
|
334
|
+
type: 'object',
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function eventDeliverPayload(eventSchema) {
|
|
338
|
+
return {
|
|
339
|
+
additionalProperties: false,
|
|
340
|
+
properties: {
|
|
341
|
+
jsonrpc: { const: JSON_RPC_VERSION, type: 'string' },
|
|
342
|
+
method: { const: EVENT_DELIVER_METHOD, type: 'string' },
|
|
343
|
+
params: {
|
|
344
|
+
additionalProperties: false,
|
|
345
|
+
properties: {
|
|
346
|
+
envelope: eventSchema,
|
|
347
|
+
subscriptionId: { type: 'string' },
|
|
348
|
+
},
|
|
349
|
+
required: ['subscriptionId', 'envelope'],
|
|
350
|
+
type: 'object',
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
required: ['jsonrpc', 'method', 'params'],
|
|
354
|
+
type: 'object',
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function terminatedPayload() {
|
|
358
|
+
return {
|
|
359
|
+
additionalProperties: false,
|
|
360
|
+
properties: {
|
|
361
|
+
jsonrpc: { const: JSON_RPC_VERSION, type: 'string' },
|
|
362
|
+
method: { const: EVENTS_TERMINATED_METHOD, type: 'string' },
|
|
363
|
+
params: {
|
|
364
|
+
additionalProperties: false,
|
|
365
|
+
properties: {
|
|
366
|
+
fault: {
|
|
367
|
+
type: 'object',
|
|
368
|
+
},
|
|
369
|
+
reason: SUBSCRIPTION_TERMINATION_REASON_SCHEMA,
|
|
370
|
+
subscriptionId: { type: 'string' },
|
|
371
|
+
},
|
|
372
|
+
required: ['subscriptionId', 'reason'],
|
|
373
|
+
type: 'object',
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
required: ['jsonrpc', 'method', 'params'],
|
|
377
|
+
type: 'object',
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
function jsonRpcErrorPayload() {
|
|
381
|
+
return {
|
|
382
|
+
additionalProperties: false,
|
|
383
|
+
properties: {
|
|
384
|
+
error: { $ref: '#/components/schemas/JsonRpcError' },
|
|
385
|
+
id: JSON_RPC_ID_SCHEMA,
|
|
386
|
+
jsonrpc: { const: JSON_RPC_VERSION, type: 'string' },
|
|
387
|
+
},
|
|
388
|
+
required: ['jsonrpc', 'id', 'error'],
|
|
389
|
+
type: 'object',
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
function eventJsonSchema(operation, definitionSchemaToJsonSchema) {
|
|
393
|
+
if (operation.eventSchema === undefined)
|
|
394
|
+
return { type: 'object' };
|
|
395
|
+
return definitionSchemaToJsonSchema(operation.eventSchema, 'output');
|
|
396
|
+
}
|
|
397
|
+
function jsonPointerEscape(value) {
|
|
398
|
+
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
399
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AsyncAPI 3.0 document generator driven by the operation registry.
|
|
3
|
+
*
|
|
4
|
+
* @module server/asyncapi
|
|
5
|
+
*/
|
|
6
|
+
import { type DiscoveryInfo } from "./discovery-info.js";
|
|
7
|
+
import type { OperationRegistry } from "./operation-catalog.js";
|
|
8
|
+
import type { RestBindingDescription } from "./rest-binding.js";
|
|
9
|
+
/** Options for generating an AsyncAPI document from an {@link OperationRegistry}. */
|
|
10
|
+
export type AsyncApiOptions = {
|
|
11
|
+
/** The operations to describe. */
|
|
12
|
+
registry: OperationRegistry;
|
|
13
|
+
/** REST bindings used to resolve SSE channel addresses. Unused with `subscriptionTransport: 'http-route'`. */
|
|
14
|
+
restBindings: ReadonlyArray<RestBindingDescription>;
|
|
15
|
+
/** The document title. */
|
|
16
|
+
title?: string;
|
|
17
|
+
/** The document version. */
|
|
18
|
+
version?: string;
|
|
19
|
+
/** The facts the document reports, such as the server URL. */
|
|
20
|
+
discoveryInfo?: DiscoveryInfo;
|
|
21
|
+
/** The server URL to list. */
|
|
22
|
+
serverUrl?: string;
|
|
23
|
+
/**
|
|
24
|
+
* How subscription operations are served. `'websocket'` (the default) is
|
|
25
|
+
* Weft's server: each subscription gets the JSON-RPC WebSocket channel.
|
|
26
|
+
* `'http-route'` is the engine-independent handler: only subscriptions that
|
|
27
|
+
* declare `transports.http` are listed, each as a Server-Sent Events channel
|
|
28
|
+
* at `/v1/subscriptions/<operation name>`, and stream operations (which that
|
|
29
|
+
* handler has no route for) are left out.
|
|
30
|
+
*/
|
|
31
|
+
subscriptionTransport?: 'websocket' | 'http-route';
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Generate an AsyncAPI 3.0 document from the operation registry.
|
|
35
|
+
*
|
|
36
|
+
* Only discoverable operations with kind `subscription` or `stream` are
|
|
37
|
+
* listed. The returned object is deterministic: object keys are recursively
|
|
38
|
+
* sorted, and identical component messages are deduplicated by canonical JSON.
|
|
39
|
+
*/
|
|
40
|
+
export declare function generateAsyncApiDocument(options: AsyncApiOptions): Record<string, unknown>;
|
package/dist/asyncapi.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AsyncAPI 3.0 document generator driven by the operation registry.
|
|
3
|
+
*
|
|
4
|
+
* @module server/asyncapi
|
|
5
|
+
*/
|
|
6
|
+
import { buildOperationEntry, buildSseChannel, buildSseMessages, buildWebSocketChannel, buildWebSocketMessages, } from "./asyncapi-channels.js";
|
|
7
|
+
import { isDiscoverable } from "./discovery-filter.js";
|
|
8
|
+
import { applyDiscoveryInfo, resolveDocumentTitleAndVersion, } from "./discovery-info.js";
|
|
9
|
+
import { compareStrings, isPlainObject, normalizeJsonObject } from "./json-schema-utilities.js";
|
|
10
|
+
import { canonicalJson } from "./openapi-canonical-json.js";
|
|
11
|
+
import { GENERIC_SUBSCRIPTION_ROUTE_PREFIX, toOpenApiPath } from "./route-model.js";
|
|
12
|
+
import { zodToJsonSchema } from "./zod-json-schema.js";
|
|
13
|
+
const JSON_RPC_ERROR_SCHEMA = {
|
|
14
|
+
additionalProperties: false,
|
|
15
|
+
properties: {
|
|
16
|
+
code: { type: 'number' },
|
|
17
|
+
data: {},
|
|
18
|
+
message: { type: 'string' },
|
|
19
|
+
},
|
|
20
|
+
required: ['code', 'message'],
|
|
21
|
+
type: 'object',
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Generate an AsyncAPI 3.0 document from the operation registry.
|
|
25
|
+
*
|
|
26
|
+
* Only discoverable operations with kind `subscription` or `stream` are
|
|
27
|
+
* listed. The returned object is deterministic: object keys are recursively
|
|
28
|
+
* sorted, and identical component messages are deduplicated by canonical JSON.
|
|
29
|
+
*/
|
|
30
|
+
export function generateAsyncApiDocument(options) {
|
|
31
|
+
const channels = {};
|
|
32
|
+
const operations = {};
|
|
33
|
+
const messages = {};
|
|
34
|
+
const messageAliases = new Map();
|
|
35
|
+
const messageNamesByCanonical = new Map();
|
|
36
|
+
const httpRoute = options.subscriptionTransport === 'http-route';
|
|
37
|
+
const asyncOperations = options.registry
|
|
38
|
+
.list()
|
|
39
|
+
.filter(isAsyncApiOperation)
|
|
40
|
+
.filter((operation) => !httpRoute || isServedOverSubscriptionRoute(operation))
|
|
41
|
+
.toSorted((left, right) => compareStrings(left.name, right.name));
|
|
42
|
+
const restBindings = httpRoute ? [] : options.restBindings;
|
|
43
|
+
const sseAddressByOperationName = new Map();
|
|
44
|
+
for (const binding of restBindings) {
|
|
45
|
+
if (binding.transportKind === 'sse') {
|
|
46
|
+
sseAddressByOperationName.set(binding.operationName, toOpenApiPath(binding.path));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const operation of asyncOperations) {
|
|
50
|
+
const channelName = channelNameForOperation(operation);
|
|
51
|
+
const operationName = operationNameForOperation(operation);
|
|
52
|
+
const { channel, messageKind, operationMessages } = describeAsyncOperation(operation, httpRoute, sseAddressByOperationName);
|
|
53
|
+
for (const [messageName, message] of Object.entries(operationMessages).toSorted(([left], [right]) => compareStrings(left, right))) {
|
|
54
|
+
const canonical = canonicalJson(message);
|
|
55
|
+
const existingName = messageNamesByCanonical.get(canonical);
|
|
56
|
+
const aliasedName = existingName ?? messageName;
|
|
57
|
+
messageAliases.set(messageName, aliasedName);
|
|
58
|
+
if (existingName === undefined) {
|
|
59
|
+
messageNamesByCanonical.set(canonical, messageName);
|
|
60
|
+
messages[messageName] = normalizeJsonObject(message);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
channels[channelName] = channel;
|
|
64
|
+
operations[operationName] = buildOperationEntry(operation, channelName, messageKind);
|
|
65
|
+
}
|
|
66
|
+
const document = {
|
|
67
|
+
asyncapi: '3.0.0',
|
|
68
|
+
info: buildAsyncApiInfo(options),
|
|
69
|
+
channels: replaceMessageReferences(channels, messageAliases),
|
|
70
|
+
operations: replaceMessageReferences(operations, messageAliases),
|
|
71
|
+
components: {
|
|
72
|
+
messages,
|
|
73
|
+
schemas: {
|
|
74
|
+
JsonRpcError: JSON_RPC_ERROR_SCHEMA,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
applyAsyncApiDocumentOptions(document, options);
|
|
79
|
+
return normalizeJsonObject(document);
|
|
80
|
+
}
|
|
81
|
+
function buildAsyncApiInfo(options) {
|
|
82
|
+
return applyDiscoveryInfo(resolveDocumentTitleAndVersion(options, options.discoveryInfo), options.discoveryInfo);
|
|
83
|
+
}
|
|
84
|
+
function applyAsyncApiDocumentOptions(document, options) {
|
|
85
|
+
if (options.serverUrl !== undefined) {
|
|
86
|
+
document['servers'] = {
|
|
87
|
+
default: createAsyncApiServer(options.serverUrl),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (options.discoveryInfo?.externalDocs !== undefined) {
|
|
91
|
+
document['externalDocs'] = { ...options.discoveryInfo.externalDocs };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function isAsyncApiOperation(operation) {
|
|
95
|
+
return (isDiscoverable(operation) && (operation.kind === 'subscription' || operation.kind === 'stream'));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Over the subscription route a subscription is an SSE stream like any other,
|
|
99
|
+
* so it takes the SSE channel, messages, and operation entry. Otherwise a
|
|
100
|
+
* subscription is a JSON-RPC WebSocket channel and a stream is an SSE channel
|
|
101
|
+
* at its REST binding.
|
|
102
|
+
*/
|
|
103
|
+
function describeAsyncOperation(operation, httpRoute, sseAddressByOperationName) {
|
|
104
|
+
if (httpRoute) {
|
|
105
|
+
return {
|
|
106
|
+
channel: buildSseChannel(operation, `${GENERIC_SUBSCRIPTION_ROUTE_PREFIX}/${operation.name}`, (path) => path),
|
|
107
|
+
messageKind: 'stream',
|
|
108
|
+
operationMessages: buildSseMessages(operation, zodToJsonSchema),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (operation.kind === 'subscription') {
|
|
112
|
+
return {
|
|
113
|
+
channel: buildWebSocketChannel(operation),
|
|
114
|
+
messageKind: 'subscription',
|
|
115
|
+
operationMessages: buildWebSocketMessages(operation, zodToJsonSchema),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
channel: buildSseChannel(operation, sseAddressByOperationName.get(operation.name)),
|
|
120
|
+
messageKind: 'stream',
|
|
121
|
+
operationMessages: buildSseMessages(operation, zodToJsonSchema),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function isServedOverSubscriptionRoute(operation) {
|
|
125
|
+
return operation.kind === 'subscription' && operation.transports.http;
|
|
126
|
+
}
|
|
127
|
+
function channelNameForOperation(operation) {
|
|
128
|
+
return operation.name.replaceAll('.', '/');
|
|
129
|
+
}
|
|
130
|
+
function operationNameForOperation(operation) {
|
|
131
|
+
return operation.name.replaceAll('.', '_');
|
|
132
|
+
}
|
|
133
|
+
function replaceMessageReferences(value, aliases) {
|
|
134
|
+
if (Array.isArray(value)) {
|
|
135
|
+
return value.map((entry) => replaceMessageReferences(entry, aliases));
|
|
136
|
+
}
|
|
137
|
+
if (!isPlainObject(value))
|
|
138
|
+
return value;
|
|
139
|
+
const reference = value['$ref'];
|
|
140
|
+
if (typeof reference === 'string' && reference.startsWith('#/components/messages/')) {
|
|
141
|
+
const messageName = reference.slice('#/components/messages/'.length);
|
|
142
|
+
const aliasedName = aliases.get(messageName) ?? messageName;
|
|
143
|
+
return { ...value, $ref: `#/components/messages/${aliasedName}` };
|
|
144
|
+
}
|
|
145
|
+
const replaced = {};
|
|
146
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
147
|
+
replaced[key] = replaceMessageReferences(entry, aliases);
|
|
148
|
+
}
|
|
149
|
+
return replaced;
|
|
150
|
+
}
|
|
151
|
+
function createAsyncApiServer(serverUrl) {
|
|
152
|
+
try {
|
|
153
|
+
const parsedServerUrl = new URL(serverUrl);
|
|
154
|
+
return {
|
|
155
|
+
host: parsedServerUrl.host,
|
|
156
|
+
protocol: parsedServerUrl.protocol === 'https:' || parsedServerUrl.protocol === 'wss:' ? 'wss' : 'ws',
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return {
|
|
161
|
+
host: serverUrl,
|
|
162
|
+
protocol: 'ws',
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ConstantTimeApiKeyEntry } from '@lostgradient/credentials/api-key-verification';
|
|
2
|
+
import { type AdditionalScopeSet, type AuthorizationScope, type ScopeVocabulary } from "../authorization-scope.js";
|
|
3
|
+
import type { AuthConfig, AuthResult } from "./types.js";
|
|
4
|
+
export declare function tryAdmitApiKey(presentedKey: string, resolver: AuthConfig['resolveApiKeyPrincipal'], apiKeyEntries: ReadonlyArray<ConstantTimeApiKeyEntry<undefined>> | null, defaultApiKeyScopes: ReadonlyArray<AuthorizationScope>, additionalScopes: AdditionalScopeSet, scopeVocabulary?: ScopeVocabulary): Promise<AuthResult | 'continue'>;
|