@drmhse/authos-react 0.1.5 → 0.2.1

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/index.js CHANGED
@@ -5,6 +5,557 @@ var ssoSdk = require('@drmhse/sso-sdk');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
 
7
7
  // src/context.tsx
8
+
9
+ // src/styles.ts
10
+ var AUTHOS_STYLES = `
11
+ /* ==========================================================================
12
+ AuthOS Component Styles
13
+ CSS Variables + Default Theme
14
+ ========================================================================== */
15
+
16
+ :root {
17
+ /* Primary Colors */
18
+ --authos-color-primary: #6366f1;
19
+ --authos-color-primary-hover: #4f46e5;
20
+ --authos-color-primary-foreground: #ffffff;
21
+
22
+ /* Semantic Colors */
23
+ --authos-color-danger: #ef4444;
24
+ --authos-color-danger-foreground: #ffffff;
25
+ --authos-color-success: #22c55e;
26
+ --authos-color-warning: #f59e0b;
27
+
28
+ /* Surface Colors */
29
+ --authos-color-background: #ffffff;
30
+ --authos-color-surface: #ffffff;
31
+ --authos-color-foreground: #0f172a;
32
+ --authos-color-muted: #64748b;
33
+ --authos-color-muted-foreground: #64748b;
34
+
35
+ /* Component Colors */
36
+ --authos-color-border: #e2e8f0;
37
+ --authos-color-input: #ffffff;
38
+ --authos-color-input-border: #cbd5e1;
39
+ --authos-color-input-focus: #6366f1;
40
+ --authos-color-ring: rgba(99, 102, 241, 0.25);
41
+
42
+ /* Typography */
43
+ --authos-font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
44
+ --authos-font-size-xs: 0.75rem;
45
+ --authos-font-size-sm: 0.875rem;
46
+ --authos-font-size-base: 1rem;
47
+ --authos-font-size-lg: 1.125rem;
48
+
49
+ /* Spacing & Shape */
50
+ --authos-border-radius: 0.5rem;
51
+ --authos-border-radius-sm: 0.375rem;
52
+ --authos-border-radius-lg: 0.75rem;
53
+ --authos-spacing-xs: 0.25rem;
54
+ --authos-spacing-sm: 0.5rem;
55
+ --authos-spacing-md: 1rem;
56
+ --authos-spacing-lg: 1.5rem;
57
+
58
+ /* Shadows */
59
+ --authos-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
60
+ --authos-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
61
+ --authos-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
62
+
63
+ /* Transitions */
64
+ --authos-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
65
+ }
66
+
67
+ /* Dark Mode */
68
+ @media (prefers-color-scheme: dark) {
69
+ :root {
70
+ --authos-color-primary: #818cf8;
71
+ --authos-color-primary-hover: #a5b4fc;
72
+
73
+ --authos-color-background: #0f172a;
74
+ --authos-color-surface: #1e293b;
75
+ --authos-color-foreground: #f1f5f9;
76
+ --authos-color-muted: #94a3b8;
77
+ --authos-color-muted-foreground: #94a3b8;
78
+
79
+ --authos-color-border: #334155;
80
+ --authos-color-input: #1e293b;
81
+ --authos-color-input-border: #475569;
82
+
83
+ --authos-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
84
+ --authos-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
85
+ --authos-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
86
+ }
87
+ }
88
+
89
+ /* ==========================================================================
90
+ Base Form Styles (Card Layout)
91
+ ========================================================================== */
92
+
93
+ [data-authos-signin],
94
+ [data-authos-signup],
95
+ [data-authos-magic-link],
96
+ [data-authos-passkey] {
97
+ font-family: var(--authos-font-family);
98
+ font-size: var(--authos-font-size-sm);
99
+ color: var(--authos-color-foreground);
100
+
101
+ /* Card Styling */
102
+ background-color: var(--authos-color-surface);
103
+ border: 1px solid var(--authos-color-border);
104
+ border-radius: var(--authos-border-radius-lg);
105
+ box-shadow: var(--authos-shadow);
106
+ padding: 2rem;
107
+ width: 100%;
108
+ max-width: 25rem; /* 400px */
109
+ margin: 0 auto; /* Center horizontally */
110
+ }
111
+
112
+ /* Ensure forms inside take full width */
113
+ [data-authos-signin] form,
114
+ [data-authos-signup] form,
115
+ [data-authos-magic-link] form,
116
+ [data-authos-passkey] form {
117
+ display: flex;
118
+ flex-direction: column;
119
+ gap: var(--authos-spacing-md);
120
+ width: 100%;
121
+ }
122
+
123
+ /* ==========================================================================
124
+ Field Styles
125
+ ========================================================================== */
126
+
127
+ [data-authos-field] {
128
+ display: flex;
129
+ flex-direction: column;
130
+ gap: var(--authos-spacing-xs);
131
+ }
132
+
133
+ [data-authos-field] label {
134
+ font-size: var(--authos-font-size-sm);
135
+ font-weight: 500;
136
+ color: var(--authos-color-foreground);
137
+ }
138
+
139
+ [data-authos-field] input {
140
+ width: 100%;
141
+ padding: 0.625rem 0.875rem;
142
+ font-size: var(--authos-font-size-sm);
143
+ font-family: inherit;
144
+ color: var(--authos-color-foreground);
145
+ background-color: var(--authos-color-input);
146
+ border: 1px solid var(--authos-color-input-border);
147
+ border-radius: var(--authos-border-radius);
148
+ outline: none;
149
+ transition: border-color var(--authos-transition), box-shadow var(--authos-transition);
150
+ }
151
+
152
+ [data-authos-field] input::placeholder {
153
+ color: var(--authos-color-muted);
154
+ }
155
+
156
+ [data-authos-field] input:focus {
157
+ border-color: var(--authos-color-input-focus);
158
+ box-shadow: 0 0 0 3px var(--authos-color-ring);
159
+ }
160
+
161
+ [data-authos-field] input:disabled {
162
+ opacity: 0.6;
163
+ cursor: not-allowed;
164
+ }
165
+
166
+ /* ==========================================================================
167
+ Button Styles
168
+ ========================================================================== */
169
+
170
+ [data-authos-submit] {
171
+ display: inline-flex;
172
+ align-items: center;
173
+ justify-content: center;
174
+ gap: var(--authos-spacing-sm);
175
+ width: 100%;
176
+ padding: 0.625rem 1rem;
177
+ font-size: var(--authos-font-size-sm);
178
+ font-weight: 500;
179
+ font-family: inherit;
180
+ color: var(--authos-color-primary-foreground);
181
+ background-color: var(--authos-color-primary);
182
+ border: none;
183
+ border-radius: var(--authos-border-radius);
184
+ cursor: pointer;
185
+ outline: none;
186
+ transition: background-color var(--authos-transition), box-shadow var(--authos-transition);
187
+ }
188
+
189
+ [data-authos-submit]:hover:not(:disabled) {
190
+ background-color: var(--authos-color-primary-hover);
191
+ }
192
+
193
+ [data-authos-submit]:focus-visible {
194
+ box-shadow: 0 0 0 3px var(--authos-color-ring);
195
+ }
196
+
197
+ [data-authos-submit]:disabled {
198
+ opacity: 0.6;
199
+ cursor: not-allowed;
200
+ }
201
+
202
+ [data-authos-back] {
203
+ display: inline-flex;
204
+ align-items: center;
205
+ justify-content: center;
206
+ padding: 0.5rem 1rem;
207
+ font-size: var(--authos-font-size-sm);
208
+ font-weight: 500;
209
+ font-family: inherit;
210
+ color: var(--authos-color-muted);
211
+ background: transparent;
212
+ border: none;
213
+ border-radius: var(--authos-border-radius);
214
+ cursor: pointer;
215
+ transition: color var(--authos-transition);
216
+ }
217
+
218
+ [data-authos-back]:hover {
219
+ color: var(--authos-color-foreground);
220
+ }
221
+
222
+ /* ==========================================================================
223
+ OAuth Button Styles
224
+ ========================================================================== */
225
+
226
+ [data-authos-oauth] {
227
+ display: inline-flex;
228
+ align-items: center;
229
+ justify-content: center;
230
+ gap: 0.75rem;
231
+ width: 100%;
232
+ padding: 0.625rem 1rem;
233
+ font-size: var(--authos-font-size-sm);
234
+ font-weight: 500;
235
+ font-family: var(--authos-font-family);
236
+ color: var(--authos-color-foreground);
237
+ background-color: var(--authos-color-surface);
238
+ border: 1px solid var(--authos-color-border);
239
+ border-radius: var(--authos-border-radius);
240
+ cursor: pointer;
241
+ outline: none;
242
+ transition: background-color var(--authos-transition), border-color var(--authos-transition), box-shadow var(--authos-transition);
243
+ }
244
+
245
+ [data-authos-oauth]:hover:not(:disabled) {
246
+ background-color: var(--authos-color-background);
247
+ border-color: var(--authos-color-input-border);
248
+ }
249
+
250
+ [data-authos-oauth]:focus-visible {
251
+ box-shadow: 0 0 0 3px var(--authos-color-ring);
252
+ }
253
+
254
+ [data-authos-oauth]:disabled {
255
+ opacity: 0.6;
256
+ cursor: not-allowed;
257
+ }
258
+
259
+ [data-authos-oauth] svg {
260
+ width: 1.25rem;
261
+ height: 1.25rem;
262
+ flex-shrink: 0;
263
+ }
264
+
265
+ /* ==========================================================================
266
+ Divider Styles
267
+ ========================================================================== */
268
+
269
+ [data-authos-divider] {
270
+ display: flex;
271
+ align-items: center;
272
+ gap: var(--authos-spacing-md);
273
+ margin: var(--authos-spacing-sm) 0;
274
+ }
275
+
276
+ [data-authos-divider]::before,
277
+ [data-authos-divider]::after {
278
+ content: '';
279
+ flex: 1;
280
+ height: 1px;
281
+ background-color: var(--authos-color-border);
282
+ }
283
+
284
+ [data-authos-divider] span {
285
+ font-size: var(--authos-font-size-xs);
286
+ color: var(--authos-color-muted);
287
+ text-transform: uppercase;
288
+ letter-spacing: 0.05em;
289
+ }
290
+
291
+ /* ==========================================================================
292
+ Error Styles
293
+ ========================================================================== */
294
+
295
+ [data-authos-error] {
296
+ display: flex;
297
+ align-items: center;
298
+ gap: var(--authos-spacing-sm);
299
+ padding: 0.75rem 1rem;
300
+ font-size: var(--authos-font-size-sm);
301
+ color: var(--authos-color-danger);
302
+ background-color: rgba(239, 68, 68, 0.1);
303
+ border: 1px solid rgba(239, 68, 68, 0.2);
304
+ border-radius: var(--authos-border-radius);
305
+ }
306
+
307
+ /* ==========================================================================
308
+ Link Styles
309
+ ========================================================================== */
310
+
311
+ [data-authos-link] {
312
+ font-size: var(--authos-font-size-sm);
313
+ color: var(--authos-color-primary);
314
+ text-decoration: none;
315
+ transition: color var(--authos-transition);
316
+ }
317
+
318
+ [data-authos-link]:hover {
319
+ color: var(--authos-color-primary-hover);
320
+ text-decoration: underline;
321
+ }
322
+
323
+ [data-authos-signup-prompt],
324
+ [data-authos-signin-prompt] {
325
+ text-align: center;
326
+ font-size: var(--authos-font-size-sm);
327
+ color: var(--authos-color-muted);
328
+ margin-top: var(--authos-spacing-sm);
329
+ }
330
+
331
+ /* ==========================================================================
332
+ OAuth Section
333
+ ========================================================================== */
334
+
335
+ [data-authos-oauth-section] {
336
+ display: flex;
337
+ flex-direction: column;
338
+ gap: var(--authos-spacing-sm);
339
+ }
340
+
341
+ /* ==========================================================================
342
+ User Button Styles
343
+ ========================================================================== */
344
+
345
+ [data-authos-userbutton] {
346
+ position: relative;
347
+ display: inline-flex;
348
+ font-family: var(--authos-font-family);
349
+ font-size: var(--authos-font-size-sm);
350
+ color: var(--authos-color-foreground);
351
+ }
352
+
353
+ [data-authos-user-trigger] {
354
+ display: flex;
355
+ align-items: center;
356
+ gap: var(--authos-spacing-sm);
357
+ padding: 0;
358
+ background: transparent;
359
+ border: none;
360
+ cursor: pointer;
361
+ outline: none;
362
+ }
363
+
364
+ [data-authos-avatar] {
365
+ display: flex;
366
+ align-items: center;
367
+ justify-content: center;
368
+ width: 2rem;
369
+ height: 2rem;
370
+ font-size: var(--authos-font-size-xs);
371
+ font-weight: 600;
372
+ color: var(--authos-color-primary-foreground);
373
+ background-color: var(--authos-color-primary);
374
+ border-radius: 50%;
375
+ flex-shrink: 0;
376
+ }
377
+
378
+ [data-authos-user-menu] {
379
+ position: absolute;
380
+ top: 100%;
381
+ right: 0;
382
+ margin-top: var(--authos-spacing-sm);
383
+ width: 240px;
384
+ background-color: var(--authos-color-surface);
385
+ border: 1px solid var(--authos-color-border);
386
+ border-radius: var(--authos-border-radius);
387
+ box-shadow: var(--authos-shadow-lg);
388
+ z-index: 50;
389
+ overflow: hidden;
390
+ animation: authos-fade-in 150ms ease-out;
391
+ }
392
+
393
+ @keyframes authos-fade-in {
394
+ from { opacity: 0; transform: translateY(-4px); }
395
+ to { opacity: 1; transform: translateY(0); }
396
+ }
397
+
398
+ [data-authos-user-info] {
399
+ padding: var(--authos-spacing-md);
400
+ display: flex;
401
+ flex-direction: column;
402
+ gap: 0.25rem;
403
+ }
404
+
405
+ [data-authos-user-info] [data-authos-email] {
406
+ font-weight: 500;
407
+ color: var(--authos-color-foreground);
408
+ word-break: break-all;
409
+ }
410
+
411
+ [data-authos-badge] {
412
+ display: inline-flex;
413
+ align-self: flex-start;
414
+ padding: 0.125rem 0.375rem;
415
+ font-size: 0.7rem;
416
+ font-weight: 500;
417
+ color: var(--authos-color-primary);
418
+ background-color: rgba(99, 102, 241, 0.1);
419
+ border-radius: 9999px;
420
+ }
421
+
422
+ [data-authos-user-menu] [data-authos-logout] {
423
+ width: 100%;
424
+ text-align: left;
425
+ padding: 0.75rem 1rem;
426
+ font-size: var(--authos-font-size-sm);
427
+ color: var(--authos-color-danger);
428
+ background: transparent;
429
+ border: none;
430
+ border-top: 1px solid var(--authos-color-border);
431
+ cursor: pointer;
432
+ transition: background-color var(--authos-transition);
433
+ }
434
+
435
+ [data-authos-user-menu] [data-authos-logout]:hover {
436
+ background-color: rgba(239, 68, 68, 0.05);
437
+ }
438
+
439
+ /* ==========================================================================
440
+ Organization Switcher Styles
441
+ ========================================================================== */
442
+
443
+ [data-authos-orgswitcher] {
444
+ position: relative;
445
+ font-family: var(--authos-font-family);
446
+ font-size: var(--authos-font-size-sm);
447
+ color: var(--authos-color-foreground);
448
+ }
449
+
450
+ [data-authos-org-trigger] {
451
+ display: flex;
452
+ align-items: center;
453
+ justify-content: space-between;
454
+ gap: var(--authos-spacing-sm);
455
+ width: 100%;
456
+ padding: 0.5rem 0.75rem;
457
+ font-size: var(--authos-font-size-sm);
458
+ font-family: inherit;
459
+ color: var(--authos-color-foreground);
460
+ background-color: var(--authos-color-surface);
461
+ border: 1px solid var(--authos-color-input-border);
462
+ border-radius: var(--authos-border-radius);
463
+ cursor: pointer;
464
+ outline: none;
465
+ transition: border-color var(--authos-transition), box-shadow var(--authos-transition);
466
+ }
467
+
468
+ [data-authos-org-trigger]:focus-visible {
469
+ border-color: var(--authos-color-input-focus);
470
+ box-shadow: 0 0 0 3px var(--authos-color-ring);
471
+ }
472
+
473
+ [data-authos-org-trigger][disabled] {
474
+ opacity: 0.6;
475
+ cursor: not-allowed;
476
+ }
477
+
478
+ [data-authos-org-chevron] {
479
+ font-size: 0.625rem;
480
+ color: var(--authos-color-muted);
481
+ }
482
+
483
+ [data-authos-org-list] {
484
+ position: absolute;
485
+ top: 100%;
486
+ left: 0;
487
+ right: 0;
488
+ margin-top: var(--authos-spacing-xs);
489
+ padding: var(--authos-spacing-xs);
490
+ background-color: var(--authos-color-surface);
491
+ border: 1px solid var(--authos-color-border);
492
+ border-radius: var(--authos-border-radius);
493
+ box-shadow: var(--authos-shadow-lg);
494
+ list-style: none;
495
+ z-index: 50;
496
+ max-height: 240px;
497
+ overflow-y: auto;
498
+ animation: authos-fade-in 150ms ease-out;
499
+ }
500
+
501
+ [data-authos-org-item] {
502
+ display: flex;
503
+ align-items: center;
504
+ justify-content: space-between;
505
+ width: 100%;
506
+ padding: 0.5rem 0.75rem;
507
+ font-size: var(--authos-font-size-sm);
508
+ color: var(--authos-color-foreground);
509
+ background: transparent;
510
+ border: none;
511
+ border-radius: var(--authos-border-radius-sm);
512
+ cursor: pointer;
513
+ text-align: left;
514
+ transition: background-color var(--authos-transition);
515
+ }
516
+
517
+ [data-authos-org-item]:hover,
518
+ [data-authos-org-item]:focus-visible {
519
+ background-color: var(--authos-color-background);
520
+ outline: none;
521
+ }
522
+
523
+ [data-authos-org-item][data-active="true"] {
524
+ background-color: rgba(99, 102, 241, 0.05);
525
+ color: var(--authos-color-primary);
526
+ font-weight: 500;
527
+ }
528
+
529
+ [data-authos-org-item-check] {
530
+ color: var(--authos-color-primary);
531
+ }
532
+
533
+ /* ==========================================================================
534
+ Loading State
535
+ ========================================================================== */
536
+
537
+ [data-state="loading"] {
538
+ opacity: 0.6;
539
+ }
540
+ `;
541
+ var stylesInjected = false;
542
+ function injectStyles() {
543
+ if (stylesInjected) return;
544
+ if (typeof document === "undefined") return;
545
+ const styleElement = document.createElement("style");
546
+ styleElement.setAttribute("data-authos-styles", "");
547
+ styleElement.textContent = AUTHOS_STYLES;
548
+ document.head.appendChild(styleElement);
549
+ stylesInjected = true;
550
+ }
551
+ function applyVariables(variables) {
552
+ if (typeof document === "undefined") return;
553
+ const root = document.documentElement;
554
+ for (const [key, value] of Object.entries(variables)) {
555
+ const cssVar = `--authos-${key.replace(/([A-Z])/g, "-$1").toLowerCase()}`;
556
+ root.style.setProperty(cssVar, value);
557
+ }
558
+ }
8
559
  var AuthOSContext = react.createContext(null);
