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

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 (84) hide show
  1. package/README.md +26 -0
  2. package/dist/AuthProvider-Bj_Prt1x.d.ts +21 -0
  3. package/dist/AuthProvider-DUAoX4G9.d.mts +21 -0
  4. package/dist/UserProvider-CMLaYOUD.d.ts +16 -0
  5. package/dist/UserProvider-Cbm8MZkJ.d.mts +16 -0
  6. package/dist/chunk-4PLCDPEN.mjs +599 -0
  7. package/dist/chunk-4PLCDPEN.mjs.map +1 -0
  8. package/dist/chunk-5UQQYXCX.js +1 -0
  9. package/dist/chunk-5UQQYXCX.js.map +1 -0
  10. package/dist/chunk-6RFRDWIP.js +223 -0
  11. package/dist/chunk-6RFRDWIP.js.map +1 -0
  12. package/dist/chunk-7K3QN2AT.js +599 -0
  13. package/dist/chunk-7K3QN2AT.js.map +1 -0
  14. package/dist/chunk-AP4627CS.mjs +223 -0
  15. package/dist/chunk-AP4627CS.mjs.map +1 -0
  16. package/dist/chunk-CRTRMMJ7.js.map +1 -1
  17. package/dist/chunk-CTVJJBBA.js +118 -0
  18. package/dist/chunk-CTVJJBBA.js.map +1 -0
  19. package/dist/chunk-FHRZSX3C.js +710 -0
  20. package/dist/chunk-FHRZSX3C.js.map +1 -0
  21. package/dist/chunk-JDZPCA3P.js +173 -0
  22. package/dist/chunk-JDZPCA3P.js.map +1 -0
  23. package/dist/chunk-MK7557NR.mjs +118 -0
  24. package/dist/chunk-MK7557NR.mjs.map +1 -0
  25. package/dist/chunk-NLRREFOX.mjs +710 -0
  26. package/dist/chunk-NLRREFOX.mjs.map +1 -0
  27. package/dist/chunk-O3WGNLRO.mjs +173 -0
  28. package/dist/chunk-O3WGNLRO.mjs.map +1 -0
  29. package/dist/chunk-PMJAV4JJ.mjs +1 -0
  30. package/dist/chunk-PMJAV4JJ.mjs.map +1 -0
  31. package/dist/index.css +63 -70
  32. package/dist/index.css.map +1 -1
  33. package/dist/index.d.mts +3 -1
  34. package/dist/index.d.ts +3 -1
  35. package/dist/index.js +2 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.mjs +1 -0
  38. package/dist/nextjs/client.css +335 -0
  39. package/dist/nextjs/client.css.map +1 -0
  40. package/dist/nextjs/client.d.mts +12 -0
  41. package/dist/nextjs/client.d.ts +12 -0
  42. package/dist/nextjs/client.js +179 -0
  43. package/dist/nextjs/client.js.map +1 -0
  44. package/dist/nextjs/client.mjs +179 -0
  45. package/dist/nextjs/client.mjs.map +1 -0
  46. package/dist/nextjs.d.mts +67 -15
  47. package/dist/nextjs.d.ts +67 -15
  48. package/dist/nextjs.js +158 -180
  49. package/dist/nextjs.js.map +1 -1
  50. package/dist/nextjs.mjs +155 -177
  51. package/dist/nextjs.mjs.map +1 -1
  52. package/dist/react.d.mts +31 -81
  53. package/dist/react.d.ts +31 -81
  54. package/dist/react.js +35 -634
  55. package/dist/react.js.map +1 -1
  56. package/dist/react.mjs +65 -664
  57. package/dist/react.mjs.map +1 -1
  58. package/dist/server.d.mts +14 -34
  59. package/dist/server.d.ts +14 -34
  60. package/dist/server.js +4 -185
  61. package/dist/server.js.map +1 -1
  62. package/dist/server.mjs +10 -191
  63. package/dist/server.mjs.map +1 -1
  64. package/dist/storage-B2eAQNdv.d.ts +25 -0
  65. package/dist/storage-BJPUpxhm.d.mts +25 -0
  66. package/dist/types-Bqm9OCZN.d.mts +22 -0
  67. package/dist/types-Bqm9OCZN.d.ts +22 -0
  68. package/dist/types-HdCjGldB.d.mts +58 -0
  69. package/dist/types-HdCjGldB.d.ts +58 -0
  70. package/package.json +26 -17
  71. package/dist/chunk-5NUJ7LFF.mjs +0 -17
  72. package/dist/chunk-5NUJ7LFF.mjs.map +0 -1
  73. package/dist/chunk-KS7ERXGZ.js +0 -481
  74. package/dist/chunk-KS7ERXGZ.js.map +0 -1
  75. package/dist/chunk-NINRO7GS.js +0 -209
  76. package/dist/chunk-NINRO7GS.js.map +0 -1
  77. package/dist/chunk-NXBKSUKI.mjs +0 -481
  78. package/dist/chunk-NXBKSUKI.mjs.map +0 -1
  79. package/dist/chunk-T7HUHQ3J.mjs +0 -209
  80. package/dist/chunk-T7HUHQ3J.mjs.map +0 -1
  81. package/dist/chunk-WZLC5B4C.js +0 -17
  82. package/dist/chunk-WZLC5B4C.js.map +0 -1
  83. package/dist/index-DoDoIY_K.d.mts +0 -79
  84. package/dist/index-DoDoIY_K.d.ts +0 -79
