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