9
560
  function AuthOSProvider({ config, children, client: externalClient, initialSessionToken }) {
10
561
  const clientRef = react.useRef(null);
@@ -12,6 +563,12 @@ function AuthOSProvider({ config, children, client: externalClient, initialSessi
12
563
  clientRef.current = externalClient ?? new ssoSdk.SsoClient(config);
13
564
  }
14
565
  const client = clientRef.current;
566
+ react.useEffect(() => {
567
+ injectStyles();
568
+ if (config.appearance?.variables) {
569
+ applyVariables(config.appearance.variables);
570
+ }
571
+ }, [config.appearance]);
15
572
  const hasInitialToken = react.useRef(!!initialSessionToken);
16
573
  react.useEffect(() => {
17
574
  if (initialSessionToken && hasInitialToken.current) {
@@ -124,6 +681,26 @@ var PROVIDER_NAMES = {
124
681
  google: "Google",
125
682
  microsoft: "Microsoft"
126
683
  };
684
+ function getProviderIcon(provider) {
685
+ switch (provider) {
686
+ case "github":
687
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 0C5.374 0 0 5.373 0 12c0 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.23A11.509 11.509 0 0112 5.803c1.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.576C20.566 21.797 24 17.3 24 12c0-6.627-5.373-12-12-12z" }) });
688
+ case "google":
689
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", "aria-hidden": "true", children: [
690
+ /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "#4285F4", 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" }),
691
+ /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "#34A853", 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" }),
692
+ /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "#FBBC05", 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" }),
693
+ /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "#EA4335", 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" })
694
+ ] });
695
+ case "microsoft":
696
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 23 23", "aria-hidden": "true", children: [
697
+ /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "#f35325", d: "M1 1h10v10H1z" }),
698
+ /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "#81bc06", d: "M12 1h10v10H12z" }),
699
+ /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "#05a6f0", d: "M1 12h10v10H1z" }),
700
+ /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "#ffba08", d: "M12 12h10v10H12z" })
701
+ ] });
702
+ }
703
+ }
127
704
  function OAuthButton({
128
705
  provider,
129
706
  children,
@@ -167,7 +744,13 @@ See: https://docs.authos.dev/react/oauth-setup`
167
744
  disabled,
168
745
  "data-authos-oauth": "",
169
746
  "data-provider": provider,
170
- children: children ?? `Continue with ${PROVIDER_NAMES[provider]}`
747
+ children: children || /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
748
+ getProviderIcon(provider),
749
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
750
+ "Continue with ",
751
+ PROVIDER_NAMES[provider]
752
+ ] })
753
+ ] })
171
754
  }
