@drmhse/authos-react 0.2.0 → 0.2.2
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/README.md +7 -1
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +174 -72
- package/dist/index.mjs +174 -72
- package/dist/nextjs.js +120 -120
- package/dist/nextjs.mjs +120 -120
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -86,26 +86,37 @@ var AUTHOS_STYLES = `
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/* ==========================================================================
|
|
89
|
-
Base Form Styles
|
|
89
|
+
Base Form Styles (Card Layout)
|
|
90
90
|
========================================================================== */
|
|
91
91
|
|
|
92
92
|
[data-authos-signin],
|
|
93
93
|
[data-authos-signup],
|
|
94
|
-
[data-authos-
|
|
94
|
+
[data-authos-magic-link],
|
|
95
95
|
[data-authos-passkey] {
|
|
96
96
|
font-family: var(--authos-font-family);
|
|
97
97
|
font-size: var(--authos-font-size-sm);
|
|
98
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;
|
|
99
106
|
width: 100%;
|
|
107
|
+
max-width: 25rem; /* 400px */
|
|
108
|
+
margin: 0 auto; /* Center horizontally */
|
|
100
109
|
}
|
|
101
110
|
|
|
111
|
+
/* Ensure forms inside take full width */
|
|
102
112
|
[data-authos-signin] form,
|
|
103
113
|
[data-authos-signup] form,
|
|
104
|
-
[data-authos-
|
|
114
|
+
[data-authos-magic-link] form,
|
|
105
115
|
[data-authos-passkey] form {
|
|
106
116
|
display: flex;
|
|
107
117
|
flex-direction: column;
|
|
108
118
|
gap: var(--authos-spacing-md);
|
|
119
|
+
width: 100%;
|
|
109
120
|
}
|
|
110
121
|
|
|
111
122
|
/* ==========================================================================
|
|
@@ -429,39 +440,95 @@ var AUTHOS_STYLES = `
|
|
|
429
440
|
========================================================================== */
|
|
430
441
|
|
|
431
442
|
[data-authos-orgswitcher] {
|
|
443
|
+
position: relative;
|
|
432
444
|
font-family: var(--authos-font-family);
|
|
433
445
|
font-size: var(--authos-font-size-sm);
|
|
446
|
+
color: var(--authos-color-foreground);
|
|
434
447
|
}
|
|
435
448
|
|
|
436
|
-
[data-authos-
|
|
437
|
-
|
|
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;
|
|
438
456
|
font-size: var(--authos-font-size-sm);
|
|
439
457
|
font-family: inherit;
|
|
440
458
|
color: var(--authos-color-foreground);
|
|
441
|
-
background-color: var(--authos-color-
|
|
442
|
-
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
|
|
443
|
-
background-repeat: no-repeat;
|
|
444
|
-
background-position: right 0.5rem center;
|
|
459
|
+
background-color: var(--authos-color-surface);
|
|
445
460
|
border: 1px solid var(--authos-color-input-border);
|
|
446
461
|
border-radius: var(--authos-border-radius);
|
|
447
462
|
cursor: pointer;
|
|
448
463
|
outline: none;
|
|
449
|
-
appearance: none;
|
|
450
|
-
-webkit-appearance: none;
|
|
451
|
-
-moz-appearance: none;
|
|
452
464
|
transition: border-color var(--authos-transition), box-shadow var(--authos-transition);
|
|
453
465
|
}
|
|
454
466
|
|
|
455
|
-
[data-authos-
|
|
467
|
+
[data-authos-org-trigger]:focus-visible {
|
|
456
468
|
border-color: var(--authos-color-input-focus);
|
|
457
469
|
box-shadow: 0 0 0 3px var(--authos-color-ring);
|
|
458
470
|
}
|
|
459
471
|
|
|
460
|
-
[data-authos-
|
|
472
|
+
[data-authos-org-trigger][disabled] {
|
|
461
473
|
opacity: 0.6;
|
|
462
474
|
cursor: not-allowed;
|
|
463
475
|
}
|
|
464
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
|
+
|
|
465
532
|
/* ==========================================================================
|
|
466
533
|
Loading State
|
|
467
534
|
========================================================================== */
|
|
@@ -500,6 +567,16 @@ function AuthOSProvider({ config, children, client: externalClient, initialSessi
|
|
|
500
567
|
if (config.appearance?.variables) {
|
|
501
568
|
applyVariables(config.appearance.variables);
|
|
502
569
|
}
|
|
570
|
+
if (config.org && !config.service) {
|
|
571
|
+
console.warn(
|
|
572
|
+
'[AuthOS] You provided "org" but not "service". OAuth flows may not work correctly.'
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
if (!config.org && config.service) {
|
|
576
|
+
console.warn(
|
|
577
|
+
'[AuthOS] You provided "service" but not "org". OAuth flows may not work correctly.'
|
|
578
|
+
);
|
|
579
|
+
}
|
|
503
580
|
}, [config.appearance]);
|
|
504
581
|
const hasInitialToken = useRef(!!initialSessionToken);
|
|
505
582
|
useEffect(() => {
|
|
@@ -842,14 +919,25 @@ function SignIn({
|
|
|
842
919
|
] })
|
|
843
920
|
] });
|
|
844
921
|
}
|
|
845
|
-
function SignUp({
|
|
846
|
-
|
|
922
|
+
function SignUp({
|
|
923
|
+
onSuccess,
|
|
924
|
+
onError,
|
|
925
|
+
orgSlug,
|
|
926
|
+
serviceSlug,
|
|
927
|
+
showSignIn = true,
|
|
928
|
+
className,
|
|
929
|
+
providers = false,
|
|
930
|
+
showDivider = true
|
|
931
|
+
}) {
|
|
932
|
+
const { client, config } = useAuthOSContext();
|
|
847
933
|
const [email, setEmail] = useState("");
|
|
848
934
|
const [password, setPassword] = useState("");
|
|
849
935
|
const [confirmPassword, setConfirmPassword] = useState("");
|
|
850
936
|
const [error, setError] = useState(null);
|
|
851
937
|
const [isLoading, setIsLoading] = useState(false);
|
|
852
938
|
const [isSuccess, setIsSuccess] = useState(false);
|
|
939
|
+
const hasOAuthConfig = !!(config.org && config.service);
|
|
940
|
+
const oauthProviders = providers && Array.isArray(providers) ? providers : [];
|
|
853
941
|
const handleSubmit = useCallback(
|
|
854
942
|
async (e) => {
|
|
855
943
|
e.preventDefault();
|
|
@@ -867,8 +955,8 @@ function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn = true, c
|
|
|
867
955
|
await client.auth.register({
|
|
868
956
|
email,
|
|
869
957
|
password,
|
|
870
|
-
org_slug: orgSlug,
|
|
871
|
-
service_slug: serviceSlug
|
|
958
|
+
org_slug: orgSlug ?? config.org,
|
|
959
|
+
service_slug: serviceSlug ?? config.service
|
|
872
960
|
});
|
|
873
961
|
setIsSuccess(true);
|
|
874
962
|
onSuccess?.();
|
|
@@ -892,63 +980,77 @@ function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn = true, c
|
|
|
892
980
|
] })
|
|
893
981
|
] }) });
|
|
894
982
|
}
|
|
895
|
-
return /* @__PURE__ */
|
|
896
|
-
/* @__PURE__ */ jsxs("div", { "data-authos-
|
|
897
|
-
/* @__PURE__ */ jsx(
|
|
898
|
-
|
|
899
|
-
"input",
|
|
900
|
-
{
|
|
901
|
-
id: "authos-signup-email",
|
|
902
|
-
type: "email",
|
|
903
|
-
autoComplete: "email",
|
|
904
|
-
value: email,
|
|
905
|
-
onChange: (e) => setEmail(e.target.value),
|
|
906
|
-
placeholder: "Enter your email",
|
|
907
|
-
required: true,
|
|
908
|
-
disabled: isLoading
|
|
909
|
-
}
|
|
910
|
-
)
|
|
911
|
-
] }),
|
|
912
|
-
/* @__PURE__ */ jsxs("div", { "data-authos-field": "password", children: [
|
|
913
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-password", children: "Password" }),
|
|
914
|
-
/* @__PURE__ */ jsx(
|
|
915
|
-
"input",
|
|
916
|
-
{
|
|
917
|
-
id: "authos-signup-password",
|
|
918
|
-
type: "password",
|
|
919
|
-
autoComplete: "new-password",
|
|
920
|
-
value: password,
|
|
921
|
-
onChange: (e) => setPassword(e.target.value),
|
|
922
|
-
placeholder: "Create a password",
|
|
923
|
-
required: true,
|
|
924
|
-
minLength: 8,
|
|
925
|
-
disabled: isLoading
|
|
926
|
-
}
|
|
927
|
-
)
|
|
928
|
-
] }),
|
|
929
|
-
/* @__PURE__ */ jsxs("div", { "data-authos-field": "confirm-password", children: [
|
|
930
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-confirm", children: "Confirm Password" }),
|
|
931
|
-
/* @__PURE__ */ jsx(
|
|
932
|
-
"input",
|
|
983
|
+
return /* @__PURE__ */ jsxs("div", { className, "data-authos-signup": true, "data-state": "form", children: [
|
|
984
|
+
oauthProviders.length > 0 && /* @__PURE__ */ jsxs("div", { "data-authos-oauth-section": "", children: [
|
|
985
|
+
oauthProviders.map((provider) => /* @__PURE__ */ jsx(
|
|
986
|
+
OAuthButton,
|
|
933
987
|
{
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
required: true,
|
|
941
|
-
disabled: isLoading
|
|
942
|
-
}
|
|
943
|
-
)
|
|
988
|
+
provider,
|
|
989
|
+
disabled: isLoading || !hasOAuthConfig
|
|
990
|
+
},
|
|
991
|
+
provider
|
|
992
|
+
)),
|
|
993
|
+
!hasOAuthConfig && /* @__PURE__ */ jsx("p", { "data-authos-oauth-warning": "", style: { color: "orange", fontSize: "0.875rem" }, children: "OAuth requires org and service in AuthOSProvider config" })
|
|
944
994
|
] }),
|
|
945
|
-
|
|
946
|
-
/* @__PURE__ */
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
995
|
+
oauthProviders.length > 0 && showDivider && /* @__PURE__ */ jsx("div", { "data-authos-divider": "", children: /* @__PURE__ */ jsx("span", { children: "or" }) }),
|
|
996
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
997
|
+
/* @__PURE__ */ jsxs("div", { "data-authos-field": "email", children: [
|
|
998
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-email", children: "Email" }),
|
|
999
|
+
/* @__PURE__ */ jsx(
|
|
1000
|
+
"input",
|
|
1001
|
+
{
|
|
1002
|
+
id: "authos-signup-email",
|
|
1003
|
+
type: "email",
|
|
1004
|
+
autoComplete: "email",
|
|
1005
|
+
value: email,
|
|
1006
|
+
onChange: (e) => setEmail(e.target.value),
|
|
1007
|
+
placeholder: "Enter your email",
|
|
1008
|
+
required: true,
|
|
1009
|
+
disabled: isLoading
|
|
1010
|
+
}
|
|
1011
|
+
)
|
|
1012
|
+
] }),
|
|
1013
|
+
/* @__PURE__ */ jsxs("div", { "data-authos-field": "password", children: [
|
|
1014
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-password", children: "Password" }),
|
|
1015
|
+
/* @__PURE__ */ jsx(
|
|
1016
|
+
"input",
|
|
1017
|
+
{
|
|
1018
|
+
id: "authos-signup-password",
|
|
1019
|
+
type: "password",
|
|
1020
|
+
autoComplete: "new-password",
|
|
1021
|
+
value: password,
|
|
1022
|
+
onChange: (e) => setPassword(e.target.value),
|
|
1023
|
+
placeholder: "Create a password",
|
|
1024
|
+
required: true,
|
|
1025
|
+
minLength: 8,
|
|
1026
|
+
disabled: isLoading
|
|
1027
|
+
}
|
|
1028
|
+
)
|
|
1029
|
+
] }),
|
|
1030
|
+
/* @__PURE__ */ jsxs("div", { "data-authos-field": "confirm-password", children: [
|
|
1031
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-confirm", children: "Confirm Password" }),
|
|
1032
|
+
/* @__PURE__ */ jsx(
|
|
1033
|
+
"input",
|
|
1034
|
+
{
|
|
1035
|
+
id: "authos-signup-confirm",
|
|
1036
|
+
type: "password",
|
|
1037
|
+
autoComplete: "new-password",
|
|
1038
|
+
value: confirmPassword,
|
|
1039
|
+
onChange: (e) => setConfirmPassword(e.target.value),
|
|
1040
|
+
placeholder: "Confirm your password",
|
|
1041
|
+
required: true,
|
|
1042
|
+
disabled: isLoading
|
|
1043
|
+
}
|
|
1044
|
+
)
|
|
1045
|
+
] }),
|
|
1046
|
+
error && /* @__PURE__ */ jsx("div", { "data-authos-error": true, children: error }),
|
|
1047
|
+
/* @__PURE__ */ jsx("button", { type: "submit", disabled: isLoading, "data-authos-submit": true, children: isLoading ? "Creating account..." : "Create Account" }),
|
|
1048
|
+
showSignIn && /* @__PURE__ */ jsxs("div", { "data-authos-signin-prompt": true, children: [
|
|
1049
|
+
"Already have an account? ",
|
|
1050
|
+
/* @__PURE__ */ jsx("a", { href: "/signin", "data-authos-link": "signin", children: "Sign in" })
|
|
1051
|
+
] })
|
|
950
1052
|
] })
|
|
951
|
-
] })
|
|
1053
|
+
] });
|
|
952
1054
|
}
|
|
953
1055
|
function OrganizationSwitcher({ onSwitch, className, renderItem }) {
|
|
954
1056
|
const { client, isAuthenticated } = useAuthOSContext();
|