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