Skip to content

Commit 9650c04

Browse files
authored
fix: NativeBrokerPlugin expiresOn (#7602)
Fix to NativeBrokerPlugin expiresOn calculations, addresses #7371 and #7086
1 parent 76c711f commit 9650c04

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix NativeBrokerPlugin expiresOn bug #7602",
4+
"packageName": "@azure/msal-node-extensions",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

extensions/msal-node-extensions/src/broker/NativeBrokerPlugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ export class NativeBrokerPlugin implements INativeBrokerPlugin {
568568
idTokenClaims: idTokenClaims,
569569
accessToken: accessToken,
570570
fromCache: fromCache,
571-
expiresOn: new Date(authResult.expiresOn),
571+
expiresOn: new Date(Number(authResult.expiresOn) * 1000),
572572
tokenType: tokenType,
573573
correlationId: request.correlationId,
574574
fromNativeBroker: true,

extensions/msal-node-extensions/test/broker/NativeBrokerPlugin.spec.ts

+24-12
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ if (process.platform === "win32") {
298298
grantedScopes:
299299
testAuthenticationResult.scopes.join(" "),
300300
expiresOn:
301-
testAuthenticationResult.expiresOn!.getTime(),
301+
testAuthenticationResult.expiresOn!.getTime() /
302+
1000, // Accounts for msalRuntime returning seconds
302303
isPopAuthorization: false,
303304
account: testMsalRuntimeAccount,
304305
CheckError: () => {},
@@ -351,7 +352,8 @@ if (process.platform === "win32") {
351352
grantedScopes:
352353
testAuthenticationResult.scopes.join(" "),
353354
expiresOn:
354-
testAuthenticationResult.expiresOn!.getTime(),
355+
testAuthenticationResult.expiresOn!.getTime() /
356+
1000,
355357
isPopAuthorization: true,
356358
account: testMsalRuntimeAccount,
357359
CheckError: () => {},
@@ -431,7 +433,8 @@ if (process.platform === "win32") {
431433
grantedScopes:
432434
testAuthenticationResult.scopes.join(" "),
433435
expiresOn:
434-
testAuthenticationResult.expiresOn!.getTime(),
436+
testAuthenticationResult.expiresOn!.getTime() /
437+
1000,
435438
isPopAuthorization: false,
436439
account: testMsalRuntimeAccount,
437440
CheckError: () => {},
@@ -617,7 +620,8 @@ if (process.platform === "win32") {
617620
grantedScopes:
618621
testAuthenticationResult.scopes.join(" "),
619622
expiresOn:
620-
testAuthenticationResult.expiresOn!.getTime(),
623+
testAuthenticationResult.expiresOn!.getTime() /
624+
1000,
621625
isPopAuthorization: false,
622626
account: testMsalRuntimeAccount,
623627
CheckError: () => {},
@@ -669,7 +673,8 @@ if (process.platform === "win32") {
669673
grantedScopes:
670674
testAuthenticationResult.scopes.join(" "),
671675
expiresOn:
672-
testAuthenticationResult.expiresOn!.getTime(),
676+
testAuthenticationResult.expiresOn!.getTime() /
677+
1000,
673678
isPopAuthorization: true,
674679
account: testMsalRuntimeAccount,
675680
CheckError: () => {},
@@ -749,7 +754,8 @@ if (process.platform === "win32") {
749754
grantedScopes:
750755
testAuthenticationResult.scopes.join(" "),
751756
expiresOn:
752-
testAuthenticationResult.expiresOn!.getTime(),
757+
testAuthenticationResult.expiresOn!.getTime() /
758+
1000,
753759
isPopAuthorization: false,
754760
account: testMsalRuntimeAccount,
755761
CheckError: () => {},
@@ -824,7 +830,8 @@ if (process.platform === "win32") {
824830
grantedScopes:
825831
testAuthenticationResult.scopes.join(" "),
826832
expiresOn:
827-
testAuthenticationResult.expiresOn!.getTime(),
833+
testAuthenticationResult.expiresOn!.getTime() /
834+
1000,
828835
isPopAuthorization: false,
829836
account: testMsalRuntimeAccount,
830837
CheckError: () => {},
@@ -879,7 +886,8 @@ if (process.platform === "win32") {
879886
grantedScopes:
880887
testAuthenticationResult.scopes.join(" "),
881888
expiresOn:
882-
testAuthenticationResult.expiresOn!.getTime(),
889+
testAuthenticationResult.expiresOn!.getTime() /
890+
1000,
883891
isPopAuthorization: false,
884892
account: testMsalRuntimeAccount,
885893
CheckError: () => {},
@@ -934,7 +942,8 @@ if (process.platform === "win32") {
934942
grantedScopes:
935943
testAuthenticationResult.scopes.join(" "),
936944
expiresOn:
937-
testAuthenticationResult.expiresOn!.getTime(),
945+
testAuthenticationResult.expiresOn!.getTime() /
946+
1000,
938947
isPopAuthorization: false,
939948
account: testMsalRuntimeAccount,
940949
CheckError: () => {},
@@ -989,7 +998,8 @@ if (process.platform === "win32") {
989998
grantedScopes:
990999
testAuthenticationResult.scopes.join(" "),
9911000
expiresOn:
992-
testAuthenticationResult.expiresOn!.getTime(),
1001+
testAuthenticationResult.expiresOn!.getTime() /
1002+
1000,
9931003
isPopAuthorization: false,
9941004
account: testMsalRuntimeAccount,
9951005
CheckError: () => {},
@@ -1044,7 +1054,8 @@ if (process.platform === "win32") {
10441054
grantedScopes:
10451055
testAuthenticationResult.scopes.join(" "),
10461056
expiresOn:
1047-
testAuthenticationResult.expiresOn!.getTime(),
1057+
testAuthenticationResult.expiresOn!.getTime() /
1058+
1000,
10481059
isPopAuthorization: false,
10491060
account: testMsalRuntimeAccount,
10501061
CheckError: () => {},
@@ -2000,7 +2011,8 @@ if (process.platform === "win32") {
20002011
grantedScopes:
20012012
testAuthenticationResult.scopes.join(" "),
20022013
expiresOn:
2003-
testAuthenticationResult.expiresOn!.getTime(),
2014+
testAuthenticationResult.expiresOn!.getTime() /
2015+
1000,
20042016
isPopAuthorization: false,
20052017
account: testMsalRuntimeAccount,
20062018
CheckError: () => {

0 commit comments

Comments
 (0)