@tapni/auth 1.0.36 → 1.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.
@@ -1390,7 +1390,7 @@ function _sfc_render$7(u, t, n, l, d, o) {
1390
1390
  const AuthWelcome = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$7], ["__scopeId", "data-v-cb61958b"]]), Welcome$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1391
1391
  __proto__: null,
1392
1392
  default: AuthWelcome
1393
- }, Symbol.toStringTag, { value: "Module" })), version$3 = "1.0.36", UserService = {
1393
+ }, Symbol.toStringTag, { value: "Module" })), version$3 = "1.0.37", UserService = {
1394
1394
  getMe() {
1395
1395
  return api$1().get("/users/me");
1396
1396
  },
@@ -5824,7 +5824,7 @@ Tanıştığınız herkesi etkileyin 😎 <br> Kendinize bir tane ayırın 👇`
5824
5824
  app_region: "지역",
5825
5825
  app_region_p: "맞춤형 결제 및 지원을 위해 지역을 선택하세요"
5826
5826
  }
5827
- }, Welcome = () => Promise.resolve().then(() => Welcome$1), Login$1 = () => Promise.resolve().then(() => Login), Register$1 = () => Promise.resolve().then(() => Register), Reset$1 = () => Promise.resolve().then(() => Reset), Account$1 = () => Promise.resolve().then(() => Account), Verify$1 = () => Promise.resolve().then(() => Verify), Callback$1 = () => Promise.resolve().then(() => Callback), QR = () => import("./QR-BvqUReyp.js"), Security$1 = () => Promise.resolve().then(() => Security), Apps = () => import("./Apps-I6gQf0Vn.js"), Billing = () => import("./Billing-BNev-aMg.js"), CustomApp = () => import("./CustomApp-CPx2mGJU.js"), General = () => import("./General-BiJJvGCh.js"), routes = [
5827
+ }, Welcome = () => Promise.resolve().then(() => Welcome$1), Login$1 = () => Promise.resolve().then(() => Login), Register$1 = () => Promise.resolve().then(() => Register), Reset$1 = () => Promise.resolve().then(() => Reset), Account$1 = () => Promise.resolve().then(() => Account), Verify$1 = () => Promise.resolve().then(() => Verify), Callback$1 = () => Promise.resolve().then(() => Callback), QR = () => import("./QR-BzZfdP0g.js"), Security$1 = () => Promise.resolve().then(() => Security), Apps = () => import("./Apps-DVN_XPTJ.js"), Billing = () => import("./Billing-Br-tdiyC.js"), CustomApp = () => import("./CustomApp-CHcb9znC.js"), General = () => import("./General-OQWiNYkq.js"), routes = [
5828
5828
  {
5829
5829
  path: "/welcome",
5830
5830
  name: "AuthWelcome",
@@ -5946,7 +5946,6 @@ Tanıştığınız herkesi etkileyin 😎 <br> Kendinize bir tane ayırın 👇`
5946
5946
  "https://designer.tapni.com",
5947
5947
  "https://designer-dev.tapni.com",
5948
5948
  "http://localhost:8082",
5949
- "http://192.168.1.107:7777",
5950
5949
  "http://localhost:7777",
5951
5950
  "http://localhost:7777",
5952
5951
  "https://localhost:7777",
@@ -37082,7 +37081,6 @@ const getRandomValues = (u) => {
37082
37081
  try {
37083
37082
  return window.crypto.getRandomValues(u);
37084
37083
  } catch {
37085
- console.log("Web Crypto API failed for getRandomValues, using Math.random fallback");
37086
37084
  for (let n = 0; n < u.length; n++)
37087
37085
  u[n] = Math.floor(Math.random() * 256);
37088
37086
  return u;
@@ -37091,7 +37089,6 @@ const getRandomValues = (u) => {
37091
37089
  try {
37092
37090
  return await window.crypto.subtle.digest("SHA-256", u);
37093
37091
  } catch {
37094
- console.log("Web Crypto API failed for digest, using js-sha256 fallback");
37095
37092
  const n = sha256Exports.sha256(u);
37096
37093
  return new Uint8Array(n.match(/.{1,2}/g).map((l) => parseInt(l, 16))).buffer;
37097
37094
  }
@@ -37099,13 +37096,13 @@ const getRandomValues = (u) => {
37099
37096
  try {
37100
37097
  return await window.crypto.subtle.encrypt(u, t, n);
37101
37098
  } catch {
37102
- throw console.log("Web Crypto API failed for encrypt, using fallback"), new Error("Encryption not supported in this environment");
37099
+ throw new Error("Encryption not supported in this environment");
37103
37100
  }
37104
37101
  }, performDecrypt = async (u, t, n) => {
37105
37102
  try {
37106
37103
  return await window.crypto.subtle.decrypt(u, t, n);
37107
37104
  } catch {
37108
- throw console.log("Web Crypto API failed for decrypt, using fallback"), new Error("Decryption not supported in this environment");
37105
+ throw new Error("Decryption not supported in this environment");
37109
37106
  }
37110
37107
  }, UtilService = {
37111
37108
  getFirstBrowserLanguage() {
@@ -37210,17 +37207,9 @@ const getRandomValues = (u) => {
37210
37207
  },
37211
37208
  async pkceChallengeFromVerifier(u) {
37212
37209
  try {
37213
- console.log("Creating TextEncoder");
37214
- const t = new TextEncoder();
37215
- console.log("Encoding verifier");
37216
- const n = t.encode(u);
37217
- console.log("Starting crypto digest");
37218
- const l = await performDigest(n);
37219
- console.log("Crypto digest completed");
37220
- const d = btoa(String.fromCharCode.apply(null, new Uint8Array(l))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
37221
- return console.log("Base64 encoding completed"), d;
37210
+ const n = new TextEncoder().encode(u), l = await performDigest(n);
37211
+ return btoa(String.fromCharCode.apply(null, new Uint8Array(l))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
37222
37212
  } catch {
37223
- console.log("Web Crypto API failed, falling back to js-sha256");
37224
37213
  const n = sha256Exports.sha256(u);
37225
37214
  return btoa(String.fromCharCode.apply(null, new Uint8Array(n.match(/.{1,2}/g).map((d) => parseInt(d, 16))))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
37226
37215
  }
@@ -37237,7 +37226,7 @@ const getRandomValues = (u) => {
37237
37226
  d
37238
37227
  );
37239
37228
  } catch (l) {
37240
- throw console.error("AES encryption failed:", l), l;
37229
+ throw l;
37241
37230
  }
37242
37231
  },
37243
37232
  async decryptAES(u, t, n) {
@@ -37250,7 +37239,7 @@ const getRandomValues = (u) => {
37250
37239
  let b = await performDecrypt({ name: "AES-CBC", iv: t }, y, n);
37251
37240
  return b = o.decode(b), b = b.replace(/ /g, "+"), b = atob(b), b;
37252
37241
  } catch (l) {
37253
- throw console.error("AES decryption failed:", l), l;
37242
+ throw l;
37254
37243
  }
37255
37244
  }
37256
37245
  }, OktaMixin = {
@@ -37326,28 +37315,20 @@ const getRandomValues = (u) => {
37326
37315
  closeWindow() {
37327
37316
  try {
37328
37317
  window.close();
37329
- } catch (u) {
37330
- console.error("Window close error", u);
37318
+ } catch {
37331
37319
  }
37332
37320
  },
37333
37321
  async samlLogin(u) {
37334
- console.log("SAMLLL2", u), this.code_verifier = UtilService.generateRandomString(28), localStorage.setItem("pkce_code_verifier", this.code_verifier), console.log("SAMLLL2.1");
37335
- try {
37336
- console.log("Starting PKCE challenge generation"), this.code_challenge = await UtilService.pkceChallengeFromVerifier(this.code_verifier), console.log("PKCE challenge generated successfully");
37337
- } catch (o) {
37338
- throw console.error("Error generating PKCE challenge:", o), o;
37339
- }
37340
- console.log("SAMLLL2.2");
37322
+ this.code_verifier = UtilService.generateRandomString(28), localStorage.setItem("pkce_code_verifier", this.code_verifier), this.code_challenge = await UtilService.pkceChallengeFromVerifier(this.code_verifier);
37341
37323
  const t = Capacitor$1.getPlatform();
37342
- console.log("SAMLLL2.3");
37343
37324
  let n = `code_challenge=${this.code_challenge}&platform=${t}&redirect_uri=${location.origin + "/app/callback/saml"}&realm=${this.realm}&display=${this.display}`, l = btoa(n);
37344
- console.log("SAMLLL2.4"), u = `${u}&RelayState=${l}`;
37325
+ u = `${u}&RelayState=${l}`;
37345
37326
  let d = this;
37346
37327
  window.addEventListener(
37347
37328
  "message",
37348
37329
  async (o) => {
37349
37330
  var E;
37350
- if (!this.allowedOriginsAuth.includes(o.origin)) return console.error("Origin is not allowed! " + o.origin);
37331
+ if (!this.allowedOriginsAuth.includes(o.origin)) return;
37351
37332
  const y = o.data.code, b = localStorage.getItem("pkce_code_verifier");
37352
37333
  if (y) {
37353
37334
  if (d.display === "popup")
@@ -37356,7 +37337,7 @@ const getRandomValues = (u) => {
37356
37337
  }
37357
37338
  },
37358
37339
  { once: !0 }
37359
- ), console.log("SAMLLL2.5"), console.log("SAMLLL2.6-NATIVE" + this.isNative), this.isNative ? (console.log("SAMLLL3"), this.popupWindow = await Browser.open({ url: u, presentationStyle: "popover" }), console.log("SAMLLL4")) : (this.checkInterval = setInterval(() => {
37340
+ ), this.isNative ? this.popupWindow = await Browser.open({ url: u, presentationStyle: "popover" }) : (this.checkInterval = setInterval(() => {
37360
37341
  var b;
37361
37342
  const o = localStorage.getItem("auth_code"), y = localStorage.getItem("pkce_code_verifier");
37362
37343
  o && (clearInterval(this.checkInterval), localStorage.removeItem("auth_code"), localStorage.removeItem("pkce_code_verifier"), (b = window.parent) == null || b.postMessage({ code: o, state: this.$route.query.state, code_verifier: y }, "*"), y && (this.display === "npm" || this.display === "redirect") && this.exchangeAuthCode({ code: o, code_verifier: y }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapni/auth",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "type": "module",
5
5
  "main": "./dist/TapniAuth.umd.js",
6
6
  "module": "./dist/TapniAuth.es.js",
@@ -64,4 +64,4 @@
64
64
  "vite": "^5.4.11",
65
65
  "vite-plugin-node-polyfills": "^0.22.0"
66
66
  }
67
- }
67
+ }
@@ -2,6 +2,7 @@ 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
7
  data() {
7
8
  return {
@@ -26,31 +27,21 @@ export default {
26
27
  try {
27
28
  window.close()
28
29
  } catch (e) {
29
- console.error('Window close error', e);
30
+ // Window close error
30
31
  }
31
32
  },
32
33
  async samlLogin(loginUrl) {
33
- console.log('SAMLLL2', loginUrl);
34
-
35
34
  // Create and store a new PKCE code_verifier (the plaintext random secret)
36
35
  this.code_verifier = UtilService.generateRandomString(28);
37
36
  localStorage.setItem("pkce_code_verifier", this.code_verifier);
38
- console.log('SAMLLL2.1');
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
- }
47
- console.log('SAMLLL2.2');
37
+
38
+ // Hash and base64-urlencode the secret to use as the challenge
39
+ this.code_challenge = await UtilService.pkceChallengeFromVerifier(this.code_verifier);
48
40
  const platform = Capacitor.getPlatform();
49
- console.log('SAMLLL2.3');
41
+
50
42
  // append public key as relayState
51
43
  let dataString = `code_challenge=${this.code_challenge}&platform=${platform}&redirect_uri=${location.origin + '/app/callback/saml'}&realm=${this.realm}&display=${this.display}`;
52
44
  let relayState = btoa(dataString);
53
- console.log('SAMLLL2.4');
54
45
  loginUrl = `${loginUrl}&RelayState=${relayState}`
55
46
 
56
47
  let self = this;
@@ -58,7 +49,7 @@ export default {
58
49
  window.addEventListener(
59
50
  'message',
60
51
  async (message) => {
61
- if (!this.allowedOriginsAuth.includes(message.origin)) return console.error('Origin is not allowed! ' + message.origin);
52
+ if (!this.allowedOriginsAuth.includes(message.origin)) return;
62
53
  const code = message.data.code;
63
54
  const pkce = localStorage.getItem('pkce_code_verifier');
64
55
  if (code) {
@@ -73,15 +64,9 @@ export default {
73
64
  },
74
65
  { once: true }
75
66
  );
76
- console.log('SAMLLL2.5');
77
- console.log('SAMLLL2.6-NATIVE' + this.isNative);
78
67
 
79
68
  if (this.isNative) {
80
- console.log('SAMLLL3');
81
-
82
69
  this.popupWindow = await Browser.open({ url: loginUrl, presentationStyle: 'popover' });
83
- console.log('SAMLLL4');
84
-
85
70
  } else {
86
71
  this.checkInterval = setInterval(() => {
87
72
  // check localStorage
@@ -13,7 +13,6 @@ const getRandomValues = (array) => {
13
13
  try {
14
14
  return window.crypto.getRandomValues(array);
15
15
  } catch (e) {
16
- console.log('Web Crypto API failed for getRandomValues, using Math.random fallback');
17
16
  for (let i = 0; i < array.length; i++) {
18
17
  array[i] = Math.floor(Math.random() * 256);
19
18
  }
@@ -26,7 +25,6 @@ const performDigest = async (data) => {
26
25
  try {
27
26
  return await window.crypto.subtle.digest('SHA-256', data);
28
27
  } catch (e) {
29
- console.log('Web Crypto API failed for digest, using js-sha256 fallback');
30
28
  const hash = sha256(data);
31
29
  return new Uint8Array(hash.match(/.{1,2}/g).map(byte => parseInt(byte, 16))).buffer;
32
30
  }
@@ -37,7 +35,6 @@ const performEncrypt = async (algorithm, key, data) => {
37
35
  try {
38
36
  return await window.crypto.subtle.encrypt(algorithm, key, data);
39
37
  } catch (e) {
40
- console.log('Web Crypto API failed for encrypt, using fallback');
41
38
  throw new Error('Encryption not supported in this environment');
42
39
  }
43
40
  };
@@ -47,7 +44,6 @@ const performDecrypt = async (algorithm, key, data) => {
47
44
  try {
48
45
  return await window.crypto.subtle.decrypt(algorithm, key, data);
49
46
  } catch (e) {
50
- console.log('Web Crypto API failed for decrypt, using fallback');
51
47
  throw new Error('Decryption not supported in this environment');
52
48
  }
53
49
  };
@@ -262,23 +258,15 @@ export default {
262
258
  },
263
259
  async pkceChallengeFromVerifier(v) {
264
260
  try {
265
- console.log('Creating TextEncoder');
266
261
  const encoder = new TextEncoder();
267
- console.log('Encoding verifier');
268
262
  const data = encoder.encode(v);
269
- console.log('Starting crypto digest');
270
263
  const hashed = await performDigest(data);
271
- console.log('Crypto digest completed');
272
- // base64 url encode
273
264
  const base64 = btoa(String.fromCharCode.apply(null, new Uint8Array(hashed)))
274
265
  .replace(/\+/g, '-')
275
266
  .replace(/\//g, '_')
276
267
  .replace(/=+$/, '');
277
- console.log('Base64 encoding completed');
278
268
  return base64;
279
269
  } catch (error) {
280
- console.log('Web Crypto API failed, falling back to js-sha256');
281
- // Fallback to js-sha256
282
270
  const hash = sha256(v);
283
271
  const base64 = btoa(String.fromCharCode.apply(null, new Uint8Array(hash.match(/.{1,2}/g).map(byte => parseInt(byte, 16)))))
284
272
  .replace(/\+/g, '-')
@@ -300,7 +288,6 @@ export default {
300
288
  encoded
301
289
  );
302
290
  } catch (error) {
303
- console.error('AES encryption failed:', error);
304
291
  throw error;
305
292
  }
306
293
  },
@@ -327,7 +314,6 @@ export default {
327
314
 
328
315
  return decoded;
329
316
  } catch (err) {
330
- console.error('AES decryption failed:', err);
331
317
  throw err;
332
318
  }
333
319
  }
package/src/store/auth.js CHANGED
@@ -63,7 +63,6 @@ export default {
63
63
  "https://designer.tapni.com",
64
64
  "https://designer-dev.tapni.com",
65
65
  "http://localhost:8082",
66
- "http://192.168.1.107:7777",
67
66
  "http://localhost:7777",
68
67
  "http://localhost:7777",
69
68
  "https://localhost:7777",