@kya-os/mcp-i-cloudflare 1.6.62 → 1.7.0

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 (83) hide show
  1. package/dist/agent.d.ts +4 -2
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +121 -94
  4. package/dist/agent.js.map +1 -1
  5. package/dist/app.d.ts.map +1 -1
  6. package/dist/app.js +9 -95
  7. package/dist/app.js.map +1 -1
  8. package/dist/services/consent-config.service.d.ts +9 -3
  9. package/dist/services/consent-config.service.d.ts.map +1 -1
  10. package/dist/services/consent-config.service.js +90 -100
  11. package/dist/services/consent-config.service.js.map +1 -1
  12. package/dist/services/consent-page-renderer.d.ts.map +1 -1
  13. package/dist/services/consent-page-renderer.js +0 -5
  14. package/dist/services/consent-page-renderer.js.map +1 -1
  15. package/dist/services/consent-templates/base/base-template.d.ts +79 -0
  16. package/dist/services/consent-templates/base/base-template.d.ts.map +1 -0
  17. package/dist/services/consent-templates/base/base-template.js +283 -0
  18. package/dist/services/consent-templates/base/base-template.js.map +1 -0
  19. package/dist/services/consent-templates/base/components.d.ts +120 -0
  20. package/dist/services/consent-templates/base/components.d.ts.map +1 -0
  21. package/dist/services/consent-templates/base/components.js +278 -0
  22. package/dist/services/consent-templates/base/components.js.map +1 -0
  23. package/dist/services/consent-templates/base/escape.d.ts +53 -0
  24. package/dist/services/consent-templates/base/escape.d.ts.map +1 -0
  25. package/dist/services/consent-templates/base/escape.js +115 -0
  26. package/dist/services/consent-templates/base/escape.js.map +1 -0
  27. package/dist/services/consent-templates/base/index.d.ts +10 -0
  28. package/dist/services/consent-templates/base/index.d.ts.map +1 -0
  29. package/dist/services/consent-templates/base/index.js +10 -0
  30. package/dist/services/consent-templates/base/index.js.map +1 -0
  31. package/dist/services/consent-templates/base/styles.d.ts +80 -0
  32. package/dist/services/consent-templates/base/styles.d.ts.map +1 -0
  33. package/dist/services/consent-templates/base/styles.js +226 -0
  34. package/dist/services/consent-templates/base/styles.js.map +1 -0
  35. package/dist/services/consent-templates/helpers.d.ts +60 -0
  36. package/dist/services/consent-templates/helpers.d.ts.map +1 -0
  37. package/dist/services/consent-templates/helpers.js +121 -0
  38. package/dist/services/consent-templates/helpers.js.map +1 -0
  39. package/dist/services/consent-templates/index.d.ts +28 -0
  40. package/dist/services/consent-templates/index.d.ts.map +1 -0
  41. package/dist/services/consent-templates/index.js +36 -0
  42. package/dist/services/consent-templates/index.js.map +1 -0
  43. package/dist/services/consent-templates/modes/consent-only.template.d.ts +36 -0
  44. package/dist/services/consent-templates/modes/consent-only.template.d.ts.map +1 -0
  45. package/dist/services/consent-templates/modes/consent-only.template.js +69 -0
  46. package/dist/services/consent-templates/modes/consent-only.template.js.map +1 -0
  47. package/dist/services/consent-templates/modes/credentials.template.d.ts +59 -0
  48. package/dist/services/consent-templates/modes/credentials.template.d.ts.map +1 -0
  49. package/dist/services/consent-templates/modes/credentials.template.js +393 -0
  50. package/dist/services/consent-templates/modes/credentials.template.js.map +1 -0
  51. package/dist/services/consent-templates/modes/index.d.ts +13 -0
  52. package/dist/services/consent-templates/modes/index.d.ts.map +1 -0
  53. package/dist/services/consent-templates/modes/index.js +13 -0
  54. package/dist/services/consent-templates/modes/index.js.map +1 -0
  55. package/dist/services/consent-templates/modes/magic-link.template.d.ts +33 -0
  56. package/dist/services/consent-templates/modes/magic-link.template.d.ts.map +1 -0
  57. package/dist/services/consent-templates/modes/magic-link.template.js +191 -0
  58. package/dist/services/consent-templates/modes/magic-link.template.js.map +1 -0
  59. package/dist/services/consent-templates/modes/oauth.template.d.ts +40 -0
  60. package/dist/services/consent-templates/modes/oauth.template.d.ts.map +1 -0
  61. package/dist/services/consent-templates/modes/oauth.template.js +151 -0
  62. package/dist/services/consent-templates/modes/oauth.template.js.map +1 -0
  63. package/dist/services/consent-templates/modes/otp.template.d.ts +35 -0
  64. package/dist/services/consent-templates/modes/otp.template.d.ts.map +1 -0
  65. package/dist/services/consent-templates/modes/otp.template.js +311 -0
  66. package/dist/services/consent-templates/modes/otp.template.js.map +1 -0
  67. package/dist/services/consent-templates/registry.d.ts +61 -0
  68. package/dist/services/consent-templates/registry.d.ts.map +1 -0
  69. package/dist/services/consent-templates/registry.js +136 -0
  70. package/dist/services/consent-templates/registry.js.map +1 -0
  71. package/dist/services/consent-templates/template-renderer.d.ts +118 -0
  72. package/dist/services/consent-templates/template-renderer.d.ts.map +1 -0
  73. package/dist/services/consent-templates/template-renderer.js +334 -0
  74. package/dist/services/consent-templates/template-renderer.js.map +1 -0
  75. package/dist/services/consent-templates/types.d.ts +194 -0
  76. package/dist/services/consent-templates/types.d.ts.map +1 -0
  77. package/dist/services/consent-templates/types.js +23 -0
  78. package/dist/services/consent-templates/types.js.map +1 -0
  79. package/dist/services/consent.service.d.ts +9 -0
  80. package/dist/services/consent.service.d.ts.map +1 -1
  81. package/dist/services/consent.service.js +50 -6
  82. package/dist/services/consent.service.js.map +1 -1
  83. package/package.json +4 -3
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Magic Link Template
3
+ *
4
+ * Passwordless authentication via email link.
5
+ *
6
+ * @module consent-templates/modes/magic-link
7
+ */
8
+ import { BaseConsentTemplate } from "../base/base-template";
9
+ import { renderInput, renderFullWidthButton, renderErrorContainer, } from "../base/components";
10
+ import { escapeJs } from "../base/escape";
11
+ /**
12
+ * Magic Link Template
13
+ *
14
+ * Renders an email-based passwordless login:
15
+ * - Email input field
16
+ * - Submit button
17
+ * - Success/waiting state
18
+ * - Resend link functionality
19
+ */
20
+ export class MagicLinkTemplate extends BaseConsentTemplate {
21
+ get authMode() {
22
+ return "magic-link";
23
+ }
24
+ get magicLinkConfig() {
25
+ return this.config.modeConfig?.magicLink;
26
+ }
27
+ renderAuthContent() {
28
+ const config = this.magicLinkConfig;
29
+ return `
30
+ <div id="magic-link-form-container">
31
+ <form id="magic-link-form" class="space-y-4">
32
+ ${this.renderEmailField(config)}
33
+ ${renderErrorContainer()}
34
+ ${renderFullWidthButton(config?.buttonText || "Send Magic Link", "submit")}
35
+ </form>
36
+ </div>
37
+ <div id="magic-link-sent" class="hidden text-center py-4 space-y-4">
38
+ <div class="w-16 h-16 mx-auto rounded-full bg-green-100 flex items-center justify-center">
39
+ <svg class="w-8 h-8 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
40
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
41
+ </svg>
42
+ </div>
43
+ <h3 class="text-lg font-semibold text-gray-900">Check your email</h3>
44
+ <p class="text-sm text-gray-600">
45
+ We've sent a magic link to <span id="sent-email" class="font-medium"></span>.<br/>
46
+ Click the link to continue.
47
+ </p>
48
+ <button type="button" id="resend-btn" class="text-sm link-primary mt-4 disabled:opacity-50">
49
+ Resend link
50
+ </button>
51
+ </div>
52
+ `;
53
+ }
54
+ /**
55
+ * Render email input field.
56
+ */
57
+ renderEmailField(config) {
58
+ return renderInput("email", "email", config?.emailLabel || "Email address", config?.emailPlaceholder || "Enter your email", true, "email");
59
+ }
60
+ /**
61
+ * Override action buttons - form has its own submit.
62
+ */
63
+ renderActionButtons() {
64
+ return "";
65
+ }
66
+ renderModeScript() {
67
+ const serverUrl = escapeJs(this.config.serverUrl);
68
+ const projectId = escapeJs(this.config.projectId);
69
+ const sessionId = escapeJs(this.config.sessionId);
70
+ const agentDid = escapeJs(this.config.agentDid);
71
+ const tool = escapeJs(this.config.tool);
72
+ const scopes = JSON.stringify(this.config.scopes);
73
+ const resendCooldown = this.magicLinkConfig?.resendCooldown || 60;
74
+ return `
75
+ <script>
76
+ (function() {
77
+ const form = document.getElementById('magic-link-form');
78
+ const formContainer = document.getElementById('magic-link-form-container');
79
+ const sentContainer = document.getElementById('magic-link-sent');
80
+ const sentEmail = document.getElementById('sent-email');
81
+ const resendBtn = document.getElementById('resend-btn');
82
+ const errorContainer = document.getElementById('error-container');
83
+ const errorDiv = errorContainer?.querySelector('div');
84
+
85
+ if (!form) return;
86
+
87
+ const serverUrl = ${serverUrl};
88
+ const cooldown = ${resendCooldown};
89
+ let lastEmail = '';
90
+ let resendTimer = null;
91
+
92
+ async function sendMagicLink(email) {
93
+ const data = {
94
+ provider_type: 'magic_link',
95
+ email: email,
96
+ tool: ${tool},
97
+ scopes: ${scopes},
98
+ agent_did: ${agentDid},
99
+ session_id: ${sessionId},
100
+ project_id: ${projectId},
101
+ };
102
+
103
+ const response = await fetch(serverUrl + '/consent/magic-link', {
104
+ method: 'POST',
105
+ headers: { 'Content-Type': 'application/json' },
106
+ body: JSON.stringify(data)
107
+ });
108
+
109
+ return response.json();
110
+ }
111
+
112
+ function showSent(email) {
113
+ formContainer.classList.add('hidden');
114
+ sentContainer.classList.remove('hidden');
115
+ sentEmail.textContent = email;
116
+
117
+ // Start cooldown
118
+ resendBtn.disabled = true;
119
+ let remaining = cooldown;
120
+ resendBtn.textContent = 'Resend link (' + remaining + 's)';
121
+
122
+ resendTimer = setInterval(() => {
123
+ remaining--;
124
+ if (remaining <= 0) {
125
+ clearInterval(resendTimer);
126
+ resendBtn.disabled = false;
127
+ resendBtn.textContent = 'Resend link';
128
+ } else {
129
+ resendBtn.textContent = 'Resend link (' + remaining + 's)';
130
+ }
131
+ }, 1000);
132
+ }
133
+
134
+ function showError(message) {
135
+ if (errorDiv) {
136
+ errorDiv.textContent = message;
137
+ errorContainer.classList.remove('hidden');
138
+ }
139
+ }
140
+
141
+ form.addEventListener('submit', async function(e) {
142
+ e.preventDefault();
143
+
144
+ const button = form.querySelector('button[type="submit"]');
145
+ const originalText = button.textContent;
146
+ const emailInput = form.querySelector('input[name="email"]');
147
+ lastEmail = emailInput.value;
148
+
149
+ if (errorContainer) errorContainer.classList.add('hidden');
150
+ button.disabled = true;
151
+ button.textContent = 'Sending...';
152
+
153
+ try {
154
+ const result = await sendMagicLink(lastEmail);
155
+
156
+ if (result.success) {
157
+ showSent(lastEmail);
158
+ } else {
159
+ showError(result.error || 'Failed to send magic link');
160
+ button.disabled = false;
161
+ button.textContent = originalText;
162
+ }
163
+ } catch (err) {
164
+ showError('Network error. Please try again.');
165
+ button.disabled = false;
166
+ button.textContent = originalText;
167
+ }
168
+ });
169
+
170
+ resendBtn?.addEventListener('click', async function() {
171
+ if (!lastEmail || resendBtn.disabled) return;
172
+
173
+ resendBtn.disabled = true;
174
+ try {
175
+ const result = await sendMagicLink(lastEmail);
176
+ if (result.success) {
177
+ showSent(lastEmail);
178
+ } else {
179
+ alert(result.error || 'Failed to resend');
180
+ resendBtn.disabled = false;
181
+ }
182
+ } catch (err) {
183
+ alert('Network error');
184
+ resendBtn.disabled = false;
185
+ }
186
+ });
187
+ })();
188
+ </script>`;
189
+ }
190
+ }
191
+ //# sourceMappingURL=magic-link.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"magic-link.template.js","sourceRoot":"","sources":["../../../../src/services/consent-templates/modes/magic-link.template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAkB,SAAQ,mBAAmB;IACxD,IAAI,QAAQ;QACV,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAY,eAAe;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC;IAC3C,CAAC;IAED,iBAAiB;QACf,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC;QAEpC,OAAO;;;YAGC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;YAC7B,oBAAoB,EAAE;YACtB,qBAAqB,CAAC,MAAM,EAAE,UAAU,IA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+ * OAuth redirect flow with provider branding.
5
+ *
6
+ * @module consent-templates/modes/oauth
7
+ */
8
+ import { BaseConsentTemplate } from "../base/base-template";
9
+ import type { AuthMode } from "../types";
10
+ /**
11
+ * OAuth Template
12
+ *
13
+ * Renders an OAuth consent page with:
14
+ * - Permission list
15
+ * - Expiration notice
16
+ * - Provider-branded continue button
17
+ */
18
+ export declare class OAuthTemplate extends BaseConsentTemplate {
19
+ private oauthUrl?;
20
+ get authMode(): AuthMode;
21
+ /**
22
+ * Set the OAuth authorization URL.
23
+ */
24
+ setOAuthUrl(url: string): void;
25
+ private get oauthConfig();
26
+ renderAuthContent(): string;
27
+ /**
28
+ * Render permissions as a simple list.
29
+ */
30
+ private renderPermissionsList;
31
+ /**
32
+ * Render expiration notice.
33
+ */
34
+ private renderExpirationNotice;
35
+ /**
36
+ * Override action buttons to show OAuth provider button.
37
+ */
38
+ protected renderActionButtons(): string;
39
+ }
40
+ //# sourceMappingURL=oauth.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.template.d.ts","sourceRoot":"","sources":["../../../../src/services/consent-templates/modes/oauth.template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAI5D,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,UAAU,CAAC;AAoCtD;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,mBAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,CAAS;IAE1B,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI9B,OAAO,KAAK,WAAW,GAEtB;IAED,iBAAiB,IAAI,MAAM;IAkB3B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAgB7B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAM9B;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,MAAM;CAgDxC"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * OAuth Template
3
+ *
4
+ * OAuth redirect flow with provider branding.
5
+ *
6
+ * @module consent-templates/modes/oauth
7
+ */
8
+ import { BaseConsentTemplate } from "../base/base-template";
9
+ import { renderExpirationNotice } from "../base/components";
10
+ import { CONSENT_CLASSES } from "../base/styles";
11
+ import { escapeHtml, escapeAttr, validateUrl } from "../base/escape";
12
+ /**
13
+ * OAuth provider branding information.
14
+ */
15
+ const PROVIDER_BRANDING = {
16
+ github: {
17
+ color: "#24292e",
18
+ name: "GitHub",
19
+ icon: `<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>`,
20
+ },
21
+ google: {
22
+ color: "#4285f4",
23
+ name: "Google",
24
+ icon: `<svg class="w-5 h-5" viewBox="0 0 24 24"><path fill="currentColor" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/><path fill="currentColor" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/><path fill="currentColor" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/><path fill="currentColor" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/></svg>`,
25
+ },
26
+ microsoft: {
27
+ color: "#0078d4",
28
+ name: "Microsoft",
29
+ icon: `<svg class="w-5 h-5" viewBox="0 0 24 24"><path fill="#f35325" d="M1 1h10v10H1z"/><path fill="#81bc06" d="M13 1h10v10H13z"/><path fill="#05a6f0" d="M1 13h10v10H1z"/><path fill="#ffba08" d="M13 13h10v10H13z"/></svg>`,
30
+ },
31
+ slack: {
32
+ color: "#4a154b",
33
+ name: "Slack",
34
+ icon: `<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24"><path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"/></svg>`,
35
+ },
36
+ auth0: {
37
+ color: "#eb5424",
38
+ name: "Auth0",
39
+ icon: `<svg class="w-5 h-5" viewBox="0 0 24 24" fill="currentColor"><path d="M21.98 7.448L19.62 0H4.347L2.02 7.448c-1.352 4.312.03 9.206 3.815 12.015L12.007 24l6.157-4.552c3.755-2.81 5.182-7.688 3.815-12.015l-6.16 4.58 2.343 7.45-6.157-4.597-6.158 4.58 2.358-7.433-6.188-4.55 7.63-.045L12.008 0l2.356 7.404 7.615.044z"/></svg>`,
40
+ },
41
+ };
42
+ /**
43
+ * OAuth Template
44
+ *
45
+ * Renders an OAuth consent page with:
46
+ * - Permission list
47
+ * - Expiration notice
48
+ * - Provider-branded continue button
49
+ */
50
+ export class OAuthTemplate extends BaseConsentTemplate {
51
+ oauthUrl;
52
+ get authMode() {
53
+ return "oauth";
54
+ }
55
+ /**
56
+ * Set the OAuth authorization URL.
57
+ */
58
+ setOAuthUrl(url) {
59
+ this.oauthUrl = url;
60
+ }
61
+ get oauthConfig() {
62
+ return this.config.modeConfig?.oauth;
63
+ }
64
+ renderAuthContent() {
65
+ const config = this.oauthConfig;
66
+ const providerId = config?.providerId || this.config.provider || "oauth";
67
+ const branding = PROVIDER_BRANDING[providerId.toLowerCase()];
68
+ return `
69
+ <div class="space-y-4">
70
+ ${this.renderPermissionsList()}
71
+ <div class="pt-2">
72
+ <p class="text-sm text-gray-600">
73
+ You will be redirected to ${escapeHtml(branding?.name || config?.providerName || "the identity provider")} to authenticate.
74
+ </p>
75
+ </div>
76
+ ${this.renderExpirationNotice()}
77
+ </div>
78
+ `;
79
+ }
80
+ /**
81
+ * Render permissions as a simple list.
82
+ */
83
+ renderPermissionsList() {
84
+ const { scopes } = this.config;
85
+ if (scopes.length === 0)
86
+ return "";
87
+ const items = scopes.map((s) => `<li>${escapeHtml(s)}</li>`).join("");
88
+ return `
89
+ <div class="space-y-2">
90
+ <p class="text-sm font-medium text-gray-700">Requested permissions:</p>
91
+ <ul class="list-disc list-inside text-sm text-gray-600 space-y-1">
92
+ ${items}
93
+ </ul>
94
+ </div>
95
+ `;
96
+ }
97
+ /**
98
+ * Render expiration notice.
99
+ */
100
+ renderExpirationNotice() {
101
+ const { copy } = this.resolved;
102
+ const expirationDays = this.config.expirationDays || 30;
103
+ return renderExpirationNotice(copy.expirationText, expirationDays);
104
+ }
105
+ /**
106
+ * Override action buttons to show OAuth provider button.
107
+ */
108
+ renderActionButtons() {
109
+ const config = this.oauthConfig;
110
+ const providerId = config?.providerId || this.config.provider || "oauth";
111
+ const branding = PROVIDER_BRANDING[providerId.toLowerCase()];
112
+ const buttonText = config?.buttonText ||
113
+ `Continue with ${branding?.name || config?.providerName || "Provider"}`;
114
+ const { copy } = this.resolved;
115
+ // If OAuth URL is set, use a direct link
116
+ const rawOauthUrl = this.oauthUrl || this.config.oauthUrl;
117
+ // Validate URL to prevent javascript: and other dangerous protocols
118
+ const oauthUrl = rawOauthUrl ? validateUrl(rawOauthUrl) : undefined;
119
+ if (oauthUrl) {
120
+ const buttonStyle = branding
121
+ ? `style="background-color: ${branding.color}"`
122
+ : "";
123
+ return `
124
+ <div class="${CONSENT_CLASSES.buttonGroup}">
125
+ <button type="button" onclick="window.close()" class="${CONSENT_CLASSES.buttonSecondary}">
126
+ ${escapeHtml(copy.cancelButtonText)}
127
+ </button>
128
+ <a href="${escapeAttr(oauthUrl)}"
129
+ class="${CONSENT_CLASSES.buttonPrimary} btn-primary flex items-center justify-center gap-2"
130
+ ${buttonStyle}>
131
+ ${branding?.icon || ""}
132
+ ${escapeHtml(buttonText)}
133
+ </a>
134
+ </div>
135
+ `;
136
+ }
137
+ // Fallback to standard buttons
138
+ return `
139
+ <div class="${CONSENT_CLASSES.buttonGroup}">
140
+ <button type="button" onclick="window.close()" class="${CONSENT_CLASSES.buttonSecondary}">
141
+ ${escapeHtml(copy.cancelButtonText)}
142
+ </button>
143
+ <button type="submit" class="${CONSENT_CLASSES.buttonPrimary} btn-primary flex items-center justify-center gap-2">
144
+ ${branding?.icon || ""}
145
+ ${escapeHtml(buttonText)}
146
+ </button>
147
+ </div>
148
+ `;
149
+ }
150
+ }
151
+ //# sourceMappingURL=oauth.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.template.js","sourceRoot":"","sources":["../../../../src/services/consent-templates/modes/oauth.template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGrE;;GAEG;AACH,MAAM,iBAAiB,GAGnB;IACF,MAAM,EAAE;QACN,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,0xBAA0xB;KACjyB;IACD,MAAM,EAAE;QACN,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,6qBAA6qB;KACprB;IACD,SAAS,EAAE;QACT,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,uNAAuN;KAC9N;IACD,KAAK,EAAE;QACL,KAAK,EAAE,SAAS;QACh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AAe,CAAC,aAAa;eACpC,WAAW;cACZ,QAAQ,EAAE,IAAI,IAAI,EAAE;cACpB,UAAU,CAAC,UAAU,CAAC;;;OAG7B,CAAC;QACJ,CAAC;QAED,+BAA+B;QAC/B,OAAO;oBACS,eAAe,CAAC,WAAW;gEACiB,eAAe,CAAC,eAAe;YACnF,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC;;uCAEN,eAAe,CAAC,aAAa;YACxD,QAAQ,EAAE,IAAI,IAAI,EAAE;YACpB,UAAU,CAAC,UAAU,CAAC;;;KAG7B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * OTP Template
3
+ *
4
+ * One-Time Password authentication via SMS/email.
5
+ *
6
+ * @module consent-templates/modes/otp
7
+ */
8
+ import { BaseConsentTemplate } from "../base/base-template";
9
+ import type { AuthMode } from "../types";
10
+ /**
11
+ * OTP Template
12
+ *
13
+ * Renders a two-step OTP flow:
14
+ * 1. Phone/email input to request code
15
+ * 2. Code input to verify
16
+ */
17
+ export declare class OTPTemplate extends BaseConsentTemplate {
18
+ get authMode(): AuthMode;
19
+ private get otpConfig();
20
+ renderAuthContent(): string;
21
+ /**
22
+ * Render phone/email input field.
23
+ */
24
+ private renderPhoneField;
25
+ /**
26
+ * Render OTP digit input boxes.
27
+ */
28
+ private renderOTPInputs;
29
+ /**
30
+ * Override action buttons - form has its own submit.
31
+ */
32
+ protected renderActionButtons(): string;
33
+ protected renderModeScript(): string;
34
+ }
35
+ //# sourceMappingURL=otp.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otp.template.d.ts","sourceRoot":"","sources":["../../../../src/services/consent-templates/modes/otp.template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAO5D,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,UAAU,CAAC;AAEpD;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,mBAAmB;IAClD,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED,OAAO,KAAK,SAAS,GAEpB;IAED,iBAAiB,IAAI,MAAM;IAkC3B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,MAAM;IAIvC,SAAS,CAAC,gBAAgB,IAAI,MAAM;CAmOrC"}