@asgardeo/browser 0.0.1 → 0.1.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 CHANGED
@@ -28,8 +28,8 @@ import { AsgardeoAuthClient } from "@asgardeo/browser";
28
28
 
29
29
  // Initialize the auth client
30
30
  const authClient = new AsgardeoAuthClient({
31
- signInRedirectURL: "https://localhost:3000",
32
- clientID: "<your_client_id>",
31
+ afterSignInUrl: "https://localhost:3000",
32
+ clientId: "<your_client_id>",
33
33
  baseUrl: "https://api.asgardeo.io/t/<org_name>"
34
34
  });
35
35
 
@@ -37,7 +37,7 @@ const authClient = new AsgardeoAuthClient({
37
37
  authClient.signIn();
38
38
 
39
39
  // Get user info after authentication
40
- const userInfo = await authClient.getBasicUserInfo();
40
+ const userInfo = await authClient.getUser();
41
41
 
42
42
  // Sign out
43
43
  authClient.signOut();
@@ -15,12 +15,12 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { AuthClientConfig, BasicUserInfo, IsomorphicCrypto, CustomGrantConfig, DataLayer, IdTokenPayload, FetchResponse, OIDCEndpoints } from '@asgardeo/javascript';
18
+ import { AuthClientConfig, IsomorphicCrypto, TokenExchangeRequestConfig, StorageManager, IdToken, OIDCEndpoints, User } from '@asgardeo/javascript';
19
19
  import { Hooks } from './constants';
20
20
  import { AuthenticationHelper } from './helpers';
21
21
  import { HttpClientInstance } from './http-client';
22
22
  import { AuthSPAClientConfig, LegacyConfig as Config, HttpRequestConfig, HttpResponse, MainThreadClientConfig, MainThreadClientInterface, SignInConfig, SignOutError, WebWorkerClientConfig, WebWorkerClientInterface } from './models';
23
- import { Storage } from './models/storage';
23
+ import { BrowserStorage } from './models/storage';
24
24
  /**
25
25
  * This class provides the necessary methods to implement authentication in a Single Page Application.
26
26
  *
@@ -30,12 +30,12 @@ import { Storage } from './models/storage';
30
30
  export declare class AsgardeoSPAClient {
31
31
  protected static _instances: Map<number, AsgardeoSPAClient>;
32
32
  protected _client: WebWorkerClientInterface | MainThreadClientInterface | undefined;
33
- protected _storage: Storage | undefined;
33
+ protected _storage: BrowserStorage | undefined;
34
34
  protected _authHelper: typeof AuthenticationHelper;
35
- protected _worker: new () => Worker;
35
+ protected _worker: any;
36
36
  protected _initialized: boolean;
37
37
  protected _startedInitialize: boolean;
38
- protected _onSignInCallback: (response: BasicUserInfo) => void;
38
+ protected _onSignInCallback: (response: User) => void;
39
39
  protected _onSignOutCallback: () => void;
40
40
  protected _onSignOutFailedCallback: (error: SignOutError) => void;
41
41
  protected _onEndUserSession: (response: any) => void;
@@ -44,7 +44,6 @@ export declare class AsgardeoSPAClient {
44
44
  protected _instanceID: number;
45
45
  protected constructor(id: number);
46
46
  instantiateAuthHelper(authHelper?: typeof AuthenticationHelper): void;
47
- instantiateWorker(worker: new () => Worker): void;
48
47
  /**
49
48
  * This method specifies if the `AsgardeoSPAClient` has been initialized or not.
50
49
  *
@@ -54,7 +53,7 @@ export declare class AsgardeoSPAClient {
54
53
  *
55
54
  * @private
56
55
  */
57
- private _isInitialized;
56
+ isInitialized(): Promise<boolean>;
58
57
  /**
59
58
  * This method checks if the SDK is initialized and the user is authenticated.
60
59
  *
@@ -97,8 +96,8 @@ export declare class AsgardeoSPAClient {
97
96
  * @example
98
97
  * ```
99
98
  * auth.initialize({
100
- * signInRedirectURL: "http://localhost:3000/sign-in",
101
- * clientID: "client ID",
99
+ * afterSignInUrl: "http://localhost:3000/sign-in",
100
+ * clientId: "client ID",
102
101
  * baseUrl: "https://api.asgardeo.io"
103
102
  * });
104
103
  * ```
@@ -113,11 +112,11 @@ export declare class AsgardeoSPAClient {
113
112
  /**
114
113
  * This method returns a Promise that resolves with the basic user information obtained from the ID token.
115
114
  *
116
- * @return {Promise<BasicUserInfo>} - A promise that resolves with the user information.
115
+ * @return {Promise<User>} - A promise that resolves with the user information.
117
116
  *
118
117
  * @example
119
118
  * ```
120
- * auth.getBasicUserInfo().then((response) => {
119
+ * auth.getUser().then((response) => {
121
120
  * // console.log(response);
122
121
  * }).catch((error) => {
123
122
  * // console.error(error);
@@ -130,7 +129,7 @@ export declare class AsgardeoSPAClient {
130
129
  *
131
130
  * @preserve
132
131
  */
133
- getBasicUserInfo(): Promise<BasicUserInfo | undefined>;
132
+ getUser(): Promise<User | undefined>;
134
133
  /**
135
134
  * This method initiates the authentication flow. This should be called twice.
136
135
  * 1. To initiate the authentication flow.
@@ -154,7 +153,7 @@ export declare class AsgardeoSPAClient {
154
153
  * @param {string} sessionState - The session state. (Optional)
155
154
  * @param {string} state - The state. (Optional)
156
155
  *
157
- * @return {Promise<BasicUserInfo>} - A promise that resolves with the user information.
156
+ * @return {Promise<User>} - A promise that resolves with the user information.
158
157
  *
159
158
  * @example
160
159
  * ```
@@ -169,7 +168,7 @@ export declare class AsgardeoSPAClient {
169
168
  */
170
169
  signIn(config?: SignInConfig, authorizationCode?: string, sessionState?: string, state?: string, tokenRequestConfig?: {
171
170
  params: Record<string, unknown>;
172
- }): Promise<BasicUserInfo | undefined>;
171
+ }): Promise<User | undefined>;
173
172
  /**
174
173
  * This method allows you to sign in silently.
175
174
  * First, this method sends a prompt none request to see if there is an active user session in the identity server.
@@ -178,7 +177,7 @@ export declare class AsgardeoSPAClient {
178
177
  * If this method is to be called on page load and the `signIn` method is also to be called on page load,
179
178
  * then it is advisable to call this method after the `signIn` call.
180
179
  *
181
- * @return {Promise<BasicUserInfo | boolean>} - A Promise that resolves with the user information after signing in
180
+ * @return {Promise<User | boolean>} - A Promise that resolves with the user information after signing in
182
181
  * or with `false` if the user is not signed in.
183
182
  *
184
183
  * @example
@@ -188,7 +187,7 @@ export declare class AsgardeoSPAClient {
188
187
  */
