@kya-os/mcp-i-runtime 1.0.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/.turbo/turbo-build.log +4 -0
- package/dist/auth/handshake.d.ts +136 -0
- package/dist/auth/handshake.d.ts.map +1 -0
- package/dist/auth/handshake.js +276 -0
- package/dist/auth/handshake.js.map +1 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +12 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/types.d.ts +52 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +10 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cache/oauth-config-cache.d.ts +69 -0
- package/dist/cache/oauth-config-cache.d.ts.map +1 -0
- package/dist/cache/oauth-config-cache.js +76 -0
- package/dist/cache/oauth-config-cache.js.map +1 -0
- package/dist/cache/tool-protection-cache.d.ts +102 -0
- package/dist/cache/tool-protection-cache.d.ts.map +1 -0
- package/dist/cache/tool-protection-cache.js +131 -0
- package/dist/cache/tool-protection-cache.js.map +1 -0
- package/dist/compliance/index.d.ts +8 -0
- package/dist/compliance/index.d.ts.map +1 -0
- package/dist/compliance/index.js +24 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/compliance/schema-registry.d.ts +50 -0
- package/dist/compliance/schema-registry.d.ts.map +1 -0
- package/dist/compliance/schema-registry.js +438 -0
- package/dist/compliance/schema-registry.js.map +1 -0
- package/dist/compliance/schema-verifier.d.ts +110 -0
- package/dist/compliance/schema-verifier.d.ts.map +1 -0
- package/dist/compliance/schema-verifier.js +518 -0
- package/dist/compliance/schema-verifier.js.map +1 -0
- package/dist/config/remote-config.d.ts +188 -0
- package/dist/config/remote-config.d.ts.map +1 -0
- package/dist/config/remote-config.js +268 -0
- package/dist/config/remote-config.js.map +1 -0
- package/dist/config.d.ts +182 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +148 -0
- package/dist/config.js.map +1 -0
- package/dist/identity/idp-token-resolver.d.ts +69 -0
- package/dist/identity/idp-token-resolver.d.ts.map +1 -0
- package/dist/identity/idp-token-resolver.js +136 -0
- package/dist/identity/idp-token-resolver.js.map +1 -0
- package/dist/identity/idp-token-storage.interface.d.ts +80 -0
- package/dist/identity/idp-token-storage.interface.d.ts.map +1 -0
- package/dist/identity/idp-token-storage.interface.js +14 -0
- package/dist/identity/idp-token-storage.interface.js.map +1 -0
- package/dist/identity/user-did-manager.d.ts +228 -0
- package/dist/identity/user-did-manager.d.ts.map +1 -0
- package/dist/identity/user-did-manager.js +356 -0
- package/dist/identity/user-did-manager.js.map +1 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +193 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/index.d.ts +5 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +10 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.d.ts +33 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +104 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/proof/generator.d.ts +109 -0
- package/dist/proof/generator.d.ts.map +1 -0
- package/dist/proof/generator.js +236 -0
- package/dist/proof/generator.js.map +1 -0
- package/dist/proof/index.d.ts +5 -0
- package/dist/proof/index.d.ts.map +1 -0
- package/dist/proof/index.js +11 -0
- package/dist/proof/index.js.map +1 -0
- package/dist/providers/base.d.ts +95 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +47 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/memory.d.ts +42 -0
- package/dist/providers/memory.d.ts.map +1 -0
- package/dist/providers/memory.js +121 -0
- package/dist/providers/memory.js.map +1 -0
- package/dist/runtime/audit-logger.d.ts +37 -0
- package/dist/runtime/audit-logger.d.ts.map +1 -0
- package/dist/runtime/audit-logger.js +9 -0
- package/dist/runtime/audit-logger.js.map +1 -0
- package/dist/runtime/base.d.ts +392 -0
- package/dist/runtime/base.d.ts.map +1 -0
- package/dist/runtime/base.js +1527 -0
- package/dist/runtime/base.js.map +1 -0
- package/dist/runtime/dif-core.d.ts +33 -0
- package/dist/runtime/dif-core.d.ts.map +1 -0
- package/dist/runtime/dif-core.js +14 -0
- package/dist/runtime/dif-core.js.map +1 -0
- package/dist/runtime/ext-apps-constants.d.ts +20 -0
- package/dist/runtime/ext-apps-constants.d.ts.map +1 -0
- package/dist/runtime/ext-apps-constants.js +23 -0
- package/dist/runtime/ext-apps-constants.js.map +1 -0
- package/dist/services/access-control.service.d.ts +138 -0
- package/dist/services/access-control.service.d.ts.map +1 -0
- package/dist/services/access-control.service.js +721 -0
- package/dist/services/access-control.service.js.map +1 -0
- package/dist/services/authorization/authorization-registry.d.ts +29 -0
- package/dist/services/authorization/authorization-registry.d.ts.map +1 -0
- package/dist/services/authorization/authorization-registry.js +58 -0
- package/dist/services/authorization/authorization-registry.js.map +1 -0
- package/dist/services/authorization/types.d.ts +53 -0
- package/dist/services/authorization/types.d.ts.map +1 -0
- package/dist/services/authorization/types.js +10 -0
- package/dist/services/authorization/types.js.map +1 -0
- package/dist/services/batch-delegation.service.d.ts +53 -0
- package/dist/services/batch-delegation.service.d.ts.map +1 -0
- package/dist/services/batch-delegation.service.js +95 -0
- package/dist/services/batch-delegation.service.js.map +1 -0
- package/dist/services/crypto.service.d.ts +69 -0
- package/dist/services/crypto.service.d.ts.map +1 -0
- package/dist/services/crypto.service.js +225 -0
- package/dist/services/crypto.service.js.map +1 -0
- package/dist/services/delegation-error-formatter.d.ts +124 -0
- package/dist/services/delegation-error-formatter.d.ts.map +1 -0
- package/dist/services/delegation-error-formatter.js +214 -0
- package/dist/services/delegation-error-formatter.js.map +1 -0
- package/dist/services/errors.d.ts +49 -0
- package/dist/services/errors.d.ts.map +1 -0
- package/dist/services/errors.js +66 -0
- package/dist/services/errors.js.map +1 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +15 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/oauth-config.service.d.ts +53 -0
- package/dist/services/oauth-config.service.d.ts.map +1 -0
- package/dist/services/oauth-config.service.js +141 -0
- package/dist/services/oauth-config.service.js.map +1 -0
- package/dist/services/oauth-provider-registry.d.ts +88 -0
- package/dist/services/oauth-provider-registry.d.ts.map +1 -0
- package/dist/services/oauth-provider-registry.js +128 -0
- package/dist/services/oauth-provider-registry.js.map +1 -0
- package/dist/services/oauth-service.d.ts +122 -0
- package/dist/services/oauth-service.d.ts.map +1 -0
- package/dist/services/oauth-service.js +442 -0
- package/dist/services/oauth-service.js.map +1 -0
- package/dist/services/oauth-token-retrieval.service.d.ts +49 -0
- package/dist/services/oauth-token-retrieval.service.d.ts.map +1 -0
- package/dist/services/oauth-token-retrieval.service.js +150 -0
- package/dist/services/oauth-token-retrieval.service.js.map +1 -0
- package/dist/services/policy.service.d.ts +130 -0
- package/dist/services/policy.service.d.ts.map +1 -0
- package/dist/services/policy.service.js +399 -0
- package/dist/services/policy.service.js.map +1 -0
- package/dist/services/proof-verifier.d.ts +103 -0
- package/dist/services/proof-verifier.d.ts.map +1 -0
- package/dist/services/proof-verifier.js +190 -0
- package/dist/services/proof-verifier.js.map +1 -0
- package/dist/services/provider-resolver.d.ts +89 -0
- package/dist/services/provider-resolver.d.ts.map +1 -0
- package/dist/services/provider-resolver.js +196 -0
- package/dist/services/provider-resolver.js.map +1 -0
- package/dist/services/provider-validator.d.ts +55 -0
- package/dist/services/provider-validator.d.ts.map +1 -0
- package/dist/services/provider-validator.js +135 -0
- package/dist/services/provider-validator.js.map +1 -0
- package/dist/services/session-registration.service.d.ts +80 -0
- package/dist/services/session-registration.service.d.ts.map +1 -0
- package/dist/services/session-registration.service.js +174 -0
- package/dist/services/session-registration.service.js.map +1 -0
- package/dist/services/storage.service.d.ts +116 -0
- package/dist/services/storage.service.d.ts.map +1 -0
- package/dist/services/storage.service.js +411 -0
- package/dist/services/storage.service.js.map +1 -0
- package/dist/services/tool-context-builder.d.ts +74 -0
- package/dist/services/tool-context-builder.d.ts.map +1 -0
- package/dist/services/tool-context-builder.js +215 -0
- package/dist/services/tool-context-builder.js.map +1 -0
- package/dist/services/tool-protection.service.d.ts +209 -0
- package/dist/services/tool-protection.service.d.ts.map +1 -0
- package/dist/services/tool-protection.service.js +752 -0
- package/dist/services/tool-protection.service.js.map +1 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +11 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/manager.d.ts +118 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +285 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/types/oauth-required-error.d.ts +46 -0
- package/dist/types/oauth-required-error.d.ts.map +1 -0
- package/dist/types/oauth-required-error.js +42 -0
- package/dist/types/oauth-required-error.js.map +1 -0
- package/dist/types/tool-protection.d.ts +144 -0
- package/dist/types/tool-protection.d.ts.map +1 -0
- package/dist/types/tool-protection.js +48 -0
- package/dist/types/tool-protection.js.map +1 -0
- package/dist/utils/base58.d.ts +31 -0
- package/dist/utils/base58.d.ts.map +1 -0
- package/dist/utils/base58.js +103 -0
- package/dist/utils/base58.js.map +1 -0
- package/dist/utils/base64.d.ts +32 -0
- package/dist/utils/base64.d.ts.map +1 -0
- package/dist/utils/base64.js +172 -0
- package/dist/utils/base64.js.map +1 -0
- package/dist/utils/cors.d.ts +52 -0
- package/dist/utils/cors.d.ts.map +1 -0
- package/dist/utils/cors.js +79 -0
- package/dist/utils/cors.js.map +1 -0
- package/dist/utils/did-helpers.d.ts +168 -0
- package/dist/utils/did-helpers.d.ts.map +1 -0
- package/dist/utils/did-helpers.js +222 -0
- package/dist/utils/did-helpers.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/storage-keys.d.ts +120 -0
- package/dist/utils/storage-keys.d.ts.map +1 -0
- package/dist/utils/storage-keys.js +217 -0
- package/dist/utils/storage-keys.js.map +1 -0
- package/dist/wire-format.d.ts +62 -0
- package/dist/wire-format.d.ts.map +1 -0
- package/dist/wire-format.js +89 -0
- package/dist/wire-format.js.map +1 -0
- package/package.json +83 -0
- package/src/__tests__/cache/tool-protection-cache.test.ts +640 -0
- package/src/__tests__/config/provider-runtime-config.test.ts +309 -0
- package/src/__tests__/config.test.ts +307 -0
- package/src/__tests__/identity/user-did-manager.test.ts +232 -0
- package/src/__tests__/index.test.ts +56 -0
- package/src/__tests__/integration/full-flow.test.ts +779 -0
- package/src/__tests__/integration.test.ts +281 -0
- package/src/__tests__/providers/base.test.ts +173 -0
- package/src/__tests__/providers/memory.test.ts +319 -0
- package/src/__tests__/regression/phase2-regression.test.ts +406 -0
- package/src/__tests__/runtime/audit-logger.test.ts +154 -0
- package/src/__tests__/runtime/base-extensions.test.ts +595 -0
- package/src/__tests__/runtime/base.test.ts +1328 -0
- package/src/__tests__/runtime/delegation-flow.test.ts +159 -0
- package/src/__tests__/runtime/process-tool-call-security.test.ts +1024 -0
- package/src/__tests__/runtime/proof-client-did.test.ts +376 -0
- package/src/__tests__/runtime/provider-selection.test.ts +292 -0
- package/src/__tests__/runtime/route-interception.test.ts +670 -0
- package/src/__tests__/runtime/tool-protection-enforcement.test.ts +989 -0
- package/src/__tests__/services/access-control-retry.test.ts +595 -0
- package/src/__tests__/services/agentshield-integration.test.ts +709 -0
- package/src/__tests__/services/cache-busting.test.ts +125 -0
- package/src/__tests__/services/oauth-service-errors.test.ts +704 -0
- package/src/__tests__/services/oauth-service-pkce.test.ts +556 -0
- package/src/__tests__/services/oauth-service-secret-resolution.test.ts +349 -0
- package/src/__tests__/services/provider-resolver-edge-cases.test.ts +591 -0
- package/src/__tests__/services/tool-protection-failsafe.test.ts +683 -0
- package/src/__tests__/services/tool-protection-merged-config.test.ts +664 -0
- package/src/__tests__/services/tool-protection-oauth-provider.test.ts +300 -0
- package/src/__tests__/services/tool-protection.service.test.ts +1201 -0
- package/src/__tests__/utils/mock-providers.ts +340 -0
- package/src/__tests__/wire-format.test.ts +123 -0
- package/src/auth/__tests__/resume-token.test.ts +42 -0
- package/src/auth/handshake.ts +476 -0
- package/src/auth/index.ts +15 -0
- package/src/auth/types.ts +68 -0
- package/src/cache/__tests__/oauth-config-cache.test.ts +215 -0
- package/src/cache/oauth-config-cache.d.ts +69 -0
- package/src/cache/oauth-config-cache.d.ts.map +1 -0
- package/src/cache/oauth-config-cache.js.map +1 -0
- package/src/cache/oauth-config-cache.ts +123 -0
- package/src/cache/tool-protection-cache.ts +184 -0
- package/src/compliance/EXAMPLE.md +412 -0
- package/src/compliance/__tests__/schema-verifier.test.ts +791 -0
- package/src/compliance/index.ts +8 -0
- package/src/compliance/schema-registry.ts +460 -0
- package/src/compliance/schema-verifier.ts +708 -0
- package/src/config/__tests__/merged-config.spec.ts +445 -0
- package/src/config/__tests__/remote-config-edge-cases.test.ts +424 -0
- package/src/config/__tests__/remote-config-helpers.test.ts +280 -0
- package/src/config/__tests__/remote-config.spec.ts +265 -0
- package/src/config/remote-config.ts +368 -0
- package/src/config.ts +312 -0
- package/src/identity/__tests__/idp-token-resolver.test.ts +340 -0
- package/src/identity/__tests__/user-did-manager.test.ts +487 -0
- package/src/identity/idp-token-resolver.ts +181 -0
- package/src/identity/idp-token-storage.interface.ts +102 -0
- package/src/identity/user-did-manager.ts +592 -0
- package/src/index.ts +331 -0
- package/src/logging/__tests__/logger.test.ts +366 -0
- package/src/logging/index.ts +10 -0
- package/src/logging/logger.ts +112 -0
- package/src/proof/__tests__/crypto-parity.test.ts +202 -0
- package/src/proof/__tests__/proof-generator.test.ts +484 -0
- package/src/proof/generator.ts +347 -0
- package/src/proof/index.ts +12 -0
- package/src/providers/base.d.ts +91 -0
- package/src/providers/base.d.ts.map +1 -0
- package/src/providers/base.js.map +1 -0
- package/src/providers/base.ts +100 -0
- package/src/providers/memory.ts +142 -0
- package/src/runtime/__tests__/dif-esm-bridge.test.ts +33 -0
- package/src/runtime/__tests__/ext-apps-consent.test.ts +334 -0
- package/src/runtime/audit-logger.ts +39 -0
- package/src/runtime/base.ts +2100 -0
- package/src/runtime/dif-core.ts +39 -0
- package/src/runtime/ext-apps-constants.ts +20 -0
- package/src/services/__tests__/access-control.integration.test.ts +441 -0
- package/src/services/__tests__/access-control.proof-response-validation.test.ts +578 -0
- package/src/services/__tests__/access-control.service.test.ts +1132 -0
- package/src/services/__tests__/batch-delegation.service.test.ts +351 -0
- package/src/services/__tests__/crypto.service.test.ts +531 -0
- package/src/services/__tests__/delegation-error-formatter.test.ts +643 -0
- package/src/services/__tests__/oauth-config.service.test.ts +359 -0
- package/src/services/__tests__/oauth-provider-registry.test.ts +142 -0
- package/src/services/__tests__/oauth-token-retrieval.service.test.ts +365 -0
- package/src/services/__tests__/proof-verifier.integration.test.ts +494 -0
- package/src/services/__tests__/proof-verifier.test.ts +489 -0
- package/src/services/__tests__/provider-resolution.integration.test.ts +202 -0
- package/src/services/__tests__/provider-resolver.test.ts +213 -0
- package/src/services/__tests__/provider-validator.test.ts +370 -0
- package/src/services/__tests__/session-registration.service.test.ts +312 -0
- package/src/services/__tests__/storage.service.test.ts +358 -0
- package/src/services/__tests__/tool-context-builder.test.ts +438 -0
- package/src/services/access-control.service.ts +1048 -0
- package/src/services/authorization/authorization-registry.ts +67 -0
- package/src/services/authorization/types.ts +71 -0
- package/src/services/batch-delegation.service.ts +136 -0
- package/src/services/crypto.service.ts +296 -0
- package/src/services/delegation-error-formatter.ts +299 -0
- package/src/services/errors.ts +76 -0
- package/src/services/index.ts +34 -0
- package/src/services/oauth-config.service.d.ts +53 -0
- package/src/services/oauth-config.service.d.ts.map +1 -0
- package/src/services/oauth-config.service.js.map +1 -0
- package/src/services/oauth-config.service.ts +192 -0
- package/src/services/oauth-provider-registry.d.ts +57 -0
- package/src/services/oauth-provider-registry.d.ts.map +1 -0
- package/src/services/oauth-provider-registry.js.map +1 -0
- package/src/services/oauth-provider-registry.ts +141 -0
- package/src/services/oauth-service.ts +652 -0
- package/src/services/oauth-token-retrieval.service.ts +245 -0
- package/src/services/policy.service.ts +527 -0
- package/src/services/proof-verifier.ts +295 -0
- package/src/services/provider-resolver.d.ts +48 -0
- package/src/services/provider-resolver.d.ts.map +1 -0
- package/src/services/provider-resolver.js.map +1 -0
- package/src/services/provider-resolver.ts +236 -0
- package/src/services/provider-validator.ts +170 -0
- package/src/services/session-registration.service.ts +259 -0
- package/src/services/storage.service.ts +566 -0
- package/src/services/tool-context-builder.ts +285 -0
- package/src/services/tool-protection.service.ts +971 -0
- package/src/session/__tests__/session-manager.test.ts +327 -0
- package/src/session/index.ts +10 -0
- package/src/session/manager.ts +380 -0
- package/src/types/__tests__/oauth-required-error.test.ts +79 -0
- package/src/types/__tests__/tool-protection.test.ts +121 -0
- package/src/types/oauth-required-error.ts +71 -0
- package/src/types/tool-protection.ts +179 -0
- package/src/utils/__tests__/base58.test.ts +281 -0
- package/src/utils/__tests__/base64.test.ts +239 -0
- package/src/utils/__tests__/cors.test.ts +184 -0
- package/src/utils/__tests__/did-helpers.test.ts +156 -0
- package/src/utils/__tests__/storage-keys.test.ts +372 -0
- package/src/utils/base58.ts +109 -0
- package/src/utils/base64.ts +185 -0
- package/src/utils/cors.ts +93 -0
- package/src/utils/did-helpers.ts +229 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/storage-keys.ts +285 -0
- package/src/wire-format.ts +114 -0
- package/tsconfig.json +21 -0
- package/vitest.config.mts +57 -0
package/dist/config.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Provider-based Runtime Configuration
|
|
4
|
+
*
|
|
5
|
+
* Core configuration for MCP-I runtime using the provider pattern.
|
|
6
|
+
* This is the foundation for all platform-specific implementations.
|
|
7
|
+
*
|
|
8
|
+
* @module @kya-os/mcp-i-core/config
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.hasMergedToolProtections = exports.extractToolProtections = exports.getToolProtection = exports.fetchRemoteConfig = exports.ProviderRuntimeConfigBuilder = void 0;
|
|
12
|
+
exports.createProviderRuntimeConfig = createProviderRuntimeConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Builder for provider runtime configuration
|
|
15
|
+
* Helps create valid configurations with proper defaults
|
|
16
|
+
*/
|
|
17
|
+
class ProviderRuntimeConfigBuilder {
|
|
18
|
+
config = {
|
|
19
|
+
environment: 'development'
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Set the providers (required)
|
|
23
|
+
*/
|
|
24
|
+
withProviders(providers) {
|
|
25
|
+
Object.assign(this.config, providers);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Set the environment
|
|
30
|
+
*/
|
|
31
|
+
withEnvironment(env) {
|
|
32
|
+
this.config.environment = env;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Configure session handling
|
|
37
|
+
*/
|
|
38
|
+
withSession(session) {
|
|
39
|
+
this.config.session = session;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Enable identity features
|
|
44
|
+
*/
|
|
45
|
+
withIdentity(identity) {
|
|
46
|
+
this.config.identity = identity;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Enable proofing features
|
|
51
|
+
*/
|
|
52
|
+
withProofing(proofing) {
|
|
53
|
+
this.config.proofing = proofing;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Enable delegation features
|
|
58
|
+
*/
|
|
59
|
+
withDelegation(delegation) {
|
|
60
|
+
this.config.delegation = delegation;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Set tool protection service
|
|
65
|
+
*/
|
|
66
|
+
withToolProtectionService(service) {
|
|
67
|
+
this.config.toolProtectionService = service;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Set tool protection configuration
|
|
72
|
+
*/
|
|
73
|
+
withToolProtection(config) {
|
|
74
|
+
this.config.toolProtection = config;
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Enable audit features
|
|
79
|
+
*/
|
|
80
|
+
withAudit(audit) {
|
|
81
|
+
this.config.audit = audit;
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Enable well-known endpoints
|
|
86
|
+
*/
|
|
87
|
+
withWellKnown(wellKnown) {
|
|
88
|
+
this.config.wellKnown = wellKnown;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Build the configuration
|
|
93
|
+
* Validates that all required providers are set
|
|
94
|
+
*/
|
|
95
|
+
build() {
|
|
96
|
+
const required = [
|
|
97
|
+
'cryptoProvider',
|
|
98
|
+
'clockProvider',
|
|
99
|
+
'fetchProvider',
|
|
100
|
+
'storageProvider',
|
|
101
|
+
'nonceCacheProvider',
|
|
102
|
+
'identityProvider'
|
|
103
|
+
];
|
|
104
|
+
for (const field of required) {
|
|
105
|
+
if (!(field in this.config)) {
|
|
106
|
+
throw new Error(`Missing required provider: ${field}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Apply defaults
|
|
110
|
+
return {
|
|
111
|
+
environment: 'development',
|
|
112
|
+
session: {
|
|
113
|
+
timestampSkewSeconds: 120,
|
|
114
|
+
ttlMinutes: 30
|
|
115
|
+
},
|
|
116
|
+
...this.config
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.ProviderRuntimeConfigBuilder = ProviderRuntimeConfigBuilder;
|
|
121
|
+
/**
|
|
122
|
+
* Re-export remote config utilities
|
|
123
|
+
*/
|
|
124
|
+
var remote_config_1 = require("./config/remote-config");
|
|
125
|
+
Object.defineProperty(exports, "fetchRemoteConfig", { enumerable: true, get: function () { return remote_config_1.fetchRemoteConfig; } });
|
|
126
|
+
Object.defineProperty(exports, "getToolProtection", { enumerable: true, get: function () { return remote_config_1.getToolProtection; } });
|
|
127
|
+
Object.defineProperty(exports, "extractToolProtections", { enumerable: true, get: function () { return remote_config_1.extractToolProtections; } });
|
|
128
|
+
Object.defineProperty(exports, "hasMergedToolProtections", { enumerable: true, get: function () { return remote_config_1.hasMergedToolProtections; } });
|
|
129
|
+
/**
|
|
130
|
+
* Create a provider runtime configuration
|
|
131
|
+
* Convenience function for creating configurations
|
|
132
|
+
*/
|
|
133
|
+
function createProviderRuntimeConfig(providers, options) {
|
|
134
|
+
return new ProviderRuntimeConfigBuilder()
|
|
135
|
+
.withProviders(providers)
|
|
136
|
+
.withEnvironment(options?.environment || 'development')
|
|
137
|
+
.withSession(options?.session || {})
|
|
138
|
+
.withIdentity(options?.identity || { enabled: false, environment: 'development' })
|
|
139
|
+
.withProofing(options?.proofing || { enabled: false })
|
|
140
|
+
.withDelegation(options?.delegation || {
|
|
141
|
+
enabled: false,
|
|
142
|
+
verifier: { type: 'memory' }
|
|
143
|
+
})
|
|
144
|
+
.withAudit(options?.audit || { enabled: false })
|
|
145
|
+
.withWellKnown(options?.wellKnown || { enabled: true })
|
|
146
|
+
.build();
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAwRH,kEAwBC;AA5LD;;;GAGG;AACH,MAAa,4BAA4B;IAC/B,MAAM,GAAmC;QAC/C,WAAW,EAAE,aAAa;KAC3B,CAAC;IAEF;;OAEG;IACH,aAAa,CAAC,SAOb;QACC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAA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AE,OAAO,EAAE,KAAK,EAAE,CAAC;SAC/C,aAAa,CAAC,OAAO,EAAE,SAAS,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SACtD,KAAK,EAAE,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IDP Token Resolver
|
|
3
|
+
*
|
|
4
|
+
* Resolves User DID to IDP access token (MH-7 requirement).
|
|
5
|
+
* Handles token lookup, expiration checking, and automatic refresh.
|
|
6
|
+
*
|
|
7
|
+
* Updated for CRED-003: Returns full token data including usage metadata
|
|
8
|
+
* to support credential providers with custom token usage patterns.
|
|
9
|
+
*
|
|
10
|
+
* @package @kya-os/mcp-i-core
|
|
11
|
+
*/
|
|
12
|
+
import type { IdpTokens } from "@kya-os/contracts/config";
|
|
13
|
+
import type { IIdpTokenStorage, IdpTokensWithMetadata } from "./idp-token-storage.interface.js";
|
|
14
|
+
export interface IdpTokenResolverConfig {
|
|
15
|
+
/** Token storage implementation */
|
|
16
|
+
tokenStorage: IIdpTokenStorage;
|
|
17
|
+
/** OAuth service for token refresh */
|
|
18
|
+
oauthService: {
|
|
19
|
+
refreshToken(provider: string, refreshToken: string): Promise<IdpTokens | null>;
|
|
20
|
+
};
|
|
21
|
+
/** Optional logger callback for diagnostics */
|
|
22
|
+
logger?: (message: string, data?: unknown) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Service for resolving User DID to IDP access token
|
|
26
|
+
*
|
|
27
|
+
* MH-7 Requirement: resolveTokenFromDid(userDid: string): Promise<string>
|
|
28
|
+
*
|
|
29
|
+
* This service implements the core MH-7 functionality:
|
|
30
|
+
* - Resolves User DID to IDP access token
|
|
31
|
+
* - Handles token expiration and automatic refresh
|
|
32
|
+
* - Supports multiple IDP providers
|
|
33
|
+
*/
|
|
34
|
+
export declare class IdpTokenResolver {
|
|
35
|
+
private config;
|
|
36
|
+
constructor(config: IdpTokenResolverConfig);
|
|
37
|
+
/**
|
|
38
|
+
* Resolve User DID to IDP access token
|
|
39
|
+
*
|
|
40
|
+
* MH-7 Requirement: resolveTokenFromDid(userDid: string): Promise<string>
|
|
41
|
+
*
|
|
42
|
+
* Flow:
|
|
43
|
+
* 1. Look up token from storage
|
|
44
|
+
* 2. Check expiration
|
|
45
|
+
* 3. Auto-refresh if expired and refresh_token available
|
|
46
|
+
* 4. Update storage after refresh
|
|
47
|
+
* 5. Return access_token or null
|
|
48
|
+
*
|
|
49
|
+
* @param userDid - User DID to resolve
|
|
50
|
+
* @param provider - OAuth provider name (e.g., "github", "google")
|
|
51
|
+
* @param scopes - Required scopes for token
|
|
52
|
+
* @returns Access token or null if not found/expired
|
|
53
|
+
*/
|
|
54
|
+
resolveTokenFromDid(userDid: string, provider: string, scopes: string[]): Promise<string | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve User DID to full IDP token data (CRED-003)
|
|
57
|
+
*
|
|
58
|
+
* Returns the full token data including usage metadata for credential providers.
|
|
59
|
+
* This allows ToolContextBuilder to construct appropriate headers based on
|
|
60
|
+
* tokenUsage (cookie/bearer/header) and cookieFormat.
|
|
61
|
+
*
|
|
62
|
+
* @param userDid - User DID to resolve
|
|
63
|
+
* @param provider - OAuth provider name or credential provider
|
|
64
|
+
* @param scopes - Required scopes for token
|
|
65
|
+
* @returns Full token data with metadata or null if not found/expired
|
|
66
|
+
*/
|
|
67
|
+
resolveTokenDataFromDid(userDid: string, provider: string, scopes: string[]): Promise<IdpTokensWithMetadata | null>;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=idp-token-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idp-token-resolver.d.ts","sourceRoot":"","sources":["../../src/identity/idp-token-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEhG,MAAM,WAAW,sBAAsB;IACrC,mCAAmC;IACnC,YAAY,EAAE,gBAAgB,CAAC;IAE/B,sCAAsC;IACtC,YAAY,EAAE;QACZ,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;KACjF,CAAC;IAEF,+CAA+C;IAC/C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpD;AAED;;;;;;;;;GASG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAEZ;gBAEU,MAAM,EAAE,sBAAsB;IAQ1C;;;;;;;;;;;;;;;;OAgBG;IACG,mBAAmB,CACvB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKzB;;;;;;;;;;;OAWG;IACG,uBAAuB,CAC3B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;CAsFzC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IDP Token Resolver
|
|
4
|
+
*
|
|
5
|
+
* Resolves User DID to IDP access token (MH-7 requirement).
|
|
6
|
+
* Handles token lookup, expiration checking, and automatic refresh.
|
|
7
|
+
*
|
|
8
|
+
* Updated for CRED-003: Returns full token data including usage metadata
|
|
9
|
+
* to support credential providers with custom token usage patterns.
|
|
10
|
+
*
|
|
11
|
+
* @package @kya-os/mcp-i-core
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.IdpTokenResolver = void 0;
|
|
15
|
+
/**
|
|
16
|
+
* Service for resolving User DID to IDP access token
|
|
17
|
+
*
|
|
18
|
+
* MH-7 Requirement: resolveTokenFromDid(userDid: string): Promise<string>
|
|
19
|
+
*
|
|
20
|
+
* This service implements the core MH-7 functionality:
|
|
21
|
+
* - Resolves User DID to IDP access token
|
|
22
|
+
* - Handles token expiration and automatic refresh
|
|
23
|
+
* - Supports multiple IDP providers
|
|
24
|
+
*/
|
|
25
|
+
class IdpTokenResolver {
|
|
26
|
+
config;
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.config = {
|
|
29
|
+
tokenStorage: config.tokenStorage,
|
|
30
|
+
oauthService: config.oauthService,
|
|
31
|
+
logger: config.logger || (() => { }),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve User DID to IDP access token
|
|
36
|
+
*
|
|
37
|
+
* MH-7 Requirement: resolveTokenFromDid(userDid: string): Promise<string>
|
|
38
|
+
*
|
|
39
|
+
* Flow:
|
|
40
|
+
* 1. Look up token from storage
|
|
41
|
+
* 2. Check expiration
|
|
42
|
+
* 3. Auto-refresh if expired and refresh_token available
|
|
43
|
+
* 4. Update storage after refresh
|
|
44
|
+
* 5. Return access_token or null
|
|
45
|
+
*
|
|
46
|
+
* @param userDid - User DID to resolve
|
|
47
|
+
* @param provider - OAuth provider name (e.g., "github", "google")
|
|
48
|
+
* @param scopes - Required scopes for token
|
|
49
|
+
* @returns Access token or null if not found/expired
|
|
50
|
+
*/
|
|
51
|
+
async resolveTokenFromDid(userDid, provider, scopes) {
|
|
52
|
+
const tokenData = await this.resolveTokenDataFromDid(userDid, provider, scopes);
|
|
53
|
+
return tokenData?.access_token ?? null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve User DID to full IDP token data (CRED-003)
|
|
57
|
+
*
|
|
58
|
+
* Returns the full token data including usage metadata for credential providers.
|
|
59
|
+
* This allows ToolContextBuilder to construct appropriate headers based on
|
|
60
|
+
* tokenUsage (cookie/bearer/header) and cookieFormat.
|
|
61
|
+
*
|
|
62
|
+
* @param userDid - User DID to resolve
|
|
63
|
+
* @param provider - OAuth provider name or credential provider
|
|
64
|
+
* @param scopes - Required scopes for token
|
|
65
|
+
* @returns Full token data with metadata or null if not found/expired
|
|
66
|
+
*/
|
|
67
|
+
async resolveTokenDataFromDid(userDid, provider, scopes) {
|
|
68
|
+
// 1. Look up token from storage
|
|
69
|
+
const storedToken = await this.config.tokenStorage.getToken(userDid, provider, scopes);
|
|
70
|
+
if (!storedToken) {
|
|
71
|
+
this.config.logger("[IdpTokenResolver] Token not found", {
|
|
72
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
73
|
+
provider,
|
|
74
|
+
scopes,
|
|
75
|
+
});
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
// 2. Check expiration
|
|
79
|
+
const now = Date.now();
|
|
80
|
+
if (storedToken.expires_at < now) {
|
|
81
|
+
this.config.logger("[IdpTokenResolver] Token expired, attempting refresh", {
|
|
82
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
83
|
+
provider,
|
|
84
|
+
expiresAt: new Date(storedToken.expires_at).toISOString(),
|
|
85
|
+
hasRefreshToken: !!storedToken.refresh_token,
|
|
86
|
+
});
|
|
87
|
+
// 3. Refresh if refresh_token available
|
|
88
|
+
// Note: Credential tokens don't support refresh - they require re-authentication
|
|
89
|
+
if (storedToken.refresh_token) {
|
|
90
|
+
const refreshed = await this.config.oauthService.refreshToken(provider, storedToken.refresh_token);
|
|
91
|
+
if (refreshed) {
|
|
92
|
+
// 4. Update storage with new tokens, preserving usage metadata
|
|
93
|
+
const refreshedWithMetadata = {
|
|
94
|
+
...refreshed,
|
|
95
|
+
tokenUsage: storedToken.tokenUsage,
|
|
96
|
+
tokenHeader: storedToken.tokenHeader,
|
|
97
|
+
cookieFormat: storedToken.cookieFormat,
|
|
98
|
+
apiHeaders: storedToken.apiHeaders,
|
|
99
|
+
};
|
|
100
|
+
await this.config.tokenStorage.storeToken(userDid, provider, scopes, refreshedWithMetadata);
|
|
101
|
+
this.config.logger("[IdpTokenResolver] Token refreshed successfully", {
|
|
102
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
103
|
+
provider,
|
|
104
|
+
expiresAt: new Date(refreshed.expires_at).toISOString(),
|
|
105
|
+
});
|
|
106
|
+
// 5. Return new token data
|
|
107
|
+
return refreshedWithMetadata;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.config.logger("[IdpTokenResolver] Token refresh failed", {
|
|
111
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
112
|
+
provider,
|
|
113
|
+
});
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.config.logger("[IdpTokenResolver] Token expired and no refresh token", {
|
|
119
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
120
|
+
provider,
|
|
121
|
+
});
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// 4. Return valid token data
|
|
126
|
+
this.config.logger("[IdpTokenResolver] Token resolved successfully", {
|
|
127
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
128
|
+
provider,
|
|
129
|
+
expiresAt: new Date(storedToken.expires_at).toISOString(),
|
|
130
|
+
tokenUsage: storedToken.tokenUsage,
|
|
131
|
+
});
|
|
132
|
+
return storedToken;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.IdpTokenResolver = IdpTokenResolver;
|
|
136
|
+
//# sourceMappingURL=idp-token-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idp-token-resolver.js","sourceRoot":"","sources":["../../src/identity/idp-token-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAkBH;;;;;;;;;GASG;AACH,MAAa,gBAAgB;IACnB,MAAM,CAEZ;IAEF,YAAY,MAA8B;QACxC,IAAI,CAAC,MAAM,GAAG;YACZ,Y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M,CAAC,uDAAuD,EAAE;oBAC1E,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK;oBACzC,QAAQ;iBACT,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,6BAA6B;QAC7B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gDAAgD,EAAE;YACnE,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK;YACzC,QAAQ;YACR,SAAS,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE;YACzD,UAAU,EAAE,WAAW,CAAC,UAAU;SACnC,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AA7ID,4CA6IC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IDP Token Storage Interface
|
|
3
|
+
*
|
|
4
|
+
* Platform-agnostic interface for storing and retrieving IDP tokens.
|
|
5
|
+
* Platform-specific implementations (Cloudflare KV, Node.js database, etc.)
|
|
6
|
+
* implement this interface.
|
|
7
|
+
*
|
|
8
|
+
* Supports both OAuth tokens and credential-based session tokens (CRED-003).
|
|
9
|
+
*
|
|
10
|
+
* @package @kya-os/mcp-i-core
|
|
11
|
+
*/
|
|
12
|
+
import type { IdpTokens } from "@kya-os/contracts/config";
|
|
13
|
+
/**
|
|
14
|
+
* Token usage metadata for credential providers (CRED-003)
|
|
15
|
+
*
|
|
16
|
+
* Specifies how the token should be used in subsequent API calls.
|
|
17
|
+
*/
|
|
18
|
+
export interface TokenUsageMetadata {
|
|
19
|
+
/**
|
|
20
|
+
* How to use the token in requests
|
|
21
|
+
* - "cookie": Send as Cookie header
|
|
22
|
+
* - "bearer": Send as Authorization: Bearer xxx
|
|
23
|
+
* - "header": Send as custom header (specify tokenHeader)
|
|
24
|
+
*/
|
|
25
|
+
tokenUsage?: "cookie" | "bearer" | "header";
|
|
26
|
+
/** Custom header name when tokenUsage is "header" */
|
|
27
|
+
tokenHeader?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Cookie format template when tokenUsage is "cookie"
|
|
30
|
+
* Use {{token}} placeholder for the token value
|
|
31
|
+
* @example "CIX={{token}}; customerCookie={{token}}"
|
|
32
|
+
*/
|
|
33
|
+
cookieFormat?: string;
|
|
34
|
+
/** Additional headers to include in API calls */
|
|
35
|
+
apiHeaders?: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* User ID extracted from credential provider response
|
|
38
|
+
*
|
|
39
|
+
* For credential providers, this is the userId extracted via responseFields.userId.
|
|
40
|
+
* This is passed to tool handlers via ToolExecutionContext.userId.
|
|
41
|
+
*/
|
|
42
|
+
userId?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Extended IdpTokens with usage metadata (CRED-003)
|
|
46
|
+
*/
|
|
47
|
+
export interface IdpTokensWithMetadata extends IdpTokens, TokenUsageMetadata {
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Interface for IDP token storage
|
|
51
|
+
*/
|
|
52
|
+
export interface IIdpTokenStorage {
|
|
53
|
+
/**
|
|
54
|
+
* Store IDP tokens
|
|
55
|
+
*
|
|
56
|
+
* @param userDid - User DID to associate tokens with
|
|
57
|
+
* @param provider - OAuth provider name or credential provider
|
|
58
|
+
* @param scopes - Scopes granted for these tokens
|
|
59
|
+
* @param tokens - IDP tokens to store (may include usage metadata for credentials)
|
|
60
|
+
*/
|
|
61
|
+
storeToken(userDid: string, provider: string, scopes: string[], tokens: IdpTokens | IdpTokensWithMetadata): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Retrieve IDP tokens
|
|
64
|
+
*
|
|
65
|
+
* @param userDid - User DID to retrieve tokens for
|
|
66
|
+
* @param provider - OAuth provider name or credential provider
|
|
67
|
+
* @param scopes - Scopes to retrieve tokens for
|
|
68
|
+
* @returns IDP tokens with optional usage metadata or null if not found
|
|
69
|
+
*/
|
|
70
|
+
getToken(userDid: string, provider: string, scopes: string[]): Promise<IdpTokensWithMetadata | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Delete IDP tokens
|
|
73
|
+
*
|
|
74
|
+
* @param userDid - User DID
|
|
75
|
+
* @param provider - OAuth provider name or credential provider
|
|
76
|
+
* @param scopes - Scopes
|
|
77
|
+
*/
|
|
78
|
+
deleteToken(userDid: string, provider: string, scopes: string[]): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=idp-token-storage.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idp-token-storage.interface.d.ts","sourceRoot":"","sources":["../../src/identity/idp-token-storage.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAE5C,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,SAAS,EAAE,kBAAkB;CAAG;AAE/E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;OAOG;IACH,UAAU,CACR,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,SAAS,GAAG,qBAAqB,GACxC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;;;OAOG;IACH,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC;IAEzC;;;;;;OAMG;IACH,WAAW,CACT,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IDP Token Storage Interface
|
|
4
|
+
*
|
|
5
|
+
* Platform-agnostic interface for storing and retrieving IDP tokens.
|
|
6
|
+
* Platform-specific implementations (Cloudflare KV, Node.js database, etc.)
|
|
7
|
+
* implement this interface.
|
|
8
|
+
*
|
|
9
|
+
* Supports both OAuth tokens and credential-based session tokens (CRED-003).
|
|
10
|
+
*
|
|
11
|
+
* @package @kya-os/mcp-i-core
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
//# sourceMappingURL=idp-token-storage.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idp-token-storage.interface.js","sourceRoot":"","sources":["../../src/identity/idp-token-storage.interface.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG"}
|