@navigraph/auth
Advanced tools
Comparing version 2.0.9 to 2.0.10
@@ -453,3 +453,2 @@ "use strict"; | ||
var import_axios3 = __toESM(require("axios")); | ||
var MAX_ATTEMPTS = 60; | ||
function signInWithDeviceFlow(callback) { | ||
@@ -528,5 +527,2 @@ return _signInWithDeviceFlow.apply(this, arguments); | ||
attempts = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : 0; | ||
if (attempts >= MAX_ATTEMPTS) { | ||
throw new Error("Unable to sign in with device flow. Max attempts reached."); | ||
} | ||
return [ | ||
@@ -533,0 +529,0 @@ 4, |
@@ -40,30 +40,9 @@ import * as axios from 'axios'; | ||
}; | ||
interface NavigraphAuth { | ||
onAuthStateChanged: (callback: Listener) => Unsubscribe; | ||
signOut: () => void; | ||
getUser: () => User | null; | ||
signInWithDeviceFlow: (callback: DeviceFlowCallback) => Promise<User>; | ||
} | ||
/** | ||
* Initializes a device flow login sequence. | ||
* @param callback - A callback that will be called with the initial parameters, such as the QR code or the verification uri and code. | ||
* | ||
* See | ||
* {@link https://developers.navigraph.com/docs/authentication/device-authorization Device Authorization Flow With PKCE} and | ||
* {@link https://developers.navigraph.com/docs/authentication/pkce Proof Key for Code Exchange (PKCE)} for detailed documentation. | ||
* | ||
* @example | ||
* ```javascript | ||
* // Initialize device flow sequence | ||
* auth.signInWithDeviceFlow((p) => { | ||
* // Display the code to user & wait for user complete flow | ||
* }).then((u) => setUser(u)); | ||
* ``` | ||
* | ||
* @throws {@link NotInitializedError} - If the SDK is not initialized. | ||
* @throws {@link InvalidClientError} - If the client id or secret is invalid. | ||
* @throws {@link InvalidScopeError} - If the client contains one or several invalid scopes. | ||
* @throws {@link UserDeniedAccessError} - If the user denied access. | ||
* @throws {@link DeviceFlowTokenExpiredError} - If the user failed to authenticate within 5 mins. | ||
* | ||
* @async | ||
* @returns {Promise<User>} A promise that resolves with the user object. | ||
*/ | ||
declare function signInWithDeviceFlow(callback: DeviceFlowCallback): Promise<User>; | ||
interface AuthParameters { | ||
@@ -95,18 +74,6 @@ /** | ||
*/ | ||
declare const getAuth: ({ keys, storage }?: AuthParameters) => { | ||
/** Subscribes to changes to the authenticated user. | ||
* @example const unsubscribe = auth.onAuthStateChanged((u) => setUser(u)); | ||
*/ | ||
onAuthStateChanged: (callback: Listener) => Unsubscribe; | ||
/** Signs out the currently authenticated user. */ | ||
signOut: () => void; | ||
/** Grabs information about the currently authenticated user. | ||
* @returns {User|null} The currently authenticated user | ||
*/ | ||
getUser: () => User | null; | ||
signInWithDeviceFlow: typeof signInWithDeviceFlow; | ||
}; | ||
declare const getAuth: ({ keys, storage }?: AuthParameters) => NavigraphAuth; | ||
declare const navigraphRequest: axios.AxiosInstance; | ||
export { CustomStorage, DeviceFlowCallback, DeviceFlowParams, Listener, StorageKeys, Unsubscribe, User, getAuth, navigraphRequest }; | ||
export { CustomStorage, DeviceFlowCallback, DeviceFlowParams, Listener, NavigraphAuth, StorageKeys, Unsubscribe, User, getAuth, navigraphRequest }; |
@@ -387,3 +387,2 @@ // src/api.ts | ||
import axios3 from "axios"; | ||
var MAX_ATTEMPTS = 60; | ||
function signInWithDeviceFlow(callback) { | ||
@@ -462,5 +461,2 @@ return _signInWithDeviceFlow.apply(this, arguments); | ||
attempts = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : 0; | ||
if (attempts >= MAX_ATTEMPTS) { | ||
throw new Error("Unable to sign in with device flow. Max attempts reached."); | ||
} | ||
return [ | ||
@@ -467,0 +463,0 @@ 4, |
{ | ||
"name": "@navigraph/auth", | ||
"version": "2.0.9", | ||
"version": "2.0.10", | ||
"license": "MIT", | ||
@@ -43,3 +43,3 @@ "description": "Authentication with Navigraph services as part of the Navigraph SDK", | ||
"@navigraph/pkce": "^1.0.3", | ||
"@navigraph/app": "1.2.7", | ||
"@navigraph/app": "1.2.8", | ||
"axios": "^0.24.0" | ||
@@ -46,0 +46,0 @@ }, |
50516
1367
+ Added@navigraph/app@1.2.8(transitive)
- Removed@navigraph/app@1.2.7(transitive)
Updated@navigraph/app@1.2.8