@tapni/auth 1.0.33 → 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-DwrMoJ1K.js → Apps-C9KmoF6K.js} +1 -1
- package/dist/{Billing-Iza9L7mf.js → Billing-BSvAEp8b.js} +1 -1
- package/dist/{CustomApp-Bc4Ed5vg.js → CustomApp-_HtrExfL.js} +1 -1
- package/dist/{General-DfkudEbe.js → General-v9FBPbby.js} +1 -1
- package/dist/{QR-BO4Bxi-9.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/services/UtilService.js +75 -18
- package/dist/install-Dgoj6XAk.js +0 -18361
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",
|
|
@@ -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,7 +257,7 @@ 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) {
|
|
@@ -222,7 +267,7 @@ export default {
|
|
|
222
267
|
console.log('Encoding verifier');
|
|
223
268
|
const data = encoder.encode(v);
|
|
224
269
|
console.log('Starting crypto digest');
|
|
225
|
-
const hashed = await
|
|
270
|
+
const hashed = await performDigest(data);
|
|
226
271
|
console.log('Crypto digest completed');
|
|
227
272
|
// base64 url encode
|
|
228
273
|
const base64 = btoa(String.fromCharCode.apply(null, new Uint8Array(hashed)))
|
|
@@ -232,21 +277,32 @@ export default {
|
|
|
232
277
|
console.log('Base64 encoding completed');
|
|
233
278
|
return base64;
|
|
234
279
|
} catch (error) {
|
|
235
|
-
console.
|
|
236
|
-
|
|
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;
|
|
237
288
|
}
|
|
238
289
|
},
|
|
239
|
-
encryptAES(key, iv, data) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
+
}
|
|
250
306
|
},
|
|
251
307
|
async decryptAES(key, iv, data) {
|
|
252
308
|
try {
|
|
@@ -259,11 +315,11 @@ export default {
|
|
|
259
315
|
|
|
260
316
|
key = encoder.encode(key);
|
|
261
317
|
iv = encoder.encode(iv);
|
|
262
|
-
data = fromBase64(data
|
|
318
|
+
data = fromBase64(data);
|
|
263
319
|
|
|
264
320
|
const secretKey = await window.crypto.subtle.importKey('raw', key, 'AES-CBC', true, ['encrypt', 'decrypt']);
|
|
265
321
|
|
|
266
|
-
let decoded = await
|
|
322
|
+
let decoded = await performDecrypt({ name: 'AES-CBC', iv }, secretKey, data);
|
|
267
323
|
|
|
268
324
|
decoded = decoder.decode(decoded);
|
|
269
325
|
decoded = decoded.replace(/ /g, '+');
|
|
@@ -271,7 +327,8 @@ export default {
|
|
|
271
327
|
|
|
272
328
|
return decoded;
|
|
273
329
|
} catch (err) {
|
|
274
|
-
console.
|
|
330
|
+
console.error('AES decryption failed:', err);
|
|
331
|
+
throw err;
|
|
275
332
|
}
|
|
276
333
|
}
|
|
277
334
|
};
|