172
755
  );
173
756
  }
@@ -327,14 +910,25 @@ function SignIn({
327
910
  ] })
328
911
  ] });
329
912
  }
330
- function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn = true, className }) {
331
- const { client } = useAuthOSContext();
913
+ function SignUp({
914
+ onSuccess,
915
+ onError,
916
+ orgSlug,
917
+ serviceSlug,
918
+ showSignIn = true,
919
+ className,
920
+ providers = false,
921
+ showDivider = true
922
+ }) {
923
+ const { client, config } = useAuthOSContext();
332
924
  const [email, setEmail] = react.useState("");
333
925
  const [password, setPassword] = react.useState("");
334
926
  const [confirmPassword, setConfirmPassword] = react.useState("");
335
927
  const [error, setError] = react.useState(null);
336
928
  const [isLoading, setIsLoading] = react.useState(false);
337
929
  const [isSuccess, setIsSuccess] = react.useState(false);
930
+ const hasOAuthConfig = !!(config.org && config.service);
931
+ const oauthProviders = providers && Array.isArray(providers) ? providers : [];
338
932
  const handleSubmit = react.useCallback(
339
933
  async (e) => {
340
934
  e.preventDefault();
@@ -377,63 +971,77 @@ function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn = true, c
377
971
  ] })
378
972
  ] }) });
