@civic/auth 0.0.1-beta.24 → 0.0.1-beta.25
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/AuthProvider-BBetpl_s.d.mts +21 -0
- package/dist/AuthProvider-BYZ8w92b.d.mts +15 -0
- package/dist/AuthProvider-BgOwv9h8.d.ts +15 -0
- package/dist/AuthProvider-D_kReUi0.d.ts +21 -0
- package/dist/{index-DTimUlkB.d.ts → UserProvider-BA2uflVB.d.ts} +1 -2
- package/dist/{index-DvjkKpkk.d.mts → UserProvider-Bl3j1PUO.d.mts} +1 -2
- package/dist/chunk-2OZJONNO.js.map +1 -1
- package/dist/chunk-2TDB4XWE.js +277 -0
- package/dist/chunk-2TDB4XWE.js.map +1 -0
- package/dist/chunk-2ZUCE3XM.mjs +705 -0
- package/dist/chunk-2ZUCE3XM.mjs.map +1 -0
- package/dist/{chunk-A43GY6C3.mjs → chunk-4KSQPSLG.mjs} +7 -12
- package/dist/chunk-4KSQPSLG.mjs.map +1 -0
- package/dist/chunk-55ELY65Q.mjs +706 -0
- package/dist/chunk-55ELY65Q.mjs.map +1 -0
- package/dist/chunk-5UQQYXCX.js.map +1 -1
- package/dist/chunk-63YGK3A7.mjs +223 -0
- package/dist/chunk-63YGK3A7.mjs.map +1 -0
- package/dist/chunk-6RFRDWIP.js.map +1 -1
- package/dist/{chunk-74J7HX36.mjs → chunk-6UFAMFB3.mjs} +5 -5
- package/dist/chunk-6UFAMFB3.mjs.map +1 -0
- package/dist/chunk-75242WAX.js +711 -0
- package/dist/chunk-75242WAX.js.map +1 -0
- package/dist/chunk-7K3QN2AT.js.map +1 -1
- package/dist/chunk-ADCTONP6.js +709 -0
- package/dist/chunk-ADCTONP6.js.map +1 -0
- package/dist/{chunk-RF23Q4V6.js → chunk-AM2Y662I.js} +117 -224
- package/dist/chunk-AM2Y662I.js.map +1 -0
- package/dist/chunk-B3L76DWC.mjs +705 -0
- package/dist/chunk-B3L76DWC.mjs.map +1 -0
- package/dist/{chunk-WXSUVTI4.mjs → chunk-BCXJ4LWQ.mjs} +3 -2
- package/dist/chunk-BCXJ4LWQ.mjs.map +1 -0
- package/dist/chunk-BFJSBJHA.js +709 -0
- package/dist/chunk-BFJSBJHA.js.map +1 -0
- package/dist/chunk-BLLLGPVG.mjs +277 -0
- package/dist/chunk-BLLLGPVG.mjs.map +1 -0
- package/dist/{chunk-COWYPS3A.js → chunk-CJCLQQS5.js} +3 -2
- package/dist/chunk-CJCLQQS5.js.map +1 -0
- package/dist/chunk-CMMHRIMG.js +705 -0
- package/dist/chunk-CMMHRIMG.js.map +1 -0
- package/dist/chunk-CRTRMMJ7.js.map +1 -1
- package/dist/chunk-CTVJJBBA.js.map +1 -1
- package/dist/chunk-D53PLWCK.js +703 -0
- package/dist/chunk-D53PLWCK.js.map +1 -0
- package/dist/chunk-EKLYHP2D.mjs +711 -0
- package/dist/chunk-EKLYHP2D.mjs.map +1 -0
- package/dist/{chunk-XNSHSKGI.js → chunk-FHRZSX3C.js} +2 -2
- package/dist/chunk-FHRZSX3C.js.map +1 -0
- package/dist/{chunk-5XL2ST72.mjs → chunk-G7PH56KW.mjs} +77 -29
- package/dist/chunk-G7PH56KW.mjs.map +1 -0
- package/dist/chunk-GB3H3I47.js +711 -0
- package/dist/chunk-GB3H3I47.js.map +1 -0
- package/dist/chunk-GFP6OLRQ.js +709 -0
- package/dist/chunk-GFP6OLRQ.js.map +1 -0
- package/dist/chunk-HMPKCLIJ.mjs +709 -0
- package/dist/chunk-HMPKCLIJ.mjs.map +1 -0
- package/dist/chunk-IENACY5A.js +116 -0
- package/dist/chunk-IENACY5A.js.map +1 -0
- package/dist/chunk-J5KMPZIV.mjs +708 -0
- package/dist/chunk-J5KMPZIV.mjs.map +1 -0
- package/dist/chunk-J7FWSTAL.js +711 -0
- package/dist/chunk-J7FWSTAL.js.map +1 -0
- package/dist/chunk-JDZPCA3P.js.map +1 -1
- package/dist/chunk-JEOPLLWO.js +223 -0
- package/dist/chunk-JEOPLLWO.js.map +1 -0
- package/dist/chunk-JTQHIECR.mjs +709 -0
- package/dist/chunk-JTQHIECR.mjs.map +1 -0
- package/dist/chunk-KBHDXIAM.js +711 -0
- package/dist/chunk-KBHDXIAM.js.map +1 -0
- package/dist/chunk-KSOWEBHG.js +720 -0
- package/dist/chunk-KSOWEBHG.js.map +1 -0
- package/dist/chunk-LPW3B7PM.js +712 -0
- package/dist/chunk-LPW3B7PM.js.map +1 -0
- package/dist/chunk-M7QA57W3.mjs +711 -0
- package/dist/chunk-M7QA57W3.mjs.map +1 -0
- package/dist/{chunk-3YV5NEM4.js → chunk-MXAJ6OFR.js} +7 -12
- package/dist/chunk-MXAJ6OFR.js.map +1 -0
- package/dist/{chunk-AMCR45Y5.mjs → chunk-NLRREFOX.mjs} +2 -2
- package/dist/chunk-NLRREFOX.mjs.map +1 -0
- package/dist/chunk-NRDG7CC4.js +706 -0
- package/dist/chunk-NRDG7CC4.js.map +1 -0
- package/dist/{chunk-JCLIMTK5.js → chunk-NSAO2ERW.js} +5 -9
- package/dist/chunk-NSAO2ERW.js.map +1 -0
- package/dist/chunk-NXGNAFNY.js +708 -0
- package/dist/chunk-NXGNAFNY.js.map +1 -0
- package/dist/chunk-OXXUQ36U.mjs +283 -0
- package/dist/chunk-OXXUQ36U.mjs.map +1 -0
- package/dist/chunk-PKBT2ALA.mjs +703 -0
- package/dist/chunk-PKBT2ALA.mjs.map +1 -0
- package/dist/chunk-PS5WST7W.mjs +711 -0
- package/dist/chunk-PS5WST7W.mjs.map +1 -0
- package/dist/{chunk-G3P5TIO2.mjs → chunk-Q7DSPTUG.mjs} +126 -233
- package/dist/chunk-Q7DSPTUG.mjs.map +1 -0
- package/dist/chunk-RCFPLIWS.js.map +1 -1
- package/dist/chunk-RIHMMI3P.mjs +116 -0
- package/dist/chunk-RIHMMI3P.mjs.map +1 -0
- package/dist/chunk-RMN6R4VP.mjs +708 -0
- package/dist/chunk-RMN6R4VP.mjs.map +1 -0
- package/dist/{chunk-QHE3SPKQ.js → chunk-SJ6NSD2E.js} +3 -6
- package/dist/chunk-SJ6NSD2E.js.map +1 -0
- package/dist/chunk-SN7YDQQH.js.map +1 -1
- package/dist/chunk-SYJZGEFV.mjs +709 -0
- package/dist/chunk-SYJZGEFV.mjs.map +1 -0
- package/dist/chunk-TH6FI2XI.js +283 -0
- package/dist/chunk-TH6FI2XI.js.map +1 -0
- package/dist/{chunk-6RJHOVY6.mjs → chunk-UBO6RIOZ.mjs} +3 -6
- package/dist/chunk-UBO6RIOZ.mjs.map +1 -0
- package/dist/chunk-UGDZ4VB3.js +705 -0
- package/dist/chunk-UGDZ4VB3.js.map +1 -0
- package/dist/{chunk-NTJWPNOZ.mjs → chunk-UVRXIVK3.mjs} +2 -4
- package/dist/chunk-UVRXIVK3.mjs.map +1 -0
- package/dist/chunk-WC2OMEHO.mjs +711 -0
- package/dist/chunk-WC2OMEHO.mjs.map +1 -0
- package/dist/chunk-WQNOMTSD.mjs +720 -0
- package/dist/chunk-WQNOMTSD.mjs.map +1 -0
- package/dist/chunk-WVG3PNQ6.js +708 -0
- package/dist/chunk-WVG3PNQ6.js.map +1 -0
- package/dist/chunk-WYA7Q4IM.mjs +708 -0
- package/dist/chunk-WYA7Q4IM.mjs.map +1 -0
- package/dist/{chunk-SEKF2WZX.js → chunk-X7YY6SHZ.js} +80 -32
- package/dist/chunk-X7YY6SHZ.js.map +1 -0
- package/dist/{chunk-ELO3M4DA.js → chunk-ZXNMEKUE.js} +2 -4
- package/dist/chunk-ZXNMEKUE.js.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js.map +1 -1
- package/dist/nextjs/client.d.mts +3 -5
- package/dist/nextjs/client.d.ts +3 -5
- package/dist/nextjs/client.js +14 -16
- package/dist/nextjs/client.js.map +1 -1
- package/dist/nextjs/client.mjs +10 -12
- package/dist/nextjs/client.mjs.map +1 -1
- package/dist/nextjs.d.mts +3 -5
- package/dist/nextjs.d.ts +3 -5
- package/dist/nextjs.js +63 -55
- package/dist/nextjs.js.map +1 -1
- package/dist/nextjs.mjs +40 -32
- package/dist/nextjs.mjs.map +1 -1
- package/dist/react.d.mts +5 -9
- package/dist/react.d.ts +5 -9
- package/dist/react.js +11 -23
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +2 -14
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +3 -3
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +2 -2
- package/dist/storage-ANmRwpZ3.d.ts +25 -0
- package/dist/storage-BJyqsZwC.d.mts +25 -0
- package/dist/types-BxAubCqO.d.mts +58 -0
- package/dist/types-BxAubCqO.d.ts +58 -0
- package/dist/{types-b4c1koXj.d.mts → types-DOfl9w7j.d.mts} +6 -2
- package/dist/{types-b4c1koXj.d.ts → types-DOfl9w7j.d.ts} +6 -2
- package/package.json +14 -14
- package/dist/chunk-3YV5NEM4.js.map +0 -1
- package/dist/chunk-5XL2ST72.mjs.map +0 -1
- package/dist/chunk-6RJHOVY6.mjs.map +0 -1
- package/dist/chunk-74J7HX36.mjs.map +0 -1
- package/dist/chunk-A43GY6C3.mjs.map +0 -1
- package/dist/chunk-AMCR45Y5.mjs.map +0 -1
- package/dist/chunk-COWYPS3A.js.map +0 -1
- package/dist/chunk-ELO3M4DA.js.map +0 -1
- package/dist/chunk-G3P5TIO2.mjs.map +0 -1
- package/dist/chunk-JCLIMTK5.js.map +0 -1
- package/dist/chunk-NTJWPNOZ.mjs.map +0 -1
- package/dist/chunk-QHE3SPKQ.js.map +0 -1
- package/dist/chunk-RF23Q4V6.js.map +0 -1
- package/dist/chunk-SEKF2WZX.js.map +0 -1
- package/dist/chunk-WXSUVTI4.mjs.map +0 -1
- package/dist/chunk-XNSHSKGI.js.map +0 -1
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BrowserAuthenticationInitiator,
|
|
3
|
+
BrowserAuthenticationService,
|
|
4
|
+
ConfidentialClientPKCEConsumer,
|
|
5
|
+
DEFAULT_AUTH_SERVER,
|
|
6
|
+
DEFAULT_SCOPES,
|
|
7
|
+
GenericUserSession,
|
|
8
|
+
IFRAME_ID,
|
|
9
|
+
LocalStorageAdapter,
|
|
10
|
+
PopupError,
|
|
11
|
+
TOKEN_EXCHANGE_TRIGGER_TEXT,
|
|
12
|
+
convertForwardedTokenFormat,
|
|
13
|
+
generateState,
|
|
14
|
+
getUser,
|
|
15
|
+
isWindowInIframe
|
|
16
|
+
} from "./chunk-4PLCDPEN.mjs";
|
|
17
|
+
import {
|
|
18
|
+
__async,
|
|
19
|
+
__spreadProps,
|
|
20
|
+
__spreadValues
|
|
21
|
+
} from "./chunk-RGHW4PYM.mjs";
|
|
22
|
+
|
|
23
|
+
// src/shared/hooks/useAuth.tsx
|
|
24
|
+
import { useContext } from "react";
|
|
25
|
+
|
|
26
|
+
// src/shared/AuthContext.tsx
|
|
27
|
+
import { createContext } from "react";
|
|
28
|
+
var AuthContext = createContext(null);
|
|
29
|
+
|
|
30
|
+
// src/shared/hooks/useAuth.tsx
|
|
31
|
+
var useAuth = () => {
|
|
32
|
+
const context = useContext(AuthContext);
|
|
33
|
+
if (!context) {
|
|
34
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
35
|
+
}
|
|
36
|
+
return context;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/shared/hooks/useSession.tsx
|
|
40
|
+
import { useContext as useContext2 } from "react";
|
|
41
|
+
|
|
42
|
+
// src/shared/providers/SessionProvider.tsx
|
|
43
|
+
import { createContext as createContext2 } from "react";
|
|
44
|
+
import { jsx } from "react/jsx-runtime";
|
|
45
|
+
var defaultSession = {
|
|
46
|
+
authenticated: false,
|
|
47
|
+
idToken: void 0,
|
|
48
|
+
accessToken: void 0,
|
|
49
|
+
displayMode: "iframe"
|
|
50
|
+
};
|
|
51
|
+
var SessionContext = createContext2(defaultSession);
|
|
52
|
+
var SessionProvider = ({ children, session }) => /* @__PURE__ */ jsx(SessionContext.Provider, { value: __spreadValues(__spreadValues({}, defaultSession), session || {}), children });
|
|
53
|
+
|
|
54
|
+
// src/shared/hooks/useSession.tsx
|
|
55
|
+
var useSession = () => {
|
|
56
|
+
const context = useContext2(SessionContext);
|
|
57
|
+
if (!context) {
|
|
58
|
+
throw new Error("useSession must be used within an SessionProvider");
|
|
59
|
+
}
|
|
60
|
+
return context;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/shared/hooks/useToken.tsx
|
|
64
|
+
import { useContext as useContext3 } from "react";
|
|
65
|
+
|
|
66
|
+
// src/shared/providers/TokenProvider.tsx
|
|
67
|
+
import { createContext as createContext3, useMemo } from "react";
|
|
68
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
69
|
+
import { parseJWT } from "oslo/jwt";
|
|
70
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
71
|
+
var TokenContext = createContext3(void 0);
|
|
72
|
+
var TokenProvider = ({ children }) => {
|
|
73
|
+
const { isLoading, error: authError } = useAuth();
|
|
74
|
+
const session = useSession();
|
|
75
|
+
const queryClient = useQueryClient();
|
|
76
|
+
const refreshTokenMutation = useMutation({
|
|
77
|
+
mutationFn: () => __async(void 0, null, function* () {
|
|
78
|
+
throw new Error("Method not implemented.");
|
|
79
|
+
}),
|
|
80
|
+
onSuccess: () => {
|
|
81
|
+
queryClient.invalidateQueries({ queryKey: ["session"] });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const decodeTokens = useMemo(() => {
|
|
85
|
+
if (!(session == null ? void 0 : session.idToken)) return null;
|
|
86
|
+
const parsedJWT = parseJWT(session.idToken);
|
|
87
|
+
if (!parsedJWT) return null;
|
|
88
|
+
const { forwardedTokens } = parsedJWT.payload;
|
|
89
|
+
return forwardedTokens ? convertForwardedTokenFormat(forwardedTokens) : null;
|
|
90
|
+
}, [session == null ? void 0 : session.idToken]);
|
|
91
|
+
const value = useMemo(
|
|
92
|
+
() => ({
|
|
93
|
+
accessToken: session.accessToken || null,
|
|
94
|
+
idToken: session.idToken || null,
|
|
95
|
+
forwardedTokens: decodeTokens || {},
|
|
96
|
+
refreshToken: refreshTokenMutation.mutateAsync,
|
|
97
|
+
isLoading,
|
|
98
|
+
error: authError || refreshTokenMutation.error
|
|
99
|
+
}),
|
|
100
|
+
[
|
|
101
|
+
session.accessToken,
|
|
102
|
+
session.idToken,
|
|
103
|
+
decodeTokens,
|
|
104
|
+
refreshTokenMutation.mutateAsync,
|
|
105
|
+
refreshTokenMutation.error,
|
|
106
|
+
isLoading,
|
|
107
|
+
authError
|
|
108
|
+
]
|
|
109
|
+
);
|
|
110
|
+
return /* @__PURE__ */ jsx2(TokenContext.Provider, { value, children });
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/shared/hooks/useToken.tsx
|
|
114
|
+
var useToken = () => {
|
|
115
|
+
const context = useContext3(TokenContext);
|
|
116
|
+
if (!context) {
|
|
117
|
+
throw new Error("useToken must be used within a TokenProvider");
|
|
118
|
+
}
|
|
119
|
+
return context;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/shared/hooks/useConfig.tsx
|
|
123
|
+
import { useContext as useContext4 } from "react";
|
|
124
|
+
|
|
125
|
+
// src/config.ts
|
|
126
|
+
var authConfig = {
|
|
127
|
+
oauthServer: DEFAULT_AUTH_SERVER
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// src/shared/providers/ConfigProvider.tsx
|
|
131
|
+
import { createContext as createContext4 } from "react";
|
|
132
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
133
|
+
var defaultConfig = {
|
|
134
|
+
config: authConfig,
|
|
135
|
+
redirectUrl: "",
|
|
136
|
+
modalIframe: true,
|
|
137
|
+
serverTokenExchange: false
|
|
138
|
+
};
|
|
139
|
+
var ConfigContext = createContext4(defaultConfig);
|
|
140
|
+
var ConfigProvider = ({
|
|
141
|
+
children,
|
|
142
|
+
config,
|
|
143
|
+
redirectUrl,
|
|
144
|
+
modalIframe,
|
|
145
|
+
serverTokenExchange
|
|
146
|
+
}) => /* @__PURE__ */ jsx3(
|
|
147
|
+
ConfigContext.Provider,
|
|
148
|
+
{
|
|
149
|
+
value: {
|
|
150
|
+
config,
|
|
151
|
+
redirectUrl,
|
|
152
|
+
modalIframe: !!modalIframe,
|
|
153
|
+
serverTokenExchange
|
|
154
|
+
},
|
|
155
|
+
children
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// src/shared/hooks/useConfig.tsx
|
|
160
|
+
var useConfig = () => {
|
|
161
|
+
const context = useContext4(ConfigContext);
|
|
162
|
+
if (!context) {
|
|
163
|
+
throw new Error("useConfig must be used within an ConfigProvider");
|
|
164
|
+
}
|
|
165
|
+
return context;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/shared/hooks/useIframe.tsx
|
|
169
|
+
import { useContext as useContext5 } from "react";
|
|
170
|
+
|
|
171
|
+
// src/shared/providers/IframeProvider.tsx
|
|
172
|
+
import {
|
|
173
|
+
createContext as createContext5
|
|
174
|
+
} from "react";
|
|
175
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
176
|
+
var defaultIframe = {
|
|
177
|
+
iframeRef: null,
|
|
178
|
+
setAuthResponseUrl: () => {
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var IframeContext = createContext5(defaultIframe);
|
|
182
|
+
var IframeProvider = ({
|
|
183
|
+
children,
|
|
184
|
+
iframeRef,
|
|
185
|
+
setAuthResponseUrl
|
|
186
|
+
}) => /* @__PURE__ */ jsx4(IframeContext.Provider, { value: { iframeRef, setAuthResponseUrl }, children });
|
|
187
|
+
|
|
188
|
+
// src/shared/hooks/useIframe.tsx
|
|
189
|
+
var useIframe = () => {
|
|
190
|
+
const context = useContext5(IframeContext);
|
|
191
|
+
if (!context) {
|
|
192
|
+
throw new Error("useIframe must be used within an IframeProvider");
|
|
193
|
+
}
|
|
194
|
+
return context;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// src/shared/components/CivicAuthIframeContainer.tsx
|
|
198
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
199
|
+
|
|
200
|
+
// src/shared/components/LoadingIcon.tsx
|
|
201
|
+
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
202
|
+
var LoadingIcon = () => /* @__PURE__ */ jsxs("div", { role: "status", children: [
|
|
203
|
+
/* @__PURE__ */ jsxs(
|
|
204
|
+
"svg",
|
|
205
|
+
{
|
|
206
|
+
"aria-hidden": "true",
|
|
207
|
+
className: "cac-inline cac-h-8 cac-w-8 cac-animate-spin cac-fill-neutral-600 cac-text-neutral-200 dark:cac-fill-neutral-300 dark:cac-text-neutral-600",
|
|
208
|
+
viewBox: "0 0 100 101",
|
|
209
|
+
fill: "none",
|
|
210
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ jsx5(
|
|
213
|
+
"path",
|
|
214
|
+
{
|
|
215
|
+
d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",
|
|
216
|
+
fill: "currentColor"
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
/* @__PURE__ */ jsx5(
|
|
220
|
+
"path",
|
|
221
|
+
{
|
|
222
|
+
d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",
|
|
223
|
+
fill: "currentFill"
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
/* @__PURE__ */ jsx5("span", { className: "cac-sr-only", children: "Loading..." })
|
|
230
|
+
] });
|
|
231
|
+
|
|
232
|
+
// src/shared/components/CloseIcon.tsx
|
|
233
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
234
|
+
var CloseIcon = () => /* @__PURE__ */ jsxs2(
|
|
235
|
+
"svg",
|
|
236
|
+
{
|
|
237
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
238
|
+
width: "24",
|
|
239
|
+
height: "24",
|
|
240
|
+
viewBox: "0 0 24 24",
|
|
241
|
+
fill: "none",
|
|
242
|
+
stroke: "currentColor",
|
|
243
|
+
strokeWidth: "2",
|
|
244
|
+
strokeLinecap: "round",
|
|
245
|
+
strokeLinejoin: "round",
|
|
246
|
+
className: "lucide lucide-x",
|
|
247
|
+
children: [
|
|
248
|
+
/* @__PURE__ */ jsx6("path", { d: "M18 6 6 18" }),
|
|
249
|
+
/* @__PURE__ */ jsx6("path", { d: "m6 6 12 12" })
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
// src/shared/components/CivicAuthIframe.tsx
|
|
255
|
+
import { forwardRef } from "react";
|
|
256
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
257
|
+
var CivicAuthIframe = forwardRef(
|
|
258
|
+
({ onLoad }, ref) => {
|
|
259
|
+
return /* @__PURE__ */ jsx7(
|
|
260
|
+
"iframe",
|
|
261
|
+
{
|
|
262
|
+
id: IFRAME_ID,
|
|
263
|
+
ref,
|
|
264
|
+
className: "cac-h-[26rem] cac-w-full cac-border-none",
|
|
265
|
+
onLoad
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
CivicAuthIframe.displayName = "CivicAuthIframe";
|
|
271
|
+
|
|
272
|
+
// src/shared/components/CivicAuthIframeContainer.tsx
|
|
273
|
+
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
274
|
+
function NoChrome({
|
|
275
|
+
children
|
|
276
|
+
}) {
|
|
277
|
+
return /* @__PURE__ */ jsx8("div", { className: "cac-relative", children });
|
|
278
|
+
}
|
|
279
|
+
function IframeChrome({
|
|
280
|
+
children,
|
|
281
|
+
onClose
|
|
282
|
+
}) {
|
|
283
|
+
return /* @__PURE__ */ jsx8(
|
|
284
|
+
"div",
|
|
285
|
+
{
|
|
286
|
+
className: "cac-absolute cac-left-0 cac-top-0 cac-z-50 cac-flex cac-h-screen cac-w-screen cac-min-w-72 cac-items-center cac-justify-center cac-bg-neutral-950 cac-bg-opacity-50",
|
|
287
|
+
onClick: onClose,
|
|
288
|
+
children: /* @__PURE__ */ jsxs3(
|
|
289
|
+
"div",
|
|
290
|
+
{
|
|
291
|
+
className: "cac-relative cac-overflow-hidden cac-rounded-3xl cac-bg-white cac-p-2 cac-shadow-lg sm:cac-p-6",
|
|
292
|
+
onClick: (e) => e.stopPropagation(),
|
|
293
|
+
children: [
|
|
294
|
+
/* @__PURE__ */ jsx8(
|
|
295
|
+
"button",
|
|
296
|
+
{
|
|
297
|
+
className: "cac-absolute cac-right-4 cac-top-4 cac-flex cac-cursor-pointer cac-items-center cac-justify-center cac-border-none cac-bg-transparent cac-p-1 cac-text-neutral-400",
|
|
298
|
+
onClick: onClose,
|
|
299
|
+
children: /* @__PURE__ */ jsx8(CloseIcon, {})
|
|
300
|
+
}
|
|
301
|
+
),
|
|
302
|
+
children
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
var CivicAuthIframeContainer = ({
|
|
310
|
+
onClose,
|
|
311
|
+
closeOnRedirect = true
|
|
312
|
+
}) => {
|
|
313
|
+
var _a;
|
|
314
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
315
|
+
const { isLoading: isAuthLoading } = useAuth();
|
|
316
|
+
const config = useConfig();
|
|
317
|
+
const { setAuthResponseUrl, iframeRef } = useIframe();
|
|
318
|
+
const processIframeUrl = useCallback(() => {
|
|
319
|
+
var _a2, _b;
|
|
320
|
+
if (iframeRef && iframeRef.current && iframeRef.current.contentWindow) {
|
|
321
|
+
try {
|
|
322
|
+
const iframeUrl = iframeRef.current.contentWindow.location.href;
|
|
323
|
+
if (iframeUrl.startsWith(config.redirectUrl)) {
|
|
324
|
+
setIsLoading(true);
|
|
325
|
+
const iframeBody = iframeRef.current.contentWindow.document.body.innerHTML;
|
|
326
|
+
if (iframeBody.includes(TOKEN_EXCHANGE_TRIGGER_TEXT)) {
|
|
327
|
+
console.log(
|
|
328
|
+
`${TOKEN_EXCHANGE_TRIGGER_TEXT}, calling callback URL again...`
|
|
329
|
+
);
|
|
330
|
+
const params = new URL(iframeUrl).searchParams;
|
|
331
|
+
const appUrl = (_b = (_a2 = globalThis.window) == null ? void 0 : _a2.location) == null ? void 0 : _b.origin;
|
|
332
|
+
fetch(`${config.redirectUrl}?${params.toString()}&appUrl=${appUrl}`);
|
|
333
|
+
} else {
|
|
334
|
+
setAuthResponseUrl(iframeUrl);
|
|
335
|
+
}
|
|
336
|
+
if (closeOnRedirect) onClose == null ? void 0 : onClose();
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
} catch (e) {
|
|
340
|
+
console.log("Waiting for redirect...");
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return false;
|
|
344
|
+
}, [
|
|
345
|
+
closeOnRedirect,
|
|
346
|
+
config.redirectUrl,
|
|
347
|
+
iframeRef,
|
|
348
|
+
onClose,
|
|
349
|
+
setAuthResponseUrl
|
|
350
|
+
]);
|
|
351
|
+
const intervalId = useRef();
|
|
352
|
+
const handleEscape = useCallback(
|
|
353
|
+
(event) => {
|
|
354
|
+
if (event.key === "Escape") {
|
|
355
|
+
onClose == null ? void 0 : onClose();
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
[onClose]
|
|
359
|
+
);
|
|
360
|
+
useEffect(() => {
|
|
361
|
+
window.addEventListener("keydown", handleEscape);
|
|
362
|
+
return () => window.removeEventListener("keydown", handleEscape);
|
|
363
|
+
});
|
|
364
|
+
const handleIframeLoad = () => {
|
|
365
|
+
setIsLoading(false);
|
|
366
|
+
console.log("handleIframeLoad");
|
|
367
|
+
if (processIframeUrl() && intervalId.current) {
|
|
368
|
+
clearInterval(intervalId.current);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const showLoadingIcon = isLoading || isAuthLoading || !((_a = iframeRef == null ? void 0 : iframeRef.current) == null ? void 0 : _a.getAttribute("src"));
|
|
372
|
+
const WrapperComponent = config.modalIframe ? IframeChrome : NoChrome;
|
|
373
|
+
return /* @__PURE__ */ jsxs3(WrapperComponent, { onClose, children: [
|
|
374
|
+
showLoadingIcon && /* @__PURE__ */ jsx8("div", { className: "cac-absolute cac-inset-0 cac-flex cac-items-center cac-justify-center cac-bg-white", children: /* @__PURE__ */ jsx8(LoadingIcon, {}) }),
|
|
375
|
+
/* @__PURE__ */ jsx8(CivicAuthIframe, { ref: iframeRef, onLoad: handleIframeLoad })
|
|
376
|
+
] });
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
// src/shared/UserProvider.tsx
|
|
380
|
+
import { createContext as createContext6 } from "react";
|
|
381
|
+
import { useQuery } from "@tanstack/react-query";
|
|
382
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
383
|
+
var UserContext = createContext6(null);
|
|
384
|
+
var UserProvider = ({
|
|
385
|
+
children,
|
|
386
|
+
storage,
|
|
387
|
+
user: inputUser,
|
|
388
|
+
signOut: inputSignOut
|
|
389
|
+
}) => {
|
|
390
|
+
var _a;
|
|
391
|
+
const { isLoading: authLoading, error: authError } = useAuth();
|
|
392
|
+
const session = useSession();
|
|
393
|
+
const { accessToken, idToken } = useToken();
|
|
394
|
+
const { signIn, signOut } = useAuth();
|
|
395
|
+
const fetchUser = () => __async(void 0, null, function* () {
|
|
396
|
+
if (!accessToken) {
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
const userSession = new GenericUserSession(storage);
|
|
400
|
+
return userSession.get();
|
|
401
|
+
});
|
|
402
|
+
const {
|
|
403
|
+
data: user,
|
|
404
|
+
isLoading: userLoading,
|
|
405
|
+
error: userError
|
|
406
|
+
} = useQuery({
|
|
407
|
+
queryKey: ["user", session == null ? void 0 : session.idToken],
|
|
408
|
+
queryFn: fetchUser,
|
|
409
|
+
enabled: !!(session == null ? void 0 : session.idToken)
|
|
410
|
+
// Only run the query if we have an access token
|
|
411
|
+
});
|
|
412
|
+
const isLoading = authLoading || userLoading;
|
|
413
|
+
const error = authError || userError;
|
|
414
|
+
const userWithIdToken = user ? __spreadProps(__spreadValues({}, user), { idToken }) : null;
|
|
415
|
+
return /* @__PURE__ */ jsx9(
|
|
416
|
+
UserContext.Provider,
|
|
417
|
+
{
|
|
418
|
+
value: {
|
|
419
|
+
user: (_a = inputUser || userWithIdToken) != null ? _a : null,
|
|
420
|
+
isLoading,
|
|
421
|
+
error,
|
|
422
|
+
signIn,
|
|
423
|
+
signOut: inputSignOut || signOut
|
|
424
|
+
},
|
|
425
|
+
children
|
|
426
|
+
}
|
|
427
|
+
);
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
// src/shared/AuthProvider.tsx
|
|
431
|
+
import {
|
|
432
|
+
useCallback as useCallback2,
|
|
433
|
+
useEffect as useEffect2,
|
|
434
|
+
useMemo as useMemo2,
|
|
435
|
+
useRef as useRef2,
|
|
436
|
+
useState as useState2
|
|
437
|
+
} from "react";
|
|
438
|
+
import { useMutation as useMutation2, useQuery as useQuery2, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
439
|
+
import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
440
|
+
var globalThisObject;
|
|
441
|
+
if (typeof window !== "undefined") {
|
|
442
|
+
globalThisObject = window;
|
|
443
|
+
} else if (typeof global !== "undefined") {
|
|
444
|
+
globalThisObject = global;
|
|
445
|
+
} else {
|
|
446
|
+
globalThisObject = Function("return this")();
|
|
447
|
+
}
|
|
448
|
+
globalThisObject.globalThis = globalThisObject;
|
|
449
|
+
function BlockDisplay({ children }) {
|
|
450
|
+
return /* @__PURE__ */ jsx10("div", { className: "cac-relative cac-left-0 cac-top-0 cac-z-50 cac-flex cac-h-screen cac-w-screen cac-items-center cac-justify-center cac-bg-white", children: /* @__PURE__ */ jsx10("div", { className: "cac-absolute cac-inset-0 cac-flex cac-items-center cac-justify-center cac-bg-white", children }) });
|
|
451
|
+
}
|
|
452
|
+
var AuthProvider = ({
|
|
453
|
+
children,
|
|
454
|
+
clientId,
|
|
455
|
+
redirectUrl: inputRedirectUrl,
|
|
456
|
+
config = authConfig,
|
|
457
|
+
onSignIn,
|
|
458
|
+
onSignOut,
|
|
459
|
+
pkceConsumer,
|
|
460
|
+
nonce,
|
|
461
|
+
modalIframe = true,
|
|
462
|
+
sessionData: inputSessionData
|
|
463
|
+
}) => {
|
|
464
|
+
const [iframeUrl, setIframeUrl] = useState2(null);
|
|
465
|
+
const [currentUrl, setCurrentUrl] = useState2(null);
|
|
466
|
+
const [isInIframe, setIsInIframe] = useState2(false);
|
|
467
|
+
const [authResponseUrl, setAuthResponseUrl] = useState2(null);
|
|
468
|
+
const [tokenExchangeError, setTokenExchangeError] = useState2();
|
|
469
|
+
const [displayMode, setDisplayMode] = useState2("iframe");
|
|
470
|
+
const [browserAuthenticationInitiator, setBrowserAuthenticationInitiator] = useState2();
|
|
471
|
+
const [showIFrame, setShowIFrame] = useState2(false);
|
|
472
|
+
const [isRedirecting, setIsRedirecting] = useState2(false);
|
|
473
|
+
const queryClient = useQueryClient2();
|
|
474
|
+
const iframeRef = useRef2(null);
|
|
475
|
+
const serverTokenExchange = pkceConsumer instanceof ConfidentialClientPKCEConsumer;
|
|
476
|
+
useEffect2(() => {
|
|
477
|
+
if (typeof globalThis.window !== "undefined") {
|
|
478
|
+
setCurrentUrl(globalThis.window.location.href);
|
|
479
|
+
const isInIframeVal = isWindowInIframe(globalThis.window);
|
|
480
|
+
setIsInIframe(isInIframeVal);
|
|
481
|
+
}
|
|
482
|
+
}, []);
|
|
483
|
+
const redirectUrl = useMemo2(
|
|
484
|
+
() => (inputRedirectUrl || currentUrl || "").split("?")[0],
|
|
485
|
+
[currentUrl, inputRedirectUrl]
|
|
486
|
+
);
|
|
487
|
+
const [authService, setAuthService] = useState2();
|
|
488
|
+
useEffect2(() => {
|
|
489
|
+
if (!currentUrl) return;
|
|
490
|
+
BrowserAuthenticationService.build({
|
|
491
|
+
clientId,
|
|
492
|
+
redirectUrl,
|
|
493
|
+
oauthServer: config.oauthServer,
|
|
494
|
+
scopes: DEFAULT_SCOPES,
|
|
495
|
+
displayMode
|
|
496
|
+
}).then(setAuthService);
|
|
497
|
+
}, [currentUrl, clientId, redirectUrl, config, displayMode]);
|
|
498
|
+
const {
|
|
499
|
+
data: session,
|
|
500
|
+
isLoading,
|
|
501
|
+
error
|
|
502
|
+
} = useQuery2({
|
|
503
|
+
queryKey: [
|
|
504
|
+
"session",
|
|
505
|
+
authResponseUrl,
|
|
506
|
+
iframeUrl,
|
|
507
|
+
currentUrl,
|
|
508
|
+
isInIframe,
|
|
509
|
+
authService
|
|
510
|
+
],
|
|
511
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
512
|
+
if (!authService) {
|
|
513
|
+
return { authenticated: false };
|
|
514
|
+
}
|
|
515
|
+
if (inputSessionData) {
|
|
516
|
+
return inputSessionData;
|
|
517
|
+
}
|
|
518
|
+
const url = new URL(
|
|
519
|
+
authResponseUrl ? authResponseUrl : globalThis.window.location.href || ""
|
|
520
|
+
);
|
|
521
|
+
const existingSessionData = yield authService.validateExistingSession();
|
|
522
|
+
if (existingSessionData.authenticated) {
|
|
523
|
+
return existingSessionData;
|
|
524
|
+
}
|
|
525
|
+
const code = url.searchParams.get("code");
|
|
526
|
+
const state = url.searchParams.get("state");
|
|
527
|
+
if (!serverTokenExchange && code && state && !isInIframe) {
|
|
528
|
+
try {
|
|
529
|
+
yield authService.tokenExchange(code, state);
|
|
530
|
+
const clientStorage = new LocalStorageAdapter();
|
|
531
|
+
const user = yield getUser(clientStorage);
|
|
532
|
+
if (!user) {
|
|
533
|
+
throw new Error("Failed to get user info");
|
|
534
|
+
}
|
|
535
|
+
const userSession = new GenericUserSession(clientStorage);
|
|
536
|
+
userSession.set(user);
|
|
537
|
+
onSignIn == null ? void 0 : onSignIn();
|
|
538
|
+
return authService.getSessionData();
|
|
539
|
+
} catch (error2) {
|
|
540
|
+
setTokenExchangeError(error2);
|
|
541
|
+
onSignIn == null ? void 0 : onSignIn(
|
|
542
|
+
error2 instanceof Error ? error2 : new Error("Failed to sign in")
|
|
543
|
+
);
|
|
544
|
+
return { authenticated: false };
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return existingSessionData;
|
|
548
|
+
})
|
|
549
|
+
});
|
|
550
|
+
const signOutMutation = useMutation2({
|
|
551
|
+
mutationFn: () => __async(void 0, null, function* () {
|
|
552
|
+
const authInitiator = getAuthInitiator();
|
|
553
|
+
authInitiator == null ? void 0 : authInitiator.signOut();
|
|
554
|
+
setIframeUrl(null);
|
|
555
|
+
setShowIFrame(false);
|
|
556
|
+
setAuthResponseUrl(null);
|
|
557
|
+
onSignOut == null ? void 0 : onSignOut();
|
|
558
|
+
}),
|
|
559
|
+
onSuccess: () => {
|
|
560
|
+
queryClient.setQueryData(
|
|
561
|
+
[
|
|
562
|
+
"session",
|
|
563
|
+
authResponseUrl,
|
|
564
|
+
iframeUrl,
|
|
565
|
+
currentUrl,
|
|
566
|
+
isInIframe,
|
|
567
|
+
authService
|
|
568
|
+
],
|
|
569
|
+
null
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
const getAuthInitiator = useCallback2(
|
|
574
|
+
(overrideDisplayMode) => {
|
|
575
|
+
const useDisplayMode = overrideDisplayMode || displayMode;
|
|
576
|
+
if (!pkceConsumer) {
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
return browserAuthenticationInitiator || new BrowserAuthenticationInitiator({
|
|
580
|
+
pkceConsumer,
|
|
581
|
+
// generate and retrieve the challenge client-side
|
|
582
|
+
clientId,
|
|
583
|
+
redirectUrl,
|
|
584
|
+
state: generateState(useDisplayMode, serverTokenExchange),
|
|
585
|
+
scopes: DEFAULT_SCOPES,
|
|
586
|
+
displayMode: useDisplayMode,
|
|
587
|
+
oauthServer: config.oauthServer,
|
|
588
|
+
// the endpoints to use for the login (if not obtained from the auth server
|
|
589
|
+
endpointOverrides: config.endpoints,
|
|
590
|
+
nonce
|
|
591
|
+
});
|
|
592
|
+
},
|
|
593
|
+
[
|
|
594
|
+
serverTokenExchange,
|
|
595
|
+
displayMode,
|
|
596
|
+
browserAuthenticationInitiator,
|
|
597
|
+
clientId,
|
|
598
|
+
redirectUrl,
|
|
599
|
+
config.oauthServer,
|
|
600
|
+
config.endpoints,
|
|
601
|
+
pkceConsumer,
|
|
602
|
+
nonce
|
|
603
|
+
]
|
|
604
|
+
);
|
|
605
|
+
const signIn = useCallback2(
|
|
606
|
+
(overrideDisplayMode = "iframe") => __async(void 0, null, function* () {
|
|
607
|
+
setDisplayMode(overrideDisplayMode);
|
|
608
|
+
const authInitiator = getAuthInitiator(overrideDisplayMode);
|
|
609
|
+
setBrowserAuthenticationInitiator(authInitiator);
|
|
610
|
+
if (overrideDisplayMode === "iframe") {
|
|
611
|
+
setShowIFrame(true);
|
|
612
|
+
} else if (overrideDisplayMode === "redirect") {
|
|
613
|
+
setIsRedirecting(true);
|
|
614
|
+
}
|
|
615
|
+
authInitiator == null ? void 0 : authInitiator.signIn(iframeRef.current).catch((error2) => {
|
|
616
|
+
console.log("signIn error", {
|
|
617
|
+
error: error2,
|
|
618
|
+
isPopupError: error2 instanceof PopupError
|
|
619
|
+
});
|
|
620
|
+
if (error2 instanceof PopupError) {
|
|
621
|
+
signIn("redirect");
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
}),
|
|
625
|
+
[getAuthInitiator]
|
|
626
|
+
);
|
|
627
|
+
useEffect2(() => {
|
|
628
|
+
return () => {
|
|
629
|
+
if (browserAuthenticationInitiator) {
|
|
630
|
+
browserAuthenticationInitiator.cleanup();
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
}, [browserAuthenticationInitiator]);
|
|
634
|
+
const isAuthenticated = useMemo2(
|
|
635
|
+
() => session ? session.authenticated : false,
|
|
636
|
+
[session]
|
|
637
|
+
);
|
|
638
|
+
useQuery2({
|
|
639
|
+
queryKey: ["autoSignIn", modalIframe, redirectUrl, isAuthenticated],
|
|
640
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
641
|
+
if (!modalIframe && redirectUrl && !isAuthenticated && iframeRef.current) {
|
|
642
|
+
signIn("iframe");
|
|
643
|
+
}
|
|
644
|
+
return true;
|
|
645
|
+
}),
|
|
646
|
+
refetchOnWindowFocus: false
|
|
647
|
+
});
|
|
648
|
+
const value = useMemo2(
|
|
649
|
+
() => ({
|
|
650
|
+
isLoading,
|
|
651
|
+
error,
|
|
652
|
+
signOut: () => __async(void 0, null, function* () {
|
|
653
|
+
yield signOutMutation.mutateAsync();
|
|
654
|
+
}),
|
|
655
|
+
isAuthenticated,
|
|
656
|
+
signIn
|
|
657
|
+
}),
|
|
658
|
+
[isLoading, error, signOutMutation, isAuthenticated, signIn]
|
|
659
|
+
);
|
|
660
|
+
return /* @__PURE__ */ jsx10(AuthContext.Provider, { value, children: /* @__PURE__ */ jsx10(
|
|
661
|
+
ConfigProvider,
|
|
662
|
+
{
|
|
663
|
+
config,
|
|
664
|
+
redirectUrl,
|
|
665
|
+
modalIframe,
|
|
666
|
+
serverTokenExchange,
|
|
667
|
+
children: /* @__PURE__ */ jsx10(
|
|
668
|
+
IframeProvider,
|
|
669
|
+
{
|
|
670
|
+
setAuthResponseUrl,
|
|
671
|
+
iframeRef,
|
|
672
|
+
children: /* @__PURE__ */ jsx10(SessionProvider, { session, children: /* @__PURE__ */ jsxs4(TokenProvider, { children: [
|
|
673
|
+
modalIframe && !isInIframe && !(session == null ? void 0 : session.authenticated) && /* @__PURE__ */ jsx10(
|
|
674
|
+
"div",
|
|
675
|
+
{
|
|
676
|
+
style: showIFrame ? { display: "block" } : { display: "none" },
|
|
677
|
+
children: /* @__PURE__ */ jsx10(
|
|
678
|
+
CivicAuthIframeContainer,
|
|
679
|
+
{
|
|
680
|
+
onClose: () => setShowIFrame(false)
|
|
681
|
+
}
|
|
682
|
+
)
|
|
683
|
+
}
|
|
684
|
+
),
|
|
685
|
+
modalIframe && (isInIframe || isRedirecting || isLoading && !serverTokenExchange) && /* @__PURE__ */ jsx10(BlockDisplay, { children: /* @__PURE__ */ jsx10(LoadingIcon, {}) }),
|
|
686
|
+
(tokenExchangeError || error) && /* @__PURE__ */ jsx10(BlockDisplay, { children: /* @__PURE__ */ jsxs4("div", { children: [
|
|
687
|
+
"Error: ",
|
|
688
|
+
(tokenExchangeError || error).message
|
|
689
|
+
] }) }),
|
|
690
|
+
children
|
|
691
|
+
] }) })
|
|
692
|
+
}
|
|
693
|
+
)
|
|
694
|
+
}
|
|
695
|
+
) });
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
export {
|
|
699
|
+
useAuth,
|
|
700
|
+
useSession,
|
|
701
|
+
useToken,
|
|
702
|
+
UserContext,
|
|
703
|
+
UserProvider,
|
|
704
|
+
useConfig,
|
|
705
|
+
useIframe,
|
|
706
|
+
CivicAuthIframeContainer,
|
|
707
|
+
AuthProvider
|
|
708
|
+
};
|
|
709
|
+
//# sourceMappingURL=chunk-SYJZGEFV.mjs.map
|