@reauth-dev/sdk 0.2.0 → 0.3.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.
- package/dist/chunk-5LFJ5PXQ.mjs +1042 -0
- package/dist/index.d.mts +182 -4
- package/dist/index.d.ts +182 -4
- package/dist/index.js +706 -0
- package/dist/index.mjs +1 -1
- package/dist/react/index.d.mts +62 -2
- package/dist/react/index.d.ts +62 -2
- package/dist/react/index.js +848 -11
- package/dist/react/index.mjs +134 -4
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +4 -0
- package/dist/server.mjs +4 -0
- package/dist/{types-BqZzje-y.d.mts → types-DKUKhCNE.d.mts} +165 -3
- package/dist/{types-BqZzje-y.d.ts → types-DKUKhCNE.d.ts} +165 -3
- package/package.json +1 -1
- package/dist/chunk-DMNMTW2C.mjs +0 -336
package/dist/index.mjs
CHANGED
package/dist/react/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ReauthConfig,
|
|
1
|
+
import { R as ReauthConfig, o as User, D as DomainConfig, M as MagicLinkVerifyResult, G as GoogleOAuthStartResult, c as TwitterOAuthStartResult } from '../types-DKUKhCNE.mjs';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
@@ -43,6 +43,66 @@ declare function useAuth(config: UseAuthOptions): {
|
|
|
43
43
|
waitlistPosition: number | null;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
type HeadlessStep = "idle" | "magic_link_sent" | "google_started" | "twitter_started" | "completed";
|
|
47
|
+
type UseHeadlessAuthOptions = {
|
|
48
|
+
domain: string;
|
|
49
|
+
callbackUrl?: string;
|
|
50
|
+
timeout?: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* React hook for headless authentication (custom UI login).
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* function LoginPage() {
|
|
58
|
+
* const {
|
|
59
|
+
* requestMagicLink,
|
|
60
|
+
* verifyMagicLink,
|
|
61
|
+
* startGoogleOAuth,
|
|
62
|
+
* loading,
|
|
63
|
+
* error,
|
|
64
|
+
* step,
|
|
65
|
+
* } = useHeadlessAuth({
|
|
66
|
+
* domain: 'yourdomain.com',
|
|
67
|
+
* callbackUrl: 'https://app.yourdomain.com/auth/verify',
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* if (step === 'magic_link_sent') {
|
|
71
|
+
* return <p>Check your email for a magic link!</p>;
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* if (step === 'completed') {
|
|
75
|
+
* return <p>Authenticated!</p>;
|
|
76
|
+
* }
|
|
77
|
+
*
|
|
78
|
+
* return (
|
|
79
|
+
* <div>
|
|
80
|
+
* <button onClick={() => requestMagicLink('user@example.com')}>
|
|
81
|
+
* Send Magic Link
|
|
82
|
+
* </button>
|
|
83
|
+
* <button onClick={startGoogleOAuth}>
|
|
84
|
+
* Sign in with Google
|
|
85
|
+
* </button>
|
|
86
|
+
* {error && <p>{error}</p>}
|
|
87
|
+
* </div>
|
|
88
|
+
* );
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function useHeadlessAuth(options: UseHeadlessAuthOptions): {
|
|
93
|
+
getConfig: () => Promise<DomainConfig>;
|
|
94
|
+
requestMagicLink: (email: string) => Promise<void>;
|
|
95
|
+
verifyMagicLink: (token: string) => Promise<MagicLinkVerifyResult>;
|
|
96
|
+
startGoogleOAuth: () => Promise<GoogleOAuthStartResult>;
|
|
97
|
+
startTwitterOAuth: () => Promise<TwitterOAuthStartResult>;
|
|
98
|
+
reset: () => void;
|
|
99
|
+
loading: boolean;
|
|
100
|
+
error: string | null;
|
|
101
|
+
step: HeadlessStep;
|
|
102
|
+
config: DomainConfig | null;
|
|
103
|
+
verifyResult: MagicLinkVerifyResult | null;
|
|
104
|
+
};
|
|
105
|
+
|
|
46
106
|
type AuthContextType = {
|
|
47
107
|
user: User | null;
|
|
48
108
|
loading: boolean;
|
|
@@ -130,4 +190,4 @@ type ProtectedRouteProps = {
|
|
|
130
190
|
*/
|
|
131
191
|
declare function ProtectedRoute({ children, fallback, onUnauthenticated, onWaitlist, }: ProtectedRouteProps): react_jsx_runtime.JSX.Element | null;
|
|
132
192
|
|
|
133
|
-
export { AuthProvider, ProtectedRoute, type UseAuthOptions, useAuth, useAuthContext };
|
|
193
|
+
export { AuthProvider, ProtectedRoute, type UseAuthOptions, type UseHeadlessAuthOptions, useAuth, useAuthContext, useHeadlessAuth };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ReauthConfig,
|
|
1
|
+
import { R as ReauthConfig, o as User, D as DomainConfig, M as MagicLinkVerifyResult, G as GoogleOAuthStartResult, c as TwitterOAuthStartResult } from '../types-DKUKhCNE.js';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
@@ -43,6 +43,66 @@ declare function useAuth(config: UseAuthOptions): {
|
|
|
43
43
|
waitlistPosition: number | null;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
type HeadlessStep = "idle" | "magic_link_sent" | "google_started" | "twitter_started" | "completed";
|
|
47
|
+
type UseHeadlessAuthOptions = {
|
|
48
|
+
domain: string;
|
|
49
|
+
callbackUrl?: string;
|
|
50
|
+
timeout?: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* React hook for headless authentication (custom UI login).
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* function LoginPage() {
|
|
58
|
+
* const {
|
|
59
|
+
* requestMagicLink,
|
|
60
|
+
* verifyMagicLink,
|
|
61
|
+
* startGoogleOAuth,
|
|
62
|
+
* loading,
|
|
63
|
+
* error,
|
|
64
|
+
* step,
|
|
65
|
+
* } = useHeadlessAuth({
|
|
66
|
+
* domain: 'yourdomain.com',
|
|
67
|
+
* callbackUrl: 'https://app.yourdomain.com/auth/verify',
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* if (step === 'magic_link_sent') {
|
|
71
|
+
* return <p>Check your email for a magic link!</p>;
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* if (step === 'completed') {
|
|
75
|
+
* return <p>Authenticated!</p>;
|
|
76
|
+
* }
|
|
77
|
+
*
|
|
78
|
+
* return (
|
|
79
|
+
* <div>
|
|
80
|
+
* <button onClick={() => requestMagicLink('user@example.com')}>
|
|
81
|
+
* Send Magic Link
|
|
82
|
+
* </button>
|
|
83
|
+
* <button onClick={startGoogleOAuth}>
|
|
84
|
+
* Sign in with Google
|
|
85
|
+
* </button>
|
|
86
|
+
* {error && <p>{error}</p>}
|
|
87
|
+
* </div>
|
|
88
|
+
* );
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function useHeadlessAuth(options: UseHeadlessAuthOptions): {
|
|
93
|
+
getConfig: () => Promise<DomainConfig>;
|
|
94
|
+
requestMagicLink: (email: string) => Promise<void>;
|
|
95
|
+
verifyMagicLink: (token: string) => Promise<MagicLinkVerifyResult>;
|
|
96
|
+
startGoogleOAuth: () => Promise<GoogleOAuthStartResult>;
|
|
97
|
+
startTwitterOAuth: () => Promise<TwitterOAuthStartResult>;
|
|
98
|
+
reset: () => void;
|
|
99
|
+
loading: boolean;
|
|
100
|
+
error: string | null;
|
|
101
|
+
step: HeadlessStep;
|
|
102
|
+
config: DomainConfig | null;
|
|
103
|
+
verifyResult: MagicLinkVerifyResult | null;
|
|
104
|
+
};
|
|
105
|
+
|
|
46
106
|
type AuthContextType = {
|
|
47
107
|
user: User | null;
|
|
48
108
|
loading: boolean;
|
|
@@ -130,4 +190,4 @@ type ProtectedRouteProps = {
|
|
|
130
190
|
*/
|
|
131
191
|
declare function ProtectedRoute({ children, fallback, onUnauthenticated, onWaitlist, }: ProtectedRouteProps): react_jsx_runtime.JSX.Element | null;
|
|
132
192
|
|
|
133
|
-
export { AuthProvider, ProtectedRoute, type UseAuthOptions, useAuth, useAuthContext };
|
|
193
|
+
export { AuthProvider, ProtectedRoute, type UseAuthOptions, type UseHeadlessAuthOptions, useAuth, useAuthContext, useHeadlessAuth };
|