@tapni/auth 0.0.77 → 0.0.79

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.
@@ -8,7 +8,7 @@ import { Capacitor as Qt, registerPlugin as In, WebPlugin as Wo } from "@capacit
8
8
  import { Browser as hn } from "@capacitor/browser";
9
9
  import $o from "qr-code-styling";
10
10
  import { sanitizeUrl as Jo } from "@braintree/sanitize-url";
11
- const Xo = "0.0.77";
11
+ const Xo = "0.0.79";
12
12
  let Un;
13
13
  const Ft = {
14
14
  setApiRootFromOptions(n) {
@@ -39,12 +39,12 @@ const Ft = {
39
39
  lang: n.appLanguage,
40
40
  realm: n.realm || "app"
41
41
  } : {}
42
- }), n && n.token && !e) {
42
+ }), console.log("before interceptor enter", n, e), n && n.token && !e) {
43
43
  const a = qr(n.token);
44
44
  if (console.log("interceptor enter", a, a.exp - 30 < Math.floor(Date.now() / 1e3)), a.exp - 30 < Math.floor(Date.now() / 1e3))
45
- return ze.methods.refreshTokenAction(a).then(() => (i.headers = {
45
+ return ze.methods.refreshTokenAction(a).then((s) => (i.headers = {
46
46
  ...i.headers,
47
- Authorization: `Bearer ${n.token}`
47
+ Authorization: `Bearer ${s}`
48
48
  }, i));
49
49
  }
50
50
  return i;
@@ -4469,21 +4469,23 @@ const ze = {
4469
4469
  });
4470
4470
  },
4471
4471
  async refreshTokenAction(n) {
4472
- if (!this.refreshToken || this.refreshing) {
4473
- console.log("return-refreshTokenAction", this.refreshToken, this.refreshing);
4474
- return;
4475
- }
4476
- this.refreshing = !0;
4477
- const [e, t] = await Z(
4478
- Ne.refreshToken({
4479
- id: n.id,
4480
- refreshToken: this.refreshToken,
4481
- refreshTokenAction: !0
4482
- }, this.$storage)
4483
- );
4484
- if (e && e.response && e.response.data.error === "ACCESS_DENIED")
4485
- return this.logout(!1), location.reload();
4486
- t && t.data ? this.setToken(t.data.token) : console.error("Invalid response setToken"), this.refreshing = !1;
4472
+ return new Promise(async (e, t) => {
4473
+ if (console.log("auth-refreshTokenAction", n), !this.refreshToken || this.refreshing) {
4474
+ console.log("return-refreshTokenAction", this.refreshToken, this.refreshing);
4475
+ return;
4476
+ }
4477
+ this.refreshing = !0;
4478
+ const [r, o] = await Z(
4479
+ Ne.refreshToken({
4480
+ id: n.id,
4481
+ refreshToken: this.refreshToken,
4482
+ refreshTokenAction: !0
4483
+ }, this.$storage)
4484
+ );
4485
+ if (r && r.response && r.response.data.error === "ACCESS_DENIED")
4486
+ return this.logout(!1), location.reload();
4487
+ o && o.data ? (this.setToken(o.data.token), z.$emit("ssoEvent", { name: "setStorage", data: this.$storage }), e(o.data.token)) : t("Invalid response setToken"), this.refreshing = !1;
4488
+ });
4487
4489
  },
4488
4490
  async login(n) {
4489
4491
  const [e, t] = await Z(Ne.login(n, this.$storage));