@cemiar/auth-sdk 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import
|
|
3
|
-
export interface UserInfo {
|
|
4
|
-
email: string;
|
|
5
|
-
displayName?: string;
|
|
6
|
-
}
|
|
2
|
+
import { AuthTokens, CemiarAuthClientInstance, CemiarAuthClientConfig, EmailCodeResponse, LogoutOptions, CreateApiClientOptions, UserInfo } from "../shared/Types.js";
|
|
7
3
|
export declare class CemiarAuthClient implements CemiarAuthClientInstance {
|
|
8
4
|
private readonly baseUrl;
|
|
9
5
|
private readonly tenantId;
|
|
@@ -100,9 +100,12 @@ export class CemiarAuthClient {
|
|
|
100
100
|
return { accessToken };
|
|
101
101
|
}
|
|
102
102
|
async logout(options = {}) {
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
this.
|
|
103
|
+
let loginMethod = options.method;
|
|
104
|
+
if (!loginMethod) {
|
|
105
|
+
loginMethod = this.getCurrentLoginMethod();
|
|
106
|
+
if (options.clearToken !== false) {
|
|
107
|
+
this.setAccessToken(null);
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
110
|
const redirectUrl = options.redirectUrl || this.logoutRedirectUrl;
|
|
108
111
|
const logoutPath = loginMethod === "microsoft" ? "/microsoft/logout" : "/logout";
|
package/dist/shared/Types.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
2
|
import type { Request, ResponseToolkit } from "@hapi/hapi";
|
|
3
|
-
|
|
3
|
+
export type LoginMethod = "emailCode" | "microsoft";
|
|
4
|
+
export interface UserInfo {
|
|
5
|
+
email: string;
|
|
6
|
+
displayName?: string;
|
|
7
|
+
}
|
|
4
8
|
export interface TokenStorage {
|
|
5
9
|
getToken(): string | null;
|
|
6
10
|
setToken(token: string | null): void;
|
|
@@ -43,6 +47,7 @@ export interface CreateApiClientOptions {
|
|
|
43
47
|
axiosConfig?: AxiosRequestConfig;
|
|
44
48
|
}
|
|
45
49
|
export interface LogoutOptions {
|
|
50
|
+
method?: LoginMethod;
|
|
46
51
|
redirectUrl?: string;
|
|
47
52
|
performRedirect?: boolean;
|
|
48
53
|
clearToken?: boolean;
|