@fusionauth/angular-sdk 1.3.0 → 2.0.0

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 (61) hide show
  1. package/README.md +7 -5
  2. package/fesm2022/fusionauth-angular-sdk.mjs +71 -38
  3. package/fesm2022/fusionauth-angular-sdk.mjs.map +1 -1
  4. package/package.json +16 -8
  5. package/types/fusionauth-angular-sdk.d.ts +183 -0
  6. package/esm2022/fusionauth-angular-sdk.mjs +0 -5
  7. package/esm2022/lib/SSRCookieAdapter.mjs +0 -23
  8. package/esm2022/lib/components/fusionauth-account.button/fusion-auth-account-button.component.mjs +0 -18
  9. package/esm2022/lib/components/fusionauth-login.button/fusion-auth-login-button.component.mjs +0 -20
  10. package/esm2022/lib/components/fusionauth-logout.button/fusion-auth-logout-button.component.mjs +0 -18
  11. package/esm2022/lib/components/fusionauth-register.button/fusion-auth-register-button.component.mjs +0 -20
  12. package/esm2022/lib/fusion-auth.module.mjs +0 -47
  13. package/esm2022/lib/fusion-auth.service.mjs +0 -118
  14. package/esm2022/lib/injectionToken.mjs +0 -3
  15. package/esm2022/lib/types.mjs +0 -2
  16. package/esm2022/public-api.mjs +0 -11
  17. package/esm2022/sdkcore/CookieHelpers/CookieHelpers.mjs +0 -34
  18. package/esm2022/sdkcore/CookieHelpers/index.mjs +0 -2
  19. package/esm2022/sdkcore/RedirectHelper/RedirectHelper.mjs +0 -47
  20. package/esm2022/sdkcore/RedirectHelper/index.mjs +0 -2
  21. package/esm2022/sdkcore/SDKConfig/SDKConfig.mjs +0 -2
  22. package/esm2022/sdkcore/SDKConfig/index.mjs +0 -2
  23. package/esm2022/sdkcore/SDKContext/SDKContext.mjs +0 -2
  24. package/esm2022/sdkcore/SDKContext/index.mjs +0 -2
  25. package/esm2022/sdkcore/SDKCore/SDKCore.mjs +0 -113
  26. package/esm2022/sdkcore/SDKCore/index.mjs +0 -2
  27. package/esm2022/sdkcore/UrlHelper/UrlHelper.mjs +0 -69
  28. package/esm2022/sdkcore/UrlHelper/UrlHelperTypes.mjs +0 -2
  29. package/esm2022/sdkcore/UrlHelper/index.mjs +0 -3
  30. package/esm2022/sdkcore/index.mjs +0 -4
  31. package/esm2022/sdkcore/testUtils/index.mjs +0 -3
  32. package/esm2022/sdkcore/testUtils/mockLoggedIn.mjs +0 -13
  33. package/esm2022/sdkcore/testUtils/mockWindowLocation.mjs +0 -10
  34. package/index.d.ts +0 -5
  35. package/lib/SSRCookieAdapter.d.ts +0 -7
  36. package/lib/components/fusionauth-account.button/fusion-auth-account-button.component.d.ts +0 -9
  37. package/lib/components/fusionauth-login.button/fusion-auth-login-button.component.d.ts +0 -10
  38. package/lib/components/fusionauth-logout.button/fusion-auth-logout-button.component.d.ts +0 -9
  39. package/lib/components/fusionauth-register.button/fusion-auth-register-button.component.d.ts +0 -10
  40. package/lib/fusion-auth.module.d.ts +0 -13
  41. package/lib/fusion-auth.service.d.ts +0 -59
  42. package/lib/injectionToken.d.ts +0 -3
  43. package/lib/types.d.ts +0 -78
  44. package/public-api.d.ts +0 -7
  45. package/sdkcore/CookieHelpers/CookieHelpers.d.ts +0 -11
  46. package/sdkcore/CookieHelpers/index.d.ts +0 -1
  47. package/sdkcore/RedirectHelper/RedirectHelper.d.ts +0 -10
  48. package/sdkcore/RedirectHelper/index.d.ts +0 -1
  49. package/sdkcore/SDKConfig/SDKConfig.d.ts +0 -79
  50. package/sdkcore/SDKConfig/index.d.ts +0 -1
  51. package/sdkcore/SDKContext/SDKContext.d.ts +0 -69
  52. package/sdkcore/SDKContext/index.d.ts +0 -1
  53. package/sdkcore/SDKCore/SDKCore.d.ts +0 -28
  54. package/sdkcore/SDKCore/index.d.ts +0 -1
  55. package/sdkcore/UrlHelper/UrlHelper.d.ts +0 -23
  56. package/sdkcore/UrlHelper/UrlHelperTypes.d.ts +0 -11
  57. package/sdkcore/UrlHelper/index.d.ts +0 -2
  58. package/sdkcore/index.d.ts +0 -5
  59. package/sdkcore/testUtils/index.d.ts +0 -2
  60. package/sdkcore/testUtils/mockLoggedIn.d.ts +0 -5
  61. package/sdkcore/testUtils/mockWindowLocation.d.ts +0 -18
