@kya-os/contracts 1.6.7 → 1.6.9

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.
@@ -464,6 +464,7 @@ export declare const verifyDelegationRequestSchema: z.ZodObject<{
464
464
  scopes: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
465
465
  timestamp: z.ZodOptional<z.ZodNumber>;
466
466
  agent_did: z.ZodString;
467
+ user_did: z.ZodOptional<z.ZodString>;
467
468
  credential_jwt: z.ZodOptional<z.ZodString>;
468
469
  delegation_token: z.ZodOptional<z.ZodString>;
469
470
  client_info: z.ZodOptional<z.ZodObject<{
@@ -483,6 +484,7 @@ export declare const verifyDelegationRequestSchema: z.ZodObject<{
483
484
  agent_did: string;
484
485
  scopes?: string[] | undefined;
485
486
  timestamp?: number | undefined;
487
+ user_did?: string | undefined;
486
488
  credential_jwt?: string | undefined;
487
489
  delegation_token?: string | undefined;
488
490
  client_info?: {
@@ -494,6 +496,7 @@ export declare const verifyDelegationRequestSchema: z.ZodObject<{
494
496
  agent_did: string;
495
497
  scopes?: string[] | undefined;
496
498
  timestamp?: number | undefined;
499
+ user_did?: string | undefined;
497
500
  credential_jwt?: string | undefined;
498
501
  delegation_token?: string | undefined;
499
502
  client_info?: {
@@ -129,6 +129,9 @@ exports.delegationCredentialSchema = zod_1.z.object({
129
129
  */
130
130
  exports.verifyDelegationRequestSchema = zod_1.z.object({
131
131
  agent_did: zod_1.z.string(),
132
+ // User DID for user-scoped delegation verification (RECOMMENDED)
133
+ // Prevents cross-user delegation leakage where User B could use User A's delegation
134
+ user_did: zod_1.z.string().optional(),
132
135
  credential_jwt: zod_1.z.string().optional(), // Optional, omit (don't set to empty string) when not available for OAuth flow
133
136
  delegation_token: zod_1.z.string().optional(), // Optional, for stateless MCP servers
134
137
  scopes: zod_1.z.array(zod_1.z.string()).optional(), // Optional, can be empty array
@@ -111,6 +111,16 @@ export interface ProofSubmissionResponse {
111
111
  export interface VerifyDelegationRequest {
112
112
  /** Agent DID to verify */
113
113
  agent_did: string;
114
+ /**
115
+ * User DID for user-scoped delegation verification (RECOMMENDED)
116
+ *
117
+ * When provided, AgentShield validates that the delegation belongs to this specific user.
118
+ * This prevents cross-user delegation leakage where User B could use User A's delegation.
119
+ *
120
+ * Without user_did, verification relies on delegation_token alone which may not provide
121
+ * user-level isolation in all scenarios (e.g., legacy agent-only delegations).
122
+ */
123
+ user_did?: string;
114
124
  /** Credential JWT (optional, defaults to empty string for OAuth flow) */
115
125
  credential_jwt?: string;
116
126
  /** Delegation token from OAuth flow (optional, for stateless MCP servers) */
@@ -160,6 +160,12 @@ export interface CredentialProviderConfig extends BaseProviderConfig {
160
160
  formTitle?: string;
161
161
  formDescription?: string;
162
162
  identityFieldLabel?: string;
163
+ /**
164
+ * Input type for the identity/username field
165
+ * Use "text" for username-based authentication, "email" for email-based
166
+ * @default Automatically detected from field name (email -> "email", otherwise "text")
167
+ */
168
+ identityFieldType?: "text" | "email" | "tel";
163
169
  passwordFieldLabel?: string;
164
170
  submitButtonText?: string;
165
171
  };
@@ -211,6 +217,7 @@ export declare const CredentialProviderConfigSchema: z.ZodObject<{
211
217
  formTitle: z.ZodOptional<z.ZodString>;
212
218
  formDescription: z.ZodOptional<z.ZodString>;
213
219
  identityFieldLabel: z.ZodOptional<z.ZodString>;
220
+ identityFieldType: z.ZodOptional<z.ZodEnum<["text", "email", "tel"]>>;
214
221
  passwordFieldLabel: z.ZodOptional<z.ZodString>;
215
222
  submitButtonText: z.ZodOptional<z.ZodString>;
216
223
  }, "strip", z.ZodTypeAny, {
@@ -218,6 +225,7 @@ export declare const CredentialProviderConfigSchema: z.ZodObject<{
218
225
  formTitle?: string | undefined;
219
226
  formDescription?: string | undefined;
220
227
  identityFieldLabel?: string | undefined;
228
+ identityFieldType?: "text" | "email" | "tel" | undefined;
221
229
  passwordFieldLabel?: string | undefined;
222
230
  submitButtonText?: string | undefined;
223
231
  }, {
@@ -225,6 +233,7 @@ export declare const CredentialProviderConfigSchema: z.ZodObject<{
225
233
  formTitle?: string | undefined;
226
234
  formDescription?: string | undefined;
227
235
  identityFieldLabel?: string | undefined;
236
+ identityFieldType?: "text" | "email" | "tel" | undefined;
228
237
  passwordFieldLabel?: string | undefined;
229
238
  submitButtonText?: string | undefined;
230
239
  }>>;
@@ -254,6 +263,7 @@ export declare const CredentialProviderConfigSchema: z.ZodObject<{
254
263
  formTitle?: string | undefined;
255
264
  formDescription?: string | undefined;
256
265
  identityFieldLabel?: string | undefined;
266
+ identityFieldType?: "text" | "email" | "tel" | undefined;
257
267
  passwordFieldLabel?: string | undefined;
258
268
  submitButtonText?: string | undefined;
259
269
  } | undefined;
@@ -283,6 +293,7 @@ export declare const CredentialProviderConfigSchema: z.ZodObject<{
283
293
  formTitle?: string | undefined;
284
294
  formDescription?: string | undefined;
285
295
  identityFieldLabel?: string | undefined;
296
+ identityFieldType?: "text" | "email" | "tel" | undefined;
286
297
  passwordFieldLabel?: string | undefined;
287
298
  submitButtonText?: string | undefined;
288
299
  } | undefined;
@@ -661,6 +672,7 @@ export declare const AuthProviderSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
661
672
  formTitle: z.ZodOptional<z.ZodString>;
662
673
  formDescription: z.ZodOptional<z.ZodString>;
663
674
  identityFieldLabel: z.ZodOptional<z.ZodString>;
675
+ identityFieldType: z.ZodOptional<z.ZodEnum<["text", "email", "tel"]>>;
664
676
  passwordFieldLabel: z.ZodOptional<z.ZodString>;
665
677
  submitButtonText: z.ZodOptional<z.ZodString>;
666
678
  }, "strip", z.ZodTypeAny, {
@@ -668,6 +680,7 @@ export declare const AuthProviderSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
668
680
  formTitle?: string | undefined;
669
681
  formDescription?: string | undefined;
670
682
  identityFieldLabel?: string | undefined;
683
+ identityFieldType?: "text" | "email" | "tel" | undefined;
671
684
  passwordFieldLabel?: string | undefined;
672
685
  submitButtonText?: string | undefined;
673
686
  }, {
@@ -675,6 +688,7 @@ export declare const AuthProviderSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
675
688
  formTitle?: string | undefined;
676
689
  formDescription?: string | undefined;
677
690
  identityFieldLabel?: string | undefined;
691
+ identityFieldType?: "text" | "email" | "tel" | undefined;
678
692
  passwordFieldLabel?: string | undefined;
679
693
  submitButtonText?: string | undefined;
680
694
  }>>;
@@ -704,6 +718,7 @@ export declare const AuthProviderSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
704
718
  formTitle?: string | undefined;
705
719
  formDescription?: string | undefined;
706
720
  identityFieldLabel?: string | undefined;
721
+ identityFieldType?: "text" | "email" | "tel" | undefined;
707
722
  passwordFieldLabel?: string | undefined;
708
723
  submitButtonText?: string | undefined;
709
724
  } | undefined;
@@ -733,6 +748,7 @@ export declare const AuthProviderSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
733
748
  formTitle?: string | undefined;
734
749
  formDescription?: string | undefined;
735
750
  identityFieldLabel?: string | undefined;
751
+ identityFieldType?: "text" | "email" | "tel" | undefined;
736
752
  passwordFieldLabel?: string | undefined;
737
753
  submitButtonText?: string | undefined;
738
754
  } | undefined;
@@ -42,6 +42,7 @@ exports.CredentialProviderConfigSchema = zod_1.z.object({
42
42
  formTitle: zod_1.z.string().optional(),
43
43
  formDescription: zod_1.z.string().optional(),
44
44
  identityFieldLabel: zod_1.z.string().optional(),
45
+ identityFieldType: zod_1.z.enum(["text", "email", "tel"]).optional(),
45
46
  passwordFieldLabel: zod_1.z.string().optional(),
46
47
  submitButtonText: zod_1.z.string().optional(),
47
48
  })
@@ -43,4 +43,15 @@ export interface ToolExecutionContext {
43
43
  sessionId?: string;
44
44
  /** Delegation token (MCP-I internal authorization) */
45
45
  delegationToken?: string;
46
+ /**
47
+ * User ID from credential provider (CRED-003)
48
+ *
49
+ * For credential providers, this is the userId extracted from the
50
+ * authentication response via responseFields.userId configuration.
51
+ * This allows tool handlers to access the external system's user ID
52
+ * (e.g., customer ID for an e-commerce API).
53
+ *
54
+ * For OAuth providers, this is typically not set (use userDid instead).
55
+ */
56
+ userId?: string;
46
57
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Identity Resolution Schemas
3
3
  *
4
- * Types and schemas for OAuth/credential identity → persistent user DID resolution.
4
+ * Types and schemas for OAuth identity → persistent user DID resolution.
5
5
  * Used by xmcp-i to call AgentShield's identity resolution endpoint.
6
6
  *
7
7
  * Part of Phase 5: Identity Resolution Integration
@@ -31,58 +31,28 @@ export declare const OAuthResultSchema: z.ZodObject<{
31
31
  provider: string;
32
32
  sub: string;
33
33
  email?: string | undefined;
34
- email_verified?: boolean | undefined;
35
34
  name?: string | undefined;
35
+ email_verified?: boolean | undefined;
36
36
  picture?: string | undefined;
37
37
  }, {
38
38
  provider: string;
39
39
  sub: string;
40
40
  email?: string | undefined;
41
- email_verified?: boolean | undefined;
42
41
  name?: string | undefined;
42
+ email_verified?: boolean | undefined;
43
43
  picture?: string | undefined;
44
44
  }>;
45
45
  export type OAuthResult = z.infer<typeof OAuthResultSchema>;
46
- /**
47
- * Credential result from credential-based authentication
48
- *
49
- * Contains user information from username/password or custom credential flows.
50
- * Used for third-party authentication systems (e.g., 'hardwareworld').
51
- */
52
- export declare const CredentialResultSchema: z.ZodObject<{
53
- /** Credential provider name (e.g., 'hardwareworld') */
54
- provider: z.ZodString;
55
- /** User ID from credential authentication */
56
- user_id: z.ZodString;
57
- /** User's email (optional) */
58
- email: z.ZodOptional<z.ZodString>;
59
- /** User's display name (optional) */
60
- name: z.ZodOptional<z.ZodString>;
61
- }, "strip", z.ZodTypeAny, {
62
- provider: string;
63
- user_id: string;
64
- email?: string | undefined;
65
- name?: string | undefined;
66
- }, {
67
- provider: string;
68
- user_id: string;
69
- email?: string | undefined;
70
- name?: string | undefined;
71
- }>;
72
- export type CredentialResult = z.infer<typeof CredentialResultSchema>;
73
46
  /**
74
47
  * Identity resolution request
75
48
  *
76
49
  * POST /api/v1/bouncer/identity/resolve
77
- *
78
- * Accepts EITHER oauth_result OR credential_result (XOR - exactly one required).
79
- * This supports both OAuth-based and credential-based authentication flows.
80
50
  */
81
- export declare const IdentityResolveRequestSchema: z.ZodEffects<z.ZodObject<{
82
- /** Project UUID or friendly ID */
51
+ export declare const IdentityResolveRequestSchema: z.ZodObject<{
52
+ /** Project UUID */
83
53
  project_id: z.ZodString;
84
- /** OAuth authentication result (mutually exclusive with credential_result) */
85
- oauth_result: z.ZodOptional<z.ZodObject<{
54
+ /** OAuth authentication result */
55
+ oauth_result: z.ZodObject<{
86
56
  /** OAuth provider name (e.g., 'google', 'github', 'microsoft') */
87
57
  provider: z.ZodString;
88
58
  /** OAuth subject claim (unique per provider) */
@@ -99,102 +69,37 @@ export declare const IdentityResolveRequestSchema: z.ZodEffects<z.ZodObject<{
99
69
  provider: string;
100
70
  sub: string;
101
71
  email?: string | undefined;
102
- email_verified?: boolean | undefined;
103
72
  name?: string | undefined;
104
- picture?: string | undefined;
105
- }, {
106
- provider: string;
107
- sub: string;
108
- email?: string | undefined;
109
73
  email_verified?: boolean | undefined;
110
- name?: string | undefined;
111
74
  picture?: string | undefined;
112
- }>>;
113
- /** Credential authentication result (mutually exclusive with oauth_result) */
114
- credential_result: z.ZodOptional<z.ZodObject<{
115
- /** Credential provider name (e.g., 'hardwareworld') */
116
- provider: z.ZodString;
117
- /** User ID from credential authentication */
118
- user_id: z.ZodString;
119
- /** User's email (optional) */
120
- email: z.ZodOptional<z.ZodString>;
121
- /** User's display name (optional) */
122
- name: z.ZodOptional<z.ZodString>;
123
- }, "strip", z.ZodTypeAny, {
124
- provider: string;
125
- user_id: string;
126
- email?: string | undefined;
127
- name?: string | undefined;
128
75
  }, {
129
- provider: string;
130
- user_id: string;
131
- email?: string | undefined;
132
- name?: string | undefined;
133
- }>>;
134
- }, "strip", z.ZodTypeAny, {
135
- project_id: string;
136
- oauth_result?: {
137
76
  provider: string;
138
77
  sub: string;
139
78
  email?: string | undefined;
140
- email_verified?: boolean | undefined;
141
79
  name?: string | undefined;
142
- picture?: string | undefined;
143
- } | undefined;
144
- credential_result?: {
145
- provider: string;
146
- user_id: string;
147
- email?: string | undefined;
148
- name?: string | undefined;
149
- } | undefined;
150
- }, {
151
- project_id: string;
152
- oauth_result?: {
153
- provider: string;
154
- sub: string;
155
- email?: string | undefined;
156
80
  email_verified?: boolean | undefined;
157
- name?: string | undefined;
158
81
  picture?: string | undefined;
159
- } | undefined;
160
- credential_result?: {
161
- provider: string;
162
- user_id: string;
163
- email?: string | undefined;
164
- name?: string | undefined;
165
- } | undefined;
166
- }>, {
82
+ }>;
83
+ }, "strip", z.ZodTypeAny, {
167
84
  project_id: string;
168
- oauth_result?: {
85
+ oauth_result: {
169
86
  provider: string;
170
87
  sub: string;
171
88
  email?: string | undefined;
172
- email_verified?: boolean | undefined;
173
89
  name?: string | undefined;
90
+ email_verified?: boolean | undefined;
174
91
  picture?: string | undefined;
175
- } | undefined;
176
- credential_result?: {
177
- provider: string;
178
- user_id: string;
179
- email?: string | undefined;
180
- name?: string | undefined;
181
- } | undefined;
92
+ };
182
93
  }, {
183
94
  project_id: string;
184
- oauth_result?: {
95
+ oauth_result: {
185
96
  provider: string;
186
97
  sub: string;
187
98
  email?: string | undefined;
188
- email_verified?: boolean | undefined;
189
99
  name?: string | undefined;
100
+ email_verified?: boolean | undefined;
190
101
  picture?: string | undefined;
191
- } | undefined;
192
- credential_result?: {
193
- provider: string;
194
- user_id: string;
195
- email?: string | undefined;
196
- name?: string | undefined;
197
- } | undefined;
102
+ };
198
103
  }>;
199
104
  export type IdentityResolveRequest = z.infer<typeof IdentityResolveRequestSchema>;
200
105
  /**
@@ -228,11 +133,11 @@ export declare const IdentityResolveResponseSchema: z.ZodObject<{
228
133
  requestId: z.ZodOptional<z.ZodString>;
229
134
  timestamp: z.ZodOptional<z.ZodString>;
230
135
  }, "strip", z.ZodTypeAny, {
231
- requestId?: string | undefined;
232
136
  timestamp?: string | undefined;
233
- }, {
234
137
  requestId?: string | undefined;
138
+ }, {
235
139
  timestamp?: string | undefined;
140
+ requestId?: string | undefined;
236
141
  }>>;
237
142
  }, "strip", z.ZodTypeAny, {
238
143
  success: true;
@@ -243,8 +148,8 @@ export declare const IdentityResolveResponseSchema: z.ZodObject<{
243
148
  auto_linked: boolean;
244
149
  };
245
150
  metadata?: {
246
- requestId?: string | undefined;
247
151
  timestamp?: string | undefined;
152
+ requestId?: string | undefined;
248
153
  } | undefined;
249
154
  }, {
250
155
  success: true;
@@ -255,8 +160,8 @@ export declare const IdentityResolveResponseSchema: z.ZodObject<{
255
160
  auto_linked: boolean;
256
161
  };
257
162
  metadata?: {
258
- requestId?: string | undefined;
259
163
  timestamp?: string | undefined;
164
+ requestId?: string | undefined;
260
165
  } | undefined;
261
166
  }>;
262
167
  export type IdentityResolveResponse = z.infer<typeof IdentityResolveResponseSchema>;
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Identity Resolution Schemas
4
4
  *
5
- * Types and schemas for OAuth/credential identity → persistent user DID resolution.
5
+ * Types and schemas for OAuth identity → persistent user DID resolution.
6
6
  * Used by xmcp-i to call AgentShield's identity resolution endpoint.
7
7
  *
8
8
  * Part of Phase 5: Identity Resolution Integration
@@ -10,7 +10,7 @@
10
10
  * @see ACCOUNT_CENTRIC_IDENTITY_AND_VC_IMPLEMENTATION.md
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.IdentityResolveErrorSchema = exports.IdentityResolveResponseSchema = exports.IdentityResolveRequestSchema = exports.CredentialResultSchema = exports.OAuthResultSchema = void 0;
13
+ exports.IdentityResolveErrorSchema = exports.IdentityResolveResponseSchema = exports.IdentityResolveRequestSchema = exports.OAuthResultSchema = void 0;
14
14
  exports.parseIdentityResolveRequest = parseIdentityResolveRequest;
15
15
  exports.safeParseIdentityResolveRequest = safeParseIdentityResolveRequest;
16
16
  exports.parseIdentityResolveResponse = parseIdentityResolveResponse;
@@ -35,45 +35,16 @@ exports.OAuthResultSchema = zod_1.z.object({
35
35
  /** Avatar URL from OAuth provider */
36
36
  picture: zod_1.z.string().url().optional(),
37
37
  });
38
- /**
39
- * Credential result from credential-based authentication
40
- *
41
- * Contains user information from username/password or custom credential flows.
42
- * Used for third-party authentication systems (e.g., 'hardwareworld').
43
- */
44
- exports.CredentialResultSchema = zod_1.z.object({
45
- /** Credential provider name (e.g., 'hardwareworld') */
46
- provider: zod_1.z.string().min(1, "Provider is required"),
47
- /** User ID from credential authentication */
48
- user_id: zod_1.z.string().min(1, "User ID is required"),
49
- /** User's email (optional) */
50
- email: zod_1.z.string().email().optional(),
51
- /** User's display name (optional) */
52
- name: zod_1.z.string().optional(),
53
- });
54
38
  /**
55
39
  * Identity resolution request
56
40
  *
57
41
  * POST /api/v1/bouncer/identity/resolve
58
- *
59
- * Accepts EITHER oauth_result OR credential_result (XOR - exactly one required).
60
- * This supports both OAuth-based and credential-based authentication flows.
61
42
  */
62
- exports.IdentityResolveRequestSchema = zod_1.z
63
- .object({
64
- /** Project UUID or friendly ID */
65
- project_id: zod_1.z.string().min(1, "Project ID is required"),
66
- /** OAuth authentication result (mutually exclusive with credential_result) */
67
- oauth_result: exports.OAuthResultSchema.optional(),
68
- /** Credential authentication result (mutually exclusive with oauth_result) */
69
- credential_result: exports.CredentialResultSchema.optional(),
70
- })
71
- .refine((data) => {
72
- const hasOAuth = !!data.oauth_result;
73
- const hasCredential = !!data.credential_result;
74
- return (hasOAuth && !hasCredential) || (!hasOAuth && hasCredential);
75
- }, {
76
- message: "Exactly one of oauth_result or credential_result must be provided",
43
+ exports.IdentityResolveRequestSchema = zod_1.z.object({
44
+ /** Project UUID */
45
+ project_id: zod_1.z.string().uuid("Invalid project ID format"),
46
+ /** OAuth authentication result */
47
+ oauth_result: exports.OAuthResultSchema,
77
48
  });
78
49
  /**
79
50
  * Identity resolution response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kya-os/contracts",
3
- "version": "1.6.7",
3
+ "version": "1.6.9",
4
4
  "description": "Shared contracts, types, and schemas for MCP-I framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",