Skip to content

Commit 392669a

Browse files
Update instanceID to instanceId for consistency across message, utils, and worker files
- Changed all occurrences of `instanceID` to `instanceId` in message.ts, spa-utils.ts, worker-core.ts, and worker-receiver.ts for uniformity. - Added `instanceId` property to the Message interface in message.ts. - Updated the handling of instanceId in the WebWorkerCore and workerReceiver functions to align with the new naming convention.
1 parent 6091a45 commit 392669a

8 files changed

Lines changed: 1090 additions & 1088 deletions

File tree

packages/browser/src/__legacy__/client.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ export class AsgardeoSPAClient {
8787
protected _onEndUserSession: (response: any) => void = () => null;
8888
protected _onInitialize: (response: boolean) => void = () => null;
8989
protected _onCustomGrant: Map<string, (response: any) => void> = new Map();
90-
protected _instanceID: number;
90+
protected _instanceId: number;
9191

9292
protected constructor(id: number) {
93-
this._instanceID = id;
93+
this._instanceId = id;
9494
}
9595

9696
public instantiateAuthHelper(authHelper?: typeof AuthenticationHelper): void {
@@ -309,7 +309,7 @@ export class AsgardeoSPAClient {
309309
* @preserve
310310
*/
311311
public getInstanceId(): number {
312-
return this._instanceID;
312+
return this._instanceId;
313313
}
314314

315315
/**
@@ -364,7 +364,7 @@ export class AsgardeoSPAClient {
364364
// Tracker: https://github.com/asgardeo/asgardeo-auth-react-sdk/issues/240
365365
if (!this._client || (this._client && (!_config || Object.keys(_config)?.length === 0))) {
366366
this._client = await MainThreadClient(
367-
this._instanceID,
367+
this._instanceId,
368368
mergedConfig,
369369
(authClient: AsgardeoAuthClient<MainThreadClientConfig>, spaHelper: SPAHelper<MainThreadClientConfig>) => {
370370
return new this._authHelper(authClient, spaHelper);
@@ -399,7 +399,7 @@ export class AsgardeoSPAClient {
399399
if (!this._client || (this._client && (!_config || Object.keys(_config)?.length === 0))) {
400400
const webWorkerClientConfig = config as AuthClientConfig<WebWorkerClientConfig>;
401401
this._client = (await WebWorkerClient(
402-
this._instanceID,
402+
this._instanceId,
403403
{
404404
...DefaultConfig,
405405
...webWorkerClientConfig,

packages/browser/src/__legacy__/clients/main-thread-client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const initiateStore = (store: BrowserStorage | undefined): Storage => {
5757
};
5858

5959
export const MainThreadClient = async (
60-
instanceID: number,
60+
instanceId: number,
6161
config: AuthClientConfig<MainThreadClientConfig>,
6262
getAuthHelper: (
6363
authClient: AsgardeoAuthClient<MainThreadClientConfig>,
@@ -67,7 +67,7 @@ export const MainThreadClient = async (
6767
const _store: Storage = initiateStore(config.storage as BrowserStorage);
6868
const _cryptoUtils: SPACryptoUtils = new SPACryptoUtils();
6969
const _authenticationClient = new AsgardeoAuthClient<MainThreadClientConfig>();
70-
await _authenticationClient.initialize(config, _store, _cryptoUtils, instanceID);
70+
await _authenticationClient.initialize(config, _store, _cryptoUtils, instanceId);
7171

7272
const _spaHelper = new SPAHelper<MainThreadClientConfig>(_authenticationClient);
7373
const _dataLayer = _authenticationClient.getStorageManager();
@@ -85,7 +85,7 @@ export const MainThreadClient = async (
8585

8686
let _getSignOutURLFromSessionStorage: boolean = false;
8787

88-
const _httpClient: HttpClientInstance = HttpClient.getInstance(instanceID);
88+
const _httpClient: HttpClientInstance = HttpClient.getInstance(instanceId);
8989
let _isHttpHandlerEnabled: boolean = true;
9090
let _httpErrorCallback: (error: HttpError) => void | Promise<void>;
9191
let _httpFinishCallback: () => void;
@@ -261,7 +261,7 @@ export const MainThreadClient = async (
261261
if ((await _authenticationClient.isSignedIn()) && !_getSignOutURLFromSessionStorage) {
262262
location.href = await _authenticationClient.getSignOutUrl();
263263
} else {
264-
location.href = SPAUtils.getSignOutUrl(config.clientId, instanceID);
264+
location.href = SPAUtils.getSignOutUrl(config.clientId, instanceId);
265265
}
266266

267267
_spaHelper.clearRefreshTokenTimeout();

packages/browser/src/__legacy__/clients/web-worker-client.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const initiateStore = (store: BrowserStorage | undefined): Storage => {
9292
};
9393

9494
export const WebWorkerClient = async (
95-
instanceID: number,
95+
instanceId: number,
9696
config: AuthClientConfig<WebWorkerClientConfig>,
9797
webWorker: new () => Worker,
9898
getAuthHelper: (
@@ -114,7 +114,7 @@ export const WebWorkerClient = async (
114114
const _store: Storage = initiateStore(config.storage as BrowserStorage);
115115
const _cryptoUtils: SPACryptoUtils = new SPACryptoUtils();
116116
const _authenticationClient = new AsgardeoAuthClient<WebWorkerClientConfig>();
117-
await _authenticationClient.initialize(config, _store, _cryptoUtils, instanceID);
117+
await _authenticationClient.initialize(config, _store, _cryptoUtils, instanceId);
118118
const _spaHelper = new SPAHelper<WebWorkerClientConfig>(_authenticationClient);
119119

120120
const _sessionManagementHelper = await SessionManagementHelper(
@@ -128,7 +128,7 @@ export const WebWorkerClient = async (
128128

129129
return signOutURL;
130130
} catch {
131-
return SPAUtils.getSignOutUrl(config.clientId, instanceID);
131+
return SPAUtils.getSignOutUrl(config.clientId, instanceId);
132132
}
133133
},
134134
config.storage as BrowserStorage,
@@ -365,8 +365,9 @@ export const WebWorkerClient = async (
365365
}
366366
};
367367

368-
const message: Message<AuthClientConfig<WebWorkerClientConfig> & {instanceID: number}> = {
369-
data: {...config, instanceID},
368+
const message: Message<AuthClientConfig<WebWorkerClientConfig>> = {
369+
data: config,
370+
instanceId,
370371
type: INIT,
371372
};
372373

@@ -524,7 +525,7 @@ export const WebWorkerClient = async (
524525

525526
return communicate<null, string>(message)
526527
.then((url: string) => {
527-
SPAUtils.setSignOutURL(url, config.clientId, instanceID);
528+
SPAUtils.setSignOutURL(url, config.clientId, instanceId);
528529

529530
// Enable OIDC Sessions Management only if it is set to true in the config.
530531
if (config.syncSession) {
@@ -656,7 +657,7 @@ export const WebWorkerClient = async (
656657
return reject(error);
657658
});
658659
} else {
659-
window.location.href = SPAUtils.getSignOutUrl(config.clientId, instanceID);
660+
window.location.href = SPAUtils.getSignOutUrl(config.clientId, instanceId);
660661

661662
return SPAUtils.waitTillPageRedirect().then(() => {
662663
return Promise.resolve(true);

0 commit comments

Comments
 (0)