@kya-os/contracts 1.5.3-canary.2 → 1.5.3-canary.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/.turbo/turbo-build.log +17 -0
  2. package/.turbo/turbo-test$colon$coverage.log +85 -0
  3. package/.turbo/turbo-test.log +32 -0
  4. package/coverage/coverage-final.json +38 -0
  5. package/dist/agentshield-api/admin-schemas.d.ts +2 -2
  6. package/dist/agentshield-api/index.d.ts +1 -1
  7. package/dist/agentshield-api/schemas.d.ts +150 -48
  8. package/dist/agentshield-api/schemas.js +32 -4
  9. package/dist/agentshield-api/types.d.ts +31 -4
  10. package/dist/audit/index.d.ts +193 -0
  11. package/dist/audit/index.js +100 -0
  12. package/dist/config/identity.d.ts +205 -2
  13. package/dist/config/identity.js +28 -0
  14. package/dist/config/index.d.ts +2 -1
  15. package/dist/config/tool-context.d.ts +34 -0
  16. package/dist/config/tool-context.js +13 -0
  17. package/dist/consent/schemas.d.ts +119 -93
  18. package/dist/consent/schemas.js +111 -64
  19. package/dist/dashboard-config/schemas.d.ts +2248 -992
  20. package/dist/handshake.d.ts +14 -14
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +2 -0
  23. package/dist/tool-protection/index.d.ts +490 -14
  24. package/dist/tool-protection/index.js +89 -2
  25. package/dist/verifier/index.d.ts +1 -0
  26. package/dist/verifier/index.js +18 -0
  27. package/dist/well-known/index.d.ts +2 -2
  28. package/package.json +43 -122
  29. package/schemas/cli/register-output/v1.0.0.json +69 -0
  30. package/schemas/identity/v1.0.0.json +46 -0
  31. package/schemas/proof/v1.0.0.json +80 -0
  32. package/schemas/registry/receipt-v1.0.0.json +60 -0
  33. package/schemas/verifier/verify-page/v1.0.0.json +94 -0
  34. package/schemas/well-known/agent/v1.0.0.json +67 -0
  35. package/schemas/well-known/did/v1.0.0.json +174 -0
  36. package/scripts/emit-schemas.js +11 -0
  37. package/src/agentshield-api/admin-schemas.ts +31 -0
  38. package/src/agentshield-api/admin-types.ts +47 -0
  39. package/src/agentshield-api/endpoints.ts +60 -0
  40. package/src/agentshield-api/index.ts +70 -0
  41. package/src/agentshield-api/schemas.ts +304 -0
  42. package/src/agentshield-api/types.ts +317 -0
  43. package/src/audit/index.ts +128 -0
  44. package/src/cli.ts +156 -0
  45. package/src/config/base.ts +107 -0
  46. package/src/config/builder.ts +97 -0
  47. package/src/config/delegation.ts +232 -0
  48. package/src/config/identity.ts +252 -0
  49. package/src/config/index.ts +78 -0
  50. package/src/config/proofing.ts +138 -0
  51. package/src/config/tool-context.ts +41 -0
  52. package/src/config/tool-protection.ts +174 -0
  53. package/src/consent/index.ts +32 -0
  54. package/src/consent/schemas.ts +334 -0
  55. package/src/consent/types.ts +199 -0
  56. package/src/dashboard-config/default-config.json +86 -0
  57. package/src/dashboard-config/default-config.ts +266 -0
  58. package/src/dashboard-config/index.ts +48 -0
  59. package/src/dashboard-config/schemas.ts +286 -0
  60. package/src/dashboard-config/types.ts +404 -0
  61. package/src/delegation/constraints.ts +267 -0
  62. package/src/delegation/index.ts +8 -0
  63. package/src/delegation/schemas.ts +595 -0
  64. package/src/did/index.ts +9 -0
  65. package/src/did/resolve-contract.ts +255 -0
  66. package/src/did/schemas.ts +190 -0
  67. package/src/did/types.ts +224 -0
  68. package/src/env/constants.ts +70 -0
  69. package/src/env/index.ts +5 -0
  70. package/src/handshake.ts +125 -0
  71. package/src/index.ts +45 -0
  72. package/src/proof/index.ts +31 -0
  73. package/src/proof/proof-record.ts +163 -0
  74. package/src/proof/signing-spec.ts +146 -0
  75. package/src/proof.ts +99 -0
  76. package/src/registry.ts +146 -0
  77. package/src/runtime/errors.ts +153 -0
  78. package/src/runtime/headers.ts +136 -0
  79. package/src/runtime/index.ts +6 -0
  80. package/src/test.ts +143 -0
  81. package/src/tlkrc/index.ts +5 -0
  82. package/src/tlkrc/rotation.ts +153 -0
  83. package/src/tool-protection/index.ts +406 -0
  84. package/src/utils/validation.ts +93 -0
  85. package/src/vc/index.ts +8 -0
  86. package/src/vc/schemas.ts +277 -0
  87. package/src/vc/statuslist.ts +279 -0
  88. package/src/verifier/index.ts +2 -0
  89. package/src/verifier.ts +92 -0
  90. package/src/well-known/index.ts +237 -0
