@drmhse/authos-react 0.1.4 → 0.1.5
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 +20 -4
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +11 -5
- package/dist/index.mjs +11 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -32,10 +32,10 @@ function App() {
|
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
That's it. You now have:
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
35
|
+
- Email/password authentication with MFA support
|
|
36
|
+
- Automatic session management
|
|
37
|
+
- User dropdown with logout
|
|
38
|
+
- Conditional rendering based on auth state
|
|
39
39
|
|
|
40
40
|
## Usage Modes
|
|
41
41
|
|
|
@@ -150,6 +150,22 @@ Registration form for new users.
|
|
|
150
150
|
/>
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
+
### MagicLinkSignIn
|
|
154
|
+
|
|
155
|
+
Sign-in component for Magic Links (passwordless).
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
<MagicLinkSignIn onSuccess={() => console.log('Magic link sent!')} />
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### PasskeySignIn
|
|
162
|
+
|
|
163
|
+
Sign-in component for Passkeys (WebAuthn).
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
<PasskeySignIn onSuccess={() => console.log('Authenticated!')} />
|
|
167
|
+
```
|
|
168
|
+
|
|
153
169
|
### SignedIn / SignedOut
|
|
154
170
|
|
|
155
171
|
Conditional rendering based on authentication state. Inspired by Clerk's API.
|
package/dist/index.d.mts
CHANGED
|
@@ -129,6 +129,8 @@ interface SignUpProps {
|
|
|
129
129
|
onError?: (error: Error) => void;
|
|
130
130
|
/** Organization slug for registration context */
|
|
131
131
|
orgSlug?: string;
|
|
132
|
+
/** Service slug for registration context (used with orgSlug for tenant attribution) */
|
|
133
|
+
serviceSlug?: string;
|
|
132
134
|
/** Whether to show the "sign in" link */
|
|
133
135
|
showSignIn?: boolean;
|
|
134
136
|
/** Custom class name for the form container */
|
|
@@ -440,7 +442,7 @@ declare function SignIn({ onSuccess, onError, showForgotPassword, showSignUp, cl
|
|
|
440
442
|
* }
|
|
441
443
|
* ```
|
|
442
444
|
*/
|
|
443
|
-
declare function SignUp({ onSuccess, onError, orgSlug, showSignIn, className }: SignUpProps): react_jsx_runtime.JSX.Element;
|
|
445
|
+
declare function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn, className }: SignUpProps): react_jsx_runtime.JSX.Element;
|
|
444
446
|
|
|
445
447
|
/**
|
|
446
448
|
* Component for switching between organizations.
|
package/dist/index.d.ts
CHANGED
|
@@ -129,6 +129,8 @@ interface SignUpProps {
|
|
|
129
129
|
onError?: (error: Error) => void;
|
|
130
130
|
/** Organization slug for registration context */
|
|
131
131
|
orgSlug?: string;
|
|
132
|
+
/** Service slug for registration context (used with orgSlug for tenant attribution) */
|
|
133
|
+
serviceSlug?: string;
|
|
132
134
|
/** Whether to show the "sign in" link */
|
|
133
135
|
showSignIn?: boolean;
|
|
134
136
|
/** Custom class name for the form container */
|
|
@@ -440,7 +442,7 @@ declare function SignIn({ onSuccess, onError, showForgotPassword, showSignUp, cl
|
|
|
440
442
|
* }
|
|
441
443
|
* ```
|
|
442
444
|
*/
|
|
443
|
-
declare function SignUp({ onSuccess, onError, orgSlug, showSignIn, className }: SignUpProps): react_jsx_runtime.JSX.Element;
|
|
445
|
+
declare function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn, className }: SignUpProps): react_jsx_runtime.JSX.Element;
|
|
444
446
|
|
|
445
447
|
/**
|
|
446
448
|
* Component for switching between organizations.
|
package/dist/index.js
CHANGED
|
@@ -197,7 +197,12 @@ function SignIn({
|
|
|
197
197
|
setError(null);
|
|
198
198
|
setIsLoading(true);
|
|
199
199
|
try {
|
|
200
|
-
const result = await client.auth.login({
|
|
200
|
+
const result = await client.auth.login({
|
|
201
|
+
email,
|
|
202
|
+
password,
|
|
203
|
+
org_slug: config.org,
|
|
204
|
+
service_slug: config.service
|
|
205
|
+
});
|
|
201
206
|
if (result.expires_in === MFA_PREAUTH_EXPIRY) {
|
|
202
207
|
setPreauthToken(result.access_token);
|
|
203
208
|
setState("mfa");
|
|
@@ -214,7 +219,7 @@ function SignIn({
|
|
|
214
219
|
setIsLoading(false);
|
|
215
220
|
}
|
|
216
221
|
},
|
|
217
|
-
[client, email, password, setUser, onSuccess, onError]
|
|
222
|
+
[client, email, password, config.org, config.service, setUser, onSuccess, onError]
|
|
218
223
|
);
|
|
219
224
|
const handleMfaSubmit = react.useCallback(
|
|
220
225
|
async (e) => {
|
|
@@ -322,7 +327,7 @@ function SignIn({
|
|
|
322
327
|
] })
|
|
323
328
|
] });
|
|
324
329
|
}
|
|
325
|
-
function SignUp({ onSuccess, onError, orgSlug, showSignIn = true, className }) {
|
|
330
|
+
function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn = true, className }) {
|
|
326
331
|
const { client } = useAuthOSContext();
|
|
327
332
|
const [email, setEmail] = react.useState("");
|
|
328
333
|
const [password, setPassword] = react.useState("");
|
|
@@ -347,7 +352,8 @@ function SignUp({ onSuccess, onError, orgSlug, showSignIn = true, className }) {
|
|
|
347
352
|
await client.auth.register({
|
|
348
353
|
email,
|
|
349
354
|
password,
|
|
350
|
-
org_slug: orgSlug
|
|
355
|
+
org_slug: orgSlug,
|
|
356
|
+
service_slug: serviceSlug
|
|
351
357
|
});
|
|
352
358
|
setIsSuccess(true);
|
|
353
359
|
onSuccess?.();
|
|
@@ -359,7 +365,7 @@ function SignUp({ onSuccess, onError, orgSlug, showSignIn = true, className }) {
|
|
|
359
365
|
setIsLoading(false);
|
|
360
366
|
}
|
|
361
367
|
},
|
|
362
|
-
[client, email, password, confirmPassword, orgSlug, onSuccess, onError]
|
|
368
|
+
[client, email, password, confirmPassword, orgSlug, serviceSlug, onSuccess, onError]
|
|
363
369
|
);
|
|
364
370
|
if (isSuccess) {
|
|
365
371
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "data-authos-signup": true, "data-state": "success", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-success": true, children: [
|
package/dist/index.mjs
CHANGED
|
@@ -196,7 +196,12 @@ function SignIn({
|
|
|
196
196
|
setError(null);
|
|
197
197
|
setIsLoading(true);
|
|
198
198
|
try {
|
|
199
|
-
const result = await client.auth.login({
|
|
199
|
+
const result = await client.auth.login({
|
|
200
|
+
email,
|
|
201
|
+
password,
|
|
202
|
+
org_slug: config.org,
|
|
203
|
+
service_slug: config.service
|
|
204
|
+
});
|
|
200
205
|
if (result.expires_in === MFA_PREAUTH_EXPIRY) {
|
|
201
206
|
setPreauthToken(result.access_token);
|
|
202
207
|
setState("mfa");
|
|
@@ -213,7 +218,7 @@ function SignIn({
|
|
|
213
218
|
setIsLoading(false);
|
|
214
219
|
}
|
|
215
220
|
},
|
|
216
|
-
[client, email, password, setUser, onSuccess, onError]
|
|
221
|
+
[client, email, password, config.org, config.service, setUser, onSuccess, onError]
|
|
217
222
|
);
|
|
218
223
|
const handleMfaSubmit = useCallback(
|
|
219
224
|
async (e) => {
|
|
@@ -321,7 +326,7 @@ function SignIn({
|
|
|
321
326
|
] })
|
|
322
327
|
] });
|
|
323
328
|
}
|
|
324
|
-
function SignUp({ onSuccess, onError, orgSlug, showSignIn = true, className }) {
|
|
329
|
+
function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn = true, className }) {
|
|
325
330
|
const { client } = useAuthOSContext();
|
|
326
331
|
const [email, setEmail] = useState("");
|
|
327
332
|
const [password, setPassword] = useState("");
|
|
@@ -346,7 +351,8 @@ function SignUp({ onSuccess, onError, orgSlug, showSignIn = true, className }) {
|
|
|
346
351
|
await client.auth.register({
|
|
347
352
|
email,
|
|
348
353
|
password,
|
|
349
|
-
org_slug: orgSlug
|
|
354
|
+
org_slug: orgSlug,
|
|
355
|
+
service_slug: serviceSlug
|
|
350
356
|
});
|
|
351
357
|
setIsSuccess(true);
|
|
352
358
|
onSuccess?.();
|
|
@@ -358,7 +364,7 @@ function SignUp({ onSuccess, onError, orgSlug, showSignIn = true, className }) {
|
|
|
358
364
|
setIsLoading(false);
|
|
359
365
|
}
|
|
360
366
|
},
|
|
361
|
-
[client, email, password, confirmPassword, orgSlug, onSuccess, onError]
|
|
367
|
+
[client, email, password, confirmPassword, orgSlug, serviceSlug, onSuccess, onError]
|
|
362
368
|
);
|
|
363
369
|
if (isSuccess) {
|
|
364
370
|
return /* @__PURE__ */ jsx("div", { className, "data-authos-signup": true, "data-state": "success", children: /* @__PURE__ */ jsxs("div", { "data-authos-success": true, children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drmhse/authos-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "React and Next.js adapter for AuthOS authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@drmhse/sso-sdk": "^0.3.
|
|
71
|
+
"@drmhse/sso-sdk": "^0.3.10"
|
|
72
72
|
}
|
|
73
73
|
}
|