Skip to content

Commit bb16fd2

Browse files
authored
Merge pull request #17 from Navigraph/fix/update-logout-actions
2 parents e54f17f + c3a8058 commit bb16fd2

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

.changeset/famous-coats-deny.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@navigraph/auth": patch
3+
---
4+
5+
Call token revocation endpoint on signout instead of calling endsession.

packages/auth/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
"publishConfig": {
3232
"access": "public"
3333
},
34+
"engines": {
35+
"node": ">=10"
36+
},
3437
"scripts": {
3538
"build": "tsup src/index.ts --format esm,cjs --dts ",
3639
"dev": "tsup src/index.ts --format esm,cjs --watch --dts --sourcemap inline",

packages/auth/src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const IDENTITY_ROOT = "https://identity.api.navigraph.com";
22
export const IDENTITY_DEVICE_AUTH = IDENTITY_ROOT + "/connect/deviceauthorization";
33
export const IDENTITY_ENDSESSION_ENDPOINT = IDENTITY_ROOT + "/connect/endsession";
4+
export const IDENTITY_REVOCATION_ENDPOINT = IDENTITY_ROOT + "/connect/revocation";

packages/auth/src/internal.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { IDENTITY_ENDSESSION_ENDPOINT } from "./constants";
1+
import { getApp, Logger } from "@navigraph/app";
2+
import { IDENTITY_REVOCATION_ENDPOINT } from "./constants";
23
import { authenticatedAxios } from "./network";
34
import { CustomStorage, Listener, StorageKeys, User } from "./public-types";
45

@@ -38,8 +39,24 @@ export const setUser = (user: User | null) => {
3839
export const setInitialized = (initialized: boolean) => (INITIALIZED = initialized);
3940

4041
export const signOut = () => {
42+
const app = getApp();
43+
const refreshToken = tokenStorage.getRefreshToken();
44+
45+
if (app && refreshToken) {
46+
authenticatedAxios
47+
.post(
48+
IDENTITY_REVOCATION_ENDPOINT,
49+
new URLSearchParams({
50+
client_id: app.clientId,
51+
client_secret: app.clientSecret,
52+
token__type_hint: "refresh_token",
53+
token: refreshToken,
54+
})
55+
)
56+
.catch(() => Logger.warning("Failed to revoke token on signout"));
57+
}
58+
4159
tokenStorage.setAccessToken();
4260
tokenStorage.setRefreshToken();
4361
setUser(null);
44-
authenticatedAxios.get(IDENTITY_ENDSESSION_ENDPOINT).catch(() => "");
4562
};

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"moduleResolution": "node",
99
"skipLibCheck": true,
1010
"strict": true,
11+
"noImplicitAny": true,
1112
"isolatedModules": true,
1213
"noFallthroughCasesInSwitch": true,
1314
"esModuleInterop": true,

0 commit comments

Comments
 (0)