189
188
  trySignInSilently(additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
190
189
  params: Record<string, unknown>;
191
- }): Promise<BasicUserInfo | boolean | undefined>;
190
+ }): Promise<User | boolean | undefined>;
192
191
  /**
193
192
  * This method initiates the sign-out flow.
194
193
  *
@@ -327,7 +326,7 @@ export declare class AsgardeoSPAClient {
327
326
  *
328
327
  * @preserve
329
328
  */
330
- requestCustomGrant(config: CustomGrantConfig): Promise<FetchResponse<any> | BasicUserInfo | undefined>;
329
+ exchangeToken(config: TokenExchangeRequestConfig): Promise<Response | User | undefined>;
331
330
  /**
332
331
  * This method ends a user session. The access token is revoked and the session information is destroyed.
333
332
  *
@@ -369,7 +368,7 @@ export declare class AsgardeoSPAClient {
369
368
  *
370
369
  * @preserve
371
370
  */
372
- getOIDCServiceEndpoints(): Promise<OIDCEndpoints | undefined>;
371
+ getOpenIDProviderEndpoints(): Promise<OIDCEndpoints | undefined>;
373
372
  /**
374
373
  * This methods returns the Axios http client.
375
374
  *
@@ -388,7 +387,7 @@ export declare class AsgardeoSPAClient {
388
387
  *
389
388
  * @example
390
389
  * ```
391
- * auth.getDecodedIDToken().then((response)=>{
390
+ * auth.getDecodedIdToken().then((response)=>{
392
391
  * // console.log(response);
393
392
  * }).catch((error)=>{
394
393
  * // console.error(error);
@@ -400,7 +399,7 @@ export declare class AsgardeoSPAClient {
400
399
  *
401
400
  * @preserve
402
401
  */
