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.
- package/README.md +7 -6
- package/bin/lib/openapi/generate.hostile.test.mjs +91 -0
- package/bin/lib/openapi/generate.mjs +42 -3
- package/dist/auth/create-tempest-auth.cjs +1 -1
- package/dist/auth/create-tempest-auth.cjs.map +1 -1
- package/dist/auth/create-tempest-auth.js +201 -153
- package/dist/auth/create-tempest-auth.js.map +1 -1
- package/dist/http/resumable-upload.cjs +1 -1
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js +124 -75
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/upload-with-progress.cjs +1 -1
- package/dist/http/upload-with-progress.cjs.map +1 -1
- package/dist/http/upload-with-progress.js +108 -44
- package/dist/http/upload-with-progress.js.map +1 -1
- package/dist/payments/PixCheckout.cjs +2 -0
- package/dist/payments/PixCheckout.cjs.map +1 -0
- package/dist/payments/PixCheckout.js +171 -0
- package/dist/payments/PixCheckout.js.map +1 -0
- package/dist/payments/PixCheckout.module.cjs +3 -0
- package/dist/payments/PixCheckout.module.cjs.map +1 -0
- package/dist/payments/PixCheckout.module.js +22 -0
- package/dist/payments/PixCheckout.module.js.map +1 -0
- package/dist/payments/format.cjs +2 -0
- package/dist/payments/format.cjs.map +1 -0
- package/dist/payments/format.js +9 -0
- package/dist/payments/format.js.map +1 -0
- package/dist/payments/mercado-pago.cjs +2 -0
- package/dist/payments/mercado-pago.cjs.map +1 -0
- package/dist/payments/mercado-pago.js +27 -0
- package/dist/payments/mercado-pago.js.map +1 -0
- package/dist/payments/outcome.cjs +2 -0
- package/dist/payments/outcome.cjs.map +1 -0
- package/dist/payments/outcome.js +108 -0
- package/dist/payments/outcome.js.map +1 -0
- package/dist/payments/types.cjs +2 -0
- package/dist/payments/types.cjs.map +1 -0
- package/dist/payments/types.js +16 -0
- package/dist/payments/types.js.map +1 -0
- package/dist/payments/use-mercado-pago-card.cjs +2 -0
- package/dist/payments/use-mercado-pago-card.cjs.map +1 -0
- package/dist/payments/use-mercado-pago-card.js +120 -0
- package/dist/payments/use-mercado-pago-card.js.map +1 -0
- package/dist/payments/use-pix-charge.cjs +2 -0
- package/dist/payments/use-pix-charge.cjs.map +1 -0
- package/dist/payments/use-pix-charge.js +63 -0
- package/dist/payments/use-pix-charge.js.map +1 -0
- package/dist/query/offline-persistence.cjs +1 -1
- package/dist/query/offline-persistence.cjs.map +1 -1
- package/dist/query/offline-persistence.js +57 -44
- package/dist/query/offline-persistence.js.map +1 -1
- package/dist/styles/PixCheckout.css +2 -0
- package/dist/styles/component/PixCheckout.css +18 -0
- package/dist/styles/manifest.json +6 -0
- package/dist/styles/payments.css +18 -0
- package/dist/styles.css +1 -1
- package/dist/sw/cache.cjs +1 -1
- package/dist/sw/cache.cjs.map +1 -1
- package/dist/sw/cache.js +82 -32
- package/dist/sw/cache.js.map +1 -1
- package/dist/sw.d.ts +21 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +748 -10
- package/dist/tempest-react-sdk.js +104 -97
- package/dist/vite/base-url.cjs +1 -1
- package/dist/vite/base-url.cjs.map +1 -1
- package/dist/vite/base-url.js +5 -1
- package/dist/vite/base-url.js.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.js +96 -31
- package/dist/vite/tempest-pwa-dev-sw.js.map +1 -1
- package/dist/vite/tempest-pwa-manifest.cjs +2 -2
- package/dist/vite/tempest-pwa-manifest.cjs.map +1 -1
- package/dist/vite/tempest-pwa-manifest.js +32 -16
- package/dist/vite/tempest-pwa-manifest.js.map +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.ts +63 -12
- package/dist/vite.js +4 -4
- 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 {
|
|
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
|
|
9
|
-
function
|
|
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
|
|
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
|
|
22
|
-
function
|
|
23
|
-
e() && !
|
|
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
|
|
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
|
|
33
|
-
let { baseURL:
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
-
name:
|
|
37
|
-
storage:
|
|
38
|
-
}),
|
|
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
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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(
|
|
72
|
+
n = await Q.get(ie, { skipAuthRetry: !0 });
|
|
63
73
|
} catch (n) {
|
|
64
|
-
throw
|
|
74
|
+
throw P === e ? n : new t();
|
|
65
75
|
}
|
|
66
|
-
if (
|
|
67
|
-
return
|
|
76
|
+
if (P !== e || !Z().continues) throw new t();
|
|
77
|
+
return M().setUser(n), n;
|
|
68
78
|
}
|
|
69
|
-
let
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
98
|
-
prefix:
|
|
99
|
-
withCredentials:
|
|
100
|
-
csrf:
|
|
101
|
-
fetcher:
|
|
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
|
-
|
|
116
|
+
P += 1, q = o(G);
|
|
107
117
|
}
|
|
108
118
|
async function G() {
|
|
109
|
-
let e =
|
|
119
|
+
let e = N(), t = P;
|
|
110
120
|
z.add(t);
|
|
121
|
+
let n;
|
|
111
122
|
try {
|
|
112
|
-
await
|
|
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
|
|
118
|
-
let t =
|
|
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(),
|
|
132
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), c), i = !1, a;
|
|
121
133
|
try {
|
|
122
|
-
await t.request(
|
|
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),
|
|
139
|
+
return clearTimeout(r), e();
|
|
128
140
|
}
|
|
141
|
+
return a;
|
|
129
142
|
}
|
|
130
|
-
async function
|
|
131
|
-
let n = e !== null ||
|
|
132
|
-
if (!n &&
|
|
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 (
|
|
135
|
-
let i =
|
|
147
|
+
if (N() !== e) return null;
|
|
148
|
+
let i = P, a;
|
|
136
149
|
try {
|
|
137
|
-
a = await B(Q.post(
|
|
138
|
-
body:
|
|
150
|
+
a = await B(Q.post(m, {
|
|
151
|
+
body: x(E()),
|
|
139
152
|
skipAuth: !0
|
|
140
153
|
}));
|
|
141
154
|
} catch (e) {
|
|
142
|
-
throw
|
|
155
|
+
throw P === i ? e : new t();
|
|
143
156
|
}
|
|
144
|
-
let { token: o, refreshToken: s } =
|
|
145
|
-
if (
|
|
146
|
-
|
|
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
|
|
149
|
-
function
|
|
150
|
-
let t =
|
|
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
|
|
154
|
-
return
|
|
171
|
+
function he() {
|
|
172
|
+
return N() === null && E() === null;
|
|
155
173
|
}
|
|
156
|
-
async function
|
|
157
|
-
if (!(I.size > 0 && F === 0 && (await Promise.allSettled([...I]),
|
|
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
|
|
160
|
-
if (e.epoch !== null && e.epoch !==
|
|
161
|
-
if (
|
|
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
|
-
|
|
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
|
|
166
|
-
if (n.epoch !== null && n.epoch !==
|
|
167
|
-
|
|
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
|
|
170
|
-
L.size > 0 && await
|
|
171
|
-
|
|
172
|
-
|
|
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
|
|
200
|
+
return await e;
|
|
175
201
|
} finally {
|
|
176
|
-
I.delete(
|
|
202
|
+
I.delete(e);
|
|
177
203
|
}
|
|
178
204
|
}
|
|
179
|
-
async function
|
|
180
|
-
let
|
|
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 } =
|
|
184
|
-
if (
|
|
185
|
-
H(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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:
|
|
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 ?
|
|
248
|
+
done: e === "switch" || F === 0 ? de : Promise.resolve()
|
|
205
249
|
};
|
|
206
250
|
}
|
|
207
|
-
function
|
|
208
|
-
if (!
|
|
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
|
|
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
|
|
265
|
+
return de = n.then(() => void 0, () => void 0), n.then(() => void 0);
|
|
222
266
|
}
|
|
223
|
-
function
|
|
224
|
-
let e =
|
|
267
|
+
function we() {
|
|
268
|
+
let e = T();
|
|
225
269
|
if (!e) return null;
|
|
226
|
-
let t = e.getItem(
|
|
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 =
|
|
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 ===
|
|
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 ||
|
|
262
|
-
if (a || W(),
|
|
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 =
|
|
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
|
|
282
|
-
if (!
|
|
283
|
-
let e =
|
|
284
|
-
if (!
|
|
285
|
-
let i =
|
|
286
|
-
return V(async () => (await
|
|
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
|
|
332
|
+
function Ee() {
|
|
289
333
|
let e = Z();
|
|
290
334
|
if (!e.continues) return e.done;
|
|
291
|
-
let t =
|
|
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
|
|
295
|
-
let { live: e, done: t } =
|
|
296
|
-
await t.catch(() => void 0), e &&
|
|
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:
|
|
300
|
-
prefix:
|
|
301
|
-
withCredentials:
|
|
302
|
-
csrf:
|
|
303
|
-
fetcher:
|
|
304
|
-
getToken:
|
|
305
|
-
getSessionEpoch: () =>
|
|
306
|
-
refresh:
|
|
307
|
-
retry:
|
|
308
|
-
onUnauthorized:
|
|
309
|
-
}),
|
|
310
|
-
|
|
311
|
-
|
|
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,
|
|
314
|
-
function
|
|
315
|
-
e.storageArea ===
|
|
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
|
|
318
|
-
return
|
|
319
|
-
useAuthStore:
|
|
364
|
+
let Me = typeof window > "u" ? null : window;
|
|
365
|
+
return Me?.addEventListener("storage", je), {
|
|
366
|
+
useAuthStore: C,
|
|
320
367
|
api: Q,
|
|
321
|
-
login:
|
|
322
|
-
logout:
|
|
323
|
-
refresh:
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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 {
|
|
378
|
+
export { p as createTempestAuth };
|
|
331
379
|
|
|
332
380
|
//# sourceMappingURL=create-tempest-auth.js.map
|