@vuetify/one 2.8.2 → 2.9.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-CXrXnM17.js +578 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +1 -1
- package/dist/stores/auth.d.ts +8 -3
- package/dist/stores/auth.js +1 -1
- package/package.json +1 -1
- package/dist/auth-CwLSOnno.js +0 -574
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
import { merge as q } from "lodash-es";
|
|
2
|
+
import { defineStore as O } from "pinia";
|
|
3
|
+
import { ref as b, reactive as X, watch as I, toRefs as Y, computed as p, shallowRef as P, toRef as C, nextTick as G } from "vue";
|
|
4
|
+
import { useRoute as K, useRouter as V } from "vue-router";
|
|
5
|
+
const J = O("queue", () => {
|
|
6
|
+
const e = b([]);
|
|
7
|
+
function t(o) {
|
|
8
|
+
const r = typeof o == "string" ? { text: o } : o;
|
|
9
|
+
e.value.push(r);
|
|
10
|
+
}
|
|
11
|
+
function s(o) {
|
|
12
|
+
t({
|
|
13
|
+
color: "error",
|
|
14
|
+
text: o,
|
|
15
|
+
location: "top end",
|
|
16
|
+
timeout: -1
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function i(o) {
|
|
20
|
+
t({
|
|
21
|
+
color: "success",
|
|
22
|
+
text: o,
|
|
23
|
+
location: "top end"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
queue: e,
|
|
28
|
+
show: t,
|
|
29
|
+
showError: s,
|
|
30
|
+
showSuccess: i
|
|
31
|
+
};
|
|
32
|
+
}), Z = [
|
|
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),
|
|
34
|
+
(e) => (e.v === 1 && (Array.isArray(e.composition) && (e.composition = "composition"), Array.isArray(e.notifications?.last?.banner) || (e.notifications = e.notifications || {}, e.notifications.last = e.notifications.last || {}, e.notifications.last.banner = []), e.v = 2), e),
|
|
35
|
+
(e) => (e.v === 2 && (e.syncSettings = !0, e.disableAds = !1, e.v = 3), e),
|
|
36
|
+
(e) => (e.v === 3 && (e.quickbar = !1, e.v = 4), e),
|
|
37
|
+
(e) => (e.v === 4 && (e.suits = { show: !1, elements: ["app-bar"], suit: "" }, e.notifications = e.notifications || {}, e.notifications.banners = !0, e.v = 5), e)
|
|
38
|
+
];
|
|
39
|
+
function D(e) {
|
|
40
|
+
return {
|
|
41
|
+
version: 6,
|
|
42
|
+
ecosystem: {
|
|
43
|
+
bin: {
|
|
44
|
+
wordWrap: !1
|
|
45
|
+
},
|
|
46
|
+
play: {
|
|
47
|
+
showErrors: !0,
|
|
48
|
+
wordWrap: !1
|
|
49
|
+
},
|
|
50
|
+
studio: {},
|
|
51
|
+
link: {},
|
|
52
|
+
docs: {
|
|
53
|
+
api: e.api || "link-only",
|
|
54
|
+
composition: e.composition || "composition",
|
|
55
|
+
pins: {
|
|
56
|
+
enabled: e.pins || !1,
|
|
57
|
+
pinned: Array.isArray(e.pinned) ? e.pinned.map((t) => t.name || t).filter(Boolean) : []
|
|
58
|
+
},
|
|
59
|
+
mixedTheme: e.mixedTheme ?? !0,
|
|
60
|
+
favorites: [],
|
|
61
|
+
slashSearch: e.slashSearch || !1,
|
|
62
|
+
railDrawer: e.railDrawer || !1
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
one: {
|
|
66
|
+
avatar: e.avatar || "",
|
|
67
|
+
ads: {
|
|
68
|
+
enabled: !e.disableAds,
|
|
69
|
+
house: e.showHouseAds || !1
|
|
70
|
+
},
|
|
71
|
+
command: {},
|
|
72
|
+
theme: e.theme || "system",
|
|
73
|
+
direction: e.direction || "ltr",
|
|
74
|
+
colors: {
|
|
75
|
+
primary: e.colors?.one || "surface-light"
|
|
76
|
+
},
|
|
77
|
+
suits: {
|
|
78
|
+
enabled: e.suits?.show || !1,
|
|
79
|
+
elements: e.suits?.elements || ["app-bar"],
|
|
80
|
+
suit: e.suits?.suit || ""
|
|
81
|
+
},
|
|
82
|
+
notifications: {
|
|
83
|
+
enabled: e.notifications?.show ?? !0,
|
|
84
|
+
read: e.notifications?.read || [],
|
|
85
|
+
last: ""
|
|
86
|
+
},
|
|
87
|
+
banners: {
|
|
88
|
+
enabled: e.notifications?.banners ?? !0,
|
|
89
|
+
read: e.notifications?.last?.banner || [],
|
|
90
|
+
last: ""
|
|
91
|
+
},
|
|
92
|
+
quicklinks: e.quickbar || !1,
|
|
93
|
+
sync: e.syncSettings ?? !0,
|
|
94
|
+
devmode: e.dev || !1
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function F(e) {
|
|
99
|
+
return {
|
|
100
|
+
...e,
|
|
101
|
+
version: 7,
|
|
102
|
+
ecosystem: {
|
|
103
|
+
...e.ecosystem,
|
|
104
|
+
mcp: {
|
|
105
|
+
seen: !1
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function ee(e) {
|
|
111
|
+
const t = Z.reduce((i, o) => o(i), e), s = D(t);
|
|
112
|
+
return F(s);
|
|
113
|
+
}
|
|
114
|
+
const H = typeof window < "u", g = {
|
|
115
|
+
version: 7,
|
|
116
|
+
ecosystem: {
|
|
117
|
+
bin: {
|
|
118
|
+
wordWrap: !0
|
|
119
|
+
},
|
|
120
|
+
play: {
|
|
121
|
+
showErrors: !0,
|
|
122
|
+
wordWrap: !1
|
|
123
|
+
},
|
|
124
|
+
studio: {},
|
|
125
|
+
link: {},
|
|
126
|
+
docs: {
|
|
127
|
+
api: "link-only",
|
|
128
|
+
composition: "composition",
|
|
129
|
+
pins: {
|
|
130
|
+
enabled: !1,
|
|
131
|
+
pinned: []
|
|
132
|
+
},
|
|
133
|
+
mixedTheme: !0,
|
|
134
|
+
favorites: [],
|
|
135
|
+
slashSearch: !1,
|
|
136
|
+
railDrawer: !1
|
|
137
|
+
},
|
|
138
|
+
mcp: {
|
|
139
|
+
seen: !1
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
one: {
|
|
143
|
+
avatar: "",
|
|
144
|
+
ads: {
|
|
145
|
+
enabled: !0,
|
|
146
|
+
house: !1
|
|
147
|
+
},
|
|
148
|
+
command: {},
|
|
149
|
+
theme: "system",
|
|
150
|
+
direction: "ltr",
|
|
151
|
+
colors: {
|
|
152
|
+
primary: "surface-light"
|
|
153
|
+
},
|
|
154
|
+
suits: {
|
|
155
|
+
enabled: !1,
|
|
156
|
+
elements: ["app-bar"],
|
|
157
|
+
suit: ""
|
|
158
|
+
},
|
|
159
|
+
notifications: {
|
|
160
|
+
enabled: !0,
|
|
161
|
+
read: [],
|
|
162
|
+
last: ""
|
|
163
|
+
},
|
|
164
|
+
banners: {
|
|
165
|
+
enabled: !0,
|
|
166
|
+
read: [],
|
|
167
|
+
last: ""
|
|
168
|
+
},
|
|
169
|
+
quicklinks: !1,
|
|
170
|
+
ecosystem: {
|
|
171
|
+
pinned: [],
|
|
172
|
+
seen: !1
|
|
173
|
+
},
|
|
174
|
+
sync: !0,
|
|
175
|
+
devmode: !1
|
|
176
|
+
}
|
|
177
|
+
}, te = O("user", () => {
|
|
178
|
+
const e = X(structuredClone(g));
|
|
179
|
+
I(e, s, { deep: !0 });
|
|
180
|
+
function t() {
|
|
181
|
+
if (!H)
|
|
182
|
+
return;
|
|
183
|
+
const o = localStorage.getItem("vuetify@user");
|
|
184
|
+
if (o)
|
|
185
|
+
try {
|
|
186
|
+
const r = JSON.parse(o);
|
|
187
|
+
if (r.version >= 7) {
|
|
188
|
+
const u = {
|
|
189
|
+
version: 7,
|
|
190
|
+
ecosystem: q(structuredClone(g.ecosystem), r.ecosystem || {}),
|
|
191
|
+
one: q(structuredClone(g.one), r.one || {})
|
|
192
|
+
};
|
|
193
|
+
Object.assign(e, u);
|
|
194
|
+
} else if (r.version === 6) {
|
|
195
|
+
const u = F(r), h = {
|
|
196
|
+
version: 7,
|
|
197
|
+
ecosystem: q(structuredClone(g.ecosystem), u.ecosystem || {}),
|
|
198
|
+
one: q(structuredClone(g.one), u.one || {})
|
|
199
|
+
};
|
|
200
|
+
Object.assign(e, h);
|
|
201
|
+
} else {
|
|
202
|
+
const u = ee(r);
|
|
203
|
+
Object.assign(e, u);
|
|
204
|
+
}
|
|
205
|
+
s();
|
|
206
|
+
} catch (r) {
|
|
207
|
+
console.error("Failed to load user settings:", r);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function s() {
|
|
211
|
+
H && localStorage.setItem("vuetify@user", JSON.stringify(e, null, 2));
|
|
212
|
+
}
|
|
213
|
+
function i() {
|
|
214
|
+
H && (Object.assign(e, structuredClone(g)), s());
|
|
215
|
+
}
|
|
216
|
+
return t(), {
|
|
217
|
+
...Y(e),
|
|
218
|
+
load: t,
|
|
219
|
+
save: s,
|
|
220
|
+
reset: i
|
|
221
|
+
};
|
|
222
|
+
}), Q = O("http", {
|
|
223
|
+
state: () => ({
|
|
224
|
+
url: ""
|
|
225
|
+
}),
|
|
226
|
+
actions: {
|
|
227
|
+
async fetch(e, t = {}) {
|
|
228
|
+
const s = await fetch(`${this.url}${e}`, {
|
|
229
|
+
credentials: "include",
|
|
230
|
+
...t
|
|
231
|
+
});
|
|
232
|
+
if (!s.ok) {
|
|
233
|
+
const i = await s.text();
|
|
234
|
+
let o = i || `HTTP ${s.status}`;
|
|
235
|
+
try {
|
|
236
|
+
const r = JSON.parse(i);
|
|
237
|
+
o = r.message || r.error || i;
|
|
238
|
+
} catch {
|
|
239
|
+
}
|
|
240
|
+
throw new Error(o);
|
|
241
|
+
}
|
|
242
|
+
return s.status === 204 ? {} : s.json();
|
|
243
|
+
},
|
|
244
|
+
async post(e, t, s = {}) {
|
|
245
|
+
return this.fetch(e, {
|
|
246
|
+
method: "POST",
|
|
247
|
+
headers: {
|
|
248
|
+
"Content-Type": "application/json"
|
|
249
|
+
},
|
|
250
|
+
body: JSON.stringify(t),
|
|
251
|
+
...s
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
async form(e, t, s = {}) {
|
|
255
|
+
return this.fetch(e, {
|
|
256
|
+
method: "POST",
|
|
257
|
+
body: t,
|
|
258
|
+
...s
|
|
259
|
+
});
|
|
260
|
+
},
|
|
261
|
+
async get(e, t = {}) {
|
|
262
|
+
return this.fetch(e, t);
|
|
263
|
+
},
|
|
264
|
+
async delete(e, t = {}) {
|
|
265
|
+
return this.fetch(e, {
|
|
266
|
+
method: "DELETE",
|
|
267
|
+
...t
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
function B() {
|
|
273
|
+
const e = K();
|
|
274
|
+
return p(
|
|
275
|
+
() => e.query
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
const z = O("one", () => {
|
|
279
|
+
const e = B(), t = V(), s = M(), i = Q(), o = J(), r = P(!1), u = P(!1), h = b(null), v = b([]), S = p(() => e.value.session_id), R = p(() => h.value?.items[0].plan.interval), j = p(() => h.value?.items[0].plan.type), k = b([]), d = p(() => s.user?.sponsorships.find((n) => n.platform === "stripe" && n.tierName.startsWith("sub_"))), E = p(() => !!d.value?.tierName), a = p(() => s.user?.sponsorships.reduce((n, l) => {
|
|
280
|
+
if (!l.isActive || l.interval === "once")
|
|
281
|
+
return n;
|
|
282
|
+
const y = l.interval === "month" ? l.amount : l.amount / 12;
|
|
283
|
+
return n + y / 100;
|
|
284
|
+
}, 0) ?? 0), T = p(() => s.user?.sponsorships.find((n) => n.tierName.startsWith("sub_") && n.isActive)), N = p(() => s.user?.sponsorships.find((n) => n.platform === "github" && n.isActive)), U = p(() => s.user?.sponsorships.find((n) => n.platform === "discord" && n.isActive)), x = p(() => s.user?.identities.find((n) => n.provider === "shopify")), c = p(() => !i.url || s.isAdmin || d.value?.isActive || k.value.some((n) => ["one", "one/team"].includes(n)));
|
|
285
|
+
I(u, L), I(S, async (n) => {
|
|
286
|
+
n && await f();
|
|
287
|
+
}, { immediate: !0 }), I(e, (n) => {
|
|
288
|
+
if (n.one !== "subscribe" || s.user)
|
|
289
|
+
return;
|
|
290
|
+
s.dialog = !0;
|
|
291
|
+
const l = I(() => s.user, (y) => {
|
|
292
|
+
y && (s.dialog = !1, l());
|
|
293
|
+
});
|
|
294
|
+
}, { immediate: !0 });
|
|
295
|
+
async function f() {
|
|
296
|
+
try {
|
|
297
|
+
r.value = !0, await i.post("/one/activate", { sessionId: S.value }), await s.verify(!0), await w();
|
|
298
|
+
const n = new URL(window.location.href), l = n.searchParams;
|
|
299
|
+
l.delete("session_id"), l.delete("team"), history.pushState(null, "", n.toString());
|
|
300
|
+
} catch (n) {
|
|
301
|
+
o.showError(n?.message ?? "Error activating subscription, Please contact support");
|
|
302
|
+
} finally {
|
|
303
|
+
r.value = !1;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
async function m() {
|
|
307
|
+
window.open(`${i.url}/one/manage`, "_blank");
|
|
308
|
+
}
|
|
309
|
+
async function $(n, l) {
|
|
310
|
+
r.value = !0;
|
|
311
|
+
const y = new URL("/one/subscribe", i.url);
|
|
312
|
+
y.searchParams.set("interval", n), y.searchParams.set("type", l), window.location.href = y.toString();
|
|
313
|
+
}
|
|
314
|
+
async function W() {
|
|
315
|
+
if (d.value)
|
|
316
|
+
try {
|
|
317
|
+
r.value = !0, await i.post(
|
|
318
|
+
`/one/cancel?subscriptionId=${d.value?.tierName}`
|
|
319
|
+
), await s.verify(!0);
|
|
320
|
+
} catch (n) {
|
|
321
|
+
o.showError(n?.message ?? "Error cancelling subscription, Please contact support");
|
|
322
|
+
} finally {
|
|
323
|
+
r.value = !1;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
async function _(n, l) {
|
|
327
|
+
if (d.value)
|
|
328
|
+
try {
|
|
329
|
+
r.value = !0, await i.post("/one/modify", {
|
|
330
|
+
subscriptionId: d.value.tierName,
|
|
331
|
+
interval: n,
|
|
332
|
+
type: l
|
|
333
|
+
}), await s.verify(!0);
|
|
334
|
+
} catch (y) {
|
|
335
|
+
o.showError(y?.message ?? "Error modifying subscription");
|
|
336
|
+
} finally {
|
|
337
|
+
r.value = !1;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
async function w() {
|
|
341
|
+
try {
|
|
342
|
+
r.value = !0;
|
|
343
|
+
const n = await i.get("/one/info");
|
|
344
|
+
return h.value = n.subscription, v.value = n.invoices, n;
|
|
345
|
+
} catch (n) {
|
|
346
|
+
o.showError(n?.message ?? "Error fetching subscription info");
|
|
347
|
+
} finally {
|
|
348
|
+
r.value = !1;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function L() {
|
|
352
|
+
t.push({
|
|
353
|
+
query: {
|
|
354
|
+
...e.value,
|
|
355
|
+
one: void 0
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
return {
|
|
360
|
+
info: h,
|
|
361
|
+
interval: R,
|
|
362
|
+
subscriptionType: j,
|
|
363
|
+
access: k,
|
|
364
|
+
invoices: v,
|
|
365
|
+
sessionId: S,
|
|
366
|
+
subscription: d,
|
|
367
|
+
monthlyTotal: a,
|
|
368
|
+
hasBilling: E,
|
|
369
|
+
isLoading: r,
|
|
370
|
+
isOpen: u,
|
|
371
|
+
isSubscriber: c,
|
|
372
|
+
github: N,
|
|
373
|
+
discord: U,
|
|
374
|
+
shopify: x,
|
|
375
|
+
one: T,
|
|
376
|
+
activate: f,
|
|
377
|
+
cancel: W,
|
|
378
|
+
manage: m,
|
|
379
|
+
modify: _,
|
|
380
|
+
resetQuery: L,
|
|
381
|
+
subscribe: $,
|
|
382
|
+
subscriptionInfo: w
|
|
383
|
+
};
|
|
384
|
+
}), se = O("team", () => {
|
|
385
|
+
const e = B(), t = M(), s = z(), i = Q(), o = J(), r = P(!1), u = b(null), h = b(!1), v = p(() => e.value.invite), S = p(
|
|
386
|
+
() => u.value ? s.access?.some((a) => ["one/team", "snips/team"].includes(a)) : !1
|
|
387
|
+
);
|
|
388
|
+
I(v, async () => {
|
|
389
|
+
if (v.value) {
|
|
390
|
+
t.user || (t.dialog = !0);
|
|
391
|
+
try {
|
|
392
|
+
r.value = !0;
|
|
393
|
+
const a = await i.get(`/one/team/${v.value}`);
|
|
394
|
+
u.value = a.team, h.value = !0;
|
|
395
|
+
} catch (a) {
|
|
396
|
+
d(), o.showError(a.message);
|
|
397
|
+
} finally {
|
|
398
|
+
r.value = !1;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}, { immediate: !0 });
|
|
402
|
+
async function R(a) {
|
|
403
|
+
try {
|
|
404
|
+
if (r.value = !0, !u.value)
|
|
405
|
+
return;
|
|
406
|
+
await i.post("/one/team/remove", { userId: a }), u.value.members = u.value.members.filter((T) => T.id !== a);
|
|
407
|
+
} catch (T) {
|
|
408
|
+
o.showError(T?.message ?? "Error removing user from team");
|
|
409
|
+
} finally {
|
|
410
|
+
r.value = !1;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
async function j() {
|
|
414
|
+
try {
|
|
415
|
+
r.value = !0, await i.post("/one/team/leave", { teamId: u.value?.id }), await t.verify(!0);
|
|
416
|
+
} catch (a) {
|
|
417
|
+
o.showError(a?.message ?? "Error leaving team");
|
|
418
|
+
} finally {
|
|
419
|
+
r.value = !1;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
async function k() {
|
|
423
|
+
try {
|
|
424
|
+
r.value = !0, await i.post("/one/team/join", { inviteCode: v.value }), await t.verify(!0), d();
|
|
425
|
+
} catch (a) {
|
|
426
|
+
o.showError(a?.message ?? "Error joining team");
|
|
427
|
+
} finally {
|
|
428
|
+
r.value = !1;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function d() {
|
|
432
|
+
h.value = !1;
|
|
433
|
+
const a = new URL(window.location.href);
|
|
434
|
+
a.searchParams.delete("invite"), window.history.replaceState({}, "", a.toString());
|
|
435
|
+
}
|
|
436
|
+
const E = p(() => t.user?.id === t.user?.team?.owner.id);
|
|
437
|
+
return {
|
|
438
|
+
team: u,
|
|
439
|
+
teamInviteDialog: h,
|
|
440
|
+
teamInviteCode: v,
|
|
441
|
+
hasTeamAccess: S,
|
|
442
|
+
isTeamOwner: E,
|
|
443
|
+
isLoading: r,
|
|
444
|
+
removeFromTeam: R,
|
|
445
|
+
leaveTeam: j,
|
|
446
|
+
joinTeam: k,
|
|
447
|
+
clearTeamQuery: d
|
|
448
|
+
};
|
|
449
|
+
}), M = O("auth", () => {
|
|
450
|
+
const e = b(!1), t = b(null), s = Q(), i = te(), o = V(), r = P(!1), u = z(), h = se(), v = J(), S = C(() => !!t.value), R = C(() => t.value?.role === "super"), j = C(() => ["super", "admin"].includes(t.value?.role ?? "")), k = C(() => ["super", "admin", "editor"].includes(t.value?.role ?? ""));
|
|
451
|
+
let d = !!x();
|
|
452
|
+
I(t, (c) => {
|
|
453
|
+
if (!c?.settings)
|
|
454
|
+
return;
|
|
455
|
+
const f = localStorage.getItem("vuetify@user") || "{}";
|
|
456
|
+
if (JSON.stringify(c.settings, null, 2) === f)
|
|
457
|
+
return;
|
|
458
|
+
d = !0;
|
|
459
|
+
let m = c.settings;
|
|
460
|
+
m.version === 6 && (m = F(m));
|
|
461
|
+
const $ = {
|
|
462
|
+
version: 7,
|
|
463
|
+
ecosystem: q(structuredClone(g.ecosystem), m.ecosystem || {}),
|
|
464
|
+
one: q(structuredClone(g.one), m.one || {})
|
|
465
|
+
};
|
|
466
|
+
Object.assign(i, $);
|
|
467
|
+
}), i.$subscribe(() => {
|
|
468
|
+
d || E(), d = !1;
|
|
469
|
+
});
|
|
470
|
+
async function E() {
|
|
471
|
+
if (await G(), !(!t.value || !i.one.sync))
|
|
472
|
+
try {
|
|
473
|
+
await s.post("/user/settings", { settings: i.$state }), await a(!0);
|
|
474
|
+
} catch (c) {
|
|
475
|
+
v.showError(c?.message ?? "Error syncing settings");
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
async function a(c = !1) {
|
|
479
|
+
if (a.promise)
|
|
480
|
+
return a.promise;
|
|
481
|
+
if (!c && !document.cookie.includes("sx=1") && location.hostname.match(/([^.]+\.[^.]+)$/)?.[1] === new URL(s.url).hostname.match(/([^.]+\.[^.]+)$/)?.[1]) {
|
|
482
|
+
t.value = null;
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
r.value = !0, a.promise = fetch(`${s.url}/auth/verify`, {
|
|
486
|
+
credentials: "include",
|
|
487
|
+
cache: c ? "reload" : void 0
|
|
488
|
+
}).then(
|
|
489
|
+
async (f) => {
|
|
490
|
+
if (f.ok || f.status === 401) {
|
|
491
|
+
const m = await f.json();
|
|
492
|
+
t.value = m.user, u.access = m.access, h.team = m.user?.team;
|
|
493
|
+
} else
|
|
494
|
+
console.error(f.statusText);
|
|
495
|
+
},
|
|
496
|
+
() => {
|
|
497
|
+
}
|
|
498
|
+
).finally(() => {
|
|
499
|
+
r.value = !1, a.promise = null;
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
a.promise = null;
|
|
503
|
+
async function T(c = "github") {
|
|
504
|
+
r.value = !0;
|
|
505
|
+
const f = `${s.url}/auth/${c}/redirect`;
|
|
506
|
+
if (c === "shopify") {
|
|
507
|
+
window.location.assign(f + "?next=" + encodeURIComponent(window.location.href));
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
const m = 400, $ = 600, W = window.screenX + (window.innerWidth - m) / 2, _ = window.screenY + (window.innerHeight - $) / 2, w = window.open(
|
|
511
|
+
"",
|
|
512
|
+
"vuetify:authorize:popup",
|
|
513
|
+
`popup,left=${W},top=${_},width=${m},height=${$},resizable`
|
|
514
|
+
);
|
|
515
|
+
if (!w) {
|
|
516
|
+
console.error("Failed to open popup");
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
w.location.href = f;
|
|
520
|
+
let L = -1, n = -1;
|
|
521
|
+
function l(A) {
|
|
522
|
+
A.origin === s.url && A.data?.type === "auth-response" && (A.data.status === "success" ? (t.value || (localStorage.setItem("vuetify@lastLoginProvider", c), e.value = !1, o.push("/user/dashboard")), t.value = A.data.body.user, u.access = A.data.body.access, h.team = A.data.body.user?.team, E()) : console.error(A.data.message), y());
|
|
523
|
+
}
|
|
524
|
+
function y() {
|
|
525
|
+
window.removeEventListener("message", l), window.clearInterval(L), window.clearTimeout(n), w?.close(), r.value = !1;
|
|
526
|
+
}
|
|
527
|
+
window.addEventListener("message", l), L = window.setInterval(() => {
|
|
528
|
+
!w || w.closed ? (console.error("Auth popup closed"), y()) : w.postMessage({ type: "auth-request" }, "*");
|
|
529
|
+
}, 1e3), n = window.setTimeout(() => {
|
|
530
|
+
y(), console.error("Auth timed out");
|
|
531
|
+
}, 120 * 1e3);
|
|
532
|
+
}
|
|
533
|
+
async function N(c) {
|
|
534
|
+
r.value = !0;
|
|
535
|
+
const f = c ? `/auth/${c}/logout` : "/auth/logout";
|
|
536
|
+
try {
|
|
537
|
+
await s.post(f), await a(!0), t.value = null;
|
|
538
|
+
} catch (m) {
|
|
539
|
+
v.showError(m?.message ?? "Error logging out");
|
|
540
|
+
} finally {
|
|
541
|
+
o.push({
|
|
542
|
+
path: "/",
|
|
543
|
+
query: o.currentRoute.value.query
|
|
544
|
+
}), r.value = !1;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
function U(c) {
|
|
548
|
+
return t.value?.identities.find((f) => f.provider === c);
|
|
549
|
+
}
|
|
550
|
+
function x() {
|
|
551
|
+
return localStorage.getItem("vuetify@lastLoginProvider");
|
|
552
|
+
}
|
|
553
|
+
return a(), {
|
|
554
|
+
user: t,
|
|
555
|
+
url: s.url,
|
|
556
|
+
dialog: e,
|
|
557
|
+
isLoading: r,
|
|
558
|
+
isAuthenticated: S,
|
|
559
|
+
isSuper: R,
|
|
560
|
+
isAdmin: j,
|
|
561
|
+
isEditor: k,
|
|
562
|
+
verify: a,
|
|
563
|
+
findIdentity: U,
|
|
564
|
+
login: T,
|
|
565
|
+
logout: N,
|
|
566
|
+
lastLoginProvider: x,
|
|
567
|
+
sync: E
|
|
568
|
+
};
|
|
569
|
+
});
|
|
570
|
+
export {
|
|
571
|
+
M as a,
|
|
572
|
+
te as b,
|
|
573
|
+
z as c,
|
|
574
|
+
B as d,
|
|
575
|
+
Q as e,
|
|
576
|
+
se as f,
|
|
577
|
+
J as u
|
|
578
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -156,10 +156,11 @@ interface VOneIdentity {
|
|
|
156
156
|
userHandle: string;
|
|
157
157
|
primary: boolean;
|
|
158
158
|
}
|
|
159
|
+
type VOneRole = 'super' | 'admin' | 'editor' | 'user';
|
|
159
160
|
interface VOneUser {
|
|
160
161
|
id: string;
|
|
161
162
|
isAdmin: boolean;
|
|
162
|
-
role:
|
|
163
|
+
role: VOneRole;
|
|
163
164
|
name: string;
|
|
164
165
|
shortid: string;
|
|
165
166
|
picture: string;
|
|
@@ -174,6 +175,10 @@ interface AuthState {
|
|
|
174
175
|
url: string;
|
|
175
176
|
dialog: Ref<boolean>;
|
|
176
177
|
isLoading: ShallowRef<boolean>;
|
|
178
|
+
isAuthenticated: Ref<boolean>;
|
|
179
|
+
isSuper: Ref<boolean>;
|
|
180
|
+
isAdmin: Ref<boolean>;
|
|
181
|
+
isEditor: Ref<boolean>;
|
|
177
182
|
verify: (force?: boolean) => Promise<void>;
|
|
178
183
|
findIdentity: (provider: string) => VOneIdentity | undefined;
|
|
179
184
|
login: (provider?: 'github' | 'discord' | 'shopify') => Promise<void>;
|
|
@@ -181,7 +186,7 @@ interface AuthState {
|
|
|
181
186
|
lastLoginProvider: () => string | null;
|
|
182
187
|
sync: () => Promise<void>;
|
|
183
188
|
}
|
|
184
|
-
declare const useAuthStore: pinia.StoreDefinition<"auth", Pick<AuthState, "isLoading" | "user" | "url" | "dialog">, Pick<AuthState, never>, Pick<AuthState, "sync" | "verify" | "findIdentity" | "login" | "logout" | "lastLoginProvider">>;
|
|
189
|
+
declare const useAuthStore: pinia.StoreDefinition<"auth", Pick<AuthState, "isLoading" | "user" | "url" | "dialog" | "isAuthenticated" | "isSuper" | "isAdmin" | "isEditor">, Pick<AuthState, never>, Pick<AuthState, "sync" | "verify" | "findIdentity" | "login" | "logout" | "lastLoginProvider">>;
|
|
185
190
|
|
|
186
191
|
interface VOneBanner {
|
|
187
192
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as y, createBlock as m, openBlock as c, unref as e, computed as b, createSlots as z, withCtx as s, createElementVNode as g, toDisplayString as C, createVNode as n, createTextVNode as S, normalizeStyle as it, createCommentVNode as h, renderSlot as w, shallowRef as M, watch as H, withModifiers as ye, mergeModels as rt, useModel as W, createElementBlock as k, Fragment as D, nextTick as be, renderList as G, mergeProps as R, withDirectives as N, vShow as Ie, isRef as j, ref as E, readonly as Se, resolveComponent as lt, watchEffect as Nt, onMounted as He, toRef as ge, normalizeClass as Zt, useSlots as ut, normalizeProps as ct, guardReactiveProps as dt, onBeforeMount as je, onBeforeUnmount as Ht, useCssVars as jt, onServerPrefetch as Rt } from "vue";
|
|
2
|
-
import { u as oe, a as F, b as T, c as O, d as ke, e as J, f as De } from "./auth-
|
|
2
|
+
import { u as oe, a as F, b as T, c as O, d as ke, e as J, f as De } from "./auth-CXrXnM17.js";
|
|
3
3
|
import { VSnackbarQueue as qt } from "vuetify/components/VSnackbarQueue";
|
|
4
4
|
import { mdiStorefront as Wt, mdiSync as Gt, mdiSyncOff as Kt, mdiLogoutVariant as Yt, mdiFullscreenExit as Qt, mdiFullscreen as Xt, mdiCheck as Ve, mdiSelect as Jt, mdiSpaceInvaders as pt, mdiImageFilterHdr as mt, mdiTransmissionTower as ft, mdiRocketLaunchOutline as vt, mdiHome as eo, mdiTextBox as to, mdiWhiteBalanceSunny as oo, mdiWeatherNight as no, mdiDesktopTowerMonitor as so, mdiContrastCircle as ao, mdiCog as io, mdiCogOutline as ro, mdiShieldKeyOutline as lo, mdiContentCopy as Re, mdiFileDocument as gt, mdiKey as uo, mdiPlus as co, mdiRefresh as po, mdiKeyOutline as mo, mdiCreditCardSettingsOutline as fo, mdiRocketOutline as vo, mdiCheckCircleOutline as Me, mdiCreditCard as go, mdiReload as _o, mdiPlaylistCheck as yo, mdiCreditCardOutline as ho, mdiOpenInNew as Ae, mdiMedal as bo, mdiHandHeart as ko, mdiHandHeartOutline as Vo, mdiCloudDownload as Co, mdiTrayArrowDown as tt, mdiAccountGroup as $o, mdiAccount as xo, mdiLinkVariant as Lo, mdiShieldLock as ot, mdiAccountRemoveOutline as wo, mdiExitToApp as So, mdiAccountGroupOutline as Mo, mdiPin as Io, mdiPinOutline as Do, mdiEmailOpenOutline as qe, mdiEmailVariant as We, mdiBell as Ao, mdiInboxOutline as To, mdiInboxFullOutline as Uo, mdiBillboard as Po, mdiBellOutline as zo, mdiViewDashboardOutline as Oo, mdiCrown as Bo, mdiArrowULeftBottom as Eo, mdiAtomVariant as Fo, mdiLogin as nt, mdiDotsVertical as No, mdiShieldStarOutline as Zo } from "@mdi/js";
|
|
5
5
|
import { VListItem as le, VList as ne, VListSubheader as Ho, VListItemTitle as _t, VListItemSubtitle as jo } from "vuetify/components/VList";
|
package/dist/stores/auth.d.ts
CHANGED
|
@@ -35,10 +35,11 @@ interface VOneIdentity {
|
|
|
35
35
|
userHandle: string;
|
|
36
36
|
primary: boolean;
|
|
37
37
|
}
|
|
38
|
+
type VOneRole = 'super' | 'admin' | 'editor' | 'user';
|
|
38
39
|
interface VOneUser {
|
|
39
40
|
id: string;
|
|
40
41
|
isAdmin: boolean;
|
|
41
|
-
role:
|
|
42
|
+
role: VOneRole;
|
|
42
43
|
name: string;
|
|
43
44
|
shortid: string;
|
|
44
45
|
picture: string;
|
|
@@ -53,6 +54,10 @@ interface AuthState {
|
|
|
53
54
|
url: string;
|
|
54
55
|
dialog: Ref<boolean>;
|
|
55
56
|
isLoading: ShallowRef<boolean>;
|
|
57
|
+
isAuthenticated: Ref<boolean>;
|
|
58
|
+
isSuper: Ref<boolean>;
|
|
59
|
+
isAdmin: Ref<boolean>;
|
|
60
|
+
isEditor: Ref<boolean>;
|
|
56
61
|
verify: (force?: boolean) => Promise<void>;
|
|
57
62
|
findIdentity: (provider: string) => VOneIdentity | undefined;
|
|
58
63
|
login: (provider?: 'github' | 'discord' | 'shopify') => Promise<void>;
|
|
@@ -60,7 +65,7 @@ interface AuthState {
|
|
|
60
65
|
lastLoginProvider: () => string | null;
|
|
61
66
|
sync: () => Promise<void>;
|
|
62
67
|
}
|
|
63
|
-
declare const useAuthStore: pinia.StoreDefinition<"auth", Pick<AuthState, "isLoading" | "user" | "url" | "dialog">, Pick<AuthState, never>, Pick<AuthState, "sync" | "verify" | "findIdentity" | "login" | "logout" | "lastLoginProvider">>;
|
|
68
|
+
declare const useAuthStore: pinia.StoreDefinition<"auth", Pick<AuthState, "isLoading" | "user" | "url" | "dialog" | "isAuthenticated" | "isSuper" | "isAdmin" | "isEditor">, Pick<AuthState, never>, Pick<AuthState, "sync" | "verify" | "findIdentity" | "login" | "logout" | "lastLoginProvider">>;
|
|
64
69
|
|
|
65
70
|
export { useAuthStore };
|
|
66
|
-
export type { AuthState, VOneIdentity, VOneSponsorship, VOneUser };
|
|
71
|
+
export type { AuthState, VOneIdentity, VOneRole, VOneSponsorship, VOneUser };
|
package/dist/stores/auth.js
CHANGED
package/package.json
CHANGED
package/dist/auth-CwLSOnno.js
DELETED
|
@@ -1,574 +0,0 @@
|
|
|
1
|
-
import { merge as O } from "lodash-es";
|
|
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
|
-
const e = T([]);
|
|
7
|
-
function r(o) {
|
|
8
|
-
const s = typeof o == "string" ? { text: o } : o;
|
|
9
|
-
e.value.push(s);
|
|
10
|
-
}
|
|
11
|
-
function t(o) {
|
|
12
|
-
r({
|
|
13
|
-
color: "error",
|
|
14
|
-
text: o,
|
|
15
|
-
location: "top end",
|
|
16
|
-
timeout: -1
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function i(o) {
|
|
20
|
-
r({
|
|
21
|
-
color: "success",
|
|
22
|
-
text: o,
|
|
23
|
-
location: "top end"
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
queue: e,
|
|
28
|
-
show: r,
|
|
29
|
-
showError: t,
|
|
30
|
-
showSuccess: i
|
|
31
|
-
};
|
|
32
|
-
}), G = [
|
|
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),
|
|
34
|
-
(e) => (e.v === 1 && (Array.isArray(e.composition) && (e.composition = "composition"), Array.isArray(e.notifications?.last?.banner) || (e.notifications = e.notifications || {}, e.notifications.last = e.notifications.last || {}, e.notifications.last.banner = []), e.v = 2), e),
|
|
35
|
-
(e) => (e.v === 2 && (e.syncSettings = !0, e.disableAds = !1, e.v = 3), e),
|
|
36
|
-
(e) => (e.v === 3 && (e.quickbar = !1, e.v = 4), e),
|
|
37
|
-
(e) => (e.v === 4 && (e.suits = { show: !1, elements: ["app-bar"], suit: "" }, e.notifications = e.notifications || {}, e.notifications.banners = !0, e.v = 5), e)
|
|
38
|
-
];
|
|
39
|
-
function K(e) {
|
|
40
|
-
return {
|
|
41
|
-
version: 6,
|
|
42
|
-
ecosystem: {
|
|
43
|
-
bin: {
|
|
44
|
-
wordWrap: !1
|
|
45
|
-
},
|
|
46
|
-
play: {
|
|
47
|
-
showErrors: !0,
|
|
48
|
-
wordWrap: !1
|
|
49
|
-
},
|
|
50
|
-
studio: {},
|
|
51
|
-
link: {},
|
|
52
|
-
docs: {
|
|
53
|
-
api: e.api || "link-only",
|
|
54
|
-
composition: e.composition || "composition",
|
|
55
|
-
pins: {
|
|
56
|
-
enabled: e.pins || !1,
|
|
57
|
-
pinned: Array.isArray(e.pinned) ? e.pinned.map((r) => r.name || r).filter(Boolean) : []
|
|
58
|
-
},
|
|
59
|
-
mixedTheme: e.mixedTheme ?? !0,
|
|
60
|
-
favorites: [],
|
|
61
|
-
slashSearch: e.slashSearch || !1,
|
|
62
|
-
railDrawer: e.railDrawer || !1
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
one: {
|
|
66
|
-
avatar: e.avatar || "",
|
|
67
|
-
ads: {
|
|
68
|
-
enabled: !e.disableAds,
|
|
69
|
-
house: e.showHouseAds || !1
|
|
70
|
-
},
|
|
71
|
-
command: {},
|
|
72
|
-
theme: e.theme || "system",
|
|
73
|
-
direction: e.direction || "ltr",
|
|
74
|
-
colors: {
|
|
75
|
-
primary: e.colors?.one || "surface-light"
|
|
76
|
-
},
|
|
77
|
-
suits: {
|
|
78
|
-
enabled: e.suits?.show || !1,
|
|
79
|
-
elements: e.suits?.elements || ["app-bar"],
|
|
80
|
-
suit: e.suits?.suit || ""
|
|
81
|
-
},
|
|
82
|
-
notifications: {
|
|
83
|
-
enabled: e.notifications?.show ?? !0,
|
|
84
|
-
read: e.notifications?.read || [],
|
|
85
|
-
last: ""
|
|
86
|
-
},
|
|
87
|
-
banners: {
|
|
88
|
-
enabled: e.notifications?.banners ?? !0,
|
|
89
|
-
read: e.notifications?.last?.banner || [],
|
|
90
|
-
last: ""
|
|
91
|
-
},
|
|
92
|
-
quicklinks: e.quickbar || !1,
|
|
93
|
-
sync: e.syncSettings ?? !0,
|
|
94
|
-
devmode: e.dev || !1
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function H(e) {
|
|
99
|
-
return {
|
|
100
|
-
...e,
|
|
101
|
-
version: 7,
|
|
102
|
-
ecosystem: {
|
|
103
|
-
...e.ecosystem,
|
|
104
|
-
mcp: {
|
|
105
|
-
seen: !1
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function Z(e) {
|
|
111
|
-
const r = G.reduce((i, o) => o(i), e), t = K(r);
|
|
112
|
-
return H(t);
|
|
113
|
-
}
|
|
114
|
-
const W = typeof window < "u", E = {
|
|
115
|
-
version: 7,
|
|
116
|
-
ecosystem: {
|
|
117
|
-
bin: {
|
|
118
|
-
wordWrap: !0
|
|
119
|
-
},
|
|
120
|
-
play: {
|
|
121
|
-
showErrors: !0,
|
|
122
|
-
wordWrap: !1
|
|
123
|
-
},
|
|
124
|
-
studio: {},
|
|
125
|
-
link: {},
|
|
126
|
-
docs: {
|
|
127
|
-
api: "link-only",
|
|
128
|
-
composition: "composition",
|
|
129
|
-
pins: {
|
|
130
|
-
enabled: !1,
|
|
131
|
-
pinned: []
|
|
132
|
-
},
|
|
133
|
-
mixedTheme: !0,
|
|
134
|
-
favorites: [],
|
|
135
|
-
slashSearch: !1,
|
|
136
|
-
railDrawer: !1
|
|
137
|
-
},
|
|
138
|
-
mcp: {
|
|
139
|
-
seen: !1
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
one: {
|
|
143
|
-
avatar: "",
|
|
144
|
-
ads: {
|
|
145
|
-
enabled: !0,
|
|
146
|
-
house: !1
|
|
147
|
-
},
|
|
148
|
-
command: {},
|
|
149
|
-
theme: "system",
|
|
150
|
-
direction: "ltr",
|
|
151
|
-
colors: {
|
|
152
|
-
primary: "surface-light"
|
|
153
|
-
},
|
|
154
|
-
suits: {
|
|
155
|
-
enabled: !1,
|
|
156
|
-
elements: ["app-bar"],
|
|
157
|
-
suit: ""
|
|
158
|
-
},
|
|
159
|
-
notifications: {
|
|
160
|
-
enabled: !0,
|
|
161
|
-
read: [],
|
|
162
|
-
last: ""
|
|
163
|
-
},
|
|
164
|
-
banners: {
|
|
165
|
-
enabled: !0,
|
|
166
|
-
read: [],
|
|
167
|
-
last: ""
|
|
168
|
-
},
|
|
169
|
-
quicklinks: !1,
|
|
170
|
-
ecosystem: {
|
|
171
|
-
pinned: [],
|
|
172
|
-
seen: !1
|
|
173
|
-
},
|
|
174
|
-
sync: !0,
|
|
175
|
-
devmode: !1
|
|
176
|
-
}
|
|
177
|
-
}, D = j("user", () => {
|
|
178
|
-
const e = z(structuredClone(E));
|
|
179
|
-
I(e, t, { deep: !0 });
|
|
180
|
-
function r() {
|
|
181
|
-
if (!W)
|
|
182
|
-
return;
|
|
183
|
-
const o = localStorage.getItem("vuetify@user");
|
|
184
|
-
if (o)
|
|
185
|
-
try {
|
|
186
|
-
const s = JSON.parse(o);
|
|
187
|
-
if (s.version >= 7) {
|
|
188
|
-
const u = {
|
|
189
|
-
version: 7,
|
|
190
|
-
ecosystem: O(structuredClone(E.ecosystem), s.ecosystem || {}),
|
|
191
|
-
one: O(structuredClone(E.one), s.one || {})
|
|
192
|
-
};
|
|
193
|
-
Object.assign(e, u);
|
|
194
|
-
} else if (s.version === 6) {
|
|
195
|
-
const u = H(s), d = {
|
|
196
|
-
version: 7,
|
|
197
|
-
ecosystem: O(structuredClone(E.ecosystem), u.ecosystem || {}),
|
|
198
|
-
one: O(structuredClone(E.one), u.one || {})
|
|
199
|
-
};
|
|
200
|
-
Object.assign(e, d);
|
|
201
|
-
} else {
|
|
202
|
-
const u = Z(s);
|
|
203
|
-
Object.assign(e, u);
|
|
204
|
-
}
|
|
205
|
-
t();
|
|
206
|
-
} catch (s) {
|
|
207
|
-
console.error("Failed to load user settings:", s);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function t() {
|
|
211
|
-
W && localStorage.setItem("vuetify@user", JSON.stringify(e, null, 2));
|
|
212
|
-
}
|
|
213
|
-
function i() {
|
|
214
|
-
W && (Object.assign(e, structuredClone(E)), t());
|
|
215
|
-
}
|
|
216
|
-
return r(), {
|
|
217
|
-
...M(e),
|
|
218
|
-
load: r,
|
|
219
|
-
save: t,
|
|
220
|
-
reset: i
|
|
221
|
-
};
|
|
222
|
-
}), J = j("http", {
|
|
223
|
-
state: () => ({
|
|
224
|
-
url: ""
|
|
225
|
-
}),
|
|
226
|
-
actions: {
|
|
227
|
-
async fetch(e, r = {}) {
|
|
228
|
-
const t = await fetch(`${this.url}${e}`, {
|
|
229
|
-
credentials: "include",
|
|
230
|
-
...r
|
|
231
|
-
});
|
|
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
|
-
}
|
|
242
|
-
return t.status === 204 ? {} : t.json();
|
|
243
|
-
},
|
|
244
|
-
async post(e, r, t = {}) {
|
|
245
|
-
return this.fetch(e, {
|
|
246
|
-
method: "POST",
|
|
247
|
-
headers: {
|
|
248
|
-
"Content-Type": "application/json"
|
|
249
|
-
},
|
|
250
|
-
body: JSON.stringify(r),
|
|
251
|
-
...t
|
|
252
|
-
});
|
|
253
|
-
},
|
|
254
|
-
async form(e, r, t = {}) {
|
|
255
|
-
return this.fetch(e, {
|
|
256
|
-
method: "POST",
|
|
257
|
-
body: r,
|
|
258
|
-
...t
|
|
259
|
-
});
|
|
260
|
-
},
|
|
261
|
-
async get(e, r = {}) {
|
|
262
|
-
return this.fetch(e, r);
|
|
263
|
-
},
|
|
264
|
-
async delete(e, r = {}) {
|
|
265
|
-
return this.fetch(e, {
|
|
266
|
-
method: "DELETE",
|
|
267
|
-
...r
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
function Q() {
|
|
273
|
-
const e = Y();
|
|
274
|
-
return m(
|
|
275
|
-
() => e.query
|
|
276
|
-
);
|
|
277
|
-
}
|
|
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) => {
|
|
280
|
-
if (!p.isActive || p.interval === "once")
|
|
281
|
-
return n;
|
|
282
|
-
const b = p.interval === "month" ? p.amount : p.amount / 12;
|
|
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)
|
|
289
|
-
return;
|
|
290
|
-
t.dialog = !0;
|
|
291
|
-
const p = I(() => t.user, (b) => {
|
|
292
|
-
b && (t.dialog = !1, p());
|
|
293
|
-
});
|
|
294
|
-
}, { immediate: !0 });
|
|
295
|
-
async function R() {
|
|
296
|
-
try {
|
|
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");
|
|
302
|
-
} finally {
|
|
303
|
-
s.value = !1;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
async function S() {
|
|
307
|
-
window.open(`${i.url}/one/manage`, "_blank");
|
|
308
|
-
}
|
|
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();
|
|
313
|
-
}
|
|
314
|
-
async function C() {
|
|
315
|
-
if (y.value)
|
|
316
|
-
try {
|
|
317
|
-
s.value = !0, await i.post(
|
|
318
|
-
`/one/cancel?subscriptionId=${y.value?.tierName}`
|
|
319
|
-
), await t.verify(!0);
|
|
320
|
-
} catch (n) {
|
|
321
|
-
o.showError(n?.message ?? "Error cancelling subscription, Please contact support");
|
|
322
|
-
} finally {
|
|
323
|
-
s.value = !1;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
async function P(n, p) {
|
|
327
|
-
if (y.value)
|
|
328
|
-
try {
|
|
329
|
-
s.value = !0, await i.post("/one/modify", {
|
|
330
|
-
subscriptionId: y.value.tierName,
|
|
331
|
-
interval: n,
|
|
332
|
-
type: p
|
|
333
|
-
}), await t.verify(!0);
|
|
334
|
-
} catch (b) {
|
|
335
|
-
o.showError(b?.message ?? "Error modifying subscription");
|
|
336
|
-
} finally {
|
|
337
|
-
s.value = !1;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
async function q() {
|
|
341
|
-
try {
|
|
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");
|
|
347
|
-
} finally {
|
|
348
|
-
s.value = !1;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
function w() {
|
|
352
|
-
r.push({
|
|
353
|
-
query: {
|
|
354
|
-
...e.value,
|
|
355
|
-
one: void 0
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
return {
|
|
360
|
-
info: d,
|
|
361
|
-
interval: A,
|
|
362
|
-
subscriptionType: h,
|
|
363
|
-
access: k,
|
|
364
|
-
invoices: v,
|
|
365
|
-
sessionId: g,
|
|
366
|
-
subscription: y,
|
|
367
|
-
monthlyTotal: c,
|
|
368
|
-
hasBilling: L,
|
|
369
|
-
isLoading: s,
|
|
370
|
-
isOpen: u,
|
|
371
|
-
isSubscriber: U,
|
|
372
|
-
github: f,
|
|
373
|
-
discord: l,
|
|
374
|
-
shopify: $,
|
|
375
|
-
one: a,
|
|
376
|
-
activate: R,
|
|
377
|
-
cancel: C,
|
|
378
|
-
manage: S,
|
|
379
|
-
modify: P,
|
|
380
|
-
resetQuery: w,
|
|
381
|
-
subscribe: x,
|
|
382
|
-
subscriptionInfo: q
|
|
383
|
-
};
|
|
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(
|
|
386
|
-
() => u.value ? t.access?.some((c) => ["one/team", "snips/team"].includes(c)) : !1
|
|
387
|
-
);
|
|
388
|
-
I(v, async () => {
|
|
389
|
-
if (v.value) {
|
|
390
|
-
r.user || (r.dialog = !0);
|
|
391
|
-
try {
|
|
392
|
-
s.value = !0;
|
|
393
|
-
const c = await i.get(`/one/team/${v.value}`);
|
|
394
|
-
u.value = c.team, d.value = !0;
|
|
395
|
-
} catch (c) {
|
|
396
|
-
y(), o.showError(c.message);
|
|
397
|
-
} finally {
|
|
398
|
-
s.value = !1;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}, { immediate: !0 });
|
|
402
|
-
async function A(c) {
|
|
403
|
-
try {
|
|
404
|
-
if (s.value = !0, !u.value)
|
|
405
|
-
return;
|
|
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");
|
|
409
|
-
} finally {
|
|
410
|
-
s.value = !1;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
async function h() {
|
|
414
|
-
try {
|
|
415
|
-
s.value = !0, await i.post("/one/team/leave", { teamId: u.value?.id }), await r.verify(!0);
|
|
416
|
-
} catch (c) {
|
|
417
|
-
o.showError(c?.message ?? "Error leaving team");
|
|
418
|
-
} finally {
|
|
419
|
-
s.value = !1;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
async function k() {
|
|
423
|
-
try {
|
|
424
|
-
s.value = !0, await i.post("/one/team/join", { inviteCode: v.value }), await r.verify(!0), y();
|
|
425
|
-
} catch (c) {
|
|
426
|
-
o.showError(c?.message ?? "Error joining team");
|
|
427
|
-
} finally {
|
|
428
|
-
s.value = !1;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
function y() {
|
|
432
|
-
d.value = !1;
|
|
433
|
-
const c = new URL(window.location.href);
|
|
434
|
-
c.searchParams.delete("invite"), window.history.replaceState({}, "", c.toString());
|
|
435
|
-
}
|
|
436
|
-
const L = m(() => r.user?.id === r.user?.team?.owner.id);
|
|
437
|
-
return {
|
|
438
|
-
team: u,
|
|
439
|
-
teamInviteDialog: d,
|
|
440
|
-
teamInviteCode: v,
|
|
441
|
-
hasTeamAccess: g,
|
|
442
|
-
isTeamOwner: L,
|
|
443
|
-
isLoading: s,
|
|
444
|
-
removeFromTeam: A,
|
|
445
|
-
leaveTeam: h,
|
|
446
|
-
joinTeam: k,
|
|
447
|
-
clearTeamQuery: y
|
|
448
|
-
};
|
|
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 = _();
|
|
451
|
-
let g = !!c();
|
|
452
|
-
I(r, (a) => {
|
|
453
|
-
if (!a?.settings)
|
|
454
|
-
return;
|
|
455
|
-
const f = localStorage.getItem("vuetify@user") || "{}";
|
|
456
|
-
if (JSON.stringify(a.settings, null, 2) === f)
|
|
457
|
-
return;
|
|
458
|
-
g = !0;
|
|
459
|
-
let l = a.settings;
|
|
460
|
-
l.version === 6 && (l = H(l));
|
|
461
|
-
const $ = {
|
|
462
|
-
version: 7,
|
|
463
|
-
ecosystem: O(structuredClone(E.ecosystem), l.ecosystem || {}),
|
|
464
|
-
one: O(structuredClone(E.one), l.one || {})
|
|
465
|
-
};
|
|
466
|
-
Object.assign(i, $);
|
|
467
|
-
}), i.$subscribe(() => {
|
|
468
|
-
g || A(), g = !1;
|
|
469
|
-
});
|
|
470
|
-
async function A() {
|
|
471
|
-
if (await X(), !(!r.value || !i.one.sync))
|
|
472
|
-
try {
|
|
473
|
-
await t.post("/user/settings", { settings: i.$state }), await h(!0);
|
|
474
|
-
} catch (a) {
|
|
475
|
-
v.showError(a?.message ?? "Error syncing settings");
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
async function h(a = !1) {
|
|
479
|
-
if (h.promise)
|
|
480
|
-
return h.promise;
|
|
481
|
-
if (!a && !document.cookie.includes("sx=1") && location.hostname.match(/([^.]+\.[^.]+)$/)?.[1] === new URL(t.url).hostname.match(/([^.]+\.[^.]+)$/)?.[1]) {
|
|
482
|
-
r.value = null;
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
s.value = !0, h.promise = fetch(`${t.url}/auth/verify`, {
|
|
486
|
-
credentials: "include",
|
|
487
|
-
cache: a ? "reload" : void 0
|
|
488
|
-
}).then(
|
|
489
|
-
async (f) => {
|
|
490
|
-
if (f.ok || f.status === 401) {
|
|
491
|
-
const l = await f.json();
|
|
492
|
-
r.value = l.user, u.access = l.access, d.team = l.user?.team;
|
|
493
|
-
} else
|
|
494
|
-
console.error(f.statusText);
|
|
495
|
-
},
|
|
496
|
-
() => {
|
|
497
|
-
}
|
|
498
|
-
).finally(() => {
|
|
499
|
-
s.value = !1, h.promise = null;
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
h.promise = null;
|
|
503
|
-
async function k(a = "github") {
|
|
504
|
-
s.value = !0;
|
|
505
|
-
const f = `${t.url}/auth/${a}/redirect`;
|
|
506
|
-
if (a === "shopify") {
|
|
507
|
-
window.location.assign(f + "?next=" + encodeURIComponent(window.location.href));
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
const l = 400, $ = 600, U = window.screenX + (window.innerWidth - l) / 2, R = window.screenY + (window.innerHeight - $) / 2, S = window.open(
|
|
511
|
-
"",
|
|
512
|
-
"vuetify:authorize:popup",
|
|
513
|
-
`popup,left=${U},top=${R},width=${l},height=${$},resizable`
|
|
514
|
-
);
|
|
515
|
-
if (!S) {
|
|
516
|
-
console.error("Failed to open popup");
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
S.location.href = f;
|
|
520
|
-
let x = -1, C = -1;
|
|
521
|
-
function P(w) {
|
|
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());
|
|
523
|
-
}
|
|
524
|
-
function q() {
|
|
525
|
-
window.removeEventListener("message", P), window.clearInterval(x), window.clearTimeout(C), S?.close(), s.value = !1;
|
|
526
|
-
}
|
|
527
|
-
window.addEventListener("message", P), x = window.setInterval(() => {
|
|
528
|
-
!S || S.closed ? (console.error("Auth popup closed"), q()) : S.postMessage({ type: "auth-request" }, "*");
|
|
529
|
-
}, 1e3), C = window.setTimeout(() => {
|
|
530
|
-
q(), console.error("Auth timed out");
|
|
531
|
-
}, 120 * 1e3);
|
|
532
|
-
}
|
|
533
|
-
async function y(a) {
|
|
534
|
-
s.value = !0;
|
|
535
|
-
const f = a ? `/auth/${a}/logout` : "/auth/logout";
|
|
536
|
-
try {
|
|
537
|
-
await t.post(f), await h(!0), r.value = null;
|
|
538
|
-
} catch (l) {
|
|
539
|
-
v.showError(l?.message ?? "Error logging out");
|
|
540
|
-
} finally {
|
|
541
|
-
o.push({
|
|
542
|
-
path: "/",
|
|
543
|
-
query: o.currentRoute.value.query
|
|
544
|
-
}), s.value = !1;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
function L(a) {
|
|
548
|
-
return r.value?.identities.find((f) => f.provider === a);
|
|
549
|
-
}
|
|
550
|
-
function c() {
|
|
551
|
-
return localStorage.getItem("vuetify@lastLoginProvider");
|
|
552
|
-
}
|
|
553
|
-
return h(), {
|
|
554
|
-
user: r,
|
|
555
|
-
url: t.url,
|
|
556
|
-
dialog: e,
|
|
557
|
-
isLoading: s,
|
|
558
|
-
verify: h,
|
|
559
|
-
findIdentity: L,
|
|
560
|
-
login: k,
|
|
561
|
-
logout: y,
|
|
562
|
-
lastLoginProvider: c,
|
|
563
|
-
sync: A
|
|
564
|
-
};
|
|
565
|
-
});
|
|
566
|
-
export {
|
|
567
|
-
B as a,
|
|
568
|
-
D as b,
|
|
569
|
-
V as c,
|
|
570
|
-
Q as d,
|
|
571
|
-
J as e,
|
|
572
|
-
ee as f,
|
|
573
|
-
_ as u
|
|
574
|
-
};
|