@asgardeo/auth-spa 0.3.8 → 0.3.9

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 (68) hide show
  1. package/dist/asgardeo-spa.production.esm.js +13 -13
  2. package/dist/asgardeo-spa.production.esm.js.map +1 -1
  3. package/dist/asgardeo-spa.production.js +13 -13
  4. package/dist/asgardeo-spa.production.js.map +1 -1
  5. package/dist/asgardeo-spa.production.min.js +1 -1
  6. package/dist/asgardeo-spa.production.min.js.map +1 -1
  7. package/dist/polyfilled/asgardeo-spa.production.esm.js +42 -40
  8. package/dist/polyfilled/asgardeo-spa.production.esm.js.map +1 -1
  9. package/dist/polyfilled/asgardeo-spa.production.js +42 -40
  10. package/dist/polyfilled/asgardeo-spa.production.js.map +1 -1
  11. package/dist/polyfilled/asgardeo-spa.production.min.js +1 -1
  12. package/dist/polyfilled/asgardeo-spa.production.min.js.map +1 -1
  13. package/dist/src/client.d.ts +21 -16
  14. package/dist/src/client.d.ts.map +1 -1
  15. package/dist/src/client.js +29 -3
  16. package/dist/src/client.js.map +1 -1
  17. package/dist/src/clients/main-thread-client.d.ts +3 -2
  18. package/dist/src/clients/main-thread-client.d.ts.map +1 -1
  19. package/dist/src/clients/main-thread-client.js +83 -385
  20. package/dist/src/clients/main-thread-client.js.map +1 -1
  21. package/dist/src/clients/web-worker-client.d.ts +3 -2
  22. package/dist/src/clients/web-worker-client.d.ts.map +1 -1
  23. package/dist/src/clients/web-worker-client.js +98 -138
  24. package/dist/src/clients/web-worker-client.js.map +1 -1
  25. package/dist/src/helpers/authentication-helper.d.ts +50 -0
  26. package/dist/src/helpers/authentication-helper.d.ts.map +1 -0
  27. package/dist/src/helpers/authentication-helper.js +482 -0
  28. package/dist/src/helpers/authentication-helper.js.map +1 -0
  29. package/dist/src/helpers/index.d.ts +1 -0
  30. package/dist/src/helpers/index.d.ts.map +1 -1
  31. package/dist/src/helpers/index.js +1 -0
  32. package/dist/src/helpers/index.js.map +1 -1
  33. package/dist/src/public-api.d.ts +3 -0
  34. package/dist/src/public-api.d.ts.map +1 -1
  35. package/dist/src/public-api.js +5 -0
  36. package/dist/src/public-api.js.map +1 -1
  37. package/dist/src/worker/index.d.ts +1 -1
  38. package/dist/src/worker/index.d.ts.map +1 -1
  39. package/dist/src/worker/index.js +1 -1
  40. package/dist/src/worker/index.js.map +1 -1
  41. package/dist/src/worker/worker-core.d.ts +3 -2
  42. package/dist/src/worker/worker-core.d.ts.map +1 -1
  43. package/dist/src/worker/worker-core.js +23 -202
  44. package/dist/src/worker/worker-core.js.map +1 -1
  45. package/dist/src/worker/worker-receiver.d.ts +22 -0
  46. package/dist/src/worker/worker-receiver.d.ts.map +1 -0
  47. package/dist/src/worker/worker-receiver.js +233 -0
  48. package/dist/src/worker/worker-receiver.js.map +1 -0
  49. package/dist/src/{worker/client.worker.d.ts → worker.d.ts} +2 -2
  50. package/dist/src/worker.d.ts.map +1 -0
  51. package/dist/src/worker.js +24 -0
  52. package/dist/src/worker.js.map +1 -0
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +1 -1
  55. package/src/client.ts +65 -19
  56. package/src/clients/main-thread-client.ts +137 -486
  57. package/src/clients/web-worker-client.ts +128 -169
  58. package/src/helpers/authentication-helper.ts +661 -0
  59. package/src/helpers/index.ts +1 -0
  60. package/src/public-api.ts +7 -0
  61. package/src/worker/index.ts +1 -1
  62. package/src/worker/worker-core.ts +48 -261
  63. package/src/worker/worker-receiver.ts +297 -0
  64. package/src/worker.ts +30 -0
  65. package/dist/src/worker/client.worker.d.ts.map +0 -1
  66. package/dist/src/worker/client.worker.js +0 -232
  67. package/dist/src/worker/client.worker.js.map +0 -1
  68. package/src/worker/client.worker.ts +0 -286
