@authhero/widget 0.2.2 → 0.4.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 (59) hide show
  1. package/dist/authhero-widget/authhero-widget.esm.js +1 -0
  2. package/dist/authhero-widget/index.esm.js +1 -0
  3. package/dist/authhero-widget/p-2e93c814.entry.js +1 -0
  4. package/dist/authhero-widget/p-539fc666.entry.js +1 -0
  5. package/dist/authhero-widget/p-DQuL1Twl.js +1 -0
  6. package/dist/authhero-widget/p-Doiemx6o.js +2 -0
  7. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  8. package/dist/cjs/authhero-node.cjs.entry.js +255 -0
  9. package/dist/cjs/authhero-widget.cjs.entry.js +577 -0
  10. package/dist/cjs/authhero-widget.cjs.js +25 -0
  11. package/dist/cjs/index-D0xitTOL.js +3788 -0
  12. package/dist/cjs/index.cjs.js +8123 -0
  13. package/dist/cjs/loader.cjs.js +13 -0
  14. package/dist/collection/collection-manifest.json +13 -0
  15. package/dist/collection/components/authhero-node/authhero-node.css +298 -0
  16. package/dist/collection/components/authhero-node/authhero-node.js +360 -0
  17. package/dist/collection/components/authhero-widget/authhero-widget.css +186 -0
  18. package/dist/collection/components/authhero-widget/authhero-widget.js +628 -0
  19. package/dist/collection/index.js +2 -0
  20. package/dist/collection/server/index.js +453 -0
  21. package/dist/collection/themes/index.js +71 -0
  22. package/dist/collection/types/components.js +8 -0
  23. package/dist/collection/utils/branding.js +248 -0
  24. package/dist/components/authhero-node.d.ts +11 -0
  25. package/dist/components/authhero-node.js +1 -0
  26. package/dist/components/authhero-widget.d.ts +11 -0
  27. package/dist/components/authhero-widget.js +1 -0
  28. package/dist/components/index.d.ts +35 -0
  29. package/dist/components/index.js +1 -0
  30. package/dist/components/p-086EZrPM.js +1 -0
  31. package/dist/components/p-DS6y_iDJ.js +1 -0
  32. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  33. package/dist/esm/authhero-node.entry.js +253 -0
  34. package/dist/esm/authhero-widget.entry.js +575 -0
  35. package/dist/esm/authhero-widget.js +21 -0
  36. package/dist/esm/index-Doiemx6o.js +3780 -0
  37. package/dist/esm/index.js +8122 -0
  38. package/dist/esm/loader.js +11 -0
  39. package/dist/index.cjs.js +1 -0
  40. package/dist/index.js +1 -0
  41. package/dist/types/components/authhero-node/authhero-node.d.ts +72 -0
  42. package/dist/types/components/authhero-widget/authhero-widget.d.ts +172 -0
  43. package/dist/types/components.d.ts +215 -0
  44. package/dist/types/index.d.ts +1 -0
  45. package/dist/types/server/index.d.ts +85 -0
  46. package/dist/types/stencil-public-runtime.d.ts +1839 -0
  47. package/dist/types/themes/index.d.ts +40 -0
  48. package/dist/types/types/components.d.ts +8 -0
  49. package/dist/types/utils/branding.d.ts +119 -0
  50. package/hydrate/index.d.ts +287 -0
  51. package/hydrate/index.js +23729 -0
  52. package/hydrate/index.mjs +23719 -0
  53. package/hydrate/package.json +12 -0
  54. package/loader/cdn.js +1 -0
  55. package/loader/index.cjs.js +1 -0
  56. package/loader/index.d.ts +24 -0
  57. package/loader/index.es2017.js +1 -0
  58. package/loader/index.js +2 -0
  59. package/package.json +1 -1
