@tapni/auth 1.0.5 → 1.0.6-3.dev
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/README.md +2 -0
- package/dist/.vite/manifest.json +16 -43
- package/dist/.well-known/assetlinks.json +10 -12
- package/dist/.well-known/microsoft-identity-association.json +5 -5
- package/dist/{Apps-DMds3Dv-.js → Apps-XNA4_3B4.js} +34 -34
- package/dist/Billing-Br0-fHed.js +256 -0
- package/dist/CustomApp-CrlbYDOm.js +83 -0
- package/dist/QR-Bvqb60-E.js +41 -0
- package/dist/TapniAuth.es.js +1 -1
- package/dist/TapniAuth.umd.js +49 -23
- package/dist/{install-L-cxSovH.js → install-7FOVy8Ol.js} +6267 -4743
- package/dist/site.webmanifest +11 -1
- package/dist/style.css +1 -1
- package/dist/{web-IFGkBi0t.js → web-UrTMimK1.js} +2 -2
- package/package.json +65 -55
- package/src/.prettierrc.json +16 -0
- package/src/App.vue +326 -269
- package/src/eslint.config.js +15 -0
- package/src/index.js +4 -0
- package/src/install.js +9 -10
- package/src/main.js +54 -57
- package/src/mixins/apple.mixin.js +56 -54
- package/src/mixins/auth.mixin.js +3 -2
- package/src/mixins/global.mixin.js +3 -3
- package/src/mixins/google.mixin.js +53 -54
- package/src/mixins/microsoft.mixin.js +2 -5
- package/src/mixins/okta.mixin.js +1 -1
- package/src/mixins/qr-auth.mixin.js +111 -107
- package/src/mixins/saml.mixin.js +82 -45
- package/src/router/index.js +6 -6
- package/src/routes.js +1 -1
- package/src/services/Api.js +56 -58
- package/src/services/AuthService.js +7 -9
- package/src/services/CompanyService.js +10 -10
- package/src/services/DeviceService.js +3 -3
- package/src/services/UserService.js +48 -45
- package/src/services/UtilService.js +317 -225
- package/src/store/auth.js +485 -549
- package/src/store/constants.js +2 -2
- package/src/store/event-bus.js +22 -22
- package/src/store/locales/cn.js +476 -458
- package/src/store/locales/de.js +478 -517
- package/src/store/locales/en.js +454 -513
- package/src/store/locales/es.js +477 -524
- package/src/store/locales/fr.js +477 -516
- package/src/store/locales/it.js +477 -514
- package/src/store/locales/ja.js +488 -0
- package/src/store/locales/kr.js +477 -491
- package/src/store/locales/lang.js +51 -43
- package/src/store/locales/pt.js +488 -0
- package/src/store/locales/sr.js +477 -492
- package/src/store/locales/tr.js +477 -487
- package/src/store/store.js +6 -6
- package/src/views/Account.vue +36 -8
- package/src/views/Billing.vue +464 -34
- package/src/views/Callback.vue +36 -33
- package/src/views/General.vue +151 -185
- package/src/views/Login.vue +2 -25
- package/src/views/Register.vue +2 -12
- package/src/views/Reset.vue +132 -135
- package/src/views/Security.vue +13 -7
- package/src/views/Verify.vue +153 -151
- package/src/views/Welcome.vue +85 -71
- package/dist/Account-Cuz87g_8.js +0 -153
- package/dist/Billing-BXlQEuNy.js +0 -113
- package/dist/CustomApp-CLCMXmMO.js +0 -83
- package/dist/General-dW73bMoR.js +0 -479
- package/dist/QR-D6ZGcPM0.js +0 -41
- package/dist/index.css +0 -193
- package/dist/web-AXRKjAOB.js +0 -92
- package/src/components/DELETE_Language.vue +0 -168
- package/src/components/DELETE_LinkIcon.vue +0 -288
- package/src/components/DELETE_ModalOverlay.vue +0 -68
- package/src/components/DELETE_OTP.vue +0 -105
- package/src/components/DELETE_SSO.vue +0 -120
- package/src/components/DELETE_SSOPick.vue +0 -166
- package/src/mixins/DELETE_mfa-auth.mixin.js +0 -53
- package/src/mixins/facebook.mixin.js +0 -78
|
@@ -1,117 +1,121 @@
|
|
|
1
|
-
import to from 'await-to-js'
|
|
2
|
-
import CompanyService from '../services/CompanyService'
|
|
3
|
-
import {nextTick} from
|
|
4
|
-
import QRCodeStyling from
|
|
1
|
+
import to from 'await-to-js';
|
|
2
|
+
import CompanyService from '../services/CompanyService';
|
|
3
|
+
import { nextTick } from 'vue';
|
|
4
|
+
import QRCodeStyling from 'qr-code-styling';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
let result = "";
|
|
7
|
+
data() {
|
|
8
|
+
return {
|
|
9
|
+
isQrCodeLogin: false,
|
|
10
|
+
qrCode: null,
|
|
11
|
+
qrCodeHash: null,
|
|
12
|
+
qrCodeRefreshInterval: null,
|
|
13
|
+
poolingInterval: null
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
props: {
|
|
17
|
+
isModal: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
required: false,
|
|
20
|
+
default: false
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
computed: {
|
|
24
|
+
displayQRLogin() {
|
|
25
|
+
return this.$route.name === 'AuthLogin' && this.display !== 'npm';
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
mounted() {
|
|
29
|
+
if (this.$route.name === 'AuthQR') this.changeLoginToQr();
|
|
30
|
+
},
|
|
31
|
+
methods: {
|
|
32
|
+
async changeLoginToQr() {
|
|
33
|
+
this.isQrCodeLogin = true;
|
|
34
|
+
await nextTick();
|
|
35
|
+
await this.initQrCodeLogin();
|
|
36
|
+
},
|
|
37
|
+
generateRandomHash() {
|
|
38
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
39
|
+
const charactersLength = characters.length;
|
|
40
|
+
let result = '';
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// Create an array of 32-bit unsigned integers
|
|
43
|
+
const randomValues = new Uint32Array(32);
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
// Generate random values
|
|
46
|
+
window.crypto.getRandomValues(randomValues);
|
|
47
|
+
randomValues.forEach((value) => {
|
|
48
|
+
result += characters.charAt(value % charactersLength);
|
|
49
|
+
});
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
return result;
|
|
52
|
+
},
|
|
53
|
+
refreshQrCode() {
|
|
54
|
+
if (this.qrCode) {
|
|
55
|
+
document.getElementById('qrCodeContainer')?.childNodes[0]?.remove();
|
|
56
|
+
}
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
this.qrCodeHash = this.generateRandomHash();
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
60
|
+
this.qrCode = new QRCodeStyling({
|
|
61
|
+
width: 300,
|
|
62
|
+
height: 300,
|
|
63
|
+
type: 'png',
|
|
64
|
+
image: '',
|
|
65
|
+
imageOptions: {
|
|
66
|
+
margin: 15
|
|
67
|
+
},
|
|
68
|
+
data: this.qrCodeHash,
|
|
69
|
+
dotsOptions: {
|
|
70
|
+
type: 'extra-rounded',
|
|
71
|
+
color: '#000000'
|
|
72
|
+
},
|
|
73
|
+
cornersSquareOptions: {
|
|
74
|
+
type: 'extra-rounded',
|
|
75
|
+
color: '#000000'
|
|
76
|
+
},
|
|
77
|
+
cornersDotOptions: {
|
|
78
|
+
type: '',
|
|
79
|
+
color: '#000000'
|
|
80
|
+
},
|
|
81
|
+
backgroundOptions: {
|
|
82
|
+
color: '#ffffff00'
|
|
83
|
+
}
|
|
84
|
+
});
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
this.qrCode.append(document.getElementById('qrCodeContainer'));
|
|
87
|
+
},
|
|
88
|
+
async startQrCodePooling() {
|
|
89
|
+
this.poolingInterval = setInterval(async () => {
|
|
90
|
+
const [err, response] = await to(
|
|
91
|
+
CompanyService.qrCodePooling(
|
|
92
|
+
{
|
|
93
|
+
qrToken: this.qrCodeHash
|
|
94
|
+
},
|
|
95
|
+
this.$storex
|
|
96
|
+
)
|
|
97
|
+
);
|
|
98
|
+
if (err) return this.errorHandler(err);
|
|
99
|
+
if (response.data.auth_code) {
|
|
100
|
+
if (this.display !== 'popup') {
|
|
101
|
+
this.loginSetup({ ...response, isModal: this.isModal });
|
|
102
|
+
await this.getLoggedInAccounts();
|
|
103
|
+
}
|
|
100
104
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
this.loginSuccess({ ...response, isModal: this.isModal });
|
|
106
|
+
clearInterval(this.poolingInterval);
|
|
107
|
+
clearInterval(this.qrCodeRefreshInterval);
|
|
108
|
+
}
|
|
109
|
+
}, 2000);
|
|
110
|
+
},
|
|
107
111
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
112
|
+
async initQrCodeLogin() {
|
|
113
|
+
this.refreshQrCode();
|
|
114
|
+
await nextTick();
|
|
115
|
+
await this.startQrCodePooling();
|
|
116
|
+
this.qrCodeRefreshInterval = setInterval(() => {
|
|
117
|
+
this.refreshQrCode();
|
|
118
|
+
}, 60000);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
package/src/mixins/saml.mixin.js
CHANGED
|
@@ -2,86 +2,123 @@ import { Browser } from '@capacitor/browser';
|
|
|
2
2
|
import UtilService from '@/services/UtilService';
|
|
3
3
|
import { Capacitor } from "@capacitor/core";
|
|
4
4
|
import { EventBus } from '@/store/event-bus.js';
|
|
5
|
+
|
|
5
6
|
export default {
|
|
6
|
-
data
|
|
7
|
+
data() {
|
|
7
8
|
return {
|
|
8
9
|
code_verifier: '',
|
|
9
|
-
code_challenge: ''
|
|
10
|
-
|
|
10
|
+
code_challenge: '',
|
|
11
|
+
shouldCloseWindow: false,
|
|
12
|
+
popupWindow: null,
|
|
13
|
+
checkInterval: null
|
|
14
|
+
};
|
|
11
15
|
},
|
|
12
16
|
computed: {
|
|
13
17
|
},
|
|
14
18
|
watch: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
'$route.path'(nv) {
|
|
20
|
+
if (nv === '/callback/saml') {
|
|
21
|
+
this.handleSamlRedirect(nv)
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
|
-
*/
|
|
20
24
|
},
|
|
21
25
|
methods: {
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
closeWindow() {
|
|
27
|
+
try {
|
|
28
|
+
window.close()
|
|
29
|
+
} catch (e) {
|
|
30
|
+
// Window close error
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
async samlLogin(loginUrl) {
|
|
24
34
|
// Create and store a new PKCE code_verifier (the plaintext random secret)
|
|
25
35
|
this.code_verifier = UtilService.generateRandomString(28);
|
|
26
36
|
localStorage.setItem("pkce_code_verifier", this.code_verifier);
|
|
27
37
|
|
|
28
38
|
// Hash and base64-urlencode the secret to use as the challenge
|
|
29
39
|
this.code_challenge = await UtilService.pkceChallengeFromVerifier(this.code_verifier);
|
|
30
|
-
|
|
31
40
|
const platform = Capacitor.getPlatform();
|
|
32
41
|
|
|
33
42
|
// append public key as relayState
|
|
34
|
-
let dataString = `code_challenge=${this.code_challenge}&platform=${platform}&redirect_uri=${
|
|
43
|
+
let dataString = `code_challenge=${this.code_challenge}&platform=${platform}&redirect_uri=${location.origin + (this.display === 'npm' ? '/app' : '') + '/callback/saml'}&realm=${this.realm}&display=${this.display}`;
|
|
35
44
|
let relayState = btoa(dataString);
|
|
36
|
-
|
|
37
45
|
loginUrl = `${loginUrl}&RelayState=${relayState}`
|
|
38
46
|
|
|
39
47
|
let self = this;
|
|
40
48
|
|
|
41
|
-
window.addEventListener(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (this.
|
|
45
|
-
|
|
49
|
+
window.addEventListener(
|
|
50
|
+
'message',
|
|
51
|
+
async (message) => {
|
|
52
|
+
if (!this.allowedOriginsAuth.includes(message.origin)) return console.error('Origin is not allowed! ' + message.origin);
|
|
53
|
+
const code = message.data.code;
|
|
54
|
+
const pkce = localStorage.getItem('pkce_code_verifier');
|
|
55
|
+
if (code) {
|
|
56
|
+
if (self.display === 'popup') {
|
|
57
|
+
return window.parent?.postMessage({ code: code, state: message.data.state, code_verifier: pkce }, '*');
|
|
58
|
+
}
|
|
59
|
+
if (pkce) {
|
|
60
|
+
await self.exchangeAuthCode({ code: message.data.code, code_verifier: pkce });
|
|
61
|
+
localStorage.removeItem('pkce_code_verifier');
|
|
62
|
+
}
|
|
46
63
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}, { once: true });
|
|
64
|
+
},
|
|
65
|
+
{ once: true }
|
|
66
|
+
);
|
|
51
67
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
if (this.isNative) {
|
|
69
|
+
this.popupWindow = await Browser.open({ url: loginUrl, presentationStyle: 'popover' });
|
|
70
|
+
} else {
|
|
71
|
+
this.checkInterval = setInterval(() => {
|
|
72
|
+
// check localStorage
|
|
73
|
+
const code = localStorage.getItem('auth_code');
|
|
74
|
+
const pkce = localStorage.getItem('pkce_code_verifier');
|
|
75
|
+
|
|
76
|
+
if (code) {
|
|
77
|
+
clearInterval(this.checkInterval);
|
|
78
|
+
localStorage.removeItem('auth_code');
|
|
79
|
+
localStorage.removeItem('pkce_code_verifier');
|
|
80
|
+
|
|
81
|
+
// handle code exchange
|
|
82
|
+
window.parent?.postMessage({ code: code, state: this.$route.query.state, code_verifier: pkce }, '*');
|
|
83
|
+
|
|
84
|
+
if (pkce && (this.display === 'npm' || this.display === 'redirect')) {
|
|
85
|
+
this.exchangeAuthCode({ code, code_verifier: pkce });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, 500);
|
|
89
|
+
|
|
90
|
+
this.popupWindow = window.open(window.location.origin + (this.display === 'npm' ? '/app' : '') + '/callback/redirect?uri=' + btoa(loginUrl), 'popup', 'width=600,height=600');
|
|
55
91
|
}
|
|
56
|
-
else popupWindow = window.open(loginUrl, 'popup','width=600,height=600')
|
|
57
|
-
/*
|
|
58
|
-
popupWindow.addEventListener('beforeunload', () => {
|
|
59
|
-
console.log('window closed')
|
|
60
|
-
})
|
|
61
|
-
*/
|
|
62
92
|
},
|
|
63
93
|
async handleSamlRedirect() {
|
|
64
94
|
let code;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
window.
|
|
95
|
+
if (this.$route.query.code) {
|
|
96
|
+
code = this.$route.query.code
|
|
97
|
+
}
|
|
98
|
+
if (window.opener) {
|
|
99
|
+
window.opener.postMessage({ type: 'saml', code }, '*');
|
|
100
|
+
this.closeWindow();
|
|
70
101
|
} else {
|
|
71
|
-
if(this.isNative && this.isiOS) await Browser.close();
|
|
72
|
-
EventBus.$emit('ssoEvent', {name: 'setLoading', data: true})
|
|
73
|
-
if (this.$route.query.code) code = this.$route.query.code
|
|
74
|
-
|
|
75
|
-
console.log(this.display, {code});
|
|
102
|
+
if (this.isNative && this.isiOS) await Browser.close();
|
|
103
|
+
EventBus.$emit('ssoEvent', { name: 'setLoading', data: true });
|
|
76
104
|
|
|
77
105
|
if (code) {
|
|
78
|
-
if (this.display === 'popup') {
|
|
79
|
-
|
|
106
|
+
if (this.display === 'popup' || this.display === 'npm') {
|
|
107
|
+
localStorage.setItem('auth_code', code);
|
|
108
|
+
this.shouldCloseWindow = true;
|
|
109
|
+
window.parent?.postMessage({ code: code, state: this.$route.query.state }, '*');
|
|
110
|
+
this.closeWindow()
|
|
111
|
+
}
|
|
112
|
+
// TODO: Replace URLs with .env variables to support staging
|
|
113
|
+
if (this.display === 'redirect' || location.host === 'auth.tapni.com') {
|
|
114
|
+
let redirect_url = 'https://auth.tapni.com/callback/auth';
|
|
115
|
+
if (this.realm === 'dashboard') {
|
|
116
|
+
redirect_url = 'https://business.tapni.com/login'
|
|
117
|
+
}
|
|
118
|
+
return location.href = redirect_url + '?code=' + code + '&code_verifier=' + localStorage.getItem('pkce_code_verifier');
|
|
80
119
|
}
|
|
81
|
-
await this.exchangeAuthCode({code, code_verifier: localStorage.getItem("pkce_code_verifier")});
|
|
82
120
|
}
|
|
83
|
-
|
|
84
|
-
EventBus.$emit('ssoEvent', {name: 'setLoading', data: false})
|
|
121
|
+
EventBus.$emit('ssoEvent', { name: 'setLoading', data: false });
|
|
85
122
|
}
|
|
86
123
|
}
|
|
87
124
|
},
|
package/src/router/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createRouter, createWebHistory } from 'vue-router'
|
|
2
|
-
import routes from '../routes.js'
|
|
1
|
+
import { createRouter, createWebHistory } from 'vue-router';
|
|
2
|
+
import routes from '../routes.js';
|
|
3
3
|
|
|
4
4
|
const router = createRouter({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})
|
|
5
|
+
history: createWebHistory(import.meta.env.BASE_URL),
|
|
6
|
+
routes
|
|
7
|
+
});
|
|
8
8
|
|
|
9
|
-
export default router
|
|
9
|
+
export default router;
|
package/src/routes.js
CHANGED
package/src/services/Api.js
CHANGED
|
@@ -1,60 +1,58 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
import { jwtDecode } from
|
|
3
|
-
import { version } from
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { jwtDecode } from 'jwt-decode';
|
|
3
|
+
import { version } from '../../package.json';
|
|
4
4
|
import store from '../store/store.js';
|
|
5
5
|
|
|
6
|
-
export default (refreshTokenAction = null) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return apiInstance;
|
|
60
|
-
}
|
|
6
|
+
export default (refreshTokenAction = null, version = 'v1') => {
|
|
7
|
+
const appInfo = version;
|
|
8
|
+
let baseURL = import.meta.env.VITE_APP_API_ROOT + '/' + version + '/';
|
|
9
|
+
|
|
10
|
+
if (store.getters['auth/apiRoot']) {
|
|
11
|
+
baseURL = store.getters['auth/apiRoot'] + '/' + version + '/';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let apiInstance = axios.create({
|
|
15
|
+
baseURL,
|
|
16
|
+
headers: {
|
|
17
|
+
Authorization: `Bearer ${store.getters['auth/accessToken']}`,
|
|
18
|
+
'X-Client-Name': 'sso-' + appInfo.platform,
|
|
19
|
+
'X-Client-Version': appInfo.version
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Add a request interceptor
|
|
24
|
+
apiInstance.interceptors.request.use(async function (config) {
|
|
25
|
+
if (['post', 'put', 'delete'].includes(config.method.toLowerCase())) {
|
|
26
|
+
config.data = {
|
|
27
|
+
...config.data,
|
|
28
|
+
lang: store.getters['auth/appLanguage'],
|
|
29
|
+
realm: store.getters['auth/appRealm'] || 'app'
|
|
30
|
+
};
|
|
31
|
+
} else if (config.method.toLowerCase() === 'get') {
|
|
32
|
+
config.params = {
|
|
33
|
+
...config.params,
|
|
34
|
+
lang: store.getters['auth/appLanguage'],
|
|
35
|
+
realm: store.getters['auth/appRealm'] || 'app'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Check refresh token expiration before request is sent
|
|
40
|
+
if (store.getters['auth/accessToken'] && !refreshTokenAction) {
|
|
41
|
+
const decoded = jwtDecode(store.getters['auth/accessToken']);
|
|
42
|
+
|
|
43
|
+
// Check if access token expired
|
|
44
|
+
if (decoded.exp - 30 < Math.floor(Date.now() / 1000)) {
|
|
45
|
+
return store.dispatch('auth/refreshTokenAction', decoded).then(() => {
|
|
46
|
+
config.headers = {
|
|
47
|
+
...config.headers,
|
|
48
|
+
Authorization: `Bearer ${store.getters['auth/accessToken']}`
|
|
49
|
+
};
|
|
50
|
+
return config;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return config;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return apiInstance;
|
|
58
|
+
};
|
|
@@ -33,7 +33,13 @@ export default {
|
|
|
33
33
|
})
|
|
34
34
|
},
|
|
35
35
|
verify (data) {
|
|
36
|
-
return api().get('/users/verify
|
|
36
|
+
return api().get('/users/verify', {
|
|
37
|
+
params: {
|
|
38
|
+
c: data.code,
|
|
39
|
+
e: data.email,
|
|
40
|
+
captchatoken: data.captchaToken
|
|
41
|
+
}
|
|
42
|
+
});
|
|
37
43
|
},
|
|
38
44
|
googleUrl (storage) {
|
|
39
45
|
return api().get('/users/google/url')
|
|
@@ -42,18 +48,10 @@ export default {
|
|
|
42
48
|
data.device_id = deviceID
|
|
43
49
|
return api().post('/users/google', data)
|
|
44
50
|
},
|
|
45
|
-
facebook (data) {
|
|
46
|
-
data.device_id = deviceID
|
|
47
|
-
return api().post('/users/facebook', data)
|
|
48
|
-
},
|
|
49
51
|
googleSDK (data) {
|
|
50
52
|
data.device_id = deviceID
|
|
51
53
|
return api().post('/users/google/sdk', data)
|
|
52
54
|
},
|
|
53
|
-
facebookSDK (data) {
|
|
54
|
-
data.device_id = deviceID
|
|
55
|
-
return api().post('/users/facebook/sdk', data)
|
|
56
|
-
},
|
|
57
55
|
appleSDK (data) {
|
|
58
56
|
data.device_id = deviceID
|
|
59
57
|
return api().post('/users/apple/sdk', data)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import api from './Api';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
4
|
+
getBySSOEmail(email) {
|
|
5
|
+
return api().get(`/company/sso/${email}`);
|
|
6
|
+
},
|
|
7
|
+
acceptCompanyInvitation(code) {
|
|
8
|
+
return api().get(`/users/invitation?ic=${code}`);
|
|
9
|
+
},
|
|
10
|
+
qrCodePooling(payload) {
|
|
11
|
+
return api().post('/company/login/qr', payload);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -2,9 +2,9 @@ import api from './Api';
|
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
registerDevice(data) {
|
|
5
|
-
return api().post(`/devices/add`, data)
|
|
5
|
+
return api().post(`/devices/add`, data);
|
|
6
6
|
},
|
|
7
7
|
addFcmToken(data) {
|
|
8
|
-
return api().post(`/devices/fcm/add`, data)
|
|
8
|
+
return api().post(`/devices/fcm/add`, data);
|
|
9
9
|
}
|
|
10
|
-
}
|
|
10
|
+
};
|