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