@tapni/auth 0.0.121 → 0.0.129

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapni/auth",
3
- "version": "0.0.121",
3
+ "version": "0.0.129",
4
4
  "type": "module",
5
5
  "main": "./dist/TapniAuth.umd.js",
6
6
  "module": "./dist/TapniAuth.es.js",
@@ -34,7 +34,7 @@
34
34
  "@codetrix-studio/capacitor-google-auth": "^3.3.6",
35
35
  "@otplib/preset-browser": "^12.0.1",
36
36
  "@recognizebv/capacitor-plugin-msauth": "^3.5.1",
37
- "@tapni/capacitor-reactive-localstorage-vue3": "^0.0.15",
37
+ "@tapni/capacitor-reactive-localstorage-vue3": "^0.0.16",
38
38
  "@tapni/styles": "^0.0.3",
39
39
  "await-to-js": "^3.0.0",
40
40
  "axios": "^1.6.5",
package/src/App.vue CHANGED
@@ -96,7 +96,7 @@ import {EventBus} from "./store/event-bus.js";
96
96
  import AuthMixin from "@/mixins/auth.mixin.js";
97
97
  import Language from "@/components/Language.vue";
98
98
  import ReactiveStorage from '@tapni/capacitor-reactive-localstorage-vue3'
99
- import store from './store/store.js';
99
+ import store from './store/auth.js';
100
100
 
