@asgardeo/browser 0.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.
Files changed (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +48 -0
  3. package/dist/AsgardeoBrowserClient.d.ts +28 -0
  4. package/dist/__legacy__/client.d.ts +651 -0
  5. package/dist/__legacy__/clients/index.d.ts +19 -0
  6. package/dist/__legacy__/clients/main-thread-client.d.ts +21 -0
  7. package/dist/__legacy__/clients/web-worker-client.d.ts +21 -0
  8. package/dist/__legacy__/constants/errors.d.ts +18 -0
  9. package/dist/__legacy__/constants/hooks.d.ts +29 -0
  10. package/dist/__legacy__/constants/index.d.ts +23 -0
  11. package/dist/__legacy__/constants/messages-types.d.ts +51 -0
  12. package/dist/__legacy__/constants/parameters.d.ts +21 -0
  13. package/dist/__legacy__/constants/session-management.d.ts +25 -0
  14. package/dist/__legacy__/constants/storage.d.ts +18 -0
  15. package/dist/__legacy__/helpers/authentication-helper.d.ts +58 -0
  16. package/dist/__legacy__/helpers/index.d.ts +20 -0
  17. package/dist/__legacy__/helpers/session-management-helper.d.ts +20 -0
  18. package/dist/__legacy__/helpers/spa-helper.d.ts +28 -0
  19. package/dist/__legacy__/http-client/clients/axios-http-client.d.ts +117 -0
  20. package/dist/__legacy__/http-client/clients/index.d.ts +19 -0
  21. package/dist/__legacy__/http-client/helpers/decorators.d.ts +24 -0
  22. package/dist/__legacy__/http-client/helpers/index.d.ts +19 -0
  23. package/dist/__legacy__/http-client/index.d.ts +20 -0
  24. package/dist/__legacy__/http-client/models/axios-http-client.d.ts +34 -0
  25. package/dist/__legacy__/http-client/models/http-client.d.ts +41 -0
  26. package/dist/__legacy__/http-client/models/index.d.ts +20 -0
  27. package/dist/__legacy__/models/client-config.d.ts +54 -0
  28. package/dist/__legacy__/models/client.d.ts +82 -0
  29. package/dist/__legacy__/models/http-client.d.ts +42 -0
  30. package/dist/__legacy__/models/index.d.ts +26 -0
  31. package/dist/__legacy__/models/message.d.ts +45 -0
  32. package/dist/__legacy__/models/request-custom-grant.d.ts +24 -0
  33. package/dist/__legacy__/models/session-management-helper.d.ts +23 -0
  34. package/dist/__legacy__/models/sign-in.d.ts +21 -0
  35. package/dist/__legacy__/models/sign-out-error.d.ts +21 -0
  36. package/dist/__legacy__/models/storage.d.ts +38 -0
  37. package/dist/__legacy__/models/web-worker.d.ts +55 -0
  38. package/dist/__legacy__/stores/index.d.ts +20 -0
  39. package/dist/__legacy__/stores/local-store.d.ts +23 -0
  40. package/dist/__legacy__/stores/memory-store.d.ts +25 -0
  41. package/dist/__legacy__/stores/session-store.d.ts +23 -0
  42. package/dist/__legacy__/utils/crypto-utils.d.ts +31 -0
  43. package/dist/__legacy__/utils/index.d.ts +19 -0
  44. package/dist/__legacy__/utils/message-utils.d.ts +37 -0
  45. package/dist/__legacy__/utils/spa-utils.d.ts +107 -0
  46. package/dist/__legacy__/worker/index.d.ts +19 -0
  47. package/dist/__legacy__/worker/worker-core.d.ts +21 -0
  48. package/dist/__legacy__/worker/worker-receiver.d.ts +21 -0
  49. package/dist/cjs/index.js +5437 -0
  50. package/dist/cjs/index.js.map +7 -0
  51. package/dist/constants/StyleConstants.d.ts +28 -0
  52. package/dist/index.d.ts +37 -0
  53. package/dist/index.js +5459 -0
  54. package/dist/index.js.map +7 -0
  55. package/dist/models/config.d.ts +19 -0
  56. package/dist/utils/hasAuthParamsInUrl.d.ts +25 -0
  57. package/dist/utils/withVendorCSSClassPrefix.d.ts +32 -0
  58. package/dist/worker.d.ts +21 -0
  59. package/package.json +76 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { AsgardeoAuthClient, AuthClientConfig } from '@asgardeo/javascript';
19
+ import { AuthenticationHelper, SPAHelper } from '../helpers';
20
+ import { WebWorkerClientConfig, WebWorkerClientInterface } from '../models';
21
+ export declare const WebWorkerClient: (instanceID: number, config: AuthClientConfig<WebWorkerClientConfig>, webWorker: new () => Worker, getAuthHelper: (authClient: AsgardeoAuthClient<WebWorkerClientConfig>, spaHelper: SPAHelper<WebWorkerClientConfig>) => AuthenticationHelper<WebWorkerClientConfig>) => Promise<WebWorkerClientInterface>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export declare const ACCESS_TOKEN_INVALID = "Access token is invalid";
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export declare enum Hooks {
19
+ SignIn = "sign-in",
20
+ SignOut = "sign-out",
21
+ Initialize = "initialize",
22
+ HttpRequestStart = "http-request-start",
23
+ HttpRequestFinish = "http-request-finish",
24
+ HttpRequestError = "http-request-error",
25
+ HttpRequestSuccess = "http-request-success",
26
+ RevokeAccessToken = "revoke-access-token",
27
+ CustomGrant = "custom-grant",
28
+ SignOutFailed = "sign-out-failed"
29
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export * from "./messages-types";
19
+ export * from "./storage";
20
+ export * from "./hooks";
21
+ export * from "./session-management";
22
+ export * from "./parameters";
23
+ export * from "./errors";
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export declare const INIT = "init";
19
+ export declare const SIGN_IN = "sign-in";
20
+ export declare const AUTH_CODE = "auth-code";
21
+ export declare const SIGN_OUT = "sign-out";
22
+ export declare const HTTP_REQUEST = "http-request";
23
+ export declare const HTTP_REQUEST_ALL = "http-request-all";
24
+ export declare const REQUEST_CUSTOM_GRANT = "request-custom-grant";
25
+ export declare const REVOKE_ACCESS_TOKEN = "revoke-access-token";
26
+ export declare const END_USER_SESSION = "end-user-session";
27
+ export declare const REQUEST_START = "request-start";
28
+ export declare const REQUEST_SUCCESS = "request-success";
29
+ export declare const REQUEST_ERROR = "request-error";
30
+ export declare const REQUEST_FINISH = "request-finish";
31
+ export declare const GET_OIDC_SERVICE_ENDPOINTS = "get-oidc-service-endpoints";
32
+ export declare const GET_BASIC_USER_INFO = "get-basic-user-info";
33
+ export declare const GET_DECODED_ID_TOKEN = "get-decoded-id-token";
34
+ export declare const GET_DECODED_IDP_ID_TOKEN = "get-decoded-idp-id-token";
35
+ export declare const GET_CRYPTO_HELPER = "get-crypto-helper";
36
+ export declare const ENABLE_HTTP_HANDLER = "enable_http_handler";
37
+ export declare const DISABLE_HTTP_HANDLER = "disable_http_handler";
38
+ export declare const GET_AUTH_URL = "get_auth_url";
39
+ export declare const REQUEST_ACCESS_TOKEN = "request_get_token";
40
+ export declare const IS_AUTHENTICATED = "is_authenticated";
41
+ export declare const GET_SIGN_OUT_URL = "get_sign_out_url";
42
+ export declare const REFRESH_ACCESS_TOKEN = "refresh_access-token";
43
+ export declare const REFRESH_ACCESS_TOKEN_ERR0R = "refresh-access-token-error";
44
+ export declare const SET_SESSION_STATE = "set_session_state";
45
+ export declare const START_AUTO_REFRESH_TOKEN = "start_auto_refresh_token";
46
+ export declare const UPDATE_CONFIG = "update_config";
47
+ export declare const GET_ID_TOKEN = "get_id_token";
48
+ export declare const CHECK_SESSION_SIGNED_IN = "check_session_signed_in";
49
+ export declare const CHECK_SESSION_SIGNED_OUT = "check_session_signed_out";
50
+ export declare const GET_CONFIG_DATA = "get_config_data";
51
+ export declare const SET_SESSION_STATE_FROM_IFRAME = "set_session_state_from_iframe";
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export declare const ERROR = "error";
19
+ export declare const ERROR_DESCRIPTION = "error_description";
20
+ export declare const CUSTOM_GRANT_CONFIG = "custom_grant_config";
21
+ export declare const STATE_QUERY = "state";
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export declare const OP_IFRAME = "opIFrame";
19
+ export declare const RP_IFRAME = "rpIFrame";
20
+ export declare const PROMPT_NONE_IFRAME = "promptNoneIFrame";
21
+ export declare const STATE = "Y2hlY2tTZXNzaW9u";
22
+ export declare const SILENT_SIGN_IN_STATE = "sign-in-silently";
23
+ export declare const INITIALIZED_SIGN_IN = "initialized-sign-in";
24
+ export declare const INITIALIZED_SILENT_SIGN_IN = "initialized-silent-sign-in";
25
+ export declare const PROMPT_NONE_REQUEST_SENT = "promptNoneRequestSent";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export declare const TOKEN_REQUEST_CONFIG_KEY = "token_request_config";
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Copyright (c) 2022-2024, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { AsgardeoAuthClient, AuthClientConfig, BasicUserInfo, IsomorphicCrypto, CustomGrantConfig, DataLayer, IdTokenPayload, FetchResponse, GetAuthURLConfig, OIDCEndpoints } from '@asgardeo/javascript';
19
+ import { SPAHelper } from './spa-helper';
20
+ import { HttpClientInstance, HttpError, HttpRequestConfig, HttpRequestInterface, HttpResponse, MainThreadClientConfig, SessionManagementHelperInterface, WebWorkerClientConfig } from '../models';
21
+ import { SPACustomGrantConfig } from '../models/request-custom-grant';
22
+ export declare class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerClientConfig> {
23
+ protected _authenticationClient: AsgardeoAuthClient<T>;
24
+ protected _dataLayer: DataLayer<T>;
25
+ protected _spaHelper: SPAHelper<T>;
26
+ protected _instanceID: number;
27
+ protected _isTokenRefreshing: boolean;
28
+ constructor(authClient: AsgardeoAuthClient<T>, spaHelper: SPAHelper<T>);
29
+ enableHttpHandler(httpClient: HttpClientInstance): void;
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>;
35
+ protected retryFailedRequests(failedRequest: HttpRequestInterface): Promise<HttpResponse>;
36
+ httpRequest(httpClient: HttpClientInstance, requestConfig: HttpRequestConfig, isHttpHandlerEnabled?: boolean, httpErrorCallback?: (error: HttpError) => void | Promise<void>, httpFinishCallback?: () => void, enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void): Promise<HttpResponse>;
37
+ httpRequestAll(requestConfigs: HttpRequestConfig[], httpClient: HttpClientInstance, isHttpHandlerEnabled?: boolean, httpErrorCallback?: (error: HttpError) => void | Promise<void>, httpFinishCallback?: () => void): Promise<HttpResponse[] | undefined>;
38
+ requestAccessToken(authorizationCode?: string, sessionState?: string, checkSession?: () => Promise<void>, pkce?: string, state?: string, tokenRequestConfig?: {
39
+ params: Record<string, unknown>;
40
+ }): Promise<BasicUserInfo>;
41
+ trySignInSilently(constructSilentSignInUrl: (additionalParams?: Record<string, string | boolean>) => Promise<string>, requestAccessToken: (authzCode: string, sessionState: string, state: string, tokenRequestConfig?: {
42
+ params: Record<string, unknown>;
43
+ }) => Promise<BasicUserInfo>, sessionManagementHelper: SessionManagementHelperInterface, additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
44
+ params: Record<string, unknown>;
45
+ }): Promise<BasicUserInfo | boolean>;
46
+ handleSignIn(shouldStopAuthn: () => Promise<boolean>, checkSession: () => Promise<void>, tryRetrievingUserInfo?: () => Promise<BasicUserInfo | undefined>): Promise<BasicUserInfo | undefined>;
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>;
54
+ getAccessToken(): Promise<string>;
55
+ getIDPAccessToken(): Promise<string>;
56
+ getDataLayer(): DataLayer<T>;
57
+ isAuthenticated(): Promise<boolean>;
58
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export * from "./authentication-helper";
19
+ export * from "./spa-helper";
20
+ export * from "./session-management-helper";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
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>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { AsgardeoAuthClient } from '@asgardeo/javascript';
19
+ import { AuthenticationHelper } from '../helpers/authentication-helper';
20
+ import { MainThreadClientConfig, WebWorkerClientConfig } from '../models/client-config';
21
+ export declare class SPAHelper<T extends MainThreadClientConfig | WebWorkerClientConfig> {
22
+ private _authenticationClient;
23
+ private _dataLayer;
24
+ constructor(authClient: AsgardeoAuthClient<T>);
25
+ refreshAccessTokenAutomatically(authenticationHelper: AuthenticationHelper<MainThreadClientConfig | WebWorkerClientConfig>): Promise<void>;
26
+ getRefreshTimeoutTimer(): Promise<number>;
27
+ clearRefreshTokenTimeout(timer?: number): Promise<void>;
28
+ }
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ */
19
+ import { HttpError, HttpRequestConfig, HttpResponse } from '../../..';
20
+ import { HttpClientInstance, HttpClientInterface } from '../models';
21
+ /**
22
+ * An Http Http client to perform Http requests.
23
+ *
24
+ * @remarks
25
+ * Typescript doesn't support static functions in interfaces. Therefore,
26
+ * a decorator i.e `staticDecorator` was written to add static support.
27
+ * Follow {@link https://github.com/Microsoft/TypeScript/issues/13462}
28
+ * for more info.
29
+ *
30
+ * @example
31
+ * Example usage.
32
+ * ```
33
+ *
34
+ * const httpClient = HttpClient.getInstance();
35
+ * httpClient.init(true, onRequestStart, onRequestSuccess, onRequestError, onRequestFinish);
36
+ * ```
37
+ */
38
+ export declare class HttpClient implements HttpClientInterface<HttpRequestConfig, HttpResponse, HttpError> {
39
+ private static axiosInstance;
40
+ private static clientInstance;
41
+ private static isHandlerEnabled;
42
+ private attachToken;
43
+ private requestStartCallback;
44
+ private requestSuccessCallback;
45
+ private requestErrorCallback;
46
+ private requestFinishCallback;
47
+ private static readonly DEFAULT_HANDLER_DISABLE_TIMEOUT;
48
+ /**
49
+ * Private constructor to avoid object instantiation from outside
50
+ * the class.
51
+ *
52
+ * @hideconstructor
53
+ */
54
+ private constructor();
55
+ /**
56
+ * Returns an aggregated instance of type `HttpInstance` of `HttpClient`.
57
+ *
58
+ * @return {any}
59
+ */
60
+ static getInstance(): HttpClientInstance;
61
+ /**
62
+ * Intercepts all the requests.
63
+ * If the `isHandlerEnabled` flag is set to true, fires the `requestStartCallback`
64
+ * and retrieves the access token from the server and attaches it to the request.
65
+ * Else, just returns the original request.
66
+ *
67
+ * @param {HttpRequestConfig} request - Original request.
68
+ * @return {HttpRequestConfig}
69
+ */
70
+ requestHandler(request: HttpRequestConfig): Promise<HttpRequestConfig>;
71
+ /**
72
+ * Handles response errors.
73
+ * If the `isHandlerEnabled` flag is set to true, fires the `requestErrorCallback`
74
+ * and the `requestFinishCallback` functions. Else, just returns the original error.
75
+ *
76
+ * @param {HttpError} error - Original error.
77
+ * @return {HttpError}
78
+ */
79
+ errorHandler(error: HttpError): HttpError;
80
+ /**
81
+ * Handles response success.
82
+ * If the `isHandlerEnabled` flag is set to true, fires the `requestSuccessCallback`
83
+ * and the `requestFinishCallback` functions. Else, just returns the original response.
84
+ *
85
+ * @param {HttpResponse} response - Original response.
86
+ * @return {HttpResponse}
87
+ */
88
+ successHandler(response: HttpResponse): HttpResponse;
89
+ /**
90
+ * Initializes the Http client.
91
+ *
92
+ * @param isHandlerEnabled - Flag to toggle handler enablement.
93
+ * @param requestStartCallback - Callback function to be triggered on request start.
94
+ * @param requestSuccessCallback - Callback function to be triggered on request success.
95
+ * @param requestErrorCallback - Callback function to be triggered on request error.
96
+ * @param requestFinishCallback - Callback function to be triggered on request error.
97
+ */
98
+ init(isHandlerEnabled: boolean, attachToken: (request: HttpRequestConfig) => Promise<void>): Promise<void>;
99
+ /**
100
+ * Enables the handler.
101
+ */
102
+ enableHandler(): void;
103
+ /**
104
+ * Disables the handler.
105
+ */
106
+ disableHandler(): void;
107
+ /**
108
+ * Disables the handler for a given period of time.
109
+ *
110
+ * @param {number} timeout - Timeout in milliseconds.
111
+ */
112
+ disableHandlerWithTimeout(timeout?: number): void;
113
+ setHttpRequestStartCallback(callback: () => void): void;
114
+ setHttpRequestSuccessCallback(callback: (response: HttpResponse) => void): void;
115
+ setHttpRequestErrorCallback(callback: (error: HttpError) => void): void;
116
+ setHttpRequestFinishCallback(callback: () => void): void;
117
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ */
19
+ export * from "./axios-http-client";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ */
19
+ /**
20
+ * A decorator to supplement static interface support.
21
+ *
22
+ * @return {<U extends T>(constructor: U) => void}
23
+ */
24
+ export declare function staticDecorator<T>(): <U extends T>(_constructor: U) => any;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ */
19
+ export * from "./decorators";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ */
19
+ export * from "./clients";
20
+ export * from "./models";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ */
19
+ import { HttpError, HttpInstance, HttpRequestConfig, HttpResponse } from '../../..';
20
+ /**
21
+ * Http Http Client model
22
+ */
23
+ export interface HttpClientInstance extends HttpInstance {
24
+ init?(isHandlerEnabled: boolean, attachToken: (request: HttpRequestConfig) => Promise<void>): Promise<void>;
25
+ disableHandler?: () => void;
26
+ disableHandlerWithTimeout?: (timeout: number) => void;
27
+ enableHandler?: () => void;
28
+ all?<T>(values: (T | Promise<T>)[]): Promise<T[]>;
29
+ spread?<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
30
+ setHttpRequestStartCallback?: (callback: () => void) => void;
31
+ setHttpRequestSuccessCallback?: (callback: (response: HttpResponse) => void) => void;
32
+ setHttpRequestErrorCallback?: (callback: (error: HttpError) => void) => void;
33
+ setHttpRequestFinishCallback?: (callback: () => void) => void;
34
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ */
19
+ import { HttpError, HttpResponse } from "../../models";
20
+ /**
21
+ * Http client interface with static functions.
22
+ */
23
+ export interface HttpClientStatic<S> {
24
+ getInstance(): S;
25
+ }
26
+ /**
27
+ * Http client interface.
28
+ */
29
+ export interface HttpClientInterface<T, U, V> {
30
+ init(isHandlerEnabled: boolean, attachToken: () => Promise<void>): Promise<void>;
31
+ disableHandler: () => void;
32
+ disableHandlerWithTimeout: (timeout: number) => void;
33
+ enableHandler: () => void;
34
+ errorHandler(error: V): V;
35
+ requestHandler(request: T): Promise<T>;
36
+ successHandler(response: U): U;
37
+ setHttpRequestStartCallback?: (callback: () => void) => void;
38
+ setHttpRequestSuccessCallback?: (callback: (response: HttpResponse) => void) => void;
39
+ setHttpRequestErrorCallback?: (callback: (error: HttpError) => void) => void;
40
+ setHttpRequestFinishCallback?: (callback: () => void) => void;
41
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ */
19
+ export * from "./axios-http-client";
20
+ export * from "./http-client";