diff --git a/sdk/mixedreality/mixedreality-authentication/src/util/jwt.ts b/sdk/mixedreality/mixedreality-authentication/src/util/jwt.ts index e6d249ed1788..382031a9c7d2 100644 --- a/sdk/mixedreality/mixedreality-authentication/src/util/jwt.ts +++ b/sdk/mixedreality/mixedreality-authentication/src/util/jwt.ts @@ -36,5 +36,6 @@ export function retrieveJwtExpirationTimestamp(jwtValue: string): number { throw new Error("Invalid JWT payload structure. No expiration."); } - return Number.parseInt(jwtPayload.exp); + // The JWT expiry value is in seconds-since-epoch whereas JS Dates are in milliseconds-since-epoch. + return 1000 * Number.parseInt(jwtPayload.exp); } diff --git a/sdk/mixedreality/mixedreality-authentication/test/jwt.spec.ts b/sdk/mixedreality/mixedreality-authentication/test/jwt.spec.ts index 65a06501205b..32065e1a4f91 100644 --- a/sdk/mixedreality/mixedreality-authentication/test/jwt.spec.ts +++ b/sdk/mixedreality/mixedreality-authentication/test/jwt.spec.ts @@ -9,7 +9,7 @@ describe("jwt", () => { // Note: The trailing "." on the end indicates an empty signature indicating that this JWT is not signed. const jwtValue = "eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJlbWFpbCI6IkJvYkBjb250b3NvLmNvbSIsImdpdmVuX25hbWUiOiJCb2IiLCJpc3MiOiJodHRwOi8vRGVmYXVsdC5Jc3N1ZXIuY29tIiwiYXVkIjoiaHR0cDovL0RlZmF1bHQuQXVkaWVuY2UuY29tIiwiaWF0IjoiMTYxMDgxMjI1MCIsIm5iZiI6IjE2MTA4MTI1NTAiLCJleHAiOiIxNjEwODk4NjUwIn0."; - const expectedExpirationTimestamp = 1610898650; // 1/17/2021 3:50:50 PM UTC + const expectedExpirationTimestamp = 1610898650000; // 1/17/2021 3:50:50 PM UTC const expirationTimestamp = retrieveJwtExpirationTimestamp(jwtValue);