@asgardeo/auth-spa 1.0.0 → 1.0.2
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 +1 -1
- package/dist/asgardeo-spa.production.esm.js +10 -10
- package/dist/asgardeo-spa.production.esm.js.map +1 -1
- package/dist/asgardeo-spa.production.js +8 -8
- package/dist/asgardeo-spa.production.js.map +1 -1
- package/dist/asgardeo-spa.production.min.js +1 -1
- package/dist/asgardeo-spa.production.min.js.map +1 -1
- package/dist/polyfilled/asgardeo-spa.production.esm.js +4 -4
- package/dist/polyfilled/asgardeo-spa.production.esm.js.map +1 -1
- package/dist/polyfilled/asgardeo-spa.production.js +8 -8
- package/dist/polyfilled/asgardeo-spa.production.js.map +1 -1
- package/dist/polyfilled/asgardeo-spa.production.min.js +1 -1
- package/dist/polyfilled/asgardeo-spa.production.min.js.map +1 -1
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +7 -1
- package/dist/src/client.js.map +1 -1
- package/dist/src/clients/main-thread-client.d.ts.map +1 -1
- package/dist/src/clients/main-thread-client.js +4 -0
- package/dist/src/clients/main-thread-client.js.map +1 -1
- package/dist/src/constants/messages-types.d.ts +1 -0
- package/dist/src/constants/messages-types.d.ts.map +1 -1
- package/dist/src/constants/messages-types.js +1 -0
- package/dist/src/constants/messages-types.js.map +1 -1
- package/dist/src/helpers/authentication-helper.d.ts.map +1 -1
- package/dist/src/helpers/authentication-helper.js +5 -1
- package/dist/src/helpers/authentication-helper.js.map +1 -1
- package/dist/src/models/message.d.ts +2 -2
- package/dist/src/models/message.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/client.ts +7 -1
- package/src/clients/main-thread-client.ts +5 -0
- package/src/constants/messages-types.ts +1 -0
- package/src/helpers/authentication-helper.ts +6 -0
- package/src/models/message.ts +2 -0
package/src/client.ts
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from "@asgardeo/auth-js";
|
|
31
31
|
import WorkerFile from "web-worker:./worker.ts";
|
|
32
32
|
import { MainThreadClient, WebWorkerClient } from "./clients";
|
|
33
|
-
import { Hooks, Storage } from "./constants";
|
|
33
|
+
import { Hooks, REFRESH_ACCESS_TOKEN_ERR0R, Storage } from "./constants";
|
|
34
34
|
import { AuthenticationHelper, SPAHelper } from "./helpers";
|
|
35
35
|
import { HttpClientInstance } from "./http-client";
|
|
36
36
|
import {
|
|
@@ -259,6 +259,12 @@ export class AsgardeoSPAClient {
|
|
|
259
259
|
this._onInitialize(true);
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
window.addEventListener("message", (event) => {
|
|
263
|
+
if (event?.data?.type === REFRESH_ACCESS_TOKEN_ERR0R) {
|
|
264
|
+
this.signOut();
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
262
268
|
return Promise.resolve(true);
|
|
263
269
|
} else {
|
|
264
270
|
if (!this._client) {
|
|
@@ -180,6 +180,10 @@ export const MainThreadClient = async (
|
|
|
180
180
|
);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
const setSessionStatus = async (sessionStatus: string): Promise<void> => {
|
|
184
|
+
await _dataLayer.setSessionStatus(sessionStatus);
|
|
185
|
+
}
|
|
186
|
+
|
|
183
187
|
const signIn = async (
|
|
184
188
|
signInConfig?: GetAuthURLConfig,
|
|
185
189
|
authorizationCode?: string,
|
|
@@ -212,6 +216,7 @@ export const MainThreadClient = async (
|
|
|
212
216
|
}
|
|
213
217
|
|
|
214
218
|
if (resolvedAuthorizationCode && resolvedState) {
|
|
219
|
+
setSessionStatus("true");
|
|
215
220
|
return requestAccessToken(resolvedAuthorizationCode, resolvedSessionState, resolvedState);
|
|
216
221
|
}
|
|
217
222
|
|
|
@@ -41,6 +41,7 @@ export const REQUEST_ACCESS_TOKEN = "request_get_token";
|
|
|
41
41
|
export const IS_AUTHENTICATED = "is_authenticated";
|
|
42
42
|
export const GET_SIGN_OUT_URL = "get_sign_out_url";
|
|
43
43
|
export const REFRESH_ACCESS_TOKEN = "refresh_access-token";
|
|
44
|
+
export const REFRESH_ACCESS_TOKEN_ERR0R = "refresh-access-token-error";
|
|
44
45
|
export const SET_SESSION_STATE = "set_session_state";
|
|
45
46
|
export const START_AUTO_REFRESH_TOKEN = "start_auto_refresh_token";
|
|
46
47
|
export const UPDATE_CONFIG = "update_config";
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
ERROR,
|
|
42
42
|
ERROR_DESCRIPTION,
|
|
43
43
|
PROMPT_NONE_IFRAME,
|
|
44
|
+
REFRESH_ACCESS_TOKEN_ERR0R,
|
|
44
45
|
RP_IFRAME,
|
|
45
46
|
Storage
|
|
46
47
|
} from "../constants";
|
|
@@ -187,6 +188,11 @@ export class AuthenticationHelper<
|
|
|
187
188
|
|
|
188
189
|
return this._authenticationClient.getBasicUserInfo();
|
|
189
190
|
} catch (error) {
|
|
191
|
+
const refreshTokenError: Message<string> = {
|
|
192
|
+
type: REFRESH_ACCESS_TOKEN_ERR0R
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
window.postMessage(refreshTokenError);
|
|
190
196
|
return Promise.reject(error);
|
|
191
197
|
}
|
|
192
198
|
}
|
package/src/models/message.ts
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
INIT,
|
|
38
38
|
IS_AUTHENTICATED,
|
|
39
39
|
REFRESH_ACCESS_TOKEN,
|
|
40
|
+
REFRESH_ACCESS_TOKEN_ERR0R,
|
|
40
41
|
REQUEST_ACCESS_TOKEN,
|
|
41
42
|
REQUEST_CUSTOM_GRANT,
|
|
42
43
|
REQUEST_ERROR,
|
|
@@ -97,6 +98,7 @@ export type MessageType =
|
|
|
97
98
|
| typeof IS_AUTHENTICATED
|
|
98
99
|
| typeof GET_SIGN_OUT_URL
|
|
99
100
|
| typeof REFRESH_ACCESS_TOKEN
|
|
101
|
+
| typeof REFRESH_ACCESS_TOKEN_ERR0R
|
|
100
102
|
| typeof SET_SESSION_STATE
|
|
101
103
|
| typeof START_AUTO_REFRESH_TOKEN
|
|
102
104
|
| typeof UPDATE_CONFIG
|