@@ -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}$/, 'Must be a valid hex color (e.g., #0066CC)')
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('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(),
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.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
+ 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, 'Option value must be 100 characters or less'),
43
- label: zod_1.z.string().max(100, 'Option label must be 100 characters or less'),
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.object({
57
+ exports.consentCustomFieldSchema = zod_1.z
58
+ .object({
49
59
  name: zod_1.z
50
60
  .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']),
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.string().max(200, 'Placeholder must be 200 characters or less').optional(),
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, 'Select fields must have at least one option')
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
- pattern: zod_1.z.string().max(500, 'Pattern must be 500 characters or less').optional(),
63
- }).refine((data) => {
82
+ })
83
+ .refine((data) => {
64
84
  // Select fields must have options
65
- if (data.type === 'select' && (!data.options || data.options.length === 0)) {
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 !== 'select' && data.options) {
90
+ if (data.type !== "select" && data.options) {
70
91
  return false;
71
92
  }
72
93
  return true;
73
94
  }, {
74
- message: 'Select fields must have options, and non-select fields must not have options',
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,48 +104,62 @@ 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.string()
87
- .min(1, 'Provider is required')
88
- .max(50, 'Provider name must be 50 characters or less'),
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.string()
94
- .min(1, 'Subject is required')
95
- .max(255, 'Subject must be 255 characters or less'),
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.string()
100
- .email('Must be a valid email address')
101
- .max(255, 'Email must be 255 characters or less')
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, 'Tool name is required'),
115
- toolDescription: zod_1.z.string().max(500, 'Tool description must be 500 characters or less'),
116
- scopes: zod_1.z.array(zod_1.z.string()).min(0, 'Scopes array cannot be negative'),
117
- agentDid: zod_1.z.string().min(1, 'Agent DID is required'),
118
- sessionId: zod_1.z.string().min(1, 'Session ID is required'),
119
- projectId: zod_1.z.string().min(1, 'Project ID is required'),
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"),
144
+ provider: zod_1.z.string().optional(), // Phase 2: OAuth provider name (e.g., "github", "google")
120
145
  branding: exports.consentBrandingSchema.optional(),
121
146
  terms: exports.consentTermsSchema.optional(),
122
147
  customFields: zod_1.z
123
148
  .array(exports.consentCustomFieldSchema)
124
- .max(10, 'Maximum 10 custom fields allowed')
149
+ .max(10, "Maximum 10 custom fields allowed")
125
150
  .optional(),
126
- serverUrl: zod_1.z.string().url('Server URL must be a valid URL'),
151
+ serverUrl: zod_1.z.string().url("Server URL must be a valid URL"),
127
152
  autoClose: zod_1.z.boolean().optional(),
153
+ /**
154
+ * Whether OAuth authorization is required immediately
155
+ * If true, the consent page will act as a landing page before redirecting
156
+ */
157
+ oauthRequired: zod_1.z.boolean().optional(),
158
+ /**
159
+ * The OAuth authorization URL to redirect to
160
+ * Required if oauthRequired is true
161
+ */
162
+ oauthUrl: zod_1.z.string().url().optional(),
128
163
  });
129
164
  /**
130
165
  * Consent Approval Request Schema
@@ -136,44 +171,49 @@ exports.consentPageConfigSchema = zod_1.z.object({
136
171
  * - user_did: Optional User DID for persistent identity (if already known)
137
172
  */
138
173
  exports.consentApprovalRequestSchema = zod_1.z.object({
139
- tool: zod_1.z.string().min(1, 'Tool name is required'),
140
- scopes: zod_1.z.array(zod_1.z.string()).min(0, 'Scopes array cannot be negative'),
141
- agent_did: zod_1.z.string().min(1, 'Agent DID is required'),
142
- session_id: zod_1.z.string().min(1, 'Session ID is required'),
143
- project_id: zod_1.z.string().min(1, 'Project ID is required'),
174
+ tool: zod_1.z.string().min(1, "Tool name is required"),
175
+ scopes: zod_1.z.array(zod_1.z.string()).min(0, "Scopes array cannot be negative"),
176
+ agent_did: zod_1.z.string().min(1, "Agent DID is required"),
177
+ session_id: zod_1.z.string().min(1, "Session ID is required"),
178
+ project_id: zod_1.z.string().min(1, "Project ID is required"),
144
179
  termsAccepted: zod_1.z.boolean(),
145
- termsVersion: zod_1.z.string()
146
- .max(50, 'Terms version must be 50 characters or less')
147
- .optional(),
148
- customFields: zod_1.z
149
- .record(zod_1.z.union([zod_1.z.string(), zod_1.z.boolean()]))
180
+ termsVersion: zod_1.z
181
+ .string()
182
+ .max(50, "Terms version must be 50 characters or less")
150
183
  .optional(),
184
+ customFields: zod_1.z.record(zod_1.z.union([zod_1.z.string(), zod_1.z.boolean()])).optional(),
151
185
  // Phase 4: OAuth identity linking
152
186
  /**
153
187
  * OAuth provider identity information (optional)
154
188
  * Used to link OAuth accounts to persistent User DIDs
189
+ *
190
+ * CRITICAL: Uses .nullish() to accept null, undefined, or OAuthIdentity
191
+ * This matches JSON parsing behavior where missing fields become null
155
192
  */
156
- oauth_identity: exports.oauthIdentitySchema.optional(),
193
+ oauth_identity: exports.oauthIdentitySchema.nullish(),
157
194
  /**
158
195
  * User DID (optional)
159
196
  * If provided, represents the persistent User DID for this user
160
197
  * Format: did:key:... or did:web:...
161
198
  */
162
- user_did: zod_1.z.string()
163
- .regex(/^did:/, 'Must be a valid DID format (starting with did:)')
164
- .max(500, 'DID must be 500 characters or less')
199
+ user_did: zod_1.z
200
+ .string()
201
+ .regex(/^did:/, "Must be a valid DID format (starting with did:)")
202
+ .max(500, "DID must be 500 characters or less")
165
203
  .optional(),
166
204
  });
167
205
  /**
168
206
  * Consent Approval Response Schema
169
207
  */
170
- exports.consentApprovalResponseSchema = zod_1.z.object({
208
+ exports.consentApprovalResponseSchema = zod_1.z
209
+ .object({
171
210
  success: zod_1.z.boolean(),
172
211
  delegation_id: zod_1.z.string().min(1).optional(),
173
212
  delegation_token: zod_1.z.string().min(1).optional(),
174
213
  error: zod_1.z.string().optional(),
175
214
  error_code: zod_1.z.string().optional(),
176
- }).refine((data) => {
215
+ })
216
+ .refine((data) => {
177
217
  // If success is true, must have delegation_id and delegation_token
178
218
  if (data.success) {
179
219
  return !!data.delegation_id && !!data.delegation_token;
@@ -181,7 +221,7 @@ exports.consentApprovalResponseSchema = zod_1.z.object({
181
221
  // If success is false, must have error or error_code
182
222
  return !!data.error || !!data.error_code;
183
223
  }, {
184
- message: 'Successful responses must include delegation_id and delegation_token. Failed responses must include error or error_code',
224
+ message: "Successful responses must include delegation_id and delegation_token. Failed responses must include error or error_code",
185
225
  });
186
226
  /**
187
227
  * Consent Config Schema
@@ -191,14 +231,21 @@ exports.consentConfigSchema = zod_1.z.object({
191
231
  terms: exports.consentTermsSchema.optional(),
192
232
  customFields: zod_1.z
193
233
  .array(exports.consentCustomFieldSchema)
194
- .max(10, 'Maximum 10 custom fields allowed')
234
+ .max(10, "Maximum 10 custom fields allowed")
195
235
  .optional(),
196
- ui: zod_1.z.object({
197
- theme: zod_1.z.enum(['light', 'dark', 'auto']).optional(),
236
+ ui: zod_1.z
237
+ .object({
238
+ theme: zod_1.z.enum(["light", "dark", "auto"]).optional(),
198
239
  popupEnabled: zod_1.z.boolean().optional(),
199
240
  autoClose: zod_1.z.boolean().optional(),
200
- autoCloseDelay: zod_1.z.number().int().positive().max(60000, 'Auto-close delay must be 60000ms or less').optional(),
201
- }).optional(),
241
+ autoCloseDelay: zod_1.z
242
+ .number()
243
+ .int()
244
+ .positive()
245
+ .max(60000, "Auto-close delay must be 60000ms or less")
246
+ .optional(),
247
+ })
248
+ .optional(),
202
249
  });
203
250
  /**
204
251
  * Validation Helpers