379
973
  }
380
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "data-authos-signup": true, "data-state": "form", children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
381
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "email", children: [
382
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-email", children: "Email" }),
383
- /* @__PURE__ */ jsxRuntime.jsx(
384
- "input",
385
- {
386
- id: "authos-signup-email",
387
- type: "email",
388
- autoComplete: "email",
389
- value: email,
390
- onChange: (e) => setEmail(e.target.value),
391
- placeholder: "Enter your email",
392
- required: true,
393
- disabled: isLoading
394
- }
395
- )
396
- ] }),
397
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "password", children: [
398
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-password", children: "Password" }),
399
- /* @__PURE__ */ jsxRuntime.jsx(
400
- "input",
401
- {
402
- id: "authos-signup-password",
403
- type: "password",
404
- autoComplete: "new-password",
405
- value: password,
406
- onChange: (e) => setPassword(e.target.value),
407
- placeholder: "Create a password",
408
- required: true,
409
- minLength: 8,
410
- disabled: isLoading
411
- }
412
- )
413
- ] }),
414
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "confirm-password", children: [
415
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-confirm", children: "Confirm Password" }),
416
- /* @__PURE__ */ jsxRuntime.jsx(
417
- "input",
974
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, "data-authos-signup": true, "data-state": "form", children: [
975
+ oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-oauth-section": "", children: [
976
+ oauthProviders.map((provider) => /* @__PURE__ */ jsxRuntime.jsx(
977
+ OAuthButton,
418
978
  {
419
- id: "authos-signup-confirm",
420
- type: "password",
421
- autoComplete: "new-password",
422
- value: confirmPassword,
423
- onChange: (e) => setConfirmPassword(e.target.value),
424
- placeholder: "Confirm your password",
425
- required: true,
426
- disabled: isLoading
427
- }
428
- )
979
+ provider,
980
+ disabled: isLoading || !hasOAuthConfig
981
+ },
982
+ provider
983
+ )),
984
+ !hasOAuthConfig && /* @__PURE__ */ jsxRuntime.jsx("p", { "data-authos-oauth-warning": "", style: { color: "orange", fontSize: "0.875rem" }, children: "OAuth requires org and service in AuthOSProvider config" })
429
985
  ] }),