403
- getDecodedIDToken(): Promise<IdTokenPayload | undefined>;
402
+ getDecodedIdToken(): Promise<IdToken | undefined>;
404
403
  /**
405
404
  * This method returns the IsomorphicCrypto instance.
406
405
  *
@@ -409,19 +408,19 @@ export declare class AsgardeoSPAClient {
409
408
  *
410
409
  * @example
411
410
  * ```
412
- * auth.getCryptoHelper().then((response)=>{
411
+ * auth.getCrypto().then((response)=>{
413
412
  * // console.log(response);
414
413
  * }).catch((error)=>{
415
414
  * // console.error(error);
416
415
  * });
417
416
  * ```
418
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getCryptoHelper
417
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getCrypto
419
418
  *
420
419
  * @memberof AsgardeoSPAClient
421
420
  *
422
421
  * @preserve
423
422
  */
424
- getCryptoHelper(): Promise<IsomorphicCrypto | undefined>;
423
+ getCrypto(): Promise<IsomorphicCrypto | undefined>;
425
424
  /**
426
425
  * This method return the ID token.
427
426
  *
@@ -429,16 +428,16 @@ export declare class AsgardeoSPAClient {
429
428
  *
430
429
  * @example
431
430
  * ```
432
- * const idToken = await auth.getIDToken();
431
+ * const idToken = await auth.getIdToken();
433
432
  * ```
434
433
  *
435
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIDToken
434
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIdToken
436
435
  *
437
436
  * @memberof AsgardeoAuthClient
438
437
  *
439
438
  * @preserve
440
439
  */
441
- getIDToken(): Promise<string | undefined>;
440
+ getIdToken(): Promise<string | undefined>;
442
441
  /**
443
442
  * This method return a Promise that resolves with the access token.
444
443
  *
@@ -494,7 +493,7 @@ export declare class AsgardeoSPAClient {
494
493
  *
495
494
  * @example
496
495
  * ```
497
- * auth.getDataLayer().then((dataLayer) => {
496
+ * auth.getStorageManager().then((dataLayer) => {
498
497
  * // console.log(dataLayer);
499
498
  * }).catch((error) => {
500
499
  * // console.error(error);
@@ -507,7 +506,7 @@ export declare class AsgardeoSPAClient {
507
506
  *
508
507
  * @preserve
509
508
  */
510
- getDataLayer(): Promise<DataLayer<MainThreadClientConfig>>;
509
+ getStorageManager(): Promise<StorageManager<MainThreadClientConfig>>;
511
510
  /**
512
511
  * This method return a Promise that resolves with the config data stored in the storage.
513
512
  *
@@ -550,7 +549,7 @@ export declare class AsgardeoSPAClient {
550
549
  *
551
550
  * @preserve
552
551
  */
553
- refreshAccessToken(): Promise<BasicUserInfo | undefined>;
552
+ refreshAccessToken(): Promise<User | undefined>;
554
553
  /**
555
554
  * This method specifies if the user is authenticated or not.
556
555
  *
@@ -560,7 +559,7 @@ export declare class AsgardeoSPAClient {
560
559
  *
561
560
  * @preserve
562
561
  */
563
- isAuthenticated(): Promise<boolean | undefined>;
562
+ isSignedIn(): Promise<boolean | undefined>;
564
563
  /**
565
564
  * This method specifies if there is an active session in the browser or not.
566
565
  *
@@ -635,17 +634,17 @@ export declare class AsgardeoSPAClient {
635
634
  * @example
636
635
  * ```
637
636
  * const config = {
638
- * signInRedirectURL: "http://localhost:3000/sign-in",
639
- * clientID: "client ID",
637
+ * afterSignInUrl: "http://localhost:3000/sign-in",
638
+ * clientId: "client ID",
640
639
  * baseUrl: "https://api.asgardeo.io"
641
640
  * }
642
- * const auth.updateConfig(config);
641
+ * const auth.reInitialize(config);
643
642
  * ```
644
- * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master/lib#updateConfig
643
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master/lib#reInitialize
645
644
  *
646
645
  * @memberof AsgardeoAuthClient
647
646
  *
648
647
  * @preserve
649
648
  */
650
- updateConfig(config: Partial<AuthClientConfig<Config>>): Promise<void>;
649
+ reInitialize(config: Partial<AuthClientConfig<Config>>): Promise<void>;
651
650
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
3
  *
4
- * WSO2 Inc. licenses this file to you under the Apache License,
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
5
  * Version 2.0 (the "License"); you may not use this file except
6
6
  * in compliance with the License.
7
7
  * You may obtain a copy of the License at
@@ -16,6 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { AsgardeoAuthClient, AuthClientConfig } from '@asgardeo/javascript';
19
- import { AuthenticationHelper, SPAHelper } from '../helpers';
19
+ import { AuthenticationHelper } from '../helpers/authentication-helper';
20
+ import { SPAHelper } from '../helpers/spa-helper';
20
21
  import { MainThreadClientConfig, MainThreadClientInterface } from '../models';