@@ -0,0 +1,453 @@
1
+ /**
2
+ * Hono SSR Helper for AuthHero Widget
3
+ *
4
+ * This module provides utilities for server-side rendering
5
+ * the AuthHero widget in Hono applications.
6
+ */
7
+ /**
8
+ * Creates a basic login screen configuration using the new UiScreen format.
9
+ */
10
+ export function createLoginScreen(options) {
11
+ const components = [];
12
+ let order = 0;
13
+ // Email field
14
+ components.push({
15
+ id: "email",
16
+ category: "FIELD",
17
+ type: "EMAIL",
18
+ order: order++,
19
+ label: "Email address",
20
+ required: true,
21
+ visible: true,
22
+ config: {
23
+ placeholder: "you@example.com",
24
+ },
25
+ });
26
+ // Password field
27
+ components.push({
28
+ id: "password",
29
+ category: "FIELD",
30
+ type: "PASSWORD",
31
+ order: order++,
32
+ label: "Password",
33
+ required: true,
34
+ visible: true,
35
+ config: {
36
+ placeholder: "Enter your password",
37
+ },
38
+ });
39
+ // Submit button
40
+ components.push({
41
+ id: "submit",
42
+ category: "BLOCK",
43
+ type: "NEXT_BUTTON",
44
+ order: order++,
45
+ visible: true,
46
+ config: {
47
+ text: "Sign in",
48
+ },
49
+ });
50
+ // Add social providers if specified
51
+ if (options.showSocialProviders?.length) {
52
+ components.push({
53
+ id: "divider",
54
+ category: "BLOCK",
55
+ type: "DIVIDER",
56
+ order: order++,
57
+ visible: true,
58
+ });
59
+ components.push({
60
+ id: "social",
61
+ category: "FIELD",
62
+ type: "SOCIAL",
63
+ order: order++,
64
+ visible: true,
65
+ config: {
66
+ providers: options.showSocialProviders,
67
+ },
68
+ });
69
+ }
70
+ const links = [];
71
+ if (options.showForgotPassword !== false) {
72
+ links.push({
73
+ text: "Forgot your password?",
74
+ href: "/forgot-password",
75
+ });
76
+ }
77
+ if (options.showSignUp !== false) {
78
+ links.push({
79
+ text: "Don't have an account?",
80
+ href: "/signup",
81
+ linkText: "Sign up",
82
+ });
83
+ }
84
+ return {
85
+ title: options.title || "Sign in to your account",
86
+ action: options.action,
87
+ method: "POST",
88
+ components,
89
+ links,
90
+ };
91
+ }
92
+ /**
93
+ * Creates an identifier-first screen (email first, then password or social)
94
+ */
95
+ export function createIdentifierScreen(options) {
96
+ const components = [];
97
+ let order = 0;
98
+ // Add logo if provided
99
+ if (options.logoUrl) {
100
+ components.push({
101
+ id: "logo",
102
+ category: "BLOCK",
103
+ type: "IMAGE",
104
+ order: order++,
105
+ visible: true,
106
+ config: {
107
+ src: options.logoUrl,
108
+ alt: `${options.tenantName || "Company"} Logo`,
109
+ },
110
+ });
111
+ }
112
+ // Email input
113
+ components.push({
114
+ id: "email",
115
+ category: "FIELD",
116
+ type: "EMAIL",
117
+ order: order++,
118
+ label: "Email",
119
+ required: true,
120
+ visible: true,
121
+ config: {
122
+ placeholder: "Your email address",
123
+ },
124
+ });
125
+ // Continue button
126
+ components.push({
127
+ id: "submit",
128
+ category: "BLOCK",
129
+ type: "NEXT_BUTTON",
130
+ order: order++,
131
+ visible: true,
132
+ config: {
133
+ text: "Continue",
134
+ },
135
+ });
136
+ // Add social providers if specified
137
+ if (options.showSocialProviders?.length) {
138
+ components.push({
139
+ id: "divider",
140
+ category: "BLOCK",
141
+ type: "DIVIDER",
142
+ order: order++,
143
+ visible: true,
144
+ });
145
+ components.push({
146
+ id: "social",
147
+ category: "FIELD",
148
+ type: "SOCIAL",
149
+ order: order++,
150
+ visible: true,
151
+ config: {
152
+ providers: options.showSocialProviders,
153
+ },
154
+ });
155
+ }
156
+ const links = [];
157
+ if (options.showSignUp !== false) {
158
+ links.push({
159
+ text: "Don't have an account?",
160
+ href: options.signUpUrl || "/signup",
161
+ linkText: "Get started",
162
+ });
163
+ }
164
+ return {
165
+ title: options.title || `Sign in to ${options.tenantName || "your account"}`,
166
+ action: options.action,
167
+ method: "POST",
168
+ components,
169
+ links,
170
+ };
171
+ }
172
+ /**
173
+ * Creates a registration screen configuration
174
+ */
175
+ export function createSignupScreen(options) {
176
+ const defaultFields = [
177
+ { name: "email", type: "email", label: "Email address", required: true },
178
+ { name: "password", type: "password", label: "Password", required: true },
179
+ {
180
+ name: "password_confirm",
181
+ type: "password",
182
+ label: "Confirm password",
183
+ required: true,
184
+ },
185
+ ];
186
+ const fields = options.fields || defaultFields;
187
+ const components = [];
188
+ let order = 0;
189
+ // Map fields to components
190
+ fields.forEach((field) => {
191
+ const fieldType = field.type || "text";
192
+ if (fieldType === "email") {
193
+ components.push({
194
+ id: field.name,
195
+ category: "FIELD",
196
+ type: "EMAIL",
197
+ order: order++,
198
+ label: field.label,
199
+ required: field.required ?? true,
200
+ visible: true,
201
+ config: {
202
+ placeholder: field.placeholder,
203
+ },
204
+ });
205
+ }
206
+ else if (fieldType === "password") {
207
+ components.push({
208
+ id: field.name,
209
+ category: "FIELD",
210
+ type: "PASSWORD",
211
+ order: order++,
212
+ label: field.label,
213
+ required: field.required ?? true,
214
+ visible: true,
215
+ config: {
216
+ placeholder: field.placeholder,
217
+ },
218
+ });
219
+ }
220
+ else {
221
+ components.push({
222
+ id: field.name,
223
+ category: "FIELD",
224
+ type: "TEXT",
225
+ order: order++,
226
+ label: field.label,
227
+ required: field.required ?? true,
228
+ visible: true,
229
+ config: {
230
+ placeholder: field.placeholder,
231
+ },
232
+ });
233
+ }
234
+ });
235
+ // Submit button
236
+ components.push({
237
+ id: "submit",
238
+ category: "BLOCK",
239
+ type: "NEXT_BUTTON",
240
+ order: order++,
241
+ visible: true,
242
+ config: {
243
+ text: "Create account",
244
+ },
245
+ });
246
+ // Add social providers if specified
247
+ if (options.showSocialProviders?.length) {
248
+ components.push({
249
+ id: "divider",
250
+ category: "BLOCK",
251
+ type: "DIVIDER",
252
+ order: order++,
253
+ visible: true,
254
+ });
255
+ components.push({
256
+ id: "social",
257
+ category: "FIELD",
258
+ type: "SOCIAL",
259
+ order: order++,
260
+ visible: true,
261
+ config: {
262
+ providers: options.showSocialProviders,
263
+ },
264
+ });
265
+ }
266
+ const links = [];
267
+ if (options.showLogin !== false) {
268
+ links.push({
269
+ text: "Already have an account?",
270
+ href: "/login",
271
+ linkText: "Sign in",
272
+ });
273
+ }
274
+ return {
275
+ title: options.title || "Create your account",
276
+ action: options.action,
277
+ method: "POST",
278
+ components,
279
+ links,
280
+ };
281
+ }
282
+ /**
283
+ * Creates an MFA verification screen
284
+ */
285
+ export function createMfaScreen(options) {
286
+ const components = [];
287
+ let order = 0;
288
+ const description = options.method === "sms"
289
+ ? "Enter the code sent to your phone"
290
+ : options.method === "email"
291
+ ? "Enter the code sent to your email"
292
+ : "Enter the code from your authenticator app";
293
+ // Description text
294
+ components.push({
295
+ id: "description",
296
+ category: "BLOCK",
297
+ type: "RICH_TEXT",
298
+ order: order++,
299
+ visible: true,
300
+ config: {
301
+ content: `<p>${description}</p>`,
302
+ },
303
+ });
304
+ // Code input
305
+ components.push({
306
+ id: "code",
307
+ category: "FIELD",
308
+ type: "TEXT",
309
+ order: order++,
310
+ label: "Verification code",
311
+ required: true,
312
+ visible: true,
313
+ config: {
314
+ placeholder: "000000",
315
+ max_length: options.codeLength || 6,
316
+ },
317
+ });
318
+ // Submit button
319
+ components.push({
320
+ id: "submit",
321
+ category: "BLOCK",
322
+ type: "NEXT_BUTTON",
323
+ order: order++,
324
+ visible: true,
325
+ config: {
326
+ text: "Verify",
327
+ },
328
+ });
329
+ return {
330
+ title: options.title || "Two-factor authentication",
331
+ action: options.action,
332
+ method: "POST",
333
+ components,
334
+ links: [
335
+ {
336
+ text: "Back to login",
337
+ href: "/login",
338
+ },
339
+ ],
340
+ };
341
+ }
342
+ /**
343
+ * Creates a password reset request screen
344
+ */
345
+ export function createForgotPasswordScreen(options) {
346
+ const components = [];
347
+ let order = 0;
348
+ // Description text
349
+ components.push({
350
+ id: "description",
351
+ category: "BLOCK",
352
+ type: "RICH_TEXT",
353
+ order: order++,
354
+ visible: true,
355
+ config: {
356
+ content: "<p>Enter your email address and we'll send you a link to reset your password.</p>",
357
+ },
358
+ });
359
+ // Email input
360
+ components.push({
361
+ id: "email",
362
+ category: "FIELD",
363
+ type: "EMAIL",
364
+ order: order++,
365
+ label: "Email address",
366
+ required: true,
367
+ visible: true,
368
+ });
369
+ // Submit button
370
+ components.push({
371
+ id: "submit",
372
+ category: "BLOCK",
373
+ type: "NEXT_BUTTON",
374
+ order: order++,
375
+ visible: true,
376
+ config: {
377
+ text: "Send reset link",
378
+ },
379
+ });
380
+ return {
381
+ title: options.title || "Reset your password",
382
+ action: options.action,
383
+ method: "POST",
384
+ components,
385
+ links: [
386
+ {
387
+ text: "Back to login",
388
+ href: "/login",
389
+ },
390
+ ],
391
+ };
392
+ }
393
+ /**
394
+ * Adds an error message to a screen
395
+ */
396
+ export function withError(screen, error) {
397
+ return {
398
+ ...screen,
399
+ messages: [...(screen.messages || []), { text: error, type: "error" }],
400
+ };
401
+ }
402
+ /**
403
+ * Adds a success message to a screen
404
+ */
405
+ export function withSuccess(screen, success) {
406
+ return {
407
+ ...screen,
408
+ messages: [...(screen.messages || []), { text: success, type: "success" }],
409
+ };
410
+ }
411
+ /**
412
+ * Recursively add an error message to a component by ID.
413
+ * Handles nested components if they have a 'components' or 'children' property.
414
+ */
415
+ function addErrorToComponent(component, componentId, error) {
416
+ // Check if this is the target component
417
+ if (component.id === componentId) {
418
+ return {
419
+ ...component,
420
+ messages: [
421
+ ...(component.messages ||
422
+ []),
423
+ { text: error, type: "error" },
424
+ ],
425
+ };
426
+ }
427
+ // Check for nested components (new format might use 'components')
428
+ const componentWithChildren = component;
429
+ if (componentWithChildren.components?.length) {
430
+ return {
431
+ ...component,
432
+ components: componentWithChildren.components.map((child) => addErrorToComponent(child, componentId, error)),
433
+ };
434
+ }
435
+ // Check for nested children (deprecated UINode format)
436
+ if (componentWithChildren.children?.length) {
437
+ return {
438
+ ...component,
439
+ children: componentWithChildren.children.map((child) => addErrorToComponent(child, componentId, error)),
440
+ };
441
+ }
442
+ return component;
443
+ }
444
+ /**
445
+ * Adds a field-level error to a specific component.
446
+ * Recursively searches nested components/children.
447
+ */
448
+ export function withFieldError(screen, componentId, error) {
449
+ return {
450
+ ...screen,
451
+ components: screen.components.map((component) => addErrorToComponent(component, componentId, error)),
452
+ };
453
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * AuthHero Widget - Theming System
3
+ *
4
+ * The widget supports theming via branding/theme props from AuthHero API,
5
+ * CSS custom properties, or CSS classes for quick prototyping.
6
+ *
7
+ * ## 1. Branding & Theme Props (Recommended)
8
+ *
9
+ * Pass AuthHero branding and theme configuration directly:
10
+ *
11
+ * ```html
12
+ * <authhero-widget
13
+ * branding='{"colors":{"primary":"#7D68F4"},"logo_url":"..."}'
14
+ * theme='{"borders":{"widget_corner_radius":16}}'
15
+ * ></authhero-widget>
16
+ * ```
17
+ *
18
+ * ## 2. CSS Custom Properties
19
+ *
20
+ * Override individual variables:
21
+ *
22
+ * ```css
23
+ * authhero-widget {
24
+ * --ah-color-primary: #7D68F4;
25
+ * --ah-widget-radius: 16px;
26
+ * }
27
+ * ```
28
+ *
29
+ * ## 3. Theme Preset Classes
30
+ *
31
+ * Quick styling via CSS classes (for demos/prototyping):
32
+ *
33
+ * ```html
34
+ * <authhero-widget class="ah-theme-dark"></authhero-widget>
35
+ * ```
36
+ */
37
+ // Re-export branding utilities
38
+ export { brandingToCssVars, themeToCssVars, mergeThemeVars, applyCssVars, } from '../utils/branding';
39
+ // Theme preset class names
40
+ export const themePresets = ['ah-theme-minimal', 'ah-theme-rounded', 'ah-theme-dark'];
41
+ // CSS part names for ::part() styling
42
+ export const cssParts = [
43
+ 'container',
44
+ 'logo',
45
+ 'title',
46
+ 'form',
47
+ 'links',
48
+ 'link',
49
+ 'link-wrapper',
50
+ 'divider',
51
+ 'divider-text',
52
+ 'message',
53
+ 'message-error',
54
+ 'message-success',
55
+ 'input-wrapper',
56
+ 'label',
57
+ 'input',
58
+ 'helper-text',
59
+ 'error-text',
60
+ 'button',
61
+ 'button-primary',
62
+ 'button-secondary',
63
+ 'checkbox-wrapper',
64
+ 'checkbox',
65
+ 'checkbox-label',
66
+ 'image',
67
+ 'text-title',
68
+ 'text-description',
69
+ 'text-error',
70
+ 'text-success',
71
+ ];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Auth0 Forms Component Types for Widget Rendering
3
+ *
4
+ * Re-exported from @authhero/adapter-interfaces for consistency.
5
+ * @see https://auth0.com/docs/customize/forms/forms-schema
6
+ */
7
+ // Re-export type guards
8
+ export { isBlockComponent, isWidgetComponent, isFieldComponent, } from "@authhero/adapter-interfaces";