@gofreego/tsutils 0.1.20 → 0.1.22
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.
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -10,6 +10,7 @@ interface HttpClientConfig {
|
|
|
10
10
|
baseURL?: string;
|
|
11
11
|
timeout?: number;
|
|
12
12
|
headers?: Record<string, string>;
|
|
13
|
+
onUnauthorized?: (error: HttpError) => void;
|
|
13
14
|
}
|
|
14
15
|
interface RequestConfig extends Omit<RequestInit, 'body'> {
|
|
15
16
|
params?: Record<string, string | number | boolean>;
|
|
@@ -36,6 +37,7 @@ declare class HttpClient {
|
|
|
36
37
|
private baseURL;
|
|
37
38
|
private timeout;
|
|
38
39
|
private defaultHeaders;
|
|
40
|
+
private onUnauthorized?;
|
|
39
41
|
constructor(config?: HttpClientConfig);
|
|
40
42
|
private buildURL;
|
|
41
43
|
private request;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ interface HttpClientConfig {
|
|
|
10
10
|
baseURL?: string;
|
|
11
11
|
timeout?: number;
|
|
12
12
|
headers?: Record<string, string>;
|
|
13
|
+
onUnauthorized?: (error: HttpError) => void;
|
|
13
14
|
}
|
|
14
15
|
interface RequestConfig extends Omit<RequestInit, 'body'> {
|
|
15
16
|
params?: Record<string, string | number | boolean>;
|
|
@@ -36,6 +37,7 @@ declare class HttpClient {
|
|
|
36
37
|
private baseURL;
|
|
37
38
|
private timeout;
|
|
38
39
|
private defaultHeaders;
|
|
40
|
+
private onUnauthorized?;
|
|
39
41
|
constructor(config?: HttpClientConfig);
|
|
40
42
|
private buildURL;
|
|
41
43
|
private request;
|
package/dist/index.js
CHANGED
|
@@ -603,6 +603,7 @@ var HttpClient = class {
|
|
|
603
603
|
this.baseURL = config.baseURL || "";
|
|
604
604
|
this.timeout = config.timeout || 3e4;
|
|
605
605
|
this.defaultHeaders = config.headers || {};
|
|
606
|
+
this.onUnauthorized = config.onUnauthorized;
|
|
606
607
|
}
|
|
607
608
|
buildURL(url, params) {
|
|
608
609
|
const fullURL = url.startsWith("http") ? url : `${this.baseURL}${url}`;
|
|
@@ -638,6 +639,9 @@ var HttpClient = class {
|
|
|
638
639
|
} catch {
|
|
639
640
|
error.data = { code: response.status, message: await response.text() };
|
|
640
641
|
}
|
|
642
|
+
if (response.status === 401 && this.onUnauthorized) {
|
|
643
|
+
this.onUnauthorized(error);
|
|
644
|
+
}
|
|
641
645
|
throw error;
|
|
642
646
|
}
|
|
643
647
|
const responseData = await response.json();
|
|
@@ -701,7 +705,7 @@ function LoginCallbackPage({ authService, navigateTo = "/", onLoginFailed }) {
|
|
|
701
705
|
onLoginFailed?.();
|
|
702
706
|
return;
|
|
703
707
|
}
|
|
704
|
-
authService.signInWithLoginToken({ loginToken }).then(() => {
|
|
708
|
+
authService.signInWithLoginToken({ loginToken, includePermissions: true }).then(() => {
|
|
705
709
|
navigate(navigateTo, { replace: true });
|
|
706
710
|
}).catch((err) => {
|
|
707
711
|
console.error("Login callback failed:", extractErrorMessage(err));
|