Skip to content

Commit

Permalink
ENG-54318 - Logout Functionality Not Working (#356)
Browse files Browse the repository at this point in the history
Fixes conduit to only respond to messages from the target URL, which
allows multiple conduit clients to coexist peacefully (and in turn,
allows logout to complete purge of conduit session data).

Also allows logging to be enabled programmatically in the console.
  • Loading branch information
mcnielsen authored Feb 22, 2024
1 parent 0fbf545 commit 85787b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@al/core",
"version": "1.2.23",
"version": "1.2.24",
"description": "Node Enterprise Packages for Alert Logic (NEPAL) Core Library",
"main": "./dist/index.cjs.js",
"types": "./dist/index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions src/session/al-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ export class AlSessionInstance
}
this.setTokenInfo( token, expirationTTL );
console.log("Updated AIMS Token to expire in %s seconds from now", offset );
},
logging: ( enable:boolean ) => {
AlErrorHandler.verbose = enable;
}
} );
}
Expand Down
24 changes: 13 additions & 11 deletions src/session/utilities/al-conduit-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
AlLocation,
AlLocatorService,
} from "../../common/navigation";
import { AlErrorHandler } from '../../error-handler';
import { AlBehaviorPromise } from "../../common/promises";
import {
AlStopwatch,
AlTriggerStream,
} from "../../common/utility";
import { AlErrorHandler } from '../../error-handler';
import {
AlDatacenterSessionErrorEvent,
AlDatacenterSessionEstablishedEvent,
Expand Down Expand Up @@ -71,7 +71,7 @@ export class AlConduitClient
}
let locationId = AlRuntimeConfiguration.getOption<string>( ConfigOption.NavigationConduitLocation, AlLocation.AccountsUI );
AlConduitClient.conduitUri = AlLocatorService.resolveURL( locationId, '/conduit.html', { residency, environment } );
console.log(`Notice: conduit client is using '${AlConduitClient.conduitUri}' as target` );
AlErrorHandler.log( `Notice: conduit client is using '${AlConduitClient.conduitUri}' as target` );
const fragment = AlConduitClient.document.createDocumentFragment();
const container = AlConduitClient.document.createElement( "div" );
container.setAttribute("id", "conduitClient" );
Expand Down Expand Up @@ -178,9 +178,9 @@ export class AlConduitClient
/**
* Deletes existing session information.
*/
public deleteSession(): Promise<boolean> {
public deleteSession() {
return this.request('conduit.deleteSession')
.then( () => true );
.then( () => true );
}

/**
Expand Down Expand Up @@ -264,12 +264,14 @@ export class AlConduitClient
}

public onConduitReady(event: any ): void {
AlConduitClient.conduitWindow = event.source;
AlConduitClient.conduitOrigin = event.origin;
AlConduitClient.ready.resolve( true );
if ( typeof( event.data.cookiesDisabled ) === 'boolean' && event.data.cookiesDisabled ) {
console.warn("WARNING: conduit has indicated that 3rd party cookies are disabled, triggering session error event." );
AlConduitClient.events.trigger( new AlDatacenterSessionErrorEvent( "inapplicable", "cookie-configuration", event.data ) );
if ( AlConduitClient.conduitUri.startsWith( event.origin ) ) {
AlConduitClient.conduitWindow = event.source;
AlConduitClient.conduitOrigin = event.origin;
AlConduitClient.ready.resolve( true );
if ( typeof( event.data.cookiesDisabled ) === 'boolean' && event.data.cookiesDisabled ) {
console.warn("WARNING: conduit has indicated that 3rd party cookies are disabled, triggering session error event." );
AlConduitClient.events.trigger( new AlDatacenterSessionErrorEvent( "inapplicable", "cookie-configuration", event.data ) );
}
}
}

Expand Down Expand Up @@ -298,7 +300,7 @@ export class AlConduitClient
if ( typeof( event.data.locationId ) !== 'string' ) {
return;
}
console.log(`Notice: received external session confirmation for location [${event.data.locationId}]` );
AlErrorHandler.log( `Notice: received external session confirmation for location [${event.data.locationId}]` );
const session = AlConduitClient.externalSessions.hasOwnProperty( event.data.locationId ) ? AlConduitClient.externalSessions[event.data.locationId] : null;

if ( session ) {
Expand Down

0 comments on commit 85787b6

Please sign in to comment.