@frontmcp/sdk 0.2.5 → 0.3.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 +81 -99
- package/package.json +24 -2
- package/src/adapter/adapter.instance.d.ts +11 -0
- package/src/adapter/adapter.instance.js +65 -0
- package/src/adapter/adapter.instance.js.map +1 -0
- package/src/adapter/adapter.regsitry.d.ts +13 -0
- package/src/adapter/adapter.regsitry.js +54 -0
- package/src/adapter/adapter.regsitry.js.map +1 -0
- package/src/adapter/adapter.utils.d.ts +10 -0
- package/src/adapter/adapter.utils.js +83 -0
- package/src/adapter/adapter.utils.js.map +1 -0
- package/src/app/app.registry.d.ts +12 -0
- package/src/app/app.registry.js +64 -0
- package/src/app/app.registry.js.map +1 -0
- package/src/app/app.utils.d.ts +15 -0
- package/src/app/app.utils.js +58 -0
- package/src/app/app.utils.js.map +1 -0
- package/src/app/instances/app.local.instance.d.ts +25 -0
- package/src/app/instances/app.local.instance.js +70 -0
- package/src/app/instances/app.local.instance.js.map +1 -0
- package/src/app/instances/app.remote.instance.d.ts +13 -0
- package/src/app/instances/app.remote.instance.js +36 -0
- package/src/app/instances/app.remote.instance.js.map +1 -0
- package/src/app/instances/index.d.ts +2 -0
- package/src/app/instances/index.js +6 -0
- package/src/app/instances/index.js.map +1 -0
- package/src/auth/auth.registry.d.ts +13 -0
- package/src/auth/auth.registry.js +81 -0
- package/src/auth/auth.registry.js.map +1 -0
- package/src/auth/auth.utils.d.ts +10 -0
- package/src/auth/auth.utils.js +85 -0
- package/src/auth/auth.utils.js.map +1 -0
- package/src/auth/flows/oauth.authorize.flow.d.ts +231 -0
- package/src/auth/flows/oauth.authorize.flow.js +154 -0
- package/src/auth/flows/oauth.authorize.flow.js.map +1 -0
- package/src/auth/flows/oauth.register.flow.d.ts +202 -0
- package/src/auth/flows/oauth.register.flow.js +201 -0
- package/src/auth/flows/oauth.register.flow.js.map +1 -0
- package/src/auth/flows/oauth.token.flow.d.ts +242 -0
- package/src/auth/flows/oauth.token.flow.js +181 -0
- package/src/auth/flows/oauth.token.flow.js.map +1 -0
- package/src/auth/flows/session.verify.flow.d.ts +404 -0
- package/src/auth/flows/session.verify.flow.js +205 -0
- package/src/auth/flows/session.verify.flow.js.map +1 -0
- package/src/auth/flows/well-known.jwks.flow.d.ts +261 -0
- package/src/auth/flows/well-known.jwks.flow.js +82 -0
- package/src/auth/flows/well-known.jwks.flow.js.map +1 -0
- package/src/auth/flows/well-known.oauth-authorization-server.flow.d.ts +282 -0
- package/src/auth/flows/well-known.oauth-authorization-server.flow.js +123 -0
- package/src/auth/flows/well-known.oauth-authorization-server.flow.js.map +1 -0
- package/src/auth/flows/well-known.prm.flow.d.ts +159 -0
- package/src/auth/flows/well-known.prm.flow.js +107 -0
- package/src/auth/flows/well-known.prm.flow.js.map +1 -0
- package/src/auth/instances/instance.local-primary-auth.d.ts +19 -0
- package/src/auth/instances/instance.local-primary-auth.js +76 -0
- package/src/auth/instances/instance.local-primary-auth.js.map +1 -0
- package/src/auth/instances/instance.remote-primary-auth.d.ts +14 -0
- package/src/auth/instances/instance.remote-primary-auth.js +47 -0
- package/src/auth/instances/instance.remote-primary-auth.js.map +1 -0
- package/src/auth/jwks/index.d.ts +2 -0
- package/src/auth/jwks/index.js +6 -0
- package/src/auth/jwks/index.js.map +1 -0
- package/src/auth/jwks/jwks.service.d.ts +41 -0
- package/src/auth/jwks/jwks.service.js +235 -0
- package/src/auth/jwks/jwks.service.js.map +1 -0
- package/src/auth/jwks/jwks.types.d.ts +25 -0
- package/src/auth/jwks/jwks.types.js +3 -0
- package/src/auth/jwks/jwks.types.js.map +1 -0
- package/src/auth/jwks/jwks.utils.d.ts +4 -0
- package/src/auth/jwks/jwks.utils.js +32 -0
- package/src/auth/jwks/jwks.utils.js.map +1 -0
- package/src/auth/oauth/flows/oauth.authorize.flow.d.ts +31 -0
- package/src/auth/oauth/flows/oauth.authorize.flow.js +33 -0
- package/src/auth/oauth/flows/oauth.authorize.flow.js.map +1 -0
- package/src/auth/oauth/flows/oauth.device-authorization.flow.d.ts +46 -0
- package/src/auth/oauth/flows/oauth.device-authorization.flow.js +48 -0
- package/src/auth/oauth/flows/oauth.device-authorization.flow.js.map +1 -0
- package/src/auth/oauth/flows/oauth.introspect.flow.d.ts +26 -0
- package/src/auth/oauth/flows/oauth.introspect.flow.js +28 -0
- package/src/auth/oauth/flows/oauth.introspect.flow.js.map +1 -0
- package/src/auth/oauth/flows/oauth.par.flow.d.ts +27 -0
- package/src/auth/oauth/flows/oauth.par.flow.js +29 -0
- package/src/auth/oauth/flows/oauth.par.flow.js.map +1 -0
- package/src/auth/oauth/flows/oauth.revoke.flow.d.ts +25 -0
- package/src/auth/oauth/flows/oauth.revoke.flow.js +27 -0
- package/src/auth/oauth/flows/oauth.revoke.flow.js.map +1 -0
- package/src/auth/oauth/flows/oauth.token.flow.d.ts +57 -0
- package/src/auth/oauth/flows/oauth.token.flow.js +59 -0
- package/src/auth/oauth/flows/oauth.token.flow.js.map +1 -0
- package/src/auth/oauth/flows/oauth.userinfo.flow.d.ts +22 -0
- package/src/auth/oauth/flows/oauth.userinfo.flow.js +24 -0
- package/src/auth/oauth/flows/oauth.userinfo.flow.js.map +1 -0
- package/src/auth/oauth/flows/oidc.logout.flow.d.ts +18 -0
- package/src/auth/oauth/flows/oidc.logout.flow.js +20 -0
- package/src/auth/oauth/flows/oidc.logout.flow.js.map +1 -0
- package/src/auth/path.utils.d.ts +20 -0
- package/src/auth/path.utils.js +71 -0
- package/src/auth/path.utils.js.map +1 -0
- package/src/auth/session/index.d.ts +4 -0
- package/src/auth/session/index.js +10 -0
- package/src/auth/session/index.js.map +1 -0
- package/src/auth/session/record/session.base.d.ts +103 -0
- package/src/auth/session/record/session.base.js +123 -0
- package/src/auth/session/record/session.base.js.map +1 -0
- package/src/auth/session/record/session.stateful.d.ts +20 -0
- package/src/auth/session/record/session.stateful.js +55 -0
- package/src/auth/session/record/session.stateful.js.map +1 -0
- package/src/auth/session/record/session.stateless.d.ts +17 -0
- package/src/auth/session/record/session.stateless.js +30 -0
- package/src/auth/session/record/session.stateless.js.map +1 -0
- package/src/auth/session/record/session.transparent.d.ts +17 -0
- package/src/auth/session/record/session.transparent.js +22 -0
- package/src/auth/session/record/session.transparent.js.map +1 -0
- package/src/auth/session/session.crypto.d.ts +7 -0
- package/src/auth/session/session.crypto.js +47 -0
- package/src/auth/session/session.crypto.js.map +1 -0
- package/src/auth/session/session.schema.d.ts +5 -0
- package/src/auth/session/session.schema.js +13 -0
- package/src/auth/session/session.schema.js.map +1 -0
- package/src/auth/session/session.service.d.ts +17 -0
- package/src/auth/session/session.service.js +111 -0
- package/src/auth/session/session.service.js.map +1 -0
- package/src/auth/session/session.transport.d.ts +4 -0
- package/src/auth/session/session.transport.js +20 -0
- package/src/auth/session/session.transport.js.map +1 -0
- package/src/auth/session/session.types.d.ts +65 -0
- package/src/auth/session/session.types.js +4 -0
- package/src/auth/session/session.types.js.map +1 -0
- package/src/auth/session/token.refresh.d.ts +60 -0
- package/src/auth/session/token.refresh.js +63 -0
- package/src/auth/session/token.refresh.js.map +1 -0
- package/src/auth/session/token.store.d.ts +35 -0
- package/src/auth/session/token.store.js +53 -0
- package/src/auth/session/token.store.js.map +1 -0
- package/src/auth/session/token.vault.d.ts +26 -0
- package/src/auth/session/token.vault.js +54 -0
- package/src/auth/session/token.vault.js.map +1 -0
- package/src/auth/session/utils/auth-token.utils.d.ts +11 -0
- package/src/auth/session/utils/auth-token.utils.js +57 -0
- package/src/auth/session/utils/auth-token.utils.js.map +1 -0
- package/src/auth/session/utils/session-id.utils.d.ts +17 -0
- package/src/auth/session/utils/session-id.utils.js +129 -0
- package/src/auth/session/utils/session-id.utils.js.map +1 -0
- package/src/auth/session/utils/tiny-ttl-cache.d.ts +7 -0
- package/src/auth/session/utils/tiny-ttl-cache.js +26 -0
- package/src/auth/session/utils/tiny-ttl-cache.js.map +1 -0
- package/src/common/common.schema.d.ts +29 -0
- package/src/common/common.schema.js +35 -0
- package/src/common/common.schema.js.map +1 -0
- package/src/common/constants.d.ts +2 -0
- package/src/common/constants.js +8 -0
- package/src/common/constants.js.map +1 -0
- package/src/common/decorators/adapter.decorator.js.map +1 -0
- package/src/common/decorators/app.decorator.js.map +1 -0
- package/src/common/decorators/auth-provider.decorator.js.map +1 -0
- package/src/common/decorators/flow.decorator.js.map +1 -0
- package/src/common/decorators/front-mcp.decorator.js +40 -0
- package/src/common/decorators/front-mcp.decorator.js.map +1 -0
- package/src/common/decorators/hook.decorator.js.map +1 -0
- package/src/common/decorators/index.js.map +1 -0
- package/src/common/decorators/logger.decorator.js.map +1 -0
- package/src/common/decorators/plugin.decorator.js.map +1 -0
- package/src/common/decorators/prompt.decorator.js.map +1 -0
- package/src/common/decorators/provider.decorator.js.map +1 -0
- package/src/common/decorators/resource.decorator.js.map +1 -0
- package/src/common/decorators/tool.decorator.d.ts +42 -0
- package/src/common/decorators/tool.decorator.js +46 -0
- package/src/common/decorators/tool.decorator.js.map +1 -0
- package/src/common/decorators-old/async-with.decorator.d.ts +10 -0
- package/src/common/decorators-old/async-with.decorator.js +24 -0
- package/src/common/decorators-old/async-with.decorator.js.map +1 -0
- package/src/common/decorators-old/auth-hook.decorator.js.map +1 -0
- package/src/common/decorators-old/session-hook.decorator.js.map +1 -0
- package/src/common/dynamic/dynamic.adapter.js.map +1 -0
- package/src/common/dynamic/dynamic.plugin.js.map +1 -0
- package/src/common/dynamic/dynamic.utils.d.ts +3 -0
- package/src/common/dynamic/dynamic.utils.js.map +1 -0
- package/src/common/dynamic/index.js.map +1 -0
- package/src/common/entries/adapter.entry.js.map +1 -0
- package/src/common/entries/app.entry.d.ts +13 -0
- package/src/common/entries/app.entry.js.map +1 -0
- package/src/common/entries/auth-provider.entry.js.map +1 -0
- package/src/common/entries/base.entry.js.map +1 -0
- package/src/common/entries/flow.entry.js.map +1 -0
- package/src/common/entries/hook.entry.js.map +1 -0
- package/src/common/entries/index.js.map +1 -0
- package/src/common/entries/logger.entry.js.map +1 -0
- package/src/common/entries/plugin.entry.js.map +1 -0
- package/src/common/entries/prompt.entry.js.map +1 -0
- package/src/common/entries/provider.entry.js.map +1 -0
- package/src/common/entries/resource.entry.js.map +1 -0
- package/src/common/entries/scope.entry.js.map +1 -0
- package/src/common/entries/tool.entry.js.map +1 -0
- package/src/common/index.d.ts +17 -0
- package/src/common/index.js +21 -0
- package/src/common/index.js.map +1 -0
- package/src/common/interfaces/adapter.interface.js.map +1 -0
- package/src/common/interfaces/app.interface.js.map +1 -0
- package/src/common/interfaces/auth-hook.interface.js.map +1 -0
- package/src/common/interfaces/auth-provider.interface.js.map +1 -0
- package/src/common/interfaces/base.interface.js.map +1 -0
- package/src/common/interfaces/flow.interface.d.ts +41 -0
- package/src/common/interfaces/flow.interface.js.map +1 -0
- package/src/common/interfaces/front-mcp.interface.js.map +1 -0
- package/src/common/interfaces/hook.interface.js.map +1 -0
- package/src/common/interfaces/index.js.map +1 -0
- package/src/common/interfaces/internal/flow.utils.d.ts +23 -0
- package/src/common/interfaces/internal/flow.utils.js.map +1 -0
- package/src/common/interfaces/internal/index.js.map +1 -0
- package/src/common/interfaces/internal/primary-auth-provider.interface.d.ts +24 -0
- package/src/common/interfaces/internal/primary-auth-provider.interface.js.map +1 -0
- package/src/common/interfaces/internal/registry.interface.d.ts +95 -0
- package/src/common/interfaces/internal/registry.interface.js.map +1 -0
- package/src/common/interfaces/logger.interface.js.map +1 -0
- package/src/common/interfaces/plugin.interface.js.map +1 -0
- package/src/common/interfaces/prompt.interface.js.map +1 -0
- package/src/common/interfaces/provider.interface.js.map +1 -0
- package/src/common/interfaces/resource.interface.js.map +1 -0
- package/src/common/interfaces/scope.interface.js.map +1 -0
- package/src/common/interfaces/server.interface.js.map +1 -0
- package/src/common/interfaces/session-hook.interface.js.map +1 -0
- package/src/common/interfaces/tool-hook.interface.js.map +1 -0
- package/src/common/interfaces/tool.interface.js.map +1 -0
- package/src/common/metadata/adapter.metadata.js.map +1 -0
- package/src/common/metadata/app.metadata.d.ts +872 -0
- package/src/common/metadata/app.metadata.js.map +1 -0
- package/src/common/metadata/auth-provider.metadata.js.map +1 -0
- package/src/common/metadata/flow.metadata.d.ts +77 -0
- package/src/common/metadata/flow.metadata.js.map +1 -0
- package/src/common/metadata/front-mcp.metadata.d.ts +1144 -0
- package/src/common/metadata/front-mcp.metadata.js.map +1 -0
- package/src/common/metadata/hook.metadata.js.map +1 -0
- package/src/common/metadata/index.js.map +1 -0
- package/src/common/metadata/logger.metadata.js.map +1 -0
- package/src/common/metadata/plugin.metadata.js.map +1 -0
- package/src/common/metadata/prompt.metadata.js.map +1 -0
- package/src/common/metadata/provider.metadata.js.map +1 -0
- package/src/common/metadata/resource.metadata.js.map +1 -0
- package/src/common/metadata/tool.metadata.d.ts +178 -0
- package/src/common/metadata/tool.metadata.js.map +1 -0
- package/src/common/providers/session.provider.js.map +1 -0
- package/src/common/records/adapter.record.js.map +1 -0
- package/src/common/records/app.record.js.map +1 -0
- package/src/common/records/auth-provider.record.js.map +1 -0
- package/src/common/records/flow.record.js.map +1 -0
- package/src/common/records/hook.record.js.map +1 -0
- package/src/common/records/index.js.map +1 -0
- package/src/common/records/logger.record.d.ts +11 -0
- package/src/common/records/logger.record.js.map +1 -0
- package/src/common/records/plugin.record.js.map +1 -0
- package/src/common/records/prompt.record.js.map +1 -0
- package/src/common/records/provider.record.js.map +1 -0
- package/src/common/records/resource.record.js.map +1 -0
- package/src/common/records/scope.record.js.map +1 -0
- package/src/common/records/tool.record.js.map +1 -0
- package/src/common/schemas/annotated-class.schema.js.map +1 -0
- package/src/common/schemas/http-input.schema.js.map +1 -0
- package/src/common/schemas/http-output.schema.d.ts +2011 -0
- package/src/common/schemas/http-output.schema.js.map +1 -0
- package/src/common/schemas/index.js.map +1 -0
- package/src/common/tokens/adapter.tokens.js.map +1 -0
- package/src/common/tokens/app.tokens.js.map +1 -0
- package/src/common/tokens/auth-provider.tokens.js.map +1 -0
- package/src/common/tokens/base.tokens.js.map +1 -0
- package/src/common/tokens/flow-hook.tokens.js.map +1 -0
- package/src/common/tokens/flow.tokens.js.map +1 -0
- package/src/common/tokens/front-mcp.tokens.js.map +1 -0
- package/src/common/tokens/index.js.map +1 -0
- package/src/common/tokens/logger.tokens.js.map +1 -0
- package/src/common/tokens/plugin.tokens.js.map +1 -0
- package/src/common/tokens/prompt.tokens.js.map +1 -0
- package/src/common/tokens/provider.tokens.js.map +1 -0
- package/src/common/tokens/resource.tokens.js.map +1 -0
- package/src/common/tokens/server.tokens.js.map +1 -0
- package/src/common/tokens/tool.tokens.js.map +1 -0
- package/src/common/types/auth/index.js.map +1 -0
- package/src/common/types/auth/jwt.types.js.map +1 -0
- package/src/common/types/auth/session.types.d.ts +263 -0
- package/src/common/types/auth/session.types.js.map +1 -0
- package/src/common/types/common.types.js.map +1 -0
- package/src/common/types/index.js.map +1 -0
- package/src/common/types/options/auth.options.d.ts +513 -0
- package/src/common/types/options/auth.options.js.map +1 -0
- package/src/common/types/options/http.options.js.map +1 -0
- package/src/common/types/options/index.js.map +1 -0
- package/src/common/types/options/logging.options.d.ts +39 -0
- package/src/common/types/options/logging.options.js.map +1 -0
- package/src/common/types/options/server-info.options.d.ts +48 -0
- package/src/common/types/options/server-info.options.js.map +1 -0
- package/src/common/types/options/session.options.d.ts +67 -0
- package/src/common/types/options/session.options.js.map +1 -0
- package/src/common/utils/decide-request-intent.utils.d.ts +79 -0
- package/src/common/utils/decide-request-intent.utils.js.map +1 -0
- package/src/common/utils/index.js.map +1 -0
- package/src/common/utils/path.utils.d.ts +20 -0
- package/src/common/utils/path.utils.js.map +1 -0
- package/src/exceptions/mcp-exceptions/session-missing.exception.d.ts +3 -0
- package/src/exceptions/mcp-exceptions/session-missing.exception.js +11 -0
- package/src/exceptions/mcp-exceptions/session-missing.exception.js.map +1 -0
- package/src/exceptions/mcp-exceptions/unsupported-client-version.exception.d.ts +5 -0
- package/src/exceptions/mcp-exceptions/unsupported-client-version.exception.js +15 -0
- package/src/exceptions/mcp-exceptions/unsupported-client-version.exception.js.map +1 -0
- package/src/flows/flow.instance.d.ts +16 -0
- package/src/flows/flow.instance.js +332 -0
- package/src/flows/flow.instance.js.map +1 -0
- package/src/flows/flow.registry.d.ts +14 -0
- package/src/flows/flow.registry.js +79 -0
- package/src/flows/flow.registry.js.map +1 -0
- package/src/flows/flow.stages.d.ts +12 -0
- package/src/flows/flow.stages.js +110 -0
- package/src/flows/flow.stages.js.map +1 -0
- package/src/flows/flow.utils.d.ts +8 -0
- package/src/flows/flow.utils.js +36 -0
- package/src/flows/flow.utils.js.map +1 -0
- package/src/front-mcp/front-mcp.d.ts +12 -0
- package/src/front-mcp/front-mcp.js +44 -0
- package/src/front-mcp/front-mcp.js.map +1 -0
- package/src/front-mcp/front-mcp.providers.d.ts +198 -0
- package/src/front-mcp/front-mcp.providers.js +30 -0
- package/src/front-mcp/front-mcp.providers.js.map +1 -0
- package/src/front-mcp/front-mcp.tokens.d.ts +2 -0
- package/src/front-mcp/front-mcp.tokens.js +5 -0
- package/src/front-mcp/front-mcp.tokens.js.map +1 -0
- package/src/front-mcp/index.d.ts +1 -0
- package/src/front-mcp/index.js +5 -0
- package/src/front-mcp/index.js.map +1 -0
- package/src/hooks/hook.instance.d.ts +7 -0
- package/src/hooks/hook.instance.js +23 -0
- package/src/hooks/hook.instance.js.map +1 -0
- package/src/hooks/hook.registry.d.ts +34 -0
- package/src/hooks/hook.registry.js +138 -0
- package/src/hooks/hook.registry.js.map +1 -0
- package/src/hooks/hooks.utils.d.ts +3 -0
- package/src/hooks/hooks.utils.js +27 -0
- package/src/hooks/hooks.utils.js.map +1 -0
- package/src/index.d.ts +21 -18
- package/src/index.js +9 -18
- package/src/index.js.map +1 -1
- package/src/logger/instances/instance.console-logger.d.ts +10 -0
- package/src/logger/instances/instance.console-logger.js +75 -0
- package/src/logger/instances/instance.console-logger.js.map +1 -0
- package/src/logger/instances/instance.logger.d.ts +24 -0
- package/src/logger/instances/instance.logger.js +77 -0
- package/src/logger/instances/instance.logger.js.map +1 -0
- package/src/logger/logger.registry.d.ts +13 -0
- package/src/logger/logger.registry.js +91 -0
- package/src/logger/logger.registry.js.map +1 -0
- package/src/logger/logger.tokens.d.ts +1 -0
- package/src/logger/logger.tokens.js +3 -0
- package/src/logger/logger.tokens.js.map +1 -0
- package/src/logger/logger.types.d.ts +10 -0
- package/src/logger/logger.types.js +8 -0
- package/src/logger/logger.types.js.map +1 -0
- package/src/logger/logger.utils.d.ts +15 -0
- package/src/logger/logger.utils.js +42 -0
- package/src/logger/logger.utils.js.map +1 -0
- package/src/plugin/plugin.registry.d.ts +24 -0
- package/src/plugin/plugin.registry.js +137 -0
- package/src/plugin/plugin.registry.js.map +1 -0
- package/src/plugin/plugin.utils.d.ts +10 -0
- package/src/plugin/plugin.utils.js +88 -0
- package/src/plugin/plugin.utils.js.map +1 -0
- package/src/prompt/prompt.registry.d.ts +16 -0
- package/src/prompt/prompt.registry.js +34 -0
- package/src/prompt/prompt.registry.js.map +1 -0
- package/src/provider/provider.registry.d.ts +75 -0
- package/src/provider/provider.registry.js +679 -0
- package/src/provider/provider.registry.js.map +1 -0
- package/src/provider/provider.types.d.ts +9 -0
- package/src/provider/provider.types.js +3 -0
- package/src/provider/provider.types.js.map +1 -0
- package/src/provider/provider.utils.d.ts +13 -0
- package/src/provider/provider.utils.js +103 -0
- package/src/provider/provider.utils.js.map +1 -0
- package/src/regsitry/index.d.ts +1 -0
- package/src/regsitry/index.js +5 -0
- package/src/regsitry/index.js.map +1 -0
- package/src/regsitry/registry.base.d.ts +25 -0
- package/src/regsitry/registry.base.js +32 -0
- package/src/regsitry/registry.base.js.map +1 -0
- package/src/resource/resource.registry.d.ts +15 -0
- package/src/resource/resource.registry.js +31 -0
- package/src/resource/resource.registry.js.map +1 -0
- package/src/scope/flows/http.request.flow.d.ts +384 -0
- package/src/scope/flows/http.request.flow.js +210 -0
- package/src/scope/flows/http.request.flow.js.map +1 -0
- package/src/scope/index.d.ts +1 -0
- package/src/scope/index.js +6 -0
- package/src/scope/index.js.map +1 -0
- package/src/scope/scope.instance.d.ts +35 -0
- package/src/scope/scope.instance.js +120 -0
- package/src/scope/scope.instance.js.map +1 -0
- package/src/scope/scope.registry.d.ts +10 -0
- package/src/scope/scope.registry.js +93 -0
- package/src/scope/scope.registry.js.map +1 -0
- package/src/scope/scope.utils.d.ts +13 -0
- package/src/scope/scope.utils.js +59 -0
- package/src/scope/scope.utils.js.map +1 -0
- package/src/server/adapters/base.host.adapter.d.ts +7 -0
- package/src/server/adapters/base.host.adapter.js +8 -0
- package/src/server/adapters/base.host.adapter.js.map +1 -0
- package/src/server/adapters/express.host.adapter.d.ts +12 -0
- package/src/server/adapters/express.host.adapter.js +50 -0
- package/src/server/adapters/express.host.adapter.js.map +1 -0
- package/src/server/server.instance.d.ts +12 -0
- package/src/server/server.instance.js +47 -0
- package/src/server/server.instance.js.map +1 -0
- package/src/server/server.types.d.ts +24 -0
- package/src/server/server.types.js +3 -0
- package/src/server/server.types.js.map +1 -0
- package/src/server/server.validation.d.ts +2 -0
- package/src/server/server.validation.js +192 -0
- package/src/server/server.validation.js.map +1 -0
- package/src/store/adapters/store.base.adapter.d.ts +21 -0
- package/src/store/adapters/store.base.adapter.js +16 -0
- package/src/store/adapters/store.base.adapter.js.map +1 -0
- package/src/store/adapters/store.memory.adapter.d.ts +26 -0
- package/src/store/adapters/store.memory.adapter.js +87 -0
- package/src/store/adapters/store.memory.adapter.js.map +1 -0
- package/src/store/adapters/store.redis.adapter.d.ts +33 -0
- package/src/store/adapters/store.redis.adapter.js +104 -0
- package/src/store/adapters/store.redis.adapter.js.map +1 -0
- package/src/store/index.d.ts +8 -0
- package/src/store/index.js +12 -0
- package/src/store/index.js.map +1 -0
- package/src/store/store.helpers.d.ts +9 -0
- package/src/store/store.helpers.js +67 -0
- package/src/store/store.helpers.js.map +1 -0
- package/src/store/store.registry.d.ts +13 -0
- package/src/store/store.registry.js +37 -0
- package/src/store/store.registry.js.map +1 -0
- package/src/store/store.tokens.d.ts +3 -0
- package/src/store/store.tokens.js +7 -0
- package/src/store/store.tokens.js.map +1 -0
- package/src/store/store.types.d.ts +64 -0
- package/src/store/store.types.js +11 -0
- package/src/store/store.types.js.map +1 -0
- package/src/store/store.utils.d.ts +8 -0
- package/src/store/store.utils.js +18 -0
- package/src/store/store.utils.js.map +1 -0
- package/src/tool/flows/call-tool.flow.d.ts +875 -0
- package/src/tool/flows/call-tool.flow.js +249 -0
- package/src/tool/flows/call-tool.flow.js.map +1 -0
- package/src/tool/flows/tools-list.flow.d.ts +771 -0
- package/src/tool/flows/tools-list.flow.js +149 -0
- package/src/tool/flows/tools-list.flow.js.map +1 -0
- package/src/tool/tool.events.d.ts +17 -0
- package/src/tool/tool.events.js +16 -0
- package/src/tool/tool.events.js.map +1 -0
- package/src/tool/tool.instance.d.ts +15 -0
- package/src/tool/tool.instance.js +68 -0
- package/src/tool/tool.instance.js.map +1 -0
- package/src/tool/tool.registry.d.ts +72 -0
- package/src/tool/tool.registry.js +339 -0
- package/src/tool/tool.registry.js.map +1 -0
- package/src/tool/tool.types.d.ts +25 -0
- package/src/tool/tool.types.js +10 -0
- package/src/tool/tool.types.js.map +1 -0
- package/src/tool/tool.utils.d.ts +20 -0
- package/src/tool/tool.utils.js +157 -0
- package/src/tool/tool.utils.js.map +1 -0
- package/src/transport/adapters/transport.local.adapter.d.ts +41 -0
- package/src/transport/adapters/transport.local.adapter.js +127 -0
- package/src/transport/adapters/transport.local.adapter.js.map +1 -0
- package/src/transport/adapters/transport.sse.adapter.d.ts +14 -0
- package/src/transport/adapters/transport.sse.adapter.js +63 -0
- package/src/transport/adapters/transport.sse.adapter.js.map +1 -0
- package/src/transport/adapters/transport.streamable-http.adapter.d.ts +13 -0
- package/src/transport/adapters/transport.streamable-http.adapter.js +65 -0
- package/src/transport/adapters/transport.streamable-http.adapter.js.map +1 -0
- package/src/transport/flows/handle.sse.flow.d.ts +92 -0
- package/src/transport/flows/handle.sse.flow.js +129 -0
- package/src/transport/flows/handle.sse.flow.js.map +1 -0
- package/src/transport/flows/handle.streamable-http.flow.d.ts +93 -0
- package/src/transport/flows/handle.streamable-http.flow.js +125 -0
- package/src/transport/flows/handle.streamable-http.flow.js.map +1 -0
- package/src/transport/legacy/legacy.sse.tranporter.d.ts +75 -0
- package/src/transport/legacy/legacy.sse.tranporter.js +170 -0
- package/src/transport/legacy/legacy.sse.tranporter.js.map +1 -0
- package/src/transport/mcp-handlers/Initialized-notification.hanlder.d.ts +3 -0
- package/src/transport/mcp-handlers/Initialized-notification.hanlder.js +14 -0
- package/src/transport/mcp-handlers/Initialized-notification.hanlder.js.map +1 -0
- package/src/transport/mcp-handlers/call-tool-request.handler.d.ts +3 -0
- package/src/transport/mcp-handlers/call-tool-request.handler.js +15 -0
- package/src/transport/mcp-handlers/call-tool-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/index.d.ts +521 -0
- package/src/transport/mcp-handlers/index.js +20 -0
- package/src/transport/mcp-handlers/index.js.map +1 -0
- package/src/transport/mcp-handlers/initialize-request.handler.d.ts +3 -0
- package/src/transport/mcp-handlers/initialize-request.handler.js +33 -0
- package/src/transport/mcp-handlers/initialize-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/list-tools-request.handler.d.ts +285 -0
- package/src/transport/mcp-handlers/list-tools-request.handler.js +11 -0
- package/src/transport/mcp-handlers/list-tools-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/mcp-handlers.types.d.ts +37 -0
- package/src/transport/mcp-handlers/mcp-handlers.types.js +3 -0
- package/src/transport/mcp-handlers/mcp-handlers.types.js.map +1 -0
- package/src/transport/transport.error.d.ts +4 -0
- package/src/transport/transport.error.js +25 -0
- package/src/transport/transport.error.js.map +1 -0
- package/src/transport/transport.event-store.d.ts +10 -0
- package/src/transport/transport.event-store.js +36 -0
- package/src/transport/transport.event-store.js.map +1 -0
- package/src/transport/transport.local.d.ts +17 -0
- package/src/transport/transport.local.js +65 -0
- package/src/transport/transport.local.js.map +1 -0
- package/src/transport/transport.registry.d.ts +23 -0
- package/src/transport/transport.registry.js +138 -0
- package/src/transport/transport.registry.js.map +1 -0
- package/src/transport/transport.remote.d.ts +15 -0
- package/src/transport/transport.remote.js +31 -0
- package/src/transport/transport.remote.js.map +1 -0
- package/src/transport/transport.types.d.ts +54 -0
- package/src/transport/transport.types.js +3 -0
- package/src/transport/transport.types.js.map +1 -0
- package/src/types/drinen-hooks.types.d.ts +20 -0
- package/src/types/drinen-hooks.types.js +3 -0
- package/src/types/drinen-hooks.types.js.map +1 -0
- package/src/types/invoke.type.d.ts +15 -0
- package/src/types/invoke.type.js +34 -0
- package/src/types/invoke.type.js.map +1 -0
- package/src/types/token.types.d.ts +1 -0
- package/src/types/token.types.js +3 -0
- package/src/types/token.types.js.map +1 -0
- package/src/utils/metadata.utils.d.ts +5 -0
- package/src/utils/metadata.utils.js +26 -0
- package/src/utils/metadata.utils.js.map +1 -0
- package/src/utils/server.utils.d.ts +19 -0
- package/src/utils/server.utils.js +59 -0
- package/src/utils/server.utils.js.map +1 -0
- package/src/utils/string.utils.d.ts +1 -0
- package/src/utils/string.utils.js +10 -0
- package/src/utils/string.utils.js.map +1 -0
- package/src/utils/token.utils.d.ts +11 -0
- package/src/utils/token.utils.js +65 -0
- package/src/utils/token.utils.js.map +1 -0
- package/src/utils/types.utils.d.ts +7 -0
- package/src/utils/types.utils.js +3 -0
- package/src/utils/types.utils.js.map +1 -0
- package/src/constants.d.ts +0 -30
- package/src/constants.js +0 -36
- package/src/constants.js.map +0 -1
- package/src/decorators/adapter.decorator.js.map +0 -1
- package/src/decorators/app.decorator.js.map +0 -1
- package/src/decorators/auth-provider.decorator.js.map +0 -1
- package/src/decorators/flow.decorator.js.map +0 -1
- package/src/decorators/front-mcp.decorator.js +0 -40
- package/src/decorators/front-mcp.decorator.js.map +0 -1
- package/src/decorators/hook.decorator.js.map +0 -1
- package/src/decorators/index.js.map +0 -1
- package/src/decorators/logger.decorator.js.map +0 -1
- package/src/decorators/plugin.decorator.js.map +0 -1
- package/src/decorators/prompt.decorator.js.map +0 -1
- package/src/decorators/provider.decorator.js.map +0 -1
- package/src/decorators/resource.decorator.js.map +0 -1
- package/src/decorators/tool.decorator.d.ts +0 -42
- package/src/decorators/tool.decorator.js +0 -45
- package/src/decorators/tool.decorator.js.map +0 -1
- package/src/decorators-old/async-with.decorator.d.ts +0 -9
- package/src/decorators-old/async-with.decorator.js +0 -23
- package/src/decorators-old/async-with.decorator.js.map +0 -1
- package/src/decorators-old/auth-hook.decorator.js.map +0 -1
- package/src/decorators-old/session-hook.decorator.js.map +0 -1
- package/src/decorators-old/tool-hook.decorator.d.ts +0 -14
- package/src/decorators-old/tool-hook.decorator.js +0 -27
- package/src/decorators-old/tool-hook.decorator.js.map +0 -1
- package/src/dynamic/dynamic.adapter.js.map +0 -1
- package/src/dynamic/dynamic.plugin.js.map +0 -1
- package/src/dynamic/dynamic.utils.d.ts +0 -3
- package/src/dynamic/dynamic.utils.js.map +0 -1
- package/src/dynamic/index.js.map +0 -1
- package/src/entries/adapter.entry.js.map +0 -1
- package/src/entries/app.entry.d.ts +0 -13
- package/src/entries/app.entry.js.map +0 -1
- package/src/entries/auth-provider.entry.js.map +0 -1
- package/src/entries/base.entry.js.map +0 -1
- package/src/entries/flow.entry.js.map +0 -1
- package/src/entries/hook.entry.js.map +0 -1
- package/src/entries/index.js.map +0 -1
- package/src/entries/logger.entry.js.map +0 -1
- package/src/entries/plugin.entry.js.map +0 -1
- package/src/entries/prompt.entry.js.map +0 -1
- package/src/entries/provider.entry.js.map +0 -1
- package/src/entries/resource.entry.js.map +0 -1
- package/src/entries/scope.entry.js.map +0 -1
- package/src/entries/tool.entry.js.map +0 -1
- package/src/interfaces/adapter.interface.js.map +0 -1
- package/src/interfaces/app.interface.js.map +0 -1
- package/src/interfaces/auth-hook.interface.js.map +0 -1
- package/src/interfaces/auth-provider.interface.js.map +0 -1
- package/src/interfaces/base.interface.js.map +0 -1
- package/src/interfaces/flow.interface.d.ts +0 -41
- package/src/interfaces/flow.interface.js.map +0 -1
- package/src/interfaces/front-mcp.interface.js.map +0 -1
- package/src/interfaces/hook.interface.js.map +0 -1
- package/src/interfaces/index.js.map +0 -1
- package/src/interfaces/internal/flow.utils.d.ts +0 -24
- package/src/interfaces/internal/flow.utils.js.map +0 -1
- package/src/interfaces/internal/index.js.map +0 -1
- package/src/interfaces/internal/primary-auth-provider.interface.d.ts +0 -24
- package/src/interfaces/internal/primary-auth-provider.interface.js.map +0 -1
- package/src/interfaces/internal/registry.interface.d.ts +0 -97
- package/src/interfaces/internal/registry.interface.js.map +0 -1
- package/src/interfaces/logger.interface.js.map +0 -1
- package/src/interfaces/plugin.interface.js.map +0 -1
- package/src/interfaces/prompt.interface.js.map +0 -1
- package/src/interfaces/provider.interface.js.map +0 -1
- package/src/interfaces/resource.interface.js.map +0 -1
- package/src/interfaces/scope.interface.js.map +0 -1
- package/src/interfaces/server.interface.js.map +0 -1
- package/src/interfaces/session-hook.interface.js.map +0 -1
- package/src/interfaces/tool-hook.interface.js.map +0 -1
- package/src/interfaces/tool.interface.js.map +0 -1
- package/src/metadata/adapter.metadata.js.map +0 -1
- package/src/metadata/app.metadata.d.ts +0 -872
- package/src/metadata/app.metadata.js.map +0 -1
- package/src/metadata/auth-provider.metadata.js.map +0 -1
- package/src/metadata/flow.metadata.d.ts +0 -77
- package/src/metadata/flow.metadata.js.map +0 -1
- package/src/metadata/front-mcp.metadata.d.ts +0 -1144
- package/src/metadata/front-mcp.metadata.js.map +0 -1
- package/src/metadata/hook.metadata.js.map +0 -1
- package/src/metadata/index.js.map +0 -1
- package/src/metadata/logger.metadata.js.map +0 -1
- package/src/metadata/plugin.metadata.js.map +0 -1
- package/src/metadata/prompt.metadata.js.map +0 -1
- package/src/metadata/provider.metadata.js.map +0 -1
- package/src/metadata/resource.metadata.js.map +0 -1
- package/src/metadata/tool.metadata.d.ts +0 -178
- package/src/metadata/tool.metadata.js.map +0 -1
- package/src/providers/session.provider.js.map +0 -1
- package/src/records/adapter.record.js.map +0 -1
- package/src/records/app.record.js.map +0 -1
- package/src/records/auth-provider.record.js.map +0 -1
- package/src/records/flow.record.js.map +0 -1
- package/src/records/hook.record.js.map +0 -1
- package/src/records/index.js.map +0 -1
- package/src/records/logger.record.d.ts +0 -11
- package/src/records/logger.record.js.map +0 -1
- package/src/records/plugin.record.js.map +0 -1
- package/src/records/prompt.record.js.map +0 -1
- package/src/records/provider.record.js.map +0 -1
- package/src/records/resource.record.js.map +0 -1
- package/src/records/scope.record.js.map +0 -1
- package/src/records/tool.record.js.map +0 -1
- package/src/schemas/annotated-class.schema.js.map +0 -1
- package/src/schemas/http-input.schema.js.map +0 -1
- package/src/schemas/http-output.schema.d.ts +0 -2011
- package/src/schemas/http-output.schema.js.map +0 -1
- package/src/schemas/index.js.map +0 -1
- package/src/tokens/adapter.tokens.js.map +0 -1
- package/src/tokens/app.tokens.js.map +0 -1
- package/src/tokens/auth-provider.tokens.js.map +0 -1
- package/src/tokens/base.tokens.js.map +0 -1
- package/src/tokens/flow-hook.tokens.js.map +0 -1
- package/src/tokens/flow.tokens.js.map +0 -1
- package/src/tokens/front-mcp.tokens.js.map +0 -1
- package/src/tokens/index.js.map +0 -1
- package/src/tokens/logger.tokens.js.map +0 -1
- package/src/tokens/plugin.tokens.js.map +0 -1
- package/src/tokens/prompt.tokens.js.map +0 -1
- package/src/tokens/provider.tokens.js.map +0 -1
- package/src/tokens/resource.tokens.js.map +0 -1
- package/src/tokens/server.tokens.js.map +0 -1
- package/src/tokens/tool.tokens.js.map +0 -1
- package/src/types/auth/index.js.map +0 -1
- package/src/types/auth/jwt.types.js.map +0 -1
- package/src/types/auth/session.types.d.ts +0 -263
- package/src/types/auth/session.types.js.map +0 -1
- package/src/types/common.types.js.map +0 -1
- package/src/types/index.js.map +0 -1
- package/src/types/options/auth.options.d.ts +0 -513
- package/src/types/options/auth.options.js.map +0 -1
- package/src/types/options/http.options.js.map +0 -1
- package/src/types/options/index.js.map +0 -1
- package/src/types/options/logging.options.d.ts +0 -39
- package/src/types/options/logging.options.js.map +0 -1
- package/src/types/options/server-info.options.d.ts +0 -48
- package/src/types/options/server-info.options.js.map +0 -1
- package/src/types/options/session.options.d.ts +0 -67
- package/src/types/options/session.options.js.map +0 -1
- package/src/utils/decide-request-intent.utils.d.ts +0 -79
- package/src/utils/decide-request-intent.utils.js.map +0 -1
- package/src/utils/index.js.map +0 -1
- package/src/utils/path.utils.d.ts +0 -20
- package/src/utils/path.utils.js.map +0 -1
- /package/src/{decorators → common/decorators}/adapter.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/adapter.decorator.js +0 -0
- /package/src/{decorators → common/decorators}/app.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/app.decorator.js +0 -0
- /package/src/{decorators → common/decorators}/auth-provider.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/auth-provider.decorator.js +0 -0
- /package/src/{decorators → common/decorators}/flow.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/flow.decorator.js +0 -0
- /package/src/{decorators → common/decorators}/front-mcp.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/hook.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/hook.decorator.js +0 -0
- /package/src/{decorators → common/decorators}/index.d.ts +0 -0
- /package/src/{decorators → common/decorators}/index.js +0 -0
- /package/src/{decorators → common/decorators}/logger.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/logger.decorator.js +0 -0
- /package/src/{decorators → common/decorators}/plugin.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/plugin.decorator.js +0 -0
- /package/src/{decorators → common/decorators}/prompt.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/prompt.decorator.js +0 -0
- /package/src/{decorators → common/decorators}/provider.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/provider.decorator.js +0 -0
- /package/src/{decorators → common/decorators}/resource.decorator.d.ts +0 -0
- /package/src/{decorators → common/decorators}/resource.decorator.js +0 -0
- /package/src/{decorators-old → common/decorators-old}/auth-hook.decorator.d.ts +0 -0
- /package/src/{decorators-old → common/decorators-old}/auth-hook.decorator.js +0 -0
- /package/src/{decorators-old → common/decorators-old}/session-hook.decorator.d.ts +0 -0
- /package/src/{decorators-old → common/decorators-old}/session-hook.decorator.js +0 -0
- /package/src/{dynamic → common/dynamic}/dynamic.adapter.d.ts +0 -0
- /package/src/{dynamic → common/dynamic}/dynamic.adapter.js +0 -0
- /package/src/{dynamic → common/dynamic}/dynamic.plugin.d.ts +0 -0
- /package/src/{dynamic → common/dynamic}/dynamic.plugin.js +0 -0
- /package/src/{dynamic → common/dynamic}/dynamic.utils.js +0 -0
- /package/src/{dynamic → common/dynamic}/index.d.ts +0 -0
- /package/src/{dynamic → common/dynamic}/index.js +0 -0
- /package/src/{entries → common/entries}/adapter.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/adapter.entry.js +0 -0
- /package/src/{entries → common/entries}/app.entry.js +0 -0
- /package/src/{entries → common/entries}/auth-provider.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/auth-provider.entry.js +0 -0
- /package/src/{entries → common/entries}/base.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/base.entry.js +0 -0
- /package/src/{entries → common/entries}/flow.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/flow.entry.js +0 -0
- /package/src/{entries → common/entries}/hook.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/hook.entry.js +0 -0
- /package/src/{entries → common/entries}/index.d.ts +0 -0
- /package/src/{entries → common/entries}/index.js +0 -0
- /package/src/{entries → common/entries}/logger.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/logger.entry.js +0 -0
- /package/src/{entries → common/entries}/plugin.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/plugin.entry.js +0 -0
- /package/src/{entries → common/entries}/prompt.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/prompt.entry.js +0 -0
- /package/src/{entries → common/entries}/provider.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/provider.entry.js +0 -0
- /package/src/{entries → common/entries}/resource.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/resource.entry.js +0 -0
- /package/src/{entries → common/entries}/scope.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/scope.entry.js +0 -0
- /package/src/{entries → common/entries}/tool.entry.d.ts +0 -0
- /package/src/{entries → common/entries}/tool.entry.js +0 -0
- /package/src/{interfaces → common/interfaces}/adapter.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/adapter.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/app.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/app.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/auth-hook.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/auth-hook.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/auth-provider.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/auth-provider.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/base.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/base.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/flow.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/front-mcp.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/front-mcp.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/hook.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/hook.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/index.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/index.js +0 -0
- /package/src/{interfaces → common/interfaces}/internal/flow.utils.js +0 -0
- /package/src/{interfaces → common/interfaces}/internal/index.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/internal/index.js +0 -0
- /package/src/{interfaces → common/interfaces}/internal/primary-auth-provider.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/internal/registry.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/logger.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/logger.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/plugin.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/plugin.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/prompt.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/prompt.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/provider.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/provider.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/resource.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/resource.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/scope.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/scope.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/server.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/server.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/session-hook.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/session-hook.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/tool-hook.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/tool-hook.interface.js +0 -0
- /package/src/{interfaces → common/interfaces}/tool.interface.d.ts +0 -0
- /package/src/{interfaces → common/interfaces}/tool.interface.js +0 -0
- /package/src/{metadata → common/metadata}/adapter.metadata.d.ts +0 -0
- /package/src/{metadata → common/metadata}/adapter.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/app.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/auth-provider.metadata.d.ts +0 -0
- /package/src/{metadata → common/metadata}/auth-provider.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/flow.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/front-mcp.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/hook.metadata.d.ts +0 -0
- /package/src/{metadata → common/metadata}/hook.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/index.d.ts +0 -0
- /package/src/{metadata → common/metadata}/index.js +0 -0
- /package/src/{metadata → common/metadata}/logger.metadata.d.ts +0 -0
- /package/src/{metadata → common/metadata}/logger.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/plugin.metadata.d.ts +0 -0
- /package/src/{metadata → common/metadata}/plugin.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/prompt.metadata.d.ts +0 -0
- /package/src/{metadata → common/metadata}/prompt.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/provider.metadata.d.ts +0 -0
- /package/src/{metadata → common/metadata}/provider.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/resource.metadata.d.ts +0 -0
- /package/src/{metadata → common/metadata}/resource.metadata.js +0 -0
- /package/src/{metadata → common/metadata}/tool.metadata.js +0 -0
- /package/src/{providers → common/providers}/session.provider.d.ts +0 -0
- /package/src/{providers → common/providers}/session.provider.js +0 -0
- /package/src/{records → common/records}/adapter.record.d.ts +0 -0
- /package/src/{records → common/records}/adapter.record.js +0 -0
- /package/src/{records → common/records}/app.record.d.ts +0 -0
- /package/src/{records → common/records}/app.record.js +0 -0
- /package/src/{records → common/records}/auth-provider.record.d.ts +0 -0
- /package/src/{records → common/records}/auth-provider.record.js +0 -0
- /package/src/{records → common/records}/flow.record.d.ts +0 -0
- /package/src/{records → common/records}/flow.record.js +0 -0
- /package/src/{records → common/records}/hook.record.d.ts +0 -0
- /package/src/{records → common/records}/hook.record.js +0 -0
- /package/src/{records → common/records}/index.d.ts +0 -0
- /package/src/{records → common/records}/index.js +0 -0
- /package/src/{records → common/records}/logger.record.js +0 -0
- /package/src/{records → common/records}/plugin.record.d.ts +0 -0
- /package/src/{records → common/records}/plugin.record.js +0 -0
- /package/src/{records → common/records}/prompt.record.d.ts +0 -0
- /package/src/{records → common/records}/prompt.record.js +0 -0
- /package/src/{records → common/records}/provider.record.d.ts +0 -0
- /package/src/{records → common/records}/provider.record.js +0 -0
- /package/src/{records → common/records}/resource.record.d.ts +0 -0
- /package/src/{records → common/records}/resource.record.js +0 -0
- /package/src/{records → common/records}/scope.record.d.ts +0 -0
- /package/src/{records → common/records}/scope.record.js +0 -0
- /package/src/{records → common/records}/tool.record.d.ts +0 -0
- /package/src/{records → common/records}/tool.record.js +0 -0
- /package/src/{schemas → common/schemas}/annotated-class.schema.d.ts +0 -0
- /package/src/{schemas → common/schemas}/annotated-class.schema.js +0 -0
- /package/src/{schemas → common/schemas}/http-input.schema.d.ts +0 -0
- /package/src/{schemas → common/schemas}/http-input.schema.js +0 -0
- /package/src/{schemas → common/schemas}/http-output.schema.js +0 -0
- /package/src/{schemas → common/schemas}/index.d.ts +0 -0
- /package/src/{schemas → common/schemas}/index.js +0 -0
- /package/src/{tokens → common/tokens}/adapter.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/adapter.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/app.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/app.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/auth-provider.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/auth-provider.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/base.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/base.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/flow-hook.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/flow-hook.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/flow.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/flow.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/front-mcp.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/front-mcp.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/index.d.ts +0 -0
- /package/src/{tokens → common/tokens}/index.js +0 -0
- /package/src/{tokens → common/tokens}/logger.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/logger.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/plugin.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/plugin.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/prompt.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/prompt.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/provider.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/provider.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/resource.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/resource.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/server.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/server.tokens.js +0 -0
- /package/src/{tokens → common/tokens}/tool.tokens.d.ts +0 -0
- /package/src/{tokens → common/tokens}/tool.tokens.js +0 -0
- /package/src/{types → common/types}/auth/index.d.ts +0 -0
- /package/src/{types → common/types}/auth/index.js +0 -0
- /package/src/{types → common/types}/auth/jwt.types.d.ts +0 -0
- /package/src/{types → common/types}/auth/jwt.types.js +0 -0
- /package/src/{types → common/types}/auth/session.types.js +0 -0
- /package/src/{types → common/types}/common.types.d.ts +0 -0
- /package/src/{types → common/types}/common.types.js +0 -0
- /package/src/{types → common/types}/index.d.ts +0 -0
- /package/src/{types → common/types}/index.js +0 -0
- /package/src/{types → common/types}/options/auth.options.js +0 -0
- /package/src/{types → common/types}/options/http.options.d.ts +0 -0
- /package/src/{types → common/types}/options/http.options.js +0 -0
- /package/src/{types → common/types}/options/index.d.ts +0 -0
- /package/src/{types → common/types}/options/index.js +0 -0
- /package/src/{types → common/types}/options/logging.options.js +0 -0
- /package/src/{types → common/types}/options/server-info.options.js +0 -0
- /package/src/{types → common/types}/options/session.options.js +0 -0
- /package/src/{utils → common/utils}/decide-request-intent.utils.js +0 -0
- /package/src/{utils → common/utils}/index.d.ts +0 -0
- /package/src/{utils → common/utils}/index.js +0 -0
- /package/src/{utils → common/utils}/path.utils.js +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { JSONWebKeySet } from 'jose';
|
|
3
|
+
import { JwksServiceOptions, ProviderVerifyRef, VerifyResult } from './jwks.types';
|
|
4
|
+
export declare class JwksService {
|
|
5
|
+
private readonly opts;
|
|
6
|
+
private orchestratorKey;
|
|
7
|
+
private providerJwks;
|
|
8
|
+
constructor(opts?: JwksServiceOptions);
|
|
9
|
+
/** Gateway's public JWKS (publish at /.well-known/jwks.json when orchestrated). */
|
|
10
|
+
getPublicJwks(): JSONWebKeySet;
|
|
11
|
+
/** Verify a token issued by the gateway itself (orchestrated mode). */
|
|
12
|
+
verifyGatewayToken(token: string, expectedIssuer: string): Promise<VerifyResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Verify a token against candidate transparent providers.
|
|
15
|
+
* Ensures JWKS are available (cached/TTL/AS discovery) per provider.
|
|
16
|
+
*/
|
|
17
|
+
verifyTransparentToken(token: string, candidates: ProviderVerifyRef[]): Promise<VerifyResult>;
|
|
18
|
+
/** Directly set provider JWKS (e.g., inline keys from config). */
|
|
19
|
+
setProviderJwks(providerId: string, jwks: JSONWebKeySet): void;
|
|
20
|
+
/**
|
|
21
|
+
* Ensure JWKS for a provider:
|
|
22
|
+
* 1) inline jwks (if provided) → cache & return
|
|
23
|
+
* 2) cached & fresh (TTL) → return
|
|
24
|
+
* 3) explicit jwksUri → fetch, cache, return
|
|
25
|
+
* 4) discover jwks_uri via AS → fetch AS metadata, then jwks_uri, cache, return
|
|
26
|
+
*/
|
|
27
|
+
getJwksForProvider(ref: ProviderVerifyRef): Promise<JSONWebKeySet | undefined>;
|
|
28
|
+
/** Return the orchestrator public JWKS (generates/rotates as needed). */
|
|
29
|
+
getOrchestratorJwks(): JSONWebKeySet;
|
|
30
|
+
/** Return private signing key + kid for issuing orchestrator tokens. */
|
|
31
|
+
getOrchestratorSigningKey(): {
|
|
32
|
+
kid: string;
|
|
33
|
+
key: crypto.KeyObject;
|
|
34
|
+
alg: string;
|
|
35
|
+
};
|
|
36
|
+
private tryFetchJwks;
|
|
37
|
+
private tryFetchAsMeta;
|
|
38
|
+
private fetchJson;
|
|
39
|
+
private ensureOrchestratorKey;
|
|
40
|
+
private generateKey;
|
|
41
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JwksService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// auth/jwks/jwks.service.ts
|
|
6
|
+
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
|
|
7
|
+
const jose_1 = require("jose");
|
|
8
|
+
const jwks_utils_1 = require("./jwks.utils");
|
|
9
|
+
class JwksService {
|
|
10
|
+
opts;
|
|
11
|
+
// Orchestrator signing material
|
|
12
|
+
orchestratorKey;
|
|
13
|
+
// Provider JWKS cache (providerId -> jwks + fetchedAt)
|
|
14
|
+
providerJwks = new Map();
|
|
15
|
+
constructor(opts) {
|
|
16
|
+
this.opts = {
|
|
17
|
+
orchestratorAlg: opts?.orchestratorAlg ?? 'RS256',
|
|
18
|
+
rotateDays: opts?.rotateDays ?? 30,
|
|
19
|
+
providerJwksTtlMs: opts?.providerJwksTtlMs ?? 6 * 60 * 60 * 1000, // 6h
|
|
20
|
+
networkTimeoutMs: opts?.networkTimeoutMs ?? 5000, // 5s
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// ===========================================================================
|
|
24
|
+
// Public JWKS (what /.well-known/jwks.json serves)
|
|
25
|
+
// ===========================================================================
|
|
26
|
+
/** Gateway's public JWKS (publish at /.well-known/jwks.json when orchestrated). */
|
|
27
|
+
getPublicJwks() {
|
|
28
|
+
return this.getOrchestratorJwks();
|
|
29
|
+
}
|
|
30
|
+
// ===========================================================================
|
|
31
|
+
// Scope-aware verification API
|
|
32
|
+
// ===========================================================================
|
|
33
|
+
/** Verify a token issued by the gateway itself (orchestrated mode). */
|
|
34
|
+
async verifyGatewayToken(token, expectedIssuer) {
|
|
35
|
+
try {
|
|
36
|
+
// TODO: add support for local/remote proxy mode
|
|
37
|
+
// current implementation for anonymous mode only
|
|
38
|
+
// const jwks = this.getPublicJwks();
|
|
39
|
+
// const JWKS = createLocalJWKSet(jwks);
|
|
40
|
+
// const {payload, protectedHeader} = await jwtVerify(token, JWKS, {
|
|
41
|
+
// issuer: normalizeIssuer(expectedIssuer),
|
|
42
|
+
// });
|
|
43
|
+
// return {
|
|
44
|
+
// ok: true,
|
|
45
|
+
// issuer: payload?.iss as string | undefined,
|
|
46
|
+
// sub: payload?.sub as string | undefined,
|
|
47
|
+
// header: protectedHeader,
|
|
48
|
+
// payload,
|
|
49
|
+
// };
|
|
50
|
+
const payload = (0, jwks_utils_1.decodeJwtPayloadSafe)(token);
|
|
51
|
+
if (!payload) {
|
|
52
|
+
return {
|
|
53
|
+
ok: false,
|
|
54
|
+
error: 'invalid bearer token'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
ok: true,
|
|
59
|
+
issuer: expectedIssuer,
|
|
60
|
+
sub: payload['sub'],
|
|
61
|
+
payload,
|
|
62
|
+
header: (0, jose_1.decodeProtectedHeader)(token),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
return { ok: false, error: err?.message ?? 'verification_failed' };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Verify a token against candidate transparent providers.
|
|
71
|
+
* Ensures JWKS are available (cached/TTL/AS discovery) per provider.
|
|
72
|
+
*/
|
|
73
|
+
async verifyTransparentToken(token, candidates) {
|
|
74
|
+
if (!candidates?.length)
|
|
75
|
+
return { ok: false, error: 'no_providers' };
|
|
76
|
+
// Helpful only for error messages
|
|
77
|
+
let kid;
|
|
78
|
+
try {
|
|
79
|
+
const header = (0, jose_1.decodeProtectedHeader)(token);
|
|
80
|
+
kid = typeof header?.kid === 'string' ? header.kid : undefined;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
/* empty */
|
|
84
|
+
}
|
|
85
|
+
for (const p of candidates) {
|
|
86
|
+
try {
|
|
87
|
+
const jwks = await this.getJwksForProvider(p);
|
|
88
|
+
if (!jwks?.keys?.length)
|
|
89
|
+
continue;
|
|
90
|
+
const draftPayload = (0, jwks_utils_1.decodeJwtPayloadSafe)(token);
|
|
91
|
+
const JWKS = (0, jose_1.createLocalJWKSet)(jwks);
|
|
92
|
+
const { payload, protectedHeader } = await (0, jose_1.jwtVerify)(token, JWKS, {
|
|
93
|
+
issuer: [
|
|
94
|
+
(0, jwks_utils_1.normalizeIssuer)(p.issuerUrl),
|
|
95
|
+
// ]
|
|
96
|
+
].concat((draftPayload?.['iss'] ? [draftPayload['iss']] : [])), // used because current cloud gateway have invalid issuer
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
ok: true,
|
|
100
|
+
issuer: payload?.iss,
|
|
101
|
+
sub: payload?.sub,
|
|
102
|
+
providerId: p.id,
|
|
103
|
+
header: protectedHeader,
|
|
104
|
+
payload,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
console.log('failed to verify token for provider: ', p.id, e);
|
|
109
|
+
// try next provider
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { ok: false, error: `no_provider_verified${kid ? ` (kid=${kid})` : ''}` };
|
|
113
|
+
}
|
|
114
|
+
// ===========================================================================
|
|
115
|
+
// Provider JWKS (cache + preload + discovery)
|
|
116
|
+
// ===========================================================================
|
|
117
|
+
/** Directly set provider JWKS (e.g., inline keys from config). */
|
|
118
|
+
setProviderJwks(providerId, jwks) {
|
|
119
|
+
this.providerJwks.set(providerId, { jwks, fetchedAt: Date.now() });
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Ensure JWKS for a provider:
|
|
123
|
+
* 1) inline jwks (if provided) → cache & return
|
|
124
|
+
* 2) cached & fresh (TTL) → return
|
|
125
|
+
* 3) explicit jwksUri → fetch, cache, return
|
|
126
|
+
* 4) discover jwks_uri via AS → fetch AS metadata, then jwks_uri, cache, return
|
|
127
|
+
*/
|
|
128
|
+
async getJwksForProvider(ref) {
|
|
129
|
+
// Inline keys win
|
|
130
|
+
if (ref.jwks?.keys?.length) {
|
|
131
|
+
this.setProviderJwks(ref.id, ref.jwks);
|
|
132
|
+
return ref.jwks;
|
|
133
|
+
}
|
|
134
|
+
// Cache hit and fresh?
|
|
135
|
+
const cached = this.providerJwks.get(ref.id);
|
|
136
|
+
if (cached && Date.now() - cached.fetchedAt < this.opts.providerJwksTtlMs) {
|
|
137
|
+
return cached.jwks;
|
|
138
|
+
}
|
|
139
|
+
// If we have a jwksUri, try it
|
|
140
|
+
if (ref.jwksUri) {
|
|
141
|
+
const fromUri = await this.tryFetchJwks(ref.id, ref.jwksUri);
|
|
142
|
+
if (fromUri?.keys?.length)
|
|
143
|
+
return fromUri;
|
|
144
|
+
}
|
|
145
|
+
// Discover via AS .well-known
|
|
146
|
+
const issuer = (0, jwks_utils_1.trimSlash)(ref.issuerUrl);
|
|
147
|
+
const meta = await this.tryFetchAsMeta(`${issuer}/.well-known/oauth-authorization-server`);
|
|
148
|
+
const uri = meta && typeof meta === 'object' && meta.jwks_uri ? String(meta.jwks_uri) : undefined;
|
|
149
|
+
if (uri) {
|
|
150
|
+
const fromMeta = await this.tryFetchJwks(ref.id, uri);
|
|
151
|
+
if (fromMeta?.keys?.length)
|
|
152
|
+
return fromMeta;
|
|
153
|
+
}
|
|
154
|
+
return cached?.jwks; // return stale if we had anything, else undefined
|
|
155
|
+
}
|
|
156
|
+
// ===========================================================================
|
|
157
|
+
// Orchestrator keys (generation/rotation)
|
|
158
|
+
// ===========================================================================
|
|
159
|
+
/** Return the orchestrator public JWKS (generates/rotates as needed). */
|
|
160
|
+
getOrchestratorJwks() {
|
|
161
|
+
this.ensureOrchestratorKey();
|
|
162
|
+
return this.orchestratorKey.publicJwk;
|
|
163
|
+
}
|
|
164
|
+
/** Return private signing key + kid for issuing orchestrator tokens. */
|
|
165
|
+
getOrchestratorSigningKey() {
|
|
166
|
+
this.ensureOrchestratorKey();
|
|
167
|
+
return { kid: this.orchestratorKey.kid, key: this.orchestratorKey.privateKey, alg: this.opts.orchestratorAlg };
|
|
168
|
+
}
|
|
169
|
+
// ===========================================================================
|
|
170
|
+
// Internals (fetch, rotation, helpers)
|
|
171
|
+
// ===========================================================================
|
|
172
|
+
async tryFetchJwks(providerId, uri) {
|
|
173
|
+
try {
|
|
174
|
+
const jwks = await this.fetchJson(uri);
|
|
175
|
+
if (jwks?.keys?.length) {
|
|
176
|
+
this.setProviderJwks(providerId, jwks);
|
|
177
|
+
return jwks;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
/* empty */
|
|
182
|
+
}
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
async tryFetchAsMeta(url) {
|
|
186
|
+
try {
|
|
187
|
+
return await this.fetchJson(url);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async fetchJson(url) {
|
|
194
|
+
const ctl = typeof AbortController !== 'undefined' ? new AbortController() : undefined;
|
|
195
|
+
const timer = setTimeout(() => ctl?.abort(), this.opts.networkTimeoutMs);
|
|
196
|
+
try {
|
|
197
|
+
const res = await fetch(url, {
|
|
198
|
+
method: 'GET',
|
|
199
|
+
headers: { accept: 'application/json' },
|
|
200
|
+
signal: ctl?.signal,
|
|
201
|
+
});
|
|
202
|
+
if (!res.ok)
|
|
203
|
+
throw new Error(`HTTP ${res.status}`);
|
|
204
|
+
return (await res.json());
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
clearTimeout(timer);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
ensureOrchestratorKey() {
|
|
211
|
+
const now = Date.now();
|
|
212
|
+
const maxAge = this.opts.rotateDays * 24 * 60 * 60 * 1000;
|
|
213
|
+
if (!this.orchestratorKey || now - this.orchestratorKey.createdAt > maxAge) {
|
|
214
|
+
this.orchestratorKey = this.generateKey(this.opts.orchestratorAlg);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
generateKey(alg) {
|
|
218
|
+
if (alg === 'RS256') {
|
|
219
|
+
const { privateKey, publicKey } = node_crypto_1.default.generateKeyPairSync('rsa', { modulusLength: 2048 });
|
|
220
|
+
const kid = node_crypto_1.default.randomBytes(8).toString('hex');
|
|
221
|
+
const publicJwk = publicKey.export({ format: 'jwk' });
|
|
222
|
+
Object.assign(publicJwk, { kid, alg: 'RS256', use: 'sig', kty: 'RSA' });
|
|
223
|
+
return { kid, privateKey, publicJwk: { keys: [publicJwk] }, createdAt: Date.now() };
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
const { privateKey, publicKey } = node_crypto_1.default.generateKeyPairSync('ec', { namedCurve: 'P-256' });
|
|
227
|
+
const kid = node_crypto_1.default.randomBytes(8).toString('hex');
|
|
228
|
+
const publicJwk = publicKey.export({ format: 'jwk' });
|
|
229
|
+
Object.assign(publicJwk, { kid, alg: 'ES256', use: 'sig', kty: 'EC' });
|
|
230
|
+
return { kid, privateKey, publicJwk: { keys: [publicJwk] }, createdAt: Date.now() };
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
exports.JwksService = JwksService;
|
|
235
|
+
//# sourceMappingURL=jwks.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwks.service.js","sourceRoot":"","sources":["../../../../src/auth/jwks/jwks.service.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,sEAAiC;AACjC,+BAAwF;AAExF,6CAA8E;AAE9E,MAAa,WAAW;IACL,IAAI,CAA+B;IAEpD,gCAAgC;IACxB,eAAe,CAKrB;IAEF,uDAAuD;IAC/C,YAAY,GAAG,IAAI,GAAG,EAAsD,CAAC;IAErF,YAAY,IAAyB;QACnC,IAAI,CAAC,IAAI,GAAG;YACV,eAAe,EAAE,IAAI,EAAE,eAAe,IAAI,OAAO;YACjD,UAAU,EAAE,IAAI,EAAE,UAAU,IAAI,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M,CAAC;YACN,MAAM,EAAC,UAAU,EAAE,SAAS,EAAC,GAAG,qBAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,EAAC,UAAU,EAAE,OAAO,EAAC,CAAC,CAAC;YACxF,MAAM,GAAG,GAAG,qBAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClD,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;YACpD,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,EAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAC,CAAC,CAAC;YACrE,OAAO,EAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,EAAC,IAAI,EAAE,CAAC,SAAS,CAAC,EAAC,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAC,CAAC;QAClF,CAAC;IACH,CAAC;CACF;AAzPD,kCAyPC","sourcesContent":["// auth/jwks/jwks.service.ts\nimport crypto from 'node:crypto';\nimport {jwtVerify, createLocalJWKSet, decodeProtectedHeader, JSONWebKeySet} from 'jose';\nimport {JwksServiceOptions, ProviderVerifyRef, VerifyResult} from './jwks.types';\nimport {normalizeIssuer, trimSlash, decodeJwtPayloadSafe} from './jwks.utils';\n\nexport class JwksService {\n private readonly opts: Required<JwksServiceOptions>;\n\n // Orchestrator signing material\n private orchestratorKey!: {\n kid: string;\n privateKey: crypto.KeyObject;\n publicJwk: JSONWebKeySet;\n createdAt: number;\n };\n\n // Provider JWKS cache (providerId -> jwks + fetchedAt)\n private providerJwks = new Map<string, { jwks: JSONWebKeySet; fetchedAt: number }>();\n\n constructor(opts?: JwksServiceOptions) {\n this.opts = {\n orchestratorAlg: opts?.orchestratorAlg ?? 'RS256',\n rotateDays: opts?.rotateDays ?? 30,\n providerJwksTtlMs: opts?.providerJwksTtlMs ?? 6 * 60 * 60 * 1000, // 6h\n networkTimeoutMs: opts?.networkTimeoutMs ?? 5000, // 5s\n };\n }\n\n // ===========================================================================\n // Public JWKS (what /.well-known/jwks.json serves)\n // ===========================================================================\n\n /** Gateway's public JWKS (publish at /.well-known/jwks.json when orchestrated). */\n getPublicJwks(): JSONWebKeySet {\n return this.getOrchestratorJwks();\n }\n\n // ===========================================================================\n // Scope-aware verification API\n // ===========================================================================\n\n /** Verify a token issued by the gateway itself (orchestrated mode). */\n async verifyGatewayToken(token: string, expectedIssuer: string): Promise<VerifyResult> {\n try {\n // TODO: add support for local/remote proxy mode\n // current implementation for anonymous mode only\n\n // const jwks = this.getPublicJwks();\n // const JWKS = createLocalJWKSet(jwks);\n // const {payload, protectedHeader} = await jwtVerify(token, JWKS, {\n // issuer: normalizeIssuer(expectedIssuer),\n // });\n // return {\n // ok: true,\n // issuer: payload?.iss as string | undefined,\n // sub: payload?.sub as string | undefined,\n // header: protectedHeader,\n // payload,\n // };\n\n const payload = decodeJwtPayloadSafe(token);\n if (!payload) {\n return {\n ok: false,\n error: 'invalid bearer token'\n }\n }\n return {\n ok: true,\n issuer: expectedIssuer,\n sub: payload['sub'] as string,\n payload,\n header: decodeProtectedHeader(token),\n }\n } catch (err: any) {\n return {ok: false, error: err?.message ?? 'verification_failed'};\n }\n }\n\n /**\n * Verify a token against candidate transparent providers.\n * Ensures JWKS are available (cached/TTL/AS discovery) per provider.\n */\n async verifyTransparentToken(token: string, candidates: ProviderVerifyRef[]): Promise<VerifyResult> {\n if (!candidates?.length) return {ok: false, error: 'no_providers'};\n\n // Helpful only for error messages\n let kid: string | undefined;\n try {\n const header = decodeProtectedHeader(token);\n\n kid = typeof header?.kid === 'string' ? header.kid : undefined;\n } catch {\n /* empty */\n }\n\n for (const p of candidates) {\n try {\n const jwks = await this.getJwksForProvider(p);\n if (!jwks?.keys?.length) continue;\n const draftPayload = decodeJwtPayloadSafe(token);\n const JWKS = createLocalJWKSet(jwks);\n const {payload, protectedHeader} = await jwtVerify(token, JWKS, {\n issuer: [\n normalizeIssuer(p.issuerUrl),\n\n // ]\n ].concat((draftPayload?.['iss'] ? [draftPayload['iss']] : []) as string[]), // used because current cloud gateway have invalid issuer\n });\n\n return {\n ok: true,\n issuer: payload?.iss as string | undefined,\n sub: payload?.sub as string | undefined,\n providerId: p.id,\n header: protectedHeader,\n payload,\n };\n } catch (e) {\n console.log('failed to verify token for provider: ', p.id, e);\n // try next provider\n }\n }\n\n return {ok: false, error: `no_provider_verified${kid ? ` (kid=${kid})` : ''}`};\n }\n\n // ===========================================================================\n // Provider JWKS (cache + preload + discovery)\n // ===========================================================================\n\n /** Directly set provider JWKS (e.g., inline keys from config). */\n setProviderJwks(providerId: string, jwks: JSONWebKeySet) {\n this.providerJwks.set(providerId, {jwks, fetchedAt: Date.now()});\n }\n\n /**\n * Ensure JWKS for a provider:\n * 1) inline jwks (if provided) → cache & return\n * 2) cached & fresh (TTL) → return\n * 3) explicit jwksUri → fetch, cache, return\n * 4) discover jwks_uri via AS → fetch AS metadata, then jwks_uri, cache, return\n */\n async getJwksForProvider(ref: ProviderVerifyRef): Promise<JSONWebKeySet | undefined> {\n // Inline keys win\n if (ref.jwks?.keys?.length) {\n this.setProviderJwks(ref.id, ref.jwks);\n return ref.jwks;\n }\n\n // Cache hit and fresh?\n const cached = this.providerJwks.get(ref.id);\n if (cached && Date.now() - cached.fetchedAt < this.opts.providerJwksTtlMs) {\n return cached.jwks;\n }\n\n // If we have a jwksUri, try it\n if (ref.jwksUri) {\n const fromUri = await this.tryFetchJwks(ref.id, ref.jwksUri);\n if (fromUri?.keys?.length) return fromUri;\n }\n\n // Discover via AS .well-known\n const issuer = trimSlash(ref.issuerUrl);\n const meta = await this.tryFetchAsMeta(`${issuer}/.well-known/oauth-authorization-server`);\n const uri = meta && typeof meta === 'object' && meta.jwks_uri ? String(meta.jwks_uri) : undefined;\n if (uri) {\n const fromMeta = await this.tryFetchJwks(ref.id, uri);\n if (fromMeta?.keys?.length) return fromMeta;\n }\n\n return cached?.jwks; // return stale if we had anything, else undefined\n }\n\n // ===========================================================================\n // Orchestrator keys (generation/rotation)\n // ===========================================================================\n\n /** Return the orchestrator public JWKS (generates/rotates as needed). */\n getOrchestratorJwks(): JSONWebKeySet {\n this.ensureOrchestratorKey();\n return this.orchestratorKey.publicJwk;\n }\n\n /** Return private signing key + kid for issuing orchestrator tokens. */\n getOrchestratorSigningKey(): { kid: string; key: crypto.KeyObject; alg: string } {\n this.ensureOrchestratorKey();\n return {kid: this.orchestratorKey.kid, key: this.orchestratorKey.privateKey, alg: this.opts.orchestratorAlg};\n }\n\n // ===========================================================================\n // Internals (fetch, rotation, helpers)\n // ===========================================================================\n\n private async tryFetchJwks(providerId: string, uri: string): Promise<JSONWebKeySet | undefined> {\n try {\n const jwks = await this.fetchJson<JSONWebKeySet>(uri);\n if (jwks?.keys?.length) {\n this.setProviderJwks(providerId, jwks);\n return jwks;\n }\n } catch {\n /* empty */\n }\n return undefined;\n }\n\n private async tryFetchAsMeta(url: string): Promise<any | undefined> {\n try {\n return await this.fetchJson(url);\n } catch {\n return undefined;\n }\n }\n\n private async fetchJson<T = any>(url: string): Promise<T> {\n const ctl = typeof AbortController !== 'undefined' ? new AbortController() : undefined;\n const timer = setTimeout(() => ctl?.abort(), this.opts.networkTimeoutMs);\n try {\n const res = await fetch(url, {\n method: 'GET',\n headers: {accept: 'application/json'},\n signal: ctl?.signal,\n });\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n return (await res.json()) as T;\n } finally {\n clearTimeout(timer);\n }\n }\n\n private ensureOrchestratorKey() {\n const now = Date.now();\n const maxAge = this.opts.rotateDays * 24 * 60 * 60 * 1000;\n if (!this.orchestratorKey || now - this.orchestratorKey.createdAt > maxAge) {\n this.orchestratorKey = this.generateKey(this.opts.orchestratorAlg);\n }\n }\n\n private generateKey(alg: 'RS256' | 'ES256') {\n if (alg === 'RS256') {\n const {privateKey, publicKey} = crypto.generateKeyPairSync('rsa', {modulusLength: 2048});\n const kid = crypto.randomBytes(8).toString('hex');\n const publicJwk = publicKey.export({format: 'jwk'});\n Object.assign(publicJwk, {kid, alg: 'RS256', use: 'sig', kty: 'RSA'});\n return {kid, privateKey, publicJwk: {keys: [publicJwk]}, createdAt: Date.now()};\n } else {\n const {privateKey, publicKey} = crypto.generateKeyPairSync('ec', {namedCurve: 'P-256'});\n const kid = crypto.randomBytes(8).toString('hex');\n const publicJwk = publicKey.export({format: 'jwk'});\n Object.assign(publicJwk, {kid, alg: 'ES256', use: 'sig', kty: 'EC'});\n return {kid, privateKey, publicJwk: {keys: [publicJwk]}, createdAt: Date.now()};\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { JSONWebKeySet } from 'jose';
|
|
2
|
+
export type JwksServiceOptions = {
|
|
3
|
+
orchestratorAlg?: 'RS256' | 'ES256';
|
|
4
|
+
rotateDays?: number;
|
|
5
|
+
/** TTL (ms) for cached provider JWKS before attempting refresh. Default: 6h */
|
|
6
|
+
providerJwksTtlMs?: number;
|
|
7
|
+
/** Timeout (ms) for network metadata/JWKS fetches. Default: 5s */
|
|
8
|
+
networkTimeoutMs?: number;
|
|
9
|
+
};
|
|
10
|
+
/** Rich descriptor used by verification & fetching */
|
|
11
|
+
export type ProviderVerifyRef = {
|
|
12
|
+
id: string;
|
|
13
|
+
issuerUrl: string;
|
|
14
|
+
jwksUri?: string;
|
|
15
|
+
jwks?: JSONWebKeySet;
|
|
16
|
+
};
|
|
17
|
+
export type VerifyResult = {
|
|
18
|
+
ok: boolean;
|
|
19
|
+
issuer?: string;
|
|
20
|
+
sub?: string;
|
|
21
|
+
providerId?: string;
|
|
22
|
+
header?: any;
|
|
23
|
+
payload?: any;
|
|
24
|
+
error?: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwks.types.js","sourceRoot":"","sources":["../../../../src/auth/jwks/jwks.types.ts"],"names":[],"mappings":"","sourcesContent":["import { JSONWebKeySet } from 'jose';\n\nexport type JwksServiceOptions = {\n orchestratorAlg?: 'RS256' | 'ES256';\n rotateDays?: number;\n /** TTL (ms) for cached provider JWKS before attempting refresh. Default: 6h */\n providerJwksTtlMs?: number;\n /** Timeout (ms) for network metadata/JWKS fetches. Default: 5s */\n networkTimeoutMs?: number;\n};\n\n/** Rich descriptor used by verification & fetching */\nexport type ProviderVerifyRef = {\n id: string;\n issuerUrl: string; // upstream issuer (e.g., https://idp.example.com)\n jwksUri?: string; // optional explicit JWKS uri\n jwks?: JSONWebKeySet; // optional inline keys (prioritized)\n};\n\nexport type VerifyResult = {\n ok: boolean;\n issuer?: string;\n sub?: string;\n providerId?: string;\n header?: any;\n payload?: any;\n error?: string;\n};\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function trimSlash(s: string): string;
|
|
2
|
+
export declare function normalizeIssuer(u?: string): string;
|
|
3
|
+
/** Safe, no-verify JWT payload decode (returns undefined on error). */
|
|
4
|
+
export declare function decodeJwtPayloadSafe(token?: string): Record<string, unknown> | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trimSlash = trimSlash;
|
|
4
|
+
exports.normalizeIssuer = normalizeIssuer;
|
|
5
|
+
exports.decodeJwtPayloadSafe = decodeJwtPayloadSafe;
|
|
6
|
+
function trimSlash(s) {
|
|
7
|
+
return (s ?? '').replace(/\/+$/, '');
|
|
8
|
+
}
|
|
9
|
+
function normalizeIssuer(u) {
|
|
10
|
+
return trimSlash(String(u ?? ''));
|
|
11
|
+
}
|
|
12
|
+
/** Safe, no-verify JWT payload decode (returns undefined on error). */
|
|
13
|
+
function decodeJwtPayloadSafe(token) {
|
|
14
|
+
if (!token)
|
|
15
|
+
return undefined;
|
|
16
|
+
const parts = token.split('.');
|
|
17
|
+
if (parts.length < 2)
|
|
18
|
+
return undefined;
|
|
19
|
+
try {
|
|
20
|
+
const b64 = parts[1].replace(/-/g, '+').replace(/_/g, '/');
|
|
21
|
+
const json = typeof Buffer !== 'undefined'
|
|
22
|
+
? Buffer.from(b64, 'base64').toString('utf8')
|
|
23
|
+
: // browser fallback
|
|
24
|
+
atob(b64);
|
|
25
|
+
const obj = JSON.parse(json);
|
|
26
|
+
return obj && typeof obj === 'object' ? obj : undefined;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=jwks.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwks.utils.js","sourceRoot":"","sources":["../../../../src/auth/jwks/jwks.utils.ts"],"names":[],"mappings":";;AAAA,8BAEC;AACD,0CAEC;AAGD,oDAgBC;AAxBD,SAAgB,SAAS,CAAC,CAAS;IACjC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC;AACD,SAAgB,eAAe,CAAC,CAAU;IACxC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,uEAAuE;AACvE,SAAgB,oBAAoB,CAAC,KAAc;IACjD,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACvC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC3D,MAAM,IAAI,GACR,OAAO,MAAM,KAAK,WAAW;YAC3B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC7C,CAAC,CAAC,mBAAmB;gBACrB,IAAI,CAAC,GAAG,CAAC,CAAC;QACd,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAE,GAA+B,CAAC,CAAC,CAAC,SAAS,CAAC;IACvF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["export function trimSlash(s: string) {\n return (s ?? '').replace(/\\/+$/, '');\n}\nexport function normalizeIssuer(u?: string) {\n return trimSlash(String(u ?? ''));\n}\n\n/** Safe, no-verify JWT payload decode (returns undefined on error). */\nexport function decodeJwtPayloadSafe(token?: string): Record<string, unknown> | undefined {\n if (!token) return undefined;\n const parts = token.split('.');\n if (parts.length < 2) return undefined;\n try {\n const b64 = parts[1].replace(/-/g, '+').replace(/_/g, '/');\n const json =\n typeof Buffer !== 'undefined'\n ? Buffer.from(b64, 'base64').toString('utf8')\n : // browser fallback\n atob(b64);\n const obj = JSON.parse(json);\n return obj && typeof obj === 'object' ? (obj as Record<string, unknown>) : undefined;\n } catch {\n return undefined;\n }\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Authorization Endpoint — GET /oauth/authorize
|
|
4
|
+
*
|
|
5
|
+
* Who calls: Browser via the Client (RP).
|
|
6
|
+
*
|
|
7
|
+
* When: Start of the flow.
|
|
8
|
+
*
|
|
9
|
+
* Purpose: Authenticate the user and obtain consent; returns an authorization code to the client’s redirect URI.
|
|
10
|
+
*
|
|
11
|
+
* Notes: Must support PKCE. Implicit/Hybrid are out in OAuth 2.1.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Typical parameter shapes
|
|
15
|
+
*
|
|
16
|
+
* /oauth/authorize (GET)
|
|
17
|
+
*
|
|
18
|
+
* response_type=code, client_id, redirect_uri, scope, state, code_challenge, code_challenge_method=S256, (optionally request_uri from PAR)
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Quick checklist (security & correctness)
|
|
22
|
+
* - PKCE (S256) required for public clients (and basically for all).
|
|
23
|
+
* - Use authorization code grant only (no implicit/hybrid).
|
|
24
|
+
* - Rotate refresh tokens and bind them to client + user + scopes.
|
|
25
|
+
* - Prefer private_key_jwt or mTLS for confidential clients.
|
|
26
|
+
* - PAR + JAR recommended for higher security.
|
|
27
|
+
* - Consider DPoP (proof-of-possession) to reduce token replay.
|
|
28
|
+
* - Keep codes very short-lived (e.g., ≤60 s) and single-use.
|
|
29
|
+
* - Publish discovery and JWKS, rotate keys safely.
|
|
30
|
+
* - Decide JWT vs opaque access tokens; provide introspection if opaque.
|
|
31
|
+
*/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Authorization Endpoint — GET /oauth/authorize
|
|
5
|
+
*
|
|
6
|
+
* Who calls: Browser via the Client (RP).
|
|
7
|
+
*
|
|
8
|
+
* When: Start of the flow.
|
|
9
|
+
*
|
|
10
|
+
* Purpose: Authenticate the user and obtain consent; returns an authorization code to the client’s redirect URI.
|
|
11
|
+
*
|
|
12
|
+
* Notes: Must support PKCE. Implicit/Hybrid are out in OAuth 2.1.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Typical parameter shapes
|
|
16
|
+
*
|
|
17
|
+
* /oauth/authorize (GET)
|
|
18
|
+
*
|
|
19
|
+
* response_type=code, client_id, redirect_uri, scope, state, code_challenge, code_challenge_method=S256, (optionally request_uri from PAR)
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Quick checklist (security & correctness)
|
|
23
|
+
* - PKCE (S256) required for public clients (and basically for all).
|
|
24
|
+
* - Use authorization code grant only (no implicit/hybrid).
|
|
25
|
+
* - Rotate refresh tokens and bind them to client + user + scopes.
|
|
26
|
+
* - Prefer private_key_jwt or mTLS for confidential clients.
|
|
27
|
+
* - PAR + JAR recommended for higher security.
|
|
28
|
+
* - Consider DPoP (proof-of-possession) to reduce token replay.
|
|
29
|
+
* - Keep codes very short-lived (e.g., ≤60 s) and single-use.
|
|
30
|
+
* - Publish discovery and JWKS, rotate keys safely.
|
|
31
|
+
* - Decide JWT vs opaque access tokens; provide introspection if opaque.
|
|
32
|
+
*/
|
|
33
|
+
//# sourceMappingURL=oauth.authorize.flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.authorize.flow.js","sourceRoot":"","sources":["../../../../../src/auth/oauth/flows/oauth.authorize.flow.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;GAUG;AACH;;;;;;GAMG;AACH;;;;;;;;;;;GAWG","sourcesContent":["/**\n * Authorization Endpoint — GET /oauth/authorize\n *\n * Who calls: Browser via the Client (RP).\n *\n * When: Start of the flow.\n *\n * Purpose: Authenticate the user and obtain consent; returns an authorization code to the client’s redirect URI.\n *\n * Notes: Must support PKCE. Implicit/Hybrid are out in OAuth 2.1.\n */\n/**\n * Typical parameter shapes\n *\n * /oauth/authorize (GET)\n *\n * response_type=code, client_id, redirect_uri, scope, state, code_challenge, code_challenge_method=S256, (optionally request_uri from PAR)\n */\n/**\n * Quick checklist (security & correctness)\n * - PKCE (S256) required for public clients (and basically for all).\n * - Use authorization code grant only (no implicit/hybrid).\n * - Rotate refresh tokens and bind them to client + user + scopes.\n * - Prefer private_key_jwt or mTLS for confidential clients.\n * - PAR + JAR recommended for higher security.\n * - Consider DPoP (proof-of-possession) to reduce token replay.\n * - Keep codes very short-lived (e.g., ≤60 s) and single-use.\n * - Publish discovery and JWKS, rotate keys safely.\n * - Decide JWT vs opaque access tokens; provide introspection if opaque.\n */\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Authorization — POST /oauth/device_authorization
|
|
3
|
+
*
|
|
4
|
+
* Who calls: Device/TV app.
|
|
5
|
+
*
|
|
6
|
+
* Purpose: Start the device flow (user completes authorization on a second screen).
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
/**
|
|
10
|
+
* Quick checklist (security & correctness)
|
|
11
|
+
* - PKCE (S256) required for public clients (and basically for all).
|
|
12
|
+
* - Use authorization code grant only (no implicit/hybrid).
|
|
13
|
+
* - Rotate refresh tokens and bind them to client + user + scopes.
|
|
14
|
+
* - Prefer private_key_jwt or mTLS for confidential clients.
|
|
15
|
+
* - PAR + JAR recommended for higher security.
|
|
16
|
+
* - Consider DPoP (proof-of-possession) to reduce token replay.
|
|
17
|
+
* - Keep codes very short-lived (e.g., ≤60 s) and single-use.
|
|
18
|
+
* - Publish discovery and JWKS, rotate keys safely.
|
|
19
|
+
* - Decide JWT vs opaque access tokens; provide introspection if opaque.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* OAuth 2.0 Device Authorization Grant (“device code flow”)
|
|
24
|
+
* Who does what (at a glance)
|
|
25
|
+
*
|
|
26
|
+
* Device/TV/CLI (no browser)
|
|
27
|
+
* Calls POST /oauth/device_authorization, shows the user a code + URL, and polls POST /oauth/token.
|
|
28
|
+
*
|
|
29
|
+
* User (on phone/laptop browser)
|
|
30
|
+
* Visits the given verification_uri and authenticates using your normal OAuth login (whatever you already have). No new UI required beyond two tiny endpoints.
|
|
31
|
+
*
|
|
32
|
+
* Auth Server (you)
|
|
33
|
+
* Stores the device transaction and, after the user authenticates, marks it as approved so the device’s /oauth/token polling succeeds.
|
|
34
|
+
*
|
|
35
|
+
* Endpoints you need (only two “new” ones)
|
|
36
|
+
*
|
|
37
|
+
* POST /oauth/device_authorization ✅ (device calls)
|
|
38
|
+
*
|
|
39
|
+
* POST /oauth/token with grant urn:ietf:params:oauth:grant-type:device_code ✅ (device polls)
|
|
40
|
+
*
|
|
41
|
+
* GET /activate ➜ “UI handler” (user lands here from verification_uri — this just redirects into your existing /oauth/authorize)
|
|
42
|
+
*
|
|
43
|
+
* GET /activate/callback ➜ “UI handler” (your existing flow returns here after the user logs in; you flip the device record to approved and show a basic “All set” page)
|
|
44
|
+
*
|
|
45
|
+
* That’s it. No pages with complex consent screens are required; reuse your normal /oauth/authorize
|
|
46
|
+
*/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Device Authorization — POST /oauth/device_authorization
|
|
4
|
+
*
|
|
5
|
+
* Who calls: Device/TV app.
|
|
6
|
+
*
|
|
7
|
+
* Purpose: Start the device flow (user completes authorization on a second screen).
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
/**
|
|
11
|
+
* Quick checklist (security & correctness)
|
|
12
|
+
* - PKCE (S256) required for public clients (and basically for all).
|
|
13
|
+
* - Use authorization code grant only (no implicit/hybrid).
|
|
14
|
+
* - Rotate refresh tokens and bind them to client + user + scopes.
|
|
15
|
+
* - Prefer private_key_jwt or mTLS for confidential clients.
|
|
16
|
+
* - PAR + JAR recommended for higher security.
|
|
17
|
+
* - Consider DPoP (proof-of-possession) to reduce token replay.
|
|
18
|
+
* - Keep codes very short-lived (e.g., ≤60 s) and single-use.
|
|
19
|
+
* - Publish discovery and JWKS, rotate keys safely.
|
|
20
|
+
* - Decide JWT vs opaque access tokens; provide introspection if opaque.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* OAuth 2.0 Device Authorization Grant (“device code flow”)
|
|
25
|
+
* Who does what (at a glance)
|
|
26
|
+
*
|
|
27
|
+
* Device/TV/CLI (no browser)
|
|
28
|
+
* Calls POST /oauth/device_authorization, shows the user a code + URL, and polls POST /oauth/token.
|
|
29
|
+
*
|
|
30
|
+
* User (on phone/laptop browser)
|
|
31
|
+
* Visits the given verification_uri and authenticates using your normal OAuth login (whatever you already have). No new UI required beyond two tiny endpoints.
|
|
32
|
+
*
|
|
33
|
+
* Auth Server (you)
|
|
34
|
+
* Stores the device transaction and, after the user authenticates, marks it as approved so the device’s /oauth/token polling succeeds.
|
|
35
|
+
*
|
|
36
|
+
* Endpoints you need (only two “new” ones)
|
|
37
|
+
*
|
|
38
|
+
* POST /oauth/device_authorization ✅ (device calls)
|
|
39
|
+
*
|
|
40
|
+
* POST /oauth/token with grant urn:ietf:params:oauth:grant-type:device_code ✅ (device polls)
|
|
41
|
+
*
|
|
42
|
+
* GET /activate ➜ “UI handler” (user lands here from verification_uri — this just redirects into your existing /oauth/authorize)
|
|
43
|
+
*
|
|
44
|
+
* GET /activate/callback ➜ “UI handler” (your existing flow returns here after the user logs in; you flip the device record to approved and show a basic “All set” page)
|
|
45
|
+
*
|
|
46
|
+
* That’s it. No pages with complex consent screens are required; reuse your normal /oauth/authorize
|
|
47
|
+
*/
|
|
48
|
+
//# sourceMappingURL=oauth.device-authorization.flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.device-authorization.flow.js","sourceRoot":"","sources":["../../../../../src/auth/oauth/flows/oauth.device-authorization.flow.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG","sourcesContent":["/**\n * Device Authorization — POST /oauth/device_authorization\n *\n * Who calls: Device/TV app.\n *\n * Purpose: Start the device flow (user completes authorization on a second screen).\n */\n\n/**\n * Quick checklist (security & correctness)\n * - PKCE (S256) required for public clients (and basically for all).\n * - Use authorization code grant only (no implicit/hybrid).\n * - Rotate refresh tokens and bind them to client + user + scopes.\n * - Prefer private_key_jwt or mTLS for confidential clients.\n * - PAR + JAR recommended for higher security.\n * - Consider DPoP (proof-of-possession) to reduce token replay.\n * - Keep codes very short-lived (e.g., ≤60 s) and single-use.\n * - Publish discovery and JWKS, rotate keys safely.\n * - Decide JWT vs opaque access tokens; provide introspection if opaque.\n */\n\n/**\n *\n * OAuth 2.0 Device Authorization Grant (“device code flow”)\n * Who does what (at a glance)\n *\n * Device/TV/CLI (no browser)\n * Calls POST /oauth/device_authorization, shows the user a code + URL, and polls POST /oauth/token.\n *\n * User (on phone/laptop browser)\n * Visits the given verification_uri and authenticates using your normal OAuth login (whatever you already have). No new UI required beyond two tiny endpoints.\n *\n * Auth Server (you)\n * Stores the device transaction and, after the user authenticates, marks it as approved so the device’s /oauth/token polling succeeds.\n *\n * Endpoints you need (only two “new” ones)\n *\n * POST /oauth/device_authorization ✅ (device calls)\n *\n * POST /oauth/token with grant urn:ietf:params:oauth:grant-type:device_code ✅ (device polls)\n *\n * GET /activate ➜ “UI handler” (user lands here from verification_uri — this just redirects into your existing /oauth/authorize)\n *\n * GET /activate/callback ➜ “UI handler” (your existing flow returns here after the user logs in; you flip the device record to approved and show a basic “All set” page)\n *\n * That’s it. No pages with complex consent screens are required; reuse your normal /oauth/authorize\n */\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Introspection — POST /oauth/introspect
|
|
3
|
+
*
|
|
4
|
+
* Who calls: Resource servers (API gateways).
|
|
5
|
+
*
|
|
6
|
+
* Purpose: Check if a token is active and fetch metadata (subject, scopes, expiry)
|
|
7
|
+
* when you use opaque tokens or want server-side validation (RFC 7662).
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
/**
|
|
11
|
+
* Typical parameter shapes
|
|
12
|
+
*
|
|
13
|
+
* /oauth/introspect (POST): token, optional token_type_hint
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Quick checklist (security & correctness)
|
|
17
|
+
* - PKCE (S256) required for public clients (and basically for all).
|
|
18
|
+
* - Use authorization code grant only (no implicit/hybrid).
|
|
19
|
+
* - Rotate refresh tokens and bind them to client + user + scopes.
|
|
20
|
+
* - Prefer private_key_jwt or mTLS for confidential clients.
|
|
21
|
+
* - PAR + JAR recommended for higher security.
|
|
22
|
+
* - Consider DPoP (proof-of-possession) to reduce token replay.
|
|
23
|
+
* - Keep codes very short-lived (e.g., ≤60 s) and single-use.
|
|
24
|
+
* - Publish discovery and JWKS, rotate keys safely.
|
|
25
|
+
* - Decide JWT vs opaque access tokens; provide introspection if opaque.
|
|
26
|
+
*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Token Introspection — POST /oauth/introspect
|
|
4
|
+
*
|
|
5
|
+
* Who calls: Resource servers (API gateways).
|
|
6
|
+
*
|
|
7
|
+
* Purpose: Check if a token is active and fetch metadata (subject, scopes, expiry)
|
|
8
|
+
* when you use opaque tokens or want server-side validation (RFC 7662).
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
/**
|
|
12
|
+
* Typical parameter shapes
|
|
13
|
+
*
|
|
14
|
+
* /oauth/introspect (POST): token, optional token_type_hint
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Quick checklist (security & correctness)
|
|
18
|
+
* - PKCE (S256) required for public clients (and basically for all).
|
|
19
|
+
* - Use authorization code grant only (no implicit/hybrid).
|
|
20
|
+
* - Rotate refresh tokens and bind them to client + user + scopes.
|
|
21
|
+
* - Prefer private_key_jwt or mTLS for confidential clients.
|
|
22
|
+
* - PAR + JAR recommended for higher security.
|
|
23
|
+
* - Consider DPoP (proof-of-possession) to reduce token replay.
|
|
24
|
+
* - Keep codes very short-lived (e.g., ≤60 s) and single-use.
|
|
25
|
+
* - Publish discovery and JWKS, rotate keys safely.
|
|
26
|
+
* - Decide JWT vs opaque access tokens; provide introspection if opaque.
|
|
27
|
+
*/
|
|
28
|
+
//# sourceMappingURL=oauth.introspect.flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.introspect.flow.js","sourceRoot":"","sources":["../../../../../src/auth/oauth/flows/oauth.introspect.flow.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAEH;;;;GAIG;AACH;;;;;;;;;;;GAWG","sourcesContent":["/**\n * Token Introspection — POST /oauth/introspect\n *\n * Who calls: Resource servers (API gateways).\n *\n * Purpose: Check if a token is active and fetch metadata (subject, scopes, expiry)\n * when you use opaque tokens or want server-side validation (RFC 7662).\n */\n\n/**\n * Typical parameter shapes\n *\n * /oauth/introspect (POST): token, optional token_type_hint\n */\n/**\n * Quick checklist (security & correctness)\n * - PKCE (S256) required for public clients (and basically for all).\n * - Use authorization code grant only (no implicit/hybrid).\n * - Rotate refresh tokens and bind them to client + user + scopes.\n * - Prefer private_key_jwt or mTLS for confidential clients.\n * - PAR + JAR recommended for higher security.\n * - Consider DPoP (proof-of-possession) to reduce token replay.\n * - Keep codes very short-lived (e.g., ≤60 s) and single-use.\n * - Publish discovery and JWKS, rotate keys safely.\n * - Decide JWT vs opaque access tokens; provide introspection if opaque.\n */\n"]}
|