kuzzle-sdk
Advanced tools
Comparing version 7.11.3 to 7.12.0
@@ -1,1 +0,1 @@ | ||
/*! Kuzzle Javascript SDK version 7.11.3 */ | ||
/*! Kuzzle Javascript SDK version 7.12.0 */ |
{ | ||
"name": "kuzzle-sdk", | ||
"version": "7.11.3", | ||
"version": "7.12.0", | ||
"description": "Official Javascript SDK for Kuzzle", | ||
@@ -5,0 +5,0 @@ "author": "The Kuzzle Team <support@kuzzle.io>", |
@@ -308,2 +308,3 @@ "use strict"; | ||
}; | ||
this.kuzzle.emit("beforeLogin"); | ||
return this.query(request, { queuable: false, timeout: -1, verb: "POST" }) | ||
@@ -318,5 +319,10 @@ .then((response) => { | ||
}); | ||
this.kuzzle.emit("afterLogin", { | ||
error: err.message, | ||
success: false, | ||
}); | ||
throw err; | ||
} | ||
this.kuzzle.emit("loginAttempt", { success: true }); | ||
this.kuzzle.emit("afterLogin", { success: true }); | ||
return; | ||
@@ -326,2 +332,3 @@ } | ||
this.kuzzle.emit("loginAttempt", { success: true }); | ||
this.kuzzle.emit("afterLogin", { success: true }); | ||
return response.result.jwt; | ||
@@ -334,2 +341,6 @@ }) | ||
}); | ||
this.kuzzle.emit("afterLogin", { | ||
error: err.message, | ||
success: false, | ||
}); | ||
throw err; | ||
@@ -343,10 +354,30 @@ }); | ||
*/ | ||
logout() { | ||
return this.query({ | ||
action: "logout", | ||
cookieAuth: this.kuzzle.cookieAuthentication, | ||
}, { queuable: false, timeout: -1 }).then(() => { | ||
async logout() { | ||
this.kuzzle.emit("beforeLogout"); | ||
try { | ||
await this.query({ | ||
action: "logout", | ||
cookieAuth: this.kuzzle.cookieAuthentication, | ||
}, { queuable: false, timeout: -1 }); | ||
this._authenticationToken = null; | ||
/** | ||
* @deprecated logout `logoutAttempt` is legacy event. Use afterLogout instead. | ||
*/ | ||
this.kuzzle.emit("logoutAttempt", { success: true }); | ||
}); | ||
this.kuzzle.emit("afterLogout", { success: true }); | ||
} | ||
catch (error) { | ||
/** | ||
* @deprecated logout `logoutAttempt` is legacy event. Use afterLogout instead. | ||
*/ | ||
this.kuzzle.emit("logoutAttempt", { | ||
error: error.message, | ||
success: false, | ||
}); | ||
this.kuzzle.emit("afterLogout", { | ||
error: error.message, | ||
success: false, | ||
}); | ||
throw error; | ||
} | ||
} | ||
@@ -353,0 +384,0 @@ /** |
type ListenerFunction = (...args: unknown[]) => unknown; | ||
export type PublicKuzzleEvents = "callbackError" | "connected" | "discarded" | "disconnected" | "loginAttempt" | "logoutAttempt" | "networkError" | "offlineQueuePush" | "offlineQueuePop" | "queryError" | "reAuthenticated" | "reconnected" | "reconnectionError" | "tokenExpired"; | ||
export type PublicKuzzleEvents = "callbackError" | "connected" | "discarded" | "disconnected" | "loginAttempt" | "beforeLogin" | "afterLogin" | "logoutAttempt" | "beforeLogout" | "afterLogout" | "networkError" | "offlineQueuePush" | "offlineQueuePop" | "queryError" | "reAuthenticated" | "reconnected" | "reconnectionError" | "tokenExpired"; | ||
type PrivateKuzzleEvents = "connect" | "reconnect" | "disconnect" | "offlineQueuePush" | "websocketRenewalStart" | "websocketRenewalDone"; | ||
@@ -4,0 +4,0 @@ /** |
@@ -222,6 +222,8 @@ import { KuzzleEventEmitter, PrivateAndPublicSDKEvents, PublicKuzzleEvents } from "./core/KuzzleEventEmitter"; | ||
on(eventName: "connected" | "reconnected" | "reAuthenticated" | "tokenExpired", listener: () => void): this; | ||
on(eventName: "logoutAttempt", listener: (status: { | ||
on(eventName: "beforeLogout", listener: () => void): this; | ||
on(eventName: "logoutAttempt" | "afterLogout", listener: (status: { | ||
success: true; | ||
}) => void): this; | ||
on(eventName: "loginAttempt", listener: (data: { | ||
on(eventName: "beforeLogin", listener: () => void): this; | ||
on(eventName: "loginAttempt" | "afterLogin", listener: (data: { | ||
success: boolean; | ||
@@ -228,0 +230,0 @@ error: string; |
@@ -51,3 +51,7 @@ "use strict"; | ||
"loginAttempt", | ||
"beforeLogin", | ||
"afterLogin", | ||
"logoutAttempt", | ||
"beforeLogout", | ||
"afterLogout", | ||
"networkError", | ||
@@ -73,2 +77,3 @@ "offlineQueuePush", | ||
this._protectedEvents = { | ||
afterLogin: {}, | ||
connected: {}, | ||
@@ -164,3 +169,6 @@ disconnected: {}, | ||
this._loggedIn = false; | ||
this.on("loginAttempt", async (status) => { | ||
/** | ||
* When successfuly logged in | ||
*/ | ||
this.on("afterLogin", async (status) => { | ||
if (status.success) { | ||
@@ -183,3 +191,3 @@ this._loggedIn = true; | ||
*/ | ||
this.on("logoutAttempt", (status) => { | ||
this.on("afterLogout", (status) => { | ||
if (status.success) { | ||
@@ -186,0 +194,0 @@ this._loggedIn = false; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
559228
12500