@civic/auth 0.0.1-beta.19 → 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.
- package/README.md +0 -26
- package/dist/chunk-5NUJ7LFF.mjs +17 -0
- package/dist/chunk-5NUJ7LFF.mjs.map +1 -0
- package/dist/chunk-CRTRMMJ7.js.map +1 -1
- package/dist/chunk-KS7ERXGZ.js +481 -0
- package/dist/chunk-KS7ERXGZ.js.map +1 -0
- package/dist/chunk-NINRO7GS.js +209 -0
- package/dist/chunk-NINRO7GS.js.map +1 -0
- package/dist/chunk-NXBKSUKI.mjs +481 -0
- package/dist/chunk-NXBKSUKI.mjs.map +1 -0
- package/dist/chunk-T7HUHQ3J.mjs +209 -0
- package/dist/chunk-T7HUHQ3J.mjs.map +1 -0
- package/dist/chunk-WZLC5B4C.js +17 -0
- package/dist/chunk-WZLC5B4C.js.map +1 -0
- package/dist/index-DoDoIY_K.d.mts +79 -0
- package/dist/index-DoDoIY_K.d.ts +79 -0
- package/dist/index.css +70 -63
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/nextjs.d.mts +15 -42
- package/dist/nextjs.d.ts +15 -42
- package/dist/nextjs.js +180 -156
- package/dist/nextjs.js.map +1 -1
- package/dist/nextjs.mjs +177 -153
- package/dist/nextjs.mjs.map +1 -1
- package/dist/react.d.mts +81 -31
- package/dist/react.d.ts +81 -31
- package/dist/react.js +634 -35
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +664 -65
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +34 -14
- package/dist/server.d.ts +34 -14
- package/dist/server.js +185 -4
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +191 -10
- package/dist/server.mjs.map +1 -1
- package/package.json +17 -26
- package/dist/AuthProvider-Bj_Prt1x.d.ts +0 -21
- package/dist/AuthProvider-DUAoX4G9.d.mts +0 -21
- package/dist/UserProvider-CMLaYOUD.d.ts +0 -16
- package/dist/UserProvider-Cbm8MZkJ.d.mts +0 -16
- package/dist/chunk-5UQQYXCX.js +0 -1
- package/dist/chunk-5UQQYXCX.js.map +0 -1
- package/dist/chunk-BFESCRFK.mjs +0 -118
- package/dist/chunk-BFESCRFK.mjs.map +0 -1
- package/dist/chunk-CBQ3HKRV.mjs +0 -599
- package/dist/chunk-CBQ3HKRV.mjs.map +0 -1
- package/dist/chunk-CZ3AVCKD.js +0 -171
- package/dist/chunk-CZ3AVCKD.js.map +0 -1
- package/dist/chunk-DJFTZS4P.js +0 -118
- package/dist/chunk-DJFTZS4P.js.map +0 -1
- package/dist/chunk-HTTTZ2BP.mjs +0 -223
- package/dist/chunk-HTTTZ2BP.mjs.map +0 -1
- package/dist/chunk-O2SODTR3.js +0 -599
- package/dist/chunk-O2SODTR3.js.map +0 -1
- package/dist/chunk-O6DPCPRH.js +0 -223
- package/dist/chunk-O6DPCPRH.js.map +0 -1
- package/dist/chunk-PMJAV4JJ.mjs +0 -1
- package/dist/chunk-PMJAV4JJ.mjs.map +0 -1
- package/dist/chunk-UADVRCHY.mjs +0 -710
- package/dist/chunk-UADVRCHY.mjs.map +0 -1
- package/dist/chunk-VJVRFKDH.js +0 -710
- package/dist/chunk-VJVRFKDH.js.map +0 -1
- package/dist/chunk-X3FQBE22.mjs +0 -171
- package/dist/chunk-X3FQBE22.mjs.map +0 -1
- package/dist/nextjs/client.css +0 -335
- package/dist/nextjs/client.css.map +0 -1
- package/dist/nextjs/client.d.mts +0 -12
- package/dist/nextjs/client.d.ts +0 -12
- package/dist/nextjs/client.js +0 -179
- package/dist/nextjs/client.js.map +0 -1
- package/dist/nextjs/client.mjs +0 -179
- package/dist/nextjs/client.mjs.map +0 -1
- package/dist/storage-B2eAQNdv.d.ts +0 -25
- package/dist/storage-BJPUpxhm.d.mts +0 -25
- package/dist/types-Bqm9OCZN.d.mts +0 -22
- package/dist/types-Bqm9OCZN.d.ts +0 -22
- package/dist/types-HdCjGldB.d.mts +0 -58
- package/dist/types-HdCjGldB.d.ts +0 -58
package/dist/react.d.mts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { F as ForwardedTokens,
|
|
3
|
-
import { RefObject, Dispatch, SetStateAction, ReactNode } from 'react';
|
|
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';
|
|
4
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import {
|
|
6
|
-
import 'oslo/
|
|
7
|
-
|
|
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">;
|
|
8
18
|
|
|
9
19
|
type TokenContextType = {
|
|
10
20
|
accessToken: string | null;
|
|
@@ -15,38 +25,78 @@ type TokenContextType = {
|
|
|
15
25
|
error: Error | null;
|
|
16
26
|
};
|
|
17
27
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
};
|
|
24
80
|
|
|
25
|
-
|
|
81
|
+
type CivicAuthProviderProps = Omit<AuthProviderProps, "authServiceImpl" | "serverSideTokenExchange">;
|
|
82
|
+
declare const CivicAuthProvider: ({ children, ...props }: CivicAuthProviderProps) => react_jsx_runtime.JSX.Element;
|
|
26
83
|
|
|
27
|
-
type
|
|
28
|
-
|
|
29
|
-
redirectUrl: string;
|
|
30
|
-
modalIframe: boolean;
|
|
31
|
-
serverTokenExchange: boolean;
|
|
84
|
+
type UserContextType = {
|
|
85
|
+
user: User<UnknownObject> | null;
|
|
32
86
|
};
|
|
87
|
+
type NextCivicAuthProviderProps = Omit<AuthProviderProps, "clientId">;
|
|
88
|
+
declare const CivicNextAuthProvider: ({ children, ...props }: NextCivicAuthProviderProps) => react_jsx_runtime.JSX.Element;
|
|
89
|
+
declare const useNextUser: () => UserContextType;
|
|
33
90
|
|
|
34
|
-
declare const
|
|
91
|
+
declare const useUser: <T extends Record<string, unknown> = Record<string, never>>() => UserContextType$1<T>;
|
|
35
92
|
|
|
36
|
-
|
|
37
|
-
iframeRef: RefObject<HTMLIFrameElement> | null;
|
|
38
|
-
setAuthResponseUrl: Dispatch<SetStateAction<string | null>>;
|
|
39
|
-
};
|
|
93
|
+
declare const useUserCookie: () => any;
|
|
40
94
|
|
|
41
|
-
declare const
|
|
95
|
+
declare const useToken: () => TokenContextType;
|
|
42
96
|
|
|
43
|
-
declare const
|
|
97
|
+
declare const useAuth: () => AuthContextType;
|
|
44
98
|
|
|
45
|
-
|
|
46
|
-
onClose?: () => void;
|
|
47
|
-
closeOnRedirect?: boolean;
|
|
48
|
-
};
|
|
49
|
-
declare const CivicAuthIframeContainer: ({ onClose, closeOnRedirect, }: CivicAuthIframeContainerProps) => react_jsx_runtime.JSX.Element;
|
|
99
|
+
declare const useSession: () => SessionData;
|
|
50
100
|
|
|
51
101
|
declare const UserButton: ({ displayMode, className, }: {
|
|
52
102
|
displayMode?: DisplayMode;
|
|
@@ -66,4 +116,4 @@ declare const NextLogOut: ({ children }: {
|
|
|
66
116
|
children: ReactNode;
|
|
67
117
|
}) => react_jsx_runtime.JSX.Element;
|
|
68
118
|
|
|
69
|
-
export { AuthContextType,
|
|
119
|
+
export { type AuthContextType, CivicAuthProvider, CivicNextAuthProvider, NextLogOut, SignInButton, SignOutButton, type TokenContextType, UserButton, type UserContextType$1 as UserContextType, useAuth, useNextUser, useSession, useToken, useUser, useUserCookie };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { F as ForwardedTokens,
|
|
3
|
-
import { RefObject, Dispatch, SetStateAction, ReactNode } from 'react';
|
|
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';
|
|
4
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import {
|
|
6
|
-
import 'oslo/
|
|
7
|
-
|
|
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">;
|
|
8
18
|
|
|
9
19
|
type TokenContextType = {
|
|
10
20
|
accessToken: string | null;
|
|
@@ -15,38 +25,78 @@ type TokenContextType = {
|
|
|
15
25
|
error: Error | null;
|
|
16
26
|
};
|
|
17
27
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
};
|
|
24
80
|
|
|
25
|
-
|
|
81
|
+
type CivicAuthProviderProps = Omit<AuthProviderProps, "authServiceImpl" | "serverSideTokenExchange">;
|
|
82
|
+
declare const CivicAuthProvider: ({ children, ...props }: CivicAuthProviderProps) => react_jsx_runtime.JSX.Element;
|
|
26
83
|
|
|
27
|
-
type
|
|
28
|
-
|
|
29
|
-
redirectUrl: string;
|
|
30
|
-
modalIframe: boolean;
|
|
31
|
-
serverTokenExchange: boolean;
|
|
84
|
+
type UserContextType = {
|
|
85
|
+
user: User<UnknownObject> | null;
|
|
32
86
|
};
|
|
87
|
+
type NextCivicAuthProviderProps = Omit<AuthProviderProps, "clientId">;
|
|
88
|
+
declare const CivicNextAuthProvider: ({ children, ...props }: NextCivicAuthProviderProps) => react_jsx_runtime.JSX.Element;
|
|
89
|
+
declare const useNextUser: () => UserContextType;
|
|
33
90
|
|
|
34
|
-
declare const
|
|
91
|
+
declare const useUser: <T extends Record<string, unknown> = Record<string, never>>() => UserContextType$1<T>;
|
|
35
92
|
|
|
36
|
-
|
|
37
|
-
iframeRef: RefObject<HTMLIFrameElement> | null;
|
|
38
|
-
setAuthResponseUrl: Dispatch<SetStateAction<string | null>>;
|
|
39
|
-
};
|
|
93
|
+
declare const useUserCookie: () => any;
|
|
40
94
|
|
|
41
|
-
declare const
|
|
95
|
+
declare const useToken: () => TokenContextType;
|
|
42
96
|
|
|
43
|
-
declare const
|
|
97
|
+
declare const useAuth: () => AuthContextType;
|
|
44
98
|
|
|
45
|
-
|
|
46
|
-
onClose?: () => void;
|
|
47
|
-
closeOnRedirect?: boolean;
|
|
48
|
-
};
|
|
49
|
-
declare const CivicAuthIframeContainer: ({ onClose, closeOnRedirect, }: CivicAuthIframeContainerProps) => react_jsx_runtime.JSX.Element;
|
|
99
|
+
declare const useSession: () => SessionData;
|
|
50
100
|
|
|
51
101
|
declare const UserButton: ({ displayMode, className, }: {
|
|
52
102
|
displayMode?: DisplayMode;
|
|
@@ -66,4 +116,4 @@ declare const NextLogOut: ({ children }: {
|
|
|
66
116
|
children: ReactNode;
|
|
67
117
|
}) => react_jsx_runtime.JSX.Element;
|
|
68
118
|
|
|
69
|
-
export { AuthContextType,
|
|
119
|
+
export { type AuthContextType, CivicAuthProvider, CivicNextAuthProvider, NextLogOut, SignInButton, SignOutButton, type TokenContextType, UserButton, type UserContextType$1 as UserContextType, useAuth, useNextUser, useSession, useToken, useUser, useUserCookie };
|