@kya-os/consent 0.1.8 → 0.1.11
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/bundle/inline.d.ts.map +1 -1
- package/dist/bundle/inline.js +2 -2
- package/dist/bundle/inline.js.map +1 -1
- package/dist/bundle/shell.d.ts +6 -0
- package/dist/bundle/shell.d.ts.map +1 -1
- package/dist/bundle/shell.js +4 -1
- package/dist/bundle/shell.js.map +1 -1
- package/dist/components/mcp-consent.d.ts +42 -18
- package/dist/components/mcp-consent.d.ts.map +1 -1
- package/dist/components/mcp-consent.js +234 -132
- package/dist/components/mcp-consent.js.map +1 -1
- package/dist/consent.js +119 -27
- package/dist/consent.min.js +26 -25
- package/dist/schemas/api.schemas.d.ts +116 -116
- package/dist/schemas/config.schemas.d.ts +116 -116
- package/dist/schemas/modes.schemas.d.ts +28 -28
- package/dist/templates/registry.d.ts +6 -0
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +11 -13
- package/dist/templates/registry.js.map +1 -1
- package/dist/types/modes.types.d.ts +53 -0
- package/dist/types/modes.types.d.ts.map +1 -1
- package/dist/types/modes.types.js +67 -0
- package/dist/types/modes.types.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,19 +12,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
-
import { LitElement, html, css, nothing } from
|
|
16
|
-
import { customElement, property, state } from
|
|
17
|
-
import { AUTH_MODES } from
|
|
18
|
-
import { resolveConsentConfig, determineAuthMode } from
|
|
15
|
+
import { LitElement, html, css, nothing } from "lit";
|
|
16
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
17
|
+
import { AUTH_MODES, getProviderTypeForAuthMode, } from "../types/modes.types.js";
|
|
18
|
+
import { resolveConsentConfig, determineAuthMode, } from "../resolution/resolve-config.js";
|
|
19
19
|
// Import component definitions for side effects
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
20
|
+
import "./consent-shell.js";
|
|
21
|
+
import "./consent-button.js";
|
|
22
|
+
import "./consent-checkbox.js";
|
|
23
|
+
import "./consent-input.js";
|
|
24
|
+
import "./consent-permissions.js";
|
|
25
|
+
import "./consent-terms.js";
|
|
26
|
+
import "./consent-oauth-button.js";
|
|
27
|
+
import "./consent-otp-input.js";
|
|
28
28
|
/**
|
|
29
29
|
* McpConsent - Full consent flow component
|
|
30
30
|
*
|
|
@@ -53,7 +53,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
53
53
|
/**
|
|
54
54
|
* Tool being authorized
|
|
55
55
|
*/
|
|
56
|
-
this.tool =
|
|
56
|
+
this.tool = "";
|
|
57
57
|
/**
|
|
58
58
|
* Permission scopes requested
|
|
59
59
|
*/
|
|
@@ -61,26 +61,48 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
61
61
|
/**
|
|
62
62
|
* Agent DID
|
|
63
63
|
*/
|
|
64
|
-
this.agentDid =
|
|
64
|
+
this.agentDid = "";
|
|
65
65
|
/**
|
|
66
66
|
* Session ID
|
|
67
67
|
*/
|
|
68
|
-
this.sessionId =
|
|
68
|
+
this.sessionId = "";
|
|
69
69
|
/**
|
|
70
70
|
* Project ID
|
|
71
71
|
*/
|
|
72
|
-
this.projectId =
|
|
72
|
+
this.projectId = "";
|
|
73
73
|
/**
|
|
74
74
|
* Server URL for form submission
|
|
75
75
|
*/
|
|
76
|
-
this.serverUrl =
|
|
76
|
+
this.serverUrl = "";
|
|
77
77
|
/**
|
|
78
78
|
* Agent name for display
|
|
79
79
|
*/
|
|
80
|
-
this.agentName =
|
|
80
|
+
this.agentName = "";
|
|
81
|
+
/**
|
|
82
|
+
* Auth provider identifier (e.g., 'credentials', 'google', 'github')
|
|
83
|
+
* Required for credential auth and OAuth flows to identify the provider
|
|
84
|
+
*/
|
|
85
|
+
this.provider = "";
|
|
86
|
+
/**
|
|
87
|
+
* CSRF token for form security
|
|
88
|
+
* Required for credential auth flows to prevent CSRF attacks
|
|
89
|
+
*/
|
|
90
|
+
this.csrfToken = "";
|
|
91
|
+
// === POST-CREDENTIAL AUTH PARAMS (for 3-screen flow) ===
|
|
92
|
+
/**
|
|
93
|
+
* Credential provider type from prior auth step
|
|
94
|
+
* Set when redirecting from credential auth → clickwrap page
|
|
95
|
+
* Used to ensure delegation is created with correct authorization type ('password')
|
|
96
|
+
*/
|
|
97
|
+
this.credentialProviderType = "";
|
|
98
|
+
/**
|
|
99
|
+
* Credential provider name from prior auth step
|
|
100
|
+
* Set when redirecting from credential auth → clickwrap page
|
|
101
|
+
*/
|
|
102
|
+
this.credentialProvider = "";
|
|
81
103
|
this.currentMode = AUTH_MODES.CONSENT_ONLY;
|
|
82
104
|
this.loading = false;
|
|
83
|
-
this.step =
|
|
105
|
+
this.step = "consent";
|
|
84
106
|
this.termsAccepted = false;
|
|
85
107
|
this.formData = {};
|
|
86
108
|
this.resendCooldown = 0;
|
|
@@ -104,47 +126,40 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
104
126
|
}
|
|
105
127
|
}
|
|
106
128
|
updated(changedProperties) {
|
|
107
|
-
if (changedProperties.has(
|
|
129
|
+
if (changedProperties.has("config") || changedProperties.has("agentName")) {
|
|
108
130
|
this.resolved = resolveConsentConfig(this.config, this.agentName);
|
|
109
131
|
}
|
|
110
|
-
if (changedProperties.has(
|
|
132
|
+
if (changedProperties.has("mode") && this.mode) {
|
|
111
133
|
this.currentMode = this.mode;
|
|
112
134
|
}
|
|
113
135
|
// Update selected scopes when scopes change
|
|
114
|
-
if (changedProperties.has(
|
|
136
|
+
if (changedProperties.has("scopes")) {
|
|
115
137
|
this.selectedScopes = [...this.scopes];
|
|
116
138
|
}
|
|
117
139
|
// Update CSS variables from resolved config
|
|
118
140
|
if (this.resolved) {
|
|
119
|
-
this.style.setProperty(
|
|
120
|
-
this.style.setProperty(
|
|
141
|
+
this.style.setProperty("--consent-primary", this.resolved.branding.primaryColor);
|
|
142
|
+
this.style.setProperty("--consent-secondary", this.resolved.branding.secondaryColor);
|
|
121
143
|
}
|
|
122
144
|
}
|
|
123
145
|
// === FORM SUBMISSION ===
|
|
124
146
|
/**
|
|
125
147
|
* Get the provider_type based on the current auth mode.
|
|
126
148
|
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* -
|
|
149
|
+
* Uses the centralized AUTH_MODE_TO_PROVIDER_TYPE mapping from modes.types.ts
|
|
150
|
+
* to ensure type-safety and DRY principle compliance.
|
|
151
|
+
*
|
|
152
|
+
* For OAuth mode, returns the specific provider from oauthIdentity if available.
|
|
153
|
+
*
|
|
154
|
+
* @see getProviderTypeForAuthMode - The canonical mapping function
|
|
133
155
|
*/
|
|
134
156
|
getProviderType() {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
case AUTH_MODES.OAUTH:
|
|
139
|
-
return this.oauthIdentity?.provider ?? 'oauth2';
|
|
140
|
-
case AUTH_MODES.MAGIC_LINK:
|
|
141
|
-
return 'magic_link';
|
|
142
|
-
case AUTH_MODES.OTP:
|
|
143
|
-
return 'otp';
|
|
144
|
-
case AUTH_MODES.CONSENT_ONLY:
|
|
145
|
-
default:
|
|
146
|
-
return 'none';
|
|
157
|
+
// For OAuth, prefer the specific provider name if available
|
|
158
|
+
if (this.currentMode === AUTH_MODES.OAUTH && this.oauthIdentity?.provider) {
|
|
159
|
+
return this.oauthIdentity.provider;
|
|
147
160
|
}
|
|
161
|
+
// Use the centralized type-safe mapping
|
|
162
|
+
return getProviderTypeForAuthMode(this.currentMode);
|
|
148
163
|
}
|
|
149
164
|
/**
|
|
150
165
|
* Handle consent approval - TRIGGERS DELEGATIONCREDENTIAL (VC) CREATION
|
|
@@ -172,11 +187,11 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
172
187
|
return;
|
|
173
188
|
}
|
|
174
189
|
if (!this.termsAccepted && this.resolved?.terms.required) {
|
|
175
|
-
this.error =
|
|
190
|
+
this.error = "Please accept the terms to continue";
|
|
176
191
|
return;
|
|
177
192
|
}
|
|
178
193
|
if (this.scopes.length > 0 && this.selectedScopes.length === 0) {
|
|
179
|
-
this.error =
|
|
194
|
+
this.error = "Please select at least one permission";
|
|
180
195
|
return;
|
|
181
196
|
}
|
|
182
197
|
this.loading = true;
|
|
@@ -185,41 +200,80 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
185
200
|
// Build consent approval request
|
|
186
201
|
// The server creates the DelegationCredential (VC) when this request succeeds
|
|
187
202
|
const formData = new FormData();
|
|
188
|
-
formData.append(
|
|
189
|
-
formData.append(
|
|
190
|
-
formData.append(
|
|
191
|
-
formData.append(
|
|
192
|
-
formData.append(
|
|
193
|
-
formData.append(
|
|
203
|
+
formData.append("tool", this.tool);
|
|
204
|
+
formData.append("scopes", JSON.stringify(this.selectedScopes));
|
|
205
|
+
formData.append("agent_did", this.agentDid);
|
|
206
|
+
formData.append("session_id", this.sessionId);
|
|
207
|
+
formData.append("project_id", this.projectId);
|
|
208
|
+
formData.append("auth_mode", this.currentMode);
|
|
194
209
|
// Set provider_type based on auth mode to ensure correct server-side routing
|
|
195
210
|
// This is stored in delegation metadata to track what auth method was used
|
|
196
|
-
formData.append(
|
|
197
|
-
|
|
211
|
+
formData.append("provider_type", this.getProviderType());
|
|
212
|
+
// Include provider for credential auth and OAuth flows - REQUIRED by consent.service.ts validation
|
|
213
|
+
if (this.provider) {
|
|
214
|
+
formData.append("provider", this.provider);
|
|
215
|
+
}
|
|
216
|
+
// Include CSRF token for security - REQUIRED by consent.service.ts for credential auth
|
|
217
|
+
if (this.csrfToken) {
|
|
218
|
+
formData.append("csrf_token", this.csrfToken);
|
|
219
|
+
}
|
|
220
|
+
formData.append("termsAccepted", String(this.termsAccepted));
|
|
221
|
+
// Include credential auth params if present (3-screen flow: Auth → Clickwrap → Success)
|
|
222
|
+
// These are set when redirecting from credential auth page to clickwrap page
|
|
223
|
+
// They ensure the delegation is created with correct authorization.type ('password')
|
|
224
|
+
if (this.credentialProviderType) {
|
|
225
|
+
formData.append("credential_provider_type", this.credentialProviderType);
|
|
226
|
+
}
|
|
227
|
+
if (this.credentialProvider) {
|
|
228
|
+
formData.append("credential_provider", this.credentialProvider);
|
|
229
|
+
}
|
|
198
230
|
// Add custom form data (e.g., username/password for credential auth)
|
|
231
|
+
// DEBUG: Log form data before submission
|
|
232
|
+
console.log("[mcp-consent] handleApprove formData:", {
|
|
233
|
+
keys: Object.keys(this.formData),
|
|
234
|
+
hasUsername: "username" in this.formData,
|
|
235
|
+
hasPassword: "password" in this.formData,
|
|
236
|
+
usernameValue: this.formData["username"],
|
|
237
|
+
passwordLength: this.formData["password"]?.length ?? "null/undefined",
|
|
238
|
+
});
|
|
199
239
|
Object.entries(this.formData).forEach(([key, value]) => {
|
|
200
240
|
formData.append(key, value);
|
|
201
241
|
});
|
|
202
242
|
// Submit consent - server creates DelegationCredential on success
|
|
203
243
|
const response = await fetch(`${this.serverUrl}/consent/approve`, {
|
|
204
|
-
method:
|
|
244
|
+
method: "POST",
|
|
205
245
|
body: formData,
|
|
206
246
|
});
|
|
207
247
|
if (!response.ok) {
|
|
208
248
|
const errorData = await response.json().catch(() => ({}));
|
|
209
|
-
throw new Error(errorData.message ||
|
|
249
|
+
throw new Error(errorData.message || "Approval failed");
|
|
210
250
|
}
|
|
211
251
|
const result = await response.json();
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
252
|
+
// Check if server wants us to redirect (e.g., credential auth → clickwrap page)
|
|
253
|
+
// This implements the 3-screen flow: Auth → Clickwrap → Success
|
|
254
|
+
if (result.redirectUrl) {
|
|
255
|
+
// Dispatch event before redirect for any listeners that need to know
|
|
256
|
+
this.dispatchEvent(new CustomEvent("mcp-consent:approve", {
|
|
257
|
+
detail: { success: true, redirectUrl: result.redirectUrl },
|
|
258
|
+
bubbles: true,
|
|
259
|
+
composed: true,
|
|
260
|
+
}));
|
|
261
|
+
// Navigate to the redirect URL (clickwrap page after credential/OAuth auth)
|
|
262
|
+
// The clickwrap page will show user info + scopes, then create the delegation
|
|
263
|
+
window.location.href = result.redirectUrl;
|
|
264
|
+
return; // Don't show success yet - the redirect page will handle it
|
|
265
|
+
}
|
|
266
|
+
// No redirect - VC/delegation created successfully, show success screen
|
|
267
|
+
this.step = "success";
|
|
268
|
+
this.dispatchEvent(new CustomEvent("mcp-consent:approve", {
|
|
269
|
+
detail: { success: true, delegationId: result.delegation_id },
|
|
216
270
|
bubbles: true,
|
|
217
271
|
composed: true,
|
|
218
272
|
}));
|
|
219
273
|
}
|
|
220
274
|
catch (e) {
|
|
221
|
-
this.error = e instanceof Error ? e.message :
|
|
222
|
-
this.dispatchEvent(new CustomEvent(
|
|
275
|
+
this.error = e instanceof Error ? e.message : "Unknown error";
|
|
276
|
+
this.dispatchEvent(new CustomEvent("mcp-consent:error", {
|
|
223
277
|
detail: { error: this.error },
|
|
224
278
|
bubbles: true,
|
|
225
279
|
composed: true,
|
|
@@ -230,7 +284,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
230
284
|
}
|
|
231
285
|
}
|
|
232
286
|
handleDeny() {
|
|
233
|
-
this.dispatchEvent(new CustomEvent(
|
|
287
|
+
this.dispatchEvent(new CustomEvent("mcp-consent:deny", {
|
|
234
288
|
bubbles: true,
|
|
235
289
|
composed: true,
|
|
236
290
|
}));
|
|
@@ -241,6 +295,13 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
241
295
|
this.termsAccepted = e.detail.checked;
|
|
242
296
|
}
|
|
243
297
|
handleInputChange(name, value) {
|
|
298
|
+
// DEBUG: Log what's being captured from inputs
|
|
299
|
+
console.log("[mcp-consent] handleInputChange:", {
|
|
300
|
+
name,
|
|
301
|
+
valueType: typeof value,
|
|
302
|
+
valueLength: value?.length ?? "null/undefined",
|
|
303
|
+
value: name === "password" ? "***" : value,
|
|
304
|
+
});
|
|
244
305
|
this.formData = { ...this.formData, [name]: value };
|
|
245
306
|
}
|
|
246
307
|
handleResendOtp() {
|
|
@@ -262,14 +323,14 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
262
323
|
}
|
|
263
324
|
}, 1000);
|
|
264
325
|
// Dispatch event for parent to handle actual resend
|
|
265
|
-
this.dispatchEvent(new CustomEvent(
|
|
326
|
+
this.dispatchEvent(new CustomEvent("mcp-consent:resend-otp", {
|
|
266
327
|
bubbles: true,
|
|
267
328
|
composed: true,
|
|
268
329
|
}));
|
|
269
330
|
}
|
|
270
331
|
// === RENDER METHODS ===
|
|
271
332
|
renderAgentInfo() {
|
|
272
|
-
const agentDisplay = this.agentName ||
|
|
333
|
+
const agentDisplay = this.agentName || "this agent";
|
|
273
334
|
return html `
|
|
274
335
|
<div class="agent-info">
|
|
275
336
|
<div class="agent-icon">
|
|
@@ -289,7 +350,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
289
350
|
<strong>${agentDisplay}</strong> is requesting permission to
|
|
290
351
|
${this.tool
|
|
291
352
|
? html `use the <strong>${this.tool}</strong> tool`
|
|
292
|
-
:
|
|
353
|
+
: "access your data"}
|
|
293
354
|
on your behalf.
|
|
294
355
|
</p>
|
|
295
356
|
</div>
|
|
@@ -305,7 +366,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
305
366
|
return html `
|
|
306
367
|
<p class="permissions-header">
|
|
307
368
|
${this.resolved?.ui.permissionsHeader ??
|
|
308
|
-
|
|
369
|
+
"The agent is requesting the following permissions:"}
|
|
309
370
|
</p>
|
|
310
371
|
<div class="permissions">
|
|
311
372
|
<consent-permissions
|
|
@@ -321,8 +382,8 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
321
382
|
const days = this.resolved?.expirationDays ?? 7;
|
|
322
383
|
return html `
|
|
323
384
|
<p class="expiration">
|
|
324
|
-
${this.resolved?.ui.expirationText ??
|
|
325
|
-
<strong>${days} ${days === 1 ?
|
|
385
|
+
${this.resolved?.ui.expirationText ?? "This delegation will expire in"}
|
|
386
|
+
<strong>${days} ${days === 1 ? "day" : "days"}</strong>
|
|
326
387
|
</p>
|
|
327
388
|
`;
|
|
328
389
|
}
|
|
@@ -334,7 +395,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
334
395
|
<consent-terms
|
|
335
396
|
name="termsAccepted"
|
|
336
397
|
text=${this.resolved.terms.text}
|
|
337
|
-
url=${this.resolved.terms.url ??
|
|
398
|
+
url=${this.resolved.terms.url ?? ""}
|
|
338
399
|
?required=${this.resolved.terms.required}
|
|
339
400
|
@change=${this.handleTermsChange}
|
|
340
401
|
></consent-terms>
|
|
@@ -350,7 +411,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
350
411
|
return html `
|
|
351
412
|
<div slot="footer">
|
|
352
413
|
<consent-button variant="secondary" @click=${this.handleDeny}>
|
|
353
|
-
${this.resolved?.ui.cancelButtonText ??
|
|
414
|
+
${this.resolved?.ui.cancelButtonText ?? "Cancel"}
|
|
354
415
|
</consent-button>
|
|
355
416
|
<consent-button
|
|
356
417
|
variant="primary"
|
|
@@ -358,7 +419,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
358
419
|
?disabled=${this.resolved?.terms.required && !this.termsAccepted}
|
|
359
420
|
@click=${this.handleApprove}
|
|
360
421
|
>
|
|
361
|
-
${this.resolved?.ui.submitButtonText ??
|
|
422
|
+
${this.resolved?.ui.submitButtonText ?? "Allow access"}
|
|
362
423
|
</consent-button>
|
|
363
424
|
</div>
|
|
364
425
|
`;
|
|
@@ -367,11 +428,11 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
367
428
|
renderConsentOnly() {
|
|
368
429
|
return html `
|
|
369
430
|
<consent-shell
|
|
370
|
-
page-title=${this.resolved?.ui.title ??
|
|
371
|
-
company-name=${this.resolved?.branding.companyName ??
|
|
372
|
-
logo-url=${this.resolved?.branding.logoUrl ??
|
|
373
|
-
primary-color=${this.resolved?.branding.primaryColor ??
|
|
374
|
-
secondary-color=${this.resolved?.branding.secondaryColor ??
|
|
431
|
+
page-title=${this.resolved?.ui.title ?? "Permission Request"}
|
|
432
|
+
company-name=${this.resolved?.branding.companyName ?? ""}
|
|
433
|
+
logo-url=${this.resolved?.branding.logoUrl ?? ""}
|
|
434
|
+
primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
|
|
435
|
+
secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
|
|
375
436
|
>
|
|
376
437
|
<div slot="content">
|
|
377
438
|
${this.renderError()} ${this.renderAgentInfo()}
|
|
@@ -386,11 +447,11 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
386
447
|
const creds = this.resolved?.credentials;
|
|
387
448
|
return html `
|
|
388
449
|
<consent-shell
|
|
389
|
-
page-title=${this.resolved?.ui.title ??
|
|
390
|
-
company-name=${this.resolved?.branding.companyName ??
|
|
391
|
-
logo-url=${this.resolved?.branding.logoUrl ??
|
|
392
|
-
primary-color=${this.resolved?.branding.primaryColor ??
|
|
393
|
-
secondary-color=${this.resolved?.branding.secondaryColor ??
|
|
450
|
+
page-title=${this.resolved?.ui.title ?? "Sign In"}
|
|
451
|
+
company-name=${this.resolved?.branding.companyName ?? ""}
|
|
452
|
+
logo-url=${this.resolved?.branding.logoUrl ?? ""}
|
|
453
|
+
primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
|
|
454
|
+
secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
|
|
394
455
|
>
|
|
395
456
|
<div slot="content">
|
|
396
457
|
${this.renderError()} ${this.renderAgentInfo()}
|
|
@@ -399,21 +460,35 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
399
460
|
<consent-input
|
|
400
461
|
type="text"
|
|
401
462
|
name="username"
|
|
402
|
-
label=${creds?.usernameLabel ??
|
|
403
|
-
placeholder=${creds?.usernamePlaceholder ??
|
|
463
|
+
label=${creds?.usernameLabel ?? "Username"}
|
|
464
|
+
placeholder=${creds?.usernamePlaceholder ?? "Enter your username"}
|
|
404
465
|
autocomplete="username"
|
|
405
466
|
required
|
|
406
|
-
@input=${(e) =>
|
|
467
|
+
@input=${(e) => {
|
|
468
|
+
// Handle both CustomEvent (from consent-input) and native InputEvent
|
|
469
|
+
const customEvent = e;
|
|
470
|
+
const value = customEvent.detail?.value ??
|
|
471
|
+
e.target?.value ??
|
|
472
|
+
"";
|
|
473
|
+
this.handleInputChange("username", value);
|
|
474
|
+
}}
|
|
407
475
|
></consent-input>
|
|
408
476
|
|
|
409
477
|
<consent-input
|
|
410
478
|
type="password"
|
|
411
479
|
name="password"
|
|
412
|
-
label=${creds?.passwordLabel ??
|
|
413
|
-
placeholder=${creds?.passwordPlaceholder ??
|
|
480
|
+
label=${creds?.passwordLabel ?? "Password"}
|
|
481
|
+
placeholder=${creds?.passwordPlaceholder ?? "Enter your password"}
|
|
414
482
|
autocomplete="current-password"
|
|
415
483
|
required
|
|
416
|
-
@input=${(e) =>
|
|
484
|
+
@input=${(e) => {
|
|
485
|
+
// Handle both CustomEvent (from consent-input) and native InputEvent
|
|
486
|
+
const customEvent = e;
|
|
487
|
+
const value = customEvent.detail?.value ??
|
|
488
|
+
e.target?.value ??
|
|
489
|
+
"";
|
|
490
|
+
this.handleInputChange("password", value);
|
|
491
|
+
}}
|
|
417
492
|
></consent-input>
|
|
418
493
|
</div>
|
|
419
494
|
|
|
@@ -438,15 +513,15 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
438
513
|
}
|
|
439
514
|
renderOAuth() {
|
|
440
515
|
const oauth = this.resolved?.oauth;
|
|
441
|
-
const provider = oauth?.providerId ??
|
|
442
|
-
const providerName = oauth?.providerName ??
|
|
516
|
+
const provider = oauth?.providerId ?? "oauth";
|
|
517
|
+
const providerName = oauth?.providerName ?? "OAuth Provider";
|
|
443
518
|
return html `
|
|
444
519
|
<consent-shell
|
|
445
|
-
page-title=${this.resolved?.ui.title ??
|
|
446
|
-
company-name=${this.resolved?.branding.companyName ??
|
|
447
|
-
logo-url=${this.resolved?.branding.logoUrl ??
|
|
448
|
-
primary-color=${this.resolved?.branding.primaryColor ??
|
|
449
|
-
secondary-color=${this.resolved?.branding.secondaryColor ??
|
|
520
|
+
page-title=${this.resolved?.ui.title ?? "Sign In"}
|
|
521
|
+
company-name=${this.resolved?.branding.companyName ?? ""}
|
|
522
|
+
logo-url=${this.resolved?.branding.logoUrl ?? ""}
|
|
523
|
+
primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
|
|
524
|
+
secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
|
|
450
525
|
>
|
|
451
526
|
<div slot="content">
|
|
452
527
|
${this.renderError()} ${this.renderAgentInfo()}
|
|
@@ -473,11 +548,11 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
473
548
|
const ml = this.resolved?.magicLink;
|
|
474
549
|
return html `
|
|
475
550
|
<consent-shell
|
|
476
|
-
page-title=${this.resolved?.ui.title ??
|
|
477
|
-
company-name=${this.resolved?.branding.companyName ??
|
|
478
|
-
logo-url=${this.resolved?.branding.logoUrl ??
|
|
479
|
-
primary-color=${this.resolved?.branding.primaryColor ??
|
|
480
|
-
secondary-color=${this.resolved?.branding.secondaryColor ??
|
|
551
|
+
page-title=${this.resolved?.ui.title ?? "Sign In"}
|
|
552
|
+
company-name=${this.resolved?.branding.companyName ?? ""}
|
|
553
|
+
logo-url=${this.resolved?.branding.logoUrl ?? ""}
|
|
554
|
+
primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
|
|
555
|
+
secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
|
|
481
556
|
>
|
|
482
557
|
<div slot="content">
|
|
483
558
|
${this.renderError()} ${this.renderAgentInfo()}
|
|
@@ -486,11 +561,18 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
486
561
|
<consent-input
|
|
487
562
|
type="email"
|
|
488
563
|
name="email"
|
|
489
|
-
label=${ml?.emailLabel ??
|
|
490
|
-
placeholder=${ml?.emailPlaceholder ??
|
|
564
|
+
label=${ml?.emailLabel ?? "Email"}
|
|
565
|
+
placeholder=${ml?.emailPlaceholder ?? "Enter your email address"}
|
|
491
566
|
autocomplete="email"
|
|
492
567
|
required
|
|
493
|
-
@input=${(e) =>
|
|
568
|
+
@input=${(e) => {
|
|
569
|
+
// Handle both CustomEvent (from consent-input) and native InputEvent
|
|
570
|
+
const customEvent = e;
|
|
571
|
+
const value = customEvent.detail?.value ??
|
|
572
|
+
e.target?.value ??
|
|
573
|
+
"";
|
|
574
|
+
this.handleInputChange("email", value);
|
|
575
|
+
}}
|
|
494
576
|
></consent-input>
|
|
495
577
|
</div>
|
|
496
578
|
|
|
@@ -508,7 +590,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
508
590
|
?disabled=${this.resolved?.terms.required && !this.termsAccepted}
|
|
509
591
|
@click=${this.handleApprove}
|
|
510
592
|
>
|
|
511
|
-
${ml?.buttonText ??
|
|
593
|
+
${ml?.buttonText ?? "Send magic link"}
|
|
512
594
|
</consent-button>
|
|
513
595
|
</div>
|
|
514
596
|
</consent-shell>
|
|
@@ -518,28 +600,35 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
518
600
|
const otp = this.resolved?.otp;
|
|
519
601
|
return html `
|
|
520
602
|
<consent-shell
|
|
521
|
-
page-title=${this.resolved?.ui.title ??
|
|
522
|
-
company-name=${this.resolved?.branding.companyName ??
|
|
523
|
-
logo-url=${this.resolved?.branding.logoUrl ??
|
|
524
|
-
primary-color=${this.resolved?.branding.primaryColor ??
|
|
525
|
-
secondary-color=${this.resolved?.branding.secondaryColor ??
|
|
603
|
+
page-title=${this.resolved?.ui.title ?? "Verify Code"}
|
|
604
|
+
company-name=${this.resolved?.branding.companyName ?? ""}
|
|
605
|
+
logo-url=${this.resolved?.branding.logoUrl ?? ""}
|
|
606
|
+
primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
|
|
607
|
+
secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
|
|
526
608
|
>
|
|
527
609
|
<div slot="content">
|
|
528
610
|
${this.renderError()} ${this.renderAgentInfo()}
|
|
529
611
|
|
|
530
612
|
<div class="otp-section">
|
|
531
613
|
<p class="otp-instructions">
|
|
532
|
-
${otp?.instructions ??
|
|
614
|
+
${otp?.instructions ??
|
|
615
|
+
"Enter the verification code sent to your device"}
|
|
533
616
|
</p>
|
|
534
617
|
<consent-otp-input
|
|
535
618
|
length=${otp?.digits ?? 6}
|
|
536
619
|
name="otp"
|
|
537
620
|
auto-focus
|
|
538
621
|
@complete=${(e) => {
|
|
539
|
-
|
|
622
|
+
const customEvent = e;
|
|
623
|
+
const value = customEvent.detail?.value ?? "";
|
|
624
|
+
this.handleInputChange("otp", value);
|
|
540
625
|
this.handleApprove();
|
|
541
626
|
}}
|
|
542
|
-
@input=${(e) =>
|
|
627
|
+
@input=${(e) => {
|
|
628
|
+
const customEvent = e;
|
|
629
|
+
const value = customEvent.detail?.value ?? "";
|
|
630
|
+
this.handleInputChange("otp", value);
|
|
631
|
+
}}
|
|
543
632
|
></consent-otp-input>
|
|
544
633
|
<div class="otp-resend">
|
|
545
634
|
Didn't receive the code?
|
|
@@ -550,7 +639,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
550
639
|
>
|
|
551
640
|
${this.resendCooldown > 0
|
|
552
641
|
? `Resend in ${this.resendCooldown}s`
|
|
553
|
-
:
|
|
642
|
+
: "Resend"}
|
|
554
643
|
</button>
|
|
555
644
|
</div>
|
|
556
645
|
</div>
|
|
@@ -565,11 +654,11 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
565
654
|
const success = this.resolved?.success;
|
|
566
655
|
return html `
|
|
567
656
|
<consent-shell
|
|
568
|
-
page-title=${success?.title ??
|
|
569
|
-
company-name=${this.resolved?.branding.companyName ??
|
|
570
|
-
logo-url=${this.resolved?.branding.logoUrl ??
|
|
571
|
-
primary-color=${this.resolved?.branding.primaryColor ??
|
|
572
|
-
secondary-color=${this.resolved?.branding.secondaryColor ??
|
|
657
|
+
page-title=${success?.title ?? "Access Granted"}
|
|
658
|
+
company-name=${this.resolved?.branding.companyName ?? ""}
|
|
659
|
+
logo-url=${this.resolved?.branding.logoUrl ?? ""}
|
|
660
|
+
primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
|
|
661
|
+
secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
|
|
573
662
|
>
|
|
574
663
|
<div slot="content">
|
|
575
664
|
<div class="success-view">
|
|
@@ -584,10 +673,10 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
584
673
|
<polyline points="20 6 9 17 4 12" />
|
|
585
674
|
</svg>
|
|
586
675
|
</div>
|
|
587
|
-
<h2 class="success-title">${success?.title ??
|
|
676
|
+
<h2 class="success-title">${success?.title ?? "Access Granted"}</h2>
|
|
588
677
|
<p class="success-description">
|
|
589
678
|
${success?.description ??
|
|
590
|
-
|
|
679
|
+
"You have successfully granted access. You can now close this window."}
|
|
591
680
|
</p>
|
|
592
681
|
</div>
|
|
593
682
|
</div>
|
|
@@ -598,7 +687,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
598
687
|
full-width
|
|
599
688
|
@click=${() => window.close()}
|
|
600
689
|
>
|
|
601
|
-
${success?.continueButtonText ??
|
|
690
|
+
${success?.continueButtonText ?? "Close"}
|
|
602
691
|
</consent-button>
|
|
603
692
|
</div>
|
|
604
693
|
</consent-shell>
|
|
@@ -606,7 +695,7 @@ let McpConsent = class McpConsent extends LitElement {
|
|
|
606
695
|
}
|
|
607
696
|
// === MAIN RENDER ===
|
|
608
697
|
render() {
|
|
609
|
-
if (this.step ===
|
|
698
|
+
if (this.step === "success") {
|
|
610
699
|
return this.renderSuccess();
|
|
611
700
|
}
|
|
612
701
|
switch (this.currentMode) {
|
|
@@ -628,8 +717,9 @@ McpConsent.styles = css `
|
|
|
628
717
|
:host {
|
|
629
718
|
display: block;
|
|
630
719
|
/* System font stack with font smoothing for crisp text */
|
|
631
|
-
font-family:
|
|
632
|
-
|
|
720
|
+
font-family:
|
|
721
|
+
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
|
|
722
|
+
Arial, sans-serif;
|
|
633
723
|
-webkit-font-smoothing: antialiased;
|
|
634
724
|
-moz-osx-font-smoothing: grayscale;
|
|
635
725
|
--_primary: var(--consent-primary, #2563eb);
|
|
@@ -736,7 +826,7 @@ McpConsent.styles = css `
|
|
|
736
826
|
|
|
737
827
|
.divider::before,
|
|
738
828
|
.divider::after {
|
|
739
|
-
content:
|
|
829
|
+
content: "";
|
|
740
830
|
flex: 1;
|
|
741
831
|
height: 1px;
|
|
742
832
|
background: #e5e7eb;
|
|
@@ -823,7 +913,7 @@ __decorate([
|
|
|
823
913
|
}
|
|
824
914
|
},
|
|
825
915
|
toAttribute: (value) => {
|
|
826
|
-
return value ? JSON.stringify(value) :
|
|
916
|
+
return value ? JSON.stringify(value) : "";
|
|
827
917
|
},
|
|
828
918
|
},
|
|
829
919
|
})
|
|
@@ -855,24 +945,36 @@ __decorate([
|
|
|
855
945
|
})
|
|
856
946
|
], McpConsent.prototype, "scopes", void 0);
|
|
857
947
|
__decorate([
|
|
858
|
-
property({ type: String, attribute:
|
|
948
|
+
property({ type: String, attribute: "agent-did" })
|
|
859
949
|
], McpConsent.prototype, "agentDid", void 0);
|
|
860
950
|
__decorate([
|
|
861
|
-
property({ type: String, attribute:
|
|
951
|
+
property({ type: String, attribute: "session-id" })
|
|
862
952
|
], McpConsent.prototype, "sessionId", void 0);
|
|
863
953
|
__decorate([
|
|
864
|
-
property({ type: String, attribute:
|
|
954
|
+
property({ type: String, attribute: "project-id" })
|
|
865
955
|
], McpConsent.prototype, "projectId", void 0);
|
|
866
956
|
__decorate([
|
|
867
|
-
property({ type: String, attribute:
|
|
957
|
+
property({ type: String, attribute: "server-url" })
|
|
868
958
|
], McpConsent.prototype, "serverUrl", void 0);
|
|
869
959
|
__decorate([
|
|
870
|
-
property({ type: String, attribute:
|
|
960
|
+
property({ type: String, attribute: "agent-name" })
|
|
871
961
|
], McpConsent.prototype, "agentName", void 0);
|
|
962
|
+
__decorate([
|
|
963
|
+
property({ type: String, attribute: "provider" })
|
|
964
|
+
], McpConsent.prototype, "provider", void 0);
|
|
965
|
+
__decorate([
|
|
966
|
+
property({ type: String, attribute: "csrf-token" })
|
|
967
|
+
], McpConsent.prototype, "csrfToken", void 0);
|
|
968
|
+
__decorate([
|
|
969
|
+
property({ type: String, attribute: "credential-provider-type" })
|
|
970
|
+
], McpConsent.prototype, "credentialProviderType", void 0);
|
|
971
|
+
__decorate([
|
|
972
|
+
property({ type: String, attribute: "credential-provider" })
|
|
973
|
+
], McpConsent.prototype, "credentialProvider", void 0);
|
|
872
974
|
__decorate([
|
|
873
975
|
property({
|
|
874
976
|
type: Object,
|
|
875
|
-
attribute:
|
|
977
|
+
attribute: "oauth-identity",
|
|
876
978
|
converter: {
|
|
877
979
|
fromAttribute: (value) => {
|
|
878
980
|
if (!value)
|
|
@@ -885,7 +987,7 @@ __decorate([
|
|
|
885
987
|
}
|
|
886
988
|
},
|
|
887
989
|
toAttribute: (value) => {
|
|
888
|
-
return value ? JSON.stringify(value) :
|
|
990
|
+
return value ? JSON.stringify(value) : "";
|
|
889
991
|
},
|
|
890
992
|
},
|
|
891
993
|
})
|
|
@@ -918,7 +1020,7 @@ __decorate([
|
|
|
918
1020
|
state()
|
|
919
1021
|
], McpConsent.prototype, "selectedScopes", void 0);
|
|
920
1022
|
McpConsent = __decorate([
|
|
921
|
-
customElement(
|
|
1023
|
+
customElement("mcp-consent")
|
|
922
1024
|
], McpConsent);
|
|
923
1025
|
export { McpConsent };
|
|
924
1026
|
//# sourceMappingURL=mcp-consent.js.map
|