@tapni/auth 0.0.35 → 0.0.37

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.35",
3
+ "version": "0.0.37",
4
4
  "type": "module",
5
5
  "main": "./dist/TapniAuth.umd.js",
6
6
  "module": "./dist/TapniAuth.es.js",
package/src/App.vue CHANGED
@@ -94,7 +94,7 @@ export default {
94
94
  mixins: [AuthMixin],
95
95
  data () {
96
96
  return {
97
- initialized: false
97
+ isSetup: false
98
98
  }
99
99
  },
100
100
  components: {
@@ -112,6 +112,11 @@ export default {
112
112
  default: false
113
113
  }
114
114
  },
115
+ computed: {
116
+ initialized () {
117
+ return this.isSetup || this.isModal;
118
+ }
119
+ },
115
120
  async mounted() {
116
121
  this.applyBgStyle()
117
122
 
@@ -124,8 +129,8 @@ export default {
124
129
  async init () {
125
130
 
126
131
  // Make sure the function is called just once
127
- if (this.initialized) return;
128
- this.initialized = true;
132
+ if (this.isSetup) return;
133
+ this.isSetup = true;
129
134
 
130
135
  this.setToken(this.$storage.token);
131
136
  const refreshTokens = this.getRefreshTokens();
@@ -255,7 +255,9 @@ export default {
255
255
  }
256
256
 
257
257
  // Set new access token
258
- this.setToken(response.data.token);
258
+ if (response && response.data) {
259
+ this.setToken(response.data.token);
260
+ } else console.error('Invalid response setToken');
259
261
  },
260
262
  async login(data) {
261
263
  const [err, response] = await to(AuthService.login(data, this.$storage));
@@ -327,12 +329,7 @@ export default {
327
329
  }
328
330
  },
329
331
  async exchangeAuthCode(data) {
330
- const [err, response] = await to(
331
- axios.post(import.meta.env.VITE_APP_API_ROOT + "/v1/users/auth-code", {
332
- code: data.code,
333
- code_verifier: data.code_verifier,
334
- })
335
- );
332
+ const [err, response] = await to(AuthService.exchangeAuthCode(data, this.storage));
336
333
  if (err) return this.errorHandler(err);
337
334
  await this.loginSetup(response);
338
335
  await this.getLoggedInAccounts();
@@ -4,9 +4,15 @@ import { version } from "../../package.json"
4
4
  import AuthMixin from "../mixins/auth.mixin"
5
5
 
6
6
  export default (storage, refreshTokenAction = false) => {
7
- const appInfo = version
7
+ const appInfo = version;
8
+ let baseURL = import.meta.env.VITE_APP_API_ROOT + '/v1/';
9
+
10
+ if (location.hostname.includes('dev.')) {
11
+ baseURL = 'https://api-dev.tapni.co'
12
+ }
13
+
8
14
  let apiInstance = axios.create({
9
- baseURL: import.meta.env.VITE_APP_API_ROOT + '/v1/',
15
+ baseURL,
10
16
  headers: {
11
17
  Authorization: `Bearer ${storage.token}`,
12
18
  "X-Client-Name": "sso-" + appInfo.platform,
@@ -67,5 +67,8 @@ export default {
67
67
  },
68
68
  samlLoginUrl (data, storage) {
69
69
  return Api(storage).post('/saml/url', data)
70
- }
70
+ },
71
+ exchangeAuthCode (data, storage) {
72
+ return Api(storage).post('/v1/users/auth-code', data)
73
+ },
71
74
  }