@civic/auth 0.0.1-beta.28 → 0.0.1-beta.29
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/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-lint.log +14 -0
- package/.turbo/turbo-test.log +1678 -0
- package/civic-auth-0.0.1-beta.15.tgz +0 -0
- package/civic-auth-0.0.1-beta.17.tgz +0 -0
- package/dist/AuthProvider-BYZ8w92b.d.mts +15 -0
- package/dist/AuthProvider-BgOwv9h8.d.ts +15 -0
- package/dist/AuthProvider-Bj_Prt1x.d.ts +21 -0
- package/dist/AuthProvider-DUAoX4G9.d.mts +21 -0
- package/dist/UserProvider-BA2uflVB.d.ts +16 -0
- package/dist/UserProvider-Bl3j1PUO.d.mts +16 -0
- package/dist/UserProvider-CMLaYOUD.d.ts +16 -0
- package/dist/UserProvider-Cbm8MZkJ.d.mts +16 -0
- package/dist/chunk-4PLCDPEN.mjs +599 -0
- package/dist/chunk-4PLCDPEN.mjs.map +1 -0
- package/dist/chunk-5UQQYXCX.js +1 -0
- package/dist/chunk-5UQQYXCX.js.map +1 -0
- package/dist/chunk-63YGK3A7.mjs +223 -0
- package/dist/chunk-63YGK3A7.mjs.map +1 -0
- package/dist/chunk-6RFRDWIP.js +223 -0
- package/dist/chunk-6RFRDWIP.js.map +1 -0
- package/dist/chunk-7K3QN2AT.js +599 -0
- package/dist/chunk-7K3QN2AT.js.map +1 -0
- package/dist/chunk-AM2Y662I.js +601 -0
- package/dist/chunk-AM2Y662I.js.map +1 -0
- package/dist/chunk-AP4627CS.mjs +223 -0
- package/dist/chunk-AP4627CS.mjs.map +1 -0
- package/dist/chunk-CRTRMMJ7.js +59 -0
- package/dist/chunk-CRTRMMJ7.js.map +1 -0
- package/dist/chunk-CTVJJBBA.js +118 -0
- package/dist/chunk-CTVJJBBA.js.map +1 -0
- package/dist/chunk-EKLYHP2D.mjs +711 -0
- package/dist/chunk-EKLYHP2D.mjs.map +1 -0
- package/dist/chunk-FHRZSX3C.js +710 -0
- package/dist/chunk-FHRZSX3C.js.map +1 -0
- package/dist/chunk-GB3H3I47.js +711 -0
- package/dist/chunk-GB3H3I47.js.map +1 -0
- package/dist/chunk-JDZPCA3P.js +173 -0
- package/dist/chunk-JDZPCA3P.js.map +1 -0
- package/dist/chunk-JEOPLLWO.js +223 -0
- package/dist/chunk-JEOPLLWO.js.map +1 -0
- package/dist/chunk-MK7557NR.mjs +118 -0
- package/dist/chunk-MK7557NR.mjs.map +1 -0
- package/dist/chunk-NLRREFOX.mjs +710 -0
- package/dist/chunk-NLRREFOX.mjs.map +1 -0
- package/dist/chunk-O3WGNLRO.mjs +173 -0
- package/dist/chunk-O3WGNLRO.mjs.map +1 -0
- package/dist/chunk-OXXUQ36U.mjs +283 -0
- package/dist/chunk-OXXUQ36U.mjs.map +1 -0
- package/dist/chunk-PMJAV4JJ.mjs +1 -0
- package/dist/chunk-PMJAV4JJ.mjs.map +1 -0
- package/dist/chunk-Q7DSPTUG.mjs +601 -0
- package/dist/chunk-Q7DSPTUG.mjs.map +1 -0
- package/dist/chunk-RGHW4PYM.mjs +59 -0
- package/dist/chunk-RGHW4PYM.mjs.map +1 -0
- package/dist/chunk-TH6FI2XI.js +283 -0
- package/dist/chunk-TH6FI2XI.js.map +1 -0
- package/dist/cjs/src/browser/storage.d.ts +2 -2
- package/dist/cjs/src/browser/storage.d.ts.map +1 -1
- package/dist/cjs/src/browser/storage.js +3 -3
- package/dist/cjs/src/browser/storage.js.map +1 -1
- package/dist/cjs/src/nextjs/GetUser.d.ts +1 -1
- package/dist/cjs/src/nextjs/GetUser.d.ts.map +1 -1
- package/dist/cjs/src/nextjs/GetUser.js +3 -3
- package/dist/cjs/src/nextjs/GetUser.js.map +1 -1
- package/dist/cjs/src/nextjs/config.d.ts.map +1 -1
- package/dist/cjs/src/nextjs/config.js +0 -2
- package/dist/cjs/src/nextjs/config.js.map +1 -1
- package/dist/cjs/src/nextjs/cookies.d.ts +4 -4
- package/dist/cjs/src/nextjs/cookies.d.ts.map +1 -1
- package/dist/cjs/src/nextjs/cookies.js +14 -11
- package/dist/cjs/src/nextjs/cookies.js.map +1 -1
- package/dist/cjs/src/nextjs/routeHandler.d.ts.map +1 -1
- package/dist/cjs/src/nextjs/routeHandler.js +1 -5
- package/dist/cjs/src/nextjs/routeHandler.js.map +1 -1
- package/dist/cjs/src/reactjs/hooks/index.d.ts +0 -1
- package/dist/cjs/src/reactjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/src/reactjs/hooks/index.js +1 -3
- package/dist/cjs/src/reactjs/hooks/index.js.map +1 -1
- package/dist/cjs/src/server/ServerAuthenticationResolver.d.ts.map +1 -1
- package/dist/cjs/src/server/ServerAuthenticationResolver.js +2 -7
- package/dist/cjs/src/server/ServerAuthenticationResolver.js.map +1 -1
- package/dist/cjs/src/server/login.d.ts +1 -1
- package/dist/cjs/src/server/login.d.ts.map +1 -1
- package/dist/cjs/src/server/login.js +2 -2
- package/dist/cjs/src/server/login.js.map +1 -1
- package/dist/cjs/src/services/AuthenticationService.d.ts.map +1 -1
- package/dist/cjs/src/services/AuthenticationService.js +6 -16
- package/dist/cjs/src/services/AuthenticationService.js.map +1 -1
- package/dist/cjs/src/shared/components/CivicAuthIframeContainer.d.ts.map +1 -1
- package/dist/cjs/src/shared/components/CivicAuthIframeContainer.js +0 -2
- package/dist/cjs/src/shared/components/CivicAuthIframeContainer.js.map +1 -1
- package/dist/cjs/src/shared/lib/GenericAuthenticationRefresher.d.ts.map +1 -1
- package/dist/cjs/src/shared/lib/GenericAuthenticationRefresher.js +2 -6
- package/dist/cjs/src/shared/lib/GenericAuthenticationRefresher.js.map +1 -1
- package/dist/cjs/src/shared/lib/UserSession.d.ts +4 -4
- package/dist/cjs/src/shared/lib/UserSession.d.ts.map +1 -1
- package/dist/cjs/src/shared/lib/UserSession.js +4 -4
- package/dist/cjs/src/shared/lib/UserSession.js.map +1 -1
- package/dist/cjs/src/shared/lib/session.js +1 -1
- package/dist/cjs/src/shared/lib/session.js.map +1 -1
- package/dist/cjs/src/shared/lib/storage.d.ts +2 -2
- package/dist/cjs/src/shared/lib/storage.d.ts.map +1 -1
- package/dist/cjs/src/shared/lib/storage.js.map +1 -1
- package/dist/cjs/src/shared/lib/util.d.ts +4 -4
- package/dist/cjs/src/shared/lib/util.d.ts.map +1 -1
- package/dist/cjs/src/shared/lib/util.js +16 -15
- package/dist/cjs/src/shared/lib/util.js.map +1 -1
- package/dist/cjs/src/types.d.ts +2 -2
- package/dist/cjs/src/types.d.ts.map +1 -1
- package/dist/cjs/src/types.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/browser/storage.d.ts +2 -2
- package/dist/esm/src/browser/storage.d.ts.map +1 -1
- package/dist/esm/src/browser/storage.js +3 -3
- package/dist/esm/src/browser/storage.js.map +1 -1
- package/dist/esm/src/nextjs/GetUser.d.ts +1 -1
- package/dist/esm/src/nextjs/GetUser.d.ts.map +1 -1
- package/dist/esm/src/nextjs/GetUser.js +3 -3
- package/dist/esm/src/nextjs/GetUser.js.map +1 -1
- package/dist/esm/src/nextjs/config.d.ts.map +1 -1
- package/dist/esm/src/nextjs/config.js +0 -2
- package/dist/esm/src/nextjs/config.js.map +1 -1
- package/dist/esm/src/nextjs/cookies.d.ts +4 -4
- package/dist/esm/src/nextjs/cookies.d.ts.map +1 -1
- package/dist/esm/src/nextjs/cookies.js +14 -11
- package/dist/esm/src/nextjs/cookies.js.map +1 -1
- package/dist/esm/src/nextjs/routeHandler.d.ts.map +1 -1
- package/dist/esm/src/nextjs/routeHandler.js +1 -5
- package/dist/esm/src/nextjs/routeHandler.js.map +1 -1
- package/dist/esm/src/reactjs/hooks/index.d.ts +0 -1
- package/dist/esm/src/reactjs/hooks/index.d.ts.map +1 -1
- package/dist/esm/src/reactjs/hooks/index.js +0 -1
- package/dist/esm/src/reactjs/hooks/index.js.map +1 -1
- package/dist/esm/src/server/ServerAuthenticationResolver.d.ts.map +1 -1
- package/dist/esm/src/server/ServerAuthenticationResolver.js +2 -7
- package/dist/esm/src/server/ServerAuthenticationResolver.js.map +1 -1
- package/dist/esm/src/server/login.d.ts +1 -1
- package/dist/esm/src/server/login.d.ts.map +1 -1
- package/dist/esm/src/server/login.js +2 -2
- package/dist/esm/src/server/login.js.map +1 -1
- package/dist/esm/src/services/AuthenticationService.d.ts.map +1 -1
- package/dist/esm/src/services/AuthenticationService.js +6 -16
- package/dist/esm/src/services/AuthenticationService.js.map +1 -1
- package/dist/esm/src/shared/components/CivicAuthIframeContainer.d.ts.map +1 -1
- package/dist/esm/src/shared/components/CivicAuthIframeContainer.js +0 -2
- package/dist/esm/src/shared/components/CivicAuthIframeContainer.js.map +1 -1
- package/dist/esm/src/shared/lib/GenericAuthenticationRefresher.d.ts.map +1 -1
- package/dist/esm/src/shared/lib/GenericAuthenticationRefresher.js +2 -6
- package/dist/esm/src/shared/lib/GenericAuthenticationRefresher.js.map +1 -1
- package/dist/esm/src/shared/lib/UserSession.d.ts +4 -4
- package/dist/esm/src/shared/lib/UserSession.d.ts.map +1 -1
- package/dist/esm/src/shared/lib/UserSession.js +4 -4
- package/dist/esm/src/shared/lib/UserSession.js.map +1 -1
- package/dist/esm/src/shared/lib/session.js +1 -1
- package/dist/esm/src/shared/lib/session.js.map +1 -1
- package/dist/esm/src/shared/lib/storage.d.ts +2 -2
- package/dist/esm/src/shared/lib/storage.d.ts.map +1 -1
- package/dist/esm/src/shared/lib/storage.js.map +1 -1
- package/dist/esm/src/shared/lib/util.d.ts +4 -4
- package/dist/esm/src/shared/lib/util.d.ts.map +1 -1
- package/dist/esm/src/shared/lib/util.js +16 -15
- package/dist/esm/src/shared/lib/util.js.map +1 -1
- package/dist/esm/src/types.d.ts +2 -2
- package/dist/esm/src/types.d.ts.map +1 -1
- package/dist/esm/src/types.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/index.css +340 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/dist/nextjs/client.css +340 -0
- package/dist/nextjs/client.css.map +1 -0
- package/dist/nextjs/client.d.mts +10 -0
- package/dist/nextjs/client.d.ts +10 -0
- package/dist/nextjs/client.js +185 -0
- package/dist/nextjs/client.js.map +1 -0
- package/dist/nextjs/client.mjs +185 -0
- package/dist/nextjs/client.mjs.map +1 -0
- package/dist/nextjs.d.mts +267 -0
- package/dist/nextjs.d.ts +267 -0
- package/dist/nextjs.js +315 -0
- package/dist/nextjs.js.map +1 -0
- package/dist/nextjs.mjs +315 -0
- package/dist/nextjs.mjs.map +1 -0
- package/dist/react.d.mts +65 -0
- package/dist/react.d.ts +65 -0
- package/dist/react.js +226 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +226 -0
- package/dist/react.mjs.map +1 -0
- package/dist/server.d.mts +35 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.js +20 -0
- package/dist/server.js.map +1 -0
- package/dist/server.mjs +20 -0
- package/dist/server.mjs.map +1 -0
- package/dist/src/shared/components/LoadingIcon.d.ts.map +1 -1
- package/dist/src/shared/components/LoadingIcon.js +0 -6
- package/dist/src/shared/components/LoadingIcon.js.map +1 -1
- package/dist/storage-ANmRwpZ3.d.ts +25 -0
- package/dist/storage-B2eAQNdv.d.ts +25 -0
- package/dist/storage-BJPUpxhm.d.mts +25 -0
- package/dist/storage-BJyqsZwC.d.mts +25 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types-Bqm9OCZN.d.mts +22 -0
- package/dist/types-Bqm9OCZN.d.ts +22 -0
- package/dist/types-BxAubCqO.d.mts +58 -0
- package/dist/types-BxAubCqO.d.ts +58 -0
- package/dist/types-DOfl9w7j.d.mts +23 -0
- package/dist/types-DOfl9w7j.d.ts +23 -0
- package/dist/types-HdCjGldB.d.mts +58 -0
- package/dist/types-HdCjGldB.d.ts +58 -0
- package/package.json +1 -1
- package/src/browser/storage.ts +3 -3
- package/src/nextjs/GetUser.ts +3 -3
- package/src/nextjs/config.ts +0 -2
- package/src/nextjs/cookies.ts +14 -18
- package/src/nextjs/routeHandler.ts +1 -5
- package/src/reactjs/hooks/index.ts +0 -1
- package/src/server/ServerAuthenticationResolver.ts +2 -7
- package/src/server/login.ts +2 -2
- package/src/services/AuthenticationService.ts +6 -16
- package/src/shared/components/CivicAuthIframeContainer.tsx +0 -4
- package/src/shared/lib/GenericAuthenticationRefresher.ts +3 -8
- package/src/shared/lib/UserSession.ts +6 -6
- package/src/shared/lib/session.ts +1 -1
- package/src/shared/lib/storage.ts +2 -2
- package/src/shared/lib/util.ts +21 -18
- package/src/types.ts +2 -2
- package/test/unit/nextjs/getUser.test.ts +8 -8
- package/test/unit/publicApi/__snapshots__/apiSnapshot.test.ts.snap +0 -7
- package/test/unit/server/login.test.ts +20 -18
- package/test/unit/server/session.test.ts +4 -4
- package/test/unit/services/AuthenticationService.test.ts +3 -3
- package/test/unit/services/ServerAuthenticationResolver.test.ts +11 -6
- package/test/unit/shared/GenericAuthenticationRefresher.test.ts +4 -4
- package/test/unit/shared/UserSession.test.ts +6 -6
- package/test/unit/shared/storage.test.ts +6 -6
- package/dist/cjs/src/nextjs/client/index.d.ts +0 -2
- package/dist/cjs/src/nextjs/client/index.d.ts.map +0 -1
- package/dist/cjs/src/nextjs/client/index.js +0 -6
- package/dist/cjs/src/nextjs/client/index.js.map +0 -1
- package/dist/cjs/src/styles.css +0 -387
- package/dist/esm/src/nextjs/client/index.d.ts +0 -2
- package/dist/esm/src/nextjs/client/index.d.ts.map +0 -1
- package/dist/esm/src/nextjs/client/index.js +0 -2
- package/dist/esm/src/nextjs/client/index.js.map +0 -1
- package/dist/esm/src/styles.css +0 -387
- package/dist/src/nextjs/client/index.d.ts +0 -2
- package/dist/src/nextjs/client/index.d.ts.map +0 -1
- package/dist/src/nextjs/client/index.js +0 -2
- package/dist/src/nextjs/client/index.js.map +0 -1
- package/dist/test/unit/nextjs/routeHandler.test.d.ts +0 -2
- package/dist/test/unit/nextjs/routeHandler.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/routeHandler.test.js +0 -271
- package/dist/test/unit/nextjs/routeHandler.test.js.map +0 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import "../chunk-PMJAV4JJ.mjs";
|
|
2
|
+
import {
|
|
3
|
+
AuthProvider,
|
|
4
|
+
UserProvider
|
|
5
|
+
} from "../chunk-EKLYHP2D.mjs";
|
|
6
|
+
import {
|
|
7
|
+
NextjsClientStorage,
|
|
8
|
+
resolveAuthConfig,
|
|
9
|
+
resolveCallbackUrl
|
|
10
|
+
} from "../chunk-OXXUQ36U.mjs";
|
|
11
|
+
import "../chunk-63YGK3A7.mjs";
|
|
12
|
+
import {
|
|
13
|
+
ConfidentialClientPKCEConsumer
|
|
14
|
+
} from "../chunk-Q7DSPTUG.mjs";
|
|
15
|
+
import {
|
|
16
|
+
__async,
|
|
17
|
+
__objRest,
|
|
18
|
+
__spreadProps,
|
|
19
|
+
__spreadValues
|
|
20
|
+
} from "../chunk-RGHW4PYM.mjs";
|
|
21
|
+
|
|
22
|
+
// src/nextjs/providers/NextAuthProvider.tsx
|
|
23
|
+
import { useEffect as useEffect3, useState } from "react";
|
|
24
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
25
|
+
|
|
26
|
+
// src/nextjs/hooks/useUserCookie.ts
|
|
27
|
+
import { useEffect, useRef } from "react";
|
|
28
|
+
import { useRouter } from "next/navigation.js";
|
|
29
|
+
import { useQuery } from "@tanstack/react-query";
|
|
30
|
+
|
|
31
|
+
// src/lib/cookies.ts
|
|
32
|
+
var getWindowCookieValue = ({
|
|
33
|
+
key,
|
|
34
|
+
window: window2,
|
|
35
|
+
parseJson = false
|
|
36
|
+
}) => {
|
|
37
|
+
const cookie = window2.document.cookie;
|
|
38
|
+
if (!cookie) return null;
|
|
39
|
+
const cookies = cookie.split(";");
|
|
40
|
+
for (const c of cookies) {
|
|
41
|
+
const [name, value] = c.trim().split("=");
|
|
42
|
+
if (value && name === key) {
|
|
43
|
+
try {
|
|
44
|
+
const decodeURIComponentValue = decodeURIComponent(value);
|
|
45
|
+
return parseJson === true ? JSON.parse(decodeURIComponentValue) : decodeURIComponentValue;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/nextjs/hooks/useUserCookie.ts
|
|
55
|
+
var getUserFromCookie = () => {
|
|
56
|
+
const userCookie = getWindowCookieValue({
|
|
57
|
+
key: "user" /* USER */,
|
|
58
|
+
window: globalThis.window,
|
|
59
|
+
parseJson: true
|
|
60
|
+
});
|
|
61
|
+
return userCookie;
|
|
62
|
+
};
|
|
63
|
+
var useUserCookie = () => {
|
|
64
|
+
const hasRunRef = useRef(false);
|
|
65
|
+
const router = useRouter();
|
|
66
|
+
const { data: user } = useQuery({
|
|
67
|
+
queryKey: ["user"],
|
|
68
|
+
queryFn: () => getUserFromCookie(),
|
|
69
|
+
refetchInterval: 2e3,
|
|
70
|
+
refetchIntervalInBackground: true,
|
|
71
|
+
enabled: !hasRunRef.current,
|
|
72
|
+
refetchOnWindowFocus: true
|
|
73
|
+
});
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (user) {
|
|
76
|
+
if (!hasRunRef.current) {
|
|
77
|
+
hasRunRef.current = true;
|
|
78
|
+
router.refresh();
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
hasRunRef.current = false;
|
|
82
|
+
}
|
|
83
|
+
}, [user, router]);
|
|
84
|
+
return user != null ? user : null;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// src/nextjs/hooks/useTokenCookie.ts
|
|
88
|
+
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
89
|
+
import { useRouter as useRouter2 } from "next/navigation.js";
|
|
90
|
+
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
91
|
+
var getTokenFromCookie = (tokenName) => {
|
|
92
|
+
return getWindowCookieValue({
|
|
93
|
+
key: tokenName,
|
|
94
|
+
window: globalThis.window,
|
|
95
|
+
parseJson: false
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
var useTokenCookie = (tokenName) => {
|
|
99
|
+
const hasRunRef = useRef2(false);
|
|
100
|
+
const router = useRouter2();
|
|
101
|
+
const { data: token } = useQuery2({
|
|
102
|
+
queryKey: ["token", tokenName],
|
|
103
|
+
queryFn: () => getTokenFromCookie(tokenName) || null,
|
|
104
|
+
refetchInterval: 2e3,
|
|
105
|
+
refetchIntervalInBackground: true,
|
|
106
|
+
enabled: !hasRunRef.current,
|
|
107
|
+
refetchOnWindowFocus: true
|
|
108
|
+
});
|
|
109
|
+
useEffect2(() => {
|
|
110
|
+
if (token) {
|
|
111
|
+
if (!hasRunRef.current) {
|
|
112
|
+
hasRunRef.current = true;
|
|
113
|
+
router.refresh();
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
hasRunRef.current = false;
|
|
117
|
+
}
|
|
118
|
+
}, [token, router]);
|
|
119
|
+
return token != null ? token : null;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/nextjs/providers/NextAuthProvider.tsx
|
|
123
|
+
import { jsx } from "react/jsx-runtime";
|
|
124
|
+
var queryClient = new QueryClient();
|
|
125
|
+
var CivicNextAuthProviderInternal = (_a) => {
|
|
126
|
+
var _b = _a, {
|
|
127
|
+
children
|
|
128
|
+
} = _b, props = __objRest(_b, [
|
|
129
|
+
"children"
|
|
130
|
+
]);
|
|
131
|
+
const [redirectUrl, setRedirectUrl] = useState("");
|
|
132
|
+
const resolvedConfig = resolveAuthConfig();
|
|
133
|
+
const { clientId, oauthServer, callbackUrl, challengeUrl, logoutUrl } = resolvedConfig;
|
|
134
|
+
useEffect3(() => {
|
|
135
|
+
if (typeof globalThis.window !== "undefined") {
|
|
136
|
+
const appUrl = globalThis.window.location.origin;
|
|
137
|
+
setRedirectUrl(resolveCallbackUrl(resolvedConfig, appUrl));
|
|
138
|
+
}
|
|
139
|
+
}, [callbackUrl, resolvedConfig]);
|
|
140
|
+
const user = useUserCookie();
|
|
141
|
+
const idToken = useTokenCookie("id_token" /* ID_TOKEN */);
|
|
142
|
+
const combinedUser = user ? __spreadProps(__spreadValues({}, user || {}), { idToken }) : null;
|
|
143
|
+
const sessionData = __spreadValues({
|
|
144
|
+
authenticated: !!user
|
|
145
|
+
}, idToken ? { idToken } : {});
|
|
146
|
+
const signOut = () => __async(void 0, null, function* () {
|
|
147
|
+
if (props.onSignOut) {
|
|
148
|
+
yield props.onSignOut();
|
|
149
|
+
}
|
|
150
|
+
const appUrl = globalThis.window.location.origin;
|
|
151
|
+
window.location.href = `${logoutUrl}?appUrl=${appUrl}`;
|
|
152
|
+
return;
|
|
153
|
+
});
|
|
154
|
+
return /* @__PURE__ */ jsx(
|
|
155
|
+
AuthProvider,
|
|
156
|
+
__spreadProps(__spreadValues({}, props), {
|
|
157
|
+
redirectUrl,
|
|
158
|
+
config: { oauthServer },
|
|
159
|
+
clientId,
|
|
160
|
+
pkceConsumer: new ConfidentialClientPKCEConsumer(challengeUrl),
|
|
161
|
+
sessionData,
|
|
162
|
+
children: /* @__PURE__ */ jsx(
|
|
163
|
+
UserProvider,
|
|
164
|
+
{
|
|
165
|
+
storage: new NextjsClientStorage(),
|
|
166
|
+
user: combinedUser,
|
|
167
|
+
signOut,
|
|
168
|
+
children
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
})
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
var CivicNextAuthProvider = (_a) => {
|
|
175
|
+
var _b = _a, {
|
|
176
|
+
children
|
|
177
|
+
} = _b, props = __objRest(_b, [
|
|
178
|
+
"children"
|
|
179
|
+
]);
|
|
180
|
+
return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(CivicNextAuthProviderInternal, __spreadProps(__spreadValues({}, props), { children })) });
|
|
181
|
+
};
|
|
182
|
+
export {
|
|
183
|
+
CivicNextAuthProvider as CivicAuthProvider
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/nextjs/providers/NextAuthProvider.tsx","../../src/nextjs/hooks/useUserCookie.ts","../../src/lib/cookies.ts","../../src/nextjs/hooks/useTokenCookie.ts"],"sourcesContent":["\"use client\";\n/**\n * A very small context provider for the user object - it takes the user object from the cookie and provides it to the app.\n */\nimport { useEffect, useState } from \"react\";\nimport { AuthProvider, AuthProviderProps } from \"@/shared/AuthProvider.js\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { resolveAuthConfig } from \"@/nextjs/config.js\";\nimport { resolveCallbackUrl } from \"@/nextjs/utils.js\";\n\n// adding the styles import here to be added to the bundle\nimport \"@/styles.css\";\nimport { ConfidentialClientPKCEConsumer } from \"@/services/PKCE.js\";\nimport { NextjsClientStorage } from \"@/nextjs/cookies\";\nimport { UserProvider } from \"@/shared/UserProvider\";\nimport { useUserCookie } from \"../hooks/useUserCookie\";\nimport { OAuthTokens } from \"@/shared/types\";\nimport { useTokenCookie } from \"../hooks/useTokenCookie\";\nimport { User } from \"@/types\";\n\nconst queryClient = new QueryClient();\n\ntype NextCivicAuthProviderProps = Omit<AuthProviderProps, \"clientId\">;\n\nconst CivicNextAuthProviderInternal = ({\n children,\n ...props\n}: NextCivicAuthProviderProps) => {\n const [redirectUrl, setRedirectUrl] = useState<string>(\"\");\n const resolvedConfig = resolveAuthConfig();\n const { clientId, oauthServer, callbackUrl, challengeUrl, logoutUrl } =\n resolvedConfig;\n\n useEffect(() => {\n if (typeof globalThis.window !== \"undefined\") {\n const appUrl = globalThis.window.location.origin;\n setRedirectUrl(resolveCallbackUrl(resolvedConfig, appUrl));\n }\n }, [callbackUrl, resolvedConfig]);\n\n const user = useUserCookie();\n const idToken = useTokenCookie(OAuthTokens.ID_TOKEN);\n const combinedUser = user ? ({ ...(user || {}), idToken } as User) : null;\n const sessionData = {\n authenticated: !!user,\n ...(idToken ? { idToken } : {}),\n };\n const signOut = async (): Promise<void> => {\n if (props.onSignOut) {\n await props.onSignOut();\n }\n const appUrl = globalThis.window.location.origin;\n window.location.href = `${logoutUrl}?appUrl=${appUrl}`;\n return;\n };\n return (\n <AuthProvider\n {...props}\n redirectUrl={redirectUrl}\n config={{ oauthServer }}\n clientId={clientId}\n pkceConsumer={new ConfidentialClientPKCEConsumer(challengeUrl)}\n sessionData={sessionData}\n >\n <UserProvider\n storage={new NextjsClientStorage()}\n user={combinedUser}\n signOut={signOut}\n >\n {children}\n </UserProvider>\n </AuthProvider>\n );\n};\n\nconst CivicNextAuthProvider = ({\n children,\n ...props\n}: NextCivicAuthProviderProps) => {\n return (\n <QueryClientProvider client={queryClient}>\n <CivicNextAuthProviderInternal {...props}>\n {children}\n </CivicNextAuthProviderInternal>\n </QueryClientProvider>\n );\n};\n\nexport { CivicNextAuthProvider, type NextCivicAuthProviderProps };\n","\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { useRouter } from \"next/navigation.js\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { getWindowCookieValue } from \"@/lib/cookies.js\";\nimport { EmptyObject, User } from \"@/types\";\nimport { UserStorage } from \"@/shared/types\";\n\nconst getUserFromCookie = () => {\n const userCookie = getWindowCookieValue({\n key: UserStorage.USER,\n window: globalThis.window,\n parseJson: true,\n });\n return userCookie;\n};\n\nexport const useUserCookie = <T extends EmptyObject>() => {\n const hasRunRef = useRef(false);\n const router = useRouter();\n\n const { data: user } = useQuery({\n queryKey: [\"user\"],\n queryFn: () => getUserFromCookie() as User<T> | null,\n refetchInterval: 2000,\n refetchIntervalInBackground: true,\n enabled: !hasRunRef.current,\n refetchOnWindowFocus: true,\n });\n\n useEffect(() => {\n if (user) {\n if (!hasRunRef.current) {\n hasRunRef.current = true;\n router.refresh();\n }\n } else {\n hasRunRef.current = false;\n }\n }, [user, router]);\n\n return user ?? null;\n};\n","const getWindowCookieValue = ({\n key,\n window,\n parseJson = false,\n}: {\n key: string;\n window: Window;\n parseJson?: boolean;\n}) => {\n const cookie = window.document.cookie;\n if (!cookie) return null;\n const cookies = cookie.split(\";\");\n for (const c of cookies) {\n const [name, value] = c.trim().split(\"=\");\n if (value && name === key) {\n try {\n const decodeURIComponentValue = decodeURIComponent(value);\n return parseJson === true\n ? JSON.parse(decodeURIComponentValue)\n : decodeURIComponentValue;\n } catch {\n return value;\n }\n }\n }\n return null;\n};\nexport { getWindowCookieValue };\n","\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { useRouter } from \"next/navigation.js\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { getWindowCookieValue } from \"@/lib/cookies.js\";\nimport { OAuthTokens } from \"@/shared/types\";\n\nconst getTokenFromCookie = (tokenName: OAuthTokens): string => {\n return getWindowCookieValue({\n key: tokenName,\n window: globalThis.window,\n parseJson: false,\n });\n};\n\nexport const useTokenCookie = (tokenName: OAuthTokens): string | null => {\n const hasRunRef = useRef(false);\n const router = useRouter();\n\n const { data: token } = useQuery({\n queryKey: [\"token\", tokenName],\n queryFn: () => getTokenFromCookie(tokenName) || null,\n refetchInterval: 2000,\n refetchIntervalInBackground: true,\n enabled: !hasRunRef.current,\n refetchOnWindowFocus: true,\n });\n\n useEffect(() => {\n if (token) {\n if (!hasRunRef.current) {\n hasRunRef.current = true;\n router.refresh();\n }\n } else {\n hasRunRef.current = false;\n }\n }, [token, router]);\n\n return token ?? null;\n};\n"],"mappings":"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","names":["useEffect","window","useEffect","useRef","useRouter","useQuery","useRef","useRouter","useQuery","useEffect","useEffect"]}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import * as next_dist_shared_lib_image_config from 'next/dist/shared/lib/image-config';
|
|
2
|
+
import * as next_dist_lib_load_custom_routes from 'next/dist/lib/load-custom-routes';
|
|
3
|
+
import * as next_dist_server_config_shared from 'next/dist/server/config-shared';
|
|
4
|
+
import { NextConfig } from 'next';
|
|
5
|
+
import { T as TokensCookieConfig, a as CookieConfig, O as OAuthTokens, C as CodeVerifier } from './types-DOfl9w7j.mjs';
|
|
6
|
+
import { U as User, S as SessionData, a as UnknownObject } from './types-BxAubCqO.mjs';
|
|
7
|
+
import { NextRequest, NextResponse } from 'next/server.js';
|
|
8
|
+
import { NextResponse as NextResponse$1 } from 'next/server';
|
|
9
|
+
import { C as CookieStorage, a as CookieStorageSettings } from './storage-BJyqsZwC.mjs';
|
|
10
|
+
import 'oslo/oauth2';
|
|
11
|
+
|
|
12
|
+
type CookiesConfigObject = {
|
|
13
|
+
tokens: TokensCookieConfig;
|
|
14
|
+
user: CookieConfig;
|
|
15
|
+
};
|
|
16
|
+
type AuthConfigWithDefaults = {
|
|
17
|
+
clientId: string;
|
|
18
|
+
oauthServer: string;
|
|
19
|
+
callbackUrl: string;
|
|
20
|
+
loginUrl: string;
|
|
21
|
+
logoutUrl: string;
|
|
22
|
+
challengeUrl: string;
|
|
23
|
+
include: string[];
|
|
24
|
+
exclude: string[];
|
|
25
|
+
cookies: CookiesConfigObject;
|
|
26
|
+
};
|
|
27
|
+
type AuthConfig = Partial<AuthConfigWithDefaults>;
|
|
28
|
+
type DefinedAuthConfig = AuthConfigWithDefaults;
|
|
29
|
+
/**
|
|
30
|
+
* Default configuration values that will be used if not overridden
|
|
31
|
+
*/
|
|
32
|
+
declare const defaultAuthConfig: Omit<AuthConfigWithDefaults, "clientId">;
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the authentication configuration by combining:
|
|
35
|
+
* 1. Default values
|
|
36
|
+
* 2. Environment variables (set internally by the plugin)
|
|
37
|
+
* 3. Explicitly passed configuration
|
|
38
|
+
*
|
|
39
|
+
* Note: Developers should not set _civic_auth_* environment variables directly.
|
|
40
|
+
* Instead, pass configuration to the createCivicAuthPlugin in next.config.js:
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```js
|
|
44
|
+
* // next.config.js
|
|
45
|
+
* export default createCivicAuthPlugin({
|
|
46
|
+
* callbackUrl: '/custom/callback',
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare const resolveAuthConfig: (config?: AuthConfig) => AuthConfigWithDefaults;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a Next.js plugin that handles auth configuration.
|
|
53
|
+
*
|
|
54
|
+
* This is the main configuration point for the auth system.
|
|
55
|
+
* Do not set _civic_auth_* environment variables directly - instead,
|
|
56
|
+
* pass your configuration here:
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```js
|
|
60
|
+
* // next.config.js
|
|
61
|
+
* export default createCivicAuthPlugin({
|
|
62
|
+
* clientId: 'my-client-id',
|
|
63
|
+
* callbackUrl: '/custom/callback',
|
|
64
|
+
* loginUrl: '/custom/login',
|
|
65
|
+
* logoutUrl: '/custom/logout',
|
|
66
|
+
* include: ['/protected/*'],
|
|
67
|
+
* exclude: ['/public/*']
|
|
68
|
+
* })
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* The plugin sets internal environment variables that are used by
|
|
72
|
+
* the auth system. These variables should not be set manually.
|
|
73
|
+
*/
|
|
74
|
+
declare const createCivicAuthPlugin: (authConfig: AuthConfig & Pick<Required<AuthConfig>, "clientId">) => (nextConfig?: NextConfig) => {
|
|
75
|
+
env: {
|
|
76
|
+
_civic_auth_client_id: string;
|
|
77
|
+
_civic_oauth_server: string;
|
|
78
|
+
_civic_auth_callback_url: string;
|
|
79
|
+
_civic_auth_challenge_url: string;
|
|
80
|
+
_civic_auth_login_url: string;
|
|
81
|
+
_civic_auth_logout_url: string;
|
|
82
|
+
_civic_auth_includes: string;
|
|
83
|
+
_civic_auth_excludes: string;
|
|
84
|
+
_civic_auth_cookie_config: string;
|
|
85
|
+
};
|
|
86
|
+
exportPathMap?: (defaultMap: next_dist_server_config_shared.ExportPathMap, ctx: {
|
|
87
|
+
dev: boolean;
|
|
88
|
+
dir: string;
|
|
89
|
+
outDir: string | null;
|
|
90
|
+
distDir: string;
|
|
91
|
+
buildId: string;
|
|
92
|
+
}) => Promise<next_dist_server_config_shared.ExportPathMap> | next_dist_server_config_shared.ExportPathMap;
|
|
93
|
+
i18n?: next_dist_server_config_shared.I18NConfig | null;
|
|
94
|
+
eslint?: next_dist_server_config_shared.ESLintConfig;
|
|
95
|
+
typescript?: next_dist_server_config_shared.TypeScriptConfig;
|
|
96
|
+
headers?: () => Promise<next_dist_lib_load_custom_routes.Header[]>;
|
|
97
|
+
rewrites?: () => Promise<next_dist_lib_load_custom_routes.Rewrite[] | {
|
|
98
|
+
beforeFiles: next_dist_lib_load_custom_routes.Rewrite[];
|
|
99
|
+
afterFiles: next_dist_lib_load_custom_routes.Rewrite[];
|
|
100
|
+
fallback: next_dist_lib_load_custom_routes.Rewrite[];
|
|
101
|
+
}>;
|
|
102
|
+
redirects?: () => Promise<next_dist_lib_load_custom_routes.Redirect[]>;
|
|
103
|
+
excludeDefaultMomentLocales?: boolean;
|
|
104
|
+
webpack?: next_dist_server_config_shared.NextJsWebpackConfig | null;
|
|
105
|
+
trailingSlash?: boolean;
|
|
106
|
+
distDir?: string;
|
|
107
|
+
cleanDistDir?: boolean;
|
|
108
|
+
assetPrefix?: string;
|
|
109
|
+
cacheHandler?: string | undefined;
|
|
110
|
+
cacheMaxMemorySize?: number;
|
|
111
|
+
useFileSystemPublicRoutes?: boolean;
|
|
112
|
+
generateBuildId?: () => string | null | Promise<string | null>;
|
|
113
|
+
generateEtags?: boolean;
|
|
114
|
+
pageExtensions?: string[];
|
|
115
|
+
compress?: boolean;
|
|
116
|
+
analyticsId?: string;
|
|
117
|
+
poweredByHeader?: boolean;
|
|
118
|
+
images?: next_dist_shared_lib_image_config.ImageConfig;
|
|
119
|
+
devIndicators?: {
|
|
120
|
+
buildActivity?: boolean;
|
|
121
|
+
buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
122
|
+
};
|
|
123
|
+
onDemandEntries?: {
|
|
124
|
+
maxInactiveAge?: number;
|
|
125
|
+
pagesBufferLength?: number;
|
|
126
|
+
};
|
|
127
|
+
amp?: {
|
|
128
|
+
canonicalBase?: string;
|
|
129
|
+
};
|
|
130
|
+
deploymentId?: string;
|
|
131
|
+
basePath?: string;
|
|
132
|
+
sassOptions?: {
|
|
133
|
+
[key: string]: any;
|
|
134
|
+
};
|
|
135
|
+
productionBrowserSourceMaps?: boolean;
|
|
136
|
+
optimizeFonts?: boolean;
|
|
137
|
+
reactProductionProfiling?: boolean;
|
|
138
|
+
reactStrictMode?: boolean | null;
|
|
139
|
+
publicRuntimeConfig?: {
|
|
140
|
+
[key: string]: any;
|
|
141
|
+
};
|
|
142
|
+
serverRuntimeConfig?: {
|
|
143
|
+
[key: string]: any;
|
|
144
|
+
};
|
|
145
|
+
httpAgentOptions?: {
|
|
146
|
+
keepAlive?: boolean;
|
|
147
|
+
};
|
|
148
|
+
outputFileTracing?: boolean;
|
|
149
|
+
staticPageGenerationTimeout?: number;
|
|
150
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
151
|
+
swcMinify?: boolean;
|
|
152
|
+
compiler?: {
|
|
153
|
+
reactRemoveProperties?: boolean | {
|
|
154
|
+
properties?: string[];
|
|
155
|
+
};
|
|
156
|
+
relay?: {
|
|
157
|
+
src: string;
|
|
158
|
+
artifactDirectory?: string;
|
|
159
|
+
language?: "typescript" | "javascript" | "flow";
|
|
160
|
+
eagerEsModules?: boolean;
|
|
161
|
+
};
|
|
162
|
+
removeConsole?: boolean | {
|
|
163
|
+
exclude?: string[];
|
|
164
|
+
};
|
|
165
|
+
styledComponents?: boolean | next_dist_server_config_shared.StyledComponentsConfig;
|
|
166
|
+
emotion?: boolean | next_dist_server_config_shared.EmotionConfig;
|
|
167
|
+
styledJsx?: boolean | {
|
|
168
|
+
useLightningcss?: boolean;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
output?: "standalone" | "export";
|
|
172
|
+
transpilePackages?: string[];
|
|
173
|
+
skipMiddlewareUrlNormalize?: boolean;
|
|
174
|
+
skipTrailingSlashRedirect?: boolean;
|
|
175
|
+
modularizeImports?: Record<string, {
|
|
176
|
+
transform: string | Record<string, string>;
|
|
177
|
+
preventFullImport?: boolean;
|
|
178
|
+
skipDefaultConversion?: boolean;
|
|
179
|
+
}>;
|
|
180
|
+
logging?: {
|
|
181
|
+
fetches?: {
|
|
182
|
+
fullUrl?: boolean;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
experimental?: next_dist_server_config_shared.ExperimentalConfig;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Used on the server-side to get the user object from the cookie
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
declare const getUser: () => User | null;
|
|
193
|
+
|
|
194
|
+
type Middleware = (request: NextRequest) => Promise<NextResponse> | NextResponse;
|
|
195
|
+
/**
|
|
196
|
+
*
|
|
197
|
+
* Use this when auth is the only middleware you need.
|
|
198
|
+
* Usage:
|
|
199
|
+
*
|
|
200
|
+
* export default authMiddleware({ loginUrl = '/login' }); // or just authMiddleware();
|
|
201
|
+
*
|
|
202
|
+
*/
|
|
203
|
+
declare const authMiddleware: (authConfig?: Omit<AuthConfigWithDefaults, "clientId">) => (request: NextRequest) => Promise<NextResponse>;
|
|
204
|
+
/**
|
|
205
|
+
* Usage:
|
|
206
|
+
*
|
|
207
|
+
* export default withAuth(async (request) => {
|
|
208
|
+
* console.log('my middleware');
|
|
209
|
+
* return NextResponse.next();
|
|
210
|
+
* })
|
|
211
|
+
*/
|
|
212
|
+
declare function withAuth(middleware: Middleware): (request: NextRequest) => Promise<NextResponse>;
|
|
213
|
+
/**
|
|
214
|
+
* Use this when you want to configure the middleware here (an alternative is to do it in the next.config file)
|
|
215
|
+
*
|
|
216
|
+
* Usage:
|
|
217
|
+
*
|
|
218
|
+
* const withAuth = auth({ loginUrl = '/login' }); // or just auth();
|
|
219
|
+
*
|
|
220
|
+
* export default withAuth(async (request) => {
|
|
221
|
+
* console.log('my middleware');
|
|
222
|
+
* return NextResponse.next();
|
|
223
|
+
* })
|
|
224
|
+
*
|
|
225
|
+
*/
|
|
226
|
+
declare function auth(authConfig?: AuthConfig): (middleware: Middleware) => ((request: NextRequest) => Promise<NextResponse>);
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Creates an authentication handler for Next.js API routes
|
|
230
|
+
*
|
|
231
|
+
* Usage:
|
|
232
|
+
* ```ts
|
|
233
|
+
* // app/api/auth/[...civicauth]/route.ts
|
|
234
|
+
* import { handler } from '@civic/auth/nextjs'
|
|
235
|
+
* export const GET = handler({
|
|
236
|
+
* // optional config overrides
|
|
237
|
+
* })
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
declare const handler: (authConfig?: {}) => (request: NextRequest) => Promise<NextResponse>;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Creates HTTP-only cookies for authentication tokens
|
|
244
|
+
*/
|
|
245
|
+
declare const createTokenCookies: (response: NextResponse$1, sessionData: SessionData, config: AuthConfig) => void;
|
|
246
|
+
/**
|
|
247
|
+
* Creates a client-readable cookie with user info
|
|
248
|
+
*/
|
|
249
|
+
declare const createUserInfoCookie: (response: NextResponse$1, user: User<UnknownObject> | null, sessionData: SessionData, config: AuthConfig) => void;
|
|
250
|
+
/**
|
|
251
|
+
* Clears all authentication cookies
|
|
252
|
+
*/
|
|
253
|
+
declare const clearAuthCookies: (config: AuthConfig) => Promise<void>;
|
|
254
|
+
type KeySetter = OAuthTokens | CodeVerifier;
|
|
255
|
+
declare class NextjsCookieStorage extends CookieStorage {
|
|
256
|
+
readonly config: Partial<TokensCookieConfig>;
|
|
257
|
+
constructor(config?: Partial<TokensCookieConfig>);
|
|
258
|
+
get(key: string): string | null;
|
|
259
|
+
set(key: KeySetter, value: string): void;
|
|
260
|
+
}
|
|
261
|
+
declare class NextjsClientStorage extends CookieStorage {
|
|
262
|
+
constructor(config?: Partial<CookieStorageSettings>);
|
|
263
|
+
get(key: string): string | null;
|
|
264
|
+
set(key: string, value: string): void;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export { type AuthConfig, type AuthConfigWithDefaults, type CookiesConfigObject, type DefinedAuthConfig, NextjsClientStorage, NextjsCookieStorage, auth, authMiddleware, clearAuthCookies, createCivicAuthPlugin, createTokenCookies, createUserInfoCookie, defaultAuthConfig, getUser, handler, resolveAuthConfig, withAuth };
|