@kya-os/contracts 1.5.4-canary.3 → 1.6.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/dist/agentshield-api/admin-schemas.d.ts +2 -8
- package/dist/agentshield-api/admin-schemas.js +0 -2
- package/dist/agentshield-api/admin-types.d.ts +0 -4
- package/dist/agentshield-api/index.d.ts +1 -1
- package/dist/agentshield-api/schemas.d.ts +150 -48
- package/dist/agentshield-api/schemas.js +32 -4
- package/dist/agentshield-api/types.d.ts +31 -4
- package/dist/audit/index.d.ts +193 -0
- package/dist/audit/index.js +100 -0
- package/dist/config/identity.d.ts +205 -2
- package/dist/config/identity.js +28 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/tool-context.d.ts +34 -0
- package/dist/config/tool-context.js +13 -0
- package/dist/consent/schemas.d.ts +101 -4
- package/dist/consent/schemas.js +139 -66
- package/dist/dashboard-config/schemas.d.ts +2248 -992
- package/dist/handshake.d.ts +14 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/tool-protection/index.d.ts +490 -14
- package/dist/tool-protection/index.js +89 -2
- package/dist/verifier/index.d.ts +1 -0
- package/dist/verifier/index.js +18 -0
- package/dist/well-known/index.d.ts +2 -2
- package/package.json +63 -120
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Types and Schemas
|
|
3
|
+
*
|
|
4
|
+
* Types and Zod schemas for audit logging in the MCP-I framework.
|
|
5
|
+
* These types are platform-agnostic and used across all implementations.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import type { AgentIdentity } from "../config/identity.js";
|
|
9
|
+
import type { SessionContext } from "../handshake.js";
|
|
10
|
+
/**
|
|
11
|
+
* Audit context schema for logging audit records
|
|
12
|
+
*
|
|
13
|
+
* Contains all metadata needed to generate an audit record.
|
|
14
|
+
* Privacy Note: Only metadata is extracted from these objects.
|
|
15
|
+
* The identity's private key, session's nonce, and other sensitive
|
|
16
|
+
* fields are NEVER included in the audit log.
|
|
17
|
+
*/
|
|
18
|
+
export declare const AuditContextSchema: z.ZodObject<{
|
|
19
|
+
/**
|
|
20
|
+
* Agent identity
|
|
21
|
+
* Only `did` and `keyId` are logged. Private key is NEVER logged.
|
|
22
|
+
*/
|
|
23
|
+
identity: z.ZodObject<{
|
|
24
|
+
did: z.ZodString;
|
|
25
|
+
kid: z.ZodString;
|
|
26
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
27
|
+
did: z.ZodString;
|
|
28
|
+
kid: z.ZodString;
|
|
29
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
30
|
+
did: z.ZodString;
|
|
31
|
+
kid: z.ZodString;
|
|
32
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
33
|
+
/**
|
|
34
|
+
* Session context
|
|
35
|
+
* Only `sessionId` and `audience` are logged. Nonce is NEVER logged.
|
|
36
|
+
*/
|
|
37
|
+
session: z.ZodObject<{
|
|
38
|
+
sessionId: z.ZodString;
|
|
39
|
+
audience: z.ZodString;
|
|
40
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
41
|
+
sessionId: z.ZodString;
|
|
42
|
+
audience: z.ZodString;
|
|
43
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
44
|
+
sessionId: z.ZodString;
|
|
45
|
+
audience: z.ZodString;
|
|
46
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
47
|
+
/**
|
|
48
|
+
* Request hash (SHA-256 with `sha256:` prefix)
|
|
49
|
+
*/
|
|
50
|
+
requestHash: z.ZodString;
|
|
51
|
+
/**
|
|
52
|
+
* Response hash (SHA-256 with `sha256:` prefix)
|
|
53
|
+
*/
|
|
54
|
+
responseHash: z.ZodString;
|
|
55
|
+
/**
|
|
56
|
+
* Verification result
|
|
57
|
+
* - 'yes': Proof was verified successfully
|
|
58
|
+
* - 'no': Proof verification failed
|
|
59
|
+
*/
|
|
60
|
+
verified: z.ZodEnum<["yes", "no"]>;
|
|
61
|
+
/**
|
|
62
|
+
* Optional scope identifier
|
|
63
|
+
* Application-level scope (e.g., 'orders.create', 'users.read').
|
|
64
|
+
* If not provided, '-' is used in the audit log.
|
|
65
|
+
*/
|
|
66
|
+
scopeId: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
requestHash: string;
|
|
69
|
+
responseHash: string;
|
|
70
|
+
session: {
|
|
71
|
+
audience: string;
|
|
72
|
+
sessionId: string;
|
|
73
|
+
} & {
|
|
74
|
+
[k: string]: unknown;
|
|
75
|
+
};
|
|
76
|
+
verified: "yes" | "no";
|
|
77
|
+
identity: {
|
|
78
|
+
did: string;
|
|
79
|
+
kid: string;
|
|
80
|
+
} & {
|
|
81
|
+
[k: string]: unknown;
|
|
82
|
+
};
|
|
83
|
+
scopeId?: string | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
requestHash: string;
|
|
86
|
+
responseHash: string;
|
|
87
|
+
session: {
|
|
88
|
+
audience: string;
|
|
89
|
+
sessionId: string;
|
|
90
|
+
} & {
|
|
91
|
+
[k: string]: unknown;
|
|
92
|
+
};
|
|
93
|
+
verified: "yes" | "no";
|
|
94
|
+
identity: {
|
|
95
|
+
did: string;
|
|
96
|
+
kid: string;
|
|
97
|
+
} & {
|
|
98
|
+
[k: string]: unknown;
|
|
99
|
+
};
|
|
100
|
+
scopeId?: string | undefined;
|
|
101
|
+
}>;
|
|
102
|
+
export type AuditContext = {
|
|
103
|
+
identity: AgentIdentity;
|
|
104
|
+
session: SessionContext;
|
|
105
|
+
requestHash: string;
|
|
106
|
+
responseHash: string;
|
|
107
|
+
verified: "yes" | "no";
|
|
108
|
+
scopeId?: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Event context schema for logging events that bypass session deduplication
|
|
112
|
+
*
|
|
113
|
+
* Used for consent events where multiple events occur in the same session.
|
|
114
|
+
* Unlike AuditContext, this allows multiple events per session.
|
|
115
|
+
*/
|
|
116
|
+
export declare const AuditEventContextSchema: z.ZodObject<{
|
|
117
|
+
/**
|
|
118
|
+
* Event type identifier
|
|
119
|
+
* @example "consent:page_viewed", "consent:approved", "runtime:initialized"
|
|
120
|
+
*/
|
|
121
|
+
eventType: z.ZodString;
|
|
122
|
+
/**
|
|
123
|
+
* Agent identity
|
|
124
|
+
* Only `did` and `keyId` are logged. Private key is NEVER logged.
|
|
125
|
+
*/
|
|
126
|
+
identity: z.ZodObject<{
|
|
127
|
+
did: z.ZodString;
|
|
128
|
+
kid: z.ZodString;
|
|
129
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
130
|
+
did: z.ZodString;
|
|
131
|
+
kid: z.ZodString;
|
|
132
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
133
|
+
did: z.ZodString;
|
|
134
|
+
kid: z.ZodString;
|
|
135
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
136
|
+
/**
|
|
137
|
+
* Session context
|
|
138
|
+
* Only `sessionId` and `audience` are logged. Nonce is NEVER logged.
|
|
139
|
+
*/
|
|
140
|
+
session: z.ZodObject<{
|
|
141
|
+
sessionId: z.ZodString;
|
|
142
|
+
audience: z.ZodString;
|
|
143
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
144
|
+
sessionId: z.ZodString;
|
|
145
|
+
audience: z.ZodString;
|
|
146
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
147
|
+
sessionId: z.ZodString;
|
|
148
|
+
audience: z.ZodString;
|
|
149
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
150
|
+
/**
|
|
151
|
+
* Optional event-specific data
|
|
152
|
+
* Used for generating event hash. Not logged directly.
|
|
153
|
+
*/
|
|
154
|
+
eventData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
session: {
|
|
157
|
+
audience: string;
|
|
158
|
+
sessionId: string;
|
|
159
|
+
} & {
|
|
160
|
+
[k: string]: unknown;
|
|
161
|
+
};
|
|
162
|
+
identity: {
|
|
163
|
+
did: string;
|
|
164
|
+
kid: string;
|
|
165
|
+
} & {
|
|
166
|
+
[k: string]: unknown;
|
|
167
|
+
};
|
|
168
|
+
eventType: string;
|
|
169
|
+
eventData?: Record<string, unknown> | undefined;
|
|
170
|
+
}, {
|
|
171
|
+
session: {
|
|
172
|
+
audience: string;
|
|
173
|
+
sessionId: string;
|
|
174
|
+
} & {
|
|
175
|
+
[k: string]: unknown;
|
|
176
|
+
};
|
|
177
|
+
identity: {
|
|
178
|
+
did: string;
|
|
179
|
+
kid: string;
|
|
180
|
+
} & {
|
|
181
|
+
[k: string]: unknown;
|
|
182
|
+
};
|
|
183
|
+
eventType: string;
|
|
184
|
+
eventData?: Record<string, unknown> | undefined;
|
|
185
|
+
}>;
|
|
186
|
+
export type AuditEventContext = {
|
|
187
|
+
eventType: string;
|
|
188
|
+
identity: AgentIdentity;
|
|
189
|
+
session: SessionContext;
|
|
190
|
+
eventData?: Record<string, any>;
|
|
191
|
+
};
|
|
192
|
+
export type { AuditRecord } from "../proof.js";
|
|
193
|
+
export { AuditRecordSchema } from "../proof.js";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Audit Types and Schemas
|
|
4
|
+
*
|
|
5
|
+
* Types and Zod schemas for audit logging in the MCP-I framework.
|
|
6
|
+
* These types are platform-agnostic and used across all implementations.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuditRecordSchema = exports.AuditEventContextSchema = exports.AuditContextSchema = void 0;
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
/**
|
|
12
|
+
* Audit context schema for logging audit records
|
|
13
|
+
*
|
|
14
|
+
* Contains all metadata needed to generate an audit record.
|
|
15
|
+
* Privacy Note: Only metadata is extracted from these objects.
|
|
16
|
+
* The identity's private key, session's nonce, and other sensitive
|
|
17
|
+
* fields are NEVER included in the audit log.
|
|
18
|
+
*/
|
|
19
|
+
exports.AuditContextSchema = zod_1.z.object({
|
|
20
|
+
/**
|
|
21
|
+
* Agent identity
|
|
22
|
+
* Only `did` and `keyId` are logged. Private key is NEVER logged.
|
|
23
|
+
*/
|
|
24
|
+
identity: zod_1.z
|
|
25
|
+
.object({
|
|
26
|
+
did: zod_1.z.string().min(1),
|
|
27
|
+
kid: zod_1.z.string().min(1),
|
|
28
|
+
})
|
|
29
|
+
.passthrough(), // Allow additional fields but only did/kid are used
|
|
30
|
+
/**
|
|
31
|
+
* Session context
|
|
32
|
+
* Only `sessionId` and `audience` are logged. Nonce is NEVER logged.
|
|
33
|
+
*/
|
|
34
|
+
session: zod_1.z
|
|
35
|
+
.object({
|
|
36
|
+
sessionId: zod_1.z.string().min(1),
|
|
37
|
+
audience: zod_1.z.string().min(1),
|
|
38
|
+
})
|
|
39
|
+
.passthrough(), // Allow additional fields but only sessionId/audience are used
|
|
40
|
+
/**
|
|
41
|
+
* Request hash (SHA-256 with `sha256:` prefix)
|
|
42
|
+
*/
|
|
43
|
+
requestHash: zod_1.z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
44
|
+
/**
|
|
45
|
+
* Response hash (SHA-256 with `sha256:` prefix)
|
|
46
|
+
*/
|
|
47
|
+
responseHash: zod_1.z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
48
|
+
/**
|
|
49
|
+
* Verification result
|
|
50
|
+
* - 'yes': Proof was verified successfully
|
|
51
|
+
* - 'no': Proof verification failed
|
|
52
|
+
*/
|
|
53
|
+
verified: zod_1.z.enum(["yes", "no"]),
|
|
54
|
+
/**
|
|
55
|
+
* Optional scope identifier
|
|
56
|
+
* Application-level scope (e.g., 'orders.create', 'users.read').
|
|
57
|
+
* If not provided, '-' is used in the audit log.
|
|
58
|
+
*/
|
|
59
|
+
scopeId: zod_1.z.string().optional(),
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Event context schema for logging events that bypass session deduplication
|
|
63
|
+
*
|
|
64
|
+
* Used for consent events where multiple events occur in the same session.
|
|
65
|
+
* Unlike AuditContext, this allows multiple events per session.
|
|
66
|
+
*/
|
|
67
|
+
exports.AuditEventContextSchema = zod_1.z.object({
|
|
68
|
+
/**
|
|
69
|
+
* Event type identifier
|
|
70
|
+
* @example "consent:page_viewed", "consent:approved", "runtime:initialized"
|
|
71
|
+
*/
|
|
72
|
+
eventType: zod_1.z.string().min(1),
|
|
73
|
+
/**
|
|
74
|
+
* Agent identity
|
|
75
|
+
* Only `did` and `keyId` are logged. Private key is NEVER logged.
|
|
76
|
+
*/
|
|
77
|
+
identity: zod_1.z
|
|
78
|
+
.object({
|
|
79
|
+
did: zod_1.z.string().min(1),
|
|
80
|
+
kid: zod_1.z.string().min(1),
|
|
81
|
+
})
|
|
82
|
+
.passthrough(), // Allow additional fields but only did/kid are used
|
|
83
|
+
/**
|
|
84
|
+
* Session context
|
|
85
|
+
* Only `sessionId` and `audience` are logged. Nonce is NEVER logged.
|
|
86
|
+
*/
|
|
87
|
+
session: zod_1.z
|
|
88
|
+
.object({
|
|
89
|
+
sessionId: zod_1.z.string().min(1),
|
|
90
|
+
audience: zod_1.z.string().min(1),
|
|
91
|
+
})
|
|
92
|
+
.passthrough(), // Allow additional fields but only sessionId/audience are used
|
|
93
|
+
/**
|
|
94
|
+
* Optional event-specific data
|
|
95
|
+
* Used for generating event hash. Not logged directly.
|
|
96
|
+
*/
|
|
97
|
+
eventData: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
98
|
+
});
|
|
99
|
+
var proof_js_1 = require("../proof.js");
|
|
100
|
+
Object.defineProperty(exports, "AuditRecordSchema", { enumerable: true, get: function () { return proof_js_1.AuditRecordSchema; } });
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module @kya-os/contracts/config
|
|
8
8
|
*/
|
|
9
|
+
import { z } from "zod";
|
|
9
10
|
/**
|
|
10
11
|
* Runtime Identity Configuration
|
|
11
12
|
*
|
|
@@ -25,7 +26,7 @@ export interface RuntimeIdentityConfig {
|
|
|
25
26
|
* Runtime environment for identity
|
|
26
27
|
* Determines where keys come from and how they're managed
|
|
27
28
|
*/
|
|
28
|
-
environment:
|
|
29
|
+
environment: "development" | "production";
|
|
29
30
|
/**
|
|
30
31
|
* Production identity configuration
|
|
31
32
|
* Used when environment is 'production'
|
|
@@ -71,7 +72,209 @@ export interface RuntimeIdentityConfig {
|
|
|
71
72
|
* - 'persistent': User DIDs are persisted in storage (requires did:web setup)
|
|
72
73
|
* @default 'ephemeral'
|
|
73
74
|
*/
|
|
74
|
-
userDidStorage?:
|
|
75
|
+
userDidStorage?: "ephemeral" | "persistent";
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* OAuth Provider Configuration
|
|
79
|
+
*
|
|
80
|
+
* Configuration for a single OAuth provider (GitHub, Google, etc.)
|
|
81
|
+
*/
|
|
82
|
+
export interface OAuthProvider {
|
|
83
|
+
/** OAuth client ID (public, safe to expose) */
|
|
84
|
+
clientId: string;
|
|
85
|
+
/** OAuth client secret (NOT returned in API response for security) */
|
|
86
|
+
clientSecret?: string | null;
|
|
87
|
+
/** OAuth authorization URL */
|
|
88
|
+
authorizationUrl: string;
|
|
89
|
+
/** OAuth token exchange URL */
|
|
90
|
+
tokenUrl: string;
|
|
91
|
+
/** OAuth user info endpoint URL */
|
|
92
|
+
userInfoUrl?: string;
|
|
93
|
+
/** Whether provider supports PKCE (Proof Key for Code Exchange) */
|
|
94
|
+
supportsPKCE: boolean;
|
|
95
|
+
/** Whether provider requires client secret (false for PKCE-only providers) */
|
|
96
|
+
requiresClientSecret: boolean;
|
|
97
|
+
/** Available scopes for this provider */
|
|
98
|
+
scopes?: string[];
|
|
99
|
+
/** Default scopes to request */
|
|
100
|
+
defaultScopes?: string[];
|
|
101
|
+
/** Whether provider uses proxy mode (via AgentShield) */
|
|
102
|
+
proxyMode?: boolean;
|
|
103
|
+
/** Custom OAuth parameters to include in authorization URL (e.g., audience, acr_values) */
|
|
104
|
+
customParams?: Record<string, string>;
|
|
105
|
+
/** Token endpoint authentication method */
|
|
106
|
+
tokenEndpointAuthMethod?: "client_secret_post" | "client_secret_basic";
|
|
107
|
+
/** OAuth response type (default: "code") */
|
|
108
|
+
responseType?: string;
|
|
109
|
+
/** OAuth grant type (default: "authorization_code") */
|
|
110
|
+
grantType?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* OAuth Configuration
|
|
114
|
+
*
|
|
115
|
+
* Configuration for OAuth providers fetched from AgentShield API.
|
|
116
|
+
* Contains all available providers for a project.
|
|
117
|
+
*
|
|
118
|
+
* Note: API does NOT return a defaultProvider field (Phase 1 architecture).
|
|
119
|
+
* Phase 1 uses configured provider as temporary fallback.
|
|
120
|
+
* Phase 2+ requires tools to explicitly specify oauthProvider.
|
|
121
|
+
*/
|
|
122
|
+
export interface OAuthConfig {
|
|
123
|
+
/** Map of provider names to provider configurations */
|
|
124
|
+
providers: Record<string, OAuthProvider>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Zod schema for OAuthProvider validation
|
|
128
|
+
*/
|
|
129
|
+
export declare const OAuthProviderSchema: z.ZodObject<{
|
|
130
|
+
clientId: z.ZodString;
|
|
131
|
+
clientSecret: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
132
|
+
authorizationUrl: z.ZodString;
|
|
133
|
+
tokenUrl: z.ZodString;
|
|
134
|
+
userInfoUrl: z.ZodOptional<z.ZodString>;
|
|
135
|
+
supportsPKCE: z.ZodBoolean;
|
|
136
|
+
requiresClientSecret: z.ZodBoolean;
|
|
137
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
138
|
+
defaultScopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
139
|
+
proxyMode: z.ZodOptional<z.ZodBoolean>;
|
|
140
|
+
customParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
141
|
+
tokenEndpointAuthMethod: z.ZodOptional<z.ZodEnum<["client_secret_post", "client_secret_basic"]>>;
|
|
142
|
+
responseType: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
143
|
+
grantType: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
clientId: string;
|
|
146
|
+
authorizationUrl: string;
|
|
147
|
+
tokenUrl: string;
|
|
148
|
+
supportsPKCE: boolean;
|
|
149
|
+
requiresClientSecret: boolean;
|
|
150
|
+
responseType: string;
|
|
151
|
+
grantType: string;
|
|
152
|
+
scopes?: string[] | undefined;
|
|
153
|
+
clientSecret?: string | null | undefined;
|
|
154
|
+
userInfoUrl?: string | undefined;
|
|
155
|
+
defaultScopes?: string[] | undefined;
|
|
156
|
+
proxyMode?: boolean | undefined;
|
|
157
|
+
customParams?: Record<string, string> | undefined;
|
|
158
|
+
tokenEndpointAuthMethod?: "client_secret_post" | "client_secret_basic" | undefined;
|
|
159
|
+
}, {
|
|
160
|
+
clientId: string;
|
|
161
|
+
authorizationUrl: string;
|
|
162
|
+
tokenUrl: string;
|
|
163
|
+
supportsPKCE: boolean;
|
|
164
|
+
requiresClientSecret: boolean;
|
|
165
|
+
scopes?: string[] | undefined;
|
|
166
|
+
clientSecret?: string | null | undefined;
|
|
167
|
+
userInfoUrl?: string | undefined;
|
|
168
|
+
defaultScopes?: string[] | undefined;
|
|
169
|
+
proxyMode?: boolean | undefined;
|
|
170
|
+
customParams?: Record<string, string> | undefined;
|
|
171
|
+
tokenEndpointAuthMethod?: "client_secret_post" | "client_secret_basic" | undefined;
|
|
172
|
+
responseType?: string | undefined;
|
|
173
|
+
grantType?: string | undefined;
|
|
174
|
+
}>;
|
|
175
|
+
/**
|
|
176
|
+
* Zod schema for OAuthConfig validation
|
|
177
|
+
*/
|
|
178
|
+
export declare const OAuthConfigSchema: z.ZodObject<{
|
|
179
|
+
providers: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
180
|
+
clientId: z.ZodString;
|
|
181
|
+
clientSecret: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
182
|
+
authorizationUrl: z.ZodString;
|
|
183
|
+
tokenUrl: z.ZodString;
|
|
184
|
+
userInfoUrl: z.ZodOptional<z.ZodString>;
|
|
185
|
+
supportsPKCE: z.ZodBoolean;
|
|
186
|
+
requiresClientSecret: z.ZodBoolean;
|
|
187
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
188
|
+
defaultScopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
189
|
+
proxyMode: z.ZodOptional<z.ZodBoolean>;
|
|
190
|
+
customParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
191
|
+
tokenEndpointAuthMethod: z.ZodOptional<z.ZodEnum<["client_secret_post", "client_secret_basic"]>>;
|
|
192
|
+
responseType: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
193
|
+
grantType: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
194
|
+
}, "strip", z.ZodTypeAny, {
|
|
195
|
+
clientId: string;
|
|
196
|
+
authorizationUrl: string;
|
|
197
|
+
tokenUrl: string;
|
|
198
|
+
supportsPKCE: boolean;
|
|
199
|
+
requiresClientSecret: boolean;
|
|
200
|
+
responseType: string;
|
|
201
|
+
grantType: string;
|
|
202
|
+
scopes?: string[] | undefined;
|
|
203
|
+
clientSecret?: string | null | undefined;
|
|
204
|
+
userInfoUrl?: string | undefined;
|
|
205
|
+
defaultScopes?: string[] | undefined;
|
|
206
|
+
proxyMode?: boolean | undefined;
|
|
207
|
+
customParams?: Record<string, string> | undefined;
|
|
208
|
+
tokenEndpointAuthMethod?: "client_secret_post" | "client_secret_basic" | undefined;
|
|
209
|
+
}, {
|
|
210
|
+
clientId: string;
|
|
211
|
+
authorizationUrl: string;
|
|
212
|
+
tokenUrl: string;
|
|
213
|
+
supportsPKCE: boolean;
|
|
214
|
+
requiresClientSecret: boolean;
|
|
215
|
+
scopes?: string[] | undefined;
|
|
216
|
+
clientSecret?: string | null | undefined;
|
|
217
|
+
userInfoUrl?: string | undefined;
|
|
218
|
+
defaultScopes?: string[] | undefined;
|
|
219
|
+
proxyMode?: boolean | undefined;
|
|
220
|
+
customParams?: Record<string, string> | undefined;
|
|
221
|
+
tokenEndpointAuthMethod?: "client_secret_post" | "client_secret_basic" | undefined;
|
|
222
|
+
responseType?: string | undefined;
|
|
223
|
+
grantType?: string | undefined;
|
|
224
|
+
}>>;
|
|
225
|
+
}, "strip", z.ZodTypeAny, {
|
|
226
|
+
providers: Record<string, {
|
|
227
|
+
clientId: string;
|
|
228
|
+
authorizationUrl: string;
|
|
229
|
+
tokenUrl: string;
|
|
230
|
+
supportsPKCE: boolean;
|
|
231
|
+
requiresClientSecret: boolean;
|
|
232
|
+
responseType: string;
|
|
233
|
+
grantType: string;
|
|
234
|
+
scopes?: string[] | undefined;
|
|
235
|
+
clientSecret?: string | null | undefined;
|
|
236
|
+
userInfoUrl?: string | undefined;
|
|
237
|
+
defaultScopes?: string[] | undefined;
|
|
238
|
+
proxyMode?: boolean | undefined;
|
|
239
|
+
customParams?: Record<string, string> | undefined;
|
|
240
|
+
tokenEndpointAuthMethod?: "client_secret_post" | "client_secret_basic" | undefined;
|
|
241
|
+
}>;
|
|
242
|
+
}, {
|
|
243
|
+
providers: Record<string, {
|
|
244
|
+
clientId: string;
|
|
245
|
+
authorizationUrl: string;
|
|
246
|
+
tokenUrl: string;
|
|
247
|
+
supportsPKCE: boolean;
|
|
248
|
+
requiresClientSecret: boolean;
|
|
249
|
+
scopes?: string[] | undefined;
|
|
250
|
+
clientSecret?: string | null | undefined;
|
|
251
|
+
userInfoUrl?: string | undefined;
|
|
252
|
+
defaultScopes?: string[] | undefined;
|
|
253
|
+
proxyMode?: boolean | undefined;
|
|
254
|
+
customParams?: Record<string, string> | undefined;
|
|
255
|
+
tokenEndpointAuthMethod?: "client_secret_post" | "client_secret_basic" | undefined;
|
|
256
|
+
responseType?: string | undefined;
|
|
257
|
+
grantType?: string | undefined;
|
|
258
|
+
}>;
|
|
259
|
+
}>;
|
|
260
|
+
/**
|
|
261
|
+
* IDP Tokens
|
|
262
|
+
*
|
|
263
|
+
* Tokens received from OAuth provider (IDP = Identity Provider)
|
|
264
|
+
*/
|
|
265
|
+
export interface IdpTokens {
|
|
266
|
+
/** OAuth access token for API calls */
|
|
267
|
+
access_token: string;
|
|
268
|
+
/** OAuth refresh token (optional) */
|
|
269
|
+
refresh_token?: string;
|
|
270
|
+
/** Token expiration time in seconds */
|
|
271
|
+
expires_in?: number;
|
|
272
|
+
/** Token expiration timestamp (milliseconds since epoch) */
|
|
273
|
+
expires_at: number;
|
|
274
|
+
/** Token type (usually "Bearer") */
|
|
275
|
+
token_type: string;
|
|
276
|
+
/** Granted scopes */
|
|
277
|
+
scope?: string;
|
|
75
278
|
}
|
|
76
279
|
/**
|
|
77
280
|
* Agent identity representation
|
package/dist/config/identity.js
CHANGED
|
@@ -8,3 +8,31 @@
|
|
|
8
8
|
* @module @kya-os/contracts/config
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.OAuthConfigSchema = exports.OAuthProviderSchema = void 0;
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
/**
|
|
14
|
+
* Zod schema for OAuthProvider validation
|
|
15
|
+
*/
|
|
16
|
+
exports.OAuthProviderSchema = zod_1.z.object({
|
|
17
|
+
clientId: zod_1.z.string().min(1),
|
|
18
|
+
clientSecret: zod_1.z.string().nullable().optional(),
|
|
19
|
+
authorizationUrl: zod_1.z.string().url(),
|
|
20
|
+
tokenUrl: zod_1.z.string().url(),
|
|
21
|
+
userInfoUrl: zod_1.z.string().url().optional(),
|
|
22
|
+
supportsPKCE: zod_1.z.boolean(),
|
|
23
|
+
requiresClientSecret: zod_1.z.boolean(),
|
|
24
|
+
scopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
25
|
+
defaultScopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
26
|
+
proxyMode: zod_1.z.boolean().optional(),
|
|
27
|
+
// Phase 3: Custom IDP Support
|
|
28
|
+
customParams: zod_1.z.record(zod_1.z.string()).optional(),
|
|
29
|
+
tokenEndpointAuthMethod: zod_1.z.enum(["client_secret_post", "client_secret_basic"]).optional(),
|
|
30
|
+
responseType: zod_1.z.string().optional().default("code"),
|
|
31
|
+
grantType: zod_1.z.string().optional().default("authorization_code"),
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Zod schema for OAuthConfig validation
|
|
35
|
+
*/
|
|
36
|
+
exports.OAuthConfigSchema = zod_1.z.object({
|
|
37
|
+
providers: zod_1.z.record(zod_1.z.string(), exports.OAuthProviderSchema),
|
|
38
|
+
});
|
package/dist/config/index.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ import type { ProofingConfig } from "./proofing.js";
|
|
|
12
12
|
import type { DelegationConfig } from "./delegation.js";
|
|
13
13
|
import type { ToolProtectionSourceConfig } from "./tool-protection.js";
|
|
14
14
|
export { MCPIBaseConfig } from "./base.js";
|
|
15
|
-
export { RuntimeIdentityConfig, AgentIdentity } from "./identity.js";
|
|
15
|
+
export { RuntimeIdentityConfig, AgentIdentity, OAuthProvider, OAuthConfig, IdpTokens, } from "./identity.js";
|
|
16
|
+
export type { ToolExecutionContext } from "./tool-context.js";
|
|
16
17
|
/**
|
|
17
18
|
* @deprecated Use RuntimeIdentityConfig instead
|
|
18
19
|
* This export is maintained for backward compatibility
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Execution Context
|
|
3
|
+
*
|
|
4
|
+
* Execution context passed to tool handlers, enabling tools to access
|
|
5
|
+
* IDP tokens for external API calls (GitHub, Google, etc.).
|
|
6
|
+
*
|
|
7
|
+
* All fields are optional for backward compatibility - tools that don't
|
|
8
|
+
* require OAuth will receive undefined context.
|
|
9
|
+
*
|
|
10
|
+
* @package @kya-os/contracts
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Execution context passed to tool handlers
|
|
14
|
+
*
|
|
15
|
+
* Enables tools to access IDP tokens for external API calls.
|
|
16
|
+
* Context is only provided when:
|
|
17
|
+
* - Tool requires OAuth (has requiredScopes)
|
|
18
|
+
* - User DID is available
|
|
19
|
+
* - IDP token is successfully resolved
|
|
20
|
+
*/
|
|
21
|
+
export interface ToolExecutionContext {
|
|
22
|
+
/** IDP access token for external API calls (e.g., GitHub, Google) */
|
|
23
|
+
idpToken?: string;
|
|
24
|
+
/** OAuth provider name (e.g., "github", "google") */
|
|
25
|
+
provider?: string;
|
|
26
|
+
/** Scopes granted for this token */
|
|
27
|
+
scopes?: string[];
|
|
28
|
+
/** User DID associated with this token */
|
|
29
|
+
userDid?: string;
|
|
30
|
+
/** Session ID */
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
/** Delegation token (MCP-I internal authorization) */
|
|
33
|
+
delegationToken?: string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool Execution Context
|
|
4
|
+
*
|
|
5
|
+
* Execution context passed to tool handlers, enabling tools to access
|
|
6
|
+
* IDP tokens for external API calls (GitHub, Google, etc.).
|
|
7
|
+
*
|
|
8
|
+
* All fields are optional for backward compatibility - tools that don't
|
|
9
|
+
* require OAuth will receive undefined context.
|
|
10
|
+
*
|
|
11
|
+
* @package @kya-os/contracts
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|