430
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-authos-error": true, children: error }),
431
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: isLoading, "data-authos-submit": true, children: isLoading ? "Creating account..." : "Create Account" }),
432
- showSignIn && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-signin-prompt": true, children: [
433
- "Already have an account? ",
434
- /* @__PURE__ */ jsxRuntime.jsx("a", { href: "/signin", "data-authos-link": "signin", children: "Sign in" })
986
+ oauthProviders.length > 0 && showDivider && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-authos-divider": "", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "or" }) }),
987
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
988
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "email", children: [
989
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-email", children: "Email" }),
990
+ /* @__PURE__ */ jsxRuntime.jsx(
991
+ "input",
992
+ {
993
+ id: "authos-signup-email",
994
+ type: "email",
995
+ autoComplete: "email",
996
+ value: email,
997
+ onChange: (e) => setEmail(e.target.value),
998
+ placeholder: "Enter your email",
999
+ required: true,
1000
+ disabled: isLoading
1001
+ }
1002
+ )
1003
+ ] }),
1004
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "password", children: [
1005
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-password", children: "Password" }),
1006
+ /* @__PURE__ */ jsxRuntime.jsx(
1007
+ "input",
1008
+ {
1009
+ id: "authos-signup-password",
1010
+ type: "password",
1011
+ autoComplete: "new-password",
1012
+ value: password,
1013
+ onChange: (e) => setPassword(e.target.value),
1014
+ placeholder: "Create a password",
1015
+ required: true,
1016
+ minLength: 8,
1017
+ disabled: isLoading
1018
+ }
1019
+ )
1020
+ ] }),
1021
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "confirm-password", children: [
1022
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-confirm", children: "Confirm Password" }),
1023
+ /* @__PURE__ */ jsxRuntime.jsx(
1024
+ "input",
1025
+ {
1026
+ id: "authos-signup-confirm",
1027
+ type: "password",
1028
+ autoComplete: "new-password",
1029
+ value: confirmPassword,
1030
+ onChange: (e) => setConfirmPassword(e.target.value),
1031
+ placeholder: "Confirm your password",
1032
+ required: true,
1033
+ disabled: isLoading
1034
+ }
1035
+ )
1036
+ ] }),
1037
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-authos-error": true, children: error }),
1038
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: isLoading, "data-authos-submit": true, children: isLoading ? "Creating account..." : "Create Account" }),
1039
+ showSignIn && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-signin-prompt": true, children: [
1040
+ "Already have an account? ",
1041
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: "/signin", "data-authos-link": "signin", children: "Sign in" })
1042
+ ] })
435
1043
  ] })
