@bcrumbs.net/bc-shared 0.0.2 → 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 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) {
@@ -10280,7 +10278,10 @@ $$3({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }
10280
10278
  // import LanguageDetector from 'i18next-browser-languagedetector';
10281
10279
  const LOCAL_STORAGE_I18N_STRING = 'I18N_SELECTION';
10282
10280
  const systemDefaultLang = 'en';
10283
- const init = () => {
10281
+ const init = ({
10282
+ version,
10283
+ customPath
10284
+ }) => {
10284
10285
  const currentLng = localStorage.getItem(LOCAL_STORAGE_I18N_STRING) || systemDefaultLang;
10285
10286
  i18n.use(Backend) // load translation using http
10286
10287
  // .use(LanguageDetector) // detect user language
@@ -10288,13 +10289,15 @@ const init = () => {
10288
10289
  .init({
10289
10290
  lng: currentLng,
10290
10291
  fallbackLng: systemDefaultLang,
10291
- ns: 'translation',
10292
+ ns: ['common', 'inbox'],
10293
+ // define your namespaces
10294
+ defaultNS: 'common',
10292
10295
  interpolation: {
10293
10296
  escapeValue: false
10294
10297
  },
10295
10298
  load: 'languageOnly',
10296
10299
  backend: {
10297
- loadPath: '/assets/locales/{{lng}}/{{ns}}.json'
10300
+ loadPath: customPath ? customPath : `/assets/locales/{{lng}}/{{ns}}.json?v=${version !== null && version !== void 0 ? version : ''}`
10298
10301
  }
10299
10302
  });
10300
10303
  };
@@ -10891,20 +10894,20 @@ const auth = {
10891
10894
  * @param {string} encodedToken - base 64 token received from server and stored in local storage
10892
10895
  * @returns {date | null} returns expiration date or null id expired props not found in decoded token
10893
10896
  */
10894
- getTokenExpirationDate(encodedToken) {
10895
- if (typeof window === 'undefined') {
10896
- return new Date(0);
10897
- }
10898
- if (!encodedToken) {
10899
- return new Date(0); // is expired
10900
- }
10901
- const token = decode(encodedToken);
10902
- if (!token.exp) {
10903
- return new Date(0); // is expired
10904
- }
10905
- const expirationDate = new Date(token.exp * 1000);
10906
- return expirationDate;
10907
- },
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
+ // },
10908
10911
  //TODO: Its not working for now while the token is not JWT token
10909
10912
  /**
10910
10913
  *
@@ -10913,12 +10916,12 @@ const auth = {
10913
10916
  * @param {string} encodedToken - base 64 token received from server and stored in local storage
10914
10917
  * @returns {bool} returns true if expired else false
10915
10918
  */
10916
- isExpiredToken(encodedToken) {
10917
- const expirationDate = this.getTokenExpirationDate(encodedToken);
10918
- const rightNow = new Date();
10919
- const isExpiredToken = isAfter(rightNow, expirationDate);
10920
- return isExpiredToken;
10921
- },
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
+ // },
10922
10925
  // /////////////////////////////////////////////////////////////
10923
10926
  // USER_INFO
10924
10927
  // /////////////////////////////////////////////////////////////
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bcrumbs.net/bc-shared",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "keyword": [
5
5
  "bcrumbs",
6
6
  "bc-shared",
@@ -12,15 +12,10 @@
12
12
  "peerDependencies": {
13
13
  "i18next": "^21.6.14",
14
14
  "react-i18next": "^11.15.6",
15
- "date-fns": "^2.28.0"
15
+ "i18next-http-backend": "^1.3.2"
16
16
  },
17
17
  "dependencies": {
18
- "jwt-decode": "^3.1.2",
19
- "i18next-browser-languagedetector": "^6.1.3",
20
- "i18next-http-backend": "^1.3.2",
21
- "next-with-apollo": "^5.3.0",
22
- "apollo-cache-inmemory": "^1.6.6",
23
- "apollo-link-http": "^1.5.17"
18
+ "date-fns": "^2.28.0"
24
19
  },
25
20
  "module": "./index.esm.js",
26
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
  *
@@ -1,6 +1,9 @@
1
1
  export declare const LOCAL_STORAGE_I18N_STRING = "I18N_SELECTION";
2
2
  export declare const LangService: {
3
- init: () => void;
3
+ init: ({ version, customPath, }: {
4
+ version?: string;
5
+ customPath?: string;
6
+ }) => void;
4
7
  changeLang: (lang: Languages) => void;
5
8
  getLang: () => string;
6
9
  };