@kya-os/contracts 1.5.3-canary.3 → 1.5.3-canary.5
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/consent/schemas.d.ts +18 -15
- package/dist/consent/schemas.js +100 -64
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Related Spec: MCP-I Phase 0 Implementation Plan
|
|
8
8
|
*/
|
|
9
|
-
import { z } from
|
|
9
|
+
import { z } from "zod";
|
|
10
10
|
/**
|
|
11
11
|
* Consent Branding Schema
|
|
12
12
|
*/
|
|
@@ -357,8 +357,11 @@ export declare const consentApprovalRequestSchema: z.ZodObject<{
|
|
|
357
357
|
/**
|
|
358
358
|
* OAuth provider identity information (optional)
|
|
359
359
|
* Used to link OAuth accounts to persistent User DIDs
|
|
360
|
+
*
|
|
361
|
+
* CRITICAL: Uses .nullish() to accept null, undefined, or OAuthIdentity
|
|
362
|
+
* This matches JSON parsing behavior where missing fields become null
|
|
360
363
|
*/
|
|
361
|
-
oauth_identity: z.ZodOptional<z.ZodObject<{
|
|
364
|
+
oauth_identity: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
362
365
|
/**
|
|
363
366
|
* OAuth provider name (e.g., "google", "github", "microsoft")
|
|
364
367
|
*/
|
|
@@ -386,7 +389,7 @@ export declare const consentApprovalRequestSchema: z.ZodObject<{
|
|
|
386
389
|
subject: string;
|
|
387
390
|
name?: string | undefined;
|
|
388
391
|
email?: string | undefined;
|
|
389
|
-
}
|
|
392
|
+
}>>>;
|
|
390
393
|
/**
|
|
391
394
|
* User DID (optional)
|
|
392
395
|
* If provided, represents the persistent User DID for this user
|
|
@@ -394,11 +397,11 @@ export declare const consentApprovalRequestSchema: z.ZodObject<{
|
|
|
394
397
|
*/
|
|
395
398
|
user_did: z.ZodOptional<z.ZodString>;
|
|
396
399
|
}, "strip", z.ZodTypeAny, {
|
|
397
|
-
agent_did: string;
|
|
398
|
-
project_id: string;
|
|
399
400
|
tool: string;
|
|
400
401
|
scopes: string[];
|
|
402
|
+
agent_did: string;
|
|
401
403
|
session_id: string;
|
|
404
|
+
project_id: string;
|
|
402
405
|
termsAccepted: boolean;
|
|
403
406
|
customFields?: Record<string, string | boolean> | undefined;
|
|
404
407
|
termsVersion?: string | undefined;
|
|
@@ -407,14 +410,14 @@ export declare const consentApprovalRequestSchema: z.ZodObject<{
|
|
|
407
410
|
subject: string;
|
|
408
411
|
name?: string | undefined;
|
|
409
412
|
email?: string | undefined;
|
|
410
|
-
} | undefined;
|
|
413
|
+
} | null | undefined;
|
|
411
414
|
user_did?: string | undefined;
|
|
412
415
|
}, {
|
|
413
|
-
agent_did: string;
|
|
414
|
-
project_id: string;
|
|
415
416
|
tool: string;
|
|
416
417
|
scopes: string[];
|
|
418
|
+
agent_did: string;
|
|
417
419
|
session_id: string;
|
|
420
|
+
project_id: string;
|
|
418
421
|
termsAccepted: boolean;
|
|
419
422
|
customFields?: Record<string, string | boolean> | undefined;
|
|
420
423
|
termsVersion?: string | undefined;
|
|
@@ -423,7 +426,7 @@ export declare const consentApprovalRequestSchema: z.ZodObject<{
|
|
|
423
426
|
subject: string;
|
|
424
427
|
name?: string | undefined;
|
|
425
428
|
email?: string | undefined;
|
|
426
|
-
} | undefined;
|
|
429
|
+
} | null | undefined;
|
|
427
430
|
user_did?: string | undefined;
|
|
428
431
|
}>;
|
|
429
432
|
export type ConsentApprovalRequest = z.infer<typeof consentApprovalRequestSchema>;
|
|
@@ -723,11 +726,11 @@ export declare function validateConsentPageConfig(config: unknown): z.SafeParseR
|
|
|
723
726
|
* @returns Validation result
|
|
724
727
|
*/
|
|
725
728
|
export declare function validateConsentApprovalRequest(request: unknown): z.SafeParseReturnType<{
|
|
726
|
-
agent_did: string;
|
|
727
|
-
project_id: string;
|
|
728
729
|
tool: string;
|
|
729
730
|
scopes: string[];
|
|
731
|
+
agent_did: string;
|
|
730
732
|
session_id: string;
|
|
733
|
+
project_id: string;
|
|
731
734
|
termsAccepted: boolean;
|
|
732
735
|
customFields?: Record<string, string | boolean> | undefined;
|
|
733
736
|
termsVersion?: string | undefined;
|
|
@@ -736,14 +739,14 @@ export declare function validateConsentApprovalRequest(request: unknown): z.Safe
|
|
|
736
739
|
subject: string;
|
|
737
740
|
name?: string | undefined;
|
|
738
741
|
email?: string | undefined;
|
|
739
|
-
} | undefined;
|
|
742
|
+
} | null | undefined;
|
|
740
743
|
user_did?: string | undefined;
|
|
741
744
|
}, {
|
|
742
|
-
agent_did: string;
|
|
743
|
-
project_id: string;
|
|
744
745
|
tool: string;
|
|
745
746
|
scopes: string[];
|
|
747
|
+
agent_did: string;
|
|
746
748
|
session_id: string;
|
|
749
|
+
project_id: string;
|
|
747
750
|
termsAccepted: boolean;
|
|
748
751
|
customFields?: Record<string, string | boolean> | undefined;
|
|
749
752
|
termsVersion?: string | undefined;
|
|
@@ -752,7 +755,7 @@ export declare function validateConsentApprovalRequest(request: unknown): z.Safe
|
|
|
752
755
|
subject: string;
|
|
753
756
|
name?: string | undefined;
|
|
754
757
|
email?: string | undefined;
|
|
755
|
-
} | undefined;
|
|
758
|
+
} | null | undefined;
|
|
756
759
|
user_did?: string | undefined;
|
|
757
760
|
}>;
|
|
758
761
|
/**
|
package/dist/consent/schemas.js
CHANGED
|
@@ -20,58 +20,79 @@ const zod_1 = require("zod");
|
|
|
20
20
|
exports.consentBrandingSchema = zod_1.z.object({
|
|
21
21
|
primaryColor: zod_1.z
|
|
22
22
|
.string()
|
|
23
|
-
.regex(/^#[0-9A-Fa-f]{6}$/,
|
|
23
|
+
.regex(/^#[0-9A-Fa-f]{6}$/, "Must be a valid hex color (e.g., #0066CC)")
|
|
24
24
|
.optional(),
|
|
25
|
-
logoUrl: zod_1.z.string().url(
|
|
26
|
-
companyName: zod_1.z
|
|
27
|
-
|
|
25
|
+
logoUrl: zod_1.z.string().url("Must be a valid URL").optional(),
|
|
26
|
+
companyName: zod_1.z
|
|
27
|
+
.string()
|
|
28
|
+
.max(100, "Company name must be 100 characters or less")
|
|
29
|
+
.optional(),
|
|
30
|
+
theme: zod_1.z.enum(["light", "dark", "auto"]).optional(),
|
|
28
31
|
});
|
|
29
32
|
/**
|
|
30
33
|
* Consent Terms Schema
|
|
31
34
|
*/
|
|
32
35
|
exports.consentTermsSchema = zod_1.z.object({
|
|
33
|
-
text: zod_1.z
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
text: zod_1.z
|
|
37
|
+
.string()
|
|
38
|
+
.max(10000, "Terms text must be 10000 characters or less")
|
|
39
|
+
.optional(),
|
|
40
|
+
url: zod_1.z.string().url("Must be a valid URL").optional(),
|
|
41
|
+
version: zod_1.z
|
|
42
|
+
.string()
|
|
43
|
+
.max(50, "Version must be 50 characters or less")
|
|
44
|
+
.optional(),
|
|
36
45
|
required: zod_1.z.boolean().default(true),
|
|
37
46
|
});
|
|
38
47
|
/**
|
|
39
48
|
* Consent Custom Field Option Schema
|
|
40
49
|
*/
|
|
41
50
|
exports.consentCustomFieldOptionSchema = zod_1.z.object({
|
|
42
|
-
value: zod_1.z.string().max(100,
|
|
43
|
-
label: zod_1.z.string().max(100,
|
|
51
|
+
value: zod_1.z.string().max(100, "Option value must be 100 characters or less"),
|
|
52
|
+
label: zod_1.z.string().max(100, "Option label must be 100 characters or less"),
|
|
44
53
|
});
|
|
45
54
|
/**
|
|
46
55
|
* Consent Custom Field Schema
|
|
47
56
|
*/
|
|
48
|
-
exports.consentCustomFieldSchema = zod_1.z
|
|
57
|
+
exports.consentCustomFieldSchema = zod_1.z
|
|
58
|
+
.object({
|
|
49
59
|
name: zod_1.z
|
|
50
60
|
.string()
|
|
51
|
-
.min(1,
|
|
52
|
-
.max(50,
|
|
53
|
-
.regex(/^[a-zA-Z0-9_]+$/,
|
|
54
|
-
label: zod_1.z
|
|
55
|
-
|
|
61
|
+
.min(1, "Field name is required")
|
|
62
|
+
.max(50, "Field name must be 50 characters or less")
|
|
63
|
+
.regex(/^[a-zA-Z0-9_]+$/, "Field name must contain only letters, numbers, and underscores"),
|
|
64
|
+
label: zod_1.z
|
|
65
|
+
.string()
|
|
66
|
+
.min(1, "Field label is required")
|
|
67
|
+
.max(100, "Field label must be 100 characters or less"),
|
|
68
|
+
type: zod_1.z.enum(["text", "textarea", "checkbox", "select"]),
|
|
56
69
|
required: zod_1.z.boolean(),
|
|
57
|
-
placeholder: zod_1.z
|
|
70
|
+
placeholder: zod_1.z
|
|
71
|
+
.string()
|
|
72
|
+
.max(200, "Placeholder must be 200 characters or less")
|
|
73
|
+
.optional(),
|
|
58
74
|
options: zod_1.z
|
|
59
75
|
.array(exports.consentCustomFieldOptionSchema)
|
|
60
|
-
.min(1,
|
|
76
|
+
.min(1, "Select fields must have at least one option")
|
|
77
|
+
.optional(),
|
|
78
|
+
pattern: zod_1.z
|
|
79
|
+
.string()
|
|
80
|
+
.max(500, "Pattern must be 500 characters or less")
|
|
61
81
|
.optional(),
|
|
62
|
-
|
|
63
|
-
|
|
82
|
+
})
|
|
83
|
+
.refine((data) => {
|
|
64
84
|
// Select fields must have options
|
|
65
|
-
if (data.type ===
|
|
85
|
+
if (data.type === "select" &&
|
|
86
|
+
(!data.options || data.options.length === 0)) {
|
|
66
87
|
return false;
|
|
67
88
|
}
|
|
68
89
|
// Non-select fields should not have options
|
|
69
|
-
if (data.type !==
|
|
90
|
+
if (data.type !== "select" && data.options) {
|
|
70
91
|
return false;
|
|
71
92
|
}
|
|
72
93
|
return true;
|
|
73
94
|
}, {
|
|
74
|
-
message:
|
|
95
|
+
message: "Select fields must have options, and non-select fields must not have options",
|
|
75
96
|
});
|
|
76
97
|
/**
|
|
77
98
|
* OAuth Identity Schema
|
|
@@ -83,47 +104,50 @@ exports.oauthIdentitySchema = zod_1.z.object({
|
|
|
83
104
|
/**
|
|
84
105
|
* OAuth provider name (e.g., "google", "github", "microsoft")
|
|
85
106
|
*/
|
|
86
|
-
provider: zod_1.z
|
|
87
|
-
.
|
|
88
|
-
.
|
|
107
|
+
provider: zod_1.z
|
|
108
|
+
.string()
|
|
109
|
+
.min(1, "Provider is required")
|
|
110
|
+
.max(50, "Provider name must be 50 characters or less"),
|
|
89
111
|
/**
|
|
90
112
|
* OAuth subject identifier (unique user ID from provider)
|
|
91
113
|
* @example "123456789" (Google), "github-user-id" (GitHub)
|
|
92
114
|
*/
|
|
93
|
-
subject: zod_1.z
|
|
94
|
-
.
|
|
95
|
-
.
|
|
115
|
+
subject: zod_1.z
|
|
116
|
+
.string()
|
|
117
|
+
.min(1, "Subject is required")
|
|
118
|
+
.max(255, "Subject must be 255 characters or less"),
|
|
96
119
|
/**
|
|
97
120
|
* User's email address from OAuth provider (optional)
|
|
98
121
|
*/
|
|
99
|
-
email: zod_1.z
|
|
100
|
-
.
|
|
101
|
-
.
|
|
122
|
+
email: zod_1.z
|
|
123
|
+
.string()
|
|
124
|
+
.email("Must be a valid email address")
|
|
125
|
+
.max(255, "Email must be 255 characters or less")
|
|
102
126
|
.optional(),
|
|
103
127
|
/**
|
|
104
128
|
* User's display name from OAuth provider (optional)
|
|
105
129
|
*/
|
|
106
|
-
name: zod_1.z.string()
|
|
107
|
-
.max(255, 'Name must be 255 characters or less')
|
|
108
|
-
.optional(),
|
|
130
|
+
name: zod_1.z.string().max(255, "Name must be 255 characters or less").optional(),
|
|
109
131
|
});
|
|
110
132
|
/**
|
|
111
133
|
* Consent Page Config Schema
|
|
112
134
|
*/
|
|
113
135
|
exports.consentPageConfigSchema = zod_1.z.object({
|
|
114
|
-
tool: zod_1.z.string().min(1,
|
|
115
|
-
toolDescription: zod_1.z
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
136
|
+
tool: zod_1.z.string().min(1, "Tool name is required"),
|
|
137
|
+
toolDescription: zod_1.z
|
|
138
|
+
.string()
|
|
139
|
+
.max(500, "Tool description must be 500 characters or less"),
|
|
140
|
+
scopes: zod_1.z.array(zod_1.z.string()).min(0, "Scopes array cannot be negative"),
|
|
141
|
+
agentDid: zod_1.z.string().min(1, "Agent DID is required"),
|
|
142
|
+
sessionId: zod_1.z.string().min(1, "Session ID is required"),
|
|
143
|
+
projectId: zod_1.z.string().min(1, "Project ID is required"),
|
|
120
144
|
branding: exports.consentBrandingSchema.optional(),
|
|
121
145
|
terms: exports.consentTermsSchema.optional(),
|
|
122
146
|
customFields: zod_1.z
|
|
123
147
|
.array(exports.consentCustomFieldSchema)
|
|
124
|
-
.max(10,
|
|
148
|
+
.max(10, "Maximum 10 custom fields allowed")
|
|
125
149
|
.optional(),
|
|
126
|
-
serverUrl: zod_1.z.string().url(
|
|
150
|
+
serverUrl: zod_1.z.string().url("Server URL must be a valid URL"),
|
|
127
151
|
autoClose: zod_1.z.boolean().optional(),
|
|
128
152
|
});
|
|
129
153
|
/**
|
|
@@ -136,44 +160,49 @@ exports.consentPageConfigSchema = zod_1.z.object({
|
|
|
136
160
|
* - user_did: Optional User DID for persistent identity (if already known)
|
|
137
161
|
*/
|
|
138
162
|
exports.consentApprovalRequestSchema = zod_1.z.object({
|
|
139
|
-
tool: zod_1.z.string().min(1,
|
|
140
|
-
scopes: zod_1.z.array(zod_1.z.string()).min(0,
|
|
141
|
-
agent_did: zod_1.z.string().min(1,
|
|
142
|
-
session_id: zod_1.z.string().min(1,
|
|
143
|
-
project_id: zod_1.z.string().min(1,
|
|
163
|
+
tool: zod_1.z.string().min(1, "Tool name is required"),
|
|
164
|
+
scopes: zod_1.z.array(zod_1.z.string()).min(0, "Scopes array cannot be negative"),
|
|
165
|
+
agent_did: zod_1.z.string().min(1, "Agent DID is required"),
|
|
166
|
+
session_id: zod_1.z.string().min(1, "Session ID is required"),
|
|
167
|
+
project_id: zod_1.z.string().min(1, "Project ID is required"),
|
|
144
168
|
termsAccepted: zod_1.z.boolean(),
|
|
145
|
-
termsVersion: zod_1.z
|
|
146
|
-
.
|
|
147
|
-
.
|
|
148
|
-
customFields: zod_1.z
|
|
149
|
-
.record(zod_1.z.union([zod_1.z.string(), zod_1.z.boolean()]))
|
|
169
|
+
termsVersion: zod_1.z
|
|
170
|
+
.string()
|
|
171
|
+
.max(50, "Terms version must be 50 characters or less")
|
|
150
172
|
.optional(),
|
|
173
|
+
customFields: zod_1.z.record(zod_1.z.union([zod_1.z.string(), zod_1.z.boolean()])).optional(),
|
|
151
174
|
// Phase 4: OAuth identity linking
|
|
152
175
|
/**
|
|
153
176
|
* OAuth provider identity information (optional)
|
|
154
177
|
* Used to link OAuth accounts to persistent User DIDs
|
|
178
|
+
*
|
|
179
|
+
* CRITICAL: Uses .nullish() to accept null, undefined, or OAuthIdentity
|
|
180
|
+
* This matches JSON parsing behavior where missing fields become null
|
|
155
181
|
*/
|
|
156
|
-
oauth_identity: exports.oauthIdentitySchema.
|
|
182
|
+
oauth_identity: exports.oauthIdentitySchema.nullish(),
|
|
157
183
|
/**
|
|
158
184
|
* User DID (optional)
|
|
159
185
|
* If provided, represents the persistent User DID for this user
|
|
160
186
|
* Format: did:key:... or did:web:...
|
|
161
187
|
*/
|
|
162
|
-
user_did: zod_1.z
|
|
163
|
-
.
|
|
164
|
-
.
|
|
188
|
+
user_did: zod_1.z
|
|
189
|
+
.string()
|
|
190
|
+
.regex(/^did:/, "Must be a valid DID format (starting with did:)")
|
|
191
|
+
.max(500, "DID must be 500 characters or less")
|
|
165
192
|
.optional(),
|
|
166
193
|
});
|
|
167
194
|
/**
|
|
168
195
|
* Consent Approval Response Schema
|
|
169
196
|
*/
|
|
170
|
-
exports.consentApprovalResponseSchema = zod_1.z
|
|
197
|
+
exports.consentApprovalResponseSchema = zod_1.z
|
|
198
|
+
.object({
|
|
171
199
|
success: zod_1.z.boolean(),
|
|
172
200
|
delegation_id: zod_1.z.string().min(1).optional(),
|
|
173
201
|
delegation_token: zod_1.z.string().min(1).optional(),
|
|
174
202
|
error: zod_1.z.string().optional(),
|
|
175
203
|
error_code: zod_1.z.string().optional(),
|
|
176
|
-
})
|
|
204
|
+
})
|
|
205
|
+
.refine((data) => {
|
|
177
206
|
// If success is true, must have delegation_id and delegation_token
|
|
178
207
|
if (data.success) {
|
|
179
208
|
return !!data.delegation_id && !!data.delegation_token;
|
|
@@ -181,7 +210,7 @@ exports.consentApprovalResponseSchema = zod_1.z.object({
|
|
|
181
210
|
// If success is false, must have error or error_code
|
|
182
211
|
return !!data.error || !!data.error_code;
|
|
183
212
|
}, {
|
|
184
|
-
message:
|
|
213
|
+
message: "Successful responses must include delegation_id and delegation_token. Failed responses must include error or error_code",
|
|
185
214
|
});
|
|
186
215
|
/**
|
|
187
216
|
* Consent Config Schema
|
|
@@ -191,14 +220,21 @@ exports.consentConfigSchema = zod_1.z.object({
|
|
|
191
220
|
terms: exports.consentTermsSchema.optional(),
|
|
192
221
|
customFields: zod_1.z
|
|
193
222
|
.array(exports.consentCustomFieldSchema)
|
|
194
|
-
.max(10,
|
|
223
|
+
.max(10, "Maximum 10 custom fields allowed")
|
|
195
224
|
.optional(),
|
|
196
|
-
ui: zod_1.z
|
|
197
|
-
|
|
225
|
+
ui: zod_1.z
|
|
226
|
+
.object({
|
|
227
|
+
theme: zod_1.z.enum(["light", "dark", "auto"]).optional(),
|
|
198
228
|
popupEnabled: zod_1.z.boolean().optional(),
|
|
199
229
|
autoClose: zod_1.z.boolean().optional(),
|
|
200
|
-
autoCloseDelay: zod_1.z
|
|
201
|
-
|
|
230
|
+
autoCloseDelay: zod_1.z
|
|
231
|
+
.number()
|
|
232
|
+
.int()
|
|
233
|
+
.positive()
|
|
234
|
+
.max(60000, "Auto-close delay must be 60000ms or less")
|
|
235
|
+
.optional(),
|
|
236
|
+
})
|
|
237
|
+
.optional(),
|
|
202
238
|
});
|
|
203
239
|
/**
|
|
204
240
|
* Validation Helpers
|