@heddleagent/execution-host-client 6.3.0 → 6.5.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.
Files changed (96) hide show
  1. package/README.md +121 -20
  2. package/dist/coordinator/contracts.d.ts +130 -0
  3. package/dist/coordinator/contracts.d.ts.map +1 -0
  4. package/dist/coordinator/contracts.js +112 -0
  5. package/dist/coordinator/contracts.js.map +1 -0
  6. package/dist/coordinator/hosted-heartbeat-coordinator-client.d.ts +20 -0
  7. package/dist/coordinator/hosted-heartbeat-coordinator-client.d.ts.map +1 -0
  8. package/dist/coordinator/hosted-heartbeat-coordinator-client.js +77 -0
  9. package/dist/coordinator/hosted-heartbeat-coordinator-client.js.map +1 -0
  10. package/dist/coordinator/hosted-heartbeat-delegation-client.d.ts +21 -0
  11. package/dist/coordinator/hosted-heartbeat-delegation-client.d.ts.map +1 -0
  12. package/dist/coordinator/hosted-heartbeat-delegation-client.js +117 -0
  13. package/dist/coordinator/hosted-heartbeat-delegation-client.js.map +1 -0
  14. package/dist/coordinator/hosted-heartbeat-delegation-service.d.ts +15 -0
  15. package/dist/coordinator/hosted-heartbeat-delegation-service.d.ts.map +1 -0
  16. package/dist/coordinator/hosted-heartbeat-delegation-service.js +81 -0
  17. package/dist/coordinator/hosted-heartbeat-delegation-service.js.map +1 -0
  18. package/dist/coordinator/hosted-heartbeat-task-reconciler.d.ts +11 -0
  19. package/dist/coordinator/hosted-heartbeat-task-reconciler.d.ts.map +1 -0
  20. package/dist/coordinator/hosted-heartbeat-task-reconciler.js +38 -0
  21. package/dist/coordinator/hosted-heartbeat-task-reconciler.js.map +1 -0
  22. package/dist/coordinator/index.d.ts +9 -0
  23. package/dist/coordinator/index.d.ts.map +1 -0
  24. package/dist/coordinator/index.js +7 -0
  25. package/dist/coordinator/index.js.map +1 -0
  26. package/dist/coordinator/node/delegation-http-service.d.ts +11 -0
  27. package/dist/coordinator/node/delegation-http-service.d.ts.map +1 -0
  28. package/dist/coordinator/node/delegation-http-service.js +131 -0
  29. package/dist/coordinator/node/delegation-http-service.js.map +1 -0
  30. package/dist/coordinator/node/environment.d.ts +3 -0
  31. package/dist/coordinator/node/environment.d.ts.map +1 -0
  32. package/dist/coordinator/node/environment.js +13 -0
  33. package/dist/coordinator/node/environment.js.map +1 -0
  34. package/dist/coordinator/node/index.d.ts +4 -0
  35. package/dist/coordinator/node/index.d.ts.map +1 -0
  36. package/dist/coordinator/node/index.js +3 -0
  37. package/dist/coordinator/node/index.js.map +1 -0
  38. package/dist/coordinator/node/types.d.ts +20 -0
  39. package/dist/coordinator/node/types.d.ts.map +1 -0
  40. package/dist/coordinator/node/types.js +2 -0
  41. package/dist/coordinator/node/types.js.map +1 -0
  42. package/dist/coordinator/runtime-session.d.ts +13 -0
  43. package/dist/coordinator/runtime-session.d.ts.map +1 -0
  44. package/dist/coordinator/runtime-session.js +23 -0
  45. package/dist/coordinator/runtime-session.js.map +1 -0
  46. package/dist/coordinator/service-token.d.ts +3 -0
  47. package/dist/coordinator/service-token.d.ts.map +1 -0
  48. package/dist/coordinator/service-token.js +7 -0
  49. package/dist/coordinator/service-token.js.map +1 -0
  50. package/dist/coordinator/types.d.ts +63 -0
  51. package/dist/coordinator/types.d.ts.map +1 -0
  52. package/dist/coordinator/types.js +2 -0
  53. package/dist/coordinator/types.js.map +1 -0
  54. package/dist/host/errors.d.ts +23 -0
  55. package/dist/host/errors.d.ts.map +1 -0
  56. package/dist/host/errors.js +32 -0
  57. package/dist/host/errors.js.map +1 -0
  58. package/dist/host/index.d.ts +7 -0
  59. package/dist/host/index.d.ts.map +1 -0
  60. package/dist/host/index.js +6 -0
  61. package/dist/host/index.js.map +1 -0
  62. package/dist/host/jwt-execution-host-mcp-capability-verifier.d.ts +8 -0
  63. package/dist/host/jwt-execution-host-mcp-capability-verifier.d.ts.map +1 -0
  64. package/dist/host/jwt-execution-host-mcp-capability-verifier.js +86 -0
  65. package/dist/host/jwt-execution-host-mcp-capability-verifier.js.map +1 -0
  66. package/dist/host/jwt-execution-identity-verifier.d.ts +8 -0
  67. package/dist/host/jwt-execution-identity-verifier.d.ts.map +1 -0
  68. package/dist/host/jwt-execution-identity-verifier.js +76 -0
  69. package/dist/host/jwt-execution-identity-verifier.js.map +1 -0
  70. package/dist/host/schemas.d.ts +37 -0
  71. package/dist/host/schemas.d.ts.map +1 -0
  72. package/dist/host/schemas.js +24 -0
  73. package/dist/host/schemas.js.map +1 -0
  74. package/dist/host/types.d.ts +62 -0
  75. package/dist/host/types.d.ts.map +1 -0
  76. package/dist/host/types.js +7 -0
  77. package/dist/host/types.js.map +1 -0
  78. package/dist/index.d.ts +1 -0
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +1 -0
  81. package/dist/index.js.map +1 -1
  82. package/dist/internal/jwt-verification.d.ts +5 -0
  83. package/dist/internal/jwt-verification.d.ts.map +1 -0
  84. package/dist/internal/jwt-verification.js +25 -0
  85. package/dist/internal/jwt-verification.js.map +1 -0
  86. package/dist/mcp/jwt-capability-verifier.d.ts.map +1 -1
  87. package/dist/mcp/jwt-capability-verifier.js +6 -25
  88. package/dist/mcp/jwt-capability-verifier.js.map +1 -1
  89. package/dist/node/http-service.d.ts.map +1 -1
  90. package/dist/node/http-service.js +5 -108
  91. package/dist/node/http-service.js.map +1 -1
  92. package/dist/node/http-utils.d.ts +15 -0
  93. package/dist/node/http-utils.d.ts.map +1 -0
  94. package/dist/node/http-utils.js +109 -0
  95. package/dist/node/http-utils.js.map +1 -0
  96. package/package.json +13 -1
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ declare const ProductExecutionScopeSchema: z.ZodObject<{
3
+ tenantId: z.ZodString;
4
+ subjectId: z.ZodString;
5
+ productSessionId: z.ZodString;
6
+ }, z.core.$strict>;
7
+ /** Stable Runtime session identity derived only from product-owned scope. */
8
+ export declare function createHostedRuntimeSessionId(rawInput: {
9
+ namespace: string;
10
+ scope: z.infer<typeof ProductExecutionScopeSchema>;
11
+ }): string;
12
+ export {};
13
+ //# sourceMappingURL=runtime-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-session.d.ts","sourceRoot":"","sources":["../../src/coordinator/runtime-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,QAAA,MAAM,2BAA2B;;;;kBAE/B,CAAC;AAOH,6EAA6E;AAC7E,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;CACpD,GAAG,MAAM,CAYT"}
@@ -0,0 +1,23 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { z } from 'zod';
3
+ import { ExecutionScopeSchema, OpaqueIdSchema, RuntimeSessionIdSchema, } from '../contracts/index.js';
4
+ const ProductExecutionScopeSchema = ExecutionScopeSchema.omit({
5
+ adopterId: true,
6
+ });
7
+ const HostedRuntimeSessionInputSchema = z.object({
8
+ namespace: OpaqueIdSchema,
9
+ scope: ProductExecutionScopeSchema,
10
+ }).strict();
11
+ /** Stable Runtime session identity derived only from product-owned scope. */
12
+ export function createHostedRuntimeSessionId(rawInput) {
13
+ const input = HostedRuntimeSessionInputSchema.parse(rawInput);
14
+ const digest = createHash('sha256')
15
+ .update(JSON.stringify([
16
+ input.scope.tenantId,
17
+ input.scope.subjectId,
18
+ input.scope.productSessionId,
19
+ ]))
20
+ .digest('hex');
21
+ return RuntimeSessionIdSchema.parse(`${input.namespace}-runtime-session-${digest}`);
22
+ }
23
+ //# sourceMappingURL=runtime-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-session.js","sourceRoot":"","sources":["../../src/coordinator/runtime-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,2BAA2B,GAAG,oBAAoB,CAAC,IAAI,CAAC;IAC5D,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC;AAEH,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,SAAS,EAAE,cAAc;IACzB,KAAK,EAAE,2BAA2B;CACnC,CAAC,CAAC,MAAM,EAAE,CAAC;AAEZ,6EAA6E;AAC7E,MAAM,UAAU,4BAA4B,CAAC,QAG5C;IACC,MAAM,KAAK,GAAG,+BAA+B,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC;SAChC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;QACrB,KAAK,CAAC,KAAK,CAAC,QAAQ;QACpB,KAAK,CAAC,KAAK,CAAC,SAAS;QACrB,KAAK,CAAC,KAAK,CAAC,gBAAgB;KAC7B,CAAC,CAAC;SACF,MAAM,CAAC,KAAK,CAAC,CAAC;IACjB,OAAO,sBAAsB,CAAC,KAAK,CACjC,GAAG,KAAK,CAAC,SAAS,oBAAoB,MAAM,EAAE,CAC/C,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\nimport { z } from 'zod';\nimport {\n ExecutionScopeSchema,\n OpaqueIdSchema,\n RuntimeSessionIdSchema,\n} from '../contracts/index.js';\n\nconst ProductExecutionScopeSchema = ExecutionScopeSchema.omit({\n adopterId: true,\n});\n\nconst HostedRuntimeSessionInputSchema = z.object({\n namespace: OpaqueIdSchema,\n scope: ProductExecutionScopeSchema,\n}).strict();\n\n/** Stable Runtime session identity derived only from product-owned scope. */\nexport function createHostedRuntimeSessionId(rawInput: {\n namespace: string;\n scope: z.infer<typeof ProductExecutionScopeSchema>;\n}): string {\n const input = HostedRuntimeSessionInputSchema.parse(rawInput);\n const digest = createHash('sha256')\n .update(JSON.stringify([\n input.scope.tenantId,\n input.scope.subjectId,\n input.scope.productSessionId,\n ]))\n .digest('hex');\n return RuntimeSessionIdSchema.parse(\n `${input.namespace}-runtime-session-${digest}`,\n );\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ export declare const HostedHeartbeatServiceTokenSchema: z.ZodString;
3
+ //# sourceMappingURL=service-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-token.d.ts","sourceRoot":"","sources":["../../src/coordinator/service-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iCAAiC,aAIjC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ export const HostedHeartbeatServiceTokenSchema = z
3
+ .string()
4
+ .trim()
5
+ .min(32)
6
+ .max(4_096);
7
+ //# sourceMappingURL=service-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-token.js","sourceRoot":"","sources":["../../src/coordinator/service-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC;KAC/C,MAAM,EAAE;KACR,IAAI,EAAE;KACN,GAAG,CAAC,EAAE,CAAC;KACP,GAAG,CAAC,KAAK,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\n\nexport const HostedHeartbeatServiceTokenSchema = z\n .string()\n .trim()\n .min(32)\n .max(4_096);\n"]}
@@ -0,0 +1,63 @@
1
+ import type { ExecutionAuthorityIssuer } from '../authority/index.js';
2
+ import type { HostedModelCredentialProvider } from '../conversation/index.js';
3
+ import type { HostedHeartbeatAgentExecutionTransportInput } from '../heartbeat/index.js';
4
+ import type { HeartbeatExecutionHost } from '../http-sse/index.js';
5
+ import type { HostedHeartbeatCoordinatorTaskInput, HostedHeartbeatCoordinatorTaskSummary, HostedHeartbeatDelegation, HostedHeartbeatDelegationAuthorization, HostedHeartbeatDelegationRequest, HostedHeartbeatDesiredTask } from './contracts.js';
6
+ export type HostedHeartbeatCoordinatorClientConfig = {
7
+ baseUrl: URL;
8
+ apiToken: string;
9
+ fetch?: typeof globalThis.fetch;
10
+ };
11
+ export interface HostedHeartbeatCoordinatorTaskApi {
12
+ listTasks(signal?: AbortSignal): Promise<HostedHeartbeatCoordinatorTaskSummary[]>;
13
+ upsertTask(taskId: string, task: HostedHeartbeatCoordinatorTaskInput, signal?: AbortSignal): Promise<void>;
14
+ deleteTask(taskId: string, signal?: AbortSignal): Promise<void>;
15
+ pause(signal?: AbortSignal): Promise<void>;
16
+ resume(signal?: AbortSignal): Promise<void>;
17
+ }
18
+ export type HostedHeartbeatTaskReconciliationInput = {
19
+ desiredTasks: readonly HostedHeartbeatDesiredTask[];
20
+ resume: boolean;
21
+ signal?: AbortSignal;
22
+ };
23
+ export type HostedHeartbeatTaskReconciliation = {
24
+ deleted: number;
25
+ upserted: number;
26
+ resumed: boolean;
27
+ };
28
+ export type HostedHeartbeatTaskReconcilerConfig = {
29
+ coordinator: HostedHeartbeatCoordinatorTaskApi;
30
+ };
31
+ export type HostedHeartbeatDelegationAuthorizationInput = {
32
+ taskId: string;
33
+ executionId: string;
34
+ signal: AbortSignal;
35
+ };
36
+ export interface HostedHeartbeatDelegationAuthorizer {
37
+ authorize(input: HostedHeartbeatDelegationAuthorizationInput): HostedHeartbeatDelegationAuthorization | undefined | Promise<HostedHeartbeatDelegationAuthorization | undefined>;
38
+ }
39
+ export type HostedHeartbeatDelegationServiceConfig = {
40
+ authority: ExecutionAuthorityIssuer;
41
+ authorizer: HostedHeartbeatDelegationAuthorizer;
42
+ runtimeSessionNamespace: string;
43
+ maxExecutionMs: number;
44
+ now?: () => Date;
45
+ };
46
+ export interface HostedHeartbeatDelegationIssuer {
47
+ issue(input: HostedHeartbeatDelegationRequest, signal?: AbortSignal): Promise<HostedHeartbeatDelegation>;
48
+ }
49
+ export type HostedHeartbeatDelegationClientConfig = {
50
+ baseUrl: URL;
51
+ apiToken: string;
52
+ fetch?: typeof globalThis.fetch;
53
+ path?: string;
54
+ };
55
+ export type HostedHeartbeatDelegatedExecutionTransportConfig = {
56
+ delegations: HostedHeartbeatDelegationIssuer;
57
+ executionHost: HeartbeatExecutionHost;
58
+ modelCredentials: HostedModelCredentialProvider;
59
+ };
60
+ export interface HostedHeartbeatDelegatedExecutionTransportPort {
61
+ execute(input: HostedHeartbeatAgentExecutionTransportInput): Promise<unknown>;
62
+ }
63
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/coordinator/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,6BAA6B,EAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,2CAA2C,EAC5C,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,yBAAyB,EACzB,sCAAsC,EACtC,gCAAgC,EAChC,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,sCAAsC,GAAG;IACnD,OAAO,EAAE,GAAG,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC,CAAC;AAEF,MAAM,WAAW,iCAAiC;IAChD,SAAS,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CACtC,qCAAqC,EAAE,CACxC,CAAC;IACF,UAAU,CACR,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,mCAAmC,EACzC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,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AM,MAAM,qCAAqC,GAAG;IAClD,OAAO,EAAE,GAAG,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,gDAAgD,GAAG;IAC7D,WAAW,EAAE,+BAA+B,CAAC;IAC7C,aAAa,EAAE,sBAAsB,CAAC;IACtC,gBAAgB,EAAE,6BAA6B,CAAC;CACjD,CAAC;AAEF,MAAM,WAAW,8CAA8C;IAC7D,OAAO,CACL,KAAK,EAAE,2CAA2C,GACjD,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/coordinator/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ExecutionAuthorityIssuer,\n} from '../authority/index.js';\nimport type {\n HostedModelCredentialProvider,\n} from '../conversation/index.js';\nimport type {\n HostedHeartbeatAgentExecutionTransportInput,\n} from '../heartbeat/index.js';\nimport type { HeartbeatExecutionHost } from '../http-sse/index.js';\nimport type {\n HostedHeartbeatCoordinatorTaskInput,\n HostedHeartbeatCoordinatorTaskSummary,\n HostedHeartbeatDelegation,\n HostedHeartbeatDelegationAuthorization,\n HostedHeartbeatDelegationRequest,\n HostedHeartbeatDesiredTask,\n} from './contracts.js';\n\nexport type HostedHeartbeatCoordinatorClientConfig = {\n baseUrl: URL;\n apiToken: string;\n fetch?: typeof globalThis.fetch;\n};\n\nexport interface HostedHeartbeatCoordinatorTaskApi {\n listTasks(signal?: AbortSignal): Promise<\n HostedHeartbeatCoordinatorTaskSummary[]\n >;\n upsertTask(\n taskId: string,\n task: HostedHeartbeatCoordinatorTaskInput,\n signal?: AbortSignal,\n ): Promise<void>;\n deleteTask(taskId: string, signal?: AbortSignal): Promise<void>;\n pause(signal?: AbortSignal): Promise<void>;\n resume(signal?: AbortSignal): Promise<void>;\n}\n\nexport type HostedHeartbeatTaskReconciliationInput = {\n desiredTasks: readonly HostedHeartbeatDesiredTask[];\n resume: boolean;\n signal?: AbortSignal;\n};\n\nexport type HostedHeartbeatTaskReconciliation = {\n deleted: number;\n upserted: number;\n resumed: boolean;\n};\n\nexport type HostedHeartbeatTaskReconcilerConfig = {\n coordinator: HostedHeartbeatCoordinatorTaskApi;\n};\n\nexport type HostedHeartbeatDelegationAuthorizationInput = {\n taskId: string;\n executionId: string;\n signal: AbortSignal;\n};\n\nexport interface HostedHeartbeatDelegationAuthorizer {\n authorize(\n input: HostedHeartbeatDelegationAuthorizationInput,\n ): HostedHeartbeatDelegationAuthorization\n | undefined\n | Promise<HostedHeartbeatDelegationAuthorization | undefined>;\n}\n\nexport type HostedHeartbeatDelegationServiceConfig = {\n authority: ExecutionAuthorityIssuer;\n authorizer: HostedHeartbeatDelegationAuthorizer;\n runtimeSessionNamespace: string;\n maxExecutionMs: number;\n now?: () => Date;\n};\n\nexport interface HostedHeartbeatDelegationIssuer {\n issue(\n input: HostedHeartbeatDelegationRequest,\n signal?: AbortSignal,\n ): Promise<HostedHeartbeatDelegation>;\n}\n\nexport type HostedHeartbeatDelegationClientConfig = {\n baseUrl: URL;\n apiToken: string;\n fetch?: typeof globalThis.fetch;\n path?: string;\n};\n\nexport type HostedHeartbeatDelegatedExecutionTransportConfig = {\n delegations: HostedHeartbeatDelegationIssuer;\n executionHost: HeartbeatExecutionHost;\n modelCredentials: HostedModelCredentialProvider;\n};\n\nexport interface HostedHeartbeatDelegatedExecutionTransportPort {\n execute(\n input: HostedHeartbeatAgentExecutionTransportInput,\n ): Promise<unknown>;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { JwtVerificationUnavailableCategory } from '../internal/jwt-verification.js';
2
+ export declare class ExecutionIdentityVerificationError extends Error {
3
+ readonly name = "ExecutionIdentityVerificationError";
4
+ constructor(options?: ErrorOptions);
5
+ }
6
+ export declare class ExecutionIdentityUnavailableError extends Error {
7
+ readonly category: JwtVerificationUnavailableCategory;
8
+ readonly name = "ExecutionIdentityUnavailableError";
9
+ constructor(category: JwtVerificationUnavailableCategory, options?: ErrorOptions);
10
+ }
11
+ export declare class ExecutionHostMcpCapabilityVerificationError extends Error {
12
+ readonly name = "ExecutionHostMcpCapabilityVerificationError";
13
+ constructor(options?: ErrorOptions);
14
+ }
15
+ export declare class ExecutionHostMcpCapabilityUnavailableError extends Error {
16
+ readonly category: JwtVerificationUnavailableCategory;
17
+ readonly name = "ExecutionHostMcpCapabilityUnavailableError";
18
+ constructor(category: JwtVerificationUnavailableCategory, options?: ErrorOptions);
19
+ }
20
+ export declare class UnexpectedExecutionHostMcpCapabilityError extends Error {
21
+ readonly name = "UnexpectedExecutionHostMcpCapabilityError";
22
+ }
23
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/host/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,iCAAiC,CAAC;AAE1F,qBAAa,kCAAmC,SAAQ,KAAK;IAC3D,QAAQ,CAAC,IAAI,wCAAwC;gBAEzC,OAAO,CAAC,EAAE,YAAY;CAGnC;AAED,qBAAa,iCAAkC,SAAQ,KAAK;IAIxD,QAAQ,CAAC,QAAQ,EAAE,kCAAkC;IAHvD,QAAQ,CAAC,IAAI,uCAAuC;gBAGzC,QAAQ,EAAE,kCAAkC,EACrD,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED,qBAAa,2CAA4C,SAAQ,KAAK;IACpE,QAAQ,CAAC,IAAI,iDAAiD;gBAElD,OAAO,CAAC,EAAE,YAAY;CAGnC;AAED,qBAAa,0CAA2C,SAAQ,KAAK;IAIjE,QAAQ,CAAC,QAAQ,EAAE,kCAAkC;IAHvD,QAAQ,CAAC,IAAI,gDAAgD;gBAGlD,QAAQ,EAAE,kCAAkC,EACrD,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED,qBAAa,yCAA0C,SAAQ,KAAK;IAClE,QAAQ,CAAC,IAAI,+CAA+C;CAC7D"}
@@ -0,0 +1,32 @@
1
+ export class ExecutionIdentityVerificationError extends Error {
2
+ name = 'ExecutionIdentityVerificationError';
3
+ constructor(options) {
4
+ super('Execution identity verification failed.', options);
5
+ }
6
+ }
7
+ export class ExecutionIdentityUnavailableError extends Error {
8
+ category;
9
+ name = 'ExecutionIdentityUnavailableError';
10
+ constructor(category, options) {
11
+ super('Execution identity verification is temporarily unavailable.', options);
12
+ this.category = category;
13
+ }
14
+ }
15
+ export class ExecutionHostMcpCapabilityVerificationError extends Error {
16
+ name = 'ExecutionHostMcpCapabilityVerificationError';
17
+ constructor(options) {
18
+ super('MCP capability verification failed.', options);
19
+ }
20
+ }
21
+ export class ExecutionHostMcpCapabilityUnavailableError extends Error {
22
+ category;
23
+ name = 'ExecutionHostMcpCapabilityUnavailableError';
24
+ constructor(category, options) {
25
+ super('MCP capability verification is temporarily unavailable.', options);
26
+ this.category = category;
27
+ }
28
+ }
29
+ export class UnexpectedExecutionHostMcpCapabilityError extends Error {
30
+ name = 'UnexpectedExecutionHostMcpCapabilityError';
31
+ }
32
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/host/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kCAAmC,SAAQ,KAAK;IAClD,IAAI,GAAG,oCAAoC,CAAC;IAErD,YAAY,OAAsB;QAChC,KAAK,CAAC,yCAAyC,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IAI/C;IAHF,IAAI,GAAG,mCAAmC,CAAC;IAEpD,YACW,QAA4C,EACrD,OAAsB;QAEtB,KAAK,CAAC,6DAA6D,EAAE,OAAO,CAAC,CAAC;QAHrE,aAAQ,GAAR,QAAQ,CAAoC;IAIvD,CAAC;CACF;AAED,MAAM,OAAO,2CAA4C,SAAQ,KAAK;IAC3D,IAAI,GAAG,6CAA6C,CAAC;IAE9D,YAAY,OAAsB;QAChC,KAAK,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;CACF;AAED,MAAM,OAAO,0CAA2C,SAAQ,KAAK;IAIxD;IAHF,IAAI,GAAG,4CAA4C,CAAC;IAE7D,YACW,QAA4C,EACrD,OAAsB;QAEtB,KAAK,CAAC,yDAAyD,EAAE,OAAO,CAAC,CAAC;QAHjE,aAAQ,GAAR,QAAQ,CAAoC;IAIvD,CAAC;CACF;AAED,MAAM,OAAO,yCAA0C,SAAQ,KAAK;IACzD,IAAI,GAAG,2CAA2C,CAAC;CAC7D","sourcesContent":["import type { JwtVerificationUnavailableCategory } from '../internal/jwt-verification.js';\n\nexport class ExecutionIdentityVerificationError extends Error {\n readonly name = 'ExecutionIdentityVerificationError';\n\n constructor(options?: ErrorOptions) {\n super('Execution identity verification failed.', options);\n }\n}\n\nexport class ExecutionIdentityUnavailableError extends Error {\n readonly name = 'ExecutionIdentityUnavailableError';\n\n constructor(\n readonly category: JwtVerificationUnavailableCategory,\n options?: ErrorOptions,\n ) {\n super('Execution identity verification is temporarily unavailable.', options);\n }\n}\n\nexport class ExecutionHostMcpCapabilityVerificationError extends Error {\n readonly name = 'ExecutionHostMcpCapabilityVerificationError';\n\n constructor(options?: ErrorOptions) {\n super('MCP capability verification failed.', options);\n }\n}\n\nexport class ExecutionHostMcpCapabilityUnavailableError extends Error {\n readonly name = 'ExecutionHostMcpCapabilityUnavailableError';\n\n constructor(\n readonly category: JwtVerificationUnavailableCategory,\n options?: ErrorOptions,\n ) {\n super('MCP capability verification is temporarily unavailable.', options);\n }\n}\n\nexport class UnexpectedExecutionHostMcpCapabilityError extends Error {\n readonly name = 'UnexpectedExecutionHostMcpCapabilityError';\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export { ExecutionHostMcpCapabilityUnavailableError, ExecutionHostMcpCapabilityVerificationError, ExecutionIdentityUnavailableError, ExecutionIdentityVerificationError, UnexpectedExecutionHostMcpCapabilityError, } from './errors.js';
2
+ export { JwtExecutionIdentityVerifier } from './jwt-execution-identity-verifier.js';
3
+ export { JwtExecutionHostMcpCapabilityVerifier } from './jwt-execution-host-mcp-capability-verifier.js';
4
+ export { ExecutionHostJwtAlgorithmsSchema, JwtExecutionHostMcpCapabilityVerifierConfigSchema, JwtExecutionIdentityVerifierConfigSchema, } from './schemas.js';
5
+ export { EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS, } from './types.js';
6
+ export type { ExecutionHostJwtAlgorithm, ExecutionHostJwtVerifierOptions, ExecutionHostMcpCapabilityVerificationRequest, ExecutionHostMcpCapabilityVerifier, ExecutionIdentityVerificationRequest, ExecutionIdentityVerifier, JwtExecutionHostMcpCapabilityVerifierConfig, JwtExecutionIdentityVerifierConfig, VerifiedExecutionHostMcpCapability, VerifiedExecutionIdentity, } from './types.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0CAA0C,EAC1C,2CAA2C,EAC3C,iCAAiC,EACjC,kCAAkC,EAClC,yCAAyC,GAC1C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,qCAAqC,EAAE,MAAM,iDAAiD,CAAC;AACxG,OAAO,EACL,gCAAgC,EAChC,iDAAiD,EACjD,wCAAwC,GACzC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uCAAuC,GACxC,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,yBAAyB,EACzB,+BAA+B,EAC/B,6CAA6C,EAC7C,kCAAkC,EAClC,oCAAoC,EACpC,yBAAyB,EACzB,2CAA2C,EAC3C,kCAAkC,EAClC,kCAAkC,EAClC,yBAAyB,GAC1B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { ExecutionHostMcpCapabilityUnavailableError, ExecutionHostMcpCapabilityVerificationError, ExecutionIdentityUnavailableError, ExecutionIdentityVerificationError, UnexpectedExecutionHostMcpCapabilityError, } from './errors.js';
2
+ export { JwtExecutionIdentityVerifier } from './jwt-execution-identity-verifier.js';
3
+ export { JwtExecutionHostMcpCapabilityVerifier } from './jwt-execution-host-mcp-capability-verifier.js';
4
+ export { ExecutionHostJwtAlgorithmsSchema, JwtExecutionHostMcpCapabilityVerifierConfigSchema, JwtExecutionIdentityVerifierConfigSchema, } from './schemas.js';
5
+ export { EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS, } from './types.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0CAA0C,EAC1C,2CAA2C,EAC3C,iCAAiC,EACjC,kCAAkC,EAClC,yCAAyC,GAC1C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,qCAAqC,EAAE,MAAM,iDAAiD,CAAC;AACxG,OAAO,EACL,gCAAgC,EAChC,iDAAiD,EACjD,wCAAwC,GACzC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uCAAuC,GACxC,MAAM,YAAY,CAAC","sourcesContent":["export {\n ExecutionHostMcpCapabilityUnavailableError,\n ExecutionHostMcpCapabilityVerificationError,\n ExecutionIdentityUnavailableError,\n ExecutionIdentityVerificationError,\n UnexpectedExecutionHostMcpCapabilityError,\n} from './errors.js';\nexport { JwtExecutionIdentityVerifier } from './jwt-execution-identity-verifier.js';\nexport { JwtExecutionHostMcpCapabilityVerifier } from './jwt-execution-host-mcp-capability-verifier.js';\nexport {\n ExecutionHostJwtAlgorithmsSchema,\n JwtExecutionHostMcpCapabilityVerifierConfigSchema,\n JwtExecutionIdentityVerifierConfigSchema,\n} from './schemas.js';\nexport {\n EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS,\n} from './types.js';\nexport type {\n ExecutionHostJwtAlgorithm,\n ExecutionHostJwtVerifierOptions,\n ExecutionHostMcpCapabilityVerificationRequest,\n ExecutionHostMcpCapabilityVerifier,\n ExecutionIdentityVerificationRequest,\n ExecutionIdentityVerifier,\n JwtExecutionHostMcpCapabilityVerifierConfig,\n JwtExecutionIdentityVerifierConfig,\n VerifiedExecutionHostMcpCapability,\n VerifiedExecutionIdentity,\n} from './types.js';\n"]}
@@ -0,0 +1,8 @@
1
+ import type { ExecutionHostJwtVerifierOptions, ExecutionHostMcpCapabilityVerificationRequest, ExecutionHostMcpCapabilityVerifier, JwtExecutionHostMcpCapabilityVerifierConfig, VerifiedExecutionHostMcpCapability } from './types.js';
2
+ /** Verifies MCP authority against an independently verified host invocation. */
3
+ export declare class JwtExecutionHostMcpCapabilityVerifier implements ExecutionHostMcpCapabilityVerifier {
4
+ #private;
5
+ constructor(config: JwtExecutionHostMcpCapabilityVerifierConfig, options?: ExecutionHostJwtVerifierOptions);
6
+ verify(rawRequest: ExecutionHostMcpCapabilityVerificationRequest): Promise<VerifiedExecutionHostMcpCapability>;
7
+ }
8
+ //# sourceMappingURL=jwt-execution-host-mcp-capability-verifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-execution-host-mcp-capability-verifier.d.ts","sourceRoot":"","sources":["../../src/host/jwt-execution-host-mcp-capability-verifier.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,+BAA+B,EAC/B,6CAA6C,EAC7C,kCAAkC,EAClC,2CAA2C,EAC3C,kCAAkC,EACnC,MAAM,YAAY,CAAC;AAOpB,gFAAgF;AAChF,qBAAa,qCACb,YAAW,kCAAkC;;gBAMzC,MAAM,EAAE,2CAA2C,EACnD,OAAO,GAAE,+BAAoC;IAczC,MAAM,CACV,UAAU,EAAE,6CAA6C,GACxD,OAAO,CAAC,kCAAkC,CAAC;CAkF/C"}
@@ -0,0 +1,86 @@
1
+ import { jwtVerify } from 'jose';
2
+ import { z } from 'zod';
3
+ import { MCP_CAPABILITY_TYPE, McpCapabilityClaimsSchema, } from '../contracts/index.js';
4
+ import { createJwtKeyResolver, resolveJwtVerificationUnavailableCategory, } from '../internal/jwt-verification.js';
5
+ import { ExecutionHostMcpCapabilityUnavailableError, ExecutionHostMcpCapabilityVerificationError, } from './errors.js';
6
+ import { JwtExecutionHostMcpCapabilityVerifierConfigSchema } from './schemas.js';
7
+ const AssertionSchema = z.string().trim().min(32).max(4_096);
8
+ /** Verifies MCP authority against an independently verified host invocation. */
9
+ export class JwtExecutionHostMcpCapabilityVerifier {
10
+ #config;
11
+ #keyResolver;
12
+ #now;
13
+ constructor(config, options = {}) {
14
+ const parsed = JwtExecutionHostMcpCapabilityVerifierConfigSchema.parse(config);
15
+ this.#config = Object.freeze({
16
+ ...parsed,
17
+ jwksUrl: new URL(parsed.jwksUrl),
18
+ });
19
+ this.#keyResolver = options.keyResolver
20
+ ?? createJwtKeyResolver(this.#config.jwksUrl);
21
+ this.#now = options.now ?? (() => new Date());
22
+ }
23
+ async verify(rawRequest) {
24
+ try {
25
+ const request = Object.freeze({
26
+ ...rawRequest,
27
+ assertion: AssertionSchema.parse(rawRequest.assertion),
28
+ });
29
+ const { payload } = await jwtVerify(request.assertion, this.#keyResolver, {
30
+ algorithms: [...this.#config.jwtAlgorithms],
31
+ audience: this.#config.audience,
32
+ clockTolerance: this.#config.clockToleranceSeconds,
33
+ currentDate: this.#now(),
34
+ issuer: this.#config.issuer,
35
+ maxTokenAge: this.#config.maxCapabilityAgeSeconds,
36
+ requiredClaims: ['exp', 'iat', 'jti', 'sub'],
37
+ typ: MCP_CAPABILITY_TYPE,
38
+ });
39
+ const claims = McpCapabilityClaimsSchema.parse(payload);
40
+ this.#assertInvocationBinding(claims, request);
41
+ this.#assertBoundedLifetime(claims);
42
+ return Object.freeze({
43
+ assertion: request.assertion,
44
+ capabilityId: claims.jti,
45
+ serverId: claims.serverId,
46
+ allowedTools: Object.freeze([...claims.allowedTools]),
47
+ issuedAt: new Date(claims.iat * 1_000).toISOString(),
48
+ expiresAt: new Date(claims.exp * 1_000).toISOString(),
49
+ });
50
+ }
51
+ catch (error) {
52
+ if (error instanceof ExecutionHostMcpCapabilityVerificationError
53
+ || error instanceof ExecutionHostMcpCapabilityUnavailableError) {
54
+ throw error;
55
+ }
56
+ const category = resolveJwtVerificationUnavailableCategory(error);
57
+ if (category) {
58
+ throw new ExecutionHostMcpCapabilityUnavailableError(category, { cause: error });
59
+ }
60
+ throw new ExecutionHostMcpCapabilityVerificationError({ cause: error });
61
+ }
62
+ }
63
+ #assertInvocationBinding(claims, request) {
64
+ const { identity } = request;
65
+ if (claims.adopterId !== this.#config.trustedAdopterId
66
+ || claims.adopterId !== identity.scope.adopterId
67
+ || claims.tenantId !== identity.scope.tenantId
68
+ || claims.sub !== identity.scope.subjectId
69
+ || claims.productSessionId !== identity.scope.productSessionId
70
+ || claims.runtimeSessionId !== identity.runtimeSessionId
71
+ || claims.invocationId !== identity.invocationId
72
+ || claims.workflow !== identity.workflow
73
+ || claims.serverId !== this.#config.serverId
74
+ || claims.jti === identity.invocationId) {
75
+ throw new ExecutionHostMcpCapabilityVerificationError();
76
+ }
77
+ }
78
+ #assertBoundedLifetime(claims) {
79
+ const lifetimeSeconds = claims.exp - claims.iat;
80
+ if (lifetimeSeconds <= 0
81
+ || lifetimeSeconds > this.#config.maxCapabilityAgeSeconds) {
82
+ throw new ExecutionHostMcpCapabilityVerificationError();
83
+ }
84
+ }
85
+ }
86
+ //# sourceMappingURL=jwt-execution-host-mcp-capability-verifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-execution-host-mcp-capability-verifier.js","sourceRoot":"","sources":["../../src/host/jwt-execution-host-mcp-capability-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAA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ACE,eAAe,IAAI,CAAC;eACjB,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAuB,EACzD,CAAC;YACD,MAAM,IAAI,2CAA2C,EAAE,CAAC;QAC1D,CAAC;IACH,CAAC;CACF","sourcesContent":["import { jwtVerify } from 'jose';\nimport { z } from 'zod';\nimport {\n MCP_CAPABILITY_TYPE,\n McpCapabilityClaimsSchema,\n} from '../contracts/index.js';\nimport {\n createJwtKeyResolver,\n resolveJwtVerificationUnavailableCategory,\n} from '../internal/jwt-verification.js';\nimport {\n ExecutionHostMcpCapabilityUnavailableError,\n ExecutionHostMcpCapabilityVerificationError,\n} from './errors.js';\nimport { JwtExecutionHostMcpCapabilityVerifierConfigSchema } from './schemas.js';\nimport type {\n ExecutionHostJwtVerifierOptions,\n ExecutionHostMcpCapabilityVerificationRequest,\n ExecutionHostMcpCapabilityVerifier,\n JwtExecutionHostMcpCapabilityVerifierConfig,\n VerifiedExecutionHostMcpCapability,\n} from './types.js';\n\nconst AssertionSchema = z.string().trim().min(32).max(4_096);\ntype ParsedConfig = z.infer<\n typeof JwtExecutionHostMcpCapabilityVerifierConfigSchema\n>;\n\n/** Verifies MCP authority against an independently verified host invocation. */\nexport class JwtExecutionHostMcpCapabilityVerifier\nimplements ExecutionHostMcpCapabilityVerifier {\n readonly #config: Readonly<ParsedConfig>;\n readonly #keyResolver: NonNullable<ExecutionHostJwtVerifierOptions['keyResolver']>;\n readonly #now: () => Date;\n\n constructor(\n config: JwtExecutionHostMcpCapabilityVerifierConfig,\n options: ExecutionHostJwtVerifierOptions = {},\n ) {\n const parsed = JwtExecutionHostMcpCapabilityVerifierConfigSchema.parse(\n config,\n );\n this.#config = Object.freeze({\n ...parsed,\n jwksUrl: new URL(parsed.jwksUrl),\n });\n this.#keyResolver = options.keyResolver\n ?? createJwtKeyResolver(this.#config.jwksUrl);\n this.#now = options.now ?? (() => new Date());\n }\n\n async verify(\n rawRequest: ExecutionHostMcpCapabilityVerificationRequest,\n ): Promise<VerifiedExecutionHostMcpCapability> {\n try {\n const request = Object.freeze({\n ...rawRequest,\n assertion: AssertionSchema.parse(rawRequest.assertion),\n });\n const { payload } = await jwtVerify(\n request.assertion,\n this.#keyResolver,\n {\n algorithms: [...this.#config.jwtAlgorithms],\n audience: this.#config.audience,\n clockTolerance: this.#config.clockToleranceSeconds,\n currentDate: this.#now(),\n issuer: this.#config.issuer,\n maxTokenAge: this.#config.maxCapabilityAgeSeconds,\n requiredClaims: ['exp', 'iat', 'jti', 'sub'],\n typ: MCP_CAPABILITY_TYPE,\n },\n );\n const claims = McpCapabilityClaimsSchema.parse(payload);\n this.#assertInvocationBinding(claims, request);\n this.#assertBoundedLifetime(claims);\n\n return Object.freeze({\n assertion: request.assertion,\n capabilityId: claims.jti,\n serverId: claims.serverId,\n allowedTools: Object.freeze([...claims.allowedTools]),\n issuedAt: new Date(claims.iat * 1_000).toISOString(),\n expiresAt: new Date(claims.exp * 1_000).toISOString(),\n });\n } catch (error) {\n if (\n error instanceof ExecutionHostMcpCapabilityVerificationError\n || error instanceof ExecutionHostMcpCapabilityUnavailableError\n ) {\n throw error;\n }\n const category = resolveJwtVerificationUnavailableCategory(error);\n if (category) {\n throw new ExecutionHostMcpCapabilityUnavailableError(\n category,\n { cause: error },\n );\n }\n throw new ExecutionHostMcpCapabilityVerificationError({ cause: error });\n }\n }\n\n #assertInvocationBinding(\n claims: z.infer<typeof McpCapabilityClaimsSchema>,\n request: ExecutionHostMcpCapabilityVerificationRequest,\n ): void {\n const { identity } = request;\n if (\n claims.adopterId !== this.#config.trustedAdopterId\n || claims.adopterId !== identity.scope.adopterId\n || claims.tenantId !== identity.scope.tenantId\n || claims.sub !== identity.scope.subjectId\n || claims.productSessionId !== identity.scope.productSessionId\n || claims.runtimeSessionId !== identity.runtimeSessionId\n || claims.invocationId !== identity.invocationId\n || claims.workflow !== identity.workflow\n || claims.serverId !== this.#config.serverId\n || claims.jti === identity.invocationId\n ) {\n throw new ExecutionHostMcpCapabilityVerificationError();\n }\n }\n\n #assertBoundedLifetime(\n claims: z.infer<typeof McpCapabilityClaimsSchema>,\n ): void {\n const lifetimeSeconds = claims.exp - claims.iat;\n if (\n lifetimeSeconds <= 0\n || lifetimeSeconds > this.#config.maxCapabilityAgeSeconds\n ) {\n throw new ExecutionHostMcpCapabilityVerificationError();\n }\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { ExecutionIdentityVerificationRequest, ExecutionIdentityVerifier, ExecutionHostJwtVerifierOptions, JwtExecutionIdentityVerifierConfig, VerifiedExecutionIdentity } from './types.js';
2
+ /** Verifies adopter authority and binds it to one exact host invocation. */
3
+ export declare class JwtExecutionIdentityVerifier implements ExecutionIdentityVerifier {
4
+ #private;
5
+ constructor(config: JwtExecutionIdentityVerifierConfig, options?: ExecutionHostJwtVerifierOptions);
6
+ verify(rawRequest: ExecutionIdentityVerificationRequest): Promise<VerifiedExecutionIdentity>;
7
+ }
8
+ //# sourceMappingURL=jwt-execution-identity-verifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-execution-identity-verifier.d.ts","sourceRoot":"","sources":["../../src/host/jwt-execution-identity-verifier.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,oCAAoC,EACpC,yBAAyB,EACzB,+BAA+B,EAC/B,kCAAkC,EAClC,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAKpB,4EAA4E;AAC5E,qBAAa,4BAA6B,YAAW,yBAAyB;;gBAM1E,MAAM,EAAE,kCAAkC,EAC1C,OAAO,GAAE,+BAAoC;IAYzC,MAAM,CACV,UAAU,EAAE,oCAAoC,GAC/C,OAAO,CAAC,yBAAyB,CAAC;CAgEtC"}
@@ -0,0 +1,76 @@
1
+ import { jwtVerify } from 'jose';
2
+ import { z } from 'zod';
3
+ import { EXECUTION_ASSERTION_TYPE, ExecutionAssertionClaimsSchema, } from '../contracts/index.js';
4
+ import { createJwtKeyResolver, resolveJwtVerificationUnavailableCategory, } from '../internal/jwt-verification.js';
5
+ import { ExecutionIdentityUnavailableError, ExecutionIdentityVerificationError, } from './errors.js';
6
+ import { JwtExecutionIdentityVerifierConfigSchema } from './schemas.js';
7
+ const AssertionSchema = z.string().trim().min(32).max(4_096);
8
+ /** Verifies adopter authority and binds it to one exact host invocation. */
9
+ export class JwtExecutionIdentityVerifier {
10
+ #config;
11
+ #keyResolver;
12
+ #now;
13
+ constructor(config, options = {}) {
14
+ const parsed = JwtExecutionIdentityVerifierConfigSchema.parse(config);
15
+ this.#config = Object.freeze({
16
+ ...parsed,
17
+ executionJwksUrl: new URL(parsed.executionJwksUrl),
18
+ });
19
+ this.#keyResolver = options.keyResolver
20
+ ?? createJwtKeyResolver(this.#config.executionJwksUrl);
21
+ this.#now = options.now ?? (() => new Date());
22
+ }
23
+ async verify(rawRequest) {
24
+ try {
25
+ const request = Object.freeze({
26
+ ...rawRequest,
27
+ assertion: AssertionSchema.parse(rawRequest.assertion),
28
+ });
29
+ const { payload } = await jwtVerify(request.assertion, this.#keyResolver, {
30
+ algorithms: [...this.#config.executionJwtAlgorithms],
31
+ audience: this.#config.executionAudience,
32
+ clockTolerance: this.#config.assertionClockToleranceSeconds,
33
+ currentDate: this.#now(),
34
+ issuer: this.#config.executionIssuer,
35
+ maxTokenAge: this.#config.maxAssertionAgeSeconds,
36
+ requiredClaims: ['exp', 'iat', 'jti', 'sub'],
37
+ typ: EXECUTION_ASSERTION_TYPE,
38
+ });
39
+ const claims = ExecutionAssertionClaimsSchema.parse(payload);
40
+ this.#assertRequestBinding(claims, request);
41
+ return Object.freeze({
42
+ scope: Object.freeze({
43
+ adopterId: claims.adopterId,
44
+ tenantId: claims.tenantId,
45
+ subjectId: claims.sub,
46
+ productSessionId: claims.productSessionId,
47
+ }),
48
+ runtimeSessionId: claims.runtimeSessionId,
49
+ invocationId: claims.jti,
50
+ workflow: claims.workflow,
51
+ issuedAt: new Date(claims.iat * 1_000).toISOString(),
52
+ expiresAt: new Date(claims.exp * 1_000).toISOString(),
53
+ });
54
+ }
55
+ catch (error) {
56
+ if (error instanceof ExecutionIdentityVerificationError
57
+ || error instanceof ExecutionIdentityUnavailableError) {
58
+ throw error;
59
+ }
60
+ const category = resolveJwtVerificationUnavailableCategory(error);
61
+ if (category) {
62
+ throw new ExecutionIdentityUnavailableError(category, { cause: error });
63
+ }
64
+ throw new ExecutionIdentityVerificationError({ cause: error });
65
+ }
66
+ }
67
+ #assertRequestBinding(claims, request) {
68
+ if (claims.adopterId !== this.#config.trustedAdopterId
69
+ || claims.runtimeSessionId !== request.runtimeSessionId
70
+ || claims.jti !== request.invocationId
71
+ || claims.workflow !== request.workflow) {
72
+ throw new ExecutionIdentityVerificationError();
73
+ }
74
+ }
75
+ }
76
+ //# sourceMappingURL=jwt-execution-identity-verifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-execution-identity-verifier.js","sourceRoot":"","sources":["../../src/host/jwt-execution-identity-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,yCAAyC,GAC1C,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC;AASxE,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAG7D,4EAA4E;AAC5E,MAAM,OAAO,4BAA4B;IAC9B,OAAO,CAAyB;IAChC,YAAY,CAA8D;IAC1E,IAAI,CAAa;IAE1B,YACE,MAA0C,EAC1C,UAA2C,EAAE;QAE7C,MAAM,MAAM,GAAG,w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,gBAAgB;eACpD,MAAM,CAAC,GAAG,KAAK,OAAO,CAAC,YAAY;eACnC,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ,EACvC,CAAC;YACD,MAAM,IAAI,kCAAkC,EAAE,CAAC;QACjD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { jwtVerify } from 'jose';\nimport { z } from 'zod';\nimport {\n EXECUTION_ASSERTION_TYPE,\n ExecutionAssertionClaimsSchema,\n} from '../contracts/index.js';\nimport {\n createJwtKeyResolver,\n resolveJwtVerificationUnavailableCategory,\n} from '../internal/jwt-verification.js';\nimport {\n ExecutionIdentityUnavailableError,\n ExecutionIdentityVerificationError,\n} from './errors.js';\nimport { JwtExecutionIdentityVerifierConfigSchema } from './schemas.js';\nimport type {\n ExecutionIdentityVerificationRequest,\n ExecutionIdentityVerifier,\n ExecutionHostJwtVerifierOptions,\n JwtExecutionIdentityVerifierConfig,\n VerifiedExecutionIdentity,\n} from './types.js';\n\nconst AssertionSchema = z.string().trim().min(32).max(4_096);\ntype ParsedConfig = z.infer<typeof JwtExecutionIdentityVerifierConfigSchema>;\n\n/** Verifies adopter authority and binds it to one exact host invocation. */\nexport class JwtExecutionIdentityVerifier implements ExecutionIdentityVerifier {\n readonly #config: Readonly<ParsedConfig>;\n readonly #keyResolver: NonNullable<ExecutionHostJwtVerifierOptions['keyResolver']>;\n readonly #now: () => Date;\n\n constructor(\n config: JwtExecutionIdentityVerifierConfig,\n options: ExecutionHostJwtVerifierOptions = {},\n ) {\n const parsed = JwtExecutionIdentityVerifierConfigSchema.parse(config);\n this.#config = Object.freeze({\n ...parsed,\n executionJwksUrl: new URL(parsed.executionJwksUrl),\n });\n this.#keyResolver = options.keyResolver\n ?? createJwtKeyResolver(this.#config.executionJwksUrl);\n this.#now = options.now ?? (() => new Date());\n }\n\n async verify(\n rawRequest: ExecutionIdentityVerificationRequest,\n ): Promise<VerifiedExecutionIdentity> {\n try {\n const request = Object.freeze({\n ...rawRequest,\n assertion: AssertionSchema.parse(rawRequest.assertion),\n });\n const { payload } = await jwtVerify(\n request.assertion,\n this.#keyResolver,\n {\n algorithms: [...this.#config.executionJwtAlgorithms],\n audience: this.#config.executionAudience,\n clockTolerance: this.#config.assertionClockToleranceSeconds,\n currentDate: this.#now(),\n issuer: this.#config.executionIssuer,\n maxTokenAge: this.#config.maxAssertionAgeSeconds,\n requiredClaims: ['exp', 'iat', 'jti', 'sub'],\n typ: EXECUTION_ASSERTION_TYPE,\n },\n );\n const claims = ExecutionAssertionClaimsSchema.parse(payload);\n this.#assertRequestBinding(claims, request);\n\n return Object.freeze({\n scope: Object.freeze({\n adopterId: claims.adopterId,\n tenantId: claims.tenantId,\n subjectId: claims.sub,\n productSessionId: claims.productSessionId,\n }),\n runtimeSessionId: claims.runtimeSessionId,\n invocationId: claims.jti,\n workflow: claims.workflow,\n issuedAt: new Date(claims.iat * 1_000).toISOString(),\n expiresAt: new Date(claims.exp * 1_000).toISOString(),\n });\n } catch (error) {\n if (\n error instanceof ExecutionIdentityVerificationError\n || error instanceof ExecutionIdentityUnavailableError\n ) {\n throw error;\n }\n const category = resolveJwtVerificationUnavailableCategory(error);\n if (category) {\n throw new ExecutionIdentityUnavailableError(category, { cause: error });\n }\n throw new ExecutionIdentityVerificationError({ cause: error });\n }\n }\n\n #assertRequestBinding(\n claims: z.infer<typeof ExecutionAssertionClaimsSchema>,\n request: ExecutionIdentityVerificationRequest,\n ): void {\n if (\n claims.adopterId !== this.#config.trustedAdopterId\n || claims.runtimeSessionId !== request.runtimeSessionId\n || claims.jti !== request.invocationId\n || claims.workflow !== request.workflow\n ) {\n throw new ExecutionIdentityVerificationError();\n }\n }\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ export declare const ExecutionHostJwtAlgorithmsSchema: z.ZodPipe<z.ZodArray<z.ZodEnum<{
3
+ ES256: "ES256";
4
+ RS256: "RS256";
5
+ PS256: "PS256";
6
+ EdDSA: "EdDSA";
7
+ }>>, z.ZodTransform<readonly ("ES256" | "RS256" | "PS256" | "EdDSA")[], ("ES256" | "RS256" | "PS256" | "EdDSA")[]>>;
8
+ export declare const JwtExecutionIdentityVerifierConfigSchema: z.ZodObject<{
9
+ executionIssuer: z.ZodURL;
10
+ executionAudience: z.ZodString;
11
+ executionJwksUrl: z.ZodCustom<URL, URL>;
12
+ executionJwtAlgorithms: z.ZodPipe<z.ZodArray<z.ZodEnum<{
13
+ ES256: "ES256";
14
+ RS256: "RS256";
15
+ PS256: "PS256";
16
+ EdDSA: "EdDSA";
17
+ }>>, z.ZodTransform<readonly ("ES256" | "RS256" | "PS256" | "EdDSA")[], ("ES256" | "RS256" | "PS256" | "EdDSA")[]>>;
18
+ trustedAdopterId: z.ZodString;
19
+ maxAssertionAgeSeconds: z.ZodNumber;
20
+ assertionClockToleranceSeconds: z.ZodNumber;
21
+ }, z.core.$strict>;
22
+ export declare const JwtExecutionHostMcpCapabilityVerifierConfigSchema: z.ZodObject<{
23
+ issuer: z.ZodURL;
24
+ audience: z.ZodString;
25
+ jwksUrl: z.ZodCustom<URL, URL>;
26
+ jwtAlgorithms: z.ZodPipe<z.ZodArray<z.ZodEnum<{
27
+ ES256: "ES256";
28
+ RS256: "RS256";
29
+ PS256: "PS256";
30
+ EdDSA: "EdDSA";
31
+ }>>, z.ZodTransform<readonly ("ES256" | "RS256" | "PS256" | "EdDSA")[], ("ES256" | "RS256" | "PS256" | "EdDSA")[]>>;
32
+ trustedAdopterId: z.ZodString;
33
+ serverId: z.ZodString;
34
+ maxCapabilityAgeSeconds: z.ZodNumber;
35
+ clockToleranceSeconds: z.ZodNumber;
36
+ }, z.core.$strict>;
37
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/host/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,gCAAgC;;;;;mHAI5C,CAAC;AAEF,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;kBAW1C,CAAC;AAEZ,eAAO,MAAM,iDAAiD;;;;;;;;;;;;;;kBAYnD,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { JwtAudienceSchema, JwtIssuerSchema, McpServerIdSchema, OpaqueIdSchema, isSafeWebUrl, } from '../contracts/index.js';
3
+ import { EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS } from './types.js';
4
+ export const ExecutionHostJwtAlgorithmsSchema = z.array(z.enum(EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS)).min(1).max(EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS.length).transform((algorithms) => Object.freeze([...new Set(algorithms)]));
5
+ export const JwtExecutionIdentityVerifierConfigSchema = z.object({
6
+ executionIssuer: JwtIssuerSchema,
7
+ executionAudience: JwtAudienceSchema,
8
+ executionJwksUrl: z.instanceof(URL).refine(isSafeWebUrl, 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment'),
9
+ executionJwtAlgorithms: ExecutionHostJwtAlgorithmsSchema,
10
+ trustedAdopterId: OpaqueIdSchema,
11
+ maxAssertionAgeSeconds: z.number().int().min(1).max(15 * 60),
12
+ assertionClockToleranceSeconds: z.number().int().min(0).max(60),
13
+ }).strict();
14
+ export const JwtExecutionHostMcpCapabilityVerifierConfigSchema = z.object({
15
+ issuer: JwtIssuerSchema,
16
+ audience: JwtAudienceSchema,
17
+ jwksUrl: z.instanceof(URL).refine(isSafeWebUrl, 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment'),
18
+ jwtAlgorithms: ExecutionHostJwtAlgorithmsSchema,
19
+ trustedAdopterId: OpaqueIdSchema,
20
+ serverId: McpServerIdSchema,
21
+ maxCapabilityAgeSeconds: z.number().int().min(1).max(15 * 60),
22
+ clockToleranceSeconds: z.number().int().min(0).max(60),
23
+ }).strict();
24
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":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;IACvB,QAAQ,EAAE,iBAAiB;IAC3B,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,CAC/B,YAAY,EACZ,gFAAgF,CACjF;IACD,aAAa,EAAE,gCAAgC;IAC/C,gBAAgB,EAAE,cAAc;IAChC,QAAQ,EAAE,iBAAiB;IAC3B,uBAAuB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;IAC7D,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;CACvD,CAAC,CAAC,MAAM,EAAE,CAAC","sourcesContent":["import { z } from 'zod';\nimport {\n JwtAudienceSchema,\n JwtIssuerSchema,\n McpServerIdSchema,\n OpaqueIdSchema,\n isSafeWebUrl,\n} from '../contracts/index.js';\nimport { EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS } from './types.js';\n\nexport const ExecutionHostJwtAlgorithmsSchema = z.array(\n z.enum(EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS),\n).min(1).max(EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS.length).transform(\n (algorithms) => Object.freeze([...new Set(algorithms)]),\n);\n\nexport const JwtExecutionIdentityVerifierConfigSchema = z.object({\n executionIssuer: JwtIssuerSchema,\n executionAudience: JwtAudienceSchema,\n executionJwksUrl: z.instanceof(URL).refine(\n isSafeWebUrl,\n 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment',\n ),\n executionJwtAlgorithms: ExecutionHostJwtAlgorithmsSchema,\n trustedAdopterId: OpaqueIdSchema,\n maxAssertionAgeSeconds: z.number().int().min(1).max(15 * 60),\n assertionClockToleranceSeconds: z.number().int().min(0).max(60),\n}).strict();\n\nexport const JwtExecutionHostMcpCapabilityVerifierConfigSchema = z.object({\n issuer: JwtIssuerSchema,\n audience: JwtAudienceSchema,\n jwksUrl: z.instanceof(URL).refine(\n isSafeWebUrl,\n 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment',\n ),\n jwtAlgorithms: ExecutionHostJwtAlgorithmsSchema,\n trustedAdopterId: OpaqueIdSchema,\n serverId: McpServerIdSchema,\n maxCapabilityAgeSeconds: z.number().int().min(1).max(15 * 60),\n clockToleranceSeconds: z.number().int().min(0).max(60),\n}).strict();\n"]}
@@ -0,0 +1,62 @@
1
+ import type { JWTVerifyGetKey } from 'jose';
2
+ import type { ExecutionScope, HostedExecutionWorkflow } from '../contracts/index.js';
3
+ export declare const EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS: readonly ["RS256", "PS256", "ES256", "EdDSA"];
4
+ export type ExecutionHostJwtAlgorithm = typeof EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS[number];
5
+ /** Authority established from one signed assertion and its request binding. */
6
+ export type VerifiedExecutionIdentity = Readonly<{
7
+ scope: Readonly<ExecutionScope>;
8
+ runtimeSessionId: string;
9
+ invocationId: string;
10
+ workflow: HostedExecutionWorkflow;
11
+ issuedAt: string;
12
+ expiresAt: string;
13
+ }>;
14
+ export type ExecutionIdentityVerificationRequest = Readonly<{
15
+ assertion: string;
16
+ runtimeSessionId: string;
17
+ invocationId: string;
18
+ workflow: HostedExecutionWorkflow;
19
+ }>;
20
+ export interface ExecutionIdentityVerifier {
21
+ verify(request: ExecutionIdentityVerificationRequest): Promise<VerifiedExecutionIdentity>;
22
+ }
23
+ export type JwtExecutionIdentityVerifierConfig = Readonly<{
24
+ executionIssuer: string;
25
+ executionAudience: string;
26
+ executionJwksUrl: URL;
27
+ executionJwtAlgorithms: readonly ExecutionHostJwtAlgorithm[];
28
+ trustedAdopterId: string;
29
+ maxAssertionAgeSeconds: number;
30
+ assertionClockToleranceSeconds: number;
31
+ }>;
32
+ /** Opaque MCP bearer whose claims match the independently verified execution. */
33
+ export type VerifiedExecutionHostMcpCapability = Readonly<{
34
+ assertion: string;
35
+ capabilityId: string;
36
+ serverId: string;
37
+ allowedTools: readonly string[];
38
+ issuedAt: string;
39
+ expiresAt: string;
40
+ }>;
41
+ export type ExecutionHostMcpCapabilityVerificationRequest = Readonly<{
42
+ assertion: string;
43
+ identity: VerifiedExecutionIdentity;
44
+ }>;
45
+ export interface ExecutionHostMcpCapabilityVerifier {
46
+ verify(request: ExecutionHostMcpCapabilityVerificationRequest): Promise<VerifiedExecutionHostMcpCapability>;
47
+ }
48
+ export type JwtExecutionHostMcpCapabilityVerifierConfig = Readonly<{
49
+ issuer: string;
50
+ audience: string;
51
+ jwksUrl: URL;
52
+ jwtAlgorithms: readonly ExecutionHostJwtAlgorithm[];
53
+ trustedAdopterId: string;
54
+ serverId: string;
55
+ maxCapabilityAgeSeconds: number;
56
+ clockToleranceSeconds: number;
57
+ }>;
58
+ export type ExecutionHostJwtVerifierOptions = Readonly<{
59
+ keyResolver?: JWTVerifyGetKey;
60
+ now?: () => Date;
61
+ }>;
62
+ //# sourceMappingURL=types.d.ts.map