@@ -1,79 +0,0 @@
1
- import { CookieAdapter } from '..';
2
- /**
3
- * Config for FusionAuth Web SDKs
4
- */
5
- export interface SDKConfig {
6
- /**
7
- * The URL of the server that performs the token exchange.
8
- */
9
- serverUrl: string;
10
- /**
11
- * The client id of the application.
12
- */
13
- clientId: string;
14
- /**
15
- * The redirect URI of the application.
16
- */
17
- redirectUri: string;
18
- /**
19
- * The OAuth2 scope parameter passed to the `/oauth2/authorize` endpoint. If not specified fusionauth will default this to `openid offline_access`.
20
- */
21
- scope?: string;
22
- /**
23
- * The redirect URI for post-logout. Defaults the provided `redirectUri`.
24
- */
25
- postLogoutRedirectUri?: string;
26
- /**
27
- * Enables automatic token refreshing. Defaults to false.
28
- */
29
- shouldAutoRefresh?: boolean;
30
- /**
31
- * Enables the SDK to automatically handle fetching user info when logged in. Defaults to false.
32
- */
33
- shouldAutoFetchUserInfo?: boolean;
34
- /**
35
- * The number of seconds before the access token expiry when the auto refresh functionality kicks in if enabled. Default is 30.
36
- */
37
- autoRefreshSecondsBeforeExpiry?: number;
38
- /**
39
- * Callback function to be invoked with the `state` value upon redirect from login or register.
40
- */
41
- onRedirect?: (state?: string) => void;
42
- /**
43
- * The path to the login endpoint.
44
- */
45
- loginPath?: string;
46
- /**
47
- * The path to the register endpoint.
48
- */
49
- registerPath?: string;
50
- /**
51
- * The path to the logout endpoint.
52
- */
53
- logoutPath?: string;
54
- /**
55
- * The path to the token refresh endpoint.
56
- */
57
- tokenRefreshPath?: string;
58
- /**
59
- * The path to the me endpoint.
60
- */
61
- mePath?: string;
62
- /**
63
- * The name of the access token expiration moment cookie.
64
- * Only set this if you are hosting server that uses a custom name for the 'app.at_exp' cookie.
65
- */
66
- accessTokenExpireCookieName?: string;
67
- /**
68
- * Callback to be invoked if a request to refresh the access token fails during autorefresh.
69
- */
70
- onAutoRefreshFailure?: (error: Error) => void;
71
- /**
72
- * Adapter pattern for SSR frameworks such as next or nuxt
73
- */
74
- cookieAdapter?: CookieAdapter;
75
- /**
76
- * Callback to be invoked at the moment of access token expiration
77
- */
78
- onTokenExpiration: () => void;
79
- }
@@ -1 +0,0 @@
1
- export * from './SDKConfig';
@@ -1,69 +0,0 @@
1
- /** The context provided by FusionAuth Web SDKs */
2
- export interface SDKContext {
3
- /**
4
- * Whether the user is logged in.
5
- */
6
- isLoggedIn: boolean;
7
- /**
8
- * Data fetched from the configured 'me' endpoint.
9
- */
10
- userInfo: UserInfo | null;
11
- /**
12
- * Fetches user info from the 'me' endpoint.
13
- * This is handled automatically if the SDK is configured with `shouldAutoFetchUserInfo`.
14
- * @returns {Promise<UserInfo>}
15
- */
16
- fetchUserInfo: () => Promise<UserInfo | undefined>;
17
- /**
18
- * Indicates that the fetchUserInfo call is unresolved.
19
- */
20
- isFetchingUserInfo: boolean;
21
- /**
22
- * Error occurred while fetching userInfo.
23
- */
24
- error: Error | null;
25
- /**
26
- * Initiates login flow.
27
- * @param {string} [state] - Optional value to be echoed back to the SDK upon redirect.
28
- */
29
- startLogin: (state?: string) => void;
30
- /**
31
- * Initiates register flow.
32
- * @param {string} [state] - Optional value to be echoed back to the SDK upon redirect.
33
- */
34
- startRegister: (state?: string) => void;
35
- /**
36
- * Initiates logout flow.
37
- */
38
- startLogout: () => void;
39
- /**
40
- * Refreshes the access token a single time.
41
- * This is handled automatically if the SDK is configured with `shouldAutoRefresh`.
42
- */
43
- refreshToken: () => Promise<void>;
44
- /**
45
- * Initializes automatic access token refreshing.
46
- * This is handled automatically if the SDK is configured with `shouldAutoRefresh`.
47
- */
48
- initAutoRefresh: () => void;
49
- }
50
- /**
51
- * User information returned from FusionAuth.
52
- */
53
- export type UserInfo = {
54
- applicationId?: string;
55
- birthdate?: string;
56
- email?: string;
57
- email_verified?: boolean;
58
- family_name?: string;
59
- given_name?: string;
60
- name?: string;
61
- middle_name?: string;
62
- phone_number?: string;
63
- picture?: string;
64
- preferred_username?: string;
65
- roles?: any[];
66
- sid?: string;
67
- sub?: string;
68
- tid?: string;
69
- };
@@ -1 +0,0 @@
1
- export * from './SDKContext';
@@ -1,28 +0,0 @@
1
- /// <reference types="node" />
2
- import { SDKConfig } from '../SDKConfig';
3
- import { UserInfo } from '../SDKContext';
4
- /** A class containing framework-agnostic SDK methods */
5
- export declare class SDKCore {
6
- private config;
7
- private urlHelper;
8
- private redirectHelper;
9
- private tokenExpirationTimeout?;
10
- constructor(config: SDKConfig);
11
- startLogin(state?: string): void;
12
- startRegister(state?: string): void;
13
- startLogout(): void;
14
- manageAccount(): void;
15
- fetchUserInfo<T = UserInfo>(): Promise<T>;
16
- refreshToken(): Promise<Response>;
17
- initAutoRefresh(): NodeJS.Timeout | undefined;
18
- handlePostRedirect(callback?: (state?: string) => void): void;
19
- get isLoggedIn(): boolean;
20
- /** The moment of access token expiration in milliseconds since epoch. */
21
- private get at_exp();
22
- /**
23
- * Schedules `onTokenExpiration` at moment of access token expiration.
24
- * SDKCore is not necessarily reactive like React, Angular, and Vue.
25
- * so `onTokenExpiration` is for reactive frameworks to hook in and perform actions as on token expiration.
26
- */
27
- private scheduleTokenExpiration;
28
- }
@@ -1 +0,0 @@
1
- export * from './SDKCore';
@@ -1,23 +0,0 @@
1
- import { UrlHelperConfig } from './UrlHelperTypes';
2
- /** A class responsible for generating URLs that FusionAuth SDKs interact with. */
3
- export declare class UrlHelper {
4
- serverUrl: string;
5
- clientId: string;
6
- redirectUri: string;
7
- scope?: string;
8
- mePath: string;
9
- loginPath: string;
10
- registerPath: string;
11
- logoutPath: string;
12
- tokenRefreshPath: string;
13
- postLogoutRedirectUri?: string;
14
- constructor(config: UrlHelperConfig);
15
- getMeUrl(): URL;
16
- getLoginUrl(state?: string): URL;
17
- getRegisterUrl(state?: string): URL;
18
- getLogoutUrl(): URL;
19
- getTokenRefreshUrl(): URL;
20
- getAccountManagementUrl(): URL;
21
- private generateUrl;
22
- private generateURLSearchParams;
23
- }
@@ -1,11 +0,0 @@
1
- import { SDKConfig } from '../SDKConfig';
2
- /** A configuration object for the UrlHelper class. */
3
- export type UrlHelperConfig = Pick<SDKConfig, 'serverUrl' | 'clientId' | 'redirectUri' | 'mePath' | 'loginPath' | 'registerPath' | 'logoutPath' | 'tokenRefreshPath' | 'scope' | 'postLogoutRedirectUri'>;
4
- /** The query params associated with URLs generated by the UrlHelper class. */
5
- export type UrlHelperQueryParams = {
6
- client_id: string;
7
- redirect_uri?: string;
8
- post_logout_redirect_uri?: string;
9
- scope?: string;
10
- state?: string;
11
- };
@@ -1,2 +0,0 @@
1
- export * from './UrlHelper';
2
- export * from './UrlHelperTypes';
@@ -1,5 +0,0 @@
1
- export * from './SDKCore';
2
- export * from './SDKConfig';
3
- export { type SDKContext } from './SDKContext';
4
- export * from './testUtils';
5
- export { type CookieAdapter } from './CookieHelpers';
@@ -1,2 +0,0 @@
1
- export * from './mockLoggedIn';
2
- export * from './mockWindowLocation';
@@ -1,5 +0,0 @@
1
- /** Sets `app.at_exp` moment cookie so the user will be logged in for 1 hour. */
2
- declare function mockIsLoggedIn(): void;
3
- /** Removes the `app.at_exp` cookie. */
4
- declare function removeAt_expCookie(): void;
5
- export { mockIsLoggedIn, removeAt_expCookie };
@@ -1,18 +0,0 @@
1
- import { VitestUtils } from 'vitest';
2
- declare function mockWindowLocation(vi: VitestUtils): {
3
- assign: import("@vitest/spy").Mock<any, any>;
4
- ancestorOrigins: DOMStringList;
5
- hash: string;
6
- host: string;
7
- hostname: string;
8
- href: string;
9
- toString(): string;
10
- origin: string;
11
- pathname: string;
12
- port: string;
13
- protocol: string;
14
- search: string;
15
- reload(): void;
16
- replace(url: string | URL): void;
17
- };
18
- export { mockWindowLocation };