Skip to content

Conversation

@sparlampe
Copy link
Contributor

@sparlampe sparlampe commented Jul 6, 2025

Current implementation does not work correctly with multiple ips using iframe renew.

  1. The events do not include the configId. This leads to corresponding code and token exchange events not being correlated. We propose the following fix.
  2. Another defect is that with multiple ipds the library is using a single iframe to execute redirects. The redirected overwrite each other if executed close in time. We propose the following fix1 and fix2 .

The PR is related to the following feature request #2105


if (isAuthenticated) {

const authResult = callbackContext && 'authResult' in callbackContext
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const authResult = callbackContext?.authResult ?? null;

Copy link
Contributor Author

@sparlampe sparlampe Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this approach, but the types are not working out. callbackContext can be of type {configId: string}, which does not contain authResult , so in this case callbackContext.authResult is not nullish, but a type error. That is why we need 'authResult' in callbackContext to test we are not in case of {configId: string}. At least this is my understanding of the matter.

I have added another approach to make this part look nicer. let me know if the alternative makes sense

result: unknown,
isRenewProcess: boolean
isRenewProcess: boolean,
config: OpenIdConfiguration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only the configId is needed, please only pass the configId in.

stateValidationResult: StateValidationResult,
isRenewProcess: boolean
isRenewProcess: boolean,
config: OpenIdConfiguration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only configId is needed, please only pass the id in.

stateValidationResult: StateValidationResult | null,
isRenewProcess: boolean
isRenewProcess: boolean,
config: OpenIdConfiguration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please only pass configId in.

stateValidationResult: StateValidationResult | null,
isRenewProcess: boolean
isRenewProcess: boolean,
config: OpenIdConfiguration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please only pass configId in.

const eventData = e.detail;

if (typeof eventData === 'object' && eventData.configId && eventData.instanceId) {
if (eventData.configId === config.configId && eventData.instanceId !== instanceId) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please extract a method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this refers, I guess, to the same hunk as the above comment.

config: OpenIdConfiguration
): boolean {

if (e?.detail == null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

===. But I think undefined should also be checked? if (!e?.detail)

return false;
}

if (e.detail.srcFrameId != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. We are only checking for null, so undefined is a valid value? Just do if(e.deailt.srcFrameId)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.detail.srcFrameId != null is null or undefined, notice != rather than !==. I will change however to if(e.deailt.srcFrameId). This is more consistent with the rest of the codebase.

if (e.detail.srcFrameId != null) {

const frameIdPrefix = `${IFRAME_FOR_SILENT_RENEW_IDENTIFIER}_`;
let eventConfigId: string | null = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would consider let as a code smell. Easy fixable by extracting a method, return the value and assign to a const here :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made this part of code more concise.


private convertToLegacyEvent(e: CustomEvent): CustomEvent {
// If event has the new format with url property, convert it to legacy format
if (e?.detail?.url != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined is a valid value here? Better do if(e?.detail?.url)

@FabianGosebrink
Copy link
Collaborator

What a PR. Thanks a lot!!!! Incredible work.

sparlampe added 2 commits July 8, 2025 03:16
This fixes compatibility issues with Angular 20+ projects created with --standalone=false flag.
@sparlampe
Copy link
Contributor Author

Thanks for the review points. Working on improvements.

@sparlampe sparlampe requested a review from FabianGosebrink July 8, 2025 20:05
@FabianGosebrink FabianGosebrink merged commit cdb82d9 into damienbod:main Jul 20, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants