@tapni/auth 1.0.32 → 1.0.34
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/dist/.vite/manifest.json +12 -12
- package/dist/{Apps-Cv7avCHq.js → Apps-C9KmoF6K.js} +1 -1
- package/dist/{Billing-omz6Qf60.js → Billing-BSvAEp8b.js} +1 -1
- package/dist/{CustomApp-BHP2lUPX.js → CustomApp-_HtrExfL.js} +1 -1
- package/dist/{General-BjfncFzK.js → General-v9FBPbby.js} +1 -1
- package/dist/{QR-CRJQNQr7.js → QR-ngY6ULHB.js} +1 -1
- package/dist/TapniAuth.es.js +1 -1
- package/dist/TapniAuth.umd.js +38 -18
- package/dist/install-Cnxt-ehi.js +40202 -0
- package/package.json +9 -8
- package/src/mixins/saml.mixin.js +10 -4
- package/src/services/UtilService.js +91 -23
- package/dist/install-DBv1zzk3.js +0 -18344
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapni/auth",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.34",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/TapniAuth.umd.js",
|
|
6
6
|
"module": "./dist/TapniAuth.es.js",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@capacitor/device": "^6.0.2",
|
|
35
35
|
"@capacitor/preferences": "^6.0.3",
|
|
36
36
|
"@codetrix-studio/capacitor-google-auth": "^3.4.0-rc.4",
|
|
37
|
+
"@eslint/js": "^9.13.0",
|
|
37
38
|
"@otplib/preset-browser": "^12.0.1",
|
|
38
39
|
"@recognizebv/capacitor-plugin-msauth": "^3.6.3",
|
|
39
40
|
"@tapni/capacitor-reactive-localstorage-vue3": "^0.0.17",
|
|
@@ -41,20 +42,20 @@
|
|
|
41
42
|
"await-to-js": "^3.0.0",
|
|
42
43
|
"axios": "^1.7.8",
|
|
43
44
|
"buffer": "^6.0.3",
|
|
45
|
+
"eslint": "^9.13.0",
|
|
46
|
+
"eslint-config-prettier": "^9.1.0",
|
|
47
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
48
|
+
"eslint-plugin-vue": "^9.29.1",
|
|
49
|
+
"js-sha256": "^0.11.0",
|
|
44
50
|
"jwt-decode": "^4.0.0",
|
|
51
|
+
"prettier": "3.3.3",
|
|
45
52
|
"qr-code-styling": "^1.8.4",
|
|
46
53
|
"vue": "^3.5.13",
|
|
47
54
|
"vue-cookies": "^1.8.4",
|
|
48
55
|
"vue-router": "^4.5.0",
|
|
49
56
|
"vue3-select-component": "^0.7.0",
|
|
50
57
|
"vuex": "^4.1.0",
|
|
51
|
-
"vuex-router-sync": "v6.0.0-rc.1"
|
|
52
|
-
"prettier": "3.3.3",
|
|
53
|
-
"eslint": "^9.13.0",
|
|
54
|
-
"eslint-config-prettier": "^9.1.0",
|
|
55
|
-
"eslint-plugin-prettier": "^5.2.1",
|
|
56
|
-
"eslint-plugin-vue": "^9.29.1",
|
|
57
|
-
"@eslint/js": "^9.13.0"
|
|
58
|
+
"vuex-router-sync": "v6.0.0-rc.1"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@rollup/plugin-inject": "^5.0.5",
|
package/src/mixins/saml.mixin.js
CHANGED
|
@@ -3,7 +3,7 @@ import UtilService from '@/services/UtilService';
|
|
|
3
3
|
import { Capacitor } from "@capacitor/core";
|
|
4
4
|
import { EventBus } from '@/store/event-bus.js';
|
|
5
5
|
export default {
|
|
6
|
-
data
|
|
6
|
+
data() {
|
|
7
7
|
return {
|
|
8
8
|
code_verifier: '',
|
|
9
9
|
code_challenge: '',
|
|
@@ -15,7 +15,7 @@ export default {
|
|
|
15
15
|
computed: {
|
|
16
16
|
},
|
|
17
17
|
watch: {
|
|
18
|
-
'$route.path'
|
|
18
|
+
'$route.path'(nv) {
|
|
19
19
|
if (nv === '/callback/saml') {
|
|
20
20
|
this.handleSamlRedirect(nv)
|
|
21
21
|
}
|
|
@@ -36,8 +36,14 @@ export default {
|
|
|
36
36
|
this.code_verifier = UtilService.generateRandomString(28);
|
|
37
37
|
localStorage.setItem("pkce_code_verifier", this.code_verifier);
|
|
38
38
|
console.log('SAMLLL2.1');
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
try {
|
|
40
|
+
console.log('Starting PKCE challenge generation');
|
|
41
|
+
this.code_challenge = await UtilService.pkceChallengeFromVerifier(this.code_verifier);
|
|
42
|
+
console.log('PKCE challenge generated successfully');
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Error generating PKCE challenge:', error);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
41
47
|
console.log('SAMLLL2.2');
|
|
42
48
|
const platform = Capacitor.getPlatform();
|
|
43
49
|
console.log('SAMLLL2.3');
|
|
@@ -6,6 +6,51 @@ import itLocale from '../store/locales/it.js';
|
|
|
6
6
|
import frLocale from '../store/locales/fr.js';
|
|
7
7
|
import srLocale from '../store/locales/sr.js';
|
|
8
8
|
import trLocale from '../store/locales/tr';
|
|
9
|
+
import { sha256 } from 'js-sha256';
|
|
10
|
+
|
|
11
|
+
// Helper function to safely get random values
|
|
12
|
+
const getRandomValues = (array) => {
|
|
13
|
+
try {
|
|
14
|
+
return window.crypto.getRandomValues(array);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
console.log('Web Crypto API failed for getRandomValues, using Math.random fallback');
|
|
17
|
+
for (let i = 0; i < array.length; i++) {
|
|
18
|
+
array[i] = Math.floor(Math.random() * 256);
|
|
19
|
+
}
|
|
20
|
+
return array;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Helper function to safely perform crypto digest
|
|
25
|
+
const performDigest = async (data) => {
|
|
26
|
+
try {
|
|
27
|
+
return await window.crypto.subtle.digest('SHA-256', data);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.log('Web Crypto API failed for digest, using js-sha256 fallback');
|
|
30
|
+
const hash = sha256(data);
|
|
31
|
+
return new Uint8Array(hash.match(/.{1,2}/g).map(byte => parseInt(byte, 16))).buffer;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Helper function to safely perform crypto encrypt
|
|
36
|
+
const performEncrypt = async (algorithm, key, data) => {
|
|
37
|
+
try {
|
|
38
|
+
return await window.crypto.subtle.encrypt(algorithm, key, data);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.log('Web Crypto API failed for encrypt, using fallback');
|
|
41
|
+
throw new Error('Encryption not supported in this environment');
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Helper function to safely perform crypto decrypt
|
|
46
|
+
const performDecrypt = async (algorithm, key, data) => {
|
|
47
|
+
try {
|
|
48
|
+
return await window.crypto.subtle.decrypt(algorithm, key, data);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.log('Web Crypto API failed for decrypt, using fallback');
|
|
51
|
+
throw new Error('Decryption not supported in this environment');
|
|
52
|
+
}
|
|
53
|
+
};
|
|
9
54
|
|
|
10
55
|
export default {
|
|
11
56
|
getFirstBrowserLanguage() {
|
|
@@ -212,30 +257,52 @@ export default {
|
|
|
212
257
|
},
|
|
213
258
|
generateRandomString(length) {
|
|
214
259
|
let array = new Uint32Array(length);
|
|
215
|
-
|
|
260
|
+
getRandomValues(array);
|
|
216
261
|
return Array.from(array, (dec) => ('0' + dec.toString(16)).substr(-2)).join('');
|
|
217
262
|
},
|
|
218
263
|
async pkceChallengeFromVerifier(v) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
.
|
|
225
|
-
|
|
226
|
-
.
|
|
264
|
+
try {
|
|
265
|
+
console.log('Creating TextEncoder');
|
|
266
|
+
const encoder = new TextEncoder();
|
|
267
|
+
console.log('Encoding verifier');
|
|
268
|
+
const data = encoder.encode(v);
|
|
269
|
+
console.log('Starting crypto digest');
|
|
270
|
+
const hashed = await performDigest(data);
|
|
271
|
+
console.log('Crypto digest completed');
|
|
272
|
+
// base64 url encode
|
|
273
|
+
const base64 = btoa(String.fromCharCode.apply(null, new Uint8Array(hashed)))
|
|
274
|
+
.replace(/\+/g, '-')
|
|
275
|
+
.replace(/\//g, '_')
|
|
276
|
+
.replace(/=+$/, '');
|
|
277
|
+
console.log('Base64 encoding completed');
|
|
278
|
+
return base64;
|
|
279
|
+
} catch (error) {
|
|
280
|
+
console.log('Web Crypto API failed, falling back to js-sha256');
|
|
281
|
+
// Fallback to js-sha256
|
|
282
|
+
const hash = sha256(v);
|
|
283
|
+
const base64 = btoa(String.fromCharCode.apply(null, new Uint8Array(hash.match(/.{1,2}/g).map(byte => parseInt(byte, 16)))))
|
|
284
|
+
.replace(/\+/g, '-')
|
|
285
|
+
.replace(/\//g, '_')
|
|
286
|
+
.replace(/=+$/, '');
|
|
287
|
+
return base64;
|
|
288
|
+
}
|
|
227
289
|
},
|
|
228
|
-
encryptAES(key, iv, data) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
290
|
+
async encryptAES(key, iv, data) {
|
|
291
|
+
try {
|
|
292
|
+
let encoder = new TextEncoder();
|
|
293
|
+
let encoded = encoder.encode(data);
|
|
294
|
+
return await performEncrypt(
|
|
295
|
+
{
|
|
296
|
+
name: 'AES-CBC',
|
|
297
|
+
iv: iv
|
|
298
|
+
},
|
|
299
|
+
key,
|
|
300
|
+
encoded
|
|
301
|
+
);
|
|
302
|
+
} catch (error) {
|
|
303
|
+
console.error('AES encryption failed:', error);
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
239
306
|
},
|
|
240
307
|
async decryptAES(key, iv, data) {
|
|
241
308
|
try {
|
|
@@ -248,11 +315,11 @@ export default {
|
|
|
248
315
|
|
|
249
316
|
key = encoder.encode(key);
|
|
250
317
|
iv = encoder.encode(iv);
|
|
251
|
-
data = fromBase64(data
|
|
318
|
+
data = fromBase64(data);
|
|
252
319
|
|
|
253
320
|
const secretKey = await window.crypto.subtle.importKey('raw', key, 'AES-CBC', true, ['encrypt', 'decrypt']);
|
|
254
321
|
|
|
255
|
-
let decoded = await
|
|
322
|
+
let decoded = await performDecrypt({ name: 'AES-CBC', iv }, secretKey, data);
|
|
256
323
|
|
|
257
324
|
decoded = decoder.decode(decoded);
|
|
258
325
|
decoded = decoded.replace(/ /g, '+');
|
|
@@ -260,7 +327,8 @@ export default {
|
|
|
260
327
|
|
|
261
328
|
return decoded;
|
|
262
329
|
} catch (err) {
|
|
263
|
-
console.
|
|
330
|
+
console.error('AES decryption failed:', err);
|
|
331
|
+
throw err;
|
|
264
332
|
}
|
|
265
333
|
}
|
|
266
334
|
};
|