@kya-os/contracts 1.5.2-canary.0 → 1.5.2-canary.1
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/index.d.ts +6 -0
- package/dist/consent/index.js +22 -0
- package/dist/consent/schemas.d.ts +738 -0
- package/dist/consent/schemas.js +186 -0
- package/dist/consent/types.d.ts +155 -0
- package/dist/consent/types.js +10 -0
- package/package.json +6 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent Module Exports
|
|
3
|
+
*
|
|
4
|
+
* Types and schemas for consent page configuration and approval handling
|
|
5
|
+
*/
|
|
6
|
+
export { consentBrandingSchema, consentTermsSchema, consentCustomFieldSchema, consentCustomFieldOptionSchema, consentPageConfigSchema, consentApprovalRequestSchema, consentApprovalResponseSchema, consentConfigSchema, validateConsentPageConfig, validateConsentApprovalRequest, validateConsentApprovalResponse, validateConsentConfig, type ConsentBranding, type ConsentTerms, type ConsentCustomField, type ConsentPageConfig, type ConsentApprovalRequest, type ConsentApprovalResponse, type ConsentConfig, } from './schemas.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Consent Module Exports
|
|
4
|
+
*
|
|
5
|
+
* Types and schemas for consent page configuration and approval handling
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.validateConsentConfig = exports.validateConsentApprovalResponse = exports.validateConsentApprovalRequest = exports.validateConsentPageConfig = exports.consentConfigSchema = exports.consentApprovalResponseSchema = exports.consentApprovalRequestSchema = exports.consentPageConfigSchema = exports.consentCustomFieldOptionSchema = exports.consentCustomFieldSchema = exports.consentTermsSchema = exports.consentBrandingSchema = void 0;
|
|
9
|
+
// Export schemas and inferred types (types are derived from schemas)
|
|
10
|
+
var schemas_js_1 = require("./schemas.js");
|
|
11
|
+
Object.defineProperty(exports, "consentBrandingSchema", { enumerable: true, get: function () { return schemas_js_1.consentBrandingSchema; } });
|
|
12
|
+
Object.defineProperty(exports, "consentTermsSchema", { enumerable: true, get: function () { return schemas_js_1.consentTermsSchema; } });
|
|
13
|
+
Object.defineProperty(exports, "consentCustomFieldSchema", { enumerable: true, get: function () { return schemas_js_1.consentCustomFieldSchema; } });
|
|
14
|
+
Object.defineProperty(exports, "consentCustomFieldOptionSchema", { enumerable: true, get: function () { return schemas_js_1.consentCustomFieldOptionSchema; } });
|
|
15
|
+
Object.defineProperty(exports, "consentPageConfigSchema", { enumerable: true, get: function () { return schemas_js_1.consentPageConfigSchema; } });
|
|
16
|
+
Object.defineProperty(exports, "consentApprovalRequestSchema", { enumerable: true, get: function () { return schemas_js_1.consentApprovalRequestSchema; } });
|
|
17
|
+
Object.defineProperty(exports, "consentApprovalResponseSchema", { enumerable: true, get: function () { return schemas_js_1.consentApprovalResponseSchema; } });
|
|
18
|
+
Object.defineProperty(exports, "consentConfigSchema", { enumerable: true, get: function () { return schemas_js_1.consentConfigSchema; } });
|
|
19
|
+
Object.defineProperty(exports, "validateConsentPageConfig", { enumerable: true, get: function () { return schemas_js_1.validateConsentPageConfig; } });
|
|
20
|
+
Object.defineProperty(exports, "validateConsentApprovalRequest", { enumerable: true, get: function () { return schemas_js_1.validateConsentApprovalRequest; } });
|
|
21
|
+
Object.defineProperty(exports, "validateConsentApprovalResponse", { enumerable: true, get: function () { return schemas_js_1.validateConsentApprovalResponse; } });
|
|
22
|
+
Object.defineProperty(exports, "validateConsentConfig", { enumerable: true, get: function () { return schemas_js_1.validateConsentConfig; } });
|
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent Schemas
|
|
3
|
+
*
|
|
4
|
+
* Zod schemas for runtime validation of consent-related data structures.
|
|
5
|
+
* All types are derived from these schemas using z.infer.
|
|
6
|
+
*
|
|
7
|
+
* Related Spec: MCP-I Phase 0 Implementation Plan
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
/**
|
|
11
|
+
* Consent Branding Schema
|
|
12
|
+
*/
|
|
13
|
+
export declare const consentBrandingSchema: z.ZodObject<{
|
|
14
|
+
primaryColor: z.ZodOptional<z.ZodString>;
|
|
15
|
+
logoUrl: z.ZodOptional<z.ZodString>;
|
|
16
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
17
|
+
theme: z.ZodOptional<z.ZodEnum<["light", "dark", "auto"]>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
primaryColor?: string | undefined;
|
|
20
|
+
logoUrl?: string | undefined;
|
|
21
|
+
companyName?: string | undefined;
|
|
22
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
primaryColor?: string | undefined;
|
|
25
|
+
logoUrl?: string | undefined;
|
|
26
|
+
companyName?: string | undefined;
|
|
27
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
export type ConsentBranding = z.infer<typeof consentBrandingSchema>;
|
|
30
|
+
/**
|
|
31
|
+
* Consent Terms Schema
|
|
32
|
+
*/
|
|
33
|
+
export declare const consentTermsSchema: z.ZodObject<{
|
|
34
|
+
text: z.ZodOptional<z.ZodString>;
|
|
35
|
+
url: z.ZodOptional<z.ZodString>;
|
|
36
|
+
version: z.ZodOptional<z.ZodString>;
|
|
37
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
required: boolean;
|
|
40
|
+
text?: string | undefined;
|
|
41
|
+
url?: string | undefined;
|
|
42
|
+
version?: string | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
text?: string | undefined;
|
|
45
|
+
url?: string | undefined;
|
|
46
|
+
version?: string | undefined;
|
|
47
|
+
required?: boolean | undefined;
|
|
48
|
+
}>;
|
|
49
|
+
export type ConsentTerms = z.infer<typeof consentTermsSchema>;
|
|
50
|
+
/**
|
|
51
|
+
* Consent Custom Field Option Schema
|
|
52
|
+
*/
|
|
53
|
+
export declare const consentCustomFieldOptionSchema: z.ZodObject<{
|
|
54
|
+
value: z.ZodString;
|
|
55
|
+
label: z.ZodString;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
value: string;
|
|
58
|
+
label: string;
|
|
59
|
+
}, {
|
|
60
|
+
value: string;
|
|
61
|
+
label: string;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Consent Custom Field Schema
|
|
65
|
+
*/
|
|
66
|
+
export declare const consentCustomFieldSchema: z.ZodEffects<z.ZodObject<{
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
label: z.ZodString;
|
|
69
|
+
type: z.ZodEnum<["text", "textarea", "checkbox", "select"]>;
|
|
70
|
+
required: z.ZodBoolean;
|
|
71
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
72
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
73
|
+
value: z.ZodString;
|
|
74
|
+
label: z.ZodString;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
value: string;
|
|
77
|
+
label: string;
|
|
78
|
+
}, {
|
|
79
|
+
value: string;
|
|
80
|
+
label: string;
|
|
81
|
+
}>, "many">>;
|
|
82
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
85
|
+
required: boolean;
|
|
86
|
+
label: string;
|
|
87
|
+
name: string;
|
|
88
|
+
options?: {
|
|
89
|
+
value: string;
|
|
90
|
+
label: string;
|
|
91
|
+
}[] | undefined;
|
|
92
|
+
placeholder?: string | undefined;
|
|
93
|
+
pattern?: string | undefined;
|
|
94
|
+
}, {
|
|
95
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
96
|
+
required: boolean;
|
|
97
|
+
label: string;
|
|
98
|
+
name: string;
|
|
99
|
+
options?: {
|
|
100
|
+
value: string;
|
|
101
|
+
label: string;
|
|
102
|
+
}[] | undefined;
|
|
103
|
+
placeholder?: string | undefined;
|
|
104
|
+
pattern?: string | undefined;
|
|
105
|
+
}>, {
|
|
106
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
107
|
+
required: boolean;
|
|
108
|
+
label: string;
|
|
109
|
+
name: string;
|
|
110
|
+
options?: {
|
|
111
|
+
value: string;
|
|
112
|
+
label: string;
|
|
113
|
+
}[] | undefined;
|
|
114
|
+
placeholder?: string | undefined;
|
|
115
|
+
pattern?: string | undefined;
|
|
116
|
+
}, {
|
|
117
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
118
|
+
required: boolean;
|
|
119
|
+
label: string;
|
|
120
|
+
name: string;
|
|
121
|
+
options?: {
|
|
122
|
+
value: string;
|
|
123
|
+
label: string;
|
|
124
|
+
}[] | undefined;
|
|
125
|
+
placeholder?: string | undefined;
|
|
126
|
+
pattern?: string | undefined;
|
|
127
|
+
}>;
|
|
128
|
+
export type ConsentCustomField = z.infer<typeof consentCustomFieldSchema>;
|
|
129
|
+
/**
|
|
130
|
+
* Consent Page Config Schema
|
|
131
|
+
*/
|
|
132
|
+
export declare const consentPageConfigSchema: z.ZodObject<{
|
|
133
|
+
tool: z.ZodString;
|
|
134
|
+
toolDescription: z.ZodString;
|
|
135
|
+
scopes: z.ZodArray<z.ZodString, "many">;
|
|
136
|
+
agentDid: z.ZodString;
|
|
137
|
+
sessionId: z.ZodString;
|
|
138
|
+
projectId: z.ZodString;
|
|
139
|
+
branding: z.ZodOptional<z.ZodObject<{
|
|
140
|
+
primaryColor: z.ZodOptional<z.ZodString>;
|
|
141
|
+
logoUrl: z.ZodOptional<z.ZodString>;
|
|
142
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
143
|
+
theme: z.ZodOptional<z.ZodEnum<["light", "dark", "auto"]>>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
primaryColor?: string | undefined;
|
|
146
|
+
logoUrl?: string | undefined;
|
|
147
|
+
companyName?: string | undefined;
|
|
148
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
primaryColor?: string | undefined;
|
|
151
|
+
logoUrl?: string | undefined;
|
|
152
|
+
companyName?: string | undefined;
|
|
153
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
154
|
+
}>>;
|
|
155
|
+
terms: z.ZodOptional<z.ZodObject<{
|
|
156
|
+
text: z.ZodOptional<z.ZodString>;
|
|
157
|
+
url: z.ZodOptional<z.ZodString>;
|
|
158
|
+
version: z.ZodOptional<z.ZodString>;
|
|
159
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
160
|
+
}, "strip", z.ZodTypeAny, {
|
|
161
|
+
required: boolean;
|
|
162
|
+
text?: string | undefined;
|
|
163
|
+
url?: string | undefined;
|
|
164
|
+
version?: string | undefined;
|
|
165
|
+
}, {
|
|
166
|
+
text?: string | undefined;
|
|
167
|
+
url?: string | undefined;
|
|
168
|
+
version?: string | undefined;
|
|
169
|
+
required?: boolean | undefined;
|
|
170
|
+
}>>;
|
|
171
|
+
customFields: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
172
|
+
name: z.ZodString;
|
|
173
|
+
label: z.ZodString;
|
|
174
|
+
type: z.ZodEnum<["text", "textarea", "checkbox", "select"]>;
|
|
175
|
+
required: z.ZodBoolean;
|
|
176
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
177
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
178
|
+
value: z.ZodString;
|
|
179
|
+
label: z.ZodString;
|
|
180
|
+
}, "strip", z.ZodTypeAny, {
|
|
181
|
+
value: string;
|
|
182
|
+
label: string;
|
|
183
|
+
}, {
|
|
184
|
+
value: string;
|
|
185
|
+
label: string;
|
|
186
|
+
}>, "many">>;
|
|
187
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
188
|
+
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
190
|
+
required: boolean;
|
|
191
|
+
label: string;
|
|
192
|
+
name: string;
|
|
193
|
+
options?: {
|
|
194
|
+
value: string;
|
|
195
|
+
label: string;
|
|
196
|
+
}[] | undefined;
|
|
197
|
+
placeholder?: string | undefined;
|
|
198
|
+
pattern?: string | undefined;
|
|
199
|
+
}, {
|
|
200
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
201
|
+
required: boolean;
|
|
202
|
+
label: string;
|
|
203
|
+
name: string;
|
|
204
|
+
options?: {
|
|
205
|
+
value: string;
|
|
206
|
+
label: string;
|
|
207
|
+
}[] | undefined;
|
|
208
|
+
placeholder?: string | undefined;
|
|
209
|
+
pattern?: string | undefined;
|
|
210
|
+
}>, {
|
|
211
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
212
|
+
required: boolean;
|
|
213
|
+
label: string;
|
|
214
|
+
name: string;
|
|
215
|
+
options?: {
|
|
216
|
+
value: string;
|
|
217
|
+
label: string;
|
|
218
|
+
}[] | undefined;
|
|
219
|
+
placeholder?: string | undefined;
|
|
220
|
+
pattern?: string | undefined;
|
|
221
|
+
}, {
|
|
222
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
223
|
+
required: boolean;
|
|
224
|
+
label: string;
|
|
225
|
+
name: string;
|
|
226
|
+
options?: {
|
|
227
|
+
value: string;
|
|
228
|
+
label: string;
|
|
229
|
+
}[] | undefined;
|
|
230
|
+
placeholder?: string | undefined;
|
|
231
|
+
pattern?: string | undefined;
|
|
232
|
+
}>, "many">>;
|
|
233
|
+
serverUrl: z.ZodString;
|
|
234
|
+
autoClose: z.ZodOptional<z.ZodBoolean>;
|
|
235
|
+
}, "strip", z.ZodTypeAny, {
|
|
236
|
+
tool: string;
|
|
237
|
+
toolDescription: string;
|
|
238
|
+
scopes: string[];
|
|
239
|
+
agentDid: string;
|
|
240
|
+
sessionId: string;
|
|
241
|
+
projectId: string;
|
|
242
|
+
serverUrl: string;
|
|
243
|
+
branding?: {
|
|
244
|
+
primaryColor?: string | undefined;
|
|
245
|
+
logoUrl?: string | undefined;
|
|
246
|
+
companyName?: string | undefined;
|
|
247
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
248
|
+
} | undefined;
|
|
249
|
+
terms?: {
|
|
250
|
+
required: boolean;
|
|
251
|
+
text?: string | undefined;
|
|
252
|
+
url?: string | undefined;
|
|
253
|
+
version?: string | undefined;
|
|
254
|
+
} | undefined;
|
|
255
|
+
customFields?: {
|
|
256
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
257
|
+
required: boolean;
|
|
258
|
+
label: string;
|
|
259
|
+
name: string;
|
|
260
|
+
options?: {
|
|
261
|
+
value: string;
|
|
262
|
+
label: string;
|
|
263
|
+
}[] | undefined;
|
|
264
|
+
placeholder?: string | undefined;
|
|
265
|
+
pattern?: string | undefined;
|
|
266
|
+
}[] | undefined;
|
|
267
|
+
autoClose?: boolean | undefined;
|
|
268
|
+
}, {
|
|
269
|
+
tool: string;
|
|
270
|
+
toolDescription: string;
|
|
271
|
+
scopes: string[];
|
|
272
|
+
agentDid: string;
|
|
273
|
+
sessionId: string;
|
|
274
|
+
projectId: string;
|
|
275
|
+
serverUrl: string;
|
|
276
|
+
branding?: {
|
|
277
|
+
primaryColor?: string | undefined;
|
|
278
|
+
logoUrl?: string | undefined;
|
|
279
|
+
companyName?: string | undefined;
|
|
280
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
281
|
+
} | undefined;
|
|
282
|
+
terms?: {
|
|
283
|
+
text?: string | undefined;
|
|
284
|
+
url?: string | undefined;
|
|
285
|
+
version?: string | undefined;
|
|
286
|
+
required?: boolean | undefined;
|
|
287
|
+
} | undefined;
|
|
288
|
+
customFields?: {
|
|
289
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
290
|
+
required: boolean;
|
|
291
|
+
label: string;
|
|
292
|
+
name: string;
|
|
293
|
+
options?: {
|
|
294
|
+
value: string;
|
|
295
|
+
label: string;
|
|
296
|
+
}[] | undefined;
|
|
297
|
+
placeholder?: string | undefined;
|
|
298
|
+
pattern?: string | undefined;
|
|
299
|
+
}[] | undefined;
|
|
300
|
+
autoClose?: boolean | undefined;
|
|
301
|
+
}>;
|
|
302
|
+
export type ConsentPageConfig = z.infer<typeof consentPageConfigSchema>;
|
|
303
|
+
/**
|
|
304
|
+
* Consent Approval Request Schema
|
|
305
|
+
*
|
|
306
|
+
* Note: Uses snake_case for API compatibility (agent_did, session_id, project_id)
|
|
307
|
+
*/
|
|
308
|
+
export declare const consentApprovalRequestSchema: z.ZodObject<{
|
|
309
|
+
tool: z.ZodString;
|
|
310
|
+
scopes: z.ZodArray<z.ZodString, "many">;
|
|
311
|
+
agent_did: z.ZodString;
|
|
312
|
+
session_id: z.ZodString;
|
|
313
|
+
project_id: z.ZodString;
|
|
314
|
+
termsAccepted: z.ZodBoolean;
|
|
315
|
+
termsVersion: z.ZodOptional<z.ZodString>;
|
|
316
|
+
customFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodBoolean]>>>;
|
|
317
|
+
}, "strip", z.ZodTypeAny, {
|
|
318
|
+
tool: string;
|
|
319
|
+
scopes: string[];
|
|
320
|
+
agent_did: string;
|
|
321
|
+
session_id: string;
|
|
322
|
+
project_id: string;
|
|
323
|
+
termsAccepted: boolean;
|
|
324
|
+
customFields?: Record<string, string | boolean> | undefined;
|
|
325
|
+
termsVersion?: string | undefined;
|
|
326
|
+
}, {
|
|
327
|
+
tool: string;
|
|
328
|
+
scopes: string[];
|
|
329
|
+
agent_did: string;
|
|
330
|
+
session_id: string;
|
|
331
|
+
project_id: string;
|
|
332
|
+
termsAccepted: boolean;
|
|
333
|
+
customFields?: Record<string, string | boolean> | undefined;
|
|
334
|
+
termsVersion?: string | undefined;
|
|
335
|
+
}>;
|
|
336
|
+
export type ConsentApprovalRequest = z.infer<typeof consentApprovalRequestSchema>;
|
|
337
|
+
/**
|
|
338
|
+
* Consent Approval Response Schema
|
|
339
|
+
*/
|
|
340
|
+
export declare const consentApprovalResponseSchema: z.ZodEffects<z.ZodObject<{
|
|
341
|
+
success: z.ZodBoolean;
|
|
342
|
+
delegation_id: z.ZodOptional<z.ZodString>;
|
|
343
|
+
delegation_token: z.ZodOptional<z.ZodString>;
|
|
344
|
+
error: z.ZodOptional<z.ZodString>;
|
|
345
|
+
error_code: z.ZodOptional<z.ZodString>;
|
|
346
|
+
}, "strip", z.ZodTypeAny, {
|
|
347
|
+
success: boolean;
|
|
348
|
+
delegation_id?: string | undefined;
|
|
349
|
+
delegation_token?: string | undefined;
|
|
350
|
+
error?: string | undefined;
|
|
351
|
+
error_code?: string | undefined;
|
|
352
|
+
}, {
|
|
353
|
+
success: boolean;
|
|
354
|
+
delegation_id?: string | undefined;
|
|
355
|
+
delegation_token?: string | undefined;
|
|
356
|
+
error?: string | undefined;
|
|
357
|
+
error_code?: string | undefined;
|
|
358
|
+
}>, {
|
|
359
|
+
success: boolean;
|
|
360
|
+
delegation_id?: string | undefined;
|
|
361
|
+
delegation_token?: string | undefined;
|
|
362
|
+
error?: string | undefined;
|
|
363
|
+
error_code?: string | undefined;
|
|
364
|
+
}, {
|
|
365
|
+
success: boolean;
|
|
366
|
+
delegation_id?: string | undefined;
|
|
367
|
+
delegation_token?: string | undefined;
|
|
368
|
+
error?: string | undefined;
|
|
369
|
+
error_code?: string | undefined;
|
|
370
|
+
}>;
|
|
371
|
+
export type ConsentApprovalResponse = z.infer<typeof consentApprovalResponseSchema>;
|
|
372
|
+
/**
|
|
373
|
+
* Consent Config Schema
|
|
374
|
+
*/
|
|
375
|
+
export declare const consentConfigSchema: z.ZodObject<{
|
|
376
|
+
branding: z.ZodOptional<z.ZodObject<{
|
|
377
|
+
primaryColor: z.ZodOptional<z.ZodString>;
|
|
378
|
+
logoUrl: z.ZodOptional<z.ZodString>;
|
|
379
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
380
|
+
theme: z.ZodOptional<z.ZodEnum<["light", "dark", "auto"]>>;
|
|
381
|
+
}, "strip", z.ZodTypeAny, {
|
|
382
|
+
primaryColor?: string | undefined;
|
|
383
|
+
logoUrl?: string | undefined;
|
|
384
|
+
companyName?: string | undefined;
|
|
385
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
386
|
+
}, {
|
|
387
|
+
primaryColor?: string | undefined;
|
|
388
|
+
logoUrl?: string | undefined;
|
|
389
|
+
companyName?: string | undefined;
|
|
390
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
391
|
+
}>>;
|
|
392
|
+
terms: z.ZodOptional<z.ZodObject<{
|
|
393
|
+
text: z.ZodOptional<z.ZodString>;
|
|
394
|
+
url: z.ZodOptional<z.ZodString>;
|
|
395
|
+
version: z.ZodOptional<z.ZodString>;
|
|
396
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
397
|
+
}, "strip", z.ZodTypeAny, {
|
|
398
|
+
required: boolean;
|
|
399
|
+
text?: string | undefined;
|
|
400
|
+
url?: string | undefined;
|
|
401
|
+
version?: string | undefined;
|
|
402
|
+
}, {
|
|
403
|
+
text?: string | undefined;
|
|
404
|
+
url?: string | undefined;
|
|
405
|
+
version?: string | undefined;
|
|
406
|
+
required?: boolean | undefined;
|
|
407
|
+
}>>;
|
|
408
|
+
customFields: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
409
|
+
name: z.ZodString;
|
|
410
|
+
label: z.ZodString;
|
|
411
|
+
type: z.ZodEnum<["text", "textarea", "checkbox", "select"]>;
|
|
412
|
+
required: z.ZodBoolean;
|
|
413
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
414
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
415
|
+
value: z.ZodString;
|
|
416
|
+
label: z.ZodString;
|
|
417
|
+
}, "strip", z.ZodTypeAny, {
|
|
418
|
+
value: string;
|
|
419
|
+
label: string;
|
|
420
|
+
}, {
|
|
421
|
+
value: string;
|
|
422
|
+
label: string;
|
|
423
|
+
}>, "many">>;
|
|
424
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
425
|
+
}, "strip", z.ZodTypeAny, {
|
|
426
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
427
|
+
required: boolean;
|
|
428
|
+
label: string;
|
|
429
|
+
name: string;
|
|
430
|
+
options?: {
|
|
431
|
+
value: string;
|
|
432
|
+
label: string;
|
|
433
|
+
}[] | undefined;
|
|
434
|
+
placeholder?: string | undefined;
|
|
435
|
+
pattern?: string | undefined;
|
|
436
|
+
}, {
|
|
437
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
438
|
+
required: boolean;
|
|
439
|
+
label: string;
|
|
440
|
+
name: string;
|
|
441
|
+
options?: {
|
|
442
|
+
value: string;
|
|
443
|
+
label: string;
|
|
444
|
+
}[] | undefined;
|
|
445
|
+
placeholder?: string | undefined;
|
|
446
|
+
pattern?: string | undefined;
|
|
447
|
+
}>, {
|
|
448
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
449
|
+
required: boolean;
|
|
450
|
+
label: string;
|
|
451
|
+
name: string;
|
|
452
|
+
options?: {
|
|
453
|
+
value: string;
|
|
454
|
+
label: string;
|
|
455
|
+
}[] | undefined;
|
|
456
|
+
placeholder?: string | undefined;
|
|
457
|
+
pattern?: string | undefined;
|
|
458
|
+
}, {
|
|
459
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
460
|
+
required: boolean;
|
|
461
|
+
label: string;
|
|
462
|
+
name: string;
|
|
463
|
+
options?: {
|
|
464
|
+
value: string;
|
|
465
|
+
label: string;
|
|
466
|
+
}[] | undefined;
|
|
467
|
+
placeholder?: string | undefined;
|
|
468
|
+
pattern?: string | undefined;
|
|
469
|
+
}>, "many">>;
|
|
470
|
+
ui: z.ZodOptional<z.ZodObject<{
|
|
471
|
+
theme: z.ZodOptional<z.ZodEnum<["light", "dark", "auto"]>>;
|
|
472
|
+
popupEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
473
|
+
autoClose: z.ZodOptional<z.ZodBoolean>;
|
|
474
|
+
autoCloseDelay: z.ZodOptional<z.ZodNumber>;
|
|
475
|
+
}, "strip", z.ZodTypeAny, {
|
|
476
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
477
|
+
autoClose?: boolean | undefined;
|
|
478
|
+
popupEnabled?: boolean | undefined;
|
|
479
|
+
autoCloseDelay?: number | undefined;
|
|
480
|
+
}, {
|
|
481
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
482
|
+
autoClose?: boolean | undefined;
|
|
483
|
+
popupEnabled?: boolean | undefined;
|
|
484
|
+
autoCloseDelay?: number | undefined;
|
|
485
|
+
}>>;
|
|
486
|
+
}, "strip", z.ZodTypeAny, {
|
|
487
|
+
branding?: {
|
|
488
|
+
primaryColor?: string | undefined;
|
|
489
|
+
logoUrl?: string | undefined;
|
|
490
|
+
companyName?: string | undefined;
|
|
491
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
492
|
+
} | undefined;
|
|
493
|
+
terms?: {
|
|
494
|
+
required: boolean;
|
|
495
|
+
text?: string | undefined;
|
|
496
|
+
url?: string | undefined;
|
|
497
|
+
version?: string | undefined;
|
|
498
|
+
} | undefined;
|
|
499
|
+
customFields?: {
|
|
500
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
501
|
+
required: boolean;
|
|
502
|
+
label: string;
|
|
503
|
+
name: string;
|
|
504
|
+
options?: {
|
|
505
|
+
value: string;
|
|
506
|
+
label: string;
|
|
507
|
+
}[] | undefined;
|
|
508
|
+
placeholder?: string | undefined;
|
|
509
|
+
pattern?: string | undefined;
|
|
510
|
+
}[] | undefined;
|
|
511
|
+
ui?: {
|
|
512
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
513
|
+
autoClose?: boolean | undefined;
|
|
514
|
+
popupEnabled?: boolean | undefined;
|
|
515
|
+
autoCloseDelay?: number | undefined;
|
|
516
|
+
} | undefined;
|
|
517
|
+
}, {
|
|
518
|
+
branding?: {
|
|
519
|
+
primaryColor?: string | undefined;
|
|
520
|
+
logoUrl?: string | undefined;
|
|
521
|
+
companyName?: string | undefined;
|
|
522
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
523
|
+
} | undefined;
|
|
524
|
+
terms?: {
|
|
525
|
+
text?: string | undefined;
|
|
526
|
+
url?: string | undefined;
|
|
527
|
+
version?: string | undefined;
|
|
528
|
+
required?: boolean | undefined;
|
|
529
|
+
} | undefined;
|
|
530
|
+
customFields?: {
|
|
531
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
532
|
+
required: boolean;
|
|
533
|
+
label: string;
|
|
534
|
+
name: string;
|
|
535
|
+
options?: {
|
|
536
|
+
value: string;
|
|
537
|
+
label: string;
|
|
538
|
+
}[] | undefined;
|
|
539
|
+
placeholder?: string | undefined;
|
|
540
|
+
pattern?: string | undefined;
|
|
541
|
+
}[] | undefined;
|
|
542
|
+
ui?: {
|
|
543
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
544
|
+
autoClose?: boolean | undefined;
|
|
545
|
+
popupEnabled?: boolean | undefined;
|
|
546
|
+
autoCloseDelay?: number | undefined;
|
|
547
|
+
} | undefined;
|
|
548
|
+
}>;
|
|
549
|
+
export type ConsentConfig = z.infer<typeof consentConfigSchema>;
|
|
550
|
+
/**
|
|
551
|
+
* Validation Helpers
|
|
552
|
+
*/
|
|
553
|
+
/**
|
|
554
|
+
* Validate a consent page config
|
|
555
|
+
*
|
|
556
|
+
* @param config - The config to validate
|
|
557
|
+
* @returns Validation result
|
|
558
|
+
*/
|
|
559
|
+
export declare function validateConsentPageConfig(config: unknown): z.SafeParseReturnType<{
|
|
560
|
+
tool: string;
|
|
561
|
+
toolDescription: string;
|
|
562
|
+
scopes: string[];
|
|
563
|
+
agentDid: string;
|
|
564
|
+
sessionId: string;
|
|
565
|
+
projectId: string;
|
|
566
|
+
serverUrl: string;
|
|
567
|
+
branding?: {
|
|
568
|
+
primaryColor?: string | undefined;
|
|
569
|
+
logoUrl?: string | undefined;
|
|
570
|
+
companyName?: string | undefined;
|
|
571
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
572
|
+
} | undefined;
|
|
573
|
+
terms?: {
|
|
574
|
+
text?: string | undefined;
|
|
575
|
+
url?: string | undefined;
|
|
576
|
+
version?: string | undefined;
|
|
577
|
+
required?: boolean | undefined;
|
|
578
|
+
} | undefined;
|
|
579
|
+
customFields?: {
|
|
580
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
581
|
+
required: boolean;
|
|
582
|
+
label: string;
|
|
583
|
+
name: string;
|
|
584
|
+
options?: {
|
|
585
|
+
value: string;
|
|
586
|
+
label: string;
|
|
587
|
+
}[] | undefined;
|
|
588
|
+
placeholder?: string | undefined;
|
|
589
|
+
pattern?: string | undefined;
|
|
590
|
+
}[] | undefined;
|
|
591
|
+
autoClose?: boolean | undefined;
|
|
592
|
+
}, {
|
|
593
|
+
tool: string;
|
|
594
|
+
toolDescription: string;
|
|
595
|
+
scopes: string[];
|
|
596
|
+
agentDid: string;
|
|
597
|
+
sessionId: string;
|
|
598
|
+
projectId: string;
|
|
599
|
+
serverUrl: string;
|
|
600
|
+
branding?: {
|
|
601
|
+
primaryColor?: string | undefined;
|
|
602
|
+
logoUrl?: string | undefined;
|
|
603
|
+
companyName?: string | undefined;
|
|
604
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
605
|
+
} | undefined;
|
|
606
|
+
terms?: {
|
|
607
|
+
required: boolean;
|
|
608
|
+
text?: string | undefined;
|
|
609
|
+
url?: string | undefined;
|
|
610
|
+
version?: string | undefined;
|
|
611
|
+
} | undefined;
|
|
612
|
+
customFields?: {
|
|
613
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
614
|
+
required: boolean;
|
|
615
|
+
label: string;
|
|
616
|
+
name: string;
|
|
617
|
+
options?: {
|
|
618
|
+
value: string;
|
|
619
|
+
label: string;
|
|
620
|
+
}[] | undefined;
|
|
621
|
+
placeholder?: string | undefined;
|
|
622
|
+
pattern?: string | undefined;
|
|
623
|
+
}[] | undefined;
|
|
624
|
+
autoClose?: boolean | undefined;
|
|
625
|
+
}>;
|
|
626
|
+
/**
|
|
627
|
+
* Validate a consent approval request
|
|
628
|
+
*
|
|
629
|
+
* @param request - The request to validate
|
|
630
|
+
* @returns Validation result
|
|
631
|
+
*/
|
|
632
|
+
export declare function validateConsentApprovalRequest(request: unknown): z.SafeParseReturnType<{
|
|
633
|
+
tool: string;
|
|
634
|
+
scopes: string[];
|
|
635
|
+
agent_did: string;
|
|
636
|
+
session_id: string;
|
|
637
|
+
project_id: string;
|
|
638
|
+
termsAccepted: boolean;
|
|
639
|
+
customFields?: Record<string, string | boolean> | undefined;
|
|
640
|
+
termsVersion?: string | undefined;
|
|
641
|
+
}, {
|
|
642
|
+
tool: string;
|
|
643
|
+
scopes: string[];
|
|
644
|
+
agent_did: string;
|
|
645
|
+
session_id: string;
|
|
646
|
+
project_id: string;
|
|
647
|
+
termsAccepted: boolean;
|
|
648
|
+
customFields?: Record<string, string | boolean> | undefined;
|
|
649
|
+
termsVersion?: string | undefined;
|
|
650
|
+
}>;
|
|
651
|
+
/**
|
|
652
|
+
* Validate a consent approval response
|
|
653
|
+
*
|
|
654
|
+
* @param response - The response to validate
|
|
655
|
+
* @returns Validation result
|
|
656
|
+
*/
|
|
657
|
+
export declare function validateConsentApprovalResponse(response: unknown): z.SafeParseReturnType<{
|
|
658
|
+
success: boolean;
|
|
659
|
+
delegation_id?: string | undefined;
|
|
660
|
+
delegation_token?: string | undefined;
|
|
661
|
+
error?: string | undefined;
|
|
662
|
+
error_code?: string | undefined;
|
|
663
|
+
}, {
|
|
664
|
+
success: boolean;
|
|
665
|
+
delegation_id?: string | undefined;
|
|
666
|
+
delegation_token?: string | undefined;
|
|
667
|
+
error?: string | undefined;
|
|
668
|
+
error_code?: string | undefined;
|
|
669
|
+
}>;
|
|
670
|
+
/**
|
|
671
|
+
* Validate a consent config
|
|
672
|
+
*
|
|
673
|
+
* @param config - The config to validate
|
|
674
|
+
* @returns Validation result
|
|
675
|
+
*/
|
|
676
|
+
export declare function validateConsentConfig(config: unknown): z.SafeParseReturnType<{
|
|
677
|
+
branding?: {
|
|
678
|
+
primaryColor?: string | undefined;
|
|
679
|
+
logoUrl?: string | undefined;
|
|
680
|
+
companyName?: string | undefined;
|
|
681
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
682
|
+
} | undefined;
|
|
683
|
+
terms?: {
|
|
684
|
+
text?: string | undefined;
|
|
685
|
+
url?: string | undefined;
|
|
686
|
+
version?: string | undefined;
|
|
687
|
+
required?: boolean | undefined;
|
|
688
|
+
} | undefined;
|
|
689
|
+
customFields?: {
|
|
690
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
691
|
+
required: boolean;
|
|
692
|
+
label: string;
|
|
693
|
+
name: string;
|
|
694
|
+
options?: {
|
|
695
|
+
value: string;
|
|
696
|
+
label: string;
|
|
697
|
+
}[] | undefined;
|
|
698
|
+
placeholder?: string | undefined;
|
|
699
|
+
pattern?: string | undefined;
|
|
700
|
+
}[] | undefined;
|
|
701
|
+
ui?: {
|
|
702
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
703
|
+
autoClose?: boolean | undefined;
|
|
704
|
+
popupEnabled?: boolean | undefined;
|
|
705
|
+
autoCloseDelay?: number | undefined;
|
|
706
|
+
} | undefined;
|
|
707
|
+
}, {
|
|
708
|
+
branding?: {
|
|
709
|
+
primaryColor?: string | undefined;
|
|
710
|
+
logoUrl?: string | undefined;
|
|
711
|
+
companyName?: string | undefined;
|
|
712
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
713
|
+
} | undefined;
|
|
714
|
+
terms?: {
|
|
715
|
+
required: boolean;
|
|
716
|
+
text?: string | undefined;
|
|
717
|
+
url?: string | undefined;
|
|
718
|
+
version?: string | undefined;
|
|
719
|
+
} | undefined;
|
|
720
|
+
customFields?: {
|
|
721
|
+
type: "text" | "textarea" | "checkbox" | "select";
|
|
722
|
+
required: boolean;
|
|
723
|
+
label: string;
|
|
724
|
+
name: string;
|
|
725
|
+
options?: {
|
|
726
|
+
value: string;
|
|
727
|
+
label: string;
|
|
728
|
+
}[] | undefined;
|
|
729
|
+
placeholder?: string | undefined;
|
|
730
|
+
pattern?: string | undefined;
|
|
731
|
+
}[] | undefined;
|
|
732
|
+
ui?: {
|
|
733
|
+
theme?: "light" | "dark" | "auto" | undefined;
|
|
734
|
+
autoClose?: boolean | undefined;
|
|
735
|
+
popupEnabled?: boolean | undefined;
|
|
736
|
+
autoCloseDelay?: number | undefined;
|
|
737
|
+
} | undefined;
|
|
738
|
+
}>;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Consent Schemas
|
|
4
|
+
*
|
|
5
|
+
* Zod schemas for runtime validation of consent-related data structures.
|
|
6
|
+
* All types are derived from these schemas using z.infer.
|
|
7
|
+
*
|
|
8
|
+
* Related Spec: MCP-I Phase 0 Implementation Plan
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.consentConfigSchema = exports.consentApprovalResponseSchema = exports.consentApprovalRequestSchema = exports.consentPageConfigSchema = exports.consentCustomFieldSchema = exports.consentCustomFieldOptionSchema = exports.consentTermsSchema = exports.consentBrandingSchema = void 0;
|
|
12
|
+
exports.validateConsentPageConfig = validateConsentPageConfig;
|
|
13
|
+
exports.validateConsentApprovalRequest = validateConsentApprovalRequest;
|
|
14
|
+
exports.validateConsentApprovalResponse = validateConsentApprovalResponse;
|
|
15
|
+
exports.validateConsentConfig = validateConsentConfig;
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
/**
|
|
18
|
+
* Consent Branding Schema
|
|
19
|
+
*/
|
|
20
|
+
exports.consentBrandingSchema = zod_1.z.object({
|
|
21
|
+
primaryColor: zod_1.z
|
|
22
|
+
.string()
|
|
23
|
+
.regex(/^#[0-9A-Fa-f]{6}$/, 'Must be a valid hex color (e.g., #0066CC)')
|
|
24
|
+
.optional(),
|
|
25
|
+
logoUrl: zod_1.z.string().url('Must be a valid URL').optional(),
|
|
26
|
+
companyName: zod_1.z.string().max(100, 'Company name must be 100 characters or less').optional(),
|
|
27
|
+
theme: zod_1.z.enum(['light', 'dark', 'auto']).optional(),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Consent Terms Schema
|
|
31
|
+
*/
|
|
32
|
+
exports.consentTermsSchema = zod_1.z.object({
|
|
33
|
+
text: zod_1.z.string().max(10000, 'Terms text must be 10000 characters or less').optional(),
|
|
34
|
+
url: zod_1.z.string().url('Must be a valid URL').optional(),
|
|
35
|
+
version: zod_1.z.string().max(50, 'Version must be 50 characters or less').optional(),
|
|
36
|
+
required: zod_1.z.boolean().default(true),
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Consent Custom Field Option Schema
|
|
40
|
+
*/
|
|
41
|
+
exports.consentCustomFieldOptionSchema = zod_1.z.object({
|
|
42
|
+
value: zod_1.z.string().max(100, 'Option value must be 100 characters or less'),
|
|
43
|
+
label: zod_1.z.string().max(100, 'Option label must be 100 characters or less'),
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Consent Custom Field Schema
|
|
47
|
+
*/
|
|
48
|
+
exports.consentCustomFieldSchema = zod_1.z.object({
|
|
49
|
+
name: zod_1.z
|
|
50
|
+
.string()
|
|
51
|
+
.min(1, 'Field name is required')
|
|
52
|
+
.max(50, 'Field name must be 50 characters or less')
|
|
53
|
+
.regex(/^[a-zA-Z0-9_]+$/, 'Field name must contain only letters, numbers, and underscores'),
|
|
54
|
+
label: zod_1.z.string().min(1, 'Field label is required').max(100, 'Field label must be 100 characters or less'),
|
|
55
|
+
type: zod_1.z.enum(['text', 'textarea', 'checkbox', 'select']),
|
|
56
|
+
required: zod_1.z.boolean(),
|
|
57
|
+
placeholder: zod_1.z.string().max(200, 'Placeholder must be 200 characters or less').optional(),
|
|
58
|
+
options: zod_1.z
|
|
59
|
+
.array(exports.consentCustomFieldOptionSchema)
|
|
60
|
+
.min(1, 'Select fields must have at least one option')
|
|
61
|
+
.optional(),
|
|
62
|
+
pattern: zod_1.z.string().max(500, 'Pattern must be 500 characters or less').optional(),
|
|
63
|
+
}).refine((data) => {
|
|
64
|
+
// Select fields must have options
|
|
65
|
+
if (data.type === 'select' && (!data.options || data.options.length === 0)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
// Non-select fields should not have options
|
|
69
|
+
if (data.type !== 'select' && data.options) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}, {
|
|
74
|
+
message: 'Select fields must have options, and non-select fields must not have options',
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Consent Page Config Schema
|
|
78
|
+
*/
|
|
79
|
+
exports.consentPageConfigSchema = zod_1.z.object({
|
|
80
|
+
tool: zod_1.z.string().min(1, 'Tool name is required'),
|
|
81
|
+
toolDescription: zod_1.z.string().max(500, 'Tool description must be 500 characters or less'),
|
|
82
|
+
scopes: zod_1.z.array(zod_1.z.string()).min(0, 'Scopes array cannot be negative'),
|
|
83
|
+
agentDid: zod_1.z.string().min(1, 'Agent DID is required'),
|
|
84
|
+
sessionId: zod_1.z.string().min(1, 'Session ID is required'),
|
|
85
|
+
projectId: zod_1.z.string().min(1, 'Project ID is required'),
|
|
86
|
+
branding: exports.consentBrandingSchema.optional(),
|
|
87
|
+
terms: exports.consentTermsSchema.optional(),
|
|
88
|
+
customFields: zod_1.z
|
|
89
|
+
.array(exports.consentCustomFieldSchema)
|
|
90
|
+
.max(10, 'Maximum 10 custom fields allowed')
|
|
91
|
+
.optional(),
|
|
92
|
+
serverUrl: zod_1.z.string().url('Server URL must be a valid URL'),
|
|
93
|
+
autoClose: zod_1.z.boolean().optional(),
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Consent Approval Request Schema
|
|
97
|
+
*
|
|
98
|
+
* Note: Uses snake_case for API compatibility (agent_did, session_id, project_id)
|
|
99
|
+
*/
|
|
100
|
+
exports.consentApprovalRequestSchema = zod_1.z.object({
|
|
101
|
+
tool: zod_1.z.string().min(1, 'Tool name is required'),
|
|
102
|
+
scopes: zod_1.z.array(zod_1.z.string()).min(0, 'Scopes array cannot be negative'),
|
|
103
|
+
agent_did: zod_1.z.string().min(1, 'Agent DID is required'),
|
|
104
|
+
session_id: zod_1.z.string().min(1, 'Session ID is required'),
|
|
105
|
+
project_id: zod_1.z.string().min(1, 'Project ID is required'),
|
|
106
|
+
termsAccepted: zod_1.z.boolean(),
|
|
107
|
+
termsVersion: zod_1.z.string().max(50, 'Terms version must be 50 characters or less').optional(),
|
|
108
|
+
customFields: zod_1.z
|
|
109
|
+
.record(zod_1.z.union([zod_1.z.string(), zod_1.z.boolean()]))
|
|
110
|
+
.optional(),
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* Consent Approval Response Schema
|
|
114
|
+
*/
|
|
115
|
+
exports.consentApprovalResponseSchema = zod_1.z.object({
|
|
116
|
+
success: zod_1.z.boolean(),
|
|
117
|
+
delegation_id: zod_1.z.string().min(1).optional(),
|
|
118
|
+
delegation_token: zod_1.z.string().min(1).optional(),
|
|
119
|
+
error: zod_1.z.string().optional(),
|
|
120
|
+
error_code: zod_1.z.string().optional(),
|
|
121
|
+
}).refine((data) => {
|
|
122
|
+
// If success is true, must have delegation_id and delegation_token
|
|
123
|
+
if (data.success) {
|
|
124
|
+
return !!data.delegation_id && !!data.delegation_token;
|
|
125
|
+
}
|
|
126
|
+
// If success is false, must have error or error_code
|
|
127
|
+
return !!data.error || !!data.error_code;
|
|
128
|
+
}, {
|
|
129
|
+
message: 'Successful responses must include delegation_id and delegation_token. Failed responses must include error or error_code',
|
|
130
|
+
});
|
|
131
|
+
/**
|
|
132
|
+
* Consent Config Schema
|
|
133
|
+
*/
|
|
134
|
+
exports.consentConfigSchema = zod_1.z.object({
|
|
135
|
+
branding: exports.consentBrandingSchema.optional(),
|
|
136
|
+
terms: exports.consentTermsSchema.optional(),
|
|
137
|
+
customFields: zod_1.z
|
|
138
|
+
.array(exports.consentCustomFieldSchema)
|
|
139
|
+
.max(10, 'Maximum 10 custom fields allowed')
|
|
140
|
+
.optional(),
|
|
141
|
+
ui: zod_1.z.object({
|
|
142
|
+
theme: zod_1.z.enum(['light', 'dark', 'auto']).optional(),
|
|
143
|
+
popupEnabled: zod_1.z.boolean().optional(),
|
|
144
|
+
autoClose: zod_1.z.boolean().optional(),
|
|
145
|
+
autoCloseDelay: zod_1.z.number().int().positive().max(60000, 'Auto-close delay must be 60000ms or less').optional(),
|
|
146
|
+
}).optional(),
|
|
147
|
+
});
|
|
148
|
+
/**
|
|
149
|
+
* Validation Helpers
|
|
150
|
+
*/
|
|
151
|
+
/**
|
|
152
|
+
* Validate a consent page config
|
|
153
|
+
*
|
|
154
|
+
* @param config - The config to validate
|
|
155
|
+
* @returns Validation result
|
|
156
|
+
*/
|
|
157
|
+
function validateConsentPageConfig(config) {
|
|
158
|
+
return exports.consentPageConfigSchema.safeParse(config);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Validate a consent approval request
|
|
162
|
+
*
|
|
163
|
+
* @param request - The request to validate
|
|
164
|
+
* @returns Validation result
|
|
165
|
+
*/
|
|
166
|
+
function validateConsentApprovalRequest(request) {
|
|
167
|
+
return exports.consentApprovalRequestSchema.safeParse(request);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Validate a consent approval response
|
|
171
|
+
*
|
|
172
|
+
* @param response - The response to validate
|
|
173
|
+
* @returns Validation result
|
|
174
|
+
*/
|
|
175
|
+
function validateConsentApprovalResponse(response) {
|
|
176
|
+
return exports.consentApprovalResponseSchema.safeParse(response);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Validate a consent config
|
|
180
|
+
*
|
|
181
|
+
* @param config - The config to validate
|
|
182
|
+
* @returns Validation result
|
|
183
|
+
*/
|
|
184
|
+
function validateConsentConfig(config) {
|
|
185
|
+
return exports.consentConfigSchema.safeParse(config);
|
|
186
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent Types
|
|
3
|
+
*
|
|
4
|
+
* TypeScript type definitions for consent page configuration and approval handling.
|
|
5
|
+
* These types are used for server-hosted consent pages in HTTP/SSE transports.
|
|
6
|
+
*
|
|
7
|
+
* Related Spec: MCP-I Phase 0 Implementation Plan
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Consent Branding Configuration
|
|
11
|
+
*
|
|
12
|
+
* Customization options for consent page appearance
|
|
13
|
+
*/
|
|
14
|
+
export interface ConsentBranding {
|
|
15
|
+
/** Primary brand color (hex format, e.g., '#0066CC') */
|
|
16
|
+
primaryColor?: string;
|
|
17
|
+
/** Logo URL for display on consent page */
|
|
18
|
+
logoUrl?: string;
|
|
19
|
+
/** Company/application name */
|
|
20
|
+
companyName?: string;
|
|
21
|
+
/** Theme preference ('light', 'dark', or 'auto' for system preference) */
|
|
22
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Consent Terms Configuration
|
|
26
|
+
*
|
|
27
|
+
* Terms of service or privacy policy information
|
|
28
|
+
*/
|
|
29
|
+
export interface ConsentTerms {
|
|
30
|
+
/** Full terms text (displayed on page) */
|
|
31
|
+
text?: string;
|
|
32
|
+
/** URL to terms document */
|
|
33
|
+
url?: string;
|
|
34
|
+
/** Version identifier for terms */
|
|
35
|
+
version?: string;
|
|
36
|
+
/** Whether terms acceptance is required */
|
|
37
|
+
required?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Consent Custom Field
|
|
41
|
+
*
|
|
42
|
+
* Additional fields to collect during consent (e.g., email, preferences)
|
|
43
|
+
*/
|
|
44
|
+
export interface ConsentCustomField {
|
|
45
|
+
/** Field name (used as form field name, must be valid identifier) */
|
|
46
|
+
name: string;
|
|
47
|
+
/** Display label for the field */
|
|
48
|
+
label: string;
|
|
49
|
+
/** Field type */
|
|
50
|
+
type: 'text' | 'textarea' | 'checkbox' | 'select';
|
|
51
|
+
/** Whether field is required */
|
|
52
|
+
required: boolean;
|
|
53
|
+
/** Placeholder text */
|
|
54
|
+
placeholder?: string;
|
|
55
|
+
/** Options for select fields */
|
|
56
|
+
options?: Array<{
|
|
57
|
+
value: string;
|
|
58
|
+
label: string;
|
|
59
|
+
}>;
|
|
60
|
+
/** Validation pattern (regex) */
|
|
61
|
+
pattern?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Consent Page Configuration
|
|
65
|
+
*
|
|
66
|
+
* Complete configuration for rendering a consent page
|
|
67
|
+
*/
|
|
68
|
+
export interface ConsentPageConfig {
|
|
69
|
+
/** Tool name requiring authorization */
|
|
70
|
+
tool: string;
|
|
71
|
+
/** Description of what the tool does */
|
|
72
|
+
toolDescription: string;
|
|
73
|
+
/** Scopes being requested */
|
|
74
|
+
scopes: string[];
|
|
75
|
+
/** Agent DID requesting authorization */
|
|
76
|
+
agentDid: string;
|
|
77
|
+
/** Session ID for tracking */
|
|
78
|
+
sessionId: string;
|
|
79
|
+
/** Project ID from AgentShield */
|
|
80
|
+
projectId: string;
|
|
81
|
+
/** Branding configuration */
|
|
82
|
+
branding?: ConsentBranding;
|
|
83
|
+
/** Terms configuration */
|
|
84
|
+
terms?: ConsentTerms;
|
|
85
|
+
/** Custom fields to collect */
|
|
86
|
+
customFields?: ConsentCustomField[];
|
|
87
|
+
/** Server URL for form submission */
|
|
88
|
+
serverUrl: string;
|
|
89
|
+
/** Whether to auto-close window after success */
|
|
90
|
+
autoClose?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Consent Approval Request
|
|
94
|
+
*
|
|
95
|
+
* Request payload when user approves consent
|
|
96
|
+
*/
|
|
97
|
+
export interface ConsentApprovalRequest {
|
|
98
|
+
/** Tool name */
|
|
99
|
+
tool: string;
|
|
100
|
+
/** Approved scopes */
|
|
101
|
+
scopes: string[];
|
|
102
|
+
/** Agent DID (snake_case for API compatibility) */
|
|
103
|
+
agent_did: string;
|
|
104
|
+
/** Session ID (snake_case for API compatibility) */
|
|
105
|
+
session_id: string;
|
|
106
|
+
/** Project ID (snake_case for API compatibility) */
|
|
107
|
+
project_id: string;
|
|
108
|
+
/** Whether terms were accepted */
|
|
109
|
+
termsAccepted: boolean;
|
|
110
|
+
/** Terms version (if applicable) */
|
|
111
|
+
termsVersion?: string;
|
|
112
|
+
/** Custom field values */
|
|
113
|
+
customFields?: Record<string, string | boolean>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Consent Approval Response
|
|
117
|
+
*
|
|
118
|
+
* Response after processing consent approval
|
|
119
|
+
*/
|
|
120
|
+
export interface ConsentApprovalResponse {
|
|
121
|
+
/** Whether approval was successful */
|
|
122
|
+
success: boolean;
|
|
123
|
+
/** Delegation ID (if successful) */
|
|
124
|
+
delegation_id?: string;
|
|
125
|
+
/** Delegation token (if successful) */
|
|
126
|
+
delegation_token?: string;
|
|
127
|
+
/** Error message (if failed) */
|
|
128
|
+
error?: string;
|
|
129
|
+
/** Error code (if failed) */
|
|
130
|
+
error_code?: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Consent Configuration
|
|
134
|
+
*
|
|
135
|
+
* Complete consent configuration fetched from AgentShield or defaults
|
|
136
|
+
*/
|
|
137
|
+
export interface ConsentConfig {
|
|
138
|
+
/** Branding configuration */
|
|
139
|
+
branding?: ConsentBranding;
|
|
140
|
+
/** Terms configuration */
|
|
141
|
+
terms?: ConsentTerms;
|
|
142
|
+
/** Custom fields configuration */
|
|
143
|
+
customFields?: ConsentCustomField[];
|
|
144
|
+
/** UI preferences */
|
|
145
|
+
ui?: {
|
|
146
|
+
/** Theme preference */
|
|
147
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
148
|
+
/** Whether popup mode is enabled */
|
|
149
|
+
popupEnabled?: boolean;
|
|
150
|
+
/** Whether to auto-close after success */
|
|
151
|
+
autoClose?: boolean;
|
|
152
|
+
/** Delay before auto-close (milliseconds) */
|
|
153
|
+
autoCloseDelay?: number;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Consent Types
|
|
4
|
+
*
|
|
5
|
+
* TypeScript type definitions for consent page configuration and approval handling.
|
|
6
|
+
* These types are used for server-hosted consent pages in HTTP/SSE transports.
|
|
7
|
+
*
|
|
8
|
+
* Related Spec: MCP-I Phase 0 Implementation Plan
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/contracts",
|
|
3
|
-
"version": "1.5.2-canary.
|
|
3
|
+
"version": "1.5.2-canary.1",
|
|
4
4
|
"description": "Shared types and schemas for XMCP-I ecosystem",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -96,6 +96,11 @@
|
|
|
96
96
|
"types": "./dist/dashboard-config/index.d.ts",
|
|
97
97
|
"import": "./dist/dashboard-config/index.js",
|
|
98
98
|
"require": "./dist/dashboard-config/index.js"
|
|
99
|
+
},
|
|
100
|
+
"./consent": {
|
|
101
|
+
"types": "./dist/consent/index.d.ts",
|
|
102
|
+
"import": "./dist/consent/index.js",
|
|
103
|
+
"require": "./dist/consent/index.js"
|
|
99
104
|
}
|
|
100
105
|
},
|
|
101
106
|
"files": [
|