@kya-os/mcp-i-runtime 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime/needs-authorization.d.ts +33 -0
- package/dist/runtime/needs-authorization.d.ts.map +1 -0
- package/dist/runtime/needs-authorization.js +43 -0
- package/dist/runtime/needs-authorization.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +7 -3
- package/src/runtime/__tests__/needs-authorization.test.ts +41 -0
- package/src/runtime/needs-authorization.ts +47 -0
package/.turbo/turbo-build.log
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { MCPIRuntimeBase } from "./runtime/base";
|
|
|
10
10
|
export type { RuntimeWithAccessControl } from "./runtime/base";
|
|
11
11
|
export { CONSENT_UI_RESOURCE_URI } from "./runtime/ext-apps-constants";
|
|
12
12
|
export { SESSION_ID_PREFIX, LEGACY_SESSION_ID_PREFIX, INTERNAL_TOOL_PREFIX, LEGACY_INTERNAL_TOOL_PREFIX, WELL_KNOWN_IDENTITY_PATH, LEGACY_WELL_KNOWN_IDENTITY_PATH, recordWireForm, isInternalToolName, normalizeInternalToolName, type WireBoundary, type WireForm, } from "./wire-format";
|
|
13
|
+
export { toNeedsAuthorization } from "./runtime/needs-authorization";
|
|
13
14
|
export type { IAuditLogger } from "./runtime/audit-logger";
|
|
14
15
|
export * from "./utils";
|
|
15
16
|
export { ToolProtectionService } from "./services/tool-protection.service";
|
|
@@ -26,7 +27,7 @@ export type { SessionRegistrationServiceConfig, SessionRegistrationResult, } fro
|
|
|
26
27
|
export { OAuthConfigService } from "./services/oauth-config.service";
|
|
27
28
|
export type { OAuthConfigServiceConfig } from "./services/oauth-config.service";
|
|
28
29
|
export { OAuthService, defaultSecretResolver } from "./services/oauth-service";
|
|
29
|
-
export type { OAuthServiceConfig, SecretResolver } from "./services/oauth-service";
|
|
30
|
+
export type { OAuthServiceConfig, SecretResolver, } from "./services/oauth-service";
|
|
30
31
|
export { ToolContextBuilder } from "./services/tool-context-builder";
|
|
31
32
|
export type { ToolContextBuilderConfig } from "./services/tool-context-builder";
|
|
32
33
|
export { OAuthProviderRegistry } from "./services/oauth-provider-registry";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,aAAa,GACnB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAG/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,+BAA+B,EAC/B,cAAc,EACd,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,YAAY,EACjB,KAAK,QAAQ,GACd,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,E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+BAA+B,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EACL,MAAM,EACN,0BAA0B,EAC1B,KAAK,MAAM,EACX,KAAK,KAAK,GACX,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,mBAAmB,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,8 +20,8 @@ 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.generateResumeToken = exports.MemoryResumeTokenStore = exports.hasSensitiveScopes = exports.verifyOrHints = exports.validateHandshakeFormat = 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 = void 0;
|
|
23
|
+
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 = exports.ProviderValidator = exports.CredentialAuthModeError = exports.ConsentOnlyModeError = exports.ProviderResolver = exports.OAuthProviderRegistry = 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.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.generateResumeToken = exports.MemoryResumeTokenStore = exports.hasSensitiveScopes = exports.verifyOrHints = exports.validateHandshakeFormat = 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 = void 0;
|
|
25
25
|
// Base providers
|
|
26
26
|
var base_1 = require("./providers/base");
|
|
27
27
|
Object.defineProperty(exports, "CryptoProvider", { enumerable: true, get: function () { return base_1.CryptoProvider; } });
|
|
@@ -52,6 +52,9 @@ Object.defineProperty(exports, "LEGACY_WELL_KNOWN_IDENTITY_PATH", { enumerable:
|
|
|
52
52
|
Object.defineProperty(exports, "recordWireForm", { enumerable: true, get: function () { return wire_format_1.recordWireForm; } });
|
|
53
53
|
Object.defineProperty(exports, "isInternalToolName", { enumerable: true, get: function () { return wire_format_1.isInternalToolName; } });
|
|
54
54
|
Object.defineProperty(exports, "normalizeInternalToolName", { enumerable: true, get: function () { return wire_format_1.normalizeInternalToolName; } });
|
|
55
|
+
// C4 (#2918) 3c envelope flip — DelegationRequiredError → needs_authorization mapper.
|
|
56
|
+
var needs_authorization_1 = require("./runtime/needs-authorization");
|
|
57
|
+
Object.defineProperty(exports, "toNeedsAuthorization", { enumerable: true, get: function () { return needs_authorization_1.toNeedsAuthorization; } });
|
|
55
58
|
// Utilities
|
|
56
59
|
__exportStar(require("./utils"), exports);
|
|
57
60
|
// Tool Protection
|
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,oBAAoB,OAAA;AACpB,0HAAA,2BAA2B,OAAA;AAC3B,uHAAA,wBAAwB,OAAA;AACxB,8HAAA,+BAA+B,OAAA;AAC/B,6GAAA,cAAc,OAAA;AACd,iHAAA,kBAAkB,OAAA;AAClB,wHAAA,yBAAyB,OAAA;
|
|
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,0GA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
4
|
+
* Projects the internal `DelegationRequiredError` control-flow signal onto the
|
|
5
|
+
* ratified DIF `needs_authorization` envelope so the tool-call gate can dual-emit
|
|
6
|
+
* the canonical wire shape alongside the legacy proprietary `_meta` keys (the
|
|
7
|
+
* wire-format dual-accept thesis: read accepts both; emit moves to the new form;
|
|
8
|
+
* legacy keys stay until the telemetry-gated sunset).
|
|
9
|
+
*
|
|
10
|
+
* Envelope-flip ONLY — N-of-M step-up (`needs_approval` / `NeedsApprovalError`)
|
|
11
|
+
* is deferred to the T3-edge step-up lane (#3222) and is intentionally NOT
|
|
12
|
+
* produced here.
|
|
13
|
+
*
|
|
14
|
+
* The shape + builder are sourced from `@kya-os/contracts/runtime` (the ratified
|
|
15
|
+
* source that DIF `@kya-os/mcp` mirrors) rather than `@kya-os/mcp` directly: this
|
|
16
|
+
* package is CommonJS (`module: Node16`) and `@kya-os/mcp` is ESM-only, so a
|
|
17
|
+
* static value import would not resolve from CJS. `auth/handshake.ts` already
|
|
18
|
+
* builds `NeedsAuthorizationError` from `@kya-os/contracts/runtime` for the same
|
|
19
|
+
* reason — this mirrors that convention.
|
|
20
|
+
*/
|
|
21
|
+
import { type NeedsAuthorizationError } from "@kya-os/contracts/runtime";
|
|
22
|
+
import type { DelegationRequiredError } from "../types/tool-protection.js";
|
|
23
|
+
/**
|
|
24
|
+
* Build the DIF `needs_authorization` envelope from a `DelegationRequiredError`.
|
|
25
|
+
*
|
|
26
|
+
* @param err - the thrown delegation signal (already carries `consentUrl`,
|
|
27
|
+
* `resumeToken`, and `requiredScopes` populated at every throw site).
|
|
28
|
+
* @param expiresAtMs - resume-token expiry as **milliseconds since epoch**, the
|
|
29
|
+
* unit the contracts schema expects and that `clock.calculateExpiry()` returns
|
|
30
|
+
* (`now() + ttlSeconds * 1000`). Pass `interceptedCall.expiresAt` directly.
|
|
31
|
+
*/
|
|
32
|
+
export declare function toNeedsAuthorization(err: DelegationRequiredError, expiresAtMs: number): NeedsAuthorizationError;
|
|
33
|
+
//# sourceMappingURL=needs-authorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"needs-authorization.d.ts","sourceRoot":"","sources":["../../src/runtime/needs-authorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,uBAAuB,EAC5B,WAAW,EAAE,MAAM,GAClB,uBAAuB,CAQzB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toNeedsAuthorization = toNeedsAuthorization;
|
|
4
|
+
/**
|
|
5
|
+
* C4 (#2918) 3c envelope flip — `DelegationRequiredError` → `needs_authorization`.
|
|
6
|
+
*
|
|
7
|
+
* Projects the internal `DelegationRequiredError` control-flow signal onto the
|
|
8
|
+
* ratified DIF `needs_authorization` envelope so the tool-call gate can dual-emit
|
|
9
|
+
* the canonical wire shape alongside the legacy proprietary `_meta` keys (the
|
|
10
|
+
* wire-format dual-accept thesis: read accepts both; emit moves to the new form;
|
|
11
|
+
* legacy keys stay until the telemetry-gated sunset).
|
|
12
|
+
*
|
|
13
|
+
* Envelope-flip ONLY — N-of-M step-up (`needs_approval` / `NeedsApprovalError`)
|
|
14
|
+
* is deferred to the T3-edge step-up lane (#3222) and is intentionally NOT
|
|
15
|
+
* produced here.
|
|
16
|
+
*
|
|
17
|
+
* The shape + builder are sourced from `@kya-os/contracts/runtime` (the ratified
|
|
18
|
+
* source that DIF `@kya-os/mcp` mirrors) rather than `@kya-os/mcp` directly: this
|
|
19
|
+
* package is CommonJS (`module: Node16`) and `@kya-os/mcp` is ESM-only, so a
|
|
20
|
+
* static value import would not resolve from CJS. `auth/handshake.ts` already
|
|
21
|
+
* builds `NeedsAuthorizationError` from `@kya-os/contracts/runtime` for the same
|
|
22
|
+
* reason — this mirrors that convention.
|
|
23
|
+
*/
|
|
24
|
+
const runtime_1 = require("@kya-os/contracts/runtime");
|
|
25
|
+
/**
|
|
26
|
+
* Build the DIF `needs_authorization` envelope from a `DelegationRequiredError`.
|
|
27
|
+
*
|
|
28
|
+
* @param err - the thrown delegation signal (already carries `consentUrl`,
|
|
29
|
+
* `resumeToken`, and `requiredScopes` populated at every throw site).
|
|
30
|
+
* @param expiresAtMs - resume-token expiry as **milliseconds since epoch**, the
|
|
31
|
+
* unit the contracts schema expects and that `clock.calculateExpiry()` returns
|
|
32
|
+
* (`now() + ttlSeconds * 1000`). Pass `interceptedCall.expiresAt` directly.
|
|
33
|
+
*/
|
|
34
|
+
function toNeedsAuthorization(err, expiresAtMs) {
|
|
35
|
+
return (0, runtime_1.createNeedsAuthorizationError)({
|
|
36
|
+
message: `Authorization required for tool "${err.toolName}".`,
|
|
37
|
+
authorizationUrl: err.consentUrl ?? "",
|
|
38
|
+
resumeToken: err.resumeToken ?? "",
|
|
39
|
+
expiresAt: expiresAtMs,
|
|
40
|
+
scopes: err.requiredScopes,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=needs-authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"needs-authorization.js","sourceRoot":"","sources":["../../src/runtime/needs-authorization.ts"],"names":[],"mappings":";;AAmCA,oDAWC;AA9CD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,uDAGmC;AAGnC;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAClC,GAA4B,EAC5B,WAAmB;IAEnB,OAAO,IAAA,uCAA6B,EAAC;QACnC,OAAO,EAAE,oCAAoC,GAAG,CAAC,QAAQ,IAAI;QAC7D,gBAAgB,EAAE,GAAG,CAAC,UAAU,IAAI,EAAE;QACtC,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,EAAE;QAClC,SAAS,EAAE,WAAW;QACtB,MAAM,EAAE,GAAG,CAAC,cAAc;KAC3B,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/mcp-i-runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
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",
|
package/src/index.ts
CHANGED
|
@@ -45,6 +45,9 @@ export {
|
|
|
45
45
|
type WireForm,
|
|
46
46
|
} from "./wire-format";
|
|
47
47
|
|
|
48
|
+
// C4 (#2918) 3c envelope flip — DelegationRequiredError → needs_authorization mapper.
|
|
49
|
+
export { toNeedsAuthorization } from "./runtime/needs-authorization";
|
|
50
|
+
|
|
48
51
|
// Audit Logger Interface
|
|
49
52
|
export type { IAuditLogger } from "./runtime/audit-logger";
|
|
50
53
|
|
|
@@ -104,7 +107,10 @@ export type { OAuthConfigServiceConfig } from "./services/oauth-config.service";
|
|
|
104
107
|
// OAuth Service (Phase 1)
|
|
105
108
|
export { OAuthService, defaultSecretResolver } from "./services/oauth-service";
|
|
106
109
|
|
|
107
|
-
export type {
|
|
110
|
+
export type {
|
|
111
|
+
OAuthServiceConfig,
|
|
112
|
+
SecretResolver,
|
|
113
|
+
} from "./services/oauth-service";
|
|
108
114
|
|
|
109
115
|
// Tool Context Builder (Phase 1)
|
|
110
116
|
export { ToolContextBuilder } from "./services/tool-context-builder";
|
|
@@ -192,7 +198,6 @@ export type {
|
|
|
192
198
|
ClientMessagesConfig,
|
|
193
199
|
} from "./services/delegation-error-formatter";
|
|
194
200
|
|
|
195
|
-
|
|
196
201
|
// Base58 Utilities (for did:key encoding/decoding)
|
|
197
202
|
export { base58Encode, base58Decode, isValidBase58 } from "./utils/base58";
|
|
198
203
|
|
|
@@ -215,7 +220,6 @@ export {
|
|
|
215
220
|
getSchemaStats,
|
|
216
221
|
} from "./compliance/schema-registry";
|
|
217
222
|
|
|
218
|
-
|
|
219
223
|
// Base64 utilities for VC JWT encoding
|
|
220
224
|
export {
|
|
221
225
|
base64urlEncodeFromBytes,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C4 (#2918) 3c envelope flip — mapper unit tests.
|
|
3
|
+
*
|
|
4
|
+
* `toNeedsAuthorization` projects the internal `DelegationRequiredError` control-flow
|
|
5
|
+
* signal onto the ratified DIF `needs_authorization` envelope. Envelope-flip ONLY —
|
|
6
|
+
* N-of-M step-up (`needs_approval`) is deferred to T3-edge #3222.
|
|
7
|
+
*/
|
|
8
|
+
import { describe, it, expect } from "vitest";
|
|
9
|
+
import { isNeedsAuthorizationError } from "@kya-os/contracts/runtime";
|
|
10
|
+
import { DelegationRequiredError } from "../../types/tool-protection.js";
|
|
11
|
+
import { toNeedsAuthorization } from "../needs-authorization.js";
|
|
12
|
+
|
|
13
|
+
describe("toNeedsAuthorization", () => {
|
|
14
|
+
const makeErr = () =>
|
|
15
|
+
new DelegationRequiredError(
|
|
16
|
+
"checkout",
|
|
17
|
+
["cart:write", "payment:process"],
|
|
18
|
+
"https://consent.example.com/authorize?resume_token=abc",
|
|
19
|
+
undefined,
|
|
20
|
+
"resume_abc123"
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
it("projects DelegationRequiredError onto the ratified needs_authorization envelope", () => {
|
|
24
|
+
const expiresAt = 1_900_000_000_000; // ms epoch (calculateExpiry returns ms)
|
|
25
|
+
const out = toNeedsAuthorization(makeErr(), expiresAt);
|
|
26
|
+
|
|
27
|
+
expect(out.error).toBe("needs_authorization");
|
|
28
|
+
expect(out.message).toMatch(/checkout/);
|
|
29
|
+
expect(out.authorizationUrl).toBe(
|
|
30
|
+
"https://consent.example.com/authorize?resume_token=abc"
|
|
31
|
+
);
|
|
32
|
+
expect(out.resumeToken).toBe("resume_abc123");
|
|
33
|
+
expect(out.expiresAt).toBe(expiresAt);
|
|
34
|
+
expect(out.scopes).toEqual(["cart:write", "payment:process"]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("produces an envelope that satisfies isNeedsAuthorizationError", () => {
|
|
38
|
+
const out = toNeedsAuthorization(makeErr(), Date.now() + 1_800_000);
|
|
39
|
+
expect(isNeedsAuthorizationError(out)).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C4 (#2918) 3c envelope flip — `DelegationRequiredError` → `needs_authorization`.
|
|
3
|
+
*
|
|
4
|
+
* Projects the internal `DelegationRequiredError` control-flow signal onto the
|
|
5
|
+
* ratified DIF `needs_authorization` envelope so the tool-call gate can dual-emit
|
|
6
|
+
* the canonical wire shape alongside the legacy proprietary `_meta` keys (the
|
|
7
|
+
* wire-format dual-accept thesis: read accepts both; emit moves to the new form;
|
|
8
|
+
* legacy keys stay until the telemetry-gated sunset).
|
|
9
|
+
*
|
|
10
|
+
* Envelope-flip ONLY — N-of-M step-up (`needs_approval` / `NeedsApprovalError`)
|
|
11
|
+
* is deferred to the T3-edge step-up lane (#3222) and is intentionally NOT
|
|
12
|
+
* produced here.
|
|
13
|
+
*
|
|
14
|
+
* The shape + builder are sourced from `@kya-os/contracts/runtime` (the ratified
|
|
15
|
+
* source that DIF `@kya-os/mcp` mirrors) rather than `@kya-os/mcp` directly: this
|
|
16
|
+
* package is CommonJS (`module: Node16`) and `@kya-os/mcp` is ESM-only, so a
|
|
17
|
+
* static value import would not resolve from CJS. `auth/handshake.ts` already
|
|
18
|
+
* builds `NeedsAuthorizationError` from `@kya-os/contracts/runtime` for the same
|
|
19
|
+
* reason — this mirrors that convention.
|
|
20
|
+
*/
|
|
21
|
+
import {
|
|
22
|
+
createNeedsAuthorizationError,
|
|
23
|
+
type NeedsAuthorizationError,
|
|
24
|
+
} from "@kya-os/contracts/runtime";
|
|
25
|
+
import type { DelegationRequiredError } from "../types/tool-protection.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Build the DIF `needs_authorization` envelope from a `DelegationRequiredError`.
|
|
29
|
+
*
|
|
30
|
+
* @param err - the thrown delegation signal (already carries `consentUrl`,
|
|
31
|
+
* `resumeToken`, and `requiredScopes` populated at every throw site).
|
|
32
|
+
* @param expiresAtMs - resume-token expiry as **milliseconds since epoch**, the
|
|
33
|
+
* unit the contracts schema expects and that `clock.calculateExpiry()` returns
|
|
34
|
+
* (`now() + ttlSeconds * 1000`). Pass `interceptedCall.expiresAt` directly.
|
|
35
|
+
*/
|
|
36
|
+
export function toNeedsAuthorization(
|
|
37
|
+
err: DelegationRequiredError,
|
|
38
|
+
expiresAtMs: number
|
|
39
|
+
): NeedsAuthorizationError {
|
|
40
|
+
return createNeedsAuthorizationError({
|
|
41
|
+
message: `Authorization required for tool "${err.toolName}".`,
|
|
42
|
+
authorizationUrl: err.consentUrl ?? "",
|
|
43
|
+
resumeToken: err.resumeToken ?? "",
|
|
44
|
+
expiresAt: expiresAtMs,
|
|
45
|
+
scopes: err.requiredScopes,
|
|
46
|
+
});
|
|
47
|
+
}
|