21
22
  export declare const MainThreadClient: (instanceID: number, config: AuthClientConfig<MainThreadClientConfig>, getAuthHelper: (authClient: AsgardeoAuthClient<MainThreadClientConfig>, spaHelper: SPAHelper<MainThreadClientConfig>) => AuthenticationHelper<MainThreadClientConfig>) => Promise<MainThreadClientInterface>;
@@ -15,44 +15,44 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { AsgardeoAuthClient, AuthClientConfig, BasicUserInfo, IsomorphicCrypto, CustomGrantConfig, DataLayer, IdTokenPayload, FetchResponse, GetAuthURLConfig, OIDCEndpoints } from '@asgardeo/javascript';
18
+ import { AsgardeoAuthClient, AuthClientConfig, User, IsomorphicCrypto, TokenExchangeRequestConfig, StorageManager, IdToken, ExtendedAuthorizeRequestUrlParams, OIDCEndpoints } from '@asgardeo/javascript';
19
19
  import { SPAHelper } from './spa-helper';
20
20
  import { HttpClientInstance, HttpError, HttpRequestConfig, HttpRequestInterface, HttpResponse, MainThreadClientConfig, SessionManagementHelperInterface, WebWorkerClientConfig } from '../models';
21
21
  import { SPACustomGrantConfig } from '../models/request-custom-grant';
22
22
  export declare class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerClientConfig> {
23
23
  protected _authenticationClient: AsgardeoAuthClient<T>;
24
- protected _dataLayer: DataLayer<T>;
24
+ protected _storageManager: StorageManager<T>;
25
25
  protected _spaHelper: SPAHelper<T>;
26
26
  protected _instanceID: number;
27
27
  protected _isTokenRefreshing: boolean;
28
28
  constructor(authClient: AsgardeoAuthClient<T>, spaHelper: SPAHelper<T>);
29
29
  enableHttpHandler(httpClient: HttpClientInstance): void;
30
30
  disableHttpHandler(httpClient: HttpClientInstance): void;
31
- initializeSessionManger(config: AuthClientConfig<T>, oidcEndpoints: OIDCEndpoints, getSessionState: () => Promise<string>, getAuthzURL: (params?: GetAuthURLConfig) => Promise<string>, sessionManagementHelper: SessionManagementHelperInterface): void;
32
- requestCustomGrant(config: SPACustomGrantConfig, enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void): Promise<BasicUserInfo | FetchResponse>;
33
- getCustomGrantConfigData(): Promise<AuthClientConfig<CustomGrantConfig> | null>;
34
- refreshAccessToken(enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void): Promise<BasicUserInfo>;
31
+ initializeSessionManger(config: AuthClientConfig<T>, oidcEndpoints: OIDCEndpoints, getSessionState: () => Promise<string>, getAuthzURL: (params?: ExtendedAuthorizeRequestUrlParams) => Promise<string>, sessionManagementHelper: SessionManagementHelperInterface): void;
32
+ exchangeToken(config: SPACustomGrantConfig, enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void): Promise<User | Response>;
33
+ getCustomGrantConfigData(): Promise<AuthClientConfig<TokenExchangeRequestConfig> | null>;
34
+ refreshAccessToken(enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void): Promise<User>;
35
35
  protected retryFailedRequests(failedRequest: HttpRequestInterface): Promise<HttpResponse>;
36
36
  httpRequest(httpClient: HttpClientInstance, requestConfig: HttpRequestConfig, isHttpHandlerEnabled?: boolean, httpErrorCallback?: (error: HttpError) => void | Promise<void>, httpFinishCallback?: () => void, enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void): Promise<HttpResponse>;
37
37
  httpRequestAll(requestConfigs: HttpRequestConfig[], httpClient: HttpClientInstance, isHttpHandlerEnabled?: boolean, httpErrorCallback?: (error: HttpError) => void | Promise<void>, httpFinishCallback?: () => void): Promise<HttpResponse[] | undefined>;
38
38
  requestAccessToken(authorizationCode?: string, sessionState?: string, checkSession?: () => Promise<void>, pkce?: string, state?: string, tokenRequestConfig?: {
39
39
  params: Record<string, unknown>;
40
- }): Promise<BasicUserInfo>;
40
+ }): Promise<User>;
41
41
  trySignInSilently(constructSilentSignInUrl: (additionalParams?: Record<string, string | boolean>) => Promise<string>, requestAccessToken: (authzCode: string, sessionState: string, state: string, tokenRequestConfig?: {
42
42
  params: Record<string, unknown>;
43
- }) => Promise<BasicUserInfo>, sessionManagementHelper: SessionManagementHelperInterface, additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
43
+ }) => Promise<User>, sessionManagementHelper: SessionManagementHelperInterface, additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
44
44
  params: Record<string, unknown>;
