@bcrumbs.net/bc-shared 0.0.3 → 0.0.4
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/index.esm.js +23 -23
- package/package.json +3 -4
- package/src/lib/services/auth/index.d.ts +0 -2
package/index.esm.js
CHANGED
|
@@ -2,8 +2,6 @@ import * as ReactJSXRuntime from 'react/jsx-runtime';
|
|
|
2
2
|
import i18n from 'i18next';
|
|
3
3
|
import { initReactI18next } from 'react-i18next';
|
|
4
4
|
import Backend from 'i18next-http-backend';
|
|
5
|
-
import decode from 'jwt-decode';
|
|
6
|
-
import { isAfter } from 'date-fns';
|
|
7
5
|
|
|
8
6
|
function _mergeNamespaces(n, m) {
|
|
9
7
|
m.forEach(function (e) {
|
|
@@ -10291,7 +10289,9 @@ const init = ({
|
|
|
10291
10289
|
.init({
|
|
10292
10290
|
lng: currentLng,
|
|
10293
10291
|
fallbackLng: systemDefaultLang,
|
|
10294
|
-
ns: '
|
|
10292
|
+
ns: ['common', 'inbox'],
|
|
10293
|
+
// define your namespaces
|
|
10294
|
+
defaultNS: 'common',
|
|
10295
10295
|
interpolation: {
|
|
10296
10296
|
escapeValue: false
|
|
10297
10297
|
},
|
|
@@ -10894,20 +10894,20 @@ const auth = {
|
|
|
10894
10894
|
* @param {string} encodedToken - base 64 token received from server and stored in local storage
|
|
10895
10895
|
* @returns {date | null} returns expiration date or null id expired props not found in decoded token
|
|
10896
10896
|
*/
|
|
10897
|
-
getTokenExpirationDate(encodedToken) {
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
},
|
|
10897
|
+
// getTokenExpirationDate(encodedToken: string): Date {
|
|
10898
|
+
// if (typeof window === 'undefined') {
|
|
10899
|
+
// return new Date(0);
|
|
10900
|
+
// }
|
|
10901
|
+
// if (!encodedToken) {
|
|
10902
|
+
// return new Date(0); // is expired
|
|
10903
|
+
// }
|
|
10904
|
+
// const token = decode<Token>(encodedToken);
|
|
10905
|
+
// if (!token.exp) {
|
|
10906
|
+
// return new Date(0); // is expired
|
|
10907
|
+
// }
|
|
10908
|
+
// const expirationDate = new Date(token.exp * 1000);
|
|
10909
|
+
// return expirationDate;
|
|
10910
|
+
// },
|
|
10911
10911
|
//TODO: Its not working for now while the token is not JWT token
|
|
10912
10912
|
/**
|
|
10913
10913
|
*
|
|
@@ -10916,12 +10916,12 @@ const auth = {
|
|
|
10916
10916
|
* @param {string} encodedToken - base 64 token received from server and stored in local storage
|
|
10917
10917
|
* @returns {bool} returns true if expired else false
|
|
10918
10918
|
*/
|
|
10919
|
-
isExpiredToken(encodedToken) {
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
},
|
|
10919
|
+
// isExpiredToken(encodedToken: string): boolean {
|
|
10920
|
+
// const expirationDate = this.getTokenExpirationDate(encodedToken);
|
|
10921
|
+
// const rightNow = new Date();
|
|
10922
|
+
// const isExpiredToken = isAfter(rightNow, expirationDate);
|
|
10923
|
+
// return isExpiredToken;
|
|
10924
|
+
// },
|
|
10925
10925
|
// /////////////////////////////////////////////////////////////
|
|
10926
10926
|
// USER_INFO
|
|
10927
10927
|
// /////////////////////////////////////////////////////////////
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bcrumbs.net/bc-shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"keyword": [
|
|
5
5
|
"bcrumbs",
|
|
6
6
|
"bc-shared",
|
|
@@ -12,11 +12,10 @@
|
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"i18next": "^21.6.14",
|
|
14
14
|
"react-i18next": "^11.15.6",
|
|
15
|
-
"
|
|
15
|
+
"i18next-http-backend": "^1.3.2"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"
|
|
19
|
-
"i18next-http-backend": "^1.3.2"
|
|
18
|
+
"date-fns": "^2.28.0"
|
|
20
19
|
},
|
|
21
20
|
"module": "./index.esm.js",
|
|
22
21
|
"type": "module",
|
|
@@ -63,7 +63,6 @@ export declare const auth: {
|
|
|
63
63
|
* @param {string} encodedToken - base 64 token received from server and stored in local storage
|
|
64
64
|
* @returns {date | null} returns expiration date or null id expired props not found in decoded token
|
|
65
65
|
*/
|
|
66
|
-
getTokenExpirationDate(encodedToken: string): Date;
|
|
67
66
|
/**
|
|
68
67
|
*
|
|
69
68
|
* tell is token is expired (compared to now)
|
|
@@ -71,7 +70,6 @@ export declare const auth: {
|
|
|
71
70
|
* @param {string} encodedToken - base 64 token received from server and stored in local storage
|
|
72
71
|
* @returns {bool} returns true if expired else false
|
|
73
72
|
*/
|
|
74
|
-
isExpiredToken(encodedToken: string): boolean;
|
|
75
73
|
/**
|
|
76
74
|
* get user info from localstorage
|
|
77
75
|
*
|