@dreadkn1ght123/auth-react 0.2.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/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @dreadkn1ght123/auth-react
2
+
3
+ React 18/19 adapter for the server-owned VVP authentication flow. It checks the
4
+ token-free session endpoint with credentials included, redirects signed-out
5
+ users through `/auth/start`, and submits logout to `/auth/logout`. Login is
6
+ always a browser navigation—never `fetch` or XHR.
7
+
8
+ Install the aligned `0.2.0` release alongside `@dreadkn1ght123/auth-types`,
9
+ `@dreadkn1ght123/auth-core`, and `@dreadkn1ght123/auth-express`. The Express router must be mounted
10
+ on the same public origin. Custom backend route paths must also be supplied via
11
+ the corresponding `meUrl`, `loginUrl`, and `logoutUrl` frontend props/options.
12
+
13
+ ## React + Vite
14
+
15
+ ```tsx
16
+ import {
17
+ VvpAuthBoundary,
18
+ VvpAuthProvider,
19
+ useVvpAuth,
20
+ } from "@dreadkn1ght123/auth-react";
21
+ import { createRoot } from "react-dom/client";
22
+
23
+ function App() {
24
+ const auth = useVvpAuth<{ actor: { displayName: string } }>();
25
+
26
+ return (
27
+ <main>
28
+ <p>Signed in as {auth.session?.actor.displayName}</p>
29
+ <button type="button" onClick={() => void auth.logout()}>
30
+ Sign out
31
+ </button>
32
+ </main>
33
+ );
34
+ }
35
+
36
+ createRoot(document.getElementById("root")!).render(
37
+ <VvpAuthProvider meUrl="/auth/me">
38
+ <VvpAuthBoundary>
39
+ <App />
40
+ </VvpAuthBoundary>
41
+ </VvpAuthProvider>,
42
+ );
43
+ ```
44
+
45
+ The Express application must mount the VVP auth router on the same origin.
46
+ There is no application login page: an unauthenticated boundary performs
47
+ top-level navigation to `/auth/start` and preserves a validated same-origin
48
+ `returnTo`. If iframe escape is blocked, it renders an accessible
49
+ `target="_top"` fallback link.
50
+
51
+ `VvpAuthBoundary` waits for the session check before deciding. A 401 initiates
52
+ login; a network/5xx or malformed response renders retry/error fallback instead
53
+ of redirecting. A short-lived per-tab marker prevents repeated automatic
54
+ redirects to the same `returnTo`; if encountered, the boundary renders the
55
+ manual top-level link. Successful authentication clears that marker.
56
+
57
+ For an imperative transition, use:
58
+
59
+ ```ts
60
+ import { redirectToVvpLogin } from "@dreadkn1ght123/auth-react";
61
+
62
+ redirectToVvpLogin({
63
+ returnTo: window.location.href,
64
+ escapeIframe: true,
65
+ });
66
+ ```
67
+
68
+ The imperative helper returns `{ url, navigated, error? }`. If `navigated` is
69
+ false, render `url` only as an ordinary same-origin link with `target="_top"`;
70
+ prefer `VvpLoginRedirect` when the component should manage this fallback.
71
+
72
+ `logoutFromVvp()` creates a top-targeted POST form. It intentionally leaves the
73
+ browser in the server-managed provider logout and `/auth/signed-out` flow.
74
+ That signed-out page does not automatically run the boundary or restart SSO;
75
+ the user explicitly chooses “sign in again”.
76
+
77
+ `VvpLoginRedirect` is available when only the navigation/fallback behavior is
78
+ needed. Its fallback child may customize presentation, but applications must
79
+ not recreate an SSO provider chooser, construct an IAM authorization URL, or
80
+ send protocol values to React.
@@ -0,0 +1,54 @@
1
+ import { type ReactNode } from "react";
2
+ /** Token-free shape returned directly by the SDK's GET /auth/me route. */
3
+ export interface VvpPublicSession {
4
+ actor: object;
5
+ expiresAt?: number;
6
+ }
7
+ export interface RedirectToVvpLoginOptions {
8
+ returnTo?: string;
9
+ escapeIframe?: boolean;
10
+ loginUrl?: string;
11
+ }
12
+ export interface VvpLoginNavigation {
13
+ url: string;
14
+ navigated: boolean;
15
+ error?: unknown;
16
+ }
17
+ export interface LogoutFromVvpOptions {
18
+ logoutUrl?: string;
19
+ }
20
+ export interface VvpAuthState<TSession = VvpPublicSession> {
21
+ loading: boolean;
22
+ authenticated: boolean;
23
+ session: TSession | null;
24
+ error: Error | null;
25
+ refresh: () => Promise<TSession | null>;
26
+ logout: () => Promise<void>;
27
+ }
28
+ export interface VvpAuthProviderProps {
29
+ children: ReactNode;
30
+ meUrl?: string;
31
+ logoutUrl?: string;
32
+ }
33
+ export interface VvpAuthBoundaryProps {
34
+ children: ReactNode;
35
+ loadingFallback?: ReactNode;
36
+ errorFallback?: ReactNode | ((error: Error, refresh: () => Promise<VvpPublicSession | null>) => ReactNode);
37
+ loginUrl?: string;
38
+ returnTo?: string;
39
+ }
40
+ export interface VvpLoginRedirectProps {
41
+ loginUrl?: string;
42
+ returnTo?: string;
43
+ escapeIframe?: boolean;
44
+ fallbackDelayMs?: number;
45
+ children?: ReactNode;
46
+ }
47
+ export declare function redirectToVvpLogin(options?: RedirectToVvpLoginOptions): VvpLoginNavigation;
48
+ export declare function logoutFromVvp(options?: LogoutFromVvpOptions): Promise<void>;
49
+ export declare function isVvpPublicSession(value: unknown): value is VvpPublicSession;
50
+ export declare function VvpAuthProvider({ children, meUrl, logoutUrl, }: VvpAuthProviderProps): ReactNode;
51
+ export declare function useVvpAuth<TSession = VvpPublicSession>(): VvpAuthState<TSession>;
52
+ export declare function VvpLoginRedirect({ loginUrl, returnTo, escapeIframe, fallbackDelayMs, children, }: VvpLoginRedirectProps): ReactNode;
53
+ export declare function VvpAuthBoundary({ children, loadingFallback, errorFallback, loginUrl, returnTo, }: VvpAuthBoundaryProps): ReactNode;
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EA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oBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC,CAef;AAMD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAc5E;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,KAAsB,EACtB,SAA8B,GAC/B,EAAE,oBAAoB,GAAG,SAAS,CAmElC;AAED,wBAAgB,UAAU,CAAC,QAAQ,GAAG,gBAAgB,KAAK,YAAY,CAAC,QAAQ,CAAC,CAMhF;AA4CD,wBAAgB,gBAAgB,CAAC,EAC/B,QAA4B,EAC5B,QAAQ,EACR,YAAmB,EACnB,eAAqB,EACrB,QAAQ,GACT,EAAE,qBAAqB,GAAG,SAAS,CA0CnC;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,eAAmD,EACnD,aAAa,EACb,QAA4B,EAC5B,QAAQ,GACT,EAAE,oBAAoB,GAAG,SAAS,CA2ClC"}
package/dist/index.js ADDED
@@ -0,0 +1,274 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
3
+ const DEFAULT_ME_URL = "/auth/me";
4
+ const DEFAULT_LOGIN_URL = "/auth/start";
5
+ const DEFAULT_LOGOUT_URL = "/auth/logout";
6
+ const REDIRECT_KEY = "@vvp/auth-react:last-login-redirect";
7
+ const REDIRECT_LOOP_WINDOW_MS = 10_000;
8
+ const AuthContext = createContext(null);
9
+ function browserWindow() {
10
+ return typeof window === "undefined" ? undefined : window;
11
+ }
12
+ function currentReturnTo(currentWindow) {
13
+ try {
14
+ const current = new URL(currentWindow.location.href);
15
+ return `${currentWindow.location.origin}${current.pathname}${current.search}${current.hash}`;
16
+ }
17
+ catch {
18
+ return `${currentWindow.location.origin}/`;
19
+ }
20
+ }
21
+ function localReturnTo(candidate, currentWindow) {
22
+ const fallback = currentReturnTo(currentWindow);
23
+ if (!candidate) {
24
+ return fallback;
25
+ }
26
+ const value = candidate.trim();
27
+ if (!value || value.startsWith("//") || value.includes("\\")) {
28
+ return fallback;
29
+ }
30
+ try {
31
+ const parsed = new URL(value, currentWindow.location.href);
32
+ if (parsed.origin !== currentWindow.location.origin ||
33
+ (parsed.protocol !== "http:" && parsed.protocol !== "https:") ||
34
+ parsed.username ||
35
+ parsed.password) {
36
+ return fallback;
37
+ }
38
+ return parsed.href;
39
+ }
40
+ catch {
41
+ return fallback;
42
+ }
43
+ }
44
+ function localEndpoint(candidate, currentWindow) {
45
+ const endpoint = new URL(candidate, currentWindow.location.origin);
46
+ if (endpoint.origin !== currentWindow.location.origin ||
47
+ (endpoint.protocol !== "http:" && endpoint.protocol !== "https:") ||
48
+ endpoint.username ||
49
+ endpoint.password) {
50
+ throw new Error("VVP auth endpoint must use the current application origin");
51
+ }
52
+ return endpoint;
53
+ }
54
+ function loginTarget(options, currentWindow) {
55
+ const endpoint = localEndpoint(options.loginUrl ?? DEFAULT_LOGIN_URL, currentWindow);
56
+ endpoint.searchParams.set("returnTo", localReturnTo(options.returnTo, currentWindow));
57
+ return endpoint.href;
58
+ }
59
+ export function redirectToVvpLogin(options = {}) {
60
+ const currentWindow = browserWindow();
61
+ if (!currentWindow) {
62
+ throw new Error("redirectToVvpLogin can only be used in a browser");
63
+ }
64
+ const url = loginTarget(options, currentWindow);
65
+ try {
66
+ const destination = options.escapeIframe === false ? currentWindow : (currentWindow.top ?? currentWindow);
67
+ destination.location.assign(url);
68
+ return { url, navigated: true };
69
+ }
70
+ catch (error) {
71
+ return { url, navigated: false, error };
72
+ }
73
+ }
74
+ export async function logoutFromVvp(options = {}) {
75
+ const currentWindow = browserWindow();
76
+ if (!currentWindow || typeof document === "undefined") {
77
+ throw new Error("logoutFromVvp can only be used in a browser");
78
+ }
79
+ const endpoint = localEndpoint(options.logoutUrl ?? DEFAULT_LOGOUT_URL, currentWindow);
80
+ const form = document.createElement("form");
81
+ form.method = "post";
82
+ form.action = endpoint.href;
83
+ form.target = "_top";
84
+ form.hidden = true;
85
+ form.setAttribute("aria-hidden", "true");
86
+ document.body.append(form);
87
+ form.submit();
88
+ }
89
+ function toError(value) {
90
+ return value instanceof Error ? value : new Error("Unable to check the VVP session");
91
+ }
92
+ export function isVvpPublicSession(value) {
93
+ if (!value || typeof value !== "object" || Array.isArray(value))
94
+ return false;
95
+ const record = value;
96
+ if (!record["actor"] ||
97
+ typeof record["actor"] !== "object" ||
98
+ Array.isArray(record["actor"])) {
99
+ return false;
100
+ }
101
+ return (record["expiresAt"] === undefined ||
102
+ (typeof record["expiresAt"] === "number" && Number.isFinite(record["expiresAt"])));
103
+ }
104
+ export function VvpAuthProvider({ children, meUrl = DEFAULT_ME_URL, logoutUrl = DEFAULT_LOGOUT_URL, }) {
105
+ const [loading, setLoading] = useState(true);
106
+ const [session, setSession] = useState(null);
107
+ const [error, setError] = useState(null);
108
+ const requestSequence = useRef(0);
109
+ const refresh = useCallback(async () => {
110
+ const request = ++requestSequence.current;
111
+ setLoading(true);
112
+ setError(null);
113
+ try {
114
+ const response = await fetch(meUrl, {
115
+ method: "GET",
116
+ credentials: "include",
117
+ headers: { accept: "application/json" },
118
+ });
119
+ if (response.status === 401) {
120
+ if (request === requestSequence.current)
121
+ setSession(null);
122
+ return null;
123
+ }
124
+ if (!response.ok) {
125
+ throw new Error(`Unable to check the VVP session (HTTP ${response.status})`);
126
+ }
127
+ const body = await response.json();
128
+ if (!isVvpPublicSession(body)) {
129
+ throw new Error("The VVP session endpoint returned an invalid response");
130
+ }
131
+ const nextSession = body;
132
+ if (request === requestSequence.current)
133
+ setSession(nextSession);
134
+ return nextSession;
135
+ }
136
+ catch (reason) {
137
+ if (request === requestSequence.current) {
138
+ setSession(null);
139
+ setError(toError(reason));
140
+ }
141
+ return null;
142
+ }
143
+ finally {
144
+ if (request === requestSequence.current)
145
+ setLoading(false);
146
+ }
147
+ }, [meUrl]);
148
+ const logout = useCallback(async () => logoutFromVvp({ logoutUrl }), [logoutUrl]);
149
+ useEffect(() => {
150
+ void refresh();
151
+ return () => {
152
+ requestSequence.current += 1;
153
+ };
154
+ }, [refresh]);
155
+ const value = useMemo(() => ({
156
+ loading,
157
+ authenticated: session !== null,
158
+ session,
159
+ error,
160
+ refresh,
161
+ logout,
162
+ }), [error, loading, logout, refresh, session]);
163
+ return _jsx(AuthContext.Provider, { value: value, children: children });
164
+ }
165
+ export function useVvpAuth() {
166
+ const value = useContext(AuthContext);
167
+ if (!value) {
168
+ throw new Error("useVvpAuth must be used inside VvpAuthProvider");
169
+ }
170
+ return value;
171
+ }
172
+ function recentlyRedirected(returnTo) {
173
+ const currentWindow = browserWindow();
174
+ if (!currentWindow)
175
+ return false;
176
+ try {
177
+ const stored = currentWindow.sessionStorage.getItem(REDIRECT_KEY);
178
+ if (!stored)
179
+ return false;
180
+ const marker = JSON.parse(stored);
181
+ return (marker.returnTo === returnTo &&
182
+ typeof marker.at === "number" &&
183
+ Date.now() >= marker.at &&
184
+ Date.now() - marker.at < REDIRECT_LOOP_WINDOW_MS);
185
+ }
186
+ catch {
187
+ return false;
188
+ }
189
+ }
190
+ function rememberRedirect(returnTo) {
191
+ const currentWindow = browserWindow();
192
+ if (!currentWindow)
193
+ return;
194
+ try {
195
+ currentWindow.sessionStorage.setItem(REDIRECT_KEY, JSON.stringify({ returnTo, at: Date.now() }));
196
+ }
197
+ catch {
198
+ // Storage can be unavailable in privacy modes. React's mounted-effect guard
199
+ // still prevents repeated navigation within this page.
200
+ }
201
+ }
202
+ function clearRedirectMarker() {
203
+ const currentWindow = browserWindow();
204
+ if (!currentWindow)
205
+ return;
206
+ try {
207
+ currentWindow.sessionStorage.removeItem(REDIRECT_KEY);
208
+ }
209
+ catch {
210
+ // Authentication succeeded; an unavailable marker no longer matters.
211
+ }
212
+ }
213
+ export function VvpLoginRedirect({ loginUrl = DEFAULT_LOGIN_URL, returnTo, escapeIframe = true, fallbackDelayMs = 750, children, }) {
214
+ const [target, setTarget] = useState(null);
215
+ const [showFallback, setShowFallback] = useState(false);
216
+ const attempted = useRef(false);
217
+ useEffect(() => {
218
+ const currentWindow = browserWindow();
219
+ if (!currentWindow)
220
+ return;
221
+ const safeReturnTo = localReturnTo(returnTo, currentWindow);
222
+ const targetUrl = loginTarget({ returnTo: safeReturnTo, loginUrl }, currentWindow);
223
+ setTarget(targetUrl);
224
+ // React Strict Mode replays this effect. The replay must restore the
225
+ // fallback timer without issuing a second navigation.
226
+ if (attempted.current) {
227
+ const replayTimer = currentWindow.setTimeout(() => setShowFallback(true), fallbackDelayMs);
228
+ return () => currentWindow.clearTimeout(replayTimer);
229
+ }
230
+ attempted.current = true;
231
+ rememberRedirect(safeReturnTo);
232
+ const result = redirectToVvpLogin({ returnTo: safeReturnTo, escapeIframe, loginUrl });
233
+ if (!result.navigated) {
234
+ setShowFallback(true);
235
+ return;
236
+ }
237
+ const timer = currentWindow.setTimeout(() => setShowFallback(true), fallbackDelayMs);
238
+ return () => currentWindow.clearTimeout(timer);
239
+ }, [escapeIframe, fallbackDelayMs, loginUrl, returnTo]);
240
+ if (!showFallback || !target)
241
+ return null;
242
+ return (_jsxs("div", { role: "alert", children: [children ?? _jsx("p", { children: "Automatic sign-in navigation was blocked." }), _jsx("a", { href: target, target: "_top", children: "Continue to sign in" })] }));
243
+ }
244
+ export function VvpAuthBoundary({ children, loadingFallback = _jsx("div", { role: "status", children: "Loading\u2026" }), errorFallback, loginUrl = DEFAULT_LOGIN_URL, returnTo, }) {
245
+ const auth = useVvpAuth();
246
+ const currentWindow = browserWindow();
247
+ const safeReturnTo = currentWindow
248
+ ? localReturnTo(returnTo, currentWindow)
249
+ : (returnTo ?? "/");
250
+ useEffect(() => {
251
+ if (auth.authenticated)
252
+ clearRedirectMarker();
253
+ }, [auth.authenticated]);
254
+ if (auth.loading)
255
+ return loadingFallback;
256
+ if (auth.authenticated)
257
+ return children;
258
+ if (auth.error) {
259
+ if (typeof errorFallback === "function") {
260
+ return errorFallback(auth.error, auth.refresh);
261
+ }
262
+ if (errorFallback !== undefined)
263
+ return errorFallback;
264
+ return (_jsxs("div", { role: "alert", children: [_jsx("p", { children: "Unable to check your session." }), _jsx("button", { type: "button", onClick: () => void auth.refresh(), children: "Try again" })] }));
265
+ }
266
+ if (recentlyRedirected(safeReturnTo)) {
267
+ const target = currentWindow
268
+ ? loginTarget({ loginUrl, returnTo: safeReturnTo }, currentWindow)
269
+ : loginUrl;
270
+ return (_jsxs("div", { role: "alert", children: [_jsx("p", { children: "Sign-in could not be started automatically." }), _jsx("a", { href: target, target: "_top", children: "Continue to sign in" })] }));
271
+ }
272
+ return _jsx(VvpLoginRedirect, { loginUrl: loginUrl, returnTo: safeReturnTo });
273
+ }
274
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AAQf,MAAM,cAAc,GAAG,UAAU,CAAC;AAClC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AACxC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAC1C,MAAM,YAAY,GAAG,qCAAqC,CAAC;AAC3D,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAmDvC,MAAM,WAAW,GAAG,aAAa,CAAwC,IAAI,CAAC,CAAC;AAE/E,SAAS,aAAa;IACpB,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5D,CAAC;AAED,SAAS,eAAe,CAAC,aAAqB;IAC5C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,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AI,CAAC;AAC1E,CAAC"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@dreadkn1ght123/auth-react",
3
+ "version": "0.2.0",
4
+ "description": "React integration for VVP authentication flows",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "sideEffects": false,
19
+ "publishConfig": {
20
+ "access": "public",
21
+ "provenance": true
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^18.0.0 || ^19.0.0",
25
+ "react-dom": "^18.0.0 || ^19.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/react": "^19.0.0",
29
+ "@types/react-dom": "^19.0.0",
30
+ "react": "^19.0.0",
31
+ "react-dom": "^19.0.0"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc -b",
35
+ "typecheck": "tsc -b --pretty false && tsc -p tsconfig.test.json --noEmit --pretty false",
36
+ "test": "vitest run --root ../.. packages/auth-react/src/index.test.tsx"
37
+ }
38
+ }