@leav/ui 0.3.5-7c2bdc0 → 0.3.6-93b3e08
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/_utils/__mocks__/isDevEnv.d.ts +1 -0
- package/dist/_utils/__mocks__/{isDevelopmentHelper.js → isDevEnv.js} +2 -2
- package/dist/_utils/__mocks__/isDevEnv.js.map +1 -0
- package/dist/_utils/isDevEnv.d.ts +1 -0
- package/dist/_utils/{isDevelopmentHelper.js → isDevEnv.js} +2 -2
- package/dist/_utils/isDevEnv.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useAuth/useAuth.js.map +1 -1
- package/dist/hooks/useLoginChecker/index.d.ts +1 -0
- package/dist/hooks/{useRefreshToken → useLoginChecker}/index.js +1 -1
- package/dist/hooks/{useRefreshToken → useLoginChecker}/index.js.map +1 -1
- package/dist/hooks/useLoginChecker/useLoginChecker.d.ts +3 -0
- package/dist/hooks/useLoginChecker/useLoginChecker.js +17 -0
- package/dist/hooks/useLoginChecker/useLoginChecker.js.map +1 -0
- package/dist/hooks/useRedirectToLogin/index.d.ts +1 -0
- package/dist/hooks/useRedirectToLogin/index.js +5 -0
- package/dist/hooks/useRedirectToLogin/index.js.map +1 -0
- package/dist/hooks/useRedirectToLogin/useRedirectToLogin.d.ts +3 -0
- package/dist/hooks/useRedirectToLogin/useRedirectToLogin.js +15 -0
- package/dist/hooks/useRedirectToLogin/useRedirectToLogin.js.map +1 -0
- package/package.json +1 -1
- package/dist/_utils/__mocks__/isDevelopmentHelper.d.ts +0 -1
- package/dist/_utils/__mocks__/isDevelopmentHelper.js.map +0 -1
- package/dist/_utils/isDevelopmentHelper.d.ts +0 -1
- package/dist/_utils/isDevelopmentHelper.js.map +0 -1
- package/dist/hooks/useRefreshToken/index.d.ts +0 -1
- package/dist/hooks/useRefreshToken/useRefreshToken.d.ts +0 -3
- package/dist/hooks/useRefreshToken/useRefreshToken.js +0 -27
- package/dist/hooks/useRefreshToken/useRefreshToken.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isDevEnv: () => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copyright LEAV Solutions 2017
|
|
2
2
|
// This file is released under LGPL V3
|
|
3
3
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
-
export const
|
|
5
|
-
//# sourceMappingURL=
|
|
4
|
+
export const isDevEnv = () => false;
|
|
5
|
+
//# sourceMappingURL=isDevEnv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDevEnv.js","sourceRoot":"","sources":["../../../src/_utils/__mocks__/isDevEnv.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AACtE,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isDevEnv: () => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copyright LEAV Solutions 2017
|
|
2
2
|
// This file is released under LGPL V3
|
|
3
3
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
-
export const
|
|
5
|
-
//# sourceMappingURL=
|
|
4
|
+
export const isDevEnv = () => import.meta.env.DEV;
|
|
5
|
+
//# sourceMappingURL=isDevEnv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDevEnv.js","sourceRoot":"","sources":["../../src/_utils/isDevEnv.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AACtE,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { default as useLang } from './useLang';
|
|
|
8
8
|
export { default as useLocalStorage } from './useLocalStorage';
|
|
9
9
|
export { default as useRecordsConsultationHistory } from './useRecordsConsultationHistory';
|
|
10
10
|
export { useRefreshFieldValues } from './useRefreshFieldValues';
|
|
11
|
-
export { default as
|
|
11
|
+
export { default as useLoginChecker } from './useLoginChecker';
|
|
12
|
+
export { default as useRedirectToLogin } from './useRedirectToLogin';
|
|
12
13
|
export { useUser } from './useUser';
|
|
13
14
|
export { useValuesCacheUpdate } from './useValuesCacheUpdate';
|
package/dist/hooks/index.js
CHANGED
|
@@ -11,7 +11,8 @@ export { default as useLang } from './useLang';
|
|
|
11
11
|
export { default as useLocalStorage } from './useLocalStorage';
|
|
12
12
|
export { default as useRecordsConsultationHistory } from './useRecordsConsultationHistory';
|
|
13
13
|
export { useRefreshFieldValues } from './useRefreshFieldValues';
|
|
14
|
-
export { default as
|
|
14
|
+
export { default as useLoginChecker } from './useLoginChecker';
|
|
15
|
+
export { default as useRedirectToLogin } from './useRedirectToLogin';
|
|
15
16
|
export { useUser } from './useUser';
|
|
16
17
|
export { useValuesCacheUpdate } from './useValuesCacheUpdate';
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AAEtE,OAAO,EAAC,0BAA0B,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAC,+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,OAAO,IAAI,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../../src/hooks/useAuth/useAuth.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;
|
|
1
|
+
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../../src/hooks/useAuth/useAuth.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AAMtE,SAAS,OAAO;IACZ,OAAO;QACH,MAAM,EAAE,KAAK,IAAI,EAAE;YACf,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE,EAAC,MAAM,EAAE,MAAM,EAAC,CAAC,CAAC;YAC/D,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,IAAI,IAAI,EAAE,WAAW,EAAE;gBACnB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACzC,OAAO;aACV;YACD,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC7B,CAAC;KACJ,CAAC;AACN,CAAC;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './useLoginChecker';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copyright LEAV Solutions 2017
|
|
2
2
|
// This file is released under LGPL V3
|
|
3
3
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
-
export { default } from './
|
|
4
|
+
export { default } from './useLoginChecker';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/useLoginChecker/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright LEAV Solutions 2017
|
|
2
|
+
// This file is released under LGPL V3
|
|
3
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
+
export default function useLoginChecker() {
|
|
5
|
+
return {
|
|
6
|
+
loginChecker: async () => {
|
|
7
|
+
const res = await fetch('/auth/login-checker', {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
headers: { 'Content-Type': 'application/json' }
|
|
10
|
+
});
|
|
11
|
+
if (!res.ok) {
|
|
12
|
+
throw new Error(res.statusText, { cause: res });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=useLoginChecker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLoginChecker.js","sourceRoot":"","sources":["../../../src/hooks/useLoginChecker/useLoginChecker.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AACtE,MAAM,CAAC,OAAO,UAAU,eAAe;IACnC,OAAO;QACH,YAAY,EAAE,KAAK,IAAI,EAAE;YACrB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,qBAAqB,EAAE;gBAC3C,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAC,cAAc,EAAE,kBAAkB,EAAC;aAChD,CAAC,CAAC;YAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,EAAC,KAAK,EAAE,GAAG,EAAC,CAAC,CAAC;aACjD;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './useRedirectToLogin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/useRedirectToLogin/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright LEAV Solutions 2017
|
|
2
|
+
// This file is released under LGPL V3
|
|
3
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
+
import { isDevEnv } from '../../_utils/isDevEnv';
|
|
5
|
+
export default function useRedirectToLogin() {
|
|
6
|
+
return {
|
|
7
|
+
redirectToLogin: async () => {
|
|
8
|
+
if (isDevEnv()) {
|
|
9
|
+
return window.location.replace(`${window.location.origin}/app/login/?dest=${window.location.pathname}`);
|
|
10
|
+
}
|
|
11
|
+
return window.location.reload();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=useRedirectToLogin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRedirectToLogin.js","sourceRoot":"","sources":["../../../src/hooks/useRedirectToLogin/useRedirectToLogin.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,OAAO,UAAU,kBAAkB;IACtC,OAAO;QACH,eAAe,EAAE,KAAK,IAAI,EAAE;YACxB,IAAI,QAAQ,EAAE,EAAE;gBACZ,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,oBAAoB,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;aAC3G;YACD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpC,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isDevelopmentHelper: () => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isDevelopmentHelper.js","sourceRoot":"","sources":["../../../src/_utils/__mocks__/isDevelopmentHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AACtE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isDevelopmentHelper: () => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isDevelopmentHelper.js","sourceRoot":"","sources":["../../src/_utils/isDevelopmentHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AACtE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './useRefreshToken';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Copyright LEAV Solutions 2017
|
|
2
|
-
// This file is released under LGPL V3
|
|
3
|
-
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
-
import { isDevelopmentHelper } from '../../_utils/isDevelopmentHelper';
|
|
5
|
-
const _redirectToLogin = () => window.location.replace(`${window.location.origin}/app/login/?dest=${window.location.pathname}`);
|
|
6
|
-
export default function useRefreshToken() {
|
|
7
|
-
return {
|
|
8
|
-
refreshToken: async (autoReload = true) => {
|
|
9
|
-
const res = await fetch('/auth/refresh', {
|
|
10
|
-
method: 'POST',
|
|
11
|
-
headers: { 'Content-Type': 'application/json' }
|
|
12
|
-
});
|
|
13
|
-
// If we didn't get a 2xx response, reload the page and let the back handle auth, unless we explicitly
|
|
14
|
-
// ask not to reload (e.g. in login app)
|
|
15
|
-
if (!res.ok) {
|
|
16
|
-
if (autoReload) {
|
|
17
|
-
if (isDevelopmentHelper()) {
|
|
18
|
-
return _redirectToLogin();
|
|
19
|
-
}
|
|
20
|
-
return window.location.reload();
|
|
21
|
-
}
|
|
22
|
-
throw new Error(res.statusText, { cause: res });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=useRefreshToken.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRefreshToken.js","sourceRoot":"","sources":["../../../src/hooks/useRefreshToken/useRefreshToken.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AAEnE,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAC1B,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,oBAAoB,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;AAErG,MAAM,CAAC,OAAO,UAAU,eAAe;IACnC,OAAO;QACH,YAAY,EAAE,KAAK,EAAE,aAAsB,IAAI,EAAE,EAAE;YAC/C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,eAAe,EAAE;gBACrC,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAC,cAAc,EAAE,kBAAkB,EAAC;aAChD,CAAC,CAAC;YAEH,sGAAsG;YACtG,wCAAwC;YACxC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;gBACT,IAAI,UAAU,EAAE;oBACZ,IAAI,mBAAmB,EAAE,EAAE;wBACvB,OAAO,gBAAgB,EAAE,CAAC;qBAC7B;oBACD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;iBACnC;gBAED,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,EAAC,KAAK,EAAE,GAAG,EAAC,CAAC,CAAC;aACjD;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
|