@civic/auth 0.0.1-beta.18 → 0.0.1-beta.2

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.
Files changed (52) hide show
  1. package/README.md +0 -26
  2. package/dist/chunk-5NUJ7LFF.mjs +17 -0
  3. package/dist/chunk-5NUJ7LFF.mjs.map +1 -0
  4. package/dist/chunk-KS7ERXGZ.js +481 -0
  5. package/dist/chunk-KS7ERXGZ.js.map +1 -0
  6. package/dist/chunk-NINRO7GS.js +209 -0
  7. package/dist/chunk-NINRO7GS.js.map +1 -0
  8. package/dist/chunk-NXBKSUKI.mjs +481 -0
  9. package/dist/chunk-NXBKSUKI.mjs.map +1 -0
  10. package/dist/chunk-T7HUHQ3J.mjs +209 -0
  11. package/dist/chunk-T7HUHQ3J.mjs.map +1 -0
  12. package/dist/chunk-WZLC5B4C.js +17 -0
  13. package/dist/chunk-WZLC5B4C.js.map +1 -0
  14. package/dist/index-DoDoIY_K.d.mts +79 -0
  15. package/dist/index-DoDoIY_K.d.ts +79 -0
  16. package/dist/index.css +70 -63
  17. package/dist/index.css.map +1 -1
  18. package/dist/index.d.mts +1 -3
  19. package/dist/index.d.ts +1 -3
  20. package/dist/nextjs.d.mts +11 -10
  21. package/dist/nextjs.d.ts +11 -10
  22. package/dist/nextjs.js +173 -62
  23. package/dist/nextjs.js.map +1 -1
  24. package/dist/nextjs.mjs +171 -60
  25. package/dist/nextjs.mjs.map +1 -1
  26. package/dist/react.d.mts +65 -39
  27. package/dist/react.d.ts +65 -39
  28. package/dist/react.js +212 -433
  29. package/dist/react.js.map +1 -1
  30. package/dist/react.mjs +235 -456
  31. package/dist/react.mjs.map +1 -1
  32. package/dist/server.d.mts +12 -13
  33. package/dist/server.d.ts +12 -13
  34. package/dist/server.js +186 -3
  35. package/dist/server.js.map +1 -1
  36. package/dist/server.mjs +192 -9
  37. package/dist/server.mjs.map +1 -1
  38. package/package.json +4 -4
  39. package/dist/chunk-5XL2ST72.mjs +0 -226
  40. package/dist/chunk-5XL2ST72.mjs.map +0 -1
  41. package/dist/chunk-G3P5TIO2.mjs +0 -708
  42. package/dist/chunk-G3P5TIO2.mjs.map +0 -1
  43. package/dist/chunk-RF23Q4V6.js +0 -708
  44. package/dist/chunk-RF23Q4V6.js.map +0 -1
  45. package/dist/chunk-SEKF2WZX.js +0 -226
  46. package/dist/chunk-SEKF2WZX.js.map +0 -1
  47. package/dist/index-DTimUlkB.d.ts +0 -17
  48. package/dist/index-DvjkKpkk.d.mts +0 -17
  49. package/dist/types-HdCjGldB.d.mts +0 -58
  50. package/dist/types-HdCjGldB.d.ts +0 -58
  51. package/dist/types-b4c1koXj.d.mts +0 -19
  52. package/dist/types-b4c1koXj.d.ts +0 -19
