Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSAL-Node Configuration: Refactoring to remove the ambiguity for deeply nested properties #7221

Open
Robbie-Microsoft opened this issue Jul 25, 2024 · 3 comments
Assignees
Labels
confidential-client Issues regarding ConfidentialClientApplications msal-node Related to msal-node package

Comments

@Robbie-Microsoft
Copy link
Collaborator

Core Library

MSAL Node (@azure/msal-node)

Wrapper Library

Not Applicable

Public or Confidential Client?

Confidential

Description

In TypeScript, the spread operator does not ignore undefined values.

For example, as it relates to msal-node, when building the configuration for an application:

Assuming
DEFAULT_AUTH_OPTIONS.clientCertificate: { thumbprint: Constants.EMPTY_STRING, thumbprintSha256: Constants.EMPTY_STRING, privateKey: Constants.EMPTY_STRING, x5c: Constants.EMPTY_STRING, }
and
auth.clientCertificate = undefined (can be undefined as long as clientSecret or clientAssertion is defined)

Then after
auth: { ...DEFAULT_AUTH_OPTIONS, ...auth },,
We want auth.clientCertificate to be equal to DEFAULT_AUTH_OPTIONS.clientCertificate. However, it's equal to undefined.

This is apparently expected behavior in TypeScript, but is not desired behavior in our case. Therefore, we need to refactor this spread operator functionality here and wherever else it's used when we want to ignore undefined values.

Please see this discussion for additional context.

Source

Internal (Microsoft)

@Robbie-Microsoft Robbie-Microsoft added question Customer is asking for a clarification, use case or information. feature-unconfirmed labels Jul 25, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Jul 25, 2024
@github-actions github-actions bot added confidential-client Issues regarding ConfidentialClientApplications msal-node Related to msal-node package labels Jul 25, 2024
@Robbie-Microsoft Robbie-Microsoft self-assigned this Jul 25, 2024
@Robbie-Microsoft Robbie-Microsoft removed question Customer is asking for a clarification, use case or information. Needs: Attention 👋 Awaiting response from the MSAL.js team feature-unconfirmed labels Jul 25, 2024
@bgavrilMS
Copy link
Member

Sounds good to me to eliminate a source of confusion like this. But how can you "refactor this spread operator functionality" ?

@Robbie-Microsoft
Copy link
Collaborator Author

@bgavrilMS, I should have worded it better. I meant to say "refactor this functionality, in general". For example, one solution would be to not use spread here, and instead write a short algorithm for merging that ignores undefined values.

@bgavrilMS
Copy link
Member

bgavrilMS commented Jul 27, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confidential-client Issues regarding ConfidentialClientApplications msal-node Related to msal-node package
Projects
None yet
Development

No branches or pull requests

2 participants