package/dist/react.d.mts CHANGED
@@ -1,20 +1,10 @@
1
- import { JWT } from 'oslo/jwt';
2
- import { D as DisplayMode, U as User, F as ForwardedTokens, A as AuthSessionService, E as Endpoints, b as UserInfoService, S as SessionData, a as UnknownObject, O as OIDCTokenResponseBody, P as ParsedTokens, C as Config } from './index-DoDoIY_K.mjs';
1
+ import { U as UserContextType, A as AuthContextType } from './UserProvider-Cbm8MZkJ.mjs';
2
+ import { F as ForwardedTokens, C as Config, S as SessionData, D as DisplayMode } from './types-HdCjGldB.mjs';
3
+ import { RefObject, Dispatch, SetStateAction, ReactNode } from 'react';
3
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- import { ReactNode } from 'react';
5
- import { OAuth2Client } from 'oslo/oauth2';
6
-
7
- type AuthContextType = {
8
- signIn: (displayMode?: DisplayMode) => Promise<void>;
9
- isAuthenticated: boolean;
10
- isLoading: boolean;
11
- error: Error | null;
12
- signOut: () => Promise<void>;
13
- };
14
-
15
- type UserContextType$1<T extends Record<string, unknown> & JWT["payload"] = Record<string, unknown> & JWT["payload"]> = {
16
- user: User<T> | null;
17
- } & Omit<AuthContextType, "isAuthenticated">;
5
+ import { A as AuthProviderProps } from './AuthProvider-DUAoX4G9.mjs';
6
+ import 'oslo/jwt';
7
+ import 'oslo/oauth2';
18
8
 
