tempest-react-sdk 0.82.0 → 0.84.0

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.
Files changed (80) hide show
  1. package/README.md +7 -6
  2. package/bin/lib/openapi/generate.hostile.test.mjs +91 -0
  3. package/bin/lib/openapi/generate.mjs +42 -3
  4. package/dist/auth/create-tempest-auth.cjs +1 -1
  5. package/dist/auth/create-tempest-auth.cjs.map +1 -1
  6. package/dist/auth/create-tempest-auth.js +201 -153
  7. package/dist/auth/create-tempest-auth.js.map +1 -1
  8. package/dist/http/resumable-upload.cjs +1 -1
  9. package/dist/http/resumable-upload.cjs.map +1 -1
  10. package/dist/http/resumable-upload.js +124 -75
  11. package/dist/http/resumable-upload.js.map +1 -1
  12. package/dist/http/upload-with-progress.cjs +1 -1
  13. package/dist/http/upload-with-progress.cjs.map +1 -1
  14. package/dist/http/upload-with-progress.js +108 -44
  15. package/dist/http/upload-with-progress.js.map +1 -1
  16. package/dist/payments/PixCheckout.cjs +2 -0
  17. package/dist/payments/PixCheckout.cjs.map +1 -0
  18. package/dist/payments/PixCheckout.js +171 -0
  19. package/dist/payments/PixCheckout.js.map +1 -0
  20. package/dist/payments/PixCheckout.module.cjs +3 -0
  21. package/dist/payments/PixCheckout.module.cjs.map +1 -0
  22. package/dist/payments/PixCheckout.module.js +22 -0
  23. package/dist/payments/PixCheckout.module.js.map +1 -0
  24. package/dist/payments/format.cjs +2 -0
  25. package/dist/payments/format.cjs.map +1 -0
  26. package/dist/payments/format.js +9 -0
  27. package/dist/payments/format.js.map +1 -0
  28. package/dist/payments/mercado-pago.cjs +2 -0
  29. package/dist/payments/mercado-pago.cjs.map +1 -0
  30. package/dist/payments/mercado-pago.js +27 -0
  31. package/dist/payments/mercado-pago.js.map +1 -0
  32. package/dist/payments/outcome.cjs +2 -0
  33. package/dist/payments/outcome.cjs.map +1 -0
  34. package/dist/payments/outcome.js +108 -0
  35. package/dist/payments/outcome.js.map +1 -0
  36. package/dist/payments/types.cjs +2 -0
  37. package/dist/payments/types.cjs.map +1 -0
  38. package/dist/payments/types.js +16 -0
  39. package/dist/payments/types.js.map +1 -0
  40. package/dist/payments/use-mercado-pago-card.cjs +2 -0
  41. package/dist/payments/use-mercado-pago-card.cjs.map +1 -0
  42. package/dist/payments/use-mercado-pago-card.js +120 -0
  43. package/dist/payments/use-mercado-pago-card.js.map +1 -0
  44. package/dist/payments/use-pix-charge.cjs +2 -0
  45. package/dist/payments/use-pix-charge.cjs.map +1 -0
  46. package/dist/payments/use-pix-charge.js +63 -0
  47. package/dist/payments/use-pix-charge.js.map +1 -0
  48. package/dist/query/offline-persistence.cjs +1 -1
  49. package/dist/query/offline-persistence.cjs.map +1 -1
  50. package/dist/query/offline-persistence.js +57 -44
  51. package/dist/query/offline-persistence.js.map +1 -1
  52. package/dist/styles/PixCheckout.css +2 -0
  53. package/dist/styles/component/PixCheckout.css +18 -0
  54. package/dist/styles/manifest.json +6 -0
  55. package/dist/styles/payments.css +18 -0
  56. package/dist/styles.css +1 -1
  57. package/dist/sw/cache.cjs +1 -1
  58. package/dist/sw/cache.cjs.map +1 -1
  59. package/dist/sw/cache.js +82 -32
  60. package/dist/sw/cache.js.map +1 -1
  61. package/dist/sw.d.ts +21 -1
  62. package/dist/tempest-react-sdk.cjs +1 -1
  63. package/dist/tempest-react-sdk.d.ts +748 -10
  64. package/dist/tempest-react-sdk.js +104 -97
  65. package/dist/vite/base-url.cjs +1 -1
  66. package/dist/vite/base-url.cjs.map +1 -1
  67. package/dist/vite/base-url.js +5 -1
  68. package/dist/vite/base-url.js.map +1 -1
  69. package/dist/vite/tempest-pwa-dev-sw.cjs +1 -1
  70. package/dist/vite/tempest-pwa-dev-sw.cjs.map +1 -1
  71. package/dist/vite/tempest-pwa-dev-sw.js +96 -31
  72. package/dist/vite/tempest-pwa-dev-sw.js.map +1 -1
  73. package/dist/vite/tempest-pwa-manifest.cjs +2 -2
  74. package/dist/vite/tempest-pwa-manifest.cjs.map +1 -1
  75. package/dist/vite/tempest-pwa-manifest.js +32 -16
  76. package/dist/vite/tempest-pwa-manifest.js.map +1 -1
  77. package/dist/vite.cjs +1 -1
  78. package/dist/vite.d.ts +63 -12
  79. package/dist/vite.js +4 -4
  80. package/package.json +1 -1