101
101
  export default {
102
102
  store,
@@ -152,7 +152,7 @@ export default {
152
152
  async mounted() {
153
153
  console.log('eey');
154
154
  this.applyBgStyle()
155
- this.$store.commit('setView', this.viewProp);
155
+ this.setView(this.viewProp);
156
156
 
157
157
  EventBus.$on('ssoEvent', this.ssoOutgoingEvent)
158
158
  EventBus.$on('ssoLogout',(data) => this.logout(data.refreshToken))
@@ -166,7 +166,7 @@ export default {
166
166
  console.log('initt');
167
167
 
168
168
  // Set $storage into vuex $storex
169
- this.$store.commit('setStorage', this.storage);
169
+ this.setStorage(this.$storage);
170
170
 
171
171
  // Make sure the function is called just once
172
172
  if (this.isSetup) return;
@@ -201,7 +201,7 @@ export default {
201
201
  display () {
202
202
  this.applyBgStyle()
203
203
  },
204
- 'storageReady.value' (nv) {
204
+ '$storageReady.value' (nv) {
205
205
  if (nv) {
206
206
  // Initialize Library after all event listeners & storage are set
207
207
  this.$nextTick(() => {
@@ -214,7 +214,7 @@ export default {
214
214
  clearInterval(this.storeInterval);
215
215
  this.storeInterval = setTimeout(() => {
216
216
  Object.keys(nv).forEach(key => {
217
- this.storage[key] = nv[key];
217
+ this.$storage[key] = nv[key];
218
218
  });
219
219
  }, 250)
220
220
  },
package/src/install.js CHANGED
@@ -1,17 +1,14 @@
1
- import Vue from 'vue'; // Import Vue
2
1
  import App from "./App.vue";
3
- import store from './store/store.js';
4
- import AuthMixin from './mixins/auth.mixin.js';
5
-
6
- // Register Vuex globally
7
- Vue.use(store);
2
+ import auth from './store/auth.js';
8
3
 
9
4
  // Export the component by default
10
5
  export default {
11
- TapniAuth: App,
12
- AuthMixin: AuthMixin,
13
- install: (app, options) => {
6
+ install: (app, rootStore) => {
14
7
  // Register the component
15
8
  app.component('TapniAuth', App);
9
+
10
+ if(!rootStore.hasModule('auth')) {
11
+ rootStore.registerModule('auth', auth);
12
+ }
16
13
  }
17
14
  };
@@ -1,4 +1,5 @@
1
- import { mapState, mapActions, mapGetters } from 'vuex';
1
+ import { createNamespacedHelpers } from 'vuex';
2
+ const { mapState, mapActions, mapGetters } = createNamespacedHelpers('auth');
2
3
  import GlobalMixin from './global.mixin'
3
4
 
4
5
  export default {
@@ -32,6 +33,8 @@ export default {
32
33
  'setRefreshToken',
33
34
  'unsetRefreshToken',
34
35
  'setToken',
36
+ 'setView',
37
+ 'setStorage',
35
38
  'setUserID',
36
39
  'updateLang',
37
40
  'login',
@@ -50,16 +53,20 @@ export default {
50
53
  'getLoggedInAccounts',
51
54
  'loginUsingQR',
52
55
  'getAccountSettings',
56
+ 'setRedirectUri',
57
+ 'setDisplay',
58
+ 'setState',
59
+ 'setResponseType',
53
60
  ])
54
61
  },
55
62
  watch: {
56
63
  "$route.query": {
57
64
  handler: function handler() {
58
- if (this.$route.query.redirect_uri) this.$store.dispatch('setRedirectUri', this.$route.query.redirect_uri);
59
- if (this.$route.query.display) this.$store.dispatch('setDisplay', this.$route.query.display);
60
- if (this.$route.query.state) this.$store.dispatch('setState', this.$route.query.state)
61
- if (this.$route.query.response_type) this.$store.dispatch('setResponseType', this.$route.query.response_type);
62
- if (this.$route.query.realm && this.$storage) this.$store.dispatch('setRealm', this.$route.query.realm);
65
+ if (this.$route.query.redirect_uri) this.setRedirectUri(this.$route.query.redirect_uri);
66
+ if (this.$route.query.display) this.setDisplay(this.$route.query.display);
67
+ if (this.$route.query.state) this.setState(this.$route.query.state)
68
+ if (this.$route.query.response_type) this.setResponseType(this.$route.query.response_type);
69
+ if (this.$route.query.realm && this.$storage) this.setRealm(this.$route.query.realm);
63
70
  },
64
71
  deep: true,
65
72
  },
@@ -3,19 +3,18 @@ import { jwtDecode } from "jwt-decode";
3
3
  import { version } from "../../package.json"
4
4
  import store from '../store/store.js';
5
5
 
6
-
7
6
  export default (refreshTokenAction = null) => {
8
7
  const appInfo = version;
9
8
  let baseURL = import.meta.env.VITE_APP_API_ROOT + '/v1/';
10
9
 
11
- if (store.getters.apiRoot) {
12
- baseURL = store.getters.apiRoot;
10
+ if (store.getters['auth/apiRoot']) {
11
+ baseURL = store.getters['auth/apiRoot'];
13
12
  }
14
13
 
15
14
  let apiInstance = axios.create({
16
15
  baseURL,
17
16
  headers: {
18
- Authorization: `Bearer ${store.getters.accessToken}`,
17
+ Authorization: `Bearer ${store.getters['auth/accessToken']}`,
19
18
  "X-Client-Name": "sso-" + appInfo.platform,
20
19
  "X-Client-Version": appInfo.version
21
20
  }
@@ -27,28 +26,28 @@ export default (refreshTokenAction = null) => {
27
26
  if (['post', 'put', 'delete'].includes(config.method.toLowerCase())) {
28
27
  config.data = {
29
28
  ...config.data,
30
- lang: store.getters.appLanguage,
31
- realm: store.getters.appRealm || 'app'
29
+ lang: store.getters['auth/appLanguage'],
30
+ realm: store.getters['auth/appRealm'] || 'app'
32
31
  }
33
32
  } else if (config.method.toLowerCase() === 'get') {
34
33
  config.params = {
35
34
  ...config.params,
36
- lang: store.getters.appLanguage,
37
- realm: store.getters.appRealm || 'app'
35
+ lang: store.getters['auth/appLanguage'],
36
+ realm: store.getters['auth/appRealm'] || 'app'
38
37
  }
39
38
  }
40
39
 
41
40
  // Check refresh token expiration before request is sent
42
- if (store.getters.accessToken && !refreshTokenAction) {
43
- const decoded = jwtDecode(store.getters.accessToken)
41
+ if (store.getters['auth/accessToken'] && !refreshTokenAction) {
42
+ const decoded = jwtDecode(store.getters['auth/accessToken'])
44
43
 
45
44
  // Check if access token expired
46
45
  if (decoded.exp - 30 < Math.floor(Date.now() / 1000)) {
47
- return store.dispatch('refreshTokenAction', decoded)
46
+ return store.dispatch('auth/refreshTokenAction', decoded)
48
47
  .then(() => {
49
48
  config.headers = {
50
49
  ...config.headers,
51
- Authorization: `Bearer ${store.getters.accessToken}`
50
+ Authorization: `Bearer ${store.getters['auth/accessToken']}`
52
51
  }
53
52
  return config;
54
53
  })