19
9
  type TokenContextType = {
20
10
  accessToken: string | null;
@@ -25,79 +15,39 @@ type TokenContextType = {
25
15
  error: Error | null;
26
16
  };
27
17
 
28
- declare class AuthSessionServiceImpl implements AuthSessionService {
29
- readonly clientId: string;
30
- readonly redirectUrl: string;
31
- readonly oauthServer: string;
32
- readonly inputEndpoints?: Partial<Endpoints> | undefined;
33
- private endpoints;
34
- private oauth2Client;
35
- private userInfoService;
36
- private codeVerifier;
37
- private refreshTokenTimeout;
38
- constructor(clientId: string, redirectUrl: string, oauthServer: string, inputEndpoints?: Partial<Endpoints> | undefined);
39
- protected getCodeVerifier(): string;
40
- getUserInfoService(): Promise<UserInfoService>;
41
- protected getEndpoints(): Promise<Endpoints>;
42
- protected getOauth2Client(): Promise<OAuth2Client>;
43
- getSessionData(): SessionData;
44
- updateSessionData(data: Partial<SessionData>): void;
45
- getUser(): User<UnknownObject> | null;
46
- setUser(data: User<UnknownObject> | null): void;
47
- clearSessionData(): void;
48
- getAuthorizationUrlWithChallenge(state: string, scopes: string[]): Promise<URL>;
49
- getAuthorizationUrl(scopes: string[], displayMode: DisplayMode, nonce?: string): Promise<string>;
50
- loadAuthorizationUrl(authorizationURL: string, displayMode: DisplayMode): void;
51
- init(): Promise<this>;
52
- logout(): Promise<void>;
53
- determineDisplayMode(displayMode: DisplayMode): DisplayMode;
54
- signIn(displayMode: DisplayMode, scopes: string[], nonce: string): Promise<void>;
55
- tokenExchange(responseUrl: string): Promise<SessionData>;
56
- private setupTokenRefresh;
57
- refreshToken(): Promise<SessionData>;
58
- getUserInfo<T extends UnknownObject>(): Promise<User<T> | null>;
59
- /**
60
- * Uses the jose library to validate a JWT token using the OAuth JWKS endpoint
61
- * @returns {Promise<jose.JWTPayload>}
62
- * @throws {Error} if the token is invalid
63
- * @param tokens
64
- */
65
- validateTokens(tokens: OIDCTokenResponseBody): Promise<ParsedTokens>;
66
- validateExistingSession(): Promise<SessionData>;
67
- }
68
-
69
- type AuthProviderProps = {
70
- children: ReactNode;
71
- clientId: string;
72
- redirectUrl?: string;
73
- nonce?: string;
74
- config?: Config;
75
- onSignIn?: (error?: Error) => void;
76
- onSignOut?: () => void;
77
- authServiceImpl?: AuthSessionServiceImpl;
78
- serverSideTokenExchange?: boolean;
79
- };
80
-
81
- type CivicAuthProviderProps = Omit<AuthProviderProps, "authServiceImpl" | "serverSideTokenExchange">;
18
+ type CivicAuthProviderProps = Omit<AuthProviderProps, "pkceConsumer">;
82
19
  declare const CivicAuthProvider: ({ children, ...props }: CivicAuthProviderProps) => react_jsx_runtime.JSX.Element;
83
20
 
84
- type UserContextType = {
85
- user: User<UnknownObject> | null;
86
- };
87
- type NextCivicAuthProviderProps = Omit<AuthProviderProps, "clientId">;
88
- declare const CivicNextAuthProvider: ({ children, ...props }: NextCivicAuthProviderProps) => react_jsx_runtime.JSX.Element;
89
- declare const useNextUser: () => UserContextType;
90
-
91
- declare const useUser: <T extends Record<string, unknown> = Record<string, never>>() => UserContextType$1<T>;
92
-
93
- declare const useUserCookie: () => any;
21
+ declare const useUser: <T extends Record<string, unknown> = Record<string, never>>() => UserContextType<T>;
94
22
 
95
23
  declare const useToken: () => TokenContextType;
96
24
 
97
25
  declare const useAuth: () => AuthContextType;
98
26
 
27
+ type ConfigProviderOutput = {
28
+ config: Config;
29
+ redirectUrl: string;
30
+ modalIframe: boolean;
31
+ serverTokenExchange: boolean;
32
+ };
33
+
34
+ declare const useConfig: () => ConfigProviderOutput;
35
+
36
+ type IframeProviderOutput = {
37
+ iframeRef: RefObject<HTMLIFrameElement> | null;
38
+ setAuthResponseUrl: Dispatch<SetStateAction<string | null>>;
39
+ };
40
+
41
+ declare const useIframe: () => IframeProviderOutput;
42
+
99
43
  declare const useSession: () => SessionData;
100
44
 
45
+ type CivicAuthIframeContainerProps = {
46
+ onClose?: () => void;
47
+ closeOnRedirect?: boolean;
48
+ };
49
+ declare const CivicAuthIframeContainer: ({ onClose, closeOnRedirect, }: CivicAuthIframeContainerProps) => react_jsx_runtime.JSX.Element;
50
+
101
51
  declare const UserButton: ({ displayMode, className, }: {
102
52
  displayMode?: DisplayMode;
103
53
  className?: string;
@@ -116,4 +66,4 @@ declare const NextLogOut: ({ children }: {
116
66
  children: ReactNode;
117
67
  }) => react_jsx_runtime.JSX.Element;
118
68
 
119
- export { type AuthContextType, CivicAuthProvider, CivicNextAuthProvider, NextLogOut, SignInButton, SignOutButton, type TokenContextType, UserButton, type UserContextType$1 as UserContextType, useAuth, useNextUser, useSession, useToken, useUser, useUserCookie };
69
+ export { AuthContextType, CivicAuthIframeContainer, CivicAuthProvider, type CivicAuthProviderProps, NextLogOut, SignInButton, SignOutButton, type TokenContextType, UserButton, UserContextType, useAuth, useConfig, useIframe, useSession, useToken, useUser };
package/dist/react.d.ts CHANGED
@@ -1,20 +1,10 @@
1
- import { JWT } from 'oslo/jwt';
2
- import { D as DisplayMode, U as User, F as ForwardedTokens, A as AuthSessionService, E as Endpoints, b as UserInfoService, S as SessionData, a as UnknownObject, O as OIDCTokenResponseBody, P as ParsedTokens, C as Config } from './index-DoDoIY_K.js';
1
+ import { U as UserContextType, A as AuthContextType } from './UserProvider-CMLaYOUD.js';
2
+ import { F as ForwardedTokens, C as Config, S as SessionData, D as DisplayMode } from './types-HdCjGldB.js';
3
+ import { RefObject, Dispatch, SetStateAction, ReactNode } from 'react';
3
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- import { ReactNode } from 'react';
5
- import { OAuth2Client } from 'oslo/oauth2';
6
-
7
- type AuthContextType = {
8
- signIn: (displayMode?: DisplayMode) => Promise<void>;
9
- isAuthenticated: boolean;
10
- isLoading: boolean;
11
- error: Error | null;
12
- signOut: () => Promise<void>;
13
- };
14
-
15
- type UserContextType$1<T extends Record<string, unknown> & JWT["payload"] = Record<string, unknown> & JWT["payload"]> = {
16
- user: User<T> | null;
17
- } & Omit<AuthContextType, "isAuthenticated">;
5
+ import { A as AuthProviderProps } from './AuthProvider-Bj_Prt1x.js';
6
+ import 'oslo/jwt';
7
+ import 'oslo/oauth2';
18
8
 
19
9
  type TokenContextType = {
20
10
  accessToken: string | null;
@@ -25,79 +15,39 @@ type TokenContextType = {
25
15
  error: Error | null;
26
16
  };
27
17
 
28
- declare class AuthSessionServiceImpl implements AuthSessionService {
29
- readonly clientId: string;
30
- readonly redirectUrl: string;
31
- readonly oauthServer: string;
32
- readonly inputEndpoints?: Partial<Endpoints> | undefined;
33
- private endpoints;
34
- private oauth2Client;
35
- private userInfoService;
36
- private codeVerifier;
37
- private refreshTokenTimeout;
38
- constructor(clientId: string, redirectUrl: string, oauthServer: string, inputEndpoints?: Partial<Endpoints> | undefined);
39
- protected getCodeVerifier(): string;
40
- getUserInfoService(): Promise<UserInfoService>;
41
- protected getEndpoints(): Promise<Endpoints>;
42
- protected getOauth2Client(): Promise<OAuth2Client>;
43
- getSessionData(): SessionData;
44
- updateSessionData(data: Partial<SessionData>): void;
45
- getUser(): User<UnknownObject> | null;
46
- setUser(data: User<UnknownObject> | null): void;
47
- clearSessionData(): void;
48
- getAuthorizationUrlWithChallenge(state: string, scopes: string[]): Promise<URL>;
49
- getAuthorizationUrl(scopes: string[], displayMode: DisplayMode, nonce?: string): Promise<string>;
50
- loadAuthorizationUrl(authorizationURL: string, displayMode: DisplayMode): void;
51
- init(): Promise<this>;
52
- logout(): Promise<void>;
53
- determineDisplayMode(displayMode: DisplayMode): DisplayMode;
54
- signIn(displayMode: DisplayMode, scopes: string[], nonce: string): Promise<void>;
55
- tokenExchange(responseUrl: string): Promise<SessionData>;
56
- private setupTokenRefresh;
57
- refreshToken(): Promise<SessionData>;
58
- getUserInfo<T extends UnknownObject>(): Promise<User<T> | null>;
59
- /**
60
- * Uses the jose library to validate a JWT token using the OAuth JWKS endpoint
61
- * @returns {Promise<jose.JWTPayload>}
62
- * @throws {Error} if the token is invalid
63
- * @param tokens
64
- */
65
- validateTokens(tokens: OIDCTokenResponseBody): Promise<ParsedTokens>;
66
- validateExistingSession(): Promise<SessionData>;
67
- }
68
-
69
- type AuthProviderProps = {
70
- children: ReactNode;
71
- clientId: string;
72
- redirectUrl?: string;
73
- nonce?: string;
74
- config?: Config;
75
- onSignIn?: (error?: Error) => void;
76
- onSignOut?: () => void;
77
- authServiceImpl?: AuthSessionServiceImpl;
78
- serverSideTokenExchange?: boolean;
79
- };
80
-
81
- type CivicAuthProviderProps = Omit<AuthProviderProps, "authServiceImpl" | "serverSideTokenExchange">;
18
+ type CivicAuthProviderProps = Omit<AuthProviderProps, "pkceConsumer">;
82
19
  declare const CivicAuthProvider: ({ children, ...props }: CivicAuthProviderProps) => react_jsx_runtime.JSX.Element;
83
20
 
84
- type UserContextType = {
85
- user: User<UnknownObject> | null;
86
- };
87
- type NextCivicAuthProviderProps = Omit<AuthProviderProps, "clientId">;
88
- declare const CivicNextAuthProvider: ({ children, ...props }: NextCivicAuthProviderProps) => react_jsx_runtime.JSX.Element;
89
- declare const useNextUser: () => UserContextType;
90
-
91
- declare const useUser: <T extends Record<string, unknown> = Record<string, never>>() => UserContextType$1<T>;
92
-
93
- declare const useUserCookie: () => any;
21
+ declare const useUser: <T extends Record<string, unknown> = Record<string, never>>() => UserContextType<T>;
94
22
 
95
23
  declare const useToken: () => TokenContextType;
96
24
 
97
25
  declare const useAuth: () => AuthContextType;
98
26
 
27
+ type ConfigProviderOutput = {
28
+ config: Config;
29
+ redirectUrl: string;
30
+ modalIframe: boolean;
31
+ serverTokenExchange: boolean;
32
+ };
33
+
34
+ declare const useConfig: () => ConfigProviderOutput;
35
+
36
+ type IframeProviderOutput = {
37
+ iframeRef: RefObject<HTMLIFrameElement> | null;
38
+ setAuthResponseUrl: Dispatch<SetStateAction<string | null>>;
39
+ };
40
+
41
+ declare const useIframe: () => IframeProviderOutput;
42
+
99
43
  declare const useSession: () => SessionData;
100
44
 
45
+ type CivicAuthIframeContainerProps = {
46
+ onClose?: () => void;
47
+ closeOnRedirect?: boolean;
48
+ };
49
+ declare const CivicAuthIframeContainer: ({ onClose, closeOnRedirect, }: CivicAuthIframeContainerProps) => react_jsx_runtime.JSX.Element;
50
+
101
51
  declare const UserButton: ({ displayMode, className, }: {
102
52
  displayMode?: DisplayMode;
103
53
  className?: string;
@@ -116,4 +66,4 @@ declare const NextLogOut: ({ children }: {
116
66
  children: ReactNode;
117
67
  }) => react_jsx_runtime.JSX.Element;
118
68
 
119
- export { type AuthContextType, CivicAuthProvider, CivicNextAuthProvider, NextLogOut, SignInButton, SignOutButton, type TokenContextType, UserButton, type UserContextType$1 as UserContextType, useAuth, useNextUser, useSession, useToken, useUser, useUserCookie };
69
+ export { AuthContextType, CivicAuthIframeContainer, CivicAuthProvider, type CivicAuthProviderProps, NextLogOut, SignInButton, SignOutButton, type TokenContextType, UserButton, UserContextType, useAuth, useConfig, useIframe, useSession, useToken, useUser };