@@ -3,10 +3,11 @@ import { SessionSupersededError as t } from "../http/errors.js";
3
3
  import { createApiClient as n } from "../http/api-client.js";
4
4
  import { bindSessionIdentity as r } from "./session-identity.js";
5
5
  import { createAuthStore as i } from "./create-auth-store.js";
6
- import { createRefreshQueue as a } from "./refresh-queue.js";
6
+ import { decodeJWT as a } from "./jwt.js";
7
+ import { createRefreshQueue as o } from "./refresh-queue.js";
7
8
  //#region src/auth/create-tempest-auth.ts
8
- var o = 1e4, s = 1e4;
9
- function c(e, t) {
9
+ var s = 1e4, c = 1e4;
10
+ function l(e, t) {
10
11
  return e.length === 0 ? Promise.resolve() : new Promise((n) => {
11
12
  let r = setTimeout(n, t);
12
13
  Promise.allSettled(e).then(() => {
@@ -14,59 +15,68 @@ function c(e, t) {
14
15
  });
15
16
  });
16
17
  }
17
- function ee() {
18
+ function u() {
18
19
  let e = globalThis.crypto;
19
20
  return typeof e?.randomUUID == "function" ? e.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
20
21
  }
21
- var te = "unlineaged", l = /* @__PURE__ */ new Set();
22
- function ne(t) {
23
- e() && !l.has(t) && (l.add(t), console.warn("[tempest-react-sdk] createTempestAuth: withCredentials is set without logoutPath. logout() cannot clear the HttpOnly refresh cookie, so the next refresh() — the boot restore — signs the same account back in. Pass logoutPath (the backend's cookie logout route) so the server revokes it."));
22
+ var d = /* @__PURE__ */ new Set();
23
+ function ee(t) {
24
+ e() && !d.has(t) && (d.add(t), console.warn("[tempest-react-sdk] createTempestAuth: withCredentials is set without logoutPath. logout() cannot clear the HttpOnly refresh cookie, so the next refresh() — the boot restore — signs the same account back in. Pass logoutPath (the backend's cookie logout route) so the server revokes it."));
24
25
  }
25
- function re(e) {
26
+ function f(e) {
27
+ if (!e) return null;
28
+ try {
29
+ let { sub: t } = a(e).payload;
30
+ return typeof t == "string" && t !== "" ? t : null;
31
+ } catch {
32
+ return null;
33
+ }
34
+ }
35
+ function te(e) {
26
36
  let t = e ?? {};
27
37
  return {
28
38
  token: t.access_token,
29
39
  refreshToken: t.refresh_token
30
40
  };
31
41
  }
32
- function u(l) {
33
- let { baseURL: u, prefix: d, loginPath: ie = "/api/auth/login", refreshPath: ae = "/api/auth/refresh", logoutPath: f, onLogoutError: oe, mePath: p, storeName: m = "tempest-auth", storage: h = "local", withCredentials: g = !1, csrf: _, fetcher: se, parseTokens: v = re, parseUser: ce, refreshBody: y = (e) => e ? { refresh_token: e } : void 0, retry: le, redirectTo: b, onSessionEnd: x } = l;
34
- g && !f && ne(m);
35
- let S = i({
36
- name: m,
37
- storage: h
38
- }), C = `${m}-refresh`;
39
- function w() {
40
- return typeof window > "u" ? null : h === "session" ? window.sessionStorage : window.localStorage;
41
- }
42
+ function p(a) {
43
+ let { baseURL: d, prefix: p, loginPath: ne = "/api/auth/login", refreshPath: m = "/api/auth/refresh", logoutPath: h, onLogoutError: re, mePath: ie, storeName: g = "tempest-auth", storage: _ = "local", withCredentials: v = !1, csrf: ae, fetcher: y, parseTokens: b = te, parseUser: oe, refreshBody: x = (e) => e ? { refresh_token: e } : void 0, retry: se, redirectTo: S, onSessionEnd: ce } = a;
44
+ v && !h && ee(g);
45
+ let C = i({
46
+ name: g,
47
+ storage: _
48
+ }), w = `${g}-refresh`;
42
49
  function T() {
43
- return w()?.getItem(C) ?? null;
44
- }
45
- let E = T();
46
- function D(e) {
47
- E = e;
48
- let t = w();
49
- t && (e ? t.setItem(C, e) : t.removeItem(C));
50
- }
51
- let O = `${m}-lineage`, ue = `tempest-react-sdk:${m}:refresh`, k = w()?.getItem(O) ?? null;
52
- function A(e) {
53
- k = e;
54
- let t = w();
55
- t && (e ? t.setItem(O, e) : t.removeItem(O));
56
- }
57
- let j = () => S.getState(), M = () => j().token;
58
- async function de() {
59
- if (!p) return j().user;
60
- let e = N, n;
50
+ return typeof window > "u" ? null : _ === "session" ? window.sessionStorage : window.localStorage;
51
+ }
52
+ function E() {
53
+ return T()?.getItem(w) ?? null;
54
+ }
55
+ let D = E();
56
+ function O(e) {
57
+ D = e;
58
+ let t = T();
59
+ t && (e ? t.setItem(w, e) : t.removeItem(w));
60
+ }
61
+ let k = `${g}-lineage`, le = `tempest-react-sdk:${g}:refresh`, A = T()?.getItem(k) ?? null;
62
+ function j(e) {
63
+ A = e;
64
+ let t = T();
65
+ t && (e ? t.setItem(k, e) : t.removeItem(k));
66
+ }
67
+ let M = () => C.getState(), N = () => M().token;
68
+ async function ue() {
69
+ if (!ie) return M().user;
70
+ let e = P, n;
61
71
  try {
62
- n = await Q.get(p, { skipAuthRetry: !0 });
72
+ n = await Q.get(ie, { skipAuthRetry: !0 });
63
73
  } catch (n) {
64
- throw N === e ? n : new t();
74
+ throw P === e ? n : new t();
65
75
  }
66
- if (N !== e || !Z().continues) throw new t();
67
- return j().setUser(n), n;
76
+ if (P !== e || !Z().continues) throw new t();
77
+ return M().setUser(n), n;
68
78
  }
69
- let N = 0, P = Promise.resolve(), F = 0, I = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Set(), z = /* @__PURE__ */ new Set();
79
+ let P = 0, de = Promise.resolve(), F = 0, I = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Set(), z = /* @__PURE__ */ new Set();
70
80
  function B(e) {
71
81
  let t = e.then(() => void 0, () => void 0);
72
82
  return R.add(t), t.then(() => R.delete(t)), e;
@@ -74,7 +84,7 @@ function u(l) {
74
84
  function fe(t) {
75
85
  e() && console.warn("[tempest-react-sdk] createTempestAuth: logoutPath revocation failed", t);
76
86
  try {
77
- oe?.(t);
87
+ re?.(t);
78
88
  } catch {
79
89
  return;
80
90
  }
@@ -90,110 +100,144 @@ function u(l) {
90
100
  return L.add(t), t.then(() => L.delete(t)), t;
91
101
  }
92
102
  function H(e, t) {
93
- f && !g && t && V(() => U(e).post(f, { body: y(t) }));
103
+ h && !v && t && V(() => U(e).post(h, { body: x(t) }));
94
104
  }
95
105
  function U(e) {
96
106
  return n({
97
- baseURL: u,
98
- prefix: d,
99
- withCredentials: g,
100
- csrf: _,
101
- fetcher: se,
107
+ baseURL: d,
108
+ prefix: p,
109
+ withCredentials: v,
110
+ csrf: ae,
111
+ fetcher: y,
102
112
  getToken: () => e
103
113
  });
104
114
  }
105
115
  function W() {
106
- N += 1, K = a(G);
116
+ P += 1, q = o(G);
107
117
  }
108
118
  async function G() {
109
- let e = M(), t = N;
119
+ let e = N(), t = P;
110
120
  z.add(t);
121
+ let n;
111
122
  try {
112
- await pe(() => me(e));
123
+ n = await K(() => pe(e));
113
124
  } finally {
114
125
  z.delete(t);
115
126
  }
127
+ n && await J(Y(n));
116
128
  }
117
- async function pe(e) {
118
- let t = h === "local" && typeof navigator < "u" ? navigator.locks : void 0;
129
+ async function K(e) {
130
+ let t = _ === "local" && typeof navigator < "u" ? navigator.locks : void 0;
119
131
  if (!t) return e();
120
- let n = new AbortController(), r = setTimeout(() => n.abort(), s), i = !1;
132
+ let n = new AbortController(), r = setTimeout(() => n.abort(), c), i = !1, a;
121
133
  try {
122
- await t.request(ue, { signal: n.signal }, async () => {
123
- i = !0, clearTimeout(r), await e();
134
+ await t.request(le, { signal: n.signal }, async () => {
135
+ i = !0, clearTimeout(r), a = await e();
124
136
  });
125
137
  } catch (t) {
126
138
  if (i) throw t;
127
- clearTimeout(r), await e();
139
+ return clearTimeout(r), e();
128
140
  }
141
+ return a;
129
142
  }
130
- async function me(e) {
131
- let n = e !== null || j().user !== null || E !== null, r = Z();
132
- if (!n && M() !== null) return;
143
+ async function pe(e) {
144
+ let n = e !== null || M().user !== null || D !== null, r = Z();
145
+ if (!n && N() !== null) return null;
133
146
  if (!r.continues) throw new t();
134
- if (M() !== e) return;
135
- let i = N, a;
147
+ if (N() !== e) return null;
148
+ let i = P, a;
136
149
  try {
137
- a = await B(Q.post(ae, {
138
- body: y(T()),
150
+ a = await B(Q.post(m, {
151
+ body: x(E()),
139
152
  skipAuth: !0
140
153
  }));
141
154
  } catch (e) {
142
- throw N === i ? e : new t();
155
+ throw P === i ? e : new t();
143
156
  }
144
- let { token: o, refreshToken: s } = v(a);
145
- if (N !== i || !Z().continues) throw H(o ?? null, s), new t();
146
- j().setToken(o), s && D(s);
157
+ let { token: o, refreshToken: s } = b(a);
158
+ if (P !== i || !Z().continues) throw H(o ?? null, s), new t();
159
+ let c = f(e), l = f(o);
160
+ return c !== null && l !== null && c !== l ? {
161
+ data: a,
162
+ token: o,
163
+ refreshToken: s
164
+ } : (n || j(u()), M().setToken(o), s && O(s), null);
147
165
  }
148
- let K = a(G);
149
- function q(e) {
150
- let t = M();
166
+ let q = o(G);
167
+ function me(e) {
168
+ let t = N();
151
169
  return t === null ? !1 : e.token === null || e.token !== t;
152
170
  }
153
- function J() {
154
- return M() === null && T() === null;
171
+ function he() {
172
+ return N() === null && E() === null;
155
173
  }
156
- async function he() {
157
- if (!(I.size > 0 && F === 0 && (await Promise.allSettled([...I]), M() !== null))) throw Error("anonymous 401 with no session");
174
+ async function ge() {
175
+ if (!(I.size > 0 && F === 0 && (await Promise.allSettled([...I]), N() !== null))) throw Error("anonymous 401 with no session");
158
176
  }
159
- async function ge(e) {
160
- if (e.epoch !== null && e.epoch !== N) throw new t();
161
- if (q(e)) {
177
+ async function _e(e) {
178
+ if (e.epoch !== null && e.epoch !== P) throw new t();
179
+ if (me(e)) {
162
180
  if (e.token === null) throw Error("anonymous 401 under a live session");
163
- } else return e.token === null && J() ? z.has(N) ? K() : he() : K();
181
+ return;
182
+ }
183
+ if (e.token === null && he()) return z.has(P) ? q() : ge();
184
+ let n = P;
185
+ if (await q(), P !== n) throw new t();
164
186
  }
165
- async function _e(e, n) {
166
- if (n.epoch !== null && n.epoch !== N || !Z().continues) throw new t();
167
- q(n) || n.token === null && J() || await Ce();
187
+ async function ve(e, n) {
188
+ if (n.epoch !== null && n.epoch !== P || !Z().continues) throw new t();
189
+ me(n) || n.token === null && he() || await De();
168
190
  }
169
- async function ve(e) {
170
- L.size > 0 && await c([...L], o);
171
- let t = ye(e);
172
- I.add(t);
191
+ async function ye(e) {
192
+ return L.size > 0 && await l([...L], s), J(Se(e));
193
+ }
194
+ async function be() {
195
+ return L.size > 0 && await l([...L], s), J(xe());
196
+ }
197
+ async function J(e) {
198
+ I.add(e);
173
199
  try {
174
- return await t;
200
+ return await e;
175
201
  } finally {
176
- I.delete(t);
202
+ I.delete(e);
177
203
  }
178
204
  }
179
- async function ye(e) {
180
- let n = N, r = await B(Q.post(ie, {
205
+ async function xe() {
206
+ let e = P, n = await K(() => B(Q.post(m, {
207
+ body: x(E()),
208
+ skipAuth: !0
209
+ }))), { token: r, refreshToken: i } = b(n);
210
+ if (P !== e) throw H(r ?? null, i), new t();
211
+ return Y({
212
+ data: n,
213
+ token: r,
214
+ refreshToken: i
215
+ });
216
+ }
217
+ async function Se(e) {
218
+ let n = P, r = await B(Q.post(ne, {
181
219
  body: e,
182
220
  skipAuth: !0
183
- })), { token: i, refreshToken: a } = v(r);
184
- if (N !== n) throw H(i ?? null, a), new t();
185
- H(M(), T() ?? void 0);
186
- let { done: o } = Y("switch"), s = N;
187
- if (await o.catch(() => void 0), N !== s) throw new t();
188
- A(ee()), j().setToken(i), D(a ?? null);
189
- let c = ce?.(r);
190
- return c == null ? de() : (j().setUser(c), c);
191
- }
192
- function Y(e) {
193
- let { user: t, token: n } = j(), r = n !== null || t !== null || T() !== null;
194
- return (r || e !== "expired") && W(), j().logout(), D(null), A(null), r ? {
221
+ })), { token: i, refreshToken: a } = b(r);
222
+ if (P !== n) throw H(i ?? null, a), new t();
223
+ return H(N(), E() ?? void 0), Y({
224
+ data: r,
225
+ token: i,
226
+ refreshToken: a
227
+ });
228
+ }
229
+ async function Y(e) {
230
+ let { done: n } = X("switch"), r = P;
231
+ if (await n.catch(() => void 0), P !== r) throw new t();
232
+ j(u()), M().setToken(e.token), O(e.refreshToken ?? null);
233
+ let i = oe?.(e.data);
234
+ return i == null ? ue() : (M().setUser(i), i);
235
+ }
236
+ function X(e) {
237
+ let { user: t, token: n } = M(), r = n !== null || t !== null || E() !== null;
238
+ return (r || e !== "expired") && W(), M().logout(), O(null), j(null), r ? {
195
239
  live: r,
196
- done: X({
240
+ done: Ce({
197
241
  reason: e,
198
242
  user: t,
199
243
  token: n,
@@ -201,16 +245,16 @@ function u(l) {
201
245
  })
202
246
  } : {
203
247
  live: r,
204
- done: e === "switch" || F === 0 ? P : Promise.resolve()
248
+ done: e === "switch" || F === 0 ? de : Promise.resolve()
205
249
  };
206
250
  }
207
- function X(e) {
208
- if (!x) return Promise.resolve();
251
+ function Ce(e) {
252
+ if (!ce) return Promise.resolve();
209
253
  let t = U(e.token);
210
254
  F += 1;
211
255
  let n = (async () => {
212
256
  try {
213
- await x({
257
+ await ce({
214
258
  ...e,
215
259
  api: t
216
260
  });
@@ -218,12 +262,12 @@ function u(l) {
218
262
  --F;
219
263
  }
220
264
  })();
221
- return P = n.then(() => void 0, () => void 0), n.then(() => void 0);
265
+ return de = n.then(() => void 0, () => void 0), n.then(() => void 0);
222
266
  }
223
- function be() {
224
- let e = w();
267
+ function we() {
268
+ let e = T();
225
269
  if (!e) return null;
226
- let t = e.getItem(C), n = e.getItem(O), r = e.getItem(m);
270
+ let t = e.getItem(w), n = e.getItem(k), r = e.getItem(g);
227
271
  if (!r) return {
228
272
  user: null,
229
273
  token: null,
@@ -248,18 +292,18 @@ function u(l) {
248
292
  }
249
293
  }
250
294
  function Z() {
251
- let e = be(), { user: t, token: n } = j();
295
+ let e = we(), { user: t, token: n } = M();
252
296
  if (e === null) return {
253
297
  continues: !0,
254
298
  done: Promise.resolve()
255
299
  };
256
300
  let r = JSON.stringify(e.user) === JSON.stringify(t);
257
- if (e.token === n && e.refreshToken === E && e.lineage === k && r) return {
301
+ if (e.token === n && e.refreshToken === D && e.lineage === A && r) return {
258
302
  continues: !0,
259
303
  done: Promise.resolve()
260
304
  };
261
- let i = e.lineage !== null || k !== null ? e.lineage === k : e.token === n || n !== null && r, a = e.token !== null && i, o = n !== null || t !== null || E !== null;
262
- if (a || W(), E = e.refreshToken, k = e.lineage, S.setState({
305
+ let i = e.lineage !== null || A !== null ? e.lineage === A : e.token === n || n !== null && r, a = e.token !== null && i, o = n !== null || t !== null || D !== null;
306
+ if (a || W(), D = e.refreshToken, A = e.lineage, C.setState({
263
307
  user: e.user,
264
308
  token: e.token,
265
309
  isAuthenticated: e.token !== null
@@ -267,7 +311,7 @@ function u(l) {
267
311
  continues: a,
268
312
  done: Promise.resolve()
269
313
  };
270
- let s = X({
314
+ let s = Ce({
271
315
  reason: e.token === null ? "logout" : "switch",
272
316
  user: t,
273
317
  token: n,
@@ -278,55 +322,59 @@ function u(l) {
278
322
  done: s
279
323
  };
280
324
  }
281
- function xe() {
282
- if (!f) return null;
283
- let e = f, { token: t, user: n } = j(), r = T();
284
- if (!g && t === null && n === null && r === null) return null;
285
- let i = g ? [...R] : [];
286
- return V(async () => (await c(i, o), U(t).post(e, { body: y(r) })));
325
+ function Te() {
326
+ if (!h) return null;
327
+ let e = h, { token: t, user: n } = M(), r = E();
328
+ if (!v && t === null && n === null && r === null) return null;
329
+ let i = v ? [...R] : [];
330
+ return V(async () => (await l(i, s), U(t).post(e, { body: x(r) })));
287
331
  }
288
- function Se() {
332
+ function Ee() {
289
333
  let e = Z();
290
334
  if (!e.continues) return e.done;
291
- let t = xe(), { done: n } = Y("logout");
335
+ let t = Te(), { done: n } = X("logout");
292
336
  return t ? Promise.all([t, n]).then(() => void 0) : n;
293
337
  }
294
- async function Ce() {
295
- let { live: e, done: t } = Y("expired");
296
- await t.catch(() => void 0), e && b && typeof window < "u" && window.location.assign(b);
338
+ async function De() {
339
+ let { live: e, done: t } = X("expired");
340
+ await t.catch(() => void 0), e && S && typeof window < "u" && window.location.assign(S);
297
341
  }
298
342
  let Q = n({
299
- baseURL: u,
300
- prefix: d,
301
- withCredentials: g,
302
- csrf: _,
303
- fetcher: se,
304
- getToken: M,
305
- getSessionEpoch: () => N,
306
- refresh: ge,
307
- retry: le,
308
- onUnauthorized: _e
309
- }), we = () => K(), Te = () => M() === null ? null : k ?? te, Ee = {
310
- current: Te,
311
- subscribe: (e) => S.subscribe(e)
343
+ baseURL: d,
344
+ prefix: p,
345
+ withCredentials: v,
346
+ csrf: ae,
347
+ fetcher: y,
348
+ getToken: N,
349
+ getSessionEpoch: () => P,
350
+ refresh: _e,
351
+ retry: se,
352
+ onUnauthorized: ve
353
+ }), Oe = () => q(), $ = null, ke = () => N() === null ? null : A === null ? ($?.epoch !== P && ($ = {
354
+ epoch: P,
355
+ key: u()
356
+ }), $.key) : A, Ae = {
357
+ current: ke,
358
+ subscribe: (e) => C.subscribe(e)
312
359
  };
313
- r(Q, Ee), r(M, Ee);
314
- function De(e) {
315
- e.storageArea === w() && (e.key === null || e.key === m || e.key === C || e.key === O) && Z();
360
+ r(Q, Ae), r(N, Ae);
361
+ function je(e) {
362
+ e.storageArea === T() && (e.key === null || e.key === g || e.key === w || e.key === k) && Z();
316
363
  }
317
- let $ = typeof window > "u" ? null : window;
318
- return $?.addEventListener("storage", De), {
319
- useAuthStore: S,
364
+ let Me = typeof window > "u" ? null : window;
365
+ return Me?.addEventListener("storage", je), {
366
+ useAuthStore: C,
320
367
  api: Q,
321
- login: ve,
322
- logout: Se,
323
- refresh: we,
324
- getToken: M,
325
- sessionKey: Te,
326
- dispose: () => $?.removeEventListener("storage", De)
368
+ login: ye,
369
+ logout: Ee,
370
+ refresh: Oe,
371
+ restore: be,
372
+ getToken: N,
373
+ sessionKey: ke,
374
+ dispose: () => Me?.removeEventListener("storage", je)
327
375
  };
328
376
  }
329
377
  //#endregion
330
- export { u as createTempestAuth };
378
+ export { p as createTempestAuth };
331
379
 
332
380
  //# sourceMappingURL=create-tempest-auth.js.map