@vuetify/one 2.8.0 → 2.8.2
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/dist/{auth-QWWxnYQv.js → auth-CwLSOnno.js} +170 -154
- package/dist/index.d.ts +2 -1
- package/dist/index.js +718 -715
- package/dist/stores/auth.js +1 -1
- package/package.json +1 -1
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { merge as O } from "lodash-es";
|
|
2
|
-
import { defineStore as
|
|
3
|
-
import { ref as T, reactive as z, watch as I, toRefs as M, computed as m, shallowRef as
|
|
4
|
-
import { useRoute as Y, useRouter as
|
|
5
|
-
const _ =
|
|
2
|
+
import { defineStore as j } from "pinia";
|
|
3
|
+
import { ref as T, reactive as z, watch as I, toRefs as M, computed as m, shallowRef as N, nextTick as X } from "vue";
|
|
4
|
+
import { useRoute as Y, useRouter as F } from "vue-router";
|
|
5
|
+
const _ = j("queue", () => {
|
|
6
6
|
const e = T([]);
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
e.value.push(
|
|
7
|
+
function r(o) {
|
|
8
|
+
const s = typeof o == "string" ? { text: o } : o;
|
|
9
|
+
e.value.push(s);
|
|
10
10
|
}
|
|
11
11
|
function t(o) {
|
|
12
|
-
|
|
12
|
+
r({
|
|
13
13
|
color: "error",
|
|
14
14
|
text: o,
|
|
15
15
|
location: "top end",
|
|
16
16
|
timeout: -1
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
+
function i(o) {
|
|
20
|
+
r({
|
|
21
|
+
color: "success",
|
|
22
|
+
text: o,
|
|
23
|
+
location: "top end"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
19
26
|
return {
|
|
20
27
|
queue: e,
|
|
21
|
-
show:
|
|
22
|
-
showError: t
|
|
28
|
+
show: r,
|
|
29
|
+
showError: t,
|
|
30
|
+
showSuccess: i
|
|
23
31
|
};
|
|
24
32
|
}), G = [
|
|
25
33
|
(e) => (e.v || (e.pwaRefresh = !0, typeof e.api == "boolean" && (e.api = e.api ? "inline" : "link-only"), typeof e.rtl == "boolean" && (e.direction = e.rtl ? "rtl" : "ltr", delete e.rtl), typeof e.theme == "object" && (e.mixedTheme = e.theme.mixed, e.theme = e.theme.system ? "system" : e.theme.dark ? "dark" : "light"), Array.isArray(e.notifications) && (e.notifications = { read: e.notifications }), typeof e.last == "object" && (e.notifications = e.notifications || {}, e.notifications.last = e.last, delete e.last), e.v = 1), e),
|
|
@@ -46,7 +54,7 @@ function K(e) {
|
|
|
46
54
|
composition: e.composition || "composition",
|
|
47
55
|
pins: {
|
|
48
56
|
enabled: e.pins || !1,
|
|
49
|
-
pinned: Array.isArray(e.pinned) ? e.pinned.map((
|
|
57
|
+
pinned: Array.isArray(e.pinned) ? e.pinned.map((r) => r.name || r).filter(Boolean) : []
|
|
50
58
|
},
|
|
51
59
|
mixedTheme: e.mixedTheme ?? !0,
|
|
52
60
|
favorites: [],
|
|
@@ -87,7 +95,7 @@ function K(e) {
|
|
|
87
95
|
}
|
|
88
96
|
};
|
|
89
97
|
}
|
|
90
|
-
function
|
|
98
|
+
function H(e) {
|
|
91
99
|
return {
|
|
92
100
|
...e,
|
|
93
101
|
version: 7,
|
|
@@ -100,8 +108,8 @@ function F(e) {
|
|
|
100
108
|
};
|
|
101
109
|
}
|
|
102
110
|
function Z(e) {
|
|
103
|
-
const
|
|
104
|
-
return
|
|
111
|
+
const r = G.reduce((i, o) => o(i), e), t = K(r);
|
|
112
|
+
return H(t);
|
|
105
113
|
}
|
|
106
114
|
const W = typeof window < "u", E = {
|
|
107
115
|
version: 7,
|
|
@@ -166,89 +174,97 @@ const W = typeof window < "u", E = {
|
|
|
166
174
|
sync: !0,
|
|
167
175
|
devmode: !1
|
|
168
176
|
}
|
|
169
|
-
}, D =
|
|
177
|
+
}, D = j("user", () => {
|
|
170
178
|
const e = z(structuredClone(E));
|
|
171
179
|
I(e, t, { deep: !0 });
|
|
172
|
-
function
|
|
180
|
+
function r() {
|
|
173
181
|
if (!W)
|
|
174
182
|
return;
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
183
|
+
const o = localStorage.getItem("vuetify@user");
|
|
184
|
+
if (o)
|
|
177
185
|
try {
|
|
178
|
-
const
|
|
179
|
-
if (
|
|
186
|
+
const s = JSON.parse(o);
|
|
187
|
+
if (s.version >= 7) {
|
|
180
188
|
const u = {
|
|
181
189
|
version: 7,
|
|
182
|
-
ecosystem: O(structuredClone(E.ecosystem),
|
|
183
|
-
one: O(structuredClone(E.one),
|
|
190
|
+
ecosystem: O(structuredClone(E.ecosystem), s.ecosystem || {}),
|
|
191
|
+
one: O(structuredClone(E.one), s.one || {})
|
|
184
192
|
};
|
|
185
193
|
Object.assign(e, u);
|
|
186
|
-
} else if (
|
|
187
|
-
const u =
|
|
194
|
+
} else if (s.version === 6) {
|
|
195
|
+
const u = H(s), d = {
|
|
188
196
|
version: 7,
|
|
189
197
|
ecosystem: O(structuredClone(E.ecosystem), u.ecosystem || {}),
|
|
190
198
|
one: O(structuredClone(E.one), u.one || {})
|
|
191
199
|
};
|
|
192
200
|
Object.assign(e, d);
|
|
193
201
|
} else {
|
|
194
|
-
const u = Z(
|
|
202
|
+
const u = Z(s);
|
|
195
203
|
Object.assign(e, u);
|
|
196
204
|
}
|
|
197
205
|
t();
|
|
198
|
-
} catch (
|
|
199
|
-
console.error("Failed to load user settings:",
|
|
206
|
+
} catch (s) {
|
|
207
|
+
console.error("Failed to load user settings:", s);
|
|
200
208
|
}
|
|
201
209
|
}
|
|
202
210
|
function t() {
|
|
203
211
|
W && localStorage.setItem("vuetify@user", JSON.stringify(e, null, 2));
|
|
204
212
|
}
|
|
205
|
-
function
|
|
213
|
+
function i() {
|
|
206
214
|
W && (Object.assign(e, structuredClone(E)), t());
|
|
207
215
|
}
|
|
208
|
-
return
|
|
216
|
+
return r(), {
|
|
209
217
|
...M(e),
|
|
210
|
-
load:
|
|
218
|
+
load: r,
|
|
211
219
|
save: t,
|
|
212
|
-
reset:
|
|
220
|
+
reset: i
|
|
213
221
|
};
|
|
214
|
-
}),
|
|
222
|
+
}), J = j("http", {
|
|
215
223
|
state: () => ({
|
|
216
224
|
url: ""
|
|
217
225
|
}),
|
|
218
226
|
actions: {
|
|
219
|
-
async fetch(e,
|
|
227
|
+
async fetch(e, r = {}) {
|
|
220
228
|
const t = await fetch(`${this.url}${e}`, {
|
|
221
229
|
credentials: "include",
|
|
222
|
-
...
|
|
230
|
+
...r
|
|
223
231
|
});
|
|
224
|
-
if (!t.ok)
|
|
225
|
-
|
|
232
|
+
if (!t.ok) {
|
|
233
|
+
const i = await t.text();
|
|
234
|
+
let o = i || `HTTP ${t.status}`;
|
|
235
|
+
try {
|
|
236
|
+
const s = JSON.parse(i);
|
|
237
|
+
o = s.message || s.error || i;
|
|
238
|
+
} catch {
|
|
239
|
+
}
|
|
240
|
+
throw new Error(o);
|
|
241
|
+
}
|
|
226
242
|
return t.status === 204 ? {} : t.json();
|
|
227
243
|
},
|
|
228
|
-
async post(e,
|
|
244
|
+
async post(e, r, t = {}) {
|
|
229
245
|
return this.fetch(e, {
|
|
230
246
|
method: "POST",
|
|
231
247
|
headers: {
|
|
232
248
|
"Content-Type": "application/json"
|
|
233
249
|
},
|
|
234
|
-
body: JSON.stringify(
|
|
250
|
+
body: JSON.stringify(r),
|
|
235
251
|
...t
|
|
236
252
|
});
|
|
237
253
|
},
|
|
238
|
-
async form(e,
|
|
254
|
+
async form(e, r, t = {}) {
|
|
239
255
|
return this.fetch(e, {
|
|
240
256
|
method: "POST",
|
|
241
|
-
body:
|
|
257
|
+
body: r,
|
|
242
258
|
...t
|
|
243
259
|
});
|
|
244
260
|
},
|
|
245
|
-
async get(e,
|
|
246
|
-
return this.fetch(e,
|
|
261
|
+
async get(e, r = {}) {
|
|
262
|
+
return this.fetch(e, r);
|
|
247
263
|
},
|
|
248
|
-
async delete(e,
|
|
264
|
+
async delete(e, r = {}) {
|
|
249
265
|
return this.fetch(e, {
|
|
250
266
|
method: "DELETE",
|
|
251
|
-
...
|
|
267
|
+
...r
|
|
252
268
|
});
|
|
253
269
|
}
|
|
254
270
|
}
|
|
@@ -259,81 +275,81 @@ function Q() {
|
|
|
259
275
|
() => e.query
|
|
260
276
|
);
|
|
261
277
|
}
|
|
262
|
-
const V =
|
|
263
|
-
const e = Q(),
|
|
278
|
+
const V = j("one", () => {
|
|
279
|
+
const e = Q(), r = F(), t = B(), i = J(), o = _(), s = N(!1), u = N(!1), d = T(null), v = T([]), g = m(() => e.value.session_id), A = m(() => d.value?.items[0].plan.interval), h = m(() => d.value?.items[0].plan.type), k = T([]), y = m(() => t.user?.sponsorships.find((n) => n.platform === "stripe" && n.tierName.startsWith("sub_"))), L = m(() => !!y.value?.tierName), c = m(() => t.user?.sponsorships.reduce((n, p) => {
|
|
264
280
|
if (!p.isActive || p.interval === "once")
|
|
265
|
-
return
|
|
281
|
+
return n;
|
|
266
282
|
const b = p.interval === "month" ? p.amount : p.amount / 12;
|
|
267
|
-
return
|
|
268
|
-
}, 0) ?? 0),
|
|
269
|
-
I(u, w), I(g, async (
|
|
270
|
-
|
|
271
|
-
}, { immediate: !0 }), I(e, (
|
|
272
|
-
if (
|
|
283
|
+
return n + b / 100;
|
|
284
|
+
}, 0) ?? 0), a = m(() => t.user?.sponsorships.find((n) => n.tierName.startsWith("sub_") && n.isActive)), f = m(() => t.user?.sponsorships.find((n) => n.platform === "github" && n.isActive)), l = m(() => t.user?.sponsorships.find((n) => n.platform === "discord" && n.isActive)), $ = m(() => t.user?.identities.find((n) => n.provider === "shopify")), U = m(() => !i.url || t.user?.isAdmin || y.value?.isActive || k.value.some((n) => ["one", "one/team"].includes(n)));
|
|
285
|
+
I(u, w), I(g, async (n) => {
|
|
286
|
+
n && await R();
|
|
287
|
+
}, { immediate: !0 }), I(e, (n) => {
|
|
288
|
+
if (n.one !== "subscribe" || t.user)
|
|
273
289
|
return;
|
|
274
290
|
t.dialog = !0;
|
|
275
291
|
const p = I(() => t.user, (b) => {
|
|
276
292
|
b && (t.dialog = !1, p());
|
|
277
293
|
});
|
|
278
294
|
}, { immediate: !0 });
|
|
279
|
-
async function
|
|
295
|
+
async function R() {
|
|
280
296
|
try {
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
p.delete("session_id"), p.delete("team"), history.pushState(null, "",
|
|
284
|
-
} catch (
|
|
285
|
-
|
|
297
|
+
s.value = !0, await i.post("/one/activate", { sessionId: g.value }), await t.verify(!0), await q();
|
|
298
|
+
const n = new URL(window.location.href), p = n.searchParams;
|
|
299
|
+
p.delete("session_id"), p.delete("team"), history.pushState(null, "", n.toString());
|
|
300
|
+
} catch (n) {
|
|
301
|
+
o.showError(n?.message ?? "Error activating subscription, Please contact support");
|
|
286
302
|
} finally {
|
|
287
|
-
|
|
303
|
+
s.value = !1;
|
|
288
304
|
}
|
|
289
305
|
}
|
|
290
306
|
async function S() {
|
|
291
|
-
window.open(`${
|
|
307
|
+
window.open(`${i.url}/one/manage`, "_blank");
|
|
292
308
|
}
|
|
293
|
-
async function
|
|
294
|
-
|
|
295
|
-
const b = new URL("/one/subscribe",
|
|
296
|
-
b.searchParams.set("interval",
|
|
309
|
+
async function x(n, p) {
|
|
310
|
+
s.value = !0;
|
|
311
|
+
const b = new URL("/one/subscribe", i.url);
|
|
312
|
+
b.searchParams.set("interval", n), b.searchParams.set("type", p), window.location.href = b.toString();
|
|
297
313
|
}
|
|
298
|
-
async function
|
|
314
|
+
async function C() {
|
|
299
315
|
if (y.value)
|
|
300
316
|
try {
|
|
301
|
-
|
|
317
|
+
s.value = !0, await i.post(
|
|
302
318
|
`/one/cancel?subscriptionId=${y.value?.tierName}`
|
|
303
319
|
), await t.verify(!0);
|
|
304
|
-
} catch (
|
|
305
|
-
|
|
320
|
+
} catch (n) {
|
|
321
|
+
o.showError(n?.message ?? "Error cancelling subscription, Please contact support");
|
|
306
322
|
} finally {
|
|
307
|
-
|
|
323
|
+
s.value = !1;
|
|
308
324
|
}
|
|
309
325
|
}
|
|
310
|
-
async function P(
|
|
326
|
+
async function P(n, p) {
|
|
311
327
|
if (y.value)
|
|
312
328
|
try {
|
|
313
|
-
|
|
329
|
+
s.value = !0, await i.post("/one/modify", {
|
|
314
330
|
subscriptionId: y.value.tierName,
|
|
315
|
-
interval:
|
|
331
|
+
interval: n,
|
|
316
332
|
type: p
|
|
317
333
|
}), await t.verify(!0);
|
|
318
334
|
} catch (b) {
|
|
319
|
-
|
|
335
|
+
o.showError(b?.message ?? "Error modifying subscription");
|
|
320
336
|
} finally {
|
|
321
|
-
|
|
337
|
+
s.value = !1;
|
|
322
338
|
}
|
|
323
339
|
}
|
|
324
340
|
async function q() {
|
|
325
341
|
try {
|
|
326
|
-
|
|
327
|
-
const
|
|
328
|
-
return d.value =
|
|
329
|
-
} catch (
|
|
330
|
-
|
|
342
|
+
s.value = !0;
|
|
343
|
+
const n = await i.get("/one/info");
|
|
344
|
+
return d.value = n.subscription, v.value = n.invoices, n;
|
|
345
|
+
} catch (n) {
|
|
346
|
+
o.showError(n?.message ?? "Error fetching subscription info");
|
|
331
347
|
} finally {
|
|
332
|
-
|
|
348
|
+
s.value = !1;
|
|
333
349
|
}
|
|
334
350
|
}
|
|
335
351
|
function w() {
|
|
336
|
-
|
|
352
|
+
r.push({
|
|
337
353
|
query: {
|
|
338
354
|
...e.value,
|
|
339
355
|
one: void 0
|
|
@@ -349,67 +365,67 @@ const V = L("one", () => {
|
|
|
349
365
|
sessionId: g,
|
|
350
366
|
subscription: y,
|
|
351
367
|
monthlyTotal: c,
|
|
352
|
-
hasBilling:
|
|
353
|
-
isLoading:
|
|
368
|
+
hasBilling: L,
|
|
369
|
+
isLoading: s,
|
|
354
370
|
isOpen: u,
|
|
355
|
-
isSubscriber:
|
|
371
|
+
isSubscriber: U,
|
|
356
372
|
github: f,
|
|
357
373
|
discord: l,
|
|
358
374
|
shopify: $,
|
|
359
|
-
one:
|
|
360
|
-
activate:
|
|
361
|
-
cancel:
|
|
375
|
+
one: a,
|
|
376
|
+
activate: R,
|
|
377
|
+
cancel: C,
|
|
362
378
|
manage: S,
|
|
363
379
|
modify: P,
|
|
364
380
|
resetQuery: w,
|
|
365
|
-
subscribe:
|
|
381
|
+
subscribe: x,
|
|
366
382
|
subscriptionInfo: q
|
|
367
383
|
};
|
|
368
|
-
}), ee =
|
|
369
|
-
const e = Q(),
|
|
384
|
+
}), ee = j("team", () => {
|
|
385
|
+
const e = Q(), r = B(), t = V(), i = J(), o = _(), s = N(!1), u = T(null), d = T(!1), v = m(() => e.value.invite), g = m(
|
|
370
386
|
() => u.value ? t.access?.some((c) => ["one/team", "snips/team"].includes(c)) : !1
|
|
371
387
|
);
|
|
372
388
|
I(v, async () => {
|
|
373
389
|
if (v.value) {
|
|
374
|
-
|
|
390
|
+
r.user || (r.dialog = !0);
|
|
375
391
|
try {
|
|
376
|
-
|
|
377
|
-
const c = await
|
|
392
|
+
s.value = !0;
|
|
393
|
+
const c = await i.get(`/one/team/${v.value}`);
|
|
378
394
|
u.value = c.team, d.value = !0;
|
|
379
395
|
} catch (c) {
|
|
380
|
-
y(),
|
|
396
|
+
y(), o.showError(c.message);
|
|
381
397
|
} finally {
|
|
382
|
-
|
|
398
|
+
s.value = !1;
|
|
383
399
|
}
|
|
384
400
|
}
|
|
385
401
|
}, { immediate: !0 });
|
|
386
402
|
async function A(c) {
|
|
387
403
|
try {
|
|
388
|
-
if (
|
|
404
|
+
if (s.value = !0, !u.value)
|
|
389
405
|
return;
|
|
390
|
-
await
|
|
391
|
-
} catch (
|
|
392
|
-
|
|
406
|
+
await i.post("/one/team/remove", { userId: c }), u.value.members = u.value.members.filter((a) => a.id !== c);
|
|
407
|
+
} catch (a) {
|
|
408
|
+
o.showError(a?.message ?? "Error removing user from team");
|
|
393
409
|
} finally {
|
|
394
|
-
|
|
410
|
+
s.value = !1;
|
|
395
411
|
}
|
|
396
412
|
}
|
|
397
413
|
async function h() {
|
|
398
414
|
try {
|
|
399
|
-
|
|
415
|
+
s.value = !0, await i.post("/one/team/leave", { teamId: u.value?.id }), await r.verify(!0);
|
|
400
416
|
} catch (c) {
|
|
401
|
-
|
|
417
|
+
o.showError(c?.message ?? "Error leaving team");
|
|
402
418
|
} finally {
|
|
403
|
-
|
|
419
|
+
s.value = !1;
|
|
404
420
|
}
|
|
405
421
|
}
|
|
406
422
|
async function k() {
|
|
407
423
|
try {
|
|
408
|
-
|
|
424
|
+
s.value = !0, await i.post("/one/team/join", { inviteCode: v.value }), await r.verify(!0), y();
|
|
409
425
|
} catch (c) {
|
|
410
|
-
|
|
426
|
+
o.showError(c?.message ?? "Error joining team");
|
|
411
427
|
} finally {
|
|
412
|
-
|
|
428
|
+
s.value = !1;
|
|
413
429
|
}
|
|
414
430
|
}
|
|
415
431
|
function y() {
|
|
@@ -417,130 +433,130 @@ const V = L("one", () => {
|
|
|
417
433
|
const c = new URL(window.location.href);
|
|
418
434
|
c.searchParams.delete("invite"), window.history.replaceState({}, "", c.toString());
|
|
419
435
|
}
|
|
420
|
-
const
|
|
436
|
+
const L = m(() => r.user?.id === r.user?.team?.owner.id);
|
|
421
437
|
return {
|
|
422
438
|
team: u,
|
|
423
439
|
teamInviteDialog: d,
|
|
424
440
|
teamInviteCode: v,
|
|
425
441
|
hasTeamAccess: g,
|
|
426
|
-
isTeamOwner:
|
|
427
|
-
isLoading:
|
|
442
|
+
isTeamOwner: L,
|
|
443
|
+
isLoading: s,
|
|
428
444
|
removeFromTeam: A,
|
|
429
445
|
leaveTeam: h,
|
|
430
446
|
joinTeam: k,
|
|
431
447
|
clearTeamQuery: y
|
|
432
448
|
};
|
|
433
|
-
}), B =
|
|
434
|
-
const e = T(!1),
|
|
449
|
+
}), B = j("auth", () => {
|
|
450
|
+
const e = T(!1), r = T(null), t = J(), i = D(), o = F(), s = N(!1), u = V(), d = ee(), v = _();
|
|
435
451
|
let g = !!c();
|
|
436
|
-
I(
|
|
437
|
-
if (!
|
|
452
|
+
I(r, (a) => {
|
|
453
|
+
if (!a?.settings)
|
|
438
454
|
return;
|
|
439
455
|
const f = localStorage.getItem("vuetify@user") || "{}";
|
|
440
|
-
if (JSON.stringify(
|
|
456
|
+
if (JSON.stringify(a.settings, null, 2) === f)
|
|
441
457
|
return;
|
|
442
458
|
g = !0;
|
|
443
|
-
let l =
|
|
444
|
-
l.version === 6 && (l =
|
|
459
|
+
let l = a.settings;
|
|
460
|
+
l.version === 6 && (l = H(l));
|
|
445
461
|
const $ = {
|
|
446
462
|
version: 7,
|
|
447
463
|
ecosystem: O(structuredClone(E.ecosystem), l.ecosystem || {}),
|
|
448
464
|
one: O(structuredClone(E.one), l.one || {})
|
|
449
465
|
};
|
|
450
|
-
Object.assign(
|
|
451
|
-
}),
|
|
466
|
+
Object.assign(i, $);
|
|
467
|
+
}), i.$subscribe(() => {
|
|
452
468
|
g || A(), g = !1;
|
|
453
469
|
});
|
|
454
470
|
async function A() {
|
|
455
|
-
if (await X(), !(!
|
|
471
|
+
if (await X(), !(!r.value || !i.one.sync))
|
|
456
472
|
try {
|
|
457
|
-
await t.post("/user/settings", { settings:
|
|
458
|
-
} catch (
|
|
459
|
-
v.showError(
|
|
473
|
+
await t.post("/user/settings", { settings: i.$state }), await h(!0);
|
|
474
|
+
} catch (a) {
|
|
475
|
+
v.showError(a?.message ?? "Error syncing settings");
|
|
460
476
|
}
|
|
461
477
|
}
|
|
462
|
-
async function h(
|
|
478
|
+
async function h(a = !1) {
|
|
463
479
|
if (h.promise)
|
|
464
480
|
return h.promise;
|
|
465
|
-
if (!
|
|
466
|
-
|
|
481
|
+
if (!a && !document.cookie.includes("sx=1") && location.hostname.match(/([^.]+\.[^.]+)$/)?.[1] === new URL(t.url).hostname.match(/([^.]+\.[^.]+)$/)?.[1]) {
|
|
482
|
+
r.value = null;
|
|
467
483
|
return;
|
|
468
484
|
}
|
|
469
|
-
|
|
485
|
+
s.value = !0, h.promise = fetch(`${t.url}/auth/verify`, {
|
|
470
486
|
credentials: "include",
|
|
471
|
-
cache:
|
|
487
|
+
cache: a ? "reload" : void 0
|
|
472
488
|
}).then(
|
|
473
489
|
async (f) => {
|
|
474
490
|
if (f.ok || f.status === 401) {
|
|
475
491
|
const l = await f.json();
|
|
476
|
-
|
|
492
|
+
r.value = l.user, u.access = l.access, d.team = l.user?.team;
|
|
477
493
|
} else
|
|
478
494
|
console.error(f.statusText);
|
|
479
495
|
},
|
|
480
496
|
() => {
|
|
481
497
|
}
|
|
482
498
|
).finally(() => {
|
|
483
|
-
|
|
499
|
+
s.value = !1, h.promise = null;
|
|
484
500
|
});
|
|
485
501
|
}
|
|
486
502
|
h.promise = null;
|
|
487
|
-
async function k(
|
|
488
|
-
|
|
489
|
-
const f = `${t.url}/auth/${
|
|
490
|
-
if (
|
|
503
|
+
async function k(a = "github") {
|
|
504
|
+
s.value = !0;
|
|
505
|
+
const f = `${t.url}/auth/${a}/redirect`;
|
|
506
|
+
if (a === "shopify") {
|
|
491
507
|
window.location.assign(f + "?next=" + encodeURIComponent(window.location.href));
|
|
492
508
|
return;
|
|
493
509
|
}
|
|
494
|
-
const l = 400, $ = 600,
|
|
510
|
+
const l = 400, $ = 600, U = window.screenX + (window.innerWidth - l) / 2, R = window.screenY + (window.innerHeight - $) / 2, S = window.open(
|
|
495
511
|
"",
|
|
496
512
|
"vuetify:authorize:popup",
|
|
497
|
-
`popup,left=${
|
|
513
|
+
`popup,left=${U},top=${R},width=${l},height=${$},resizable`
|
|
498
514
|
);
|
|
499
515
|
if (!S) {
|
|
500
516
|
console.error("Failed to open popup");
|
|
501
517
|
return;
|
|
502
518
|
}
|
|
503
519
|
S.location.href = f;
|
|
504
|
-
let
|
|
520
|
+
let x = -1, C = -1;
|
|
505
521
|
function P(w) {
|
|
506
|
-
w.origin === t.url && w.data?.type === "auth-response" && (w.data.status === "success" ? (
|
|
522
|
+
w.origin === t.url && w.data?.type === "auth-response" && (w.data.status === "success" ? (r.value || (localStorage.setItem("vuetify@lastLoginProvider", a), e.value = !1, o.push("/user/dashboard")), r.value = w.data.body.user, u.access = w.data.body.access, d.team = w.data.body.user?.team, A()) : console.error(w.data.message), q());
|
|
507
523
|
}
|
|
508
524
|
function q() {
|
|
509
|
-
window.removeEventListener("message", P), window.clearInterval(
|
|
525
|
+
window.removeEventListener("message", P), window.clearInterval(x), window.clearTimeout(C), S?.close(), s.value = !1;
|
|
510
526
|
}
|
|
511
|
-
window.addEventListener("message", P),
|
|
527
|
+
window.addEventListener("message", P), x = window.setInterval(() => {
|
|
512
528
|
!S || S.closed ? (console.error("Auth popup closed"), q()) : S.postMessage({ type: "auth-request" }, "*");
|
|
513
|
-
}, 1e3),
|
|
529
|
+
}, 1e3), C = window.setTimeout(() => {
|
|
514
530
|
q(), console.error("Auth timed out");
|
|
515
531
|
}, 120 * 1e3);
|
|
516
532
|
}
|
|
517
|
-
async function y(
|
|
518
|
-
|
|
519
|
-
const f =
|
|
533
|
+
async function y(a) {
|
|
534
|
+
s.value = !0;
|
|
535
|
+
const f = a ? `/auth/${a}/logout` : "/auth/logout";
|
|
520
536
|
try {
|
|
521
|
-
await t.post(f), await h(!0),
|
|
537
|
+
await t.post(f), await h(!0), r.value = null;
|
|
522
538
|
} catch (l) {
|
|
523
539
|
v.showError(l?.message ?? "Error logging out");
|
|
524
540
|
} finally {
|
|
525
|
-
|
|
541
|
+
o.push({
|
|
526
542
|
path: "/",
|
|
527
|
-
query:
|
|
528
|
-
}),
|
|
543
|
+
query: o.currentRoute.value.query
|
|
544
|
+
}), s.value = !1;
|
|
529
545
|
}
|
|
530
546
|
}
|
|
531
|
-
function
|
|
532
|
-
return
|
|
547
|
+
function L(a) {
|
|
548
|
+
return r.value?.identities.find((f) => f.provider === a);
|
|
533
549
|
}
|
|
534
550
|
function c() {
|
|
535
551
|
return localStorage.getItem("vuetify@lastLoginProvider");
|
|
536
552
|
}
|
|
537
553
|
return h(), {
|
|
538
|
-
user:
|
|
554
|
+
user: r,
|
|
539
555
|
url: t.url,
|
|
540
556
|
dialog: e,
|
|
541
|
-
isLoading:
|
|
557
|
+
isLoading: s,
|
|
542
558
|
verify: h,
|
|
543
|
-
findIdentity:
|
|
559
|
+
findIdentity: L,
|
|
544
560
|
login: k,
|
|
545
561
|
logout: y,
|
|
546
562
|
lastLoginProvider: c,
|
|
@@ -552,7 +568,7 @@ export {
|
|
|
552
568
|
D as b,
|
|
553
569
|
V as c,
|
|
554
570
|
Q as d,
|
|
555
|
-
|
|
571
|
+
J as e,
|
|
556
572
|
ee as f,
|
|
557
573
|
_ as u
|
|
558
574
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -995,8 +995,9 @@ interface QueueState {
|
|
|
995
995
|
queue: Ref<Snackbar[]>;
|
|
996
996
|
show: (text: Snackbar) => void;
|
|
997
997
|
showError: (text: Snackbar) => void;
|
|
998
|
+
showSuccess: (text: Snackbar) => void;
|
|
998
999
|
}
|
|
999
|
-
declare const useQueueStore: pinia.StoreDefinition<"queue", Pick<QueueState, "queue">, Pick<QueueState, never>, Pick<QueueState, "show" | "showError">>;
|
|
1000
|
+
declare const useQueueStore: pinia.StoreDefinition<"queue", Pick<QueueState, "queue">, Pick<QueueState, never>, Pick<QueueState, "show" | "showError" | "showSuccess">>;
|
|
1000
1001
|
|
|
1001
1002
|
interface VOneSuit {
|
|
1002
1003
|
'app-bar': string;
|