Skip to content

Commit 273ec5a

Browse files
Fixed bug where dev-provided certificate was not being attached to client assertion
1 parent 8ba150d commit 273ec5a

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

lib/msal-node/src/client/ClientApplication.ts

+22-18
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,9 @@ export abstract class ClientApplication {
457457
serverTelemetryManager: serverTelemetryManager,
458458
clientCredentials: {
459459
clientSecret: this.clientSecret,
460-
clientAssertion: this.developerProvidedClientAssertion
461-
? await this.getClientAssertion(discoveredAuthority)
462-
: undefined,
460+
clientAssertion: await this.getClientAssertion(
461+
discoveredAuthority
462+
),
463463
},
464464
libraryInfo: {
465465
sku: NodeConstants.MSAL_SKU,
@@ -478,22 +478,26 @@ export abstract class ClientApplication {
478478
private async getClientAssertion(
479479
authority: Authority
480480
): Promise<ClientAssertionType> {
481-
this.clientAssertion = ClientAssertion.fromAssertion(
482-
await getClientAssertion(
483-
this.developerProvidedClientAssertion,
484-
this.config.auth.clientId,
485-
authority.tokenEndpoint
486-
)
487-
);
481+
if (this.developerProvidedClientAssertion) {
482+
this.clientAssertion = ClientAssertion.fromAssertion(
483+
await getClientAssertion(
484+
this.developerProvidedClientAssertion,
485+
this.config.auth.clientId,
486+
authority.tokenEndpoint
487+
)
488+
);
489+
}
488490

489-
return {
490-
assertion: this.clientAssertion.getJwt(
491-
this.cryptoProvider,
492-
this.config.auth.clientId,
493-
authority.tokenEndpoint
494-
),
495-
assertionType: NodeConstants.JWT_BEARER_ASSERTION_TYPE,
496-
};
491+
return (
492+
this.clientAssertion && {
493+
assertion: this.clientAssertion.getJwt(
494+
this.cryptoProvider,
495+
this.config.auth.clientId,
496+
authority.tokenEndpoint
497+
),
498+
assertionType: NodeConstants.JWT_BEARER_ASSERTION_TYPE,
499+
}
500+
);
497501
}
498502

499503
/**

0 commit comments

Comments
 (0)