package/dist/react.mjs CHANGED
@@ -1,24 +1,14 @@
1
1
  import {
2
- NextjsClientStorage,
3
- resolveAuthConfig,
4
- resolveCallbackUrl
5
- } from "./chunk-5XL2ST72.mjs";
2
+ AuthSessionServiceImpl,
3
+ resolveAuthConfig
4
+ } from "./chunk-NXBKSUKI.mjs";
6
5
  import {
7
- BrowserAuthenticationInitiator,
8
- BrowserAuthenticationService,
9
- BrowserPublicClientPKCEProducer,
10
- ConfidentialClientPKCEConsumer,
11
6
  DEFAULT_SCOPES,
12
- GenericUserSession,
13
- IFRAME_ID,
14
- LocalStorageAdapter,
15
- TOKEN_EXCHANGE_TRIGGER_TEXT,
16
- cn,
17
- convertForwardedTokenFormat,
18
- generateState,
19
- getUser,
20
- isWindowInIframe
21
- } from "./chunk-G3P5TIO2.mjs";
7
+ IFRAME_ID
8
+ } from "./chunk-5NUJ7LFF.mjs";
9
+ import {
10
+ cn
11
+ } from "./chunk-T7HUHQ3J.mjs";
22
12
  import {
23
13
  __async,
24
14
  __objRest,
@@ -27,9 +17,9 @@ import {
27
17
  } from "./chunk-RGHW4PYM.mjs";
28
18
 
29
19
  // src/react/hooks/useUser.tsx
30
- import { useContext as useContext4 } from "react";
20
+ import { useContext as useContext5 } from "react";
31
21
 
32
- // src/shared/UserProvider.tsx
22
+ // src/react/providers/UserProvider.tsx
33
23
  import { createContext as createContext4 } from "react";
34
24
  import { useQuery } from "@tanstack/react-query";
35
25
 
@@ -69,7 +59,7 @@ var defaultSession = {
69
59
  displayMode: "iframe"
70
60
  };
71
61
  var SessionContext = createContext2(defaultSession);
72
- var SessionProvider = ({ children, session }) => /* @__PURE__ */ jsx(SessionContext.Provider, { value: __spreadValues(__spreadValues({}, defaultSession), session || {}), children });
62
+ var SessionProvider = ({ children, session }) => /* @__PURE__ */ jsx(SessionContext.Provider, { value: session || defaultSession, children });
73
63
 
74
64
  // src/react/hooks/useSession.tsx
75
65
  var useSession = () => {
@@ -82,6 +72,20 @@ var useSession = () => {
82
72
 
83
73
  // src/react/providers/TokenProvider.tsx
84
74
  import { parseJWT } from "oslo/jwt";
75
+
76
+ // src/lib/jwt.ts
77
+ var convertForwardedTokenFormat = (inputTokens) => Object.fromEntries(
78
+ Object.entries(inputTokens).map(([source, tokens]) => [
79
+ source,
80
+ {
81
+ idToken: tokens == null ? void 0 : tokens.id_token,
82
+ accessToken: tokens == null ? void 0 : tokens.access_token,
83
+ refreshToken: tokens == null ? void 0 : tokens.refresh_token
84
+ }
85
+ ])
86
+ );
87
+
88
+ // src/react/providers/TokenProvider.tsx
85
89
  import { jsx as jsx2 } from "react/jsx-runtime";
86
90
  var TokenContext = createContext3(void 0);
87
91
  var TokenProvider = ({ children }) => {
@@ -134,26 +138,31 @@ var useToken = () => {
134
138
  return context;
135
139
  };
136
140
 
137
- // src/shared/UserProvider.tsx
141
+ // src/react/providers/UserProvider.tsx
138
142
  import { jsx as jsx3 } from "react/jsx-runtime";
139
143
  var UserContext = createContext4(null);
140
144
  var UserProvider = ({
141
145
  children,
142
- storage,
143
- user: inputUser,
144
- signOut: inputSignOut
146
+ userInfoService
145
147
  }) => {
146
- var _a;
147
148
  const { isLoading: authLoading, error: authError } = useAuth();
148
149
  const session = useSession();
149
- const { accessToken } = useToken();
150
+ const { forwardedTokens, idToken, accessToken, refreshToken } = useToken();
150
151
  const { signIn, signOut } = useAuth();
151
152
  const fetchUser = () => __async(void 0, null, function* () {
152
- if (!accessToken) {
153
+ if (!accessToken || !userInfoService) {
154
+ return null;
155
+ }
156
+ const user2 = yield userInfoService == null ? void 0 : userInfoService.getUserInfo(accessToken, idToken);
157
+ if (!user2) {
153
158
  return null;
154
159
  }
155
- const userSession = new GenericUserSession(storage);
156
- return userSession.get();
160
+ return __spreadProps(__spreadValues({}, user2), {
161
+ forwardedTokens,
162
+ idToken,
163
+ accessToken,
164
+ refreshToken
165
+ });
157
166
  });
158
167
  const {
159
168
  data: user,
@@ -171,11 +180,11 @@ var UserProvider = ({
171
180
  UserContext.Provider,
172
181
  {
173
182
  value: {
174
- user: (_a = inputUser || user) != null ? _a : null,
183
+ user: user != null ? user : null,
175
184
  isLoading,
176
185
  error,
177
186
  signIn,
178
- signOut: inputSignOut || signOut
187
+ signOut
179
188
  },
180
189
  children
181
190
  }
@@ -192,7 +201,7 @@ import {
192
201
  } from "react";
193
202
  import { useMutation as useMutation2, useQuery as useQuery2, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
194
203
 
195
- // src/react/components/CivicAuthIframeContainer.tsx
204
+ // src/react/components/CivicAuthIframeModal.tsx
196
205
  import { useCallback, useEffect, useRef, useState } from "react";
197
206
 
198
207
  // src/react/components/LoadingIcon.tsx
@@ -202,7 +211,7 @@ var LoadingIcon = () => /* @__PURE__ */ jsxs("div", { role: "status", children:
202
211
  "svg",
203
212
  {
204
213
  "aria-hidden": "true",
205
- 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",
214
+ className: "inline h-8 w-8 animate-spin fill-neutral-600 text-neutral-200 dark:fill-neutral-300 dark:text-neutral-600",
206
215
  viewBox: "0 0 100 101",
207
216
  fill: "none",
208
217
  xmlns: "http://www.w3.org/2000/svg",
@@ -224,7 +233,7 @@ var LoadingIcon = () => /* @__PURE__ */ jsxs("div", { role: "status", children:
224
233
  ]
225
234
  }
226
235
  ),
227
- /* @__PURE__ */ jsx4("span", { className: "cac-sr-only", children: "Loading..." })
236
+ /* @__PURE__ */ jsx4("span", { className: "sr-only", children: "Loading..." })
228
237
  ] });
229
238
 
230
239
  // src/react/components/CloseIcon.tsx
@@ -253,13 +262,14 @@ var CloseIcon = () => /* @__PURE__ */ jsxs2(
253
262
  import { forwardRef } from "react";
254
263
  import { jsx as jsx6 } from "react/jsx-runtime";
255
264
  var CivicAuthIframe = forwardRef(
256
- ({ onLoad }, ref) => {
265
+ ({ authUrl, onLoad }, ref) => {
257
266
  return /* @__PURE__ */ jsx6(
258
267
  "iframe",
259
268
  {
260
269
  id: IFRAME_ID,
261
270
  ref,
262
- className: "cac-h-[26rem] cac-w-80 cac-border-none",
271
+ src: authUrl,
272
+ className: "h-96 w-80 border-none",
263
273
  onLoad
264
274
  }
265
275
  );
@@ -267,69 +277,25 @@ var CivicAuthIframe = forwardRef(
267
277
  );
268
278
  CivicAuthIframe.displayName = "CivicAuthIframe";
269
279
 
270
- // src/react/components/CivicAuthIframeContainer.tsx
280
+ // src/react/components/CivicAuthIframeModal.tsx
271
281
  import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
272
- function NoChrome({
273
- children
274
- }) {
275
- return /* @__PURE__ */ jsx7("div", { className: "cac-relative", children });
276
- }
277
- function IframeChrome({
278
- children,
279
- onClose
280
- }) {
281
- return /* @__PURE__ */ jsx7(
282
- "div",
283
- {
284
- className: "cac-absolute 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-neutral-950 cac-bg-opacity-50",
285
- onClick: onClose,
286
- children: /* @__PURE__ */ jsxs3(
287
- "div",
288
- {
289
- className: "cac-relative cac-rounded-3xl cac-bg-white cac-p-6 cac-shadow-lg",
290
- onClick: (e) => e.stopPropagation(),
291
- children: [
292
- /* @__PURE__ */ jsx7(
293
- "button",
294
- {
295
- 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",
296
- onClick: onClose,
297
- children: /* @__PURE__ */ jsx7(CloseIcon, {})
298
- }
299
- ),
300
- children
301
- ]
302
- }
303
- )
304
- }
305
- );
306
- }
307
- var CivicAuthIframeContainer = ({
282
+ var CivicAuthIframeModal = ({
283
+ authUrl,
284
+ redirectUri,
285
+ setAuthResponseUrl,
308
286
  onClose,
287
+ iframeRef,
288
+ redirectInProgress = false,
309
289
  closeOnRedirect = true
310
290
  }) => {
311
- var _a;
312
291
  const [isLoading, setIsLoading] = useState(true);
313
- const { isLoading: isAuthLoading } = useAuth();
314
- const config = useConfig();
315
- const { setAuthResponseUrl, iframeRef } = useIframe();
316
292
  const processIframeUrl = useCallback(() => {
317
- if (iframeRef && iframeRef.current && iframeRef.current.contentWindow) {
293
+ if (iframeRef.current && iframeRef.current.contentWindow) {
318
294
  try {
319
295
  const iframeUrl = iframeRef.current.contentWindow.location.href;
320
- if (iframeUrl.startsWith(config.redirectUrl)) {
321
- setIsLoading(true);
322
- const iframeBody = iframeRef.current.contentWindow.document.body.innerHTML;
323
- if (iframeBody.includes(TOKEN_EXCHANGE_TRIGGER_TEXT)) {
324
- console.log(
325
- `${TOKEN_EXCHANGE_TRIGGER_TEXT}, calling callback URL again...`
326
- );
327
- const params = new URL(iframeUrl).searchParams;
328
- fetch(`${config.redirectUrl}?${params.toString()}`);
329
- } else {
330
- setAuthResponseUrl(iframeUrl);
331
- }
332
- if (closeOnRedirect) onClose == null ? void 0 : onClose();
296
+ if (iframeUrl.startsWith(redirectUri)) {
297
+ setAuthResponseUrl(iframeUrl);
298
+ if (closeOnRedirect) onClose();
333
299
  return true;
334
300
  }
335
301
  } catch (e) {
@@ -337,18 +303,12 @@ var CivicAuthIframeContainer = ({
337
303
  }
338
304
  }
339
305
  return false;
340
- }, [
341
- closeOnRedirect,
342
- config.redirectUrl,
343
- iframeRef,
344
- onClose,
345
- setAuthResponseUrl
346
- ]);
306
+ }, [closeOnRedirect, iframeRef, onClose, redirectUri, setAuthResponseUrl]);
347
307
  const intervalId = useRef();
348
308
  const handleEscape = useCallback(
349
309
  (event) => {
350
310
  if (event.key === "Escape") {
351
- onClose == null ? void 0 : onClose();
311
+ onClose();
352
312
  }
353
313
  },
354
314
  [onClose]
@@ -364,12 +324,39 @@ var CivicAuthIframeContainer = ({
364
324
  clearInterval(intervalId.current);
365
325
  }
366
326
  };
367
- const showLoadingIcon = isLoading || isAuthLoading || !((_a = iframeRef == null ? void 0 : iframeRef.current) == null ? void 0 : _a.getAttribute("src"));
368
- const WrapperComponent = config.modalIframe ? IframeChrome : NoChrome;
369
- return /* @__PURE__ */ jsxs3(WrapperComponent, { onClose, children: [
370
- showLoadingIcon && /* @__PURE__ */ jsx7("div", { className: "cac-absolute cac-inset-0 cac-flex cac-items-center cac-justify-center cac-rounded-3xl cac-bg-white", children: /* @__PURE__ */ jsx7(LoadingIcon, {}) }),
371
- /* @__PURE__ */ jsx7(CivicAuthIframe, { ref: iframeRef, onLoad: handleIframeLoad })
372
- ] });
327
+ return /* @__PURE__ */ jsx7(
328
+ "div",
329
+ {
330
+ className: "absolute left-0 top-0 z-50 flex h-screen w-screen items-center justify-center bg-neutral-950 bg-opacity-50",
331
+ onClick: onClose,
332
+ children: /* @__PURE__ */ jsxs3(
333
+ "div",
334
+ {
335
+ className: "relative rounded-3xl bg-white p-6 shadow-lg",
336
+ onClick: (e) => e.stopPropagation(),
337
+ children: [
338
+ /* @__PURE__ */ jsx7(
339
+ "button",
340
+ {
341
+ className: "absolute right-4 top-4 flex cursor-pointer items-center justify-center border-none bg-transparent p-1 text-neutral-400",
342
+ onClick: onClose,
343
+ children: /* @__PURE__ */ jsx7(CloseIcon, {})
344
+ }
345
+ ),
346
+ (isLoading || redirectInProgress) && /* @__PURE__ */ jsx7("div", { className: "absolute inset-0 flex items-center justify-center rounded-3xl bg-neutral-100", children: /* @__PURE__ */ jsx7(LoadingIcon, {}) }),
347
+ /* @__PURE__ */ jsx7(
348
+ CivicAuthIframe,
349
+ {
350
+ ref: iframeRef,
351
+ authUrl,
352
+ onLoad: handleIframeLoad
353
+ }
354
+ )
355
+ ]
356
+ }
357
+ )
358
+ }
359
+ );
373
360
  };
374
361
 
375
362
  // src/config.ts
@@ -378,54 +365,23 @@ var authConfig = {
378
365
  oauthServer: "https://auth-dev.civic.com/oauth/"
379
366
  };
380
367
 
381
- // src/react/providers/ConfigProvider.tsx
382
- import { createContext as createContext5 } from "react";
383
- import { jsx as jsx8 } from "react/jsx-runtime";
384
- var defaultConfig = {
385
- config: authConfig,
386
- redirectUrl: "",
387
- modalIframe: true,
388
- serverTokenExchange: false
389
- };
390
- var ConfigContext = createContext5(defaultConfig);
391
- var ConfigProvider = ({
392
- children,
393
- config,
394
- redirectUrl,
395
- modalIframe,
396
- serverTokenExchange
397
- }) => /* @__PURE__ */ jsx8(
398
- ConfigContext.Provider,
399
- {
400
- value: {
401
- config,
402
- redirectUrl,
403
- modalIframe: !!modalIframe,
404
- serverTokenExchange
405
- },
406
- children
407
- }
408
- );
409
-
410
- // src/react/providers/IframeProvider.tsx
411
- import {
412
- createContext as createContext6
413
- } from "react";
414
- import { jsx as jsx9 } from "react/jsx-runtime";
415
- var defaultIframe = {
416
- iframeRef: null,
417
- setAuthResponseUrl: () => {
368
+ // src/lib/windowUtil.ts
369
+ var isWindowInIframe = (window2) => {
370
+ var _a;
371
+ if (typeof window2 !== "undefined") {
372
+ try {
373
+ if (((_a = window2 == null ? void 0 : window2.frameElement) == null ? void 0 : _a.id) === "civic-auth-iframe") {
374
+ return true;
375
+ }
376
+ } catch (_e) {
377
+ return false;
378
+ }
418
379
  }
380
+ return false;
419
381
  };
420
- var IframeContext = createContext6(defaultIframe);
421
- var IframeProvider = ({
422
- children,
423
- iframeRef,
424
- setAuthResponseUrl
425
- }) => /* @__PURE__ */ jsx9(IframeContext.Provider, { value: { iframeRef, setAuthResponseUrl }, children });
426
382
 
427
383
  // src/shared/AuthProvider.tsx
428
- import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
384
+ import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
429
385
  var globalThisObject;
430
386
  if (typeof window !== "undefined") {
431
387
  globalThisObject = window;
@@ -435,33 +391,24 @@ if (typeof window !== "undefined") {
435
391
  globalThisObject = Function("return this")();
436
392
  }
437
393
  globalThisObject.globalThis = globalThisObject;
438
- function BlockDisplay({ children }) {
439
- 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 }) });
440
- }
441
394
  var AuthProvider = ({
442
395
  children,
443
396
  clientId,
444
397
  redirectUrl: inputRedirectUrl,
445
398
  config = authConfig,
399
+ nonce,
446
400
  onSignIn,
447
401
  onSignOut,
448
- pkceConsumer,
449
- nonce,
450
- modalIframe = true,
451
- sessionData: inputSessionData
402
+ authServiceImpl,
403
+ serverSideTokenExchange
452
404
  }) => {
453
405
  const [iframeUrl, setIframeUrl] = useState2(null);
454
406
  const [currentUrl, setCurrentUrl] = useState2(null);
455
407
  const [isInIframe, setIsInIframe] = useState2(false);
456
408
  const [authResponseUrl, setAuthResponseUrl] = useState2(null);
457
409
  const [tokenExchangeError, setTokenExchangeError] = useState2();
458
- const [displayMode, setDisplayMode] = useState2("iframe");
459
- const [browserAuthenticationInitiator, setBrowserAuthenticationInitiator] = useState2();
460
- const [showIFrame, setShowIFrame] = useState2(false);
461
- const [isRedirecting, setIsRedirecting] = useState2(false);
462
410
  const queryClient3 = useQueryClient2();
463
411
  const iframeRef = useRef2(null);
464
- const serverTokenExchange = pkceConsumer instanceof ConfidentialClientPKCEConsumer;
465
412
  useEffect2(() => {
466
413
  if (typeof globalThis.window !== "undefined") {
467
414
  setCurrentUrl(globalThis.window.location.href);
@@ -473,63 +420,40 @@ var AuthProvider = ({
473
420
  () => (inputRedirectUrl || currentUrl || "").split("?")[0],
474
421
  [currentUrl, inputRedirectUrl]
475
422
  );
476
- const [authService, setAuthService] = useState2();
477
- useEffect2(() => {
478
- if (!currentUrl) return;
479
- BrowserAuthenticationService.build({
423
+ const authService = useMemo2(
424
+ () => currentUrl ? authServiceImpl || new AuthSessionServiceImpl(
480
425
  clientId,
481
426
  redirectUrl,
482
- oauthServer: config.oauthServer,
483
- scopes: DEFAULT_SCOPES,
484
- displayMode
485
- }).then(setAuthService);
486
- }, [currentUrl, clientId, redirectUrl, config, displayMode]);
427
+ config == null ? void 0 : config.oauthServer,
428
+ config == null ? void 0 : config.endpoints
429
+ ) : null,
430
+ [currentUrl, clientId, redirectUrl, config, authServiceImpl]
431
+ );
432
+ const [userInfoService, setUserInfoService] = useState2();
433
+ useEffect2(() => {
434
+ if (!authService) return;
435
+ authService.getUserInfoService().then(setUserInfoService);
436
+ }, [authService]);
487
437
  const {
488
438
  data: session,
489
439
  isLoading,
490
440
  error
491
441
  } = useQuery2({
492
- queryKey: [
493
- "session",
494
- authResponseUrl,
495
- iframeUrl,
496
- currentUrl,
497
- isInIframe,
498
- authService
499
- ],
442
+ queryKey: ["session", authResponseUrl, iframeUrl, currentUrl, isInIframe],
500
443
  queryFn: () => __async(void 0, null, function* () {
501
444
  if (!authService) {
502
445
  return { authenticated: false };
503
446
  }
504
- if (inputSessionData) {
505
- return inputSessionData;
506
- }
507
447
  const url = new URL(
508
448
  authResponseUrl ? authResponseUrl : globalThis.window.location.href || ""
509
449
  );
510
- const existingSessionData = yield authService.validateExistingSession();
511
- if (existingSessionData.authenticated) {
512
- return existingSessionData;
513
- }
514
450
  const code = url.searchParams.get("code");
515
- const state = url.searchParams.get("state");
516
- if (!serverTokenExchange && code && state && !isInIframe) {
451
+ if (code && !isInIframe && !serverSideTokenExchange) {
517
452
  try {
518
- console.log("AuthProvider useQuery code", {
519
- isInIframe,
520
- code,
521
- state
522
- });
523
- yield authService.tokenExchange(code, state);
524
- const clientStorage = new LocalStorageAdapter();
525
- const user = yield getUser(clientStorage);
526
- if (!user) {
527
- throw new Error("Failed to get user info");
528
- }
529
- const userSession = new GenericUserSession(clientStorage);
530
- userSession.set(user);
453
+ console.log("AuthProvider useQuery code", { isInIframe, code });
454
+ const newSession = yield authService.tokenExchange(url.toString());
531
455
  onSignIn == null ? void 0 : onSignIn();
532
- return authService.getSessionData();
456
+ return newSession;
533
457
  } catch (error2) {
534
458
  setTokenExchangeError(error2);
535
459
  onSignIn == null ? void 0 : onSignIn(
@@ -538,91 +462,48 @@ var AuthProvider = ({
538
462
  return { authenticated: false };
539
463
  }
540
464
  }
465
+ const existingSessionData = yield authService.validateExistingSession();
466
+ if (existingSessionData.authenticated) {
467
+ return existingSessionData;
468
+ }
541
469
  return existingSessionData;
542
470
  })
543
471
  });
544
472
  const signOutMutation = useMutation2({
545
473
  mutationFn: () => __async(void 0, null, function* () {
546
- const authInitiator = getAuthInitiator();
547
- authInitiator == null ? void 0 : authInitiator.signOut();
474
+ authService == null ? void 0 : authService.updateSessionData({});
548
475
  setIframeUrl(null);
549
- setShowIFrame(false);
550
476
  setAuthResponseUrl(null);
551
477
  onSignOut == null ? void 0 : onSignOut();
552
478
  }),
553
479
  onSuccess: () => {
554
480
  queryClient3.setQueryData(
555
- [
556
- "session",
557
- authResponseUrl,
558
- iframeUrl,
559
- currentUrl,
560
- isInIframe,
561
- authService
562
- ],
481
+ ["session", authResponseUrl, iframeUrl, currentUrl, isInIframe],
563
482
  null
564
483
  );
565
484
  }
566
485
  });
567
- const getAuthInitiator = useCallback2(
568
- (overrideDisplayMode) => {
569
- const useDisplayMode = overrideDisplayMode || displayMode;
570
- if (!pkceConsumer) {
571
- return null;
572
- }
573
- return browserAuthenticationInitiator || new BrowserAuthenticationInitiator({
574
- pkceConsumer,
575
- // generate and retrieve the challenge client-side
576
- clientId,
577
- redirectUrl,
578
- state: generateState(useDisplayMode),
579
- scopes: DEFAULT_SCOPES,
580
- displayMode: useDisplayMode,
581
- oauthServer: config.oauthServer,
582
- // the endpoints to use for the login (if not obtained from the auth server
583
- endpointOverrides: config.endpoints,
584
- nonce
585
- });
586
- },
587
- [
588
- displayMode,
589
- browserAuthenticationInitiator,
590
- clientId,
591
- redirectUrl,
592
- config.oauthServer,
593
- config.endpoints,
594
- pkceConsumer,
595
- nonce
596
- ]
597
- );
598
486
  const signIn = useCallback2(
599
487
  (overrideDisplayMode = "iframe") => __async(void 0, null, function* () {
600
- setDisplayMode(overrideDisplayMode);
601
- const authInitiator = getAuthInitiator(overrideDisplayMode);
602
- setBrowserAuthenticationInitiator(authInitiator);
488
+ if (!authService) return;
489
+ const url = yield authService.getAuthorizationUrl(
490
+ // This is the default scope. We will eventually pull this from the partner dashboard
491
+ DEFAULT_SCOPES,
492
+ overrideDisplayMode,
493
+ nonce
494
+ );
603
495
  if (overrideDisplayMode === "iframe") {
604
- setShowIFrame(true);
605
- } else if (overrideDisplayMode === "redirect") {
606
- setIsRedirecting(true);
496
+ setIframeUrl(url);
497
+ return;
607
498
  }
608
- authInitiator == null ? void 0 : authInitiator.signIn(iframeRef.current);
499
+ authService.loadAuthorizationUrl(url, overrideDisplayMode);
609
500
  }),
610
- [getAuthInitiator]
501
+ [authService, nonce]
611
502
  );
612
503
  const isAuthenticated = useMemo2(
613
504
  () => session ? session.authenticated : false,
614
505
  [session]
615
506
  );
616
- useQuery2({
617
- queryKey: ["autoSignIn", modalIframe, redirectUrl, isAuthenticated],
618
- queryFn: () => __async(void 0, null, function* () {
619
- if (!modalIframe && redirectUrl && !isAuthenticated && iframeRef.current) {
620
- signIn("iframe");
621
- }
622
- return true;
623
- }),
624
- refetchOnWindowFocus: false
625
- });
626
507
  const value = useMemo2(
627
508
  () => ({
628
509
  isLoading,
@@ -635,86 +516,55 @@ var AuthProvider = ({
635
516
  }),
636
517
  [isLoading, error, signOutMutation, isAuthenticated, signIn]
637
518
  );
638
- return /* @__PURE__ */ jsx10(AuthContext.Provider, { value, children: /* @__PURE__ */ jsx10(
639
- ConfigProvider,
640
- {
641
- config,
642
- redirectUrl,
643
- modalIframe,
644
- serverTokenExchange,
645
- children: /* @__PURE__ */ jsx10(
646
- IframeProvider,
647
- {
648
- setAuthResponseUrl,
649
- iframeRef,
650
- children: /* @__PURE__ */ jsx10(SessionProvider, { session, children: /* @__PURE__ */ jsxs4(TokenProvider, { children: [
651
- modalIframe && !isInIframe && !(session == null ? void 0 : session.authenticated) && /* @__PURE__ */ jsx10(
652
- "div",
653
- {
654
- style: showIFrame ? { display: "block" } : { display: "none" },
655
- children: /* @__PURE__ */ jsx10(
656
- CivicAuthIframeContainer,
657
- {
658
- onClose: () => setShowIFrame(false)
659
- }
660
- )
661
- }
662
- ),
663
- modalIframe && (isInIframe || isRedirecting || isLoading && !serverTokenExchange) && /* @__PURE__ */ jsx10(BlockDisplay, { children: /* @__PURE__ */ jsx10(LoadingIcon, {}) }),
664
- (tokenExchangeError || error) && /* @__PURE__ */ jsx10(BlockDisplay, { children: /* @__PURE__ */ jsxs4("div", { children: [
665
- "Error: ",
666
- (tokenExchangeError || error).message
667
- ] }) }),
668
- children
669
- ] }) })
670
- }
671
- )
672
- }
673
- ) });
519
+ return /* @__PURE__ */ jsx8(AuthContext.Provider, { value, children: /* @__PURE__ */ jsx8(SessionProvider, { session, children: /* @__PURE__ */ jsx8(TokenProvider, { children: /* @__PURE__ */ jsxs4(UserProvider, { userInfoService, children: [
520
+ !isInIframe && iframeUrl && !(session == null ? void 0 : session.authenticated) && /* @__PURE__ */ jsx8(
521
+ CivicAuthIframeModal,
522
+ {
523
+ iframeRef,
524
+ authUrl: iframeUrl,
525
+ redirectUri: redirectUrl,
526
+ setAuthResponseUrl,
527
+ onClose: () => setIframeUrl(null)
528
+ }
529
+ ),
530
+ (tokenExchangeError || isLoading || error || isInIframe && !(tokenExchangeError || error)) && /* @__PURE__ */ jsx8("div", { className: "absolute left-0 top-0 z-50 flex h-screen w-screen items-center justify-center bg-white", children: /* @__PURE__ */ jsx8("div", { className: "absolute inset-0 flex items-center justify-center bg-white", children: tokenExchangeError || error ? /* @__PURE__ */ jsxs4("div", { children: [
531
+ "Error: ",
532
+ (tokenExchangeError || error).message
533
+ ] }) : /* @__PURE__ */ jsx8(LoadingIcon, {}) }) }),
534
+ children
535
+ ] }) }) }) });
674
536
  };
675
537
 
676
538
  // src/shared/CivicAuthProvider.tsx
677
539
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
678
540
  import "@civic/auth/styles.css";
679
- import { jsx as jsx11 } from "react/jsx-runtime";
541
+ import { jsx as jsx9 } from "react/jsx-runtime";
680
542
  var queryClient = new QueryClient();
681
543
  var CivicAuthProvider = (_a) => {
682
544
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
683
- return /* @__PURE__ */ jsx11(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx11(
684
- AuthProvider,
685
- __spreadProps(__spreadValues({}, props), {
686
- pkceConsumer: new BrowserPublicClientPKCEProducer(),
687
- children: /* @__PURE__ */ jsx11(UserProvider, { storage: new LocalStorageAdapter(), children })
688
- })
689
- ) });
545
+ return /* @__PURE__ */ jsx9(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx9(AuthProvider, __spreadProps(__spreadValues({}, props), { children })) });
690
546
  };
691
547
 
692
548
  // src/react/providers/NextAuthProvider.tsx
693
- import { useEffect as useEffect4, useState as useState3 } from "react";
694
- import { QueryClient as QueryClient2, QueryClientProvider as QueryClientProvider2 } from "@tanstack/react-query";
695
- import "@civic/auth/styles.css";
549
+ import { createContext as createContext5, useContext as useContext4, useEffect as useEffect4, useMemo as useMemo3, useState as useState3 } from "react";
696
550
 
697
- // src/react/hooks/useTokenCookie.ts
551
+ // src/react/hooks/useUserCookie.ts
698
552
  import { useEffect as useEffect3, useRef as useRef3 } from "react";
699
553
  import { useRouter } from "next/navigation.js";
700
554
  import { useQuery as useQuery3 } from "@tanstack/react-query";
701
555
 
702
556
  // src/lib/cookies.ts
703
- var getWindowCookieValue = ({
704
- key,
705
- window: window2,
706
- parseJson = false
707
- }) => {
557
+ var getCookieValue = (key, window2) => {
708
558
  const cookie = window2.document.cookie;
709
559
  if (!cookie) return null;
710
560
  const cookies = cookie.split(";");
711
561
  for (const c of cookies) {
712
562
  const [name, value] = c.trim().split("=");
713
- if (value && name === key) {
563
+ if (name === key) {
714
564
  try {
715
- const decodeURIComponentValue = decodeURIComponent(value);
716
- return parseJson === true ? JSON.parse(decodeURIComponentValue) : decodeURIComponentValue;
565
+ return JSON.parse(decodeURIComponent(value));
717
566
  } catch (e) {
567
+ console.log("Error parsing cookie value", e);
718
568
  return value;
719
569
  }
720
570
  }
@@ -722,27 +572,24 @@ var getWindowCookieValue = ({
722
572
  return null;
723
573
  };
724
574
 
725
- // src/react/hooks/useTokenCookie.ts
726
- var getTokenFromCookie = (tokenName) => {
727
- return getWindowCookieValue({
728
- key: tokenName,
729
- window: globalThis.window,
730
- parseJson: false
731
- });
575
+ // src/react/hooks/useUserCookie.ts
576
+ var getUserFromCookie = () => {
577
+ const userCookie = getCookieValue("user", globalThis.window);
578
+ return userCookie;
732
579
  };
733
- var useTokenCookie = (tokenName) => {
580
+ var useUserCookie = () => {
734
581
  const hasRunRef = useRef3(false);
735
582
  const router = useRouter();
736
- const { data: token } = useQuery3({
737
- queryKey: ["token", tokenName],
738
- queryFn: () => getTokenFromCookie(tokenName) || null,
583
+ const { data: user } = useQuery3({
584
+ queryKey: ["user"],
585
+ queryFn: () => getUserFromCookie(),
739
586
  refetchInterval: 2e3,
740
587
  refetchIntervalInBackground: true,
741
588
  enabled: !hasRunRef.current,
742
589
  refetchOnWindowFocus: true
743
590
  });
744
591
  useEffect3(() => {
745
- if (token) {
592
+ if (user) {
746
593
  if (!hasRunRef.current) {
747
594
  hasRunRef.current = true;
748
595
  router.refresh();
@@ -750,129 +597,65 @@ var useTokenCookie = (tokenName) => {
750
597
  } else {
751
598
  hasRunRef.current = false;
752
599
  }
753
- }, [token, router]);
754
- return token != null ? token : null;
600
+ }, [user, router]);
601
+ return user;
755
602
  };
756
603
 
757
604
  // src/react/providers/NextAuthProvider.tsx
758
- import { jsx as jsx12 } from "react/jsx-runtime";
605
+ import { QueryClient as QueryClient2, QueryClientProvider as QueryClientProvider2 } from "@tanstack/react-query";
606
+ import { jsx as jsx10 } from "react/jsx-runtime";
759
607
  var queryClient2 = new QueryClient2();
608
+ var defaultUserContext = { user: null };
609
+ var UserContext2 = createContext5(defaultUserContext);
760
610
  var CivicNextAuthProvider = (_a) => {
761
611
  var _b = _a, {
762
612
  children
763
613
  } = _b, props = __objRest(_b, [
764
614
  "children"
765
615
  ]);
616
+ const user = useUserCookie();
766
617
  const [redirectUrl, setRedirectUrl] = useState3("");
767
- const { clientId, oauthServer, callbackUrl, challengeUrl, logoutUrl } = resolveAuthConfig();
618
+ const { clientId, oauthServer, callbackUrl, challengeUrl } = resolveAuthConfig();
768
619
  useEffect4(() => {
769
620
  if (typeof globalThis.window !== "undefined") {
770
621
  const currentUrl = globalThis.window.location.href;
771
- setRedirectUrl(resolveCallbackUrl(resolveAuthConfig(), currentUrl));
622
+ setRedirectUrl(new URL(callbackUrl, currentUrl).toString());
772
623
  }
773
624
  }, [callbackUrl]);
774
- const user = useUserCookie();
775
- const idToken = useTokenCookie("id_token" /* ID_TOKEN */);
776
- const combinedUser = user ? __spreadProps(__spreadValues({}, user || {}), { idToken }) : null;
777
- const sessionData = __spreadValues({
778
- authenticated: !!user
779
- }, idToken ? { idToken } : {});
780
- const signOut = () => __async(void 0, null, function* () {
781
- var _a2;
782
- (_a2 = props.onSignOut) == null ? void 0 : _a2.call(props);
783
- window.location.href = logoutUrl;
784
- return;
785
- });
786
- return /* @__PURE__ */ jsx12(QueryClientProvider2, { client: queryClient2, children: /* @__PURE__ */ jsx12(
625
+ const authService = useMemo3(() => {
626
+ if (redirectUrl && clientId && oauthServer) {
627
+ return new AuthSessionServiceImpl(clientId, redirectUrl, oauthServer, {
628
+ challenge: challengeUrl
629
+ });
630
+ }
631
+ return void 0;
632
+ }, [redirectUrl, clientId, oauthServer, challengeUrl]);
633
+ return /* @__PURE__ */ jsx10(QueryClientProvider2, { client: queryClient2, children: /* @__PURE__ */ jsx10(
787
634
  AuthProvider,
788
635
  __spreadProps(__spreadValues({}, props), {
789
- redirectUrl,
790
636
  config: { oauthServer },
791
637
  clientId,
792
- pkceConsumer: new ConfidentialClientPKCEConsumer(challengeUrl),
793
- sessionData,
794
- children: /* @__PURE__ */ jsx12(
795
- UserProvider,
796
- {
797
- storage: new NextjsClientStorage(),
798
- user: combinedUser,
799
- signOut,
800
- children
801
- }
802
- )
638
+ authServiceImpl: authService,
639
+ serverSideTokenExchange: true,
640
+ children: /* @__PURE__ */ jsx10(UserContext2.Provider, { value: user, children })
803
641
  })
804
642
  ) });
805
643
  };
644
+ var useNextUser = () => useContext4(UserContext2);
806
645
 
807
646
  // src/react/hooks/useUser.tsx
808
647
  var useUser = () => {
809
- const context = useContext4(UserContext);
648
+ const context = useContext5(UserContext);
810
649
  if (!context) {
811
650
  throw new Error("useUser must be used within a UserProvider");
812
651
  }
813
652
  return context;
814
653
  };
815
654
 
816
- // src/react/hooks/useUserCookie.ts
817
- import { useEffect as useEffect5, useRef as useRef4 } from "react";
818
- import { useRouter as useRouter2 } from "next/navigation.js";
819
- import { useQuery as useQuery4 } from "@tanstack/react-query";
820
- var getUserFromCookie = () => {
821
- const userCookie = getWindowCookieValue({
822
- key: "user" /* USER */,
823
- window: globalThis.window,
824
- parseJson: true
825
- });
826
- return userCookie;
827
- };
828
- var useUserCookie = () => {
829
- const hasRunRef = useRef4(false);
830
- const router = useRouter2();
831
- const { data: user } = useQuery4({
832
- queryKey: ["user"],
833
- queryFn: () => getUserFromCookie(),
834
- refetchInterval: 2e3,
835
- refetchIntervalInBackground: true,
836
- enabled: !hasRunRef.current,
837
- refetchOnWindowFocus: true
838
- });
839
- useEffect5(() => {
840
- if (user) {
841
- if (!hasRunRef.current) {
842
- hasRunRef.current = true;
843
- router.refresh();
844
- }
845
- } else {
846
- hasRunRef.current = false;
847
- }
848
- }, [user, router]);
849
- return user != null ? user : null;
850
- };
851
-
852
- // src/react/hooks/useConfig.tsx
853
- import { useContext as useContext5 } from "react";
854
- var useConfig = () => {
855
- const context = useContext5(ConfigContext);
856
- if (!context) {
857
- throw new Error("useConfig must be used within an ConfigProvider");
858
- }
859
- return context;
860
- };
861
-
862
- // src/react/hooks/useIframe.tsx
863
- import { useContext as useContext6 } from "react";
864
- var useIframe = () => {
865
- const context = useContext6(IframeContext);
866
- if (!context) {
867
- throw new Error("useIframe must be used within an IframeProvider");
868
- }
869
- return context;
870
- };
871
-
872
655
  // src/react/components/UserButton.tsx
873
- import { useCallback as useCallback3, useEffect as useEffect6, useState as useState4 } from "react";
874
- import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
875
- var ChevronDown = () => /* @__PURE__ */ jsx13(
656
+ import { useCallback as useCallback3, useEffect as useEffect5, useState as useState4 } from "react";
657
+ import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
658
+ var ChevronDown = () => /* @__PURE__ */ jsx11(
876
659
  "svg",
877
660
  {
878
661
  xmlns: "http://www.w3.org/2000/svg",
@@ -885,10 +668,10 @@ var ChevronDown = () => /* @__PURE__ */ jsx13(
885
668
  strokeLinecap: "round",
886
669
  strokeLinejoin: "round",
887
670
  className: "lucide lucide-chevron-down",
888
- children: /* @__PURE__ */ jsx13("path", { d: "m6 9 6 6 6-6" })
671
+ children: /* @__PURE__ */ jsx11("path", { d: "m6 9 6 6 6-6" })
889
672
  }
890
673
  );
891
- var ChevronUp = () => /* @__PURE__ */ jsx13(
674
+ var ChevronUp = () => /* @__PURE__ */ jsx11(
892
675
  "svg",
893
676
  {
894
677
  xmlns: "http://www.w3.org/2000/svg",
@@ -901,7 +684,7 @@ var ChevronUp = () => /* @__PURE__ */ jsx13(
901
684
  strokeLinecap: "round",
902
685
  strokeLinejoin: "round",
903
686
  className: "lucide lucide-chevron-up",
904
- children: /* @__PURE__ */ jsx13("path", { d: "m18 15-6-6-6 6" })
687
+ children: /* @__PURE__ */ jsx11("path", { d: "m18 15-6-6-6 6" })
905
688
  }
906
689
  );
907
690
  var UserButton = ({
@@ -909,7 +692,8 @@ var UserButton = ({
909
692
  className
910
693
  }) => {
911
694
  const [isOpen, setIsOpen] = useState4(false);
912
- const { user, signIn, signOut } = useUser();
695
+ const { signIn, isAuthenticated, signOut } = useAuth();
696
+ const { user } = useUser();
913
697
  const handleClickOutside = useCallback3((event) => {
914
698
  const target = event.target;
915
699
  if (!target.closest("#civic-dropdown-container")) {
@@ -917,7 +701,7 @@ var UserButton = ({
917
701
  }
918
702
  }, []);
919
703
  const handleSignOut = useCallback3(() => __async(void 0, null, function* () {
920
- signOut();
704
+ yield signOut();
921
705
  setIsOpen(false);
922
706
  }), [signOut]);
923
707
  const handleSignIn = useCallback3(() => __async(void 0, null, function* () {
@@ -929,7 +713,7 @@ var UserButton = ({
929
713
  setIsOpen(false);
930
714
  }
931
715
  }, []);
932
- useEffect6(() => {
716
+ useEffect5(() => {
933
717
  if (isOpen) {
934
718
  window.addEventListener("click", handleClickOutside);
935
719
  window.addEventListener("keydown", handleEscape);
@@ -939,38 +723,38 @@ var UserButton = ({
939
723
  window.removeEventListener("keydown", handleEscape);
940
724
  };
941
725
  }, [handleClickOutside, handleEscape, isOpen]);
942
- if (user) {
943
- return /* @__PURE__ */ jsxs5("div", { className: "cac-relative", id: "civic-dropdown-container", children: [
726
+ if (isAuthenticated) {
727
+ return /* @__PURE__ */ jsxs5("div", { className: "relative", id: "civic-dropdown-container", children: [
944
728
  /* @__PURE__ */ jsxs5(
945
729
  "button",
946
730
  {
947
731
  className: cn(
948
- "cac-flex cac-w-full cac-items-center cac-justify-between cac-gap-2 cac-rounded-full cac-border cac-border-neutral-500 cac-px-3 cac-py-2 cac-text-neutral-500 cac-transition-colors hover:cac-bg-neutral-200 hover:cac-bg-opacity-50",
732
+ "flex w-full items-center justify-between gap-2 rounded-full border border-neutral-500 px-3 py-2 text-neutral-500 transition-colors hover:bg-neutral-200 hover:bg-opacity-50",
949
733
  className
950
734
  ),
951
735
  onClick: () => setIsOpen((isOpen2) => !isOpen2),
952
736
  children: [
953
- (user == null ? void 0 : user.picture) ? /* @__PURE__ */ jsx13("span", { className: "cac-relative cac-flex cac-h-10 cac-w-10 cac-shrink-0 cac-gap-2 cac-overflow-hidden cac-rounded-full", children: /* @__PURE__ */ jsx13(
737
+ (user == null ? void 0 : user.picture) ? /* @__PURE__ */ jsx11("span", { className: "relative flex h-10 w-10 shrink-0 gap-2 overflow-hidden rounded-full", children: /* @__PURE__ */ jsx11(
954
738
  "img",
955
739
  {
956
- className: "cac-h-full cac-w-full cac-object-cover",
740
+ className: "h-full w-full object-cover",
957
741
  src: user.picture,
958
742
  alt: (user == null ? void 0 : user.name) || (user == null ? void 0 : user.email)
959
743
  }
960
- ) }) : /* @__PURE__ */ jsx13("div", {}),
961
- /* @__PURE__ */ jsx13("span", { children: (user == null ? void 0 : user.name) || (user == null ? void 0 : user.email) }),
962
- isOpen ? /* @__PURE__ */ jsx13(ChevronUp, {}) : /* @__PURE__ */ jsx13(ChevronDown, {})
744
+ ) }) : /* @__PURE__ */ jsx11("div", {}),
745
+ /* @__PURE__ */ jsx11("span", { children: (user == null ? void 0 : user.name) || (user == null ? void 0 : user.email) }),
746
+ isOpen ? /* @__PURE__ */ jsx11(ChevronUp, {}) : /* @__PURE__ */ jsx11(ChevronDown, {})
963
747
  ]
964
748
  }
965
749
  ),
966
- /* @__PURE__ */ jsx13(
750
+ /* @__PURE__ */ jsx11(
967
751
  "div",
968
752
  {
969
- className: isOpen ? "cac-absolute cac-right-0 cac-mt-2 cac-w-full cac-rounded-lg cac-bg-white cac-py-2 cac-text-neutral-500 cac-shadow-xl" : "cac-hidden",
970
- children: /* @__PURE__ */ jsx13("ul", { children: /* @__PURE__ */ jsx13("li", { children: /* @__PURE__ */ jsx13(
753
+ className: isOpen ? "absolute right-0 mt-2 w-full rounded-lg bg-white py-2 text-neutral-500 shadow-xl" : "hidden",
754
+ children: /* @__PURE__ */ jsx11("ul", { children: /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsx11(
971
755
  "button",
972
756
  {
973
- className: "cac-block cac-w-full cac-px-4 cac-py-2 cac-transition-colors hover:cac-bg-neutral-200 hover:cac-bg-opacity-50",
757
+ className: "block w-full px-4 py-2 transition-colors hover:bg-neutral-200 hover:bg-opacity-50",
974
758
  onClick: handleSignOut,
975
759
  children: "Logout"
976
760
  }
@@ -979,12 +763,11 @@ var UserButton = ({
979
763
  )
980
764
  ] });
981
765
  }
982
- return /* @__PURE__ */ jsx13(
766
+ return /* @__PURE__ */ jsx11(
983
767
  "button",
984
768
  {
985
- "data-testid": "sign-in-button",
986
769
  className: cn(
987
- "cac-rounded-full cac-border cac-border-neutral-500 cac-px-3 cac-py-2 cac-transition-colors hover:cac-bg-neutral-200 hover:cac-bg-opacity-50",
770
+ "rounded-full border border-neutral-500 px-3 py-2 transition-colors hover:bg-neutral-200 hover:bg-opacity-50",
988
771
  className
989
772
  ),
990
773
  onClick: handleSignIn,
@@ -994,18 +777,17 @@ var UserButton = ({
994
777
  };
995
778
 
996
779
  // src/react/components/SignInButton.tsx
997
- import { jsx as jsx14 } from "react/jsx-runtime";
780
+ import { jsx as jsx12 } from "react/jsx-runtime";
998
781
  var SignInButton = ({
999
782
  displayMode,
1000
783
  className
1001
784
  }) => {
1002
- const { signIn } = useUser();
1003
- return /* @__PURE__ */ jsx14(
785
+ const { signIn } = useAuth();
786
+ return /* @__PURE__ */ jsx12(
1004
787
  "button",
1005
788
  {
1006
- "data-testid": "sign-in-button",
1007
789
  className: cn(
1008
- "cac-rounded-full cac-border cac-border-neutral-500 cac-px-3 cac-py-2 cac-transition-colors hover:cac-bg-neutral-200 hover:cac-bg-opacity-50",
790
+ "rounded-full border border-neutral-500 px-3 py-2 transition-colors hover:bg-neutral-200 hover:bg-opacity-50",
1009
791
  className
1010
792
  ),
1011
793
  onClick: () => signIn(displayMode),
@@ -1015,14 +797,14 @@ var SignInButton = ({
1015
797
  };
1016
798
 
1017
799
  // src/react/components/SignOutButton.tsx
1018
- import { jsx as jsx15 } from "react/jsx-runtime";
800
+ import { jsx as jsx13 } from "react/jsx-runtime";
1019
801
  var SignOutButton = ({ className }) => {
1020
- const { signOut } = useUser();
1021
- return /* @__PURE__ */ jsx15(
802
+ const { signOut } = useAuth();
803
+ return /* @__PURE__ */ jsx13(
1022
804
  "button",
1023
805
  {
1024
806
  className: cn(
1025
- "cac-rounded-full cac-border cac-border-neutral-500 cac-px-3 cac-py-2 cac-transition-colors hover:cac-bg-neutral-200 hover:cac-bg-opacity-50",
807
+ "rounded-full border border-neutral-500 px-3 py-2 transition-colors hover:bg-neutral-200 hover:bg-opacity-50",
1026
808
  className
1027
809
  ),
1028
810
  onClick: () => signOut(),
@@ -1032,14 +814,13 @@ var SignOutButton = ({ className }) => {
1032
814
  };
1033
815
 
1034
816
  // src/react/components/NextLogOut.tsx
1035
- import { jsx as jsx16 } from "react/jsx-runtime";
817
+ import { jsx as jsx14 } from "react/jsx-runtime";
1036
818
  var NextLogOut = ({ children }) => {
1037
819
  const config = resolveAuthConfig();
1038
820
  const logoutUrl = `${config.logoutUrl}`;
1039
- return /* @__PURE__ */ jsx16("a", { href: logoutUrl, children });
821
+ return /* @__PURE__ */ jsx14("a", { href: logoutUrl, children });
1040
822
  };
1041
823
  export {
1042
- CivicAuthIframeContainer,
1043
824
  CivicAuthProvider,
1044
825
  CivicNextAuthProvider,
1045
826
  NextLogOut,
@@ -1047,11 +828,9 @@ export {
1047
828
  SignOutButton,
1048
829
  UserButton,
1049
830
  useAuth,
1050
- useConfig,
1051
- useIframe,
831
+ useNextUser,
1052
832
  useSession,
1053
833
  useToken,
1054
- useTokenCookie,
1055
834
  useUser,
1056
835
  useUserCookie
1057
836
  };