45
- }): Promise<BasicUserInfo | boolean>;
46
- handleSignIn(shouldStopAuthn: () => Promise<boolean>, checkSession: () => Promise<void>, tryRetrievingUserInfo?: () => Promise<BasicUserInfo | undefined>): Promise<BasicUserInfo | undefined>;
45
+ }): Promise<User | boolean>;
46
+ handleSignIn(shouldStopAuthn: () => Promise<boolean>, checkSession: () => Promise<void>, tryRetrievingUserInfo?: () => Promise<User | undefined>): Promise<User | undefined>;
47
47
  attachTokenToRequestConfig(request: HttpRequestConfig): Promise<void>;
48
- getBasicUserInfo(): Promise<BasicUserInfo>;
49
- getDecodedIDToken(): Promise<IdTokenPayload>;
50
- getDecodedIDPIDToken(): Promise<IdTokenPayload>;
51
- getCryptoHelper(): Promise<IsomorphicCrypto>;
52
- getIDToken(): Promise<string>;
53
- getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
48
+ getUser(): Promise<User>;
49
+ getDecodedIdToken(): Promise<IdToken>;
50
+ getDecodedIDPIDToken(): Promise<IdToken>;
51
+ getCrypto(): Promise<IsomorphicCrypto>;
52
+ getIdToken(): Promise<string>;
53
+ getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
54
54
  getAccessToken(): Promise<string>;
55
55
  getIDPAccessToken(): Promise<string>;
56
- getDataLayer(): DataLayer<T>;
57
- isAuthenticated(): Promise<boolean>;
56
+ getStorageManager(): StorageManager<T>;
57
+ isSignedIn(): Promise<boolean>;
58
58
  }
@@ -16,5 +16,5 @@
16
16
  * under the License.
17
17
  */
18
18
  import { SessionManagementHelperInterface } from '../models';
19
- import { Storage } from '../models/storage';
20
- export declare const SessionManagementHelper: (signOut: () => Promise<string>, storage: Storage, setSessionState: (sessionState: string) => void) => Promise<SessionManagementHelperInterface>;
19
+ import { BrowserStorage } from '../models/storage';
20
+ export declare const SessionManagementHelper: (signOut: () => Promise<string>, storage: BrowserStorage, setSessionState: (sessionState: string) => void) => Promise<SessionManagementHelperInterface>;
@@ -20,7 +20,7 @@ import { AuthenticationHelper } from '../helpers/authentication-helper';
20
20
  import { MainThreadClientConfig, WebWorkerClientConfig } from '../models/client-config';
