@asgardeo/browser 0.0.1 → 0.1.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.
- package/README.md +3 -3
- package/dist/__legacy__/client.d.ts +34 -35
- package/dist/__legacy__/helpers/authentication-helper.d.ts +17 -17
- package/dist/__legacy__/helpers/session-management-helper.d.ts +2 -2
- package/dist/__legacy__/helpers/spa-helper.d.ts +1 -1
- package/dist/__legacy__/models/client-config.d.ts +3 -3
- package/dist/__legacy__/models/client.d.ts +28 -28
- package/dist/__legacy__/models/request-custom-grant.d.ts +2 -2
- package/dist/__legacy__/models/session-management-helper.d.ts +2 -2
- package/dist/__legacy__/models/sign-in.d.ts +2 -2
- package/dist/__legacy__/models/storage.d.ts +1 -1
- package/dist/__legacy__/models/web-worker.d.ts +16 -15
- package/dist/__legacy__/stores/local-store.d.ts +2 -2
- package/dist/__legacy__/stores/memory-store.d.ts +2 -2
- package/dist/__legacy__/stores/session-store.d.ts +2 -2
- package/dist/__legacy__/utils/crypto-utils.d.ts +1 -1
- package/dist/__legacy__/utils/spa-utils.d.ts +2 -2
- package/dist/cjs/index.js +1566 -1562
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.js +1556 -1552
- package/dist/index.js.map +4 -4
- package/package.json +5 -5
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
|
-
|
|
32
|
-
|
|
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.
|
|
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,
|
|
18
|
+
import { AuthClientConfig, IsomorphicCrypto, TokenExchangeRequestConfig, StorageManager, IdTokenPayload, 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 {
|
|
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:
|
|
33
|
+
protected _storage: BrowserStorage | undefined;
|
|
34
34
|
protected _authHelper: typeof AuthenticationHelper;
|
|
35
|
-
protected _worker:
|
|
35
|
+
protected _worker: any;
|
|
36
36
|
protected _initialized: boolean;
|
|
37
37
|
protected _startedInitialize: boolean;
|
|
38
|
-
protected _onSignInCallback: (response:
|
|
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
|
-
|
|
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
|
-
*
|
|
101
|
-
*
|
|
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<
|
|
115
|
+
* @return {Promise<User>} - A promise that resolves with the user information.
|
|
117
116
|
*
|
|
118
117
|
* @example
|
|
119
118
|
* ```
|
|
120
|
-
* auth.
|
|
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
|
-
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
402
|
+
getDecodedIdToken(): Promise<IdTokenPayload | 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.
|
|
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#
|
|
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
|
-
|
|
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.
|
|
431
|
+
* const idToken = await auth.getIdToken();
|
|
433
432
|
* ```
|
|
434
433
|
*
|
|
435
|
-
* @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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<
|
|
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
|
-
|
|
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
|
-
*
|
|
639
|
-
*
|
|
637
|
+
* afterSignInUrl: "http://localhost:3000/sign-in",
|
|
638
|
+
* clientId: "client ID",
|
|
640
639
|
* baseUrl: "https://api.asgardeo.io"
|
|
641
640
|
* }
|
|
642
|
-
* const auth.
|
|
641
|
+
* const auth.reInitialize(config);
|
|
643
642
|
* ```
|
|
644
|
-
* @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master/lib#
|
|
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
|
-
|
|
649
|
+
reInitialize(config: Partial<AuthClientConfig<Config>>): Promise<void>;
|
|
651
650
|
}
|
|
@@ -15,44 +15,44 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AsgardeoAuthClient, AuthClientConfig,
|
|
18
|
+
import { AsgardeoAuthClient, AuthClientConfig, User, IsomorphicCrypto, TokenExchangeRequestConfig, StorageManager, IdTokenPayload, 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
|
|
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?:
|
|
32
|
-
|
|
33
|
-
getCustomGrantConfigData(): Promise<AuthClientConfig<
|
|
34
|
-
refreshAccessToken(enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void): Promise<
|
|
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<
|
|
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<
|
|
43
|
+
}) => Promise<User>, sessionManagementHelper: SessionManagementHelperInterface, additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
|
|
44
44
|
params: Record<string, unknown>;
|
|
45
|
-
}): Promise<
|
|
46
|
-
handleSignIn(shouldStopAuthn: () => Promise<boolean>, checkSession: () => Promise<void>, tryRetrievingUserInfo?: () => Promise<
|
|
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
|
-
|
|
49
|
-
|
|
48
|
+
getUser(): Promise<User>;
|
|
49
|
+
getDecodedIdToken(): Promise<IdTokenPayload>;
|
|
50
50
|
getDecodedIDPIDToken(): Promise<IdTokenPayload>;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
getCrypto(): Promise<IsomorphicCrypto>;
|
|
52
|
+
getIdToken(): Promise<string>;
|
|
53
|
+
getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
|
|
54
54
|
getAccessToken(): Promise<string>;
|
|
55
55
|
getIDPAccessToken(): Promise<string>;
|
|
56
|
-
|
|
57
|
-
|
|
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 {
|
|
20
|
-
export declare const SessionManagementHelper: (signOut: () => Promise<string>, storage:
|
|
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
|
|
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 {
|
|
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?:
|
|
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:
|
|
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,
|
|
18
|
+
import { AuthClientConfig, User, IsomorphicCrypto, TokenExchangeRequestConfig, StorageManager, IdTokenPayload, 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,
|
|
31
|
+
signIn(config?: SignInConfig, authorizationCode?: string, sessionState?: string, afterSignInUrl?: string, tokenRequestConfig?: {
|
|
32
32
|
params: Record<string, unknown>;
|
|
33
|
-
}): Promise<
|
|
34
|
-
signOut(
|
|
35
|
-
|
|
36
|
-
refreshAccessToken(): Promise<
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
getUser(): Promise<User>;
|
|
39
|
+
getDecodedIdToken(): Promise<IdTokenPayload>;
|
|
40
|
+
getCrypto(): Promise<IsomorphicCrypto>;
|
|
41
41
|
getConfigData(): Promise<AuthClientConfig<MainThreadClientConfig>>;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
getIdToken(): Promise<string>;
|
|
43
|
+
getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
|
|
44
44
|
getAccessToken(): Promise<string>;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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<
|
|
50
|
+
}): Promise<User | boolean>;
|
|
51
51
|
isSessionActive(): Promise<boolean>;
|
|
52
52
|
}
|
|
53
53
|
export interface WebWorkerClientInterface {
|
|
54
|
-
|
|
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,
|
|
60
|
+
signIn(params?: SignInConfig, authorizationCode?: string, sessionState?: string, afterSignInUrl?: string, tokenRequestConfig?: {
|
|
61
61
|
params: Record<string, unknown>;
|
|
62
|
-
}): Promise<
|
|
63
|
-
signOut(
|
|
62
|
+
}): Promise<User>;
|
|
63
|
+
signOut(afterSignOutUrl?: string): Promise<boolean>;
|
|
64
64
|
revokeAccessToken(): Promise<boolean>;
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
|
|
66
|
+
getUser(): Promise<User>;
|
|
67
67
|
getConfigData(): Promise<AuthClientConfig<WebWorkerClientConfig>>;
|
|
68
|
-
|
|
68
|
+
getDecodedIdToken(): Promise<IdTokenPayload>;
|
|
69
69
|
getDecodedIDPIDToken(): Promise<IdTokenPayload>;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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<
|
|
78
|
-
|
|
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<
|
|
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 {
|
|
18
|
+
import { TokenExchangeRequestConfig } from '@asgardeo/javascript';
|
|
19
19
|
/**
|
|
20
20
|
* SPA Custom Request Grant config model
|
|
21
21
|
*/
|
|
22
|
-
export interface SPACustomGrantConfig extends
|
|
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 {
|
|
18
|
+
import { ExtendedAuthorizeRequestUrlParams } from '@asgardeo/javascript';
|
|
19
19
|
export interface SessionManagementHelperInterface {
|
|
20
|
-
initialize(
|
|
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 {
|
|
19
|
-
export type SignInConfig =
|
|
18
|
+
import { ExtendedAuthorizeRequestUrlParams } from '@asgardeo/javascript';
|
|
19
|
+
export type SignInConfig = ExtendedAuthorizeRequestUrlParams & {
|
|
20
20
|
callOnlyOnRedirect?: boolean;
|
|
21
21
|
};
|
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AuthClientConfig,
|
|
18
|
+
import { AuthClientConfig, AuthorizeRequestUrlParams, User, IsomorphicCrypto, TokenExchangeRequestConfig, IdTokenPayload, 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>
|
|
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
|
-
|
|
36
|
-
requestAccessToken(authorizationCode?: string, sessionState?: string, pkce?: string, state?: string): Promise<
|
|
37
|
-
signOut(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
refreshAccessToken(): Promise<
|
|
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
|
-
|
|
43
|
-
|
|
43
|
+
getUser(): Promise<User>;
|
|
44
|
+
getDecodedIdToken(): Promise<IdTokenPayload>;
|
|
44
45
|
getDecodedIDPIDToken(): Promise<IdTokenPayload>;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
getCrypto(): Promise<IsomorphicCrypto>;
|
|
47
|
+
getIdToken(): Promise<string>;
|
|
48
|
+
getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
|
|
48
49
|
getAccessToken(): Promise<string>;
|
|
49
|
-
|
|
50
|
+
isSignedIn(): Promise<boolean>;
|
|
50
51
|
startAutoRefreshToken(): Promise<void>;
|
|
51
52
|
setSessionState(sessionState: string): Promise<void>;
|
|
52
|
-
|
|
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 {
|
|
19
|
-
export declare class LocalStore implements
|
|
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 {
|
|
19
|
-
export declare class MemoryStore implements
|
|
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 {
|
|
19
|
-
export declare class SessionStore implements
|
|
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>;
|
|
@@ -27,5 +27,5 @@ export declare class SPACryptoUtils implements Crypto<Buffer | string> {
|
|
|
27
27
|
base64URLDecode(value: string): string;
|
|
28
28
|
hashSha256(data: string): string | Buffer;
|
|
29
29
|
generateRandomBytes(length: number): string | Buffer;
|
|
30
|
-
verifyJwt(idToken: string, jwk: Partial<JWKInterface>, algorithms: string[],
|
|
30
|
+
verifyJwt(idToken: string, jwk: Partial<JWKInterface>, algorithms: string[], clientId: string, issuer: string, subject: string, clockTolerance?: number, validateJwtIssuer?: boolean): Promise<boolean>;
|
|
31
31
|
}
|
|
@@ -21,8 +21,8 @@ export declare class SPAUtils {
|
|
|
21
21
|
static removeAuthorizationCode(): void;
|
|
22
22
|
static getPKCE(pkceKey: string): string;
|
|
23
23
|
static setPKCE(pkceKey: string, pkce: string): void;
|
|
24
|
-
static setSignOutURL(url: string,
|
|
25
|
-
static
|
|
24
|
+
static setSignOutURL(url: string, clientId: string, instanceID: number): void;
|
|
25
|
+
static getSignOutUrl(clientId: string, instanceID: number): string;
|
|
26
26
|
static removePKCE(pkceKey: string): void;
|
|
27
27
|
/**
|
|
28
28
|
* This method is used to discontinue the execution of the `signIn` method if `callOnlyOnRedirect` is true and
|