@tapni/auth 1.0.13 → 1.0.14

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.
@@ -1397,7 +1397,7 @@ function pa(n, e, t, r, o, i) {
1397
1397
  const ao = /* @__PURE__ */ _t(oa, [["render", pa], ["__scopeId", "data-v-7aad6400"]]), ha = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1398
1398
  __proto__: null,
1399
1399
  default: ao
1400
- }, Symbol.toStringTag, { value: "Module" })), fa = "1.0.12", cr = {
1400
+ }, Symbol.toStringTag, { value: "Module" })), fa = "1.0.14", cr = {
1401
1401
  getMe() {
1402
1402
  return le().get("/users/me");
1403
1403
  },
@@ -5563,7 +5563,7 @@ Tanıştığınız herkesi etkileyin 😎 <br> Kendinize bir tane ayırın 👇`
5563
5563
  choose_other_login_methods: "다른 로그인 방법 선택하기",
5564
5564
  no_sso_logins: "귀하의 회사는 SSO 로그인을 사용하지 않습니다. 관리자에게 문의하십시오."
5565
5565
  }
5566
- }, To = () => Promise.resolve().then(() => ha), ma = () => Promise.resolve().then(() => mc), _a = () => Promise.resolve().then(() => cl), va = () => Promise.resolve().then(() => Xu), ya = () => Promise.resolve().then(() => zc), wa = () => Promise.resolve().then(() => Cl), ba = () => Promise.resolve().then(() => od), ka = () => import("./QR-ShTn8gSL.js"), Ca = () => Promise.resolve().then(() => Cu), Ea = () => import("./Apps-DeRIQjBx.js"), Ta = () => import("./Billing-DsilesKo.js"), Sa = () => import("./CustomApp-CEzhE2YM.js"), Ia = () => import("./General-C9CUD54h.js"), Aa = [
5566
+ }, To = () => Promise.resolve().then(() => ha), ma = () => Promise.resolve().then(() => mc), _a = () => Promise.resolve().then(() => cl), va = () => Promise.resolve().then(() => Xu), ya = () => Promise.resolve().then(() => zc), wa = () => Promise.resolve().then(() => Cl), ba = () => Promise.resolve().then(() => od), ka = () => import("./QR-BfTMaaLP.js"), Ca = () => Promise.resolve().then(() => Cu), Ea = () => import("./Apps-CFXAriI4.js"), Ta = () => import("./Billing-JwfACI7M.js"), Sa = () => import("./CustomApp---b2SbIq.js"), Ia = () => import("./General-kIEcVs4A.js"), Aa = [
5567
5567
  {
5568
5568
  path: "/welcome",
5569
5569
  name: "AuthWelcome",
@@ -5686,6 +5686,7 @@ Tanıştığınız herkesi etkileyin 😎 <br> Kendinize bir tane ayırın 👇`
5686
5686
  "https://designer-dev.tapni.com",
5687
5687
  "http://localhost:8082",
5688
5688
  "http://localhost:7777",
5689
+ "https://localhost:7777",
5689
5690
  "http://localhost:8086",
5690
5691
  "https://localhost:8085",
5691
5692
  "http://localhost:8085"
@@ -15198,46 +15199,66 @@ const xs = Ir("MsAuthPlugin", {
15198
15199
  data() {
15199
15200
  return {
15200
15201
  code_verifier: "",
15201
- code_challenge: ""
15202
+ code_challenge: "",
15203
+ shouldCloseWindow: !1,
15204
+ popupWindow: null,
15205
+ checkInterval: null
15202
15206
  };
15203
15207
  },
15204
15208
  computed: {},
15205
15209
  watch: {
15206
- /*
15207
- '$route.path': async function(routePath) {
15208
- await this.handleSamlRedirect(routePath)
15210
+ "$route.path"(n) {
15211
+ n === "/callback/saml" && this.handleSamlRedirect(n);
15209
15212
  }
15210
- */
15211
15213
  },
15212
15214
  methods: {
15215
+ closeWindow() {
15216
+ try {
15217
+ window.close();
15218
+ } catch (n) {
15219
+ console.log("Window close error", n);
15220
+ }
15221
+ },
15213
15222
  async samlLogin(n) {
15214
15223
  this.code_verifier = Bn.generateRandomString(28), localStorage.setItem("pkce_code_verifier", this.code_verifier), this.code_challenge = await Bn.pkceChallengeFromVerifier(this.code_verifier);
15215
15224
  const e = Kn.getPlatform();
15216
- let t = `code_challenge=${this.code_challenge}&platform=${e}&redirect_uri=${location.origin + "/callback/saml"}&realm=${this.$storex.realm}`, r = btoa(t);
15225
+ let t = `code_challenge=${this.code_challenge}&platform=${e}&redirect_uri=${location.origin + "/callback/saml"}&realm=${this.realm}&display=${this.display}`, r = btoa(t);
15217
15226
  n = `${n}&RelayState=${r}`;
15218
15227
  let o = this;
15219
- window.addEventListener("message", async (i) => {
15220
- var a;
15221
- if (!this.allowedOriginsAuth.includes(i.origin)) return console.log("Origin is not allowed! " + i.origin);
15222
- if (i.data.type === "saml" && i.data.code) {
15223
- if (this.display === "popup")
15224
- return (a = window.parent) == null ? void 0 : a.postMessage({ code: i.data.code, state: this.$route.query.state, code_verifier: localStorage.getItem("pkce_code_verifier") }, "*");
15225
- await o.exchangeAuthCode({ code: i.data.code, code_verifier: localStorage.getItem("pkce_code_verifier") }), localStorage.removeItem("pkce_code_verifier");
15226
- }
15227
- }, { once: !0 }), this.isNative ? await fr.open({ url: n, presentationStyle: "popover" }) : window.open(n, "popup", "width=600,height=600");
15228
+ window.addEventListener(
15229
+ "message",
15230
+ async (i) => {
15231
+ var a;
15232
+ if (!this.allowedOriginsAuth.includes(i.origin)) return console.log("Origin is not allowed! " + i.origin);
15233
+ if (i.data.code) {
15234
+ if (console.log("post message from opener", i.data, o.display), o.display === "popup")
15235
+ return (a = window.parent) == null ? void 0 : a.postMessage({ code: i.data.code, state: i.data.state, code_verifier: localStorage.getItem("pkce_code_verifier") }, "*");
15236
+ await o.exchangeAuthCode({ code: i.data.code, code_verifier: localStorage.getItem("pkce_code_verifier") }), localStorage.removeItem("pkce_code_verifier");
15237
+ }
15238
+ },
15239
+ { once: !0 }
15240
+ ), this.isNative ? this.popupWindow = await fr.open({ url: n, presentationStyle: "popover" }) : (this.checkInterval = setInterval(() => {
15241
+ var s;
15242
+ const i = localStorage.getItem("auth_code"), a = localStorage.getItem("pkce_code_verifier");
15243
+ console.log("interval", i, a), i && (clearInterval(this.checkInterval), localStorage.removeItem("auth_code"), localStorage.removeItem("pkce_code_verifier"), (s = window.parent) == null || s.postMessage({ code: i, state: this.$route.query.state, code_verifier: a }, "*"));
15244
+ }, 500), this.popupWindow = window.open(window.location.origin + "/callback/redirect?uri=" + btoa(n), "popup", "width=600,height=600")), this.popupWindow && this.popupWindow.addEventListener("beforeunload", () => {
15245
+ console.log("popup window closed");
15246
+ });
15228
15247
  },
15229
15248
  async handleSamlRedirect() {
15230
- var t;
15231
- let n, e = { type: "saml" };
15232
- if (this.$route.query.code && (e.code = this.$route.query.code), window.opener)
15233
- window.opener.postMessage(e, location.origin), window.close();
15249
+ var e;
15250
+ let n;
15251
+ if (this.$route.query.code && (n = this.$route.query.code), console.log("window1", window.opener), console.log("window2", window.parent), window.opener)
15252
+ window.opener.postMessage({ type: "saml", code: n }, "*"), this.closeWindow();
15234
15253
  else {
15235
- if (this.isNative && this.isiOS && await fr.close(), Y.$emit("ssoEvent", { name: "setLoading", data: !0 }), this.$route.query.code && (n = this.$route.query.code), console.log(this.display, { code: n }), n) {
15236
- if (this.display === "popup")
15237
- return (t = window.parent) == null ? void 0 : t.postMessage({ code: n, state: this.$route.query.state }, "*");
15254
+ if (this.isNative && this.isiOS && await fr.close(), Y.$emit("ssoEvent", { name: "setLoading", data: !0 }), console.log(this.display, { code: n }, window.parent, window.opener), n) {
15255
+ if (this.display === "popup" && (localStorage.setItem("auth_code", n), this.shouldCloseWindow = !0, (e = window.parent) == null || e.postMessage({ code: n, state: this.$route.query.state }, "*"), this.closeWindow()), this.display === "redirect" || location.host === "auth.tapni.com") {
15256
+ let t = "https://auth.tapni.com/callback/auth";
15257
+ return this.realm === "dashboard" && (t = "https://business.tapni.com/login"), location.href = t + "?code=" + n + "&code_verifier=" + localStorage.getItem("pkce_code_verifier");
15258
+ }
15238
15259
  await this.exchangeAuthCode({ code: n, code_verifier: localStorage.getItem("pkce_code_verifier") });
15239
15260
  }
15240
- localStorage.removeItem("pkce_code_verifier"), Y.$emit("ssoEvent", { name: "setLoading", data: !1 });
15261
+ Y.$emit("ssoEvent", { name: "setLoading", data: !1 });
15241
15262
  }
15242
15263
  }
15243
15264
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapni/auth",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "type": "module",
5
5
  "main": "./dist/TapniAuth.umd.js",
6
6
  "module": "./dist/TapniAuth.es.js",
@@ -87,7 +87,7 @@ export default {
87
87
  }
88
88
  }, 500);
89
89
 
90
- this.popupWindow = window.open('https://auth.tapni.com/callback/redirect?uri=' + btoa(loginUrl), 'popup', 'width=600,height=600');
90
+ this.popupWindow = window.open(window.location.origin + '/callback/redirect?uri=' + btoa(loginUrl), 'popup', 'width=600,height=600');
91
91
  }
92
92
 
93
93
  if (this.popupWindow) {
package/src/store/auth.js CHANGED
@@ -64,6 +64,7 @@ export default {
64
64
  "https://designer-dev.tapni.com",
65
65
  "http://localhost:8082",
66
66
  "http://localhost:7777",
67
+ "https://localhost:7777",
67
68
  "http://localhost:8086",
68
69
  "https://localhost:8085",
69
70
  "http://localhost:8085"