@kya-os/mcp-i-runtime 1.2.1 → 1.2.2
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/services/auth-type-satisfies.d.ts +41 -0
- package/dist/services/auth-type-satisfies.d.ts.map +1 -1
- package/dist/services/auth-type-satisfies.js +53 -0
- package/dist/services/auth-type-satisfies.js.map +1 -1
- package/dist/services/tool-context-builder.d.ts.map +1 -1
- package/dist/services/tool-context-builder.js +13 -0
- package/dist/services/tool-context-builder.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/services/__tests__/auth-type-satisfies.test.ts +62 -1
- package/src/services/__tests__/tool-context-builder-authtype.test.ts +75 -0
- package/src/services/auth-type-satisfies.ts +55 -0
- package/src/services/tool-context-builder.ts +22 -1
package/.turbo/turbo-build.log
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export { OAuthService, defaultSecretResolver } from "./services/oauth-service";
|
|
|
31
31
|
export type { OAuthServiceConfig, SecretResolver, } from "./services/oauth-service";
|
|
32
32
|
export { ToolContextBuilder } from "./services/tool-context-builder";
|
|
33
33
|
export type { ToolContextBuilderConfig } from "./services/tool-context-builder";
|
|
34
|
-
export { authTypeSatisfies, normalizeAuthType, } from "./services/auth-type-satisfies";
|
|
34
|
+
export { authTypeSatisfies, normalizeAuthType, isUnsatisfiableAuthType, MINTABLE_AUTH_TYPES, } from "./services/auth-type-satisfies";
|
|
35
35
|
export { OAuthProviderRegistry } from "./services/oauth-provider-registry";
|
|
36
36
|
export { ProviderResolver, ConsentOnlyModeError, CredentialAuthModeError, } from "./services/provider-resolver";
|
|
37
37
|
export { ProviderValidator, ProviderValidationError, } from "./services/provider-validator";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1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AmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,9 +20,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.generateResumeToken = exports.MemoryResumeTokenStore = exports.hasSensitiveScopes = void 0;
|
|
23
|
+
exports.ProviderValidator = exports.CredentialAuthModeError = exports.ConsentOnlyModeError = exports.ProviderResolver = exports.OAuthProviderRegistry = exports.MINTABLE_AUTH_TYPES = exports.isUnsatisfiableAuthType = exports.normalizeAuthType = exports.authTypeSatisfies = exports.ToolContextBuilder = exports.defaultSecretResolver = exports.OAuthService = exports.OAuthConfigService = exports.createSessionRegistrationService = exports.SessionRegistrationService = exports.authorizationMatches = exports.AccessControlApiService = exports.ProofVerifier = exports.CryptoService = exports.PolicyService = exports.ToolProtectionService = exports.terminalForToolResult = exports.terminalForToolError = exports.recordRuntimeDelegationAudit = exports.recordRuntimeConsentAudit = exports.createHmacRuntimeAuditContextFactory = exports.beginRuntimeToolAudit = exports.attachRuntimeAuditMetadata = exports.RuntimeToolAuditInvocation = exports.toNeedsAuthorization = exports.normalizeInternalToolName = exports.isInternalToolName = exports.recordWireForm = exports.LEGACY_WELL_KNOWN_IDENTITY_PATH = exports.WELL_KNOWN_IDENTITY_PATH = exports.LEGACY_INTERNAL_TOOL_PREFIX = exports.INTERNAL_TOOL_PREFIX = exports.LEGACY_SESSION_ID_PREFIX = exports.SESSION_ID_PREFIX = exports.CONSENT_UI_RESOURCE_URI = exports.MCPIRuntimeBase = exports.MemoryIdentityProvider = exports.MemoryNonceCacheProvider = exports.MemoryStorageProvider = exports.IdentityProvider = exports.NonceCacheProvider = exports.StorageProvider = exports.FetchProvider = exports.ClockProvider = exports.CryptoProvider = void 0;
|
|
24
|
+
exports.createHandshakeRequest = exports.SessionManager = exports.extractCanonicalData = exports.createProofResponse = exports.ProofGenerator = exports.createDefaultConsoleLogger = exports.logger = exports.IdpTokenResolver = exports.UserDidManager = exports.isPolicyEnabled = exports.hasMergedPolicy = exports.extractPolicy = exports.getPolicy = exports.hasMergedToolProtections = exports.extractToolProtections = exports.getToolProtection = exports.fetchRemoteConfig = exports.bytesToBase64 = exports.base64urlDecodeToString = exports.base64urlDecodeToBytes = exports.base64urlEncodeFromString = exports.base64urlEncodeFromBytes = exports.getSchemaStats = exports.getCriticalSchemas = exports.getSchemaById = exports.getSchemasByCategory = exports.getAllSchemas = exports.SCHEMA_REGISTRY = exports.createSchemaVerifier = exports.SchemaVerifier = exports.isValidBase58 = exports.base58Decode = exports.base58Encode = exports.createDelegationErrorFormatter = exports.DelegationErrorFormatter = exports.OAuthRequiredError = exports.DelegationRequiredError = exports.NoOpToolProtectionCache = exports.InMemoryToolProtectionCache = exports.createProofVerificationError = exports.PROOF_VERIFICATION_ERROR_CODES = exports.ProofVerificationError = exports.migrateLegacyKeys = exports.StorageKeyHelpers = exports.createStorageProviders = exports.NoOpOAuthConfigCache = exports.InMemoryOAuthConfigCache = exports.BatchDelegationService = exports.OAuthTokenRetrievalService = exports.ProviderValidationError = void 0;
|
|
25
|
+
exports.generateResumeToken = exports.MemoryResumeTokenStore = exports.hasSensitiveScopes = exports.verifyOrHints = exports.validateHandshakeFormat = void 0;
|
|
26
26
|
// Base providers
|
|
27
27
|
var base_1 = require("./providers/base");
|
|
28
28
|
Object.defineProperty(exports, "CryptoProvider", { enumerable: true, get: function () { return base_1.CryptoProvider; } });
|
|
@@ -105,6 +105,8 @@ Object.defineProperty(exports, "ToolContextBuilder", { enumerable: true, get: fu
|
|
|
105
105
|
var auth_type_satisfies_1 = require("./services/auth-type-satisfies");
|
|
106
106
|
Object.defineProperty(exports, "authTypeSatisfies", { enumerable: true, get: function () { return auth_type_satisfies_1.authTypeSatisfies; } });
|
|
107
107
|
Object.defineProperty(exports, "normalizeAuthType", { enumerable: true, get: function () { return auth_type_satisfies_1.normalizeAuthType; } });
|
|
108
|
+
Object.defineProperty(exports, "isUnsatisfiableAuthType", { enumerable: true, get: function () { return auth_type_satisfies_1.isUnsatisfiableAuthType; } });
|
|
109
|
+
Object.defineProperty(exports, "MINTABLE_AUTH_TYPES", { enumerable: true, get: function () { return auth_type_satisfies_1.MINTABLE_AUTH_TYPES; } });
|
|
108
110
|
// OAuth Provider Registry (Phase 2)
|
|
109
111
|
var oauth_provider_registry_1 = require("./services/oauth-provider-registry");
|
|
110
112
|
Object.defineProperty(exports, "OAuthProviderRegistry", { enumerable: true, get: function () { return oauth_provider_registry_1.OAuthProviderRegistry; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;AAEH,iBAAiB;AACjB,yCAQ0B;AAPxB,sGAAA,cAAc,OAAA;AACd,qGAAA,aAAa,OAAA;AACb,qGAAA,aAAa,OAAA;AACb,uGAAA,eAAe,OAAA;AACf,0GAAA,kBAAkB,OAAA;AAClB,wGAAA,gBAAgB,OAAA;AAIlB,mBAAmB;AACnB,6CAI4B;AAH1B,+GAAA,qBAAqB,OAAA;AACrB,kHAAA,wBAAwB,OAAA;AACxB,gHAAA,sBAAsB,OAAA;AAGxB,UAAU;AACV,uCAAiD;AAAxC,uGAAA,eAAe,OAAA;AAGxB,6BAA6B;AAC7B,mEAAuE;AAA9D,6HAAA,uBAAuB,OAAA;AAEhC,4CAA4C;AAC5C,6CAYuB;AAXrB,gHAAA,iBAAiB,OAAA;AACjB,uHAAA,wBAAwB,OAAA;AACxB,mHAAA,oB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AApD,kHAAA,cAAc,OAAA;AAQvB,4DAA4D;AAC5D,oEAAiE;AAAxD,sHAAA,gBAAgB,OAAA;AAQzB,mCAAmC;AACnC,qCAKmB;AAJjB,iGAAA,MAAM,OAAA;AACN,qHAAA,0BAA0B,OAAA;AAK5B,sEAAsE;AACtE,iCAQiB;AAPf,uGAAA,cAAc,OAAA;AACd,4GAAA,mBAAmB,OAAA;AACnB,6GAAA,oBAAoB,OAAA;AAOtB,wEAAwE;AACxE,qCAMmB;AALjB,yGAAA,cAAc,OAAA;AACd,iHAAA,sBAAsB,OAAA;AACtB,kHAAA,uBAAuB,OAAA;AAKzB,oEAAoE;AACpE,+BAWgB;AAVd,qGAAA,aAAa,OAAA;AACb,0GAAA,kBAAkB,OAAA;AAClB,8GAAA,sBAAsB,OAAA;AACtB,2GAAA,mBAAmB,OAAA"}
|
|
@@ -90,4 +90,45 @@ export declare function normalizeAuthType(type: string | undefined | null): stri
|
|
|
90
90
|
* @returns `true` iff both types are present and equal after normalization.
|
|
91
91
|
*/
|
|
92
92
|
export declare function authTypeSatisfies(delegationType: string | undefined | null, requiredType: string | undefined | null): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* The normalized authorization types the mint side can actually produce today.
|
|
95
|
+
*
|
|
96
|
+
* Every delegation is minted with one of these three:
|
|
97
|
+
* - `password` — the credential clickwrap, which rewrites `provider_type` to
|
|
98
|
+
* PASSWORD for EVERY credential provider (`consent.service.ts`);
|
|
99
|
+
* - `oauth2` — the OAuth callback, which persists it as a literal;
|
|
100
|
+
* - `none` — the pure consent-only branch.
|
|
101
|
+
*
|
|
102
|
+
* This is deliberately about what is MINTED, not what is declarable: the
|
|
103
|
+
* `AUTHORIZATION_TYPES` contract also allows `mdl`, `idv`,
|
|
104
|
+
* `verifiable_credential`, `webauthn` and `siwe`.
|
|
105
|
+
*/
|
|
106
|
+
export declare const MINTABLE_AUTH_TYPES: ReadonlySet<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Whether a tool's required authorization type is one that no mint can ever
|
|
109
|
+
* produce — meaning the delegation gate can never be satisfied and the tool
|
|
110
|
+
* will re-challenge forever rather than once.
|
|
111
|
+
*
|
|
112
|
+
* Under strict normalized equality (the locked decision), a requirement
|
|
113
|
+
* outside {@link MINTABLE_AUTH_TYPES} is unsatisfiable by construction: no
|
|
114
|
+
* delegation carrying such a type is ever written, so `authTypeSatisfies`
|
|
115
|
+
* cannot return true for it. Before the auth-type gate existed these tools
|
|
116
|
+
* authorized on mere delegation presence, so this is a behaviour change that
|
|
117
|
+
* presents to a user as an inexplicable auth loop.
|
|
118
|
+
*
|
|
119
|
+
* This exists purely so the enforcement gates can SAY so in their logs. It
|
|
120
|
+
* makes no authorization decision and must never be used to relax one —
|
|
121
|
+
* treating "unsatisfiable" as "allow" would reopen exactly the bypass the
|
|
122
|
+
* gate closes.
|
|
123
|
+
*
|
|
124
|
+
* `apikey` is intentionally NOT special-cased here: api-key tools are
|
|
125
|
+
* resolved by a separate vault branch that returns before either delegation
|
|
126
|
+
* gate, so this predicate is never consulted for them.
|
|
127
|
+
*
|
|
128
|
+
* @param requiredType - The tool's required authorization type.
|
|
129
|
+
* @returns `true` if the requirement can never be met by any minted
|
|
130
|
+
* delegation. Nullish/unknown input returns `false` — absence of a
|
|
131
|
+
* requirement is not an unsatisfiable requirement.
|
|
132
|
+
*/
|
|
133
|
+
export declare function isUnsatisfiableAuthType(requiredType: string | undefined | null): boolean;
|
|
93
134
|
//# sourceMappingURL=auth-type-satisfies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-type-satisfies.d.ts","sourceRoot":"","sources":["../../src/services/auth-type-satisfies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC9B,MAAM,GAAG,SAAS,CAmBpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EACzC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GACtC,OAAO,CAgBT"}
|
|
1
|
+
{"version":3,"file":"auth-type-satisfies.d.ts","sourceRoot":"","sources":["../../src/services/auth-type-satisfies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC9B,MAAM,GAAG,SAAS,CAmBpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EACzC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GACtC,OAAO,CAgBT;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAIlD,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GACtC,OAAO,CAMT"}
|
|
@@ -27,8 +27,10 @@
|
|
|
27
27
|
* @module @kya-os/mcp-i-runtime/services/auth-type-satisfies
|
|
28
28
|
*/
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.MINTABLE_AUTH_TYPES = void 0;
|
|
30
31
|
exports.normalizeAuthType = normalizeAuthType;
|
|
31
32
|
exports.authTypeSatisfies = authTypeSatisfies;
|
|
33
|
+
exports.isUnsatisfiableAuthType = isUnsatisfiableAuthType;
|
|
32
34
|
/**
|
|
33
35
|
* Fold deprecated authorization-type aliases to their canonical form and
|
|
34
36
|
* normalize casing/whitespace.
|
|
@@ -124,4 +126,55 @@ function authTypeSatisfies(delegationType, requiredType) {
|
|
|
124
126
|
}
|
|
125
127
|
return normalizedDelegationType === normalizedRequiredType;
|
|
126
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* The normalized authorization types the mint side can actually produce today.
|
|
131
|
+
*
|
|
132
|
+
* Every delegation is minted with one of these three:
|
|
133
|
+
* - `password` — the credential clickwrap, which rewrites `provider_type` to
|
|
134
|
+
* PASSWORD for EVERY credential provider (`consent.service.ts`);
|
|
135
|
+
* - `oauth2` — the OAuth callback, which persists it as a literal;
|
|
136
|
+
* - `none` — the pure consent-only branch.
|
|
137
|
+
*
|
|
138
|
+
* This is deliberately about what is MINTED, not what is declarable: the
|
|
139
|
+
* `AUTHORIZATION_TYPES` contract also allows `mdl`, `idv`,
|
|
140
|
+
* `verifiable_credential`, `webauthn` and `siwe`.
|
|
141
|
+
*/
|
|
142
|
+
exports.MINTABLE_AUTH_TYPES = new Set([
|
|
143
|
+
"password",
|
|
144
|
+
"oauth2",
|
|
145
|
+
"none",
|
|
146
|
+
]);
|
|
147
|
+
/**
|
|
148
|
+
* Whether a tool's required authorization type is one that no mint can ever
|
|
149
|
+
* produce — meaning the delegation gate can never be satisfied and the tool
|
|
150
|
+
* will re-challenge forever rather than once.
|
|
151
|
+
*
|
|
152
|
+
* Under strict normalized equality (the locked decision), a requirement
|
|
153
|
+
* outside {@link MINTABLE_AUTH_TYPES} is unsatisfiable by construction: no
|
|
154
|
+
* delegation carrying such a type is ever written, so `authTypeSatisfies`
|
|
155
|
+
* cannot return true for it. Before the auth-type gate existed these tools
|
|
156
|
+
* authorized on mere delegation presence, so this is a behaviour change that
|
|
157
|
+
* presents to a user as an inexplicable auth loop.
|
|
158
|
+
*
|
|
159
|
+
* This exists purely so the enforcement gates can SAY so in their logs. It
|
|
160
|
+
* makes no authorization decision and must never be used to relax one —
|
|
161
|
+
* treating "unsatisfiable" as "allow" would reopen exactly the bypass the
|
|
162
|
+
* gate closes.
|
|
163
|
+
*
|
|
164
|
+
* `apikey` is intentionally NOT special-cased here: api-key tools are
|
|
165
|
+
* resolved by a separate vault branch that returns before either delegation
|
|
166
|
+
* gate, so this predicate is never consulted for them.
|
|
167
|
+
*
|
|
168
|
+
* @param requiredType - The tool's required authorization type.
|
|
169
|
+
* @returns `true` if the requirement can never be met by any minted
|
|
170
|
+
* delegation. Nullish/unknown input returns `false` — absence of a
|
|
171
|
+
* requirement is not an unsatisfiable requirement.
|
|
172
|
+
*/
|
|
173
|
+
function isUnsatisfiableAuthType(requiredType) {
|
|
174
|
+
const normalized = normalizeAuthType(requiredType);
|
|
175
|
+
if (normalized === undefined) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
return !exports.MINTABLE_AUTH_TYPES.has(normalized);
|
|
179
|
+
}
|
|
127
180
|
//# sourceMappingURL=auth-type-satisfies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-type-satisfies.js","sourceRoot":"","sources":["../../src/services/auth-type-satisfies.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG
|
|
1
|
+
{"version":3,"file":"auth-type-satisfies.js","sourceRoot":"","sources":["../../src/services/auth-type-satisfies.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;AA6BH,8CAqBC;AAsCD,8CAmBC;AA+CD,0DAQC;AAhKD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,iBAAiB,CAC/B,IAA+B;IAE/B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC1C,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QAC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context-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-context-builder.d.ts","sourceRoot":"","sources":["../../src/services/tool-context-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAY/D,MAAM,WAAW,wBAAwB;IACvC,4DAA4D;IAC5D,aAAa,EAAE,gBAAgB,CAAC;IAEhC,gEAAgE;IAChE,aAAa,EAAE,kBAAkB,CAAC;IAElC,gEAAgE;IAChE,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAElB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpD;AAED;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAEZ;gBAEU,MAAM,EAAE,wBAAwB;IAU5C;;;;;;;;;;;;;;OAcG;IACG,YAAY,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,cAAc,EAAE,cAAc,GAAG,IAAI,EACrC,2BAA2B,CAAC,EAAE,MAAM,GACnC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IA+K5C;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,gBAAgB;IA2CxB;;;;;;;OAOG;YACW,eAAe;CAsB9B"}
|
|
@@ -129,6 +129,19 @@ class ToolContextBuilder {
|
|
|
129
129
|
requiredAuthType,
|
|
130
130
|
delegationAuthorizationType: delegationAuthorizationType ?? null,
|
|
131
131
|
});
|
|
132
|
+
// Distinguish "re-authenticate and this resolves" from "no mint can
|
|
133
|
+
// ever satisfy this, so the user is in an infinite loop". Without
|
|
134
|
+
// this, an unsatisfiable requirement is indistinguishable from a
|
|
135
|
+
// normal re-challenge in the logs and presents as an inexplicable
|
|
136
|
+
// auth loop. Diagnostic only — the decision above is unchanged.
|
|
137
|
+
if ((0, auth_type_satisfies_js_1.isUnsatisfiableAuthType)(requiredAuthType)) {
|
|
138
|
+
this.config.logger("[ToolContextBuilder] MISCONFIGURATION: tool requires an authorization type no delegation mint can produce - this tool will re-challenge forever", {
|
|
139
|
+
toolName,
|
|
140
|
+
requiredAuthType,
|
|
141
|
+
mintableAuthTypes: [...auth_type_satisfies_js_1.MINTABLE_AUTH_TYPES],
|
|
142
|
+
hint: "Set the tool's authorization.type to one of the mintable types, or add mint support for the required type.",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
132
145
|
}
|
|
133
146
|
// No (satisfying) delegation token - throw OAuthRequiredError to trigger auth flow
|
|
134
147
|
this.config.logger("[ToolContextBuilder] Token not available, throwing OAuthRequiredError", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-context-builder.js","sourceRoot":"","sources":["../../src/services/tool-context-builder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAQH,8EAAsE;AACtE,iEAGgC;AAChC,
|
|
1
|
+
{"version":3,"file":"tool-context-builder.js","sourceRoot":"","sources":["../../src/services/tool-context-builder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAQH,8EAAsE;AACtE,iEAGgC;AAChC,qEAIkC;AAmBlC;;;;;;GAMG;AACH,MAAa,kBAAkB;IACrB,MAAM,CAEZ;IAEF,YAAY,MAAgC;QAC1C,IAAI,CAAC,MAAM,GAAG;YACZ,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;SACpC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,YAAY,CAChB,QAAgB,EAChB,OAA2B,EAC3B,SAA6B,EAC7B,eAAmC,EACnC,cAAqC,EACrC,2BAAoC;QAEpC,wDAAwD;QACxD,IAAI,CAAC,cAAc,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACxD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,mDAAmD;QACnD,oEAAoE;QACpE,IAAI,QAAgB,CAAC;QACrB,IAAI,CAAC;YACH,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,kEAAkE;YAClE,8EAA8E;YAC9E,IACE,KAAK,YAAY,2CAAoB;gBACrC,KAAK,YAAY,8CAAuB,EACxC,CAAC;gBACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAChB,8DAA8D,EAC9D;oBACE,QAAQ;oBACR,SAAS,EAAE,KAAK,CAAC,I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,gCAAgC;QAC/C,CAAC;IACH,CAAC;CACF;AA1SD,gDA0SC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/mcp-i-runtime",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Shared product-runtime layer for the MCP-I framework (Node + Cloudflare adapters). Protocol types/values live in @kya-os/mcp (DIF).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Dylan Hobbs",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@kya-os/contracts": "^1.10.
|
|
62
|
+
"@kya-os/contracts": "^1.10.1",
|
|
63
63
|
"@kya-os/mcp": "1.11.0",
|
|
64
64
|
"jose": "^5.6.3",
|
|
65
65
|
"json-canonicalize": "^2.0.0",
|
package/src/index.ts
CHANGED
|
@@ -145,6 +145,8 @@ export type { ToolContextBuilderConfig } from "./services/tool-context-builder";
|
|
|
145
145
|
export {
|
|
146
146
|
authTypeSatisfies,
|
|
147
147
|
normalizeAuthType,
|
|
148
|
+
isUnsatisfiableAuthType,
|
|
149
|
+
MINTABLE_AUTH_TYPES,
|
|
148
150
|
} from "./services/auth-type-satisfies";
|
|
149
151
|
|
|
150
152
|
// OAuth Provider Registry (Phase 2)
|
|
@@ -17,7 +17,12 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { describe, it, expect } from "vitest";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
authTypeSatisfies,
|
|
22
|
+
normalizeAuthType,
|
|
23
|
+
isUnsatisfiableAuthType,
|
|
24
|
+
MINTABLE_AUTH_TYPES,
|
|
25
|
+
} from "../auth-type-satisfies";
|
|
21
26
|
|
|
22
27
|
describe("normalizeAuthType", () => {
|
|
23
28
|
it("returns undefined for undefined", () => {
|
|
@@ -230,3 +235,59 @@ describe("authTypeSatisfies", () => {
|
|
|
230
235
|
}
|
|
231
236
|
});
|
|
232
237
|
});
|
|
238
|
+
|
|
239
|
+
describe("isUnsatisfiableAuthType", () => {
|
|
240
|
+
// Diagnostic predicate only — it must never influence an authorization
|
|
241
|
+
// decision. It exists so the enforcement gates can distinguish "re-auth
|
|
242
|
+
// fixes this" from "no mint can ever satisfy this, you are in a loop".
|
|
243
|
+
|
|
244
|
+
it("is false for the types a mint can actually produce", () => {
|
|
245
|
+
expect(isUnsatisfiableAuthType("password")).toBe(false);
|
|
246
|
+
expect(isUnsatisfiableAuthType("oauth2")).toBe(false);
|
|
247
|
+
expect(isUnsatisfiableAuthType("none")).toBe(false);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("folds deprecated aliases before deciding", () => {
|
|
251
|
+
// `oauth` normalizes to `oauth2`, which IS mintable — so this must not be
|
|
252
|
+
// reported as unsatisfiable.
|
|
253
|
+
expect(isUnsatisfiableAuthType("oauth")).toBe(false);
|
|
254
|
+
// `credential` normalizes to `verifiable_credential`, which is NOT.
|
|
255
|
+
expect(isUnsatisfiableAuthType("credential")).toBe(true);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it("is true for declarable-but-never-minted types", () => {
|
|
259
|
+
for (const type of [
|
|
260
|
+
"mdl",
|
|
261
|
+
"idv",
|
|
262
|
+
"verifiable_credential",
|
|
263
|
+
"webauthn",
|
|
264
|
+
"siwe",
|
|
265
|
+
]) {
|
|
266
|
+
expect(isUnsatisfiableAuthType(type)).toBe(true);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it("is true for apikey as a bare string, which is safe because api-key tools never reach this gate", () => {
|
|
271
|
+
// Documented explicitly so a future reader does not "fix" this: api-key
|
|
272
|
+
// tools are resolved by a separate vault branch that returns before the
|
|
273
|
+
// delegation gate, so the predicate is never consulted for them.
|
|
274
|
+
expect(isUnsatisfiableAuthType("apikey")).toBe(true);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("is false for nullish/empty input — no requirement is not an unsatisfiable requirement", () => {
|
|
278
|
+
expect(isUnsatisfiableAuthType(undefined)).toBe(false);
|
|
279
|
+
expect(isUnsatisfiableAuthType(null)).toBe(false);
|
|
280
|
+
expect(isUnsatisfiableAuthType("")).toBe(false);
|
|
281
|
+
expect(isUnsatisfiableAuthType(" ")).toBe(false);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it("agrees with authTypeSatisfies: nothing mintable can satisfy an unsatisfiable requirement", () => {
|
|
285
|
+
// The property that makes the diagnostic true rather than a guess.
|
|
286
|
+
for (const required of ["mdl", "idv", "verifiable_credential", "webauthn", "siwe"]) {
|
|
287
|
+
expect(isUnsatisfiableAuthType(required)).toBe(true);
|
|
288
|
+
for (const minted of MINTABLE_AUTH_TYPES) {
|
|
289
|
+
expect(authTypeSatisfies(minted, required)).toBe(false);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
});
|
|
@@ -164,4 +164,79 @@ describe("ToolContextBuilder — delegation auth-type enforcement (B3)", () => {
|
|
|
164
164
|
)
|
|
165
165
|
).rejects.toThrow(OAuthRequiredError);
|
|
166
166
|
});
|
|
167
|
+
|
|
168
|
+
describe("unsatisfiable-requirement diagnostic", () => {
|
|
169
|
+
// A tool whose required type no mint can produce re-challenges forever.
|
|
170
|
+
// The gate cannot fix that (strict equality is the locked decision), but it
|
|
171
|
+
// must SAY so — otherwise the operator sees an inexplicable auth loop.
|
|
172
|
+
|
|
173
|
+
const mdlTool: ToolProtection = {
|
|
174
|
+
requiresDelegation: true,
|
|
175
|
+
requiredScopes: ["read:user"],
|
|
176
|
+
authorization: { type: "mdl" } as ToolProtection["authorization"],
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
function buildWithLogger(logger: (msg: string, data?: unknown) => void) {
|
|
180
|
+
return new ToolContextBuilder({
|
|
181
|
+
tokenResolver: mockTokenResolver,
|
|
182
|
+
configService: mockConfigService,
|
|
183
|
+
providerResolver: mockProviderResolver,
|
|
184
|
+
projectId: "proj-123",
|
|
185
|
+
logger,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
it("logs a MISCONFIGURATION line when the required type can never be minted", async () => {
|
|
190
|
+
const lines: string[] = [];
|
|
191
|
+
const builderWithLog = buildWithLogger((msg) => lines.push(msg));
|
|
192
|
+
|
|
193
|
+
await expect(
|
|
194
|
+
builderWithLog.buildContext(
|
|
195
|
+
"gated-tool",
|
|
196
|
+
"did:key:z6MkUser",
|
|
197
|
+
"session-123",
|
|
198
|
+
"delegation-token-oauth",
|
|
199
|
+
mdlTool,
|
|
200
|
+
"oauth2"
|
|
201
|
+
)
|
|
202
|
+
).rejects.toThrow(OAuthRequiredError);
|
|
203
|
+
|
|
204
|
+
expect(lines.some((l) => l.includes("MISCONFIGURATION"))).toBe(true);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("does NOT log it for an ordinary mismatch that re-authenticating can fix", async () => {
|
|
208
|
+
const lines: string[] = [];
|
|
209
|
+
const builderWithLog = buildWithLogger((msg) => lines.push(msg));
|
|
210
|
+
|
|
211
|
+
// oauth2-gated tool presented a `none` delegation: a real mismatch, but
|
|
212
|
+
// the user CAN resolve it by authenticating via OAuth.
|
|
213
|
+
await expect(
|
|
214
|
+
builderWithLog.buildContext(
|
|
215
|
+
"gated-tool",
|
|
216
|
+
"did:key:z6MkUser",
|
|
217
|
+
"session-123",
|
|
218
|
+
"delegation-token-anon",
|
|
219
|
+
oauthTool,
|
|
220
|
+
"none"
|
|
221
|
+
)
|
|
222
|
+
).rejects.toThrow(OAuthRequiredError);
|
|
223
|
+
|
|
224
|
+
expect(lines.some((l) => l.includes("MISCONFIGURATION"))).toBe(false);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it("still REJECTS — the diagnostic must not relax the decision", async () => {
|
|
228
|
+
// Guards against a future "unsatisfiable, so let it through" "fix",
|
|
229
|
+
// which would reopen the bypass the gate exists to close.
|
|
230
|
+
await expect(
|
|
231
|
+
buildWithLogger(() => {}).buildContext(
|
|
232
|
+
"gated-tool",
|
|
233
|
+
"did:key:z6MkUser",
|
|
234
|
+
"session-123",
|
|
235
|
+
"delegation-token-oauth",
|
|
236
|
+
mdlTool,
|
|
237
|
+
"oauth2"
|
|
238
|
+
)
|
|
239
|
+
).rejects.toThrow(OAuthRequiredError);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
167
242
|
});
|
|
@@ -132,3 +132,58 @@ export function authTypeSatisfies(
|
|
|
132
132
|
|
|
133
133
|
return normalizedDelegationType === normalizedRequiredType;
|
|
134
134
|
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The normalized authorization types the mint side can actually produce today.
|
|
138
|
+
*
|
|
139
|
+
* Every delegation is minted with one of these three:
|
|
140
|
+
* - `password` — the credential clickwrap, which rewrites `provider_type` to
|
|
141
|
+
* PASSWORD for EVERY credential provider (`consent.service.ts`);
|
|
142
|
+
* - `oauth2` — the OAuth callback, which persists it as a literal;
|
|
143
|
+
* - `none` — the pure consent-only branch.
|
|
144
|
+
*
|
|
145
|
+
* This is deliberately about what is MINTED, not what is declarable: the
|
|
146
|
+
* `AUTHORIZATION_TYPES` contract also allows `mdl`, `idv`,
|
|
147
|
+
* `verifiable_credential`, `webauthn` and `siwe`.
|
|
148
|
+
*/
|
|
149
|
+
export const MINTABLE_AUTH_TYPES: ReadonlySet<string> = new Set([
|
|
150
|
+
"password",
|
|
151
|
+
"oauth2",
|
|
152
|
+
"none",
|
|
153
|
+
]);
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Whether a tool's required authorization type is one that no mint can ever
|
|
157
|
+
* produce — meaning the delegation gate can never be satisfied and the tool
|
|
158
|
+
* will re-challenge forever rather than once.
|
|
159
|
+
*
|
|
160
|
+
* Under strict normalized equality (the locked decision), a requirement
|
|
161
|
+
* outside {@link MINTABLE_AUTH_TYPES} is unsatisfiable by construction: no
|
|
162
|
+
* delegation carrying such a type is ever written, so `authTypeSatisfies`
|
|
163
|
+
* cannot return true for it. Before the auth-type gate existed these tools
|
|
164
|
+
* authorized on mere delegation presence, so this is a behaviour change that
|
|
165
|
+
* presents to a user as an inexplicable auth loop.
|
|
166
|
+
*
|
|
167
|
+
* This exists purely so the enforcement gates can SAY so in their logs. It
|
|
168
|
+
* makes no authorization decision and must never be used to relax one —
|
|
169
|
+
* treating "unsatisfiable" as "allow" would reopen exactly the bypass the
|
|
170
|
+
* gate closes.
|
|
171
|
+
*
|
|
172
|
+
* `apikey` is intentionally NOT special-cased here: api-key tools are
|
|
173
|
+
* resolved by a separate vault branch that returns before either delegation
|
|
174
|
+
* gate, so this predicate is never consulted for them.
|
|
175
|
+
*
|
|
176
|
+
* @param requiredType - The tool's required authorization type.
|
|
177
|
+
* @returns `true` if the requirement can never be met by any minted
|
|
178
|
+
* delegation. Nullish/unknown input returns `false` — absence of a
|
|
179
|
+
* requirement is not an unsatisfiable requirement.
|
|
180
|
+
*/
|
|
181
|
+
export function isUnsatisfiableAuthType(
|
|
182
|
+
requiredType: string | undefined | null
|
|
183
|
+
): boolean {
|
|
184
|
+
const normalized = normalizeAuthType(requiredType);
|
|
185
|
+
if (normalized === undefined) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return !MINTABLE_AUTH_TYPES.has(normalized);
|
|
189
|
+
}
|
|
@@ -21,7 +21,11 @@ import {
|
|
|
21
21
|
ConsentOnlyModeError,
|
|
22
22
|
CredentialAuthModeError,
|
|
23
23
|
} from "./provider-resolver.js";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
authTypeSatisfies,
|
|
26
|
+
isUnsatisfiableAuthType,
|
|
27
|
+
MINTABLE_AUTH_TYPES,
|
|
28
|
+
} from "./auth-type-satisfies.js";
|
|
25
29
|
|
|
26
30
|
export interface ToolContextBuilderConfig {
|
|
27
31
|
/** IDP token resolver for resolving tokens from User DID */
|
|
@@ -187,6 +191,23 @@ export class ToolContextBuilder {
|
|
|
187
191
|
delegationAuthorizationType: delegationAuthorizationType ?? null,
|
|
188
192
|
}
|
|
189
193
|
);
|
|
194
|
+
|
|
195
|
+
// Distinguish "re-authenticate and this resolves" from "no mint can
|
|
196
|
+
// ever satisfy this, so the user is in an infinite loop". Without
|
|
197
|
+
// this, an unsatisfiable requirement is indistinguishable from a
|
|
198
|
+
// normal re-challenge in the logs and presents as an inexplicable
|
|
199
|
+
// auth loop. Diagnostic only — the decision above is unchanged.
|
|
200
|
+
if (isUnsatisfiableAuthType(requiredAuthType)) {
|
|
201
|
+
this.config.logger(
|
|
202
|
+
"[ToolContextBuilder] MISCONFIGURATION: tool requires an authorization type no delegation mint can produce - this tool will re-challenge forever",
|
|
203
|
+
{
|
|
204
|
+
toolName,
|
|
205
|
+
requiredAuthType,
|
|
206
|
+
mintableAuthTypes: [...MINTABLE_AUTH_TYPES],
|
|
207
|
+
hint: "Set the tool's authorization.type to one of the mintable types, or add mint support for the required type.",
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
}
|
|
190
211
|
}
|
|
191
212
|
|
|
192
213
|
// No (satisfying) delegation token - throw OAuthRequiredError to trigger auth flow
|