@navigraph/auth
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -32,4 +32,7 @@ "use strict"; | ||
// src/api.ts | ||
var import_app4 = require("@navigraph/app"); | ||
var import_app5 = require("@navigraph/app"); | ||
// src/internal.ts | ||
var import_app3 = require("@navigraph/app"); | ||
// src/constants.ts | ||
@@ -39,2 +42,3 @@ var IDENTITY_ROOT = "https://identity.api.navigraph.com"; | ||
var IDENTITY_ENDSESSION_ENDPOINT = IDENTITY_ROOT + "/connect/endsession"; | ||
var IDENTITY_REVOCATION_ENDPOINT = IDENTITY_ROOT + "/connect/revocation"; | ||
@@ -147,6 +151,15 @@ // src/network.ts | ||
var signOut = () => { | ||
const app = (0, import_app3.getApp)(); | ||
const refreshToken = tokenStorage.getRefreshToken(); | ||
if (app && refreshToken) { | ||
authenticatedAxios.post(IDENTITY_REVOCATION_ENDPOINT, new URLSearchParams({ | ||
client_id: app.clientId, | ||
client_secret: app.clientSecret, | ||
token__type_hint: "refresh_token", | ||
token: refreshToken | ||
})).catch(() => import_app3.Logger.warning("Failed to revoke token on signout")); | ||
} | ||
tokenStorage.setAccessToken(); | ||
tokenStorage.setRefreshToken(); | ||
setUser(null); | ||
authenticatedAxios.get(IDENTITY_ENDSESSION_ENDPOINT).catch(() => ""); | ||
}; | ||
@@ -156,9 +169,9 @@ | ||
var import_pkce = __toESM(require("@navigraph/pkce")); | ||
var import_app3 = require("@navigraph/app"); | ||
var import_app4 = require("@navigraph/app"); | ||
var import_axios3 = __toESM(require("axios")); | ||
var MAX_ATTEMPTS = 12; | ||
async function signInWithDeviceFlow(callback) { | ||
const app = (0, import_app3.getApp)(); | ||
const app = (0, import_app4.getApp)(); | ||
if (!app) { | ||
throw new import_app3.NotInitializedError("Auth"); | ||
throw new import_app4.NotInitializedError("Auth"); | ||
} | ||
@@ -212,5 +225,5 @@ const { code_verifier, code_challenge } = (0, import_pkce.default)(); | ||
case "access_denied": | ||
throw new import_app3.UserDeniedAccessError(); | ||
throw new import_app4.UserDeniedAccessError(); | ||
case "expired_token": | ||
throw new import_app3.DeviceFlowTokenExpiredError(); | ||
throw new import_app4.DeviceFlowTokenExpiredError(); | ||
default: | ||
@@ -225,3 +238,3 @@ throw error; | ||
if (typeof localStorage === "undefined" && !storage2) { | ||
import_app4.Logger.warning("No storage API available in your environment. Please provide a custom tokenStorage implementation."); | ||
import_app5.Logger.warning("No storage API available in your environment. Please provide a custom tokenStorage implementation."); | ||
} | ||
@@ -236,5 +249,5 @@ if (storage2) { | ||
} | ||
const app = (0, import_app4.getApp)(); | ||
const app = (0, import_app5.getApp)(); | ||
if (!app) { | ||
throw new import_app4.NotInitializedError("Auth"); | ||
throw new import_app5.NotInitializedError("Auth"); | ||
} | ||
@@ -241,0 +254,0 @@ loadPersistedCredentials(app); |
{ | ||
"name": "@navigraph/auth", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"license": "MIT", | ||
@@ -34,2 +34,5 @@ "description": "Authentication with Navigraph services as part of the Navigraph SDK", | ||
}, | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
@@ -36,0 +39,0 @@ "build": "tsup src/index.ts --format esm,cjs --dts ", |
Sorry, the diff of this file is not supported yet
21952
606