@@ -0,0 +1,482 @@
1
+ /**
2
+ * Copyright (c) 2022, 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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
19
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
20
+ return new (P || (P = Promise))(function (resolve, reject) {
21
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
25
+ });
26
+ };
27
+ import { AsgardeoAuthException, AuthenticationUtils } from "@asgardeo/auth-js";
28
+ import { SPAUtils } from "..";
29
+ import { ACCESS_TOKEN_INVALID, CHECK_SESSION_SIGNED_IN, CHECK_SESSION_SIGNED_OUT, CUSTOM_GRANT_CONFIG, ERROR, ERROR_DESCRIPTION, PROMPT_NONE_IFRAME, RP_IFRAME, Storage } from "../constants";
30
+ export class AuthenticationHelper {
31
+ constructor(authClient, spaHelper) {
32
+ this._authenticationClient = authClient;
33
+ this._dataLayer = this._authenticationClient.getDataLayer();
34
+ this._spaHelper = spaHelper;
35
+ }
36
+ attachToken(request) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const requestConfig = Object.assign({ attachToken: true }, request);
39
+ if (requestConfig.attachToken) {
40
+ request.headers = Object.assign(Object.assign({}, request.headers), { Authorization: `Bearer ${yield this._authenticationClient.getAccessToken()}` });
41
+ }
42
+ });
43
+ }
44
+ setHttpRequestStartCallback(_httpClient, callback) {
45
+ (_httpClient === null || _httpClient === void 0 ? void 0 : _httpClient.setHttpRequestStartCallback) &&
46
+ _httpClient.setHttpRequestStartCallback(callback);
47
+ }
48
+ setHttpRequestSuccessCallback(_httpClient, callback) {
49
+ (_httpClient === null || _httpClient === void 0 ? void 0 : _httpClient.setHttpRequestSuccessCallback) &&
50
+ _httpClient.setHttpRequestSuccessCallback(callback);
51
+ }
52
+ setHttpRequestFinishCallback(_httpClient, callback) {
53
+ (_httpClient === null || _httpClient === void 0 ? void 0 : _httpClient.setHttpRequestFinishCallback) &&
54
+ _httpClient.setHttpRequestFinishCallback(callback);
55
+ }
56
+ enableHttpHandler(httpClient) {
57
+ (httpClient === null || httpClient === void 0 ? void 0 : httpClient.enableHandler) && httpClient.enableHandler();
58
+ }
59
+ disableHttpHandler(httpClient) {
60
+ (httpClient === null || httpClient === void 0 ? void 0 : httpClient.disableHandler) && httpClient.disableHandler();
61
+ }
62
+ initializeSessionManger(config, oidcEndpoints, getSessionState, getAuthzURL, sessionManagementHelper) {
63
+ var _a, _b, _c;
64
+ sessionManagementHelper.initialize(config.clientID, (_a = oidcEndpoints.checkSessionIframe) !== null && _a !== void 0 ? _a : "", getSessionState, (_b = config.checkSessionInterval) !== null && _b !== void 0 ? _b : 3, (_c = config.sessionRefreshInterval) !== null && _c !== void 0 ? _c : 300, config.signInRedirectURL, getAuthzURL);
65
+ }
66
+ requestCustomGrant(config, enableRetrievingSignOutURLFromSession) {
67
+ var _a, _b, _c;
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ let useDefaultEndpoint = true;
70
+ let matches = false;
71
+ // If the config does not contains a token endpoint, default token endpoint will be used.
72
+ if (config === null || config === void 0 ? void 0 : config.tokenEndpoint) {
73
+ useDefaultEndpoint = false;
74
+ for (const baseUrl of [
75
+ ...((_b = (_a = (yield this._dataLayer.getConfigData())) === null || _a === void 0 ? void 0 : _a.resourceServerURLs) !== null && _b !== void 0 ? _b : []),
76
+ config.baseUrl
77
+ ]) {
78
+ if (baseUrl && ((_c = config.tokenEndpoint) === null || _c === void 0 ? void 0 : _c.startsWith(baseUrl))) {
79
+ matches = true;
80
+ break;
81
+ }
82
+ }
83
+ }
84
+ if (config.shouldReplayAfterRefresh) {
85
+ this._dataLayer.setTemporaryDataParameter(CUSTOM_GRANT_CONFIG, JSON.stringify(config));
86
+ }
87
+ if (useDefaultEndpoint || matches) {
88
+ return this._authenticationClient
89
+ .requestCustomGrant(config)
90
+ .then((response) => __awaiter(this, void 0, void 0, function* () {
91
+ if (enableRetrievingSignOutURLFromSession &&
92
+ typeof enableRetrievingSignOutURLFromSession === "function") {
93
+ enableRetrievingSignOutURLFromSession(config);
94
+ }
95
+ if (config.returnsSession) {
96
+ this._spaHelper.refreshAccessTokenAutomatically();
97
+ return this._authenticationClient.getBasicUserInfo();
98
+ }
99
+ else {
100
+ return response;
101
+ }
102
+ }))
103
+ .catch((error) => {
104
+ return Promise.reject(error);
105
+ });
106
+ }
107
+ else {
108
+ return Promise.reject(new AsgardeoAuthException("SPA-MAIN_THREAD_CLIENT-RCG-IV01", "Request to the provided endpoint is prohibited.", "Requests can only be sent to resource servers specified by the `resourceServerURLs`" +
109
+ " attribute while initializing the SDK. The specified token endpoint in this request " +
110
+ "cannot be found among the `resourceServerURLs`"));
111
+ }
112
+ });
113
+ }
114
+ getCustomGrantConfigData() {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ const configString = yield this._dataLayer.getTemporaryDataParameter(CUSTOM_GRANT_CONFIG);
117
+ if (configString) {
118
+ return JSON.parse(configString);
119
+ }
120
+ else {
121
+ return null;
122
+ }
123
+ });
124
+ }
125
+ refreshAccessToken(enableRetrievingSignOutURLFromSession) {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ try {
128
+ yield this._authenticationClient.refreshAccessToken();
129
+ const customGrantConfig = yield this.getCustomGrantConfigData();
130
+ if (customGrantConfig) {
131
+ yield this.requestCustomGrant(customGrantConfig, enableRetrievingSignOutURLFromSession);
132
+ }
133
+ this._spaHelper.refreshAccessTokenAutomatically();
134
+ return this._authenticationClient.getBasicUserInfo();
135
+ }
136
+ catch (error) {
137
+ return Promise.reject(error);
138
+ }
139
+ });
140
+ }
141
+ httpRequest(httpClient, requestConfig, isHttpHandlerEnabled, httpErrorCallback, httpFinishCallback, enableRetrievingSignOutURLFromSession) {
142
+ var _a, _b;
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ let matches = false;
145
+ const config = yield this._dataLayer.getConfigData();
146
+ for (const baseUrl of [
147
+ ...((_a = (yield (config === null || config === void 0 ? void 0 : config.resourceServerURLs))) !== null && _a !== void 0 ? _a : []),
148
+ config.baseUrl
149
+ ]) {
150
+ if (baseUrl && ((_b = requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.url) === null || _b === void 0 ? void 0 : _b.startsWith(baseUrl))) {
151
+ matches = true;
152
+ break;
153
+ }
154
+ }
155
+ if (matches) {
156
+ return httpClient
157
+ .request(requestConfig)
158
+ .then((response) => {
159
+ return Promise.resolve(response);
160
+ })
161
+ .catch((error) => __awaiter(this, void 0, void 0, function* () {
162
+ var _c, _d, _e;
163
+ if (((_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.status) === 401 || !(error === null || error === void 0 ? void 0 : error.response)) {
164
+ // Try to refresh the token
165
+ let refreshAccessTokenResponse;
166
+ try {
167
+ refreshAccessTokenResponse = yield this.refreshAccessToken(enableRetrievingSignOutURLFromSession);
168
+ }
169
+ catch (refreshError) {
170
+ if (isHttpHandlerEnabled) {
171
+ if (typeof httpErrorCallback === "function") {
172
+ yield httpErrorCallback(Object.assign(Object.assign({}, error), { code: ACCESS_TOKEN_INVALID }));
173
+ }
174
+ if (typeof httpFinishCallback === "function") {
175
+ httpFinishCallback();
176
+ }
177
+ }
178
+ throw new AsgardeoAuthException("SPA-AUTH_HELPER-HR-SE01", (_d = refreshError === null || refreshError === void 0 ? void 0 : refreshError.name) !== null && _d !== void 0 ? _d : "Refresh token request failed.", (_e = refreshError === null || refreshError === void 0 ? void 0 : refreshError.message) !== null && _e !== void 0 ? _e : "An error occurred while trying to refresh the " +
179
+ "access token following a 401 response from the server.");
180
+ }
181
+ // Retry the request after refreshing the token
182
+ if (refreshAccessTokenResponse) {
183
+ try {
184
+ const httpResponse = yield httpClient.request(requestConfig);
185
+ return Promise.resolve(httpResponse);
186
+ }
187
+ catch (error) {
188
+ if (isHttpHandlerEnabled) {
189
+ if (typeof httpErrorCallback === "function") {
190
+ yield httpErrorCallback(error);
191
+ }
192
+ if (typeof httpFinishCallback === "function") {
193
+ httpFinishCallback();
194
+ }
195
+ }
196
+ return Promise.reject(error);
197
+ }
198
+ }
199
+ }
200
+ if (isHttpHandlerEnabled) {
201
+ if (typeof httpErrorCallback === "function") {
202
+ yield httpErrorCallback(error);
203
+ }
204
+ if (typeof httpFinishCallback === "function") {
205
+ httpFinishCallback();
206
+ }
207
+ }
208
+ return Promise.reject(error);
209
+ }));
210
+ }
211
+ else {
212
+ return Promise.reject(new AsgardeoAuthException("SPA-AUTH_HELPER-HR-IV02", "Request to the provided endpoint is prohibited.", "Requests can only be sent to resource servers specified by the `resourceServerURLs`" +
213
+ " attribute while initializing the SDK. The specified endpoint in this request " +
214
+ "cannot be found among the `resourceServerURLs`"));
215
+ }
216
+ });
217
+ }
218
+ httpRequestAll(requestConfigs, httpClient, isHttpHandlerEnabled, httpErrorCallback, httpFinishCallback) {
219
+ var _a, _b, _c;
220
+ return __awaiter(this, void 0, void 0, function* () {
221
+ let matches = true;
222
+ const config = yield this._dataLayer.getConfigData();
223
+ for (const requestConfig of requestConfigs) {
224
+ let urlMatches = false;
225
+ for (const baseUrl of [
226
+ ...((_b = (_a = (yield config)) === null || _a === void 0 ? void 0 : _a.resourceServerURLs) !== null && _b !== void 0 ? _b : []),
227
+ config.baseUrl
228
+ ]) {
229
+ if (baseUrl && ((_c = requestConfig.url) === null || _c === void 0 ? void 0 : _c.startsWith(baseUrl))) {
230
+ urlMatches = true;
231
+ break;
232
+ }
233
+ }
234
+ if (!urlMatches) {
235
+ matches = false;
236
+ break;
237
+ }
238
+ }
239
+ const requests = [];
240
+ if (matches) {
241
+ requestConfigs.forEach((request) => {
242
+ requests.push(httpClient.request(request));
243
+ });
244
+ return ((httpClient === null || httpClient === void 0 ? void 0 : httpClient.all) &&
245
+ httpClient
246
+ .all(requests)
247
+ .then((responses) => {
248
+ return Promise.resolve(responses);
249
+ })
250
+ .catch((error) => __awaiter(this, void 0, void 0, function* () {
251
+ var _d, _e, _f;
252
+ if (((_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.status) === 401 || !(error === null || error === void 0 ? void 0 : error.response)) {
253
+ let refreshTokenResponse;
254
+ try {
255
+ refreshTokenResponse = yield this._authenticationClient.refreshAccessToken();
256
+ }
257
+ catch (refreshError) {
258
+ if (isHttpHandlerEnabled) {
259
+ if (typeof httpErrorCallback === "function") {
260
+ yield httpErrorCallback(Object.assign(Object.assign({}, error), { code: ACCESS_TOKEN_INVALID }));
261
+ }
262
+ if (typeof httpFinishCallback === "function") {
263
+ httpFinishCallback();
264
+ }
265
+ }
266
+ throw new AsgardeoAuthException("SPA-AUTH_HELPER-HRA-SE01", (_e = refreshError === null || refreshError === void 0 ? void 0 : refreshError.name) !== null && _e !== void 0 ? _e : "Refresh token request failed.", (_f = refreshError === null || refreshError === void 0 ? void 0 : refreshError.message) !== null && _f !== void 0 ? _f : "An error occurred while trying to refresh the " +
267
+ "access token following a 401 response from the server.");
268
+ }
269
+ if (refreshTokenResponse) {
270
+ return (httpClient.all &&
271
+ httpClient
272
+ .all(requests)
273
+ .then((response) => {
274
+ return Promise.resolve(response);
275
+ })
276
+ .catch((error) => __awaiter(this, void 0, void 0, function* () {
277
+ if (isHttpHandlerEnabled) {
278
+ if (typeof httpErrorCallback === "function") {
279
+ yield httpErrorCallback(error);
280
+ }
281
+ if (typeof httpFinishCallback === "function") {
282
+ httpFinishCallback();
283
+ }
284
+ }
285
+ return Promise.reject(error);
286
+ })));
287
+ }
288
+ }
289
+ if (isHttpHandlerEnabled) {
290
+ if (typeof httpErrorCallback === "function") {
291
+ yield httpErrorCallback(error);
292
+ }
293
+ if (typeof httpFinishCallback === "function") {
294
+ httpFinishCallback();
295
+ }
296
+ }
297
+ return Promise.reject(error);
298
+ })));
299
+ }
300
+ else {
301
+ throw new AsgardeoAuthException("SPA-AUTH_HELPER-HRA-IV02", "Request to the provided endpoint is prohibited.", "Requests can only be sent to resource servers specified by the `resourceServerURLs`" +
302
+ " attribute while initializing the SDK. The specified endpoint in this request " +
303
+ "cannot be found among the `resourceServerURLs`");
304
+ }
305
+ });
306
+ }
307
+ requestAccessToken(authorizationCode, sessionState, checkSession, pkce, state) {
308
+ return __awaiter(this, void 0, void 0, function* () {
309
+ const config = yield this._dataLayer.getConfigData();
310
+ if (config.storage === Storage.BrowserMemory && config.enablePKCE && sessionState) {
311
+ const pkce = SPAUtils.getPKCE(AuthenticationUtils.extractPKCEKeyFromStateParam(sessionState));
312
+ yield this._authenticationClient.setPKCECode(AuthenticationUtils.extractPKCEKeyFromStateParam(sessionState), pkce);
313
+ }
314
+ else if (config.storage === Storage.WebWorker && pkce) {
315
+ yield this._authenticationClient.setPKCECode(pkce, state !== null && state !== void 0 ? state : "");
316
+ }
317
+ if (authorizationCode) {
318
+ return this._authenticationClient
319
+ .requestAccessToken(authorizationCode, sessionState !== null && sessionState !== void 0 ? sessionState : "", state !== null && state !== void 0 ? state : "")
320
+ .then(() => __awaiter(this, void 0, void 0, function* () {
321
+ // Disable this temporarily
322
+ /* if (config.storage === Storage.BrowserMemory) {
323
+ SPAUtils.setSignOutURL(await _authenticationClient.getSignOutURL());
324
+ } */
325
+ if (config.storage !== Storage.WebWorker) {
326
+ SPAUtils.setSignOutURL(yield this._authenticationClient.getSignOutURL());
327
+ if (this._spaHelper) {
328
+ this._spaHelper.clearRefreshTokenTimeout();
329
+ this._spaHelper.refreshAccessTokenAutomatically();
330
+ }
331
+ // Enable OIDC Sessions Management only if it is set to true in the config.
332
+ if (checkSession &&
333
+ typeof checkSession === "function" &&
334
+ config.enableOIDCSessionManagement) {
335
+ checkSession();
336
+ }
337
+ }
338
+ else {
339
+ if (this._spaHelper) {
340
+ this._spaHelper.refreshAccessTokenAutomatically();
341
+ }
342
+ }
343
+ return this._authenticationClient.getBasicUserInfo();
344
+ }))
345
+ .catch((error) => {
346
+ return Promise.reject(error);
347
+ });
348
+ }
349
+ return Promise.reject(new AsgardeoAuthException("SPA-AUTH_HELPER-RAT1-NF01", "No authorization code.", "No authorization code was found."));
350
+ });
351
+ }
352
+ trySignInSilently(constructSilentSignInUrl, requestAccessToken, sessionManagementHelper) {
353
+ var _a;
354
+ return __awaiter(this, void 0, void 0, function* () {
355
+ // This block is executed by the iFrame when the server redirects with the authorization code.
356
+ if (SPAUtils.isInitializedSilentSignIn()) {
357
+ yield sessionManagementHelper.receivePromptNoneResponse();
358
+ return Promise.resolve({
359
+ allowedScopes: "",
360
+ displayName: "",
361
+ email: "",
362
+ sessionState: "",
363
+ sub: "",
364
+ tenantDomain: "",
365
+ username: ""
366
+ });
367
+ }
368
+ // This gets executed in the main thread and sends the prompt none request.
369
+ const rpIFrame = document.getElementById(RP_IFRAME);
370
+ const promptNoneIFrame = (_a = rpIFrame === null || rpIFrame === void 0 ? void 0 : rpIFrame.contentDocument) === null || _a === void 0 ? void 0 : _a.getElementById(PROMPT_NONE_IFRAME);
371
+ try {
372
+ const url = yield constructSilentSignInUrl();
373
+ promptNoneIFrame.src = url;
374
+ }
375
+ catch (error) {
376
+ return Promise.reject(error);
377
+ }
378
+ return new Promise((resolve, reject) => {
379
+ const timer = setTimeout(() => {
380
+ resolve(false);
381
+ }, 10000);
382
+ const listenToPromptNoneIFrame = (e) => __awaiter(this, void 0, void 0, function* () {
383
+ var _a, _b, _c, _d;
384
+ const data = e.data;
385
+ if ((data === null || data === void 0 ? void 0 : data.type) == CHECK_SESSION_SIGNED_OUT) {
386
+ window.removeEventListener("message", listenToPromptNoneIFrame);
387
+ clearTimeout(timer);
388
+ resolve(false);
389
+ }
390
+ if ((data === null || data === void 0 ? void 0 : data.type) == CHECK_SESSION_SIGNED_IN && ((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.code)) {
391
+ requestAccessToken((_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.code, (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.sessionState, (_d = data === null || data === void 0 ? void 0 : data.data) === null || _d === void 0 ? void 0 : _d.state)
392
+ .then((response) => {
393
+ window.removeEventListener("message", listenToPromptNoneIFrame);
394
+ resolve(response);
395
+ })
396
+ .catch((error) => {
397
+ window.removeEventListener("message", listenToPromptNoneIFrame);
398
+ reject(error);
399
+ })
400
+ .finally(() => {
401
+ clearTimeout(timer);
402
+ });
403
+ }
404
+ });
405
+ window.addEventListener("message", listenToPromptNoneIFrame);
406
+ });
407
+ });
408
+ }
409
+ handleSignIn(shouldStopAuthn, checkSession, tryRetrievingUserInfo) {
410
+ return __awaiter(this, void 0, void 0, function* () {
411
+ const config = yield this._dataLayer.getConfigData();
412
+ if (yield shouldStopAuthn()) {
413
+ return Promise.resolve({
414
+ allowedScopes: "",
415
+ displayName: "",
416
+ email: "",
417
+ sessionState: "",
418
+ sub: "",
419
+ tenantDomain: "",
420
+ username: ""
421
+ });
422
+ }
423
+ if (config.storage !== Storage.WebWorker) {
424
+ if (yield this._authenticationClient.isAuthenticated()) {
425
+ this._spaHelper.clearRefreshTokenTimeout();
426
+ this._spaHelper.refreshAccessTokenAutomatically();
427
+ // Enable OIDC Sessions Management only if it is set to true in the config.
428
+ if (config.enableOIDCSessionManagement) {
429
+ checkSession();
430
+ }
431
+ return Promise.resolve(yield this._authenticationClient.getBasicUserInfo());
432
+ }
433
+ }
434
+ const error = new URL(window.location.href).searchParams.get(ERROR);
435
+ const errorDescription = new URL(window.location.href).searchParams.get(ERROR_DESCRIPTION);
436
+ if (error) {
437
+ const url = new URL(window.location.href);
438
+ url.searchParams.delete(ERROR);
439
+ url.searchParams.delete(ERROR_DESCRIPTION);
440
+ history.pushState(null, document.title, url.toString());
441
+ throw new AsgardeoAuthException("SPA-AUTH_HELPER-SI-SE01", error, errorDescription !== null && errorDescription !== void 0 ? errorDescription : "");
442
+ }
443
+ if (config.storage === Storage.WebWorker && tryRetrievingUserInfo) {
444
+ const basicUserInfo = yield tryRetrievingUserInfo();
445
+ if (basicUserInfo) {
446
+ return basicUserInfo;
447
+ }
448
+ }
449
+ });
450
+ }
451
+ getBasicUserInfo() {
452
+ return __awaiter(this, void 0, void 0, function* () {
453
+ return this._authenticationClient.getBasicUserInfo();
454
+ });
455
+ }
456
+ getDecodedIDToken() {
457
+ return __awaiter(this, void 0, void 0, function* () {
458
+ return this._authenticationClient.getDecodedIDToken();
459
+ });
460
+ }
461
+ getIDToken() {
462
+ return __awaiter(this, void 0, void 0, function* () {
463
+ return this._authenticationClient.getIDToken();
464
+ });
465
+ }
466
+ getOIDCServiceEndpoints() {
467
+ return __awaiter(this, void 0, void 0, function* () {
468
+ return this._authenticationClient.getOIDCServiceEndpoints();
469
+ });
470
+ }
471
+ getAccessToken() {
472
+ return __awaiter(this, void 0, void 0, function* () {
473
+ return this._authenticationClient.getAccessToken();
474
+ });
475
+ }
476
+ isAuthenticated() {
477
+ return __awaiter(this, void 0, void 0, function* () {
478
+ return this._authenticationClient.isAuthenticated();
479
+ });
480
+ }
481
+ }
482
+ //# sourceMappingURL=authentication-helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-helper.js","sourceRoot":"","sources":["../../../src/helpers/authentication-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;AAEH,OAAO,EAEH,qBAAqB,EAErB,mBAAmB,EAStB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAW,QAAQ,EAAoC,MAAM,IAAI,CAAC;AACzE,OAAO,EACH,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB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* under the License.
17
17
  */
18
+ export * from "./authentication-helper";
18
19
  export * from "./spa-helper";
19
20
  export * from "./session-management-helper";
20
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC"}
@@ -15,6 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
+ export * from "./authentication-helper";
18
19
  export * from "./spa-helper";
19
20
  export * from "./session-management-helper";
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC"}
@@ -24,4 +24,7 @@ export * from "./utils/spa-utils";
24
24
  export * from "./constants/storage";
25
25
  export * from "./constants/hooks";
26
26
  export * from "@asgardeo/auth-js";
27
+ export * from "./helpers/authentication-helper";
28
+ export * from "./helpers/spa-helper";
29
+ export * from "./worker/worker-receiver";
27
30
  //# sourceMappingURL=public-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../src/public-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAGzB,cAAc,mBAAmB,CAAA;AAGjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAElC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../src/public-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAGzB,cAAc,mBAAmB,CAAA;AAGjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAElC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AAGrC,cAAc,0BAA0B,CAAC"}
@@ -26,4 +26,9 @@ export * from "./utils/spa-utils";
26
26
  export * from "./constants/storage";
27
27
  export * from "./constants/hooks";
28
28
  export * from "@asgardeo/auth-js";
29
+ // helpers
30
+ export * from "./helpers/authentication-helper";
31
+ export * from "./helpers/spa-helper";
32
+ // worker receiver
33
+ export * from "./worker/worker-receiver";
29
34
  //# sourceMappingURL=public-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../src/public-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,QAAQ;AACR,cAAc,mBAAmB,CAAA;AAEjC,YAAY;AACZ,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAElC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../src/public-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,QAAQ;AACR,cAAc,mBAAmB,CAAA;AAEjC,YAAY;AACZ,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAElC,cAAc,mBAAmB,CAAC;AAElC,UAAU;AACV,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AAErC,kBAAkB;AAClB,cAAc,0BAA0B,CAAC"}
@@ -15,6 +15,6 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- export * from "./client.worker";
18
+ export * from "./worker-receiver";
19
19
  export * from "./worker-core";
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/worker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/worker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
@@ -15,6 +15,6 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- export * from "./client.worker";
18
+ export * from "./worker-receiver";
19
19
  export * from "./worker-core";
20
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/worker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/worker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
@@ -15,7 +15,8 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { AuthClientConfig } from "@asgardeo/auth-js";
18
+ import { AsgardeoAuthClient, AuthClientConfig } from "@asgardeo/auth-js";
19
+ import { AuthenticationHelper, SPAHelper } from "../helpers";
19
20
  import { WebWorkerClientConfig, WebWorkerCoreInterface } from "../models";
20
- export declare const WebWorkerCore: (config: AuthClientConfig<WebWorkerClientConfig>) => Promise<WebWorkerCoreInterface>;
21
+ export declare const WebWorkerCore: (config: AuthClientConfig<WebWorkerClientConfig>, getAuthHelper: (authClient: AsgardeoAuthClient<WebWorkerClientConfig>, spaHelper: SPAHelper<WebWorkerClientConfig>) => AuthenticationHelper<WebWorkerClientConfig>) => Promise<WebWorkerCoreInterface>;
21
22
  //# sourceMappingURL=worker-core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-core.d.ts","sourceRoot":"","sources":["../../../src/worker/worker-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAGH,gBAAgB,EAWnB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAKH,qBAAqB,EACrB,sBAAsB,EACzB,MAAM,WAAW,CAAC;AAInB,eAAO,MAAM,aAAa,WACd,iBAAiB,qBAAqB,CAAC,KAChD,QAAQ,sBAAsB,CAkZhC,CAAC"}
1
+ {"version":3,"file":"worker-core.d.ts","sourceRoot":"","sources":["../../../src/worker/worker-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAUnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE7D,OAAO,EAIH,qBAAqB,EACrB,sBAAsB,EACzB,MAAM,WAAW,CAAC;AAInB,eAAO,MAAM,aAAa,WACd,iBAAiB,qBAAqB,CAAC,8BAE/B,mBAAmB,qBAAqB,CAAC,aAC1C,UAAU,qBAAqB,CAAC,KAC1C,qBAAqB,qBAAqB,CAAC,KACjD,QAAQ,sBAAsB,CA6LhC,CAAC"}