436
- ] }) });
1044
+ ] });
437
1045
  }
438
1046
  function OrganizationSwitcher({ onSwitch, className, renderItem }) {
439
1047
  const { client, isAuthenticated } = useAuthOSContext();
@@ -553,33 +1161,33 @@ function UserButton({ className, showEmail = false, onLogout }) {
553
1161
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "data-authos-userbutton": true, "data-state": "signed-out", children: /* @__PURE__ */ jsxRuntime.jsx("span", { "data-authos-user-placeholder": true, children: "Not signed in" }) });
554
1162
  }
555
1163
  const initials = user.email.split("@")[0].split(".").map((part) => part[0]?.toUpperCase() ?? "").slice(0, 2).join("");
556
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, "data-authos-userbutton": true, "data-state": isOpen ? "open" : "closed", children: [
1164
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, "data-authos-userbutton": "", "data-state": isOpen ? "open" : "closed", children: [
557
1165
  /* @__PURE__ */ jsxRuntime.jsxs(
558
1166
  "button",
559
1167
  {
560
1168
  type: "button",
561
1169
  onClick: () => setIsOpen(!isOpen),
562
1170
  disabled: isLoggingOut,
563
- "data-authos-user-trigger": true,
1171
+ "data-authos-user-trigger": "",
564
1172
  children: [
565
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-authos-user-avatar": true, "aria-hidden": "true", children: initials }),
566
- showEmail && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-authos-user-email": true, children: user.email })
1173
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-authos-avatar": "", "aria-hidden": "true", children: initials }),
1174
+ showEmail && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-authos-email": "", children: user.email })
567
1175
  ]
568
1176
  }
569
1177
  ),
570
- isOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-user-menu": true, children: [
571
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-user-info": true, children: [
572
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-authos-user-email": true, children: user.email }),
573
- user.is_platform_owner && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-authos-user-badge": true, children: "Platform Owner" })
1178
+ isOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-user-menu": "", children: [
1179
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-user-info": "", children: [
1180
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-authos-email": "", children: user.email }),
1181
+ user.is_platform_owner && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-authos-badge": "", children: "Platform Owner" })
574
1182
  ] }),
575
- /* @__PURE__ */ jsxRuntime.jsx("hr", { "data-authos-divider": true }),
1183
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "data-authos-divider": "" }),
576
1184
  /* @__PURE__ */ jsxRuntime.jsx(
577
1185
  "button",
578
1186
  {
579
1187
  type: "button",
580
1188
  onClick: handleLogout,
581
1189
  disabled: isLoggingOut,
582
- "data-authos-logout": true,
1190
+ "data-authos-logout": "",
583
1191
  children: isLoggingOut ? "Signing out..." : "Sign out"
584
1192
  }
585
1193
  )