21
21
  export declare class SPAHelper<T extends MainThreadClientConfig | WebWorkerClientConfig> {
22
22
  private _authenticationClient;
23
- private _dataLayer;
23
+ private _storageManager;
24
24
  constructor(authClient: AsgardeoAuthClient<T>);
25
25
  refreshAccessTokenAutomatically(authenticationHelper: AuthenticationHelper<MainThreadClientConfig | WebWorkerClientConfig>): Promise<void>;
26
26
  getRefreshTimeoutTimer(): Promise<number>;
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { AuthClientConfig } from '@asgardeo/javascript';
19
- import { Storage } from './storage';
19
+ import { BrowserStorage } from './storage';
20
20
  export interface SPAConfig {
21
21
  /**
22
22
  * Enable OIDC Session Management with PR Iframe.
@@ -38,13 +38,13 @@ export interface MainThreadClientConfig extends SPAConfig {
38
38
  /**
39
39
  * The storage type to be used for storing the session information.
40
40
  */
41
- storage?: Storage.SessionStorage | Storage.LocalStorage | Storage.BrowserMemory | 'sessionStorage' | 'localStorage' | 'browserMemory';
41
+ storage?: BrowserStorage.SessionStorage | BrowserStorage.LocalStorage | BrowserStorage.BrowserMemory | 'sessionStorage' | 'localStorage' | 'browserMemory';
42
42
  }
43
43
  export interface WebWorkerClientConfig extends SPAConfig {
44
44
  /**
45
45
  * The storage type to be used for storing the session information.
46
46
  */
47
- storage: Storage.WebWorker | 'webWorker';
47
+ storage: BrowserStorage.WebWorker | 'webWorker';
48
48
  /**
49
49
  * Specifies in seconds how long a request to the web worker should wait before being timed.
50
50
  */
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { AuthClientConfig, BasicUserInfo, IsomorphicCrypto, CustomGrantConfig, DataLayer, IdTokenPayload, FetchResponse, OIDCEndpoints } from '@asgardeo/javascript';
18
+ import { AuthClientConfig, User, IsomorphicCrypto, TokenExchangeRequestConfig, StorageManager, IdToken, OIDCEndpoints } from '@asgardeo/javascript';
19
19
  import { HttpError, HttpRequestConfig, HttpResponse, MainThreadClientConfig, SignInConfig, WebWorkerClientConfig } from '.';
20
20
  import { HttpClientInstance } from '../http-client';
21
21
  export interface MainThreadClientInterface {
@@ -28,55 +28,55 @@ export interface MainThreadClientInterface {
28
28
  getHttpClient(): HttpClientInstance;
29
29
  enableHttpHandler(): boolean;
30
30
  disableHttpHandler(): boolean;
31
- signIn(config?: SignInConfig, authorizationCode?: string, sessionState?: string, signInRedirectURL?: string, tokenRequestConfig?: {
31
+ signIn(config?: SignInConfig, authorizationCode?: string, sessionState?: string, afterSignInUrl?: string, tokenRequestConfig?: {
32
32
  params: Record<string, unknown>;
33
- }): Promise<BasicUserInfo>;
34
- signOut(signOutRedirectURL?: string): Promise<boolean>;
35
- requestCustomGrant(config: CustomGrantConfig): Promise<BasicUserInfo | FetchResponse>;
36
- refreshAccessToken(): Promise<BasicUserInfo>;
33
+ }): Promise<User>;
34
+ signOut(afterSignOutUrl?: string): Promise<boolean>;
35
+ exchangeToken(config: TokenExchangeRequestConfig): Promise<User | Response>;
36
+ refreshAccessToken(): Promise<User>;
37
37
  revokeAccessToken(): Promise<boolean>;
38
- getBasicUserInfo(): Promise<BasicUserInfo>;
39
- getDecodedIDToken(): Promise<IdTokenPayload>;
40
- getCryptoHelper(): Promise<IsomorphicCrypto>;
38
+ getUser(): Promise<User>;
39
+ getDecodedIdToken(): Promise<IdToken>;
40
+ getCrypto(): Promise<IsomorphicCrypto>;
41
41
  getConfigData(): Promise<AuthClientConfig<MainThreadClientConfig>>;
42
- getIDToken(): Promise<string>;
43
- getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
42
+ getIdToken(): Promise<string>;
43
+ getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
44
44
  getAccessToken(): Promise<string>;
45
- getDataLayer(): Promise<DataLayer<MainThreadClientConfig>>;
46
- isAuthenticated(): Promise<boolean>;
47
- updateConfig(config: Partial<AuthClientConfig<MainThreadClientConfig>>): Promise<void>;
45
+ getStorageManager(): Promise<StorageManager<MainThreadClientConfig>>;
46
+ isSignedIn(): Promise<boolean>;
47
+ reInitialize(config: Partial<AuthClientConfig<MainThreadClientConfig>>): Promise<void>;
48
48
  trySignInSilently(additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
49
49
  params: Record<string, unknown>;
50
- }): Promise<BasicUserInfo | boolean>;
50
+ }): Promise<User | boolean>;
51
51
  isSessionActive(): Promise<boolean>;
52
52
  }
