@fusionauth/angular-sdk 0.1.7 → 1.0.1
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 +41 -66
- package/esm2022/lib/components/fusionauth-login.button/fusion-auth-login-button.component.mjs +3 -3
- package/esm2022/lib/components/fusionauth-logout.button/fusion-auth-logout-button.component.mjs +3 -3
- package/esm2022/lib/components/fusionauth-register.button/fusion-auth-register-button.component.mjs +3 -3
- package/esm2022/lib/core.mjs +241 -0
- package/esm2022/lib/fusion-auth.module.mjs +4 -4
- package/esm2022/lib/fusion-auth.service.mjs +58 -94
- package/esm2022/lib/types.mjs +1 -1
- package/fesm2022/fusionauth-angular-sdk.mjs +309 -106
- package/fesm2022/fusionauth-angular-sdk.mjs.map +1 -1
- package/lib/core.d.ts +57 -0
- package/lib/fusion-auth.service.d.ts +26 -17
- package/lib/types.d.ts +44 -2
- package/package.json +1 -1
package/lib/core.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
declare class g {
|
|
3
|
+
constructor(e: any);
|
|
4
|
+
getMeUrl(): URL;
|
|
5
|
+
getLoginUrl(e: any): URL;
|
|
6
|
+
getRegisterUrl(e: any): URL;
|
|
7
|
+
getLogoutUrl(): URL;
|
|
8
|
+
getTokenRefreshUrl(): URL;
|
|
9
|
+
generateUrl(e: any, t: any): URL;
|
|
10
|
+
generateURLSearchParams(e: any): URLSearchParams;
|
|
11
|
+
}
|
|
12
|
+
declare class o {
|
|
13
|
+
/**
|
|
14
|
+
* Parses document.cookie for the access token expiration cookie value.
|
|
15
|
+
* @returns {(number | null)} The moment of expiration in milliseconds since epoch.
|
|
16
|
+
*/
|
|
17
|
+
static getAccessTokenExpirationMoment(e?: string): number | null;
|
|
18
|
+
}
|
|
19
|
+
declare class p {
|
|
20
|
+
constructor(e: any);
|
|
21
|
+
/** Refresh token a single time */
|
|
22
|
+
refreshToken(): Promise<void>;
|
|
23
|
+
/** Initializes continuous automatic token refresh. */
|
|
24
|
+
initAutoRefresh(e: number | undefined, t: any): NodeJS.Timeout | undefined;
|
|
25
|
+
}
|
|
26
|
+
declare class T {
|
|
27
|
+
constructor(e: any);
|
|
28
|
+
startLogin(e: any): void;
|
|
29
|
+
startRegister(e: any): void;
|
|
30
|
+
startLogout(): void;
|
|
31
|
+
fetchUserInfo(): Promise<any>;
|
|
32
|
+
refreshToken(): Promise<any>;
|
|
33
|
+
initAutoRefresh(): any;
|
|
34
|
+
handlePostRedirect(e: any): void;
|
|
35
|
+
get isLoggedIn(): boolean;
|
|
36
|
+
get accessTokenExpirationMoment(): number | null;
|
|
37
|
+
scheduleTokenExpirationEvent(): void;
|
|
38
|
+
}
|
|
39
|
+
declare function U(): void;
|
|
40
|
+
declare function P(): void;
|
|
41
|
+
declare function E(r: any): {
|
|
42
|
+
assign: any;
|
|
43
|
+
ancestorOrigins: DOMStringList;
|
|
44
|
+
hash: string;
|
|
45
|
+
host: string;
|
|
46
|
+
hostname: string;
|
|
47
|
+
href: string;
|
|
48
|
+
toString(): string;
|
|
49
|
+
origin: string;
|
|
50
|
+
pathname: string;
|
|
51
|
+
port: string;
|
|
52
|
+
protocol: string;
|
|
53
|
+
search: string;
|
|
54
|
+
reload(): void;
|
|
55
|
+
replace(url: string | URL): void;
|
|
56
|
+
};
|
|
57
|
+
export { o as CookieHelpers, T as SDKCore, p as TokenRefresher, g as UrlHelper, U as mockIsLoggedIn, E as mockWindowLocation, P as removeAt_expCookie, };
|
|
@@ -1,42 +1,51 @@
|
|
|
1
1
|
import { FusionAuthConfig, UserInfo } from './types';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
2
3
|
/**
|
|
3
4
|
* Service class to use with FusionAuth backend endpoints.
|
|
4
5
|
*/
|
|
5
6
|
export declare class FusionAuthService {
|
|
6
|
-
private
|
|
7
|
+
private core;
|
|
8
|
+
private autoRefreshTimer?;
|
|
9
|
+
private isLoggedInSubject;
|
|
7
10
|
constructor(config: FusionAuthConfig);
|
|
11
|
+
/** An observable representing whether the user is logged in. */
|
|
12
|
+
isLoggedIn$: Observable<boolean>;
|
|
13
|
+
/** A function that returns whether the user is logged in. This returned value is non-observable. */
|
|
14
|
+
isLoggedIn(): boolean;
|
|
8
15
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
16
|
+
* Refreshes the access token a single time.
|
|
17
|
+
* Automatic token refreshing can be enabled if the SDK is configured with `shouldAutoRefresh`.
|
|
11
18
|
*/
|
|
12
|
-
|
|
19
|
+
refreshToken(): Promise<void>;
|
|
13
20
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
21
|
+
* Initializes automatic access token refreshing.
|
|
22
|
+
* This is handled automatically if the SDK is configured with `shouldAutoRefresh`.
|
|
16
23
|
*/
|
|
17
24
|
initAutoRefresh(): void;
|
|
18
25
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @return {boolean} app.at_exp is present and not for a time in the past
|
|
26
|
+
* Returns an observable request that fetches userInfo, and catches error.
|
|
21
27
|
*/
|
|
22
|
-
|
|
28
|
+
getUserInfoObservable(callbacks?: {
|
|
29
|
+
onBegin?: () => void;
|
|
30
|
+
onDone?: () => void;
|
|
31
|
+
}): Observable<UserInfo>;
|
|
23
32
|
/**
|
|
24
|
-
*
|
|
33
|
+
* Fetches userInfo from the 'me' endpoint.
|
|
34
|
+
* @throws {Error} - if an error occurred while fetching.
|
|
25
35
|
*/
|
|
26
|
-
|
|
36
|
+
getUserInfo(): Promise<UserInfo>;
|
|
27
37
|
/**
|
|
28
|
-
*
|
|
38
|
+
* Initiates login flow.
|
|
39
|
+
* @param {string} [state] - Optional value to be echoed back to the SDK upon redirect.
|
|
29
40
|
*/
|
|
30
41
|
startLogin(state?: string): void;
|
|
31
42
|
/**
|
|
32
|
-
*
|
|
43
|
+
* Initiates register flow.
|
|
44
|
+
* @param {string} [state] - Optional value to be echoed back to the SDK upon redirect.
|
|
33
45
|
*/
|
|
34
46
|
startRegistration(state?: string): void;
|
|
35
47
|
/**
|
|
36
|
-
*
|
|
48
|
+
* Initiates logout flow.
|
|
37
49
|
*/
|
|
38
50
|
logout(): void;
|
|
39
|
-
private doRedirectForPath;
|
|
40
|
-
private getUrlForPath;
|
|
41
|
-
private getExpTime;
|
|
42
51
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,12 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config for FusionAuth Angular SDK
|
|
3
|
+
*/
|
|
1
4
|
export interface FusionAuthConfig {
|
|
5
|
+
/**
|
|
6
|
+
* The URL of the server that performs the token exchange.
|
|
7
|
+
*/
|
|
2
8
|
serverUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* The client id of the application.
|
|
11
|
+
*/
|
|
3
12
|
clientId: string;
|
|
4
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The redirect URI of the application.
|
|
15
|
+
*/
|
|
16
|
+
redirectUri: string;
|
|
17
|
+
/**
|
|
18
|
+
* The OAuth2 scope parameter passed to the `/oauth2/authorize` endpoint. If not specified fusionauth will default this to `openid offline_access`.
|
|
19
|
+
*/
|
|
20
|
+
scope?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Enables automatic token refreshing. Defaults to false.
|
|
23
|
+
*/
|
|
24
|
+
shouldAutoRefresh?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The number of seconds before the access token expiry when the auto refresh functionality kicks in if enabled. Default is 10.
|
|
27
|
+
*/
|
|
5
28
|
autoRefreshSecondsBeforeExpiry?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Callback function to be invoked with the `state` value upon redirect from login or register.
|
|
31
|
+
*/
|
|
32
|
+
onRedirect?: (state?: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* The path to the login endpoint.
|
|
35
|
+
*/
|
|
6
36
|
loginPath?: string;
|
|
7
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The path to the register endpoint.
|
|
39
|
+
*/
|
|
8
40
|
registerPath?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The path to the logout endpoint.
|
|
43
|
+
*/
|
|
44
|
+
logoutPath?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The path to the token refresh endpoint.
|
|
47
|
+
*/
|
|
9
48
|
tokenRefreshPath?: string;
|
|
49
|
+
/**
|
|
50
|
+
* The path to the me endpoint.
|
|
51
|
+
*/
|
|
10
52
|
mePath?: string;
|
|
11
53
|
}
|
|
12
54
|
export interface UserInfo {
|