@frontmcp/sdk 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/README.md +11 -0
- package/package.json +29 -0
- package/src/constants.d.ts +30 -0
- package/src/constants.js +36 -0
- package/src/constants.js.map +1 -0
- package/src/decorators/adapter.decorator.d.ts +7 -0
- package/src/decorators/adapter.decorator.js +20 -0
- package/src/decorators/adapter.decorator.js.map +1 -0
- package/src/decorators/app.decorator.d.ts +7 -0
- package/src/decorators/app.decorator.js +44 -0
- package/src/decorators/app.decorator.js.map +1 -0
- package/src/decorators/auth-provider.decorator.d.ts +7 -0
- package/src/decorators/auth-provider.decorator.js +20 -0
- package/src/decorators/auth-provider.decorator.js.map +1 -0
- package/src/decorators/flow-hooks.decorator.d.ts +12 -0
- package/src/decorators/flow-hooks.decorator.js +63 -0
- package/src/decorators/flow-hooks.decorator.js.map +1 -0
- package/src/decorators/flow.decorator.d.ts +6 -0
- package/src/decorators/flow.decorator.js +19 -0
- package/src/decorators/flow.decorator.js.map +1 -0
- package/src/decorators/front-mcp.decorator.d.ts +6 -0
- package/src/decorators/front-mcp.decorator.js +40 -0
- package/src/decorators/front-mcp.decorator.js.map +1 -0
- package/src/decorators/index.d.ts +12 -0
- package/src/decorators/index.js +16 -0
- package/src/decorators/index.js.map +1 -0
- package/src/decorators/logger.decorator.d.ts +7 -0
- package/src/decorators/logger.decorator.js +20 -0
- package/src/decorators/logger.decorator.js.map +1 -0
- package/src/decorators/plugin.decorator.d.ts +7 -0
- package/src/decorators/plugin.decorator.js +38 -0
- package/src/decorators/plugin.decorator.js.map +1 -0
- package/src/decorators/prompt.decorator.d.ts +13 -0
- package/src/decorators/prompt.decorator.js +38 -0
- package/src/decorators/prompt.decorator.js.map +1 -0
- package/src/decorators/provider.decorator.d.ts +7 -0
- package/src/decorators/provider.decorator.js +20 -0
- package/src/decorators/provider.decorator.js.map +1 -0
- package/src/decorators/resource.decorator.d.ts +17 -0
- package/src/decorators/resource.decorator.js +52 -0
- package/src/decorators/resource.decorator.js.map +1 -0
- package/src/decorators/tool.decorator.d.ts +14 -0
- package/src/decorators/tool.decorator.js +38 -0
- package/src/decorators/tool.decorator.js.map +1 -0
- package/src/decorators-old/async-with.decorator.d.ts +9 -0
- package/src/decorators-old/async-with.decorator.js +23 -0
- package/src/decorators-old/async-with.decorator.js.map +1 -0
- package/src/decorators-old/auth-hook.decorator.d.ts +14 -0
- package/src/decorators-old/auth-hook.decorator.js +27 -0
- package/src/decorators-old/auth-hook.decorator.js.map +1 -0
- package/src/decorators-old/session-hook.decorator.d.ts +14 -0
- package/src/decorators-old/session-hook.decorator.js +27 -0
- package/src/decorators-old/session-hook.decorator.js.map +1 -0
- package/src/decorators-old/tool-hook.decorator.d.ts +14 -0
- package/src/decorators-old/tool-hook.decorator.js +27 -0
- package/src/decorators-old/tool-hook.decorator.js.map +1 -0
- package/src/dynamic/dynamic.adapter.d.ts +42 -0
- package/src/dynamic/dynamic.adapter.js +28 -0
- package/src/dynamic/dynamic.adapter.js.map +1 -0
- package/src/dynamic/dynamic.plugin.d.ts +52 -0
- package/src/dynamic/dynamic.plugin.js +33 -0
- package/src/dynamic/dynamic.plugin.js.map +1 -0
- package/src/dynamic/dynamic.utils.d.ts +3 -0
- package/src/dynamic/dynamic.utils.js +27 -0
- package/src/dynamic/dynamic.utils.js.map +1 -0
- package/src/dynamic/index.d.ts +2 -0
- package/src/dynamic/index.js +6 -0
- package/src/dynamic/index.js.map +1 -0
- package/src/entries/adapter.entry.d.ts +6 -0
- package/src/entries/adapter.entry.js +8 -0
- package/src/entries/adapter.entry.js.map +1 -0
- package/src/entries/app.entry.d.ts +13 -0
- package/src/entries/app.entry.js +9 -0
- package/src/entries/app.entry.js.map +1 -0
- package/src/entries/auth-provider.entry.d.ts +6 -0
- package/src/entries/auth-provider.entry.js +8 -0
- package/src/entries/auth-provider.entry.js.map +1 -0
- package/src/entries/base.entry.d.ts +20 -0
- package/src/entries/base.entry.js +17 -0
- package/src/entries/base.entry.js.map +1 -0
- package/src/entries/flow.entry.d.ts +15 -0
- package/src/entries/flow.entry.js +21 -0
- package/src/entries/flow.entry.js.map +1 -0
- package/src/entries/index.d.ts +12 -0
- package/src/entries/index.js +16 -0
- package/src/entries/index.js.map +1 -0
- package/src/entries/logger.entry.d.ts +6 -0
- package/src/entries/logger.entry.js +8 -0
- package/src/entries/logger.entry.js.map +1 -0
- package/src/entries/plugin.entry.d.ts +6 -0
- package/src/entries/plugin.entry.js +8 -0
- package/src/entries/plugin.entry.js.map +1 -0
- package/src/entries/prompt.entry.d.ts +6 -0
- package/src/entries/prompt.entry.js +8 -0
- package/src/entries/prompt.entry.js.map +1 -0
- package/src/entries/provider.entry.d.ts +7 -0
- package/src/entries/provider.entry.js +8 -0
- package/src/entries/provider.entry.js.map +1 -0
- package/src/entries/resource.entry.d.ts +7 -0
- package/src/entries/resource.entry.js +11 -0
- package/src/entries/resource.entry.js.map +1 -0
- package/src/entries/scope.entry.d.ts +17 -0
- package/src/entries/scope.entry.js +8 -0
- package/src/entries/scope.entry.js.map +1 -0
- package/src/entries/tool.entry.d.ts +15 -0
- package/src/entries/tool.entry.js +11 -0
- package/src/entries/tool.entry.js.map +1 -0
- package/src/index.d.ts +18 -0
- package/src/index.js +22 -0
- package/src/index.js.map +1 -0
- package/src/interfaces/adapter.interface.d.ts +20 -0
- package/src/interfaces/adapter.interface.js +3 -0
- package/src/interfaces/adapter.interface.js.map +1 -0
- package/src/interfaces/app.interface.d.ts +6 -0
- package/src/interfaces/app.interface.js +3 -0
- package/src/interfaces/app.interface.js.map +1 -0
- package/src/interfaces/auth-hook.interface.d.ts +126 -0
- package/src/interfaces/auth-hook.interface.js +135 -0
- package/src/interfaces/auth-hook.interface.js.map +1 -0
- package/src/interfaces/auth-provider.interface.d.ts +22 -0
- package/src/interfaces/auth-provider.interface.js +18 -0
- package/src/interfaces/auth-provider.interface.js.map +1 -0
- package/src/interfaces/base.interface.d.ts +77 -0
- package/src/interfaces/base.interface.js +3 -0
- package/src/interfaces/base.interface.js.map +1 -0
- package/src/interfaces/flow.interface.d.ts +38 -0
- package/src/interfaces/flow.interface.js +69 -0
- package/src/interfaces/flow.interface.js.map +1 -0
- package/src/interfaces/front-mcp.interface.d.ts +5 -0
- package/src/interfaces/front-mcp.interface.js +3 -0
- package/src/interfaces/front-mcp.interface.js.map +1 -0
- package/src/interfaces/index.d.ts +15 -0
- package/src/interfaces/index.js +19 -0
- package/src/interfaces/index.js.map +1 -0
- package/src/interfaces/internal/flow.utils.d.ts +24 -0
- package/src/interfaces/internal/flow.utils.js +83 -0
- package/src/interfaces/internal/flow.utils.js.map +1 -0
- package/src/interfaces/internal/index.d.ts +2 -0
- package/src/interfaces/internal/index.js +7 -0
- package/src/interfaces/internal/index.js.map +1 -0
- package/src/interfaces/internal/primary-auth-provider.interface.d.ts +24 -0
- package/src/interfaces/internal/primary-auth-provider.interface.js +33 -0
- package/src/interfaces/internal/primary-auth-provider.interface.js.map +1 -0
- package/src/interfaces/internal/registry.interface.d.ts +71 -0
- package/src/interfaces/internal/registry.interface.js +3 -0
- package/src/interfaces/internal/registry.interface.js.map +1 -0
- package/src/interfaces/logger.interface.d.ts +42 -0
- package/src/interfaces/logger.interface.js +10 -0
- package/src/interfaces/logger.interface.js.map +1 -0
- package/src/interfaces/plugin.interface.d.ts +8 -0
- package/src/interfaces/plugin.interface.js +3 -0
- package/src/interfaces/plugin.interface.js.map +1 -0
- package/src/interfaces/prompt.interface.d.ts +5 -0
- package/src/interfaces/prompt.interface.js +3 -0
- package/src/interfaces/prompt.interface.js.map +1 -0
- package/src/interfaces/provider.interface.d.ts +20 -0
- package/src/interfaces/provider.interface.js +18 -0
- package/src/interfaces/provider.interface.js.map +1 -0
- package/src/interfaces/resource.interface.d.ts +21 -0
- package/src/interfaces/resource.interface.js +3 -0
- package/src/interfaces/resource.interface.js.map +1 -0
- package/src/interfaces/scope.interface.d.ts +5 -0
- package/src/interfaces/scope.interface.js +3 -0
- package/src/interfaces/scope.interface.js.map +1 -0
- package/src/interfaces/server.interface.d.ts +46 -0
- package/src/interfaces/server.interface.js +18 -0
- package/src/interfaces/server.interface.js.map +1 -0
- package/src/interfaces/session-hook.interface.d.ts +131 -0
- package/src/interfaces/session-hook.interface.js +140 -0
- package/src/interfaces/session-hook.interface.js.map +1 -0
- package/src/interfaces/tool-hook.interface.d.ts +80 -0
- package/src/interfaces/tool-hook.interface.js +92 -0
- package/src/interfaces/tool-hook.interface.js.map +1 -0
- package/src/interfaces/tool.interface.d.ts +45 -0
- package/src/interfaces/tool.interface.js +89 -0
- package/src/interfaces/tool.interface.js.map +1 -0
- package/src/metadata/adapter.metadata.d.ts +22 -0
- package/src/metadata/adapter.metadata.js +10 -0
- package/src/metadata/adapter.metadata.js.map +1 -0
- package/src/metadata/app.metadata.d.ts +872 -0
- package/src/metadata/app.metadata.js +30 -0
- package/src/metadata/app.metadata.js.map +1 -0
- package/src/metadata/auth-provider.metadata.d.ts +33 -0
- package/src/metadata/auth-provider.metadata.js +19 -0
- package/src/metadata/auth-provider.metadata.js.map +1 -0
- package/src/metadata/flow-hooks.metadata.d.ts +20 -0
- package/src/metadata/flow-hooks.metadata.js +3 -0
- package/src/metadata/flow-hooks.metadata.js.map +1 -0
- package/src/metadata/flow.metadata.d.ts +75 -0
- package/src/metadata/flow.metadata.js +15 -0
- package/src/metadata/flow.metadata.js.map +1 -0
- package/src/metadata/front-mcp.metadata.d.ts +1144 -0
- package/src/metadata/front-mcp.metadata.js +25 -0
- package/src/metadata/front-mcp.metadata.js.map +1 -0
- package/src/metadata/index.d.ts +12 -0
- package/src/metadata/index.js +16 -0
- package/src/metadata/index.js.map +1 -0
- package/src/metadata/logger.metadata.d.ts +39 -0
- package/src/metadata/logger.metadata.js +10 -0
- package/src/metadata/logger.metadata.js.map +1 -0
- package/src/metadata/plugin.metadata.d.ts +93 -0
- package/src/metadata/plugin.metadata.js +18 -0
- package/src/metadata/plugin.metadata.js.map +1 -0
- package/src/metadata/prompt.metadata.d.ts +226 -0
- package/src/metadata/prompt.metadata.js +27 -0
- package/src/metadata/prompt.metadata.js.map +1 -0
- package/src/metadata/provider.metadata.d.ts +34 -0
- package/src/metadata/provider.metadata.js +20 -0
- package/src/metadata/provider.metadata.js.map +1 -0
- package/src/metadata/resource.metadata.d.ts +199 -0
- package/src/metadata/resource.metadata.js +22 -0
- package/src/metadata/resource.metadata.js.map +1 -0
- package/src/metadata/tool.metadata.d.ts +278 -0
- package/src/metadata/tool.metadata.js +28 -0
- package/src/metadata/tool.metadata.js.map +1 -0
- package/src/providers/session.provider.d.ts +13 -0
- package/src/providers/session.provider.js +27 -0
- package/src/providers/session.provider.js.map +1 -0
- package/src/records/adapter.record.d.ts +26 -0
- package/src/records/adapter.record.js +11 -0
- package/src/records/adapter.record.js.map +1 -0
- package/src/records/app.record.d.ts +19 -0
- package/src/records/app.record.js +9 -0
- package/src/records/app.record.js.map +1 -0
- package/src/records/auth-provider.record.d.ts +37 -0
- package/src/records/auth-provider.record.js +12 -0
- package/src/records/auth-provider.record.js.map +1 -0
- package/src/records/flow.record.d.ts +11 -0
- package/src/records/flow.record.js +8 -0
- package/src/records/flow.record.js.map +1 -0
- package/src/records/index.d.ts +11 -0
- package/src/records/index.js +15 -0
- package/src/records/index.js.map +1 -0
- package/src/records/logger.record.d.ts +11 -0
- package/src/records/logger.record.js +8 -0
- package/src/records/logger.record.js.map +1 -0
- package/src/records/plugin.record.d.ts +21 -0
- package/src/records/plugin.record.js +11 -0
- package/src/records/plugin.record.js.map +1 -0
- package/src/records/prompt.record.d.ts +18 -0
- package/src/records/prompt.record.js +9 -0
- package/src/records/prompt.record.js.map +1 -0
- package/src/records/provider.record.d.ts +36 -0
- package/src/records/provider.record.js +14 -0
- package/src/records/provider.record.js.map +1 -0
- package/src/records/resource.record.d.ts +18 -0
- package/src/records/resource.record.js +14 -0
- package/src/records/resource.record.js.map +1 -0
- package/src/records/scope.record.d.ts +18 -0
- package/src/records/scope.record.js +9 -0
- package/src/records/scope.record.js.map +1 -0
- package/src/records/tool.record.d.ts +17 -0
- package/src/records/tool.record.js +9 -0
- package/src/records/tool.record.js.map +1 -0
- package/src/schemas/annotated-class.schema.d.ts +11 -0
- package/src/schemas/annotated-class.schema.js +40 -0
- package/src/schemas/annotated-class.schema.js.map +1 -0
- package/src/schemas/http-input.schema.d.ts +33 -0
- package/src/schemas/http-input.schema.js +13 -0
- package/src/schemas/http-input.schema.js.map +1 -0
- package/src/schemas/http-output.schema.d.ts +2011 -0
- package/src/schemas/http-output.schema.js +283 -0
- package/src/schemas/http-output.schema.js.map +1 -0
- package/src/schemas/index.d.ts +3 -0
- package/src/schemas/index.js +7 -0
- package/src/schemas/index.js.map +1 -0
- package/src/tokens/adapter.tokens.d.ts +3 -0
- package/src/tokens/adapter.tokens.js +11 -0
- package/src/tokens/adapter.tokens.js.map +1 -0
- package/src/tokens/app.tokens.d.ts +4 -0
- package/src/tokens/app.tokens.js +30 -0
- package/src/tokens/app.tokens.js.map +1 -0
- package/src/tokens/auth-provider.tokens.d.ts +3 -0
- package/src/tokens/auth-provider.tokens.js +12 -0
- package/src/tokens/auth-provider.tokens.js.map +1 -0
- package/src/tokens/base.tokens.d.ts +5 -0
- package/src/tokens/base.tokens.js +9 -0
- package/src/tokens/base.tokens.js.map +1 -0
- package/src/tokens/flow-hook.tokens.d.ts +4 -0
- package/src/tokens/flow-hook.tokens.js +9 -0
- package/src/tokens/flow-hook.tokens.js.map +1 -0
- package/src/tokens/flow.tokens.d.ts +11 -0
- package/src/tokens/flow.tokens.js +16 -0
- package/src/tokens/flow.tokens.js.map +1 -0
- package/src/tokens/front-mcp.tokens.d.ts +3 -0
- package/src/tokens/front-mcp.tokens.js +19 -0
- package/src/tokens/front-mcp.tokens.js.map +1 -0
- package/src/tokens/index.d.ts +13 -0
- package/src/tokens/index.js +17 -0
- package/src/tokens/index.js.map +1 -0
- package/src/tokens/logger.tokens.d.ts +3 -0
- package/src/tokens/logger.tokens.js +11 -0
- package/src/tokens/logger.tokens.js.map +1 -0
- package/src/tokens/plugin.tokens.d.ts +13 -0
- package/src/tokens/plugin.tokens.js +18 -0
- package/src/tokens/plugin.tokens.js.map +1 -0
- package/src/tokens/prompt.tokens.d.ts +9 -0
- package/src/tokens/prompt.tokens.js +14 -0
- package/src/tokens/prompt.tokens.js.map +1 -0
- package/src/tokens/provider.tokens.d.ts +3 -0
- package/src/tokens/provider.tokens.js +12 -0
- package/src/tokens/provider.tokens.js.map +1 -0
- package/src/tokens/resource.tokens.d.ts +20 -0
- package/src/tokens/resource.tokens.js +25 -0
- package/src/tokens/resource.tokens.js.map +1 -0
- package/src/tokens/server.tokens.d.ts +6 -0
- package/src/tokens/server.tokens.js +11 -0
- package/src/tokens/server.tokens.js.map +1 -0
- package/src/tokens/tool.tokens.d.ts +13 -0
- package/src/tokens/tool.tokens.js +18 -0
- package/src/tokens/tool.tokens.js.map +1 -0
- package/src/types/auth/index.d.ts +2 -0
- package/src/types/auth/index.js +6 -0
- package/src/types/auth/index.js.map +1 -0
- package/src/types/auth/jwt.types.d.ts +112 -0
- package/src/types/auth/jwt.types.js +36 -0
- package/src/types/auth/jwt.types.js.map +1 -0
- package/src/types/auth/session.types.d.ts +263 -0
- package/src/types/auth/session.types.js +40 -0
- package/src/types/auth/session.types.js.map +1 -0
- package/src/types/common.types.d.ts +11 -0
- package/src/types/common.types.js +3 -0
- package/src/types/common.types.js.map +1 -0
- package/src/types/index.d.ts +3 -0
- package/src/types/index.js +7 -0
- package/src/types/index.js.map +1 -0
- package/src/types/options/auth.options.d.ts +513 -0
- package/src/types/options/auth.options.js +53 -0
- package/src/types/options/auth.options.js.map +1 -0
- package/src/types/options/http.options.d.ts +22 -0
- package/src/types/options/http.options.js +10 -0
- package/src/types/options/http.options.js.map +1 -0
- package/src/types/options/index.d.ts +5 -0
- package/src/types/options/index.js +9 -0
- package/src/types/options/index.js.map +1 -0
- package/src/types/options/logging.options.d.ts +39 -0
- package/src/types/options/logging.options.js +37 -0
- package/src/types/options/logging.options.js.map +1 -0
- package/src/types/options/server-info.options.d.ts +48 -0
- package/src/types/options/server-info.options.js +13 -0
- package/src/types/options/server-info.options.js.map +1 -0
- package/src/types/options/session.options.d.ts +67 -0
- package/src/types/options/session.options.js +9 -0
- package/src/types/options/session.options.js.map +1 -0
- package/src/utils/decide-request-intent.utils.d.ts +79 -0
- package/src/utils/decide-request-intent.utils.js +326 -0
- package/src/utils/decide-request-intent.utils.js.map +1 -0
- package/src/utils/index.d.ts +2 -0
- package/src/utils/index.js +6 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/path.utils.d.ts +20 -0
- package/src/utils/path.utils.js +66 -0
- package/src/utils/path.utils.js.map +1 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Lifecycle stages for auth invocation.
|
|
4
|
+
*
|
|
5
|
+
* Ordering notes:
|
|
6
|
+
* - "will*" stages run before the action; "did*" stages run after.
|
|
7
|
+
* - Higher `priority()` runs earlier for "will*" (outermost), and later for "did*".
|
|
8
|
+
* - Finalization stages (`willFinalize`, `willAudit`, `didAudit`, `onMetrics`) should be placed
|
|
9
|
+
* in your plan’s `finalize` array to run on both success and error paths.
|
|
10
|
+
*
|
|
11
|
+
* Control flow:
|
|
12
|
+
* - Hooks may call `ctx.respond(value)` to short-circuit with a return value.
|
|
13
|
+
* - Hooks may call `ctx.abort(reason, code?, httpStatus?)` to stop with an error.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AuthHookStage = void 0;
|
|
18
|
+
var AuthHookStage;
|
|
19
|
+
(function (AuthHookStage) {
|
|
20
|
+
/** Prepare a new session (or re-register an incoming secureJwt).
|
|
21
|
+
* Responsibilities:
|
|
22
|
+
* - Validate incoming token (if any); compute defaults; attach user hints.
|
|
23
|
+
* - Initialize per-session resources and attach to `ctx.data`.
|
|
24
|
+
* Failure modes:
|
|
25
|
+
* - `ctx.abort('invalid jwt', 'INVALID_SESSION', 401)`.
|
|
26
|
+
*/
|
|
27
|
+
AuthHookStage["willCreateSession"] = "willCreateSession";
|
|
28
|
+
/** Session created and registered.
|
|
29
|
+
* Responsibilities:
|
|
30
|
+
* - Announce readiness (mount handlers/streams), emit side-effects if needed.
|
|
31
|
+
* - Optionally shape `ctx.output` with a `SessionContextView`.
|
|
32
|
+
*/
|
|
33
|
+
AuthHookStage["didCreateSession"] = "didCreateSession";
|
|
34
|
+
/** Bind DI providers needed for this session/request.
|
|
35
|
+
* Responsibilities:
|
|
36
|
+
* - Resolve and bind providers so later hooks can `ctx.get(...)`.
|
|
37
|
+
* - May set `ctx.bindProvider/bindProviders` helpers.
|
|
38
|
+
*/
|
|
39
|
+
AuthHookStage["willBindProviders"] = "willBindProviders";
|
|
40
|
+
// ---------- Auth (within a session) ----------
|
|
41
|
+
/** Signal the beginning of an auth sequence in the scope of this session.
|
|
42
|
+
* Responsibilities:
|
|
43
|
+
* - Initialize auth-related state (PKCE/state, CSRF, telemetry).
|
|
44
|
+
* - Decide transport (SSE/StreamableHTTP) for status/URL events if applicable.
|
|
45
|
+
*/
|
|
46
|
+
AuthHookStage["willBeginAuth"] = "willBeginAuth";
|
|
47
|
+
/** Streamable authorization progress within the session.
|
|
48
|
+
* Responsibilities:
|
|
49
|
+
* - Emit URL/status events (e.g., “authorize_url”, “awaiting_callback”).
|
|
50
|
+
* - Optionally `ctx.respond({event: ...})` for push-style transports.
|
|
51
|
+
*/
|
|
52
|
+
AuthHookStage["willAuthorize"] = "willAuthorize";
|
|
53
|
+
/** Prepare and gate the token exchange with the provider.
|
|
54
|
+
* Responsibilities:
|
|
55
|
+
* - Verify callback params; ensure prerequisites (sessionId present).
|
|
56
|
+
* - Compute exchange request; rate-limit/anti-replay checks.
|
|
57
|
+
* Failure modes:
|
|
58
|
+
* - `ctx.abort('invalid state/pkce', 'OAUTH_CALLBACK_ERROR', 400)`.
|
|
59
|
+
*/
|
|
60
|
+
AuthHookStage["willExchangeToken"] = "willExchangeToken";
|
|
61
|
+
/** SecureMcp JWT has been minted/confirmed for this session.
|
|
62
|
+
* Responsibilities:
|
|
63
|
+
* - React to issuance (e.g., persist session claims, notify listeners).
|
|
64
|
+
* Notes:
|
|
65
|
+
* - Fired once the session’s secureJwt is known; avoid logging secrets.
|
|
66
|
+
*/
|
|
67
|
+
AuthHookStage["didIssueSecureJwt"] = "didIssueSecureJwt";
|
|
68
|
+
/** Encrypt and store provider tokens for this session.
|
|
69
|
+
* Responsibilities:
|
|
70
|
+
* - Write encrypted blobs to the session record (per provider).
|
|
71
|
+
* - Derive minimal metadata (scopes/expiry) for later claims-only exposure.
|
|
72
|
+
*/
|
|
73
|
+
AuthHookStage["willStoreTokens"] = "willStoreTokens";
|
|
74
|
+
// ---------- Access (read path) ----------
|
|
75
|
+
/** Authorize and prepare a session read.
|
|
76
|
+
* Responsibilities:
|
|
77
|
+
* - Validate access to the session; attach read-scoped providers if required.
|
|
78
|
+
* - Optionally shape a partial view before execute.
|
|
79
|
+
*/
|
|
80
|
+
AuthHookStage["willGetSession"] = "willGetSession";
|
|
81
|
+
/** Post-process the session view.
|
|
82
|
+
* Responsibilities:
|
|
83
|
+
* - Redact/transform/derive fields for the final response.
|
|
84
|
+
* - Set `ctx.output` to a `SessionContextView`.
|
|
85
|
+
*/
|
|
86
|
+
AuthHookStage["didGetSession"] = "didGetSession";
|
|
87
|
+
// ---------- Disposal ----------
|
|
88
|
+
/** Announce shutdown and allow flush/cleanup.
|
|
89
|
+
* Responsibilities:
|
|
90
|
+
* - Close streams, unsubscribe listeners, schedule disposers.
|
|
91
|
+
*/
|
|
92
|
+
AuthHookStage["willDisposeSession"] = "willDisposeSession";
|
|
93
|
+
/** Confirm teardown and emit metrics.
|
|
94
|
+
* Responsibilities:
|
|
95
|
+
* - Final confirmation of resource release; summarize outcome.
|
|
96
|
+
*/
|
|
97
|
+
AuthHookStage["didDisposeSession"] = "didDisposeSession";
|
|
98
|
+
// ---------- Finalize / audit / metrics / errors ----------
|
|
99
|
+
/** Optional “late finally” hook if you need a single place before audit/metrics.
|
|
100
|
+
* Responsibilities:
|
|
101
|
+
* - Last-chance cleanup across success/error paths (idempotent, non-throwing).
|
|
102
|
+
* Notes:
|
|
103
|
+
* - Include this stage in your plan’s `finalize` array to activate.
|
|
104
|
+
*/
|
|
105
|
+
AuthHookStage["willFinalize"] = "willFinalize";
|
|
106
|
+
/** Centralized error handler.
|
|
107
|
+
* Responsibilities:
|
|
108
|
+
* - Redact sensitive data; map internal errors to public codes.
|
|
109
|
+
* - Optionally `ctx.respond({ error })` or `ctx.abort(...)`.
|
|
110
|
+
* Notes:
|
|
111
|
+
* - Should not throw; runs before audit/metrics finalize.
|
|
112
|
+
*/
|
|
113
|
+
AuthHookStage["onError"] = "onError";
|
|
114
|
+
/** Pre-audit collection on both success and error paths.
|
|
115
|
+
* Responsibilities:
|
|
116
|
+
* - Build audit envelope (actor, sessionId, providers touched).
|
|
117
|
+
* - Normalize and strip secrets (no raw tokens).
|
|
118
|
+
*/
|
|
119
|
+
AuthHookStage["willAudit"] = "willAudit";
|
|
120
|
+
/** Persist/emit the audit record.
|
|
121
|
+
* Responsibilities:
|
|
122
|
+
* - Write to audit sink(s) with outcome and timings.
|
|
123
|
+
* - Correlate via `ctx.requestId`/`ctx.sessionId`.
|
|
124
|
+
*/
|
|
125
|
+
AuthHookStage["didAudit"] = "didAudit";
|
|
126
|
+
/** Telemetry/metrics emission for both success and errors.
|
|
127
|
+
* Responsibilities:
|
|
128
|
+
* - Counters & timings (create/get/dispose/auth/exchange/store).
|
|
129
|
+
* - Error code/tag cardinality kept small for SLOs/alerts.
|
|
130
|
+
* Constraints:
|
|
131
|
+
* - Non-throwing; must not alter control flow.
|
|
132
|
+
*/
|
|
133
|
+
AuthHookStage["onMetrics"] = "onMetrics";
|
|
134
|
+
})(AuthHookStage || (exports.AuthHookStage = AuthHookStage = {}));
|
|
135
|
+
//# sourceMappingURL=auth-hook.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-hook.interface.js","sourceRoot":"","sources":["../../../src/interfaces/auth-hook.interface.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,IAAY,aAwIX;AAxID,WAAY,aAAa;IACvB;;;;;;OAMG;IACH,wDAAuC,CAAA;IAGvC;;;;OAIG;IACH,sDAAqC,CAAA;IAErC;;;;OAIG;IACH,wDAAuC,CAAA;IAEvC,gDAAgD;IAEhD;;;;OAIG;IACH,gDAA+B,CAAA;IAE/B;;;;OAIG;IACH,gDAA+B,CAAA;IAE/B;;;;;;OAMG;IACH,wDAAuC,CAAA;IAEvC;;;;;OAKG;IACH,wDAAuC,CAAA;IAEvC;;;;OAIG;IACH,oDAAmC,CAAA;IAEnC,2CAA2C;IAE3C;;;;OAIG;IACH,kDAAiC,CAAA;IAEjC;;;;OAIG;IACH,gDAA+B,CAAA;IAE/B,iCAAiC;IAEjC;;;OAGG;IACH,0DAAyC,CAAA;IAEzC;;;OAGG;IACH,wDAAuC,CAAA;IAEvC,4DAA4D;IAE5D;;;;;OAKG;IACH,8CAA6B,CAAA;IAE7B;;;;;;OAMG;IACH,oCAAmB,CAAA;IAEnB;;;;OAIG;IACH,wCAAuB,CAAA;IAEvB;;;;OAIG;IACH,sCAAqB,CAAA;IAErB;;;;;;OAMG;IACH,wCAAuB,CAAA;AACzB,CAAC,EAxIW,aAAa,6BAAb,aAAa,QAwIxB","sourcesContent":["/**\n * Lifecycle stages for auth invocation.\n *\n * Ordering notes:\n * - \"will*\" stages run before the action; \"did*\" stages run after.\n * - Higher `priority()` runs earlier for \"will*\" (outermost), and later for \"did*\".\n * - Finalization stages (`willFinalize`, `willAudit`, `didAudit`, `onMetrics`) should be placed\n * in your plan’s `finalize` array to run on both success and error paths.\n *\n * Control flow:\n * - Hooks may call `ctx.respond(value)` to short-circuit with a return value.\n * - Hooks may call `ctx.abort(reason, code?, httpStatus?)` to stop with an error.\n *\n */\n\nexport enum AuthHookStage {\n /** Prepare a new session (or re-register an incoming secureJwt).\n * Responsibilities:\n * - Validate incoming token (if any); compute defaults; attach user hints.\n * - Initialize per-session resources and attach to `ctx.data`.\n * Failure modes:\n * - `ctx.abort('invalid jwt', 'INVALID_SESSION', 401)`.\n */\n willCreateSession = 'willCreateSession',\n\n\n /** Session created and registered.\n * Responsibilities:\n * - Announce readiness (mount handlers/streams), emit side-effects if needed.\n * - Optionally shape `ctx.output` with a `SessionContextView`.\n */\n didCreateSession = 'didCreateSession',\n\n /** Bind DI providers needed for this session/request.\n * Responsibilities:\n * - Resolve and bind providers so later hooks can `ctx.get(...)`.\n * - May set `ctx.bindProvider/bindProviders` helpers.\n */\n willBindProviders = 'willBindProviders',\n\n // ---------- Auth (within a session) ----------\n\n /** Signal the beginning of an auth sequence in the scope of this session.\n * Responsibilities:\n * - Initialize auth-related state (PKCE/state, CSRF, telemetry).\n * - Decide transport (SSE/StreamableHTTP) for status/URL events if applicable.\n */\n willBeginAuth = 'willBeginAuth',\n\n /** Streamable authorization progress within the session.\n * Responsibilities:\n * - Emit URL/status events (e.g., “authorize_url”, “awaiting_callback”).\n * - Optionally `ctx.respond({event: ...})` for push-style transports.\n */\n willAuthorize = 'willAuthorize', // stream-able events (URL/status)\n\n /** Prepare and gate the token exchange with the provider.\n * Responsibilities:\n * - Verify callback params; ensure prerequisites (sessionId present).\n * - Compute exchange request; rate-limit/anti-replay checks.\n * Failure modes:\n * - `ctx.abort('invalid state/pkce', 'OAUTH_CALLBACK_ERROR', 400)`.\n */\n willExchangeToken = 'willExchangeToken',\n\n /** SecureMcp JWT has been minted/confirmed for this session.\n * Responsibilities:\n * - React to issuance (e.g., persist session claims, notify listeners).\n * Notes:\n * - Fired once the session’s secureJwt is known; avoid logging secrets.\n */\n didIssueSecureJwt = 'didIssueSecureJwt',\n\n /** Encrypt and store provider tokens for this session.\n * Responsibilities:\n * - Write encrypted blobs to the session record (per provider).\n * - Derive minimal metadata (scopes/expiry) for later claims-only exposure.\n */\n willStoreTokens = 'willStoreTokens',\n\n // ---------- Access (read path) ----------\n\n /** Authorize and prepare a session read.\n * Responsibilities:\n * - Validate access to the session; attach read-scoped providers if required.\n * - Optionally shape a partial view before execute.\n */\n willGetSession = 'willGetSession',\n\n /** Post-process the session view.\n * Responsibilities:\n * - Redact/transform/derive fields for the final response.\n * - Set `ctx.output` to a `SessionContextView`.\n */\n didGetSession = 'didGetSession',\n\n // ---------- Disposal ----------\n\n /** Announce shutdown and allow flush/cleanup.\n * Responsibilities:\n * - Close streams, unsubscribe listeners, schedule disposers.\n */\n willDisposeSession = 'willDisposeSession',\n\n /** Confirm teardown and emit metrics.\n * Responsibilities:\n * - Final confirmation of resource release; summarize outcome.\n */\n didDisposeSession = 'didDisposeSession',\n\n // ---------- Finalize / audit / metrics / errors ----------\n\n /** Optional “late finally” hook if you need a single place before audit/metrics.\n * Responsibilities:\n * - Last-chance cleanup across success/error paths (idempotent, non-throwing).\n * Notes:\n * - Include this stage in your plan’s `finalize` array to activate.\n */\n willFinalize = 'willFinalize',\n\n /** Centralized error handler.\n * Responsibilities:\n * - Redact sensitive data; map internal errors to public codes.\n * - Optionally `ctx.respond({ error })` or `ctx.abort(...)`.\n * Notes:\n * - Should not throw; runs before audit/metrics finalize.\n */\n onError = 'onError',\n\n /** Pre-audit collection on both success and error paths.\n * Responsibilities:\n * - Build audit envelope (actor, sessionId, providers touched).\n * - Normalize and strip secrets (no raw tokens).\n */\n willAudit = 'willAudit',\n\n /** Persist/emit the audit record.\n * Responsibilities:\n * - Write to audit sink(s) with outcome and timings.\n * - Correlate via `ctx.requestId`/`ctx.sessionId`.\n */\n didAudit = 'didAudit',\n\n /** Telemetry/metrics emission for both success and errors.\n * Responsibilities:\n * - Counters & timings (create/get/dispose/auth/exchange/store).\n * - Error code/tag cardinality kept small for SLOs/alerts.\n * Constraints:\n * - Non-throwing; must not alter control flow.\n */\n onMetrics = 'onMetrics',\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Type, Token, ClassType, ValueType, FactoryType, ClassToken } from './base.interface';
|
|
2
|
+
import { AuthProviderMetadata } from '../metadata';
|
|
3
|
+
export interface AuthProviderInterface {
|
|
4
|
+
headers(): Record<string, string>;
|
|
5
|
+
refreshToken?(): Promise<string | undefined>;
|
|
6
|
+
}
|
|
7
|
+
export type AuthProviderClassType<Provide> = ClassType<Provide> & AuthProviderMetadata;
|
|
8
|
+
export type AuthProviderValueType<Provide> = ValueType<Provide> & AuthProviderMetadata;
|
|
9
|
+
export type AuthProviderFactoryType<Provide, Tokens extends readonly (ClassToken | Token)[]> = FactoryType<Provide, Tokens> & AuthProviderMetadata;
|
|
10
|
+
export type AuthProviderType<Provide extends AuthProviderInterface = any, Tokens extends readonly (ClassToken | Token)[] = readonly (ClassToken | Token)[]> = Type<Provide> | AuthProviderClassType<Provide> | AuthProviderValueType<Provide> | AuthProviderFactoryType<Provide, Tokens>;
|
|
11
|
+
/**
|
|
12
|
+
* Helper to define factory providers without tuple widening.
|
|
13
|
+
* Enforces that `useFactory` params follow the `inject()` tokens (order + arity).
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* const p = AsyncMcpProvider({
|
|
17
|
+
* provide: RedisProviderRef,
|
|
18
|
+
* inject: () => [ExpenseConfigRef, RedisType] as const,
|
|
19
|
+
* useFactory: async (config, redis) => new RedisProvider(redis),
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
export declare function AsyncAuthProvider<Provide, const Tokens extends readonly (ClassToken | Token)[]>(cfg: AuthProviderFactoryType<Provide, Tokens>): AuthProviderFactoryType<Provide, Tokens>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncAuthProvider = AsyncAuthProvider;
|
|
4
|
+
/**
|
|
5
|
+
* Helper to define factory providers without tuple widening.
|
|
6
|
+
* Enforces that `useFactory` params follow the `inject()` tokens (order + arity).
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const p = AsyncMcpProvider({
|
|
10
|
+
* provide: RedisProviderRef,
|
|
11
|
+
* inject: () => [ExpenseConfigRef, RedisType] as const,
|
|
12
|
+
* useFactory: async (config, redis) => new RedisProvider(redis),
|
|
13
|
+
* });
|
|
14
|
+
*/
|
|
15
|
+
function AsyncAuthProvider(cfg) {
|
|
16
|
+
return cfg;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=auth-provider.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-provider.interface.js","sourceRoot":"","sources":["../../../src/interfaces/auth-provider.interface.ts"],"names":[],"mappings":";;AAuCA,8CAIC;AAfD;;;;;;;;;;GAUG;AACH,SAAgB,iBAAiB,CAC/B,GAA6C;IAE7C,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { Type, Token, ClassType, ValueType, FactoryType, ClassToken } from './base.interface';\nimport { AuthProviderMetadata } from '../metadata';\n\n\nexport interface AuthProviderInterface {\n headers(): Record<string, string>;\n\n refreshToken?(): Promise<string | undefined>;\n}\n\n\nexport type AuthProviderClassType<Provide> = ClassType<Provide> & AuthProviderMetadata;\nexport type AuthProviderValueType<Provide> = ValueType<Provide> & AuthProviderMetadata;\nexport type AuthProviderFactoryType<Provide, Tokens extends readonly (ClassToken | Token)[]> =\n FactoryType<Provide, Tokens>\n & AuthProviderMetadata;\n\n\nexport type AuthProviderType<\n Provide extends AuthProviderInterface = any,\n Tokens extends readonly (ClassToken | Token)[] = readonly (ClassToken | Token)[]\n> =\n | Type<Provide>\n | AuthProviderClassType<Provide>\n | AuthProviderValueType<Provide>\n | AuthProviderFactoryType<Provide, Tokens>\n\n\n/**\n * Helper to define factory providers without tuple widening.\n * Enforces that `useFactory` params follow the `inject()` tokens (order + arity).\n *\n * Usage:\n * const p = AsyncMcpProvider({\n * provide: RedisProviderRef,\n * inject: () => [ExpenseConfigRef, RedisType] as const,\n * useFactory: async (config, redis) => new RedisProvider(redis),\n * });\n */\nexport function AsyncAuthProvider<Provide, const Tokens extends readonly (ClassToken | Token)[]>(\n cfg: AuthProviderFactoryType<Provide, Tokens>,\n): AuthProviderFactoryType<Provide, Tokens> {\n return cfg;\n}\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructor type for a concrete class that produces instances of T.
|
|
3
|
+
*
|
|
4
|
+
* Useful anywhere a factory/DI container expects a class reference that can be
|
|
5
|
+
* `new`-ed. For example: `getProvider(UserRepo as Type<UserRepo>)`.
|
|
6
|
+
*/
|
|
7
|
+
export interface Type<T = unknown> extends Function {
|
|
8
|
+
new (...args: any[]): T;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Constructor type for a concrete class that produces instances of T.
|
|
12
|
+
*
|
|
13
|
+
* Useful anywhere a factory/DI container expects a class reference that can be
|
|
14
|
+
* `new`-ed. For example: `getProvider(UserRepo as Type<UserRepo>)`.
|
|
15
|
+
*/
|
|
16
|
+
export type FuncType<T> = (...args: any[]) => any | Promise<any>;
|
|
17
|
+
export type PartialStagesType<T extends string> = Partial<Record<T, Type[]>>;
|
|
18
|
+
/**
|
|
19
|
+
* Empty Constructor type for a concrete class that produces instances of T.
|
|
20
|
+
*
|
|
21
|
+
* Useful anywhere a factory/DI container expects a class reference that can be
|
|
22
|
+
* `new`-ed. For example: `getProvider(UserRepo as Type<UserRepo>)`.
|
|
23
|
+
*/
|
|
24
|
+
export interface CtorType<T = unknown> extends Function {
|
|
25
|
+
new (): T;
|
|
26
|
+
}
|
|
27
|
+
export type Ctor<T> = new (...args: any[]) => T;
|
|
28
|
+
/**
|
|
29
|
+
* Shape of an abstract class (or interface-like constructor) whose instances
|
|
30
|
+
* cannot be created directly but still expose a prototype of T.
|
|
31
|
+
*
|
|
32
|
+
* This is handy when accepting references that may point at abstract bases
|
|
33
|
+
* instead of concrete implementors.
|
|
34
|
+
*/
|
|
35
|
+
export interface Abstract<T> extends Function {
|
|
36
|
+
prototype: T;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A reference token that may be used to look up or identify a dependency.
|
|
40
|
+
*
|
|
41
|
+
* Typical usages:
|
|
42
|
+
* - string | symbol: named tokens (e.g., provider IDs like "provider:redis").
|
|
43
|
+
* - Type<T>: a concrete class constructor (can be instantiated).
|
|
44
|
+
* - Abstract<T>: an abstract base reference (resolved to a concrete impl).
|
|
45
|
+
* - Function: generic function references when needed.
|
|
46
|
+
*/
|
|
47
|
+
export type Reference<T = unknown> = string | symbol | Type<T> | Abstract<T> | Function;
|
|
48
|
+
/** A DI token that can be either a class constructor or a logical reference. */
|
|
49
|
+
export type Token<T = any> = Type<T> | Reference<T>;
|
|
50
|
+
export interface ClassType<Provide> {
|
|
51
|
+
provide: Reference<Provide>;
|
|
52
|
+
useClass: Type<Provide>;
|
|
53
|
+
}
|
|
54
|
+
export interface ValueType<Provide> {
|
|
55
|
+
provide: Reference<Provide>;
|
|
56
|
+
useValue: Provide;
|
|
57
|
+
}
|
|
58
|
+
/** Map a tuple of tokens to a tuple of their instance types (order preserved). */
|
|
59
|
+
export type ClassToken<T = any> = abstract new (...a: any) => T;
|
|
60
|
+
/** 2) Map tokens -> runtime parameter types **/
|
|
61
|
+
type ResolveToken<T> = T extends ClassToken<infer R> ? R : T extends symbol & {
|
|
62
|
+
readonly __di_type?: infer R;
|
|
63
|
+
} ? R : never;
|
|
64
|
+
type ResolveTokens<Tokens extends readonly unknown[]> = {
|
|
65
|
+
[K in keyof Tokens]: Tokens[K] extends Token<infer R> ? R : ResolveToken<Tokens[K]>;
|
|
66
|
+
};
|
|
67
|
+
type Mutable<T extends readonly unknown[]> = {
|
|
68
|
+
-readonly [K in keyof T]: T[K];
|
|
69
|
+
};
|
|
70
|
+
/** 3) FactoryType with correct useFactory shape **/
|
|
71
|
+
export interface FactoryType<Provide, Tokens extends readonly (ClassToken | Token)[]> {
|
|
72
|
+
provide: Reference<Provide>;
|
|
73
|
+
inject: () => Tokens;
|
|
74
|
+
useFactory: (...args: Mutable<ResolveTokens<Tokens>>) => Provide | Promise<Provide>;
|
|
75
|
+
}
|
|
76
|
+
export type RequiredByKey<T, K extends keyof T> = T & Required<Omit<T, K>>;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.interface.js","sourceRoot":"","sources":["../../../src/interfaces/base.interface.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Constructor type for a concrete class that produces instances of T.\n *\n * Useful anywhere a factory/DI container expects a class reference that can be\n * `new`-ed. For example: `getProvider(UserRepo as Type<UserRepo>)`.\n */\nexport interface Type<T = unknown> extends Function {\n new(...args: any[]): T;\n}\n\n/**\n * Constructor type for a concrete class that produces instances of T.\n *\n * Useful anywhere a factory/DI container expects a class reference that can be\n * `new`-ed. For example: `getProvider(UserRepo as Type<UserRepo>)`.\n */\nexport type FuncType<T> = (...args: any[]) => any | Promise<any>;\n\n\nexport type PartialStagesType<T extends string> = Partial<Record<T, Type[]>>;\n\n/**\n * Empty Constructor type for a concrete class that produces instances of T.\n *\n * Useful anywhere a factory/DI container expects a class reference that can be\n * `new`-ed. For example: `getProvider(UserRepo as Type<UserRepo>)`.\n */\nexport interface CtorType<T = unknown> extends Function {\n new(): T;\n}\n\nexport type Ctor<T> = new (...args: any[]) => T;\n\n/**\n * Shape of an abstract class (or interface-like constructor) whose instances\n * cannot be created directly but still expose a prototype of T.\n *\n * This is handy when accepting references that may point at abstract bases\n * instead of concrete implementors.\n */\nexport interface Abstract<T> extends Function {\n prototype: T;\n}\n\n/**\n * A reference token that may be used to look up or identify a dependency.\n *\n * Typical usages:\n * - string | symbol: named tokens (e.g., provider IDs like \"provider:redis\").\n * - Type<T>: a concrete class constructor (can be instantiated).\n * - Abstract<T>: an abstract base reference (resolved to a concrete impl).\n * - Function: generic function references when needed.\n */\nexport type Reference<T = unknown> = string | symbol | Type<T> | Abstract<T> | Function;\n\n/** A DI token that can be either a class constructor or a logical reference. */\nexport type Token<T = any> = Type<T> | Reference<T>;\n\n\nexport interface ClassType<Provide> {\n provide: Reference<Provide>;\n useClass: Type<Provide>;\n}\n\nexport interface ValueType<Provide> {\n provide: Reference<Provide>;\n useValue: Provide;\n}\n\n/** Map a tuple of tokens to a tuple of their instance types (order preserved). */\n\nexport type ClassToken<T = any> = abstract new (...a: any) => T;\n// Branded symbol token that carries the payload type T\n\n// export type Resolve<Tokens extends readonly Token[]> = {\n// [K in keyof Tokens]: Tokens[K] extends Token<infer R> ? R : never;\n// };\n\n/** 2) Map tokens -> runtime parameter types **/\ntype ResolveToken<T> =\n T extends ClassToken<infer R> ? R\n : T extends symbol & { readonly __di_type?: infer R } ? R\n : never;\n\ntype ResolveTokens<Tokens extends readonly unknown[]> = {\n [K in keyof Tokens]: Tokens[K] extends Token<infer R> ? R : ResolveToken<Tokens[K]>;\n};\n\n// Rest parameters can't be readonly tuples; strip readonly.\ntype Mutable<T extends readonly unknown[]> = { -readonly [K in keyof T]: T[K] };\n\n/** 3) FactoryType with correct useFactory shape **/\nexport interface FactoryType<Provide, Tokens extends readonly (ClassToken | Token)[]> {\n provide: Reference<Provide>;\n inject: () => Tokens;\n useFactory: (...args: Mutable<ResolveTokens<Tokens>>) => Provide | Promise<Provide>;\n}\n\n\n\nexport type RequiredByKey<T, K extends keyof T> = T & Required<Omit<T, K>>;\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Token, Type } from './base.interface';
|
|
2
|
+
import { FlowMetadata, FlowName } from '../metadata';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { ScopeEntry } from '../entries';
|
|
5
|
+
import { FlowStateOf } from './internal/flow.utils';
|
|
6
|
+
import { FrontMcpLogger } from "./logger.interface";
|
|
7
|
+
export type FlowInputOf<N extends FlowName> = z.infer<ExtendFlows[N]['input']>;
|
|
8
|
+
export type FlowOutputOf<N extends FlowName> = z.infer<ExtendFlows[N]['output']>;
|
|
9
|
+
export type FlowPlanOf<N extends FlowName> = ExtendFlows[N]['plan'];
|
|
10
|
+
export type FlowCtxOf<N extends FlowName> = ExtendFlows[N]['ctx'];
|
|
11
|
+
export type FlowControlType = 'respond' | 'fail' | 'abort' | 'next' | 'handled';
|
|
12
|
+
export declare class FlowControl extends Error {
|
|
13
|
+
readonly type: FlowControlType;
|
|
14
|
+
readonly output: any;
|
|
15
|
+
constructor(type: FlowControlType, output: any);
|
|
16
|
+
static respond<T>(output: T): never;
|
|
17
|
+
static next(): never;
|
|
18
|
+
static handled(): never;
|
|
19
|
+
static fail(error: Error): never;
|
|
20
|
+
static abort(reason: string): never;
|
|
21
|
+
}
|
|
22
|
+
export declare abstract class FlowBase<N extends FlowName = FlowName> {
|
|
23
|
+
protected readonly metadata: FlowMetadata<N>;
|
|
24
|
+
protected readonly rawInput: Partial<FlowInputOf<N>> | any;
|
|
25
|
+
protected readonly scope: ScopeEntry;
|
|
26
|
+
protected readonly deps: ReadonlyMap<Token, unknown>;
|
|
27
|
+
protected input: FlowInputOf<N>;
|
|
28
|
+
state: FlowStateOf<N>;
|
|
29
|
+
scopeLogger: FrontMcpLogger;
|
|
30
|
+
constructor(metadata: FlowMetadata<N>, rawInput: Partial<FlowInputOf<N>> | any, scope: ScopeEntry, deps?: ReadonlyMap<Token, unknown>);
|
|
31
|
+
get<T>(token: Token<T>): T;
|
|
32
|
+
protected respond(output: FlowOutputOf<N>): void;
|
|
33
|
+
protected fail(error: Error): void;
|
|
34
|
+
protected abort(message: string): void;
|
|
35
|
+
protected next(): void;
|
|
36
|
+
protected handled(): void;
|
|
37
|
+
}
|
|
38
|
+
export type FlowType<Provide = FlowBase<FlowName>> = Type<Provide>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowBase = exports.FlowControl = void 0;
|
|
4
|
+
const flow_utils_1 = require("./internal/flow.utils");
|
|
5
|
+
class FlowControl extends Error {
|
|
6
|
+
type;
|
|
7
|
+
output;
|
|
8
|
+
constructor(type, output) {
|
|
9
|
+
super();
|
|
10
|
+
this.type = type;
|
|
11
|
+
this.output = output;
|
|
12
|
+
}
|
|
13
|
+
static respond(output) {
|
|
14
|
+
throw new FlowControl('respond', output);
|
|
15
|
+
}
|
|
16
|
+
static next() {
|
|
17
|
+
throw new FlowControl('next', null);
|
|
18
|
+
}
|
|
19
|
+
static handled() {
|
|
20
|
+
throw new FlowControl('handled', null);
|
|
21
|
+
}
|
|
22
|
+
static fail(error) {
|
|
23
|
+
throw new FlowControl('fail', error);
|
|
24
|
+
}
|
|
25
|
+
static abort(reason) {
|
|
26
|
+
throw new FlowControl('abort', reason);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.FlowControl = FlowControl;
|
|
30
|
+
// 1) The actual abstract class (value)
|
|
31
|
+
class FlowBase {
|
|
32
|
+
metadata;
|
|
33
|
+
rawInput;
|
|
34
|
+
scope;
|
|
35
|
+
deps;
|
|
36
|
+
input;
|
|
37
|
+
state = flow_utils_1.FlowState.create({});
|
|
38
|
+
scopeLogger;
|
|
39
|
+
constructor(metadata, rawInput, scope, deps = new Map()) {
|
|
40
|
+
this.metadata = metadata;
|
|
41
|
+
this.rawInput = rawInput;
|
|
42
|
+
this.scope = scope;
|
|
43
|
+
this.deps = deps;
|
|
44
|
+
this.input = metadata.inputSchema?.parse?.(rawInput);
|
|
45
|
+
this.scopeLogger = scope.logger;
|
|
46
|
+
}
|
|
47
|
+
get(token) {
|
|
48
|
+
if (this.deps.has(token))
|
|
49
|
+
return this.deps.get(token);
|
|
50
|
+
return this.scope.providers.get(token);
|
|
51
|
+
}
|
|
52
|
+
respond(output) {
|
|
53
|
+
throw FlowControl.respond(this.metadata.outputSchema.parse(output));
|
|
54
|
+
}
|
|
55
|
+
fail(error) {
|
|
56
|
+
throw FlowControl.fail(error);
|
|
57
|
+
}
|
|
58
|
+
abort(message) {
|
|
59
|
+
throw FlowControl.abort(message);
|
|
60
|
+
}
|
|
61
|
+
next() {
|
|
62
|
+
throw FlowControl.next();
|
|
63
|
+
}
|
|
64
|
+
handled() {
|
|
65
|
+
throw FlowControl.handled();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.FlowBase = FlowBase;
|
|
69
|
+
//# sourceMappingURL=flow.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.interface.js","sourceRoot":"","sources":["../../../src/interfaces/flow.interface.ts"],"names":[],"mappings":";;;AAIA,sDAA6D;AAW7D,MAAa,WAAY,SAAQ,KAAK;IACR;IAAuC;IAAnE,YAA4B,IAAqB,EAAkB,MAAW;QAC5E,KAAK,EAAE,CAAC;QADkB,SAAI,GAAJ,IAAI,CAAiB;QAAkB,WAAM,GAAN,MAAM,CAAK;IAE9E,CAAC;IAED,MAAM,CAAC,OAAO,CAAI,MAAS;QACzB,MAAM,IAAI,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,IAAI;QACT,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,MAAM,IAAI,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,KAAY;QACtB,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAc;QACzB,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;CAEF;AAzBD,kCAyBC;AAGD,uCAAuC;AACvC,MAAsB,QAAQ;IAMP;IACA;IACA;IACA;IARX,KAAK,CAAiB;IAChC,KAAK,GAAmB,sBAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7C,WAAW,CAAiB;IAE5B,YACqB,QAAyB,EACzB,QAAuC,EACvC,KAAiB,EACjB,OAAoC,IAAI,GAAG,EAAE;QAH7C,aAAQ,GAAR,QAAQ,CAAiB;QACzB,aAAQ,GAAR,QAAQ,CAA+B;QACvC,UAAK,GAAL,KAAK,CAAY;QACjB,SAAI,GAAJ,IAAI,CAAyC;QAEhE,IAAI,CAAC,KAAK,GAAI,QAAQ,CAAC,WAAmB,EAAE,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,GAAG,CAAI,KAAe;QACpB,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAM,CAAC;QAC3D,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAES,OAAO,CAAC,MAAuB;QACvC,MAAM,WAAW,CAAC,OAAO,CAAE,IAAI,CAAC,QAAQ,CAAC,YAAiC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5F,CAAC;IAES,IAAI,CAAC,KAAY;QACzB,MAAM,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAES,KAAK,CAAC,OAAe;QAC7B,MAAM,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAES,IAAI;QACZ,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAES,OAAO;QACf,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CACF;AAvCD,4BAuCC","sourcesContent":["import {Token, Type} from './base.interface';\nimport {FlowMetadata, FlowName} from '../metadata';\nimport {z} from 'zod';\nimport {ScopeEntry} from '../entries';\nimport {FlowState, FlowStateOf} from './internal/flow.utils';\nimport {FrontMcpLogger} from \"./logger.interface\";\n\nexport type FlowInputOf<N extends FlowName> = z.infer<ExtendFlows[N]['input']>;\nexport type FlowOutputOf<N extends FlowName> = z.infer<ExtendFlows[N]['output']>;\nexport type FlowPlanOf<N extends FlowName> = ExtendFlows[N]['plan'];\nexport type FlowCtxOf<N extends FlowName> = ExtendFlows[N]['ctx'];\n\n\nexport type FlowControlType = 'respond' | 'fail' | 'abort' | 'next' | 'handled';\n\nexport class FlowControl extends Error {\n constructor(public readonly type: FlowControlType, public readonly output: any) {\n super();\n }\n\n static respond<T>(output: T): never {\n throw new FlowControl('respond', output);\n }\n\n static next(): never {\n throw new FlowControl('next', null);\n }\n\n static handled(): never {\n throw new FlowControl('handled', null);\n }\n\n static fail(error: Error): never {\n throw new FlowControl('fail', error);\n }\n\n static abort(reason: string): never {\n throw new FlowControl('abort', reason);\n }\n\n}\n\n\n// 1) The actual abstract class (value)\nexport abstract class FlowBase<N extends FlowName = FlowName> {\n protected input: FlowInputOf<N>;\n state: FlowStateOf<N> = FlowState.create({});\n scopeLogger: FrontMcpLogger;\n\n constructor(\n protected readonly metadata: FlowMetadata<N>,\n protected readonly rawInput: Partial<FlowInputOf<N>> | any,\n protected readonly scope: ScopeEntry,\n protected readonly deps: ReadonlyMap<Token, unknown> = new Map(),\n ) {\n this.input = (metadata.inputSchema as any)?.parse?.(rawInput);\n this.scopeLogger = scope.logger;\n }\n\n get<T>(token: Token<T>): T {\n if (this.deps.has(token)) return this.deps.get(token) as T;\n return this.scope.providers.get(token);\n }\n\n protected respond(output: FlowOutputOf<N>) {\n throw FlowControl.respond((this.metadata.outputSchema as z.ZodObject<any>).parse(output));\n }\n\n protected fail(error: Error) {\n throw FlowControl.fail(error);\n }\n\n protected abort(message: string) {\n throw FlowControl.abort(message);\n }\n\n protected next() {\n throw FlowControl.next();\n }\n\n protected handled() {\n throw FlowControl.handled();\n }\n}\n\nexport type FlowType<Provide = FlowBase<FlowName>> =\n | Type<Provide>\n\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"front-mcp.interface.js","sourceRoot":"","sources":["../../../src/interfaces/front-mcp.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { FrontMcpConfigType } from '../metadata';\n\n\nexport interface FrontMcpInterface {\n readonly config: FrontMcpConfigType;\n readonly ready: Promise<void>;\n\n}"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './base.interface';
|
|
2
|
+
export * from './front-mcp.interface';
|
|
3
|
+
export * from './server.interface';
|
|
4
|
+
export * from './scope.interface';
|
|
5
|
+
export * from './flow.interface';
|
|
6
|
+
export * from './app.interface';
|
|
7
|
+
export * from './provider.interface';
|
|
8
|
+
export * from './auth-provider.interface';
|
|
9
|
+
export * from './adapter.interface';
|
|
10
|
+
export * from './plugin.interface';
|
|
11
|
+
export * from './tool.interface';
|
|
12
|
+
export * from './resource.interface';
|
|
13
|
+
export * from './prompt.interface';
|
|
14
|
+
export * from './logger.interface';
|
|
15
|
+
export * from './internal';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./base.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./front-mcp.interface"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./server.interface"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./scope.interface"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./flow.interface"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./app.interface"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./provider.interface"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./auth-provider.interface"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./adapter.interface"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./plugin.interface"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./tool.interface"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./resource.interface"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./prompt.interface"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./logger.interface"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./internal"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,gEAAsC;AACtC,6DAAmC;AACnC,4DAAkC;AAClC,2DAAiC;AACjC,0DAAgC;AAChC,+DAAqC;AACrC,oEAA0C;AAC1C,8DAAoC;AACpC,6DAAmC;AACnC,2DAAiC;AACjC,+DAAqC;AACrC,6DAAmC;AACnC,6DAAmC;AAEnC,qDAA0B","sourcesContent":["export * from './base.interface';\nexport * from './front-mcp.interface';\nexport * from './server.interface';\nexport * from './scope.interface';\nexport * from './flow.interface';\nexport * from './app.interface';\nexport * from './provider.interface';\nexport * from './auth-provider.interface';\nexport * from './adapter.interface';\nexport * from './plugin.interface';\nexport * from './tool.interface';\nexport * from './resource.interface';\nexport * from './prompt.interface';\nexport * from './logger.interface';\n\nexport * from './internal'"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FlowName } from '../../metadata';
|
|
3
|
+
export type Dict = Record<PropertyKey, unknown>;
|
|
4
|
+
type RequiredView<T> = {
|
|
5
|
+
[K in keyof T]-?: Exclude<T[K], undefined>;
|
|
6
|
+
};
|
|
7
|
+
type StateAccess<T> = {
|
|
8
|
+
[K in keyof T]: T[K] | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
required: RequiredView<T>;
|
|
11
|
+
};
|
|
12
|
+
type StateType<Name extends FlowName> = z.infer<ExtendFlows[Name]['state']>;
|
|
13
|
+
export type FlowStateOf<Name extends FlowName, T = StateType<Name>> = StateAccess<T> & {
|
|
14
|
+
get<K extends keyof T>(key: K): T[K] | undefined;
|
|
15
|
+
getOrThrow<K extends keyof T>(key: K, message?: string): Exclude<T[K], undefined>;
|
|
16
|
+
set<K extends keyof T>(key: K, value: T[K]): FlowStateOf<Name, T>;
|
|
17
|
+
set(patch: Partial<T>): FlowStateOf<Name, T>;
|
|
18
|
+
snapshot(): Readonly<Partial<T>>;
|
|
19
|
+
};
|
|
20
|
+
export declare class FlowState {
|
|
21
|
+
private constructor();
|
|
22
|
+
static create<Name extends FlowName, T = StateType<Name>>(initial?: Partial<T>): FlowStateOf<Name>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowState = void 0;
|
|
4
|
+
class FlowState {
|
|
5
|
+
constructor() {
|
|
6
|
+
/* empty */
|
|
7
|
+
}
|
|
8
|
+
static create(initial) {
|
|
9
|
+
const data = initial ? { ...initial } : {};
|
|
10
|
+
const api = {
|
|
11
|
+
get(key) {
|
|
12
|
+
return data[key];
|
|
13
|
+
},
|
|
14
|
+
getOrThrow(key, message) {
|
|
15
|
+
const val = data[key];
|
|
16
|
+
if (val === undefined || val === null) {
|
|
17
|
+
throw new Error(message ?? `InvokeState: missing required key "${String(key)}"`);
|
|
18
|
+
}
|
|
19
|
+
return val;
|
|
20
|
+
},
|
|
21
|
+
set(...args) {
|
|
22
|
+
if (args.length === 1)
|
|
23
|
+
Object.assign(data, args[0]);
|
|
24
|
+
else {
|
|
25
|
+
const [k, v] = args;
|
|
26
|
+
data[k] = v;
|
|
27
|
+
}
|
|
28
|
+
return proxy;
|
|
29
|
+
},
|
|
30
|
+
snapshot() {
|
|
31
|
+
return { ...data };
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const requiredProxy = new Proxy({}, {
|
|
35
|
+
get(_t, prop) {
|
|
36
|
+
const val = data[prop];
|
|
37
|
+
if (val === undefined || val === null) {
|
|
38
|
+
throw new Error(`InvokeState: missing required key "${String(prop)}"`);
|
|
39
|
+
}
|
|
40
|
+
return val;
|
|
41
|
+
},
|
|
42
|
+
has(_t, prop) {
|
|
43
|
+
const val = data[prop];
|
|
44
|
+
return val !== undefined && val !== null;
|
|
45
|
+
},
|
|
46
|
+
ownKeys() {
|
|
47
|
+
return Reflect.ownKeys(data);
|
|
48
|
+
},
|
|
49
|
+
getOwnPropertyDescriptor() {
|
|
50
|
+
return { enumerable: true, configurable: true };
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
const methodKeys = new Set(['get', 'getOrThrow', 'set', 'snapshot']);
|
|
54
|
+
const proxy = new Proxy(api, {
|
|
55
|
+
get(_t, prop, receiver) {
|
|
56
|
+
if (prop === 'required')
|
|
57
|
+
return requiredProxy;
|
|
58
|
+
if (methodKeys.has(prop))
|
|
59
|
+
return Reflect.get(api, prop, receiver);
|
|
60
|
+
return data[prop];
|
|
61
|
+
},
|
|
62
|
+
set(_t, prop, value) {
|
|
63
|
+
data[prop] = value;
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
has(_t, prop) {
|
|
67
|
+
return prop === 'required' || methodKeys.has(prop) || prop in data;
|
|
68
|
+
},
|
|
69
|
+
ownKeys() {
|
|
70
|
+
return [...Reflect.ownKeys(data), 'required', ...methodKeys];
|
|
71
|
+
},
|
|
72
|
+
getOwnPropertyDescriptor(_t, prop) {
|
|
73
|
+
if (prop === 'required' || methodKeys.has(prop)) {
|
|
74
|
+
return { enumerable: false, configurable: true };
|
|
75
|
+
}
|
|
76
|
+
return { enumerable: true, configurable: true };
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
return proxy;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.FlowState = FlowState;
|
|
83
|
+
//# sourceMappingURL=flow.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.utils.js","sourceRoot":"","sources":["../../../../src/interfaces/internal/flow.utils.ts"],"names":[],"mappings":";;;AAiBA,MAAa,SAAS;IACpB;QACE,WAAW;IACb,CAAC;IAED,MAAM,CAAC,MAAM,CAA6C,OAAoB;QAC5E,MAAM,IAAI,GAAe,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAEvD,MAAM,GAAG,GAAG;YACV,GAAG,CAAoB,GAAM;gBAC3B,OAAO,IAAI,CAAC,GAAG,CAAqB,CAAC;YACvC,CAAC;YACD,UAAU,CAAoB,GAAM,EAAE,OAAgB;gBACpD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;gBACtB,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;oBACtC,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,sCAAsC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACnF,CAAC;gBACD,OAAO,GAA+B,CAAC;YACzC,CAAC;YACD,GAAG,CAAoB,GAAG,IAA8B;gBACtD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;oBAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;qBAC/C,CAAC;oBACJ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAiB,CAAC;oBAChC,IAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBACvB,CAAC;gBACD,OAAO,KAA0B,CAAC;YACpC,CAAC;YACD,QAAQ;gBACN,OAAO,EAAE,GAAG,IAAI,EAA0B,CAAC;YAC7C,CAAC;SACF,CAAC;QAEF,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,EAAqB,EAAE;YACrD,GAAG,CAAC,EAAE,EAAE,IAAiB;gBACvB,MAAM,GAAG,GAAI,IAAY,CAAC,IAAI,CAAC,CAAC;gBAChC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;oBACtC,MAAM,IAAI,KAAK,CAAC,sCAAsC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACzE,CAAC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC;YACD,GAAG,CAAC,EAAE,EAAE,IAAI;gBACV,MAAM,GAAG,GAAI,IAAY,CAAC,IAAI,CAAC,CAAC;gBAChC,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,CAAC;YAC3C,CAAC;YACD,OAAO;gBACL,OAAO,OAAO,CAAC,OAAO,CAAC,IAAc,CAAC,CAAC;YACzC,CAAC;YACD,wBAAwB;gBACtB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;YAClD,CAAC;SACF,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAc,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;QAElF,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAU,EAAE;YAClC,GAAG,CAAC,EAAE,EAAE,IAAiB,EAAE,QAAQ;gBACjC,IAAI,IAAI,KAAK,UAAU;oBAAE,OAAO,aAAa,CAAC;gBAC9C,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;oBAAE,OAAO,OAAO,CAAC,GAAG,CAAC,GAAU,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;gBACzE,OAAQ,IAAY,CAAC,IAAI,CAAC,CAAC;YAC7B,CAAC;YACD,GAAG,CAAC,EAAE,EAAE,IAAiB,EAAE,KAAK;gBAC7B,IAAY,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;gBAC5B,OAAO,IAAI,CAAC;YACd,CAAC;YACD,GAAG,CAAC,EAAE,EAAE,IAAI;gBACV,OAAO,IAAI,KAAK,UAAU,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,IAAK,IAAe,CAAC;YACjF,CAAC;YACD,OAAO;gBACL,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,IAAc,CAAC,EAAE,UAAU,EAAE,GAAG,UAAU,CAA+B,CAAC;YACvG,CAAC;YACD,wBAAwB,CAAC,EAAE,EAAE,IAAI;gBAC/B,IAAI,IAAI,KAAK,UAAU,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;oBAChD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;gBACnD,CAAC;gBACD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;YAClD,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,KAA0B,CAAC;IACpC,CAAC;CACF;AAhFD,8BAgFC","sourcesContent":["import { z } from 'zod';\nimport { FlowName } from '../../metadata';\n\nexport type Dict = Record<PropertyKey, unknown>;\ntype RequiredView<T> = { [K in keyof T]-?: Exclude<T[K], undefined> };\ntype StateAccess<T> = { [K in keyof T]: T[K] | undefined } & { required: RequiredView<T> };\n\ntype StateType<Name extends FlowName> = z.infer<ExtendFlows[Name]['state']>\n\nexport type FlowStateOf<Name extends FlowName, T = StateType<Name>> = StateAccess<T> & {\n get<K extends keyof T>(key: K): T[K] | undefined;\n getOrThrow<K extends keyof T>(key: K, message?: string): Exclude<T[K], undefined>;\n set<K extends keyof T>(key: K, value: T[K]): FlowStateOf<Name, T>;\n set(patch: Partial<T>): FlowStateOf<Name, T>;\n snapshot(): Readonly<Partial<T>>;\n};\n\nexport class FlowState {\n private constructor() {\n /* empty */\n }\n\n static create<Name extends FlowName, T = StateType<Name>>(initial?: Partial<T>): FlowStateOf<Name> {\n const data: Partial<T> = initial ? { ...initial } : {};\n\n const api = {\n get<K extends keyof T>(key: K) {\n return data[key] as T[K] | undefined;\n },\n getOrThrow<K extends keyof T>(key: K, message?: string) {\n const val = data[key];\n if (val === undefined || val === null) {\n throw new Error(message ?? `InvokeState: missing required key \"${String(key)}\"`);\n }\n return val as Exclude<T[K], undefined>;\n },\n set<K extends keyof T>(...args: [K, T[K]] | [Partial<T>]) {\n if (args.length === 1) Object.assign(data, args[0]);\n else {\n const [k, v] = args as [K, T[K]];\n (data as any)[k] = v;\n }\n return proxy as FlowStateOf<Name>;\n },\n snapshot() {\n return { ...data } as Readonly<Partial<T>>;\n },\n };\n\n const requiredProxy = new Proxy({} as RequiredView<T>, {\n get(_t, prop: PropertyKey) {\n const val = (data as any)[prop];\n if (val === undefined || val === null) {\n throw new Error(`InvokeState: missing required key \"${String(prop)}\"`);\n }\n return val;\n },\n has(_t, prop) {\n const val = (data as any)[prop];\n return val !== undefined && val !== null;\n },\n ownKeys() {\n return Reflect.ownKeys(data as object);\n },\n getOwnPropertyDescriptor() {\n return { enumerable: true, configurable: true };\n },\n });\n\n const methodKeys = new Set<PropertyKey>(['get', 'getOrThrow', 'set', 'snapshot']);\n\n const proxy = new Proxy(api as any, {\n get(_t, prop: PropertyKey, receiver) {\n if (prop === 'required') return requiredProxy;\n if (methodKeys.has(prop)) return Reflect.get(api as any, prop, receiver);\n return (data as any)[prop];\n },\n set(_t, prop: PropertyKey, value) {\n (data as any)[prop] = value;\n return true;\n },\n has(_t, prop) {\n return prop === 'required' || methodKeys.has(prop) || prop in (data as object);\n },\n ownKeys() {\n return [...Reflect.ownKeys(data as object), 'required', ...methodKeys] as ArrayLike<string | symbol>;\n },\n getOwnPropertyDescriptor(_t, prop) {\n if (prop === 'required' || methodKeys.has(prop)) {\n return { enumerable: false, configurable: true };\n }\n return { enumerable: true, configurable: true };\n },\n });\n\n return proxy as FlowStateOf<Name>;\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
// core interfaces
|
|
5
|
+
tslib_1.__exportStar(require("./primary-auth-provider.interface"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./registry.interface"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/interfaces/internal/index.ts"],"names":[],"mappings":";;;AAAA,kBAAkB;AAClB,4EAAkD;AAClD,+DAAqC","sourcesContent":["// core interfaces\nexport * from './primary-auth-provider.interface';\nexport * from './registry.interface';\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ServerRequest } from '../server.interface';
|
|
2
|
+
import { AuthOptions } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Base class for primary auth provider.
|
|
5
|
+
* Used for easy access current auth context by dependency injection.
|
|
6
|
+
*
|
|
7
|
+
* In tool context, you can access current auth context by calling:
|
|
8
|
+
* this.get(FrontMcpAuth) | this.get(Auth)
|
|
9
|
+
*
|
|
10
|
+
* Or in session scoped Providers in constructor arguments:
|
|
11
|
+
* constructor(private readonly auth: FrontMcpAuth) {
|
|
12
|
+
* // auth.fetch('MY endpoint ')
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class FrontMcpAuth {
|
|
16
|
+
ready: Promise<void>;
|
|
17
|
+
readonly options: AuthOptions;
|
|
18
|
+
readonly id: string;
|
|
19
|
+
constructor(options: AuthOptions);
|
|
20
|
+
abstract fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
21
|
+
abstract validate(request: ServerRequest): Promise<void>;
|
|
22
|
+
abstract get issuer(): string;
|
|
23
|
+
}
|
|
24
|
+
export { FrontMcpAuth as Auth, };
|