53
53
  export interface WebWorkerClientInterface {
54
- requestCustomGrant(requestParams: CustomGrantConfig): Promise<FetchResponse | BasicUserInfo>;
54
+ exchangeToken(requestParams: TokenExchangeRequestConfig): Promise<Response | User>;
55
55
  httpRequest<T = any>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
56
56
  httpRequestAll<T = any>(configs: HttpRequestConfig[]): Promise<HttpResponse<T>[]>;
57
57
  enableHttpHandler(): Promise<boolean>;
58
58
  disableHttpHandler(): Promise<boolean>;
59
59
  initialize(): Promise<boolean>;
60
- signIn(params?: SignInConfig, authorizationCode?: string, sessionState?: string, signInRedirectURL?: string, tokenRequestConfig?: {
60
+ signIn(params?: SignInConfig, authorizationCode?: string, sessionState?: string, afterSignInUrl?: string, tokenRequestConfig?: {
61
61
  params: Record<string, unknown>;
62
- }): Promise<BasicUserInfo>;
63
- signOut(signOutRedirectURL?: string): Promise<boolean>;
62
+ }): Promise<User>;
63
+ signOut(afterSignOutUrl?: string): Promise<boolean>;
64
64
  revokeAccessToken(): Promise<boolean>;
65
- getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
66
- getBasicUserInfo(): Promise<BasicUserInfo>;
65
+ getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
66
+ getUser(): Promise<User>;
67
67
  getConfigData(): Promise<AuthClientConfig<WebWorkerClientConfig>>;
68
- getDecodedIDToken(): Promise<IdTokenPayload>;
69
- getDecodedIDPIDToken(): Promise<IdTokenPayload>;
70
- getCryptoHelper(): Promise<IsomorphicCrypto>;
71
- getIDToken(): Promise<string>;
72
- isAuthenticated(): Promise<boolean>;
68
+ getDecodedIdToken(): Promise<IdToken>;
69
+ getDecodedIDPIDToken(): Promise<IdToken>;
70
+ getCrypto(): Promise<IsomorphicCrypto>;
71
+ getIdToken(): Promise<string>;
72
+ isSignedIn(): Promise<boolean>;
73
73
  setHttpRequestSuccessCallback(callback: (response: HttpResponse) => void): void;
74
74
  setHttpRequestErrorCallback(callback: (response: HttpError) => void | Promise<void>): void;
75
75
  setHttpRequestStartCallback(callback: () => void): void;
76
76
  setHttpRequestFinishCallback(callback: () => void): void;
77
- refreshAccessToken(): Promise<BasicUserInfo>;
78
- updateConfig(config: Partial<AuthClientConfig<WebWorkerClientConfig>>): Promise<void>;
77
+ refreshAccessToken(): Promise<User>;
78
+ reInitialize(config: Partial<AuthClientConfig<WebWorkerClientConfig>>): Promise<void>;
79
79
  trySignInSilently(additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
80
80
  params: Record<string, unknown>;
81
- }): Promise<BasicUserInfo | boolean>;
81
+ }): Promise<User | boolean>;
82
82
  }
@@ -15,10 +15,10 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { CustomGrantConfig } from '@asgardeo/javascript';
18
+ import { TokenExchangeRequestConfig } from '@asgardeo/javascript';
19
19
  /**
20
20
  * SPA Custom Request Grant config model
21
21
  */
