@kya-os/consent 0.1.9 → 0.1.12

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.
@@ -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 'lit';
16
- import { customElement, property, state } from 'lit/decorators.js';
17
- import { AUTH_MODES } from '../types/modes.types.js';
18
- import { resolveConsentConfig, determineAuthMode } from '../resolution/resolve-config.js';
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 './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';
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,31 +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
81
  /**
82
82
  * Auth provider identifier (e.g., 'credentials', 'google', 'github')
83
83
  * Required for credential auth and OAuth flows to identify the provider
84
84
  */
85
- this.provider = '';
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 = "";
86
103
  this.currentMode = AUTH_MODES.CONSENT_ONLY;
87
104
  this.loading = false;
88
- this.step = 'consent';
105
+ this.step = "consent";
89
106
  this.termsAccepted = false;
90
107
  this.formData = {};
91
108
  this.resendCooldown = 0;
@@ -109,47 +126,40 @@ let McpConsent = class McpConsent extends LitElement {
109
126
  }
110
127
  }
111
128
  updated(changedProperties) {
112
- if (changedProperties.has('config') || changedProperties.has('agentName')) {
129
+ if (changedProperties.has("config") || changedProperties.has("agentName")) {
113
130
  this.resolved = resolveConsentConfig(this.config, this.agentName);
114
131
  }
115
- if (changedProperties.has('mode') && this.mode) {
132
+ if (changedProperties.has("mode") && this.mode) {
116
133
  this.currentMode = this.mode;
117
134
  }
118
135
  // Update selected scopes when scopes change
119
- if (changedProperties.has('scopes')) {
136
+ if (changedProperties.has("scopes")) {
120
137
  this.selectedScopes = [...this.scopes];
121
138
  }
122
139
  // Update CSS variables from resolved config
123
140
  if (this.resolved) {
124
- this.style.setProperty('--consent-primary', this.resolved.branding.primaryColor);
125
- this.style.setProperty('--consent-secondary', this.resolved.branding.secondaryColor);
141
+ this.style.setProperty("--consent-primary", this.resolved.branding.primaryColor);
142
+ this.style.setProperty("--consent-secondary", this.resolved.branding.secondaryColor);
126
143
  }
127
144
  }
128
145
  // === FORM SUBMISSION ===
129
146
  /**
130
147
  * Get the provider_type based on the current auth mode.
131
148
  *
132
- * This maps auth modes to the provider_type expected by the consent service:
133
- * - consent-only 'none'
134
- * - credentials → 'credential'
135
- * - oauth 'oauth2' (or specific provider from oauthIdentity)
136
- * - magic-link → 'magic_link'
137
- * - otp 'otp'
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
138
155
  */
139
156
  getProviderType() {
140
- switch (this.currentMode) {
141
- case AUTH_MODES.CREDENTIALS:
142
- return 'credential';
143
- case AUTH_MODES.OAUTH:
144
- return this.oauthIdentity?.provider ?? 'oauth2';
145
- case AUTH_MODES.MAGIC_LINK:
146
- return 'magic_link';
147
- case AUTH_MODES.OTP:
148
- return 'otp';
149
- case AUTH_MODES.CONSENT_ONLY:
150
- default:
151
- 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;
152
160
  }
161
+ // Use the centralized type-safe mapping
162
+ return getProviderTypeForAuthMode(this.currentMode);
153
163
  }
154
164
  /**
155
165
  * Handle consent approval - TRIGGERS DELEGATIONCREDENTIAL (VC) CREATION
@@ -177,11 +187,11 @@ let McpConsent = class McpConsent extends LitElement {
177
187
  return;
178
188
  }
179
189
  if (!this.termsAccepted && this.resolved?.terms.required) {
180
- this.error = 'Please accept the terms to continue';
190
+ this.error = "Please accept the terms to continue";
181
191
  return;
182
192
  }
183
193
  if (this.scopes.length > 0 && this.selectedScopes.length === 0) {
184
- this.error = 'Please select at least one permission';
194
+ this.error = "Please select at least one permission";
185
195
  return;
186
196
  }
187
197
  this.loading = true;
@@ -190,45 +200,72 @@ let McpConsent = class McpConsent extends LitElement {
190
200
  // Build consent approval request
191
201
  // The server creates the DelegationCredential (VC) when this request succeeds
192
202
  const formData = new FormData();
193
- formData.append('tool', this.tool);
194
- formData.append('scopes', JSON.stringify(this.selectedScopes));
195
- formData.append('agent_did', this.agentDid);
196
- formData.append('session_id', this.sessionId);
197
- formData.append('project_id', this.projectId);
198
- formData.append('auth_mode', this.currentMode);
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);
199
209
  // Set provider_type based on auth mode to ensure correct server-side routing
200
210
  // This is stored in delegation metadata to track what auth method was used
201
- formData.append('provider_type', this.getProviderType());
211
+ formData.append("provider_type", this.getProviderType());
202
212
  // Include provider for credential auth and OAuth flows - REQUIRED by consent.service.ts validation
203
213
  if (this.provider) {
204
- formData.append('provider', 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);
205
229
  }
206
- formData.append('termsAccepted', String(this.termsAccepted));
207
230
  // Add custom form data (e.g., username/password for credential auth)
208
231
  Object.entries(this.formData).forEach(([key, value]) => {
209
232
  formData.append(key, value);
210
233
  });
211
234
  // Submit consent - server creates DelegationCredential on success
212
235
  const response = await fetch(`${this.serverUrl}/consent/approve`, {
213
- method: 'POST',
236
+ method: "POST",
214
237
  body: formData,
215
238
  });
216
239
  if (!response.ok) {
217
240
  const errorData = await response.json().catch(() => ({}));
218
- throw new Error(errorData.message || 'Approval failed');
241
+ throw new Error(errorData.message || "Approval failed");
219
242
  }
220
243
  const result = await response.json();
221
- // VC created successfully - show success screen
222
- this.step = 'success';
223
- this.dispatchEvent(new CustomEvent('mcp-consent:approve', {
224
- detail: { success: true, redirectUrl: result.redirectUrl },
244
+ // Check if server wants us to redirect (e.g., credential auth → clickwrap page)
245
+ // This implements the 3-screen flow: Auth → Clickwrap → Success
246
+ if (result.redirectUrl) {
247
+ // Dispatch event before redirect for any listeners that need to know
248
+ this.dispatchEvent(new CustomEvent("mcp-consent:approve", {
249
+ detail: { success: true, redirectUrl: result.redirectUrl },
250
+ bubbles: true,
251
+ composed: true,
252
+ }));
253
+ // Navigate to the redirect URL (clickwrap page after credential/OAuth auth)
254
+ // The clickwrap page will show user info + scopes, then create the delegation
255
+ window.location.href = result.redirectUrl;
256
+ return; // Don't show success yet - the redirect page will handle it
257
+ }
258
+ // No redirect - VC/delegation created successfully, show success screen
259
+ this.step = "success";
260
+ this.dispatchEvent(new CustomEvent("mcp-consent:approve", {
261
+ detail: { success: true, delegationId: result.delegation_id },
225
262
  bubbles: true,
226
263
  composed: true,
227
264
  }));
228
265
  }
229
266
  catch (e) {
230
- this.error = e instanceof Error ? e.message : 'Unknown error';
231
- this.dispatchEvent(new CustomEvent('mcp-consent:error', {
267
+ this.error = e instanceof Error ? e.message : "Unknown error";
268
+ this.dispatchEvent(new CustomEvent("mcp-consent:error", {
232
269
  detail: { error: this.error },
233
270
  bubbles: true,
234
271
  composed: true,
@@ -239,7 +276,7 @@ let McpConsent = class McpConsent extends LitElement {
239
276
  }
240
277
  }
241
278
  handleDeny() {
242
- this.dispatchEvent(new CustomEvent('mcp-consent:deny', {
279
+ this.dispatchEvent(new CustomEvent("mcp-consent:deny", {
243
280
  bubbles: true,
244
281
  composed: true,
245
282
  }));
@@ -271,14 +308,14 @@ let McpConsent = class McpConsent extends LitElement {
271
308
  }
272
309
  }, 1000);
273
310
  // Dispatch event for parent to handle actual resend
274
- this.dispatchEvent(new CustomEvent('mcp-consent:resend-otp', {
311
+ this.dispatchEvent(new CustomEvent("mcp-consent:resend-otp", {
275
312
  bubbles: true,
276
313
  composed: true,
277
314
  }));
278
315
  }
279
316
  // === RENDER METHODS ===
280
317
  renderAgentInfo() {
281
- const agentDisplay = this.agentName || 'this agent';
318
+ const agentDisplay = this.agentName || "this agent";
282
319
  return html `
283
320
  <div class="agent-info">
284
321
  <div class="agent-icon">
@@ -298,7 +335,7 @@ let McpConsent = class McpConsent extends LitElement {
298
335
  <strong>${agentDisplay}</strong> is requesting permission to
299
336
  ${this.tool
300
337
  ? html `use the <strong>${this.tool}</strong> tool`
301
- : 'access your data'}
338
+ : "access your data"}
302
339
  on your behalf.
303
340
  </p>
304
341
  </div>
@@ -314,7 +351,7 @@ let McpConsent = class McpConsent extends LitElement {
314
351
  return html `
315
352
  <p class="permissions-header">
316
353
  ${this.resolved?.ui.permissionsHeader ??
317
- 'The agent is requesting the following permissions:'}
354
+ "The agent is requesting the following permissions:"}
318
355
  </p>
319
356
  <div class="permissions">
320
357
  <consent-permissions
@@ -330,8 +367,8 @@ let McpConsent = class McpConsent extends LitElement {
330
367
  const days = this.resolved?.expirationDays ?? 7;
331
368
  return html `
332
369
  <p class="expiration">
333
- ${this.resolved?.ui.expirationText ?? 'This delegation will expire in'}
334
- <strong>${days} ${days === 1 ? 'day' : 'days'}</strong>
370
+ ${this.resolved?.ui.expirationText ?? "This delegation will expire in"}
371
+ <strong>${days} ${days === 1 ? "day" : "days"}</strong>
335
372
  </p>
336
373
  `;
337
374
  }
@@ -343,7 +380,7 @@ let McpConsent = class McpConsent extends LitElement {
343
380
  <consent-terms
344
381
  name="termsAccepted"
345
382
  text=${this.resolved.terms.text}
346
- url=${this.resolved.terms.url ?? ''}
383
+ url=${this.resolved.terms.url ?? ""}
347
384
  ?required=${this.resolved.terms.required}
348
385
  @change=${this.handleTermsChange}
349
386
  ></consent-terms>
@@ -359,7 +396,7 @@ let McpConsent = class McpConsent extends LitElement {
359
396
  return html `
360
397
  <div slot="footer">
361
398
  <consent-button variant="secondary" @click=${this.handleDeny}>
362
- ${this.resolved?.ui.cancelButtonText ?? 'Cancel'}
399
+ ${this.resolved?.ui.cancelButtonText ?? "Cancel"}
363
400
  </consent-button>
364
401
  <consent-button
365
402
  variant="primary"
@@ -367,7 +404,7 @@ let McpConsent = class McpConsent extends LitElement {
367
404
  ?disabled=${this.resolved?.terms.required && !this.termsAccepted}
368
405
  @click=${this.handleApprove}
369
406
  >
370
- ${this.resolved?.ui.submitButtonText ?? 'Allow access'}
407
+ ${this.resolved?.ui.submitButtonText ?? "Allow access"}
371
408
  </consent-button>
372
409
  </div>
373
410
  `;
@@ -376,11 +413,11 @@ let McpConsent = class McpConsent extends LitElement {
376
413
  renderConsentOnly() {
377
414
  return html `
378
415
  <consent-shell
379
- page-title=${this.resolved?.ui.title ?? 'Permission Request'}
380
- company-name=${this.resolved?.branding.companyName ?? ''}
381
- logo-url=${this.resolved?.branding.logoUrl ?? ''}
382
- primary-color=${this.resolved?.branding.primaryColor ?? '#2563eb'}
383
- secondary-color=${this.resolved?.branding.secondaryColor ?? '#dbeafe'}
416
+ page-title=${this.resolved?.ui.title ?? "Permission Request"}
417
+ company-name=${this.resolved?.branding.companyName ?? ""}
418
+ logo-url=${this.resolved?.branding.logoUrl ?? ""}
419
+ primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
420
+ secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
384
421
  >
385
422
  <div slot="content">
386
423
  ${this.renderError()} ${this.renderAgentInfo()}
@@ -395,11 +432,11 @@ let McpConsent = class McpConsent extends LitElement {
395
432
  const creds = this.resolved?.credentials;
396
433
  return html `
397
434
  <consent-shell
398
- page-title=${this.resolved?.ui.title ?? 'Sign In'}
399
- company-name=${this.resolved?.branding.companyName ?? ''}
400
- logo-url=${this.resolved?.branding.logoUrl ?? ''}
401
- primary-color=${this.resolved?.branding.primaryColor ?? '#2563eb'}
402
- secondary-color=${this.resolved?.branding.secondaryColor ?? '#dbeafe'}
435
+ page-title=${this.resolved?.ui.title ?? "Sign In"}
436
+ company-name=${this.resolved?.branding.companyName ?? ""}
437
+ logo-url=${this.resolved?.branding.logoUrl ?? ""}
438
+ primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
439
+ secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
403
440
  >
404
441
  <div slot="content">
405
442
  ${this.renderError()} ${this.renderAgentInfo()}
@@ -408,21 +445,35 @@ let McpConsent = class McpConsent extends LitElement {
408
445
  <consent-input
409
446
  type="text"
410
447
  name="username"
411
- label=${creds?.usernameLabel ?? 'Username'}
412
- placeholder=${creds?.usernamePlaceholder ?? 'Enter your username'}
448
+ label=${creds?.usernameLabel ?? "Username"}
449
+ placeholder=${creds?.usernamePlaceholder ?? "Enter your username"}
413
450
  autocomplete="username"
414
451
  required
415
- @input=${(e) => this.handleInputChange('username', e.detail.value)}
452
+ @input=${(e) => {
453
+ // Handle both CustomEvent (from consent-input) and native InputEvent
454
+ const customEvent = e;
455
+ const value = customEvent.detail?.value ??
456
+ e.target?.value ??
457
+ "";
458
+ this.handleInputChange("username", value);
459
+ }}
416
460
  ></consent-input>
417
461
 
418
462
  <consent-input
419
463
  type="password"
420
464
  name="password"
421
- label=${creds?.passwordLabel ?? 'Password'}
422
- placeholder=${creds?.passwordPlaceholder ?? 'Enter your password'}
465
+ label=${creds?.passwordLabel ?? "Password"}
466
+ placeholder=${creds?.passwordPlaceholder ?? "Enter your password"}
423
467
  autocomplete="current-password"
424
468
  required
425
- @input=${(e) => this.handleInputChange('password', e.detail.value)}
469
+ @input=${(e) => {
470
+ // Handle both CustomEvent (from consent-input) and native InputEvent
471
+ const customEvent = e;
472
+ const value = customEvent.detail?.value ??
473
+ e.target?.value ??
474
+ "";
475
+ this.handleInputChange("password", value);
476
+ }}
426
477
  ></consent-input>
427
478
  </div>
428
479
 
@@ -447,15 +498,15 @@ let McpConsent = class McpConsent extends LitElement {
447
498
  }
448
499
  renderOAuth() {
449
500
  const oauth = this.resolved?.oauth;
450
- const provider = oauth?.providerId ?? 'oauth';
451
- const providerName = oauth?.providerName ?? 'OAuth Provider';
501
+ const provider = oauth?.providerId ?? "oauth";
502
+ const providerName = oauth?.providerName ?? "OAuth Provider";
452
503
  return html `
453
504
  <consent-shell
454
- page-title=${this.resolved?.ui.title ?? 'Sign In'}
455
- company-name=${this.resolved?.branding.companyName ?? ''}
456
- logo-url=${this.resolved?.branding.logoUrl ?? ''}
457
- primary-color=${this.resolved?.branding.primaryColor ?? '#2563eb'}
458
- secondary-color=${this.resolved?.branding.secondaryColor ?? '#dbeafe'}
505
+ page-title=${this.resolved?.ui.title ?? "Sign In"}
506
+ company-name=${this.resolved?.branding.companyName ?? ""}
507
+ logo-url=${this.resolved?.branding.logoUrl ?? ""}
508
+ primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
509
+ secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
459
510
  >
460
511
  <div slot="content">
461
512
  ${this.renderError()} ${this.renderAgentInfo()}
@@ -482,11 +533,11 @@ let McpConsent = class McpConsent extends LitElement {
482
533
  const ml = this.resolved?.magicLink;
483
534
  return html `
484
535
  <consent-shell
485
- page-title=${this.resolved?.ui.title ?? 'Sign In'}
486
- company-name=${this.resolved?.branding.companyName ?? ''}
487
- logo-url=${this.resolved?.branding.logoUrl ?? ''}
488
- primary-color=${this.resolved?.branding.primaryColor ?? '#2563eb'}
489
- secondary-color=${this.resolved?.branding.secondaryColor ?? '#dbeafe'}
536
+ page-title=${this.resolved?.ui.title ?? "Sign In"}
537
+ company-name=${this.resolved?.branding.companyName ?? ""}
538
+ logo-url=${this.resolved?.branding.logoUrl ?? ""}
539
+ primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
540
+ secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
490
541
  >
491
542
  <div slot="content">
492
543
  ${this.renderError()} ${this.renderAgentInfo()}
@@ -495,11 +546,18 @@ let McpConsent = class McpConsent extends LitElement {
495
546
  <consent-input
496
547
  type="email"
497
548
  name="email"
498
- label=${ml?.emailLabel ?? 'Email'}
499
- placeholder=${ml?.emailPlaceholder ?? 'Enter your email address'}
549
+ label=${ml?.emailLabel ?? "Email"}
550
+ placeholder=${ml?.emailPlaceholder ?? "Enter your email address"}
500
551
  autocomplete="email"
501
552
  required
502
- @input=${(e) => this.handleInputChange('email', e.detail.value)}
553
+ @input=${(e) => {
554
+ // Handle both CustomEvent (from consent-input) and native InputEvent
555
+ const customEvent = e;
556
+ const value = customEvent.detail?.value ??
557
+ e.target?.value ??
558
+ "";
559
+ this.handleInputChange("email", value);
560
+ }}
503
561
  ></consent-input>
504
562
  </div>
505
563
 
@@ -517,7 +575,7 @@ let McpConsent = class McpConsent extends LitElement {
517
575
  ?disabled=${this.resolved?.terms.required && !this.termsAccepted}
518
576
  @click=${this.handleApprove}
519
577
  >
520
- ${ml?.buttonText ?? 'Send magic link'}
578
+ ${ml?.buttonText ?? "Send magic link"}
521
579
  </consent-button>
522
580
  </div>
523
581
  </consent-shell>
@@ -527,28 +585,35 @@ let McpConsent = class McpConsent extends LitElement {
527
585
  const otp = this.resolved?.otp;
528
586
  return html `
529
587
  <consent-shell
530
- page-title=${this.resolved?.ui.title ?? 'Verify Code'}
531
- company-name=${this.resolved?.branding.companyName ?? ''}
532
- logo-url=${this.resolved?.branding.logoUrl ?? ''}
533
- primary-color=${this.resolved?.branding.primaryColor ?? '#2563eb'}
534
- secondary-color=${this.resolved?.branding.secondaryColor ?? '#dbeafe'}
588
+ page-title=${this.resolved?.ui.title ?? "Verify Code"}
589
+ company-name=${this.resolved?.branding.companyName ?? ""}
590
+ logo-url=${this.resolved?.branding.logoUrl ?? ""}
591
+ primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
592
+ secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
535
593
  >
536
594
  <div slot="content">
537
595
  ${this.renderError()} ${this.renderAgentInfo()}
538
596
 
539
597
  <div class="otp-section">
540
598
  <p class="otp-instructions">
541
- ${otp?.instructions ?? 'Enter the verification code sent to your device'}
599
+ ${otp?.instructions ??
600
+ "Enter the verification code sent to your device"}
542
601
  </p>
543
602
  <consent-otp-input
544
603
  length=${otp?.digits ?? 6}
545
604
  name="otp"
546
605
  auto-focus
547
606
  @complete=${(e) => {
548
- this.handleInputChange('otp', e.detail.value);
607
+ const customEvent = e;
608
+ const value = customEvent.detail?.value ?? "";
609
+ this.handleInputChange("otp", value);
549
610
  this.handleApprove();
550
611
  }}
551
- @input=${(e) => this.handleInputChange('otp', e.detail.value)}
612
+ @input=${(e) => {
613
+ const customEvent = e;
614
+ const value = customEvent.detail?.value ?? "";
615
+ this.handleInputChange("otp", value);
616
+ }}
552
617
  ></consent-otp-input>
553
618
  <div class="otp-resend">
554
619
  Didn't receive the code?
@@ -559,7 +624,7 @@ let McpConsent = class McpConsent extends LitElement {
559
624
  >
560
625
  ${this.resendCooldown > 0
561
626
  ? `Resend in ${this.resendCooldown}s`
562
- : 'Resend'}
627
+ : "Resend"}
563
628
  </button>
564
629
  </div>
565
630
  </div>
@@ -574,11 +639,11 @@ let McpConsent = class McpConsent extends LitElement {
574
639
  const success = this.resolved?.success;
575
640
  return html `
576
641
  <consent-shell
577
- page-title=${success?.title ?? 'Access Granted'}
578
- company-name=${this.resolved?.branding.companyName ?? ''}
579
- logo-url=${this.resolved?.branding.logoUrl ?? ''}
580
- primary-color=${this.resolved?.branding.primaryColor ?? '#2563eb'}
581
- secondary-color=${this.resolved?.branding.secondaryColor ?? '#dbeafe'}
642
+ page-title=${success?.title ?? "Access Granted"}
643
+ company-name=${this.resolved?.branding.companyName ?? ""}
644
+ logo-url=${this.resolved?.branding.logoUrl ?? ""}
645
+ primary-color=${this.resolved?.branding.primaryColor ?? "#2563eb"}
646
+ secondary-color=${this.resolved?.branding.secondaryColor ?? "#dbeafe"}
582
647
  >
583
648
  <div slot="content">
584
649
  <div class="success-view">
@@ -593,10 +658,10 @@ let McpConsent = class McpConsent extends LitElement {
593
658
  <polyline points="20 6 9 17 4 12" />
594
659
  </svg>
595
660
  </div>
596
- <h2 class="success-title">${success?.title ?? 'Access Granted'}</h2>
661
+ <h2 class="success-title">${success?.title ?? "Access Granted"}</h2>
597
662
  <p class="success-description">
598
663
  ${success?.description ??
599
- 'You have successfully granted access. You can now close this window.'}
664
+ "You have successfully granted access. You can now close this window."}
600
665
  </p>
601
666
  </div>
602
667
  </div>
@@ -607,7 +672,7 @@ let McpConsent = class McpConsent extends LitElement {
607
672
  full-width
608
673
  @click=${() => window.close()}
609
674
  >
610
- ${success?.continueButtonText ?? 'Close'}
675
+ ${success?.continueButtonText ?? "Close"}
611
676
  </consent-button>
612
677
  </div>
613
678
  </consent-shell>
@@ -615,7 +680,7 @@ let McpConsent = class McpConsent extends LitElement {
615
680
  }
616
681
  // === MAIN RENDER ===
617
682
  render() {
618
- if (this.step === 'success') {
683
+ if (this.step === "success") {
619
684
  return this.renderSuccess();
620
685
  }
621
686
  switch (this.currentMode) {
@@ -637,8 +702,9 @@ McpConsent.styles = css `
637
702
  :host {
638
703
  display: block;
639
704
  /* System font stack with font smoothing for crisp text */
640
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
641
- 'Helvetica Neue', Arial, sans-serif;
705
+ font-family:
706
+ -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
707
+ Arial, sans-serif;
642
708
  -webkit-font-smoothing: antialiased;
643
709
  -moz-osx-font-smoothing: grayscale;
644
710
  --_primary: var(--consent-primary, #2563eb);
@@ -745,7 +811,7 @@ McpConsent.styles = css `
745
811
 
746
812
  .divider::before,
747
813
  .divider::after {
748
- content: '';
814
+ content: "";
749
815
  flex: 1;
750
816
  height: 1px;
751
817
  background: #e5e7eb;
@@ -832,7 +898,7 @@ __decorate([
832
898
  }
833
899
  },
834
900
  toAttribute: (value) => {
835
- return value ? JSON.stringify(value) : '';
901
+ return value ? JSON.stringify(value) : "";
836
902
  },
837
903
  },
838
904
  })
@@ -864,27 +930,36 @@ __decorate([
864
930
  })
865
931
  ], McpConsent.prototype, "scopes", void 0);
866
932
  __decorate([
867
- property({ type: String, attribute: 'agent-did' })
933
+ property({ type: String, attribute: "agent-did" })
868
934
  ], McpConsent.prototype, "agentDid", void 0);
869
935
  __decorate([
870
- property({ type: String, attribute: 'session-id' })
936
+ property({ type: String, attribute: "session-id" })
871
937
  ], McpConsent.prototype, "sessionId", void 0);
872
938
  __decorate([
873
- property({ type: String, attribute: 'project-id' })
939
+ property({ type: String, attribute: "project-id" })
874
940
  ], McpConsent.prototype, "projectId", void 0);
875
941
  __decorate([
876
- property({ type: String, attribute: 'server-url' })
942
+ property({ type: String, attribute: "server-url" })
877
943
  ], McpConsent.prototype, "serverUrl", void 0);
878
944
  __decorate([
879
- property({ type: String, attribute: 'agent-name' })
945
+ property({ type: String, attribute: "agent-name" })
880
946
  ], McpConsent.prototype, "agentName", void 0);
881
947
  __decorate([
882
- property({ type: String, attribute: 'provider' })
948
+ property({ type: String, attribute: "provider" })
883
949
  ], McpConsent.prototype, "provider", void 0);
950
+ __decorate([
951
+ property({ type: String, attribute: "csrf-token" })
952
+ ], McpConsent.prototype, "csrfToken", void 0);
953
+ __decorate([
954
+ property({ type: String, attribute: "credential-provider-type" })
955
+ ], McpConsent.prototype, "credentialProviderType", void 0);
956
+ __decorate([
957
+ property({ type: String, attribute: "credential-provider" })
958
+ ], McpConsent.prototype, "credentialProvider", void 0);
884
959
  __decorate([
885
960
  property({
886
961
  type: Object,
887
- attribute: 'oauth-identity',
962
+ attribute: "oauth-identity",
888
963
  converter: {
889
964
  fromAttribute: (value) => {
890
965
  if (!value)
@@ -897,7 +972,7 @@ __decorate([
897
972
  }
898
973
  },
899
974
  toAttribute: (value) => {
900
- return value ? JSON.stringify(value) : '';
975
+ return value ? JSON.stringify(value) : "";
901
976
  },
902
977
  },
903
978
  })
@@ -930,7 +1005,7 @@ __decorate([
930
1005
  state()
931
1006
  ], McpConsent.prototype, "selectedScopes", void 0);
932
1007
  McpConsent = __decorate([
933
- customElement('mcp-consent')
1008
+ customElement("mcp-consent")
934
1009
  ], McpConsent);
935
1010
  export { McpConsent };
936
1011
  //# sourceMappingURL=mcp-consent.js.map