22
- export interface SPACustomGrantConfig extends CustomGrantConfig {
22
+ export interface SPACustomGrantConfig extends TokenExchangeRequestConfig {
23
23
  preventSignOutURLUpdate?: boolean;
24
24
  }
@@ -15,9 +15,9 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { GetAuthURLConfig } from '@asgardeo/javascript';
18
+ import { ExtendedAuthorizeRequestUrlParams } from '@asgardeo/javascript';
19
19
  export interface SessionManagementHelperInterface {
20
- initialize(clientID: string, checkSessionEndpoint: string, getSessionState: () => Promise<string>, interval: number, sessionRefreshInterval: number, redirectURL: string, getAuthorizationURL: (params?: GetAuthURLConfig) => Promise<string>): void;
20
+ initialize(clientId: string, checkSessionEndpoint: string, getSessionState: () => Promise<string>, interval: number, sessionRefreshInterval: number, redirectURL: string, getSignInUrl: (params?: ExtendedAuthorizeRequestUrlParams) => Promise<string>): void;
21
21
  receivePromptNoneResponse(setSessionState?: (sessionState: string | null) => Promise<void>): Promise<boolean>;
22
22
  reset(): any;
23
23
  }
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { GetAuthURLConfig } from '@asgardeo/javascript';
19
- export type SignInConfig = GetAuthURLConfig & {
18
+ import { ExtendedAuthorizeRequestUrlParams } from '@asgardeo/javascript';
19
+ export type SignInConfig = ExtendedAuthorizeRequestUrlParams & {
20
20
  callOnlyOnRedirect?: boolean;
21
21
  };
@@ -18,7 +18,7 @@
18
18
  /**
19
19
  * Enum for the different storage types.
20
20
  */
21
- export declare enum Storage {
21
+ export declare enum BrowserStorage {
22
22
  /**
23
23
  * Stores the session information in the local storage
24
24
  */
@@ -15,14 +15,15 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { AuthClientConfig, AuthorizationURLParams, BasicUserInfo, IsomorphicCrypto, CustomGrantConfig, IdTokenPayload, FetchResponse, OIDCEndpoints } from '@asgardeo/javascript';
18
+ import { AuthClientConfig, AuthorizeRequestUrlParams, User, IsomorphicCrypto, TokenExchangeRequestConfig, IdToken, OIDCEndpoints } from '@asgardeo/javascript';
19
19
  import { HttpRequestConfig, HttpResponse, Message } from '.';
20
20
  import { AuthorizationResponse, WebWorkerClientConfig } from '../..';
21
21
  interface WebWorkerEvent<T> extends MessageEvent {
22
22
  data: Message<T>;
23
23
  }
24
- export declare class WebWorkerClass<T> extends Worker {
24
+ export declare class WebWorkerClass<T> {
25
25
  onmessage: (this: Worker, event: WebWorkerEvent<T>) => any;
26
+ postMessage: (message: Message<T>) => void;
26
27
  }
27
28
  export interface WebWorkerCoreInterface {
28
29
  setHttpRequestStartCallback(callback: () => void): void;
@@ -32,24 +33,24 @@ export interface WebWorkerCoreInterface {
32
33
  httpRequestAll(configs: HttpRequestConfig[]): Promise<HttpResponse[] | undefined>;
33
34
  enableHttpHandler(): void;
34
35
  disableHttpHandler(): void;
35
- getAuthorizationURL(params?: AuthorizationURLParams, signInRedirectURL?: string): Promise<AuthorizationResponse>;
36
- requestAccessToken(authorizationCode?: string, sessionState?: string, pkce?: string, state?: string): Promise<BasicUserInfo>;
37
- signOut(signOutRedirectURL?: string): Promise<string>;
38
- getSignOutURL(signOutRedirectURL?: string): Promise<string>;
39
- requestCustomGrant(config: CustomGrantConfig): Promise<BasicUserInfo | FetchResponse>;
40
- refreshAccessToken(): Promise<BasicUserInfo>;
36
+ getSignInUrl(params?: AuthorizeRequestUrlParams, afterSignInUrl?: string): Promise<AuthorizationResponse>;
37
+ requestAccessToken(authorizationCode?: string, sessionState?: string, pkce?: string, state?: string): Promise<User>;
38
+ signOut(afterSignOutUrl?: string): Promise<string>;
39
+ getSignOutUrl(afterSignOutUrl?: string): Promise<string>;
40
+ exchangeToken(config: TokenExchangeRequestConfig): Promise<User | Response>;
41
+ refreshAccessToken(): Promise<User>;
41
42
  revokeAccessToken(): Promise<boolean>;
42
- getBasicUserInfo(): Promise<BasicUserInfo>;
43
- getDecodedIDToken(): Promise<IdTokenPayload>;
44
- getDecodedIDPIDToken(): Promise<IdTokenPayload>;
45
- getCryptoHelper(): Promise<IsomorphicCrypto>;
46
- getIDToken(): Promise<string>;
47
- getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
43
+ getUser(): Promise<User>;
44
+ getDecodedIdToken(): Promise<IdToken>;
45
+ getDecodedIDPIDToken(): Promise<IdToken>;
46
+ getCrypto(): Promise<IsomorphicCrypto>;
47
+ getIdToken(): Promise<string>;
48
+ getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
48
49
  getAccessToken(): Promise<string>;
49
- isAuthenticated(): Promise<boolean>;
50
+ isSignedIn(): Promise<boolean>;
50
51
  startAutoRefreshToken(): Promise<void>;
51
52
  setSessionState(sessionState: string): Promise<void>;
52
- updateConfig(config: Partial<AuthClientConfig<WebWorkerClientConfig>>): Promise<void>;
53
+ reInitialize(config: Partial<AuthClientConfig<WebWorkerClientConfig>>): Promise<void>;
53
54
  getConfigData(): Promise<AuthClientConfig<WebWorkerClientConfig>>;
54
55
  }
55
56
  export {};
@@ -15,8 +15,8 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { Store } from '@asgardeo/javascript';
19
- export declare class LocalStore implements Store {
18
+ import { Storage } from '@asgardeo/javascript';
19
+ export declare class LocalStore implements Storage {
20
20
  setData(key: string, value: string): Promise<void>;
21
21
  getData(key: string): Promise<string>;
22
22
  removeData(key: string): Promise<void>;
@@ -15,8 +15,8 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { Store } from '@asgardeo/javascript';
19
- export declare class MemoryStore implements Store {
18
+ import { Storage } from '@asgardeo/javascript';
19
+ export declare class MemoryStore implements Storage {
20
20
  private _data;
21
21
  constructor();
22
22
  setData(key: string, value: string): Promise<void>;
@@ -15,8 +15,8 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { Store } from '@asgardeo/javascript';
19
- export declare class SessionStore implements Store {
18
+ import { Storage } from '@asgardeo/javascript';
19
+ export declare class SessionStore implements Storage {
20
20
  setData(key: string, value: string): Promise<void>;
21
21
  getData(key: string): Promise<string>;
22
22
  removeData(key: string): Promise<void>;