@vuetify/one 3.1.1 → 4.0.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-DK4fBwyp.js → auth-DItQv4ut.js} +173 -179
- package/dist/index.d.ts +7 -162
- package/dist/index.js +987 -1195
- package/dist/one.css +1 -1
- package/dist/stores/auth.d.ts +3 -3
- package/dist/stores/auth.js +1 -1
- package/dist/styles.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ref as S, shallowRef as L, computed as
|
|
1
|
+
import { ref as S, shallowRef as L, computed as m, readonly as q, reactive as Y, watch as j, toRefs as G, toRef as P, nextTick as Z } from "vue";
|
|
2
2
|
import { defineStore as $ } from "pinia";
|
|
3
|
-
import { merge as
|
|
4
|
-
import { useRoute as
|
|
3
|
+
import { merge as U, debounce as D } from "lodash-es";
|
|
4
|
+
import { useRoute as ee, useRouter as K } from "vue-router";
|
|
5
5
|
const J = $("queue", () => {
|
|
6
6
|
const e = S([]);
|
|
7
7
|
function i(r) {
|
|
@@ -29,7 +29,7 @@ const J = $("queue", () => {
|
|
|
29
29
|
showError: t,
|
|
30
30
|
showSuccess: s
|
|
31
31
|
};
|
|
32
|
-
}),
|
|
32
|
+
}), _ = $("http", {
|
|
33
33
|
state: () => ({ url: "" }),
|
|
34
34
|
actions: {
|
|
35
35
|
async fetch(e, i = {}) {
|
|
@@ -67,18 +67,18 @@ const J = $("queue", () => {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
}),
|
|
71
|
-
const e =
|
|
70
|
+
}), de = $("auth-api-key", () => {
|
|
71
|
+
const e = _(), i = S(null), t = L(!1), s = m(() => i.value?.apiKey || ""), r = m(() => {
|
|
72
72
|
if (!s.value) return "";
|
|
73
73
|
const a = s.value;
|
|
74
74
|
return `${a.slice(0, 6)}...${a.slice(-6)}`;
|
|
75
75
|
});
|
|
76
76
|
async function n(a = !1) {
|
|
77
77
|
!t.value && a && (t.value = !0);
|
|
78
|
-
const d = a ? "regenerate" : "generate",
|
|
79
|
-
return i.value =
|
|
78
|
+
const d = a ? "regenerate" : "generate", y = a ? await e.post(`/one/mcp/${d}`) : await e.fetch(`/one/mcp/${d}`);
|
|
79
|
+
return i.value = y, y;
|
|
80
80
|
}
|
|
81
|
-
async function
|
|
81
|
+
async function u() {
|
|
82
82
|
try {
|
|
83
83
|
const a = await e.fetch("/one/mcp/getToken");
|
|
84
84
|
return a?.apiKey ? (i.value = a, a) : null;
|
|
@@ -92,14 +92,14 @@ const J = $("queue", () => {
|
|
|
92
92
|
regenerated: q(t),
|
|
93
93
|
trim: q(r),
|
|
94
94
|
generate: n,
|
|
95
|
-
fetch:
|
|
95
|
+
fetch: u
|
|
96
96
|
};
|
|
97
|
-
}),
|
|
98
|
-
function
|
|
97
|
+
}), te = typeof window < "u";
|
|
98
|
+
function ne() {
|
|
99
99
|
return document.cookie.split(";").some((e) => e.trim().startsWith("sx="));
|
|
100
100
|
}
|
|
101
|
-
const
|
|
102
|
-
const e =
|
|
101
|
+
const Q = $("auth-core", () => {
|
|
102
|
+
const e = _(), i = S(!1), t = S(null), s = L(!1), r = L({}), n = L(null), u = m(() => !!t.value), a = m(() => t.value?.role === "super"), d = m(() => ["super", "admin"].includes(t.value?.role ?? "")), y = m(() => [
|
|
103
103
|
"super",
|
|
104
104
|
"admin",
|
|
105
105
|
"editor"
|
|
@@ -109,40 +109,35 @@ const V = $("auth-core", () => {
|
|
|
109
109
|
}
|
|
110
110
|
async function O(l = !1) {
|
|
111
111
|
if (n.value) return n.value;
|
|
112
|
-
if (!e.url || !l && !
|
|
112
|
+
if (!e.url || !l && !ne() && location.hostname?.match(/([^.]+\.[^.]+)$/)?.[1] === new URL(e.url).hostname.match(/([^.]+\.[^.]+)$/)?.[1])
|
|
113
113
|
return t.value = null, null;
|
|
114
114
|
s.value = !0;
|
|
115
|
-
const
|
|
115
|
+
const g = fetch(`${e.url}/auth/verify`, {
|
|
116
116
|
credentials: "include",
|
|
117
117
|
cache: l ? "reload" : void 0
|
|
118
118
|
});
|
|
119
|
-
return !
|
|
120
|
-
if (
|
|
121
|
-
const b = await
|
|
119
|
+
return !g || typeof g.then != "function" ? (s.value = !1, t.value = null, null) : (n.value = g.then(async (v) => {
|
|
120
|
+
if (v.ok || v.status === 401) {
|
|
121
|
+
const b = await v.json();
|
|
122
122
|
return t.value = b.user, r.value.onAuth?.(b), b;
|
|
123
123
|
} else {
|
|
124
|
-
const b = new Error(
|
|
124
|
+
const b = new Error(v.statusText || `HTTP ${v.status}`);
|
|
125
125
|
return r.value.onError?.(b), null;
|
|
126
126
|
}
|
|
127
|
-
}, (
|
|
127
|
+
}, (v) => (r.value.onError?.(v), null)).finally(() => {
|
|
128
128
|
s.value = !1, n.value = null;
|
|
129
129
|
}), n.value);
|
|
130
130
|
}
|
|
131
131
|
async function I(l = "github") {
|
|
132
132
|
s.value = !0;
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
window.location.assign(p + "?next=" + encodeURIComponent(window.location.href));
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const h = 400, b = 600, W = window.screenX + (window.innerWidth - h) / 2, _ = window.screenY + (window.innerHeight - b) / 2, u = window.open(p, "vuetify:authorize:popup", `popup,left=${W},top=${_},width=${h},height=${b},resizable`);
|
|
139
|
-
if (!u) {
|
|
133
|
+
const g = `${e.url}/auth/${l}/redirect`, v = 400, b = 600, z = window.screenX + (window.innerWidth - v) / 2, N = window.screenY + (window.innerHeight - b) / 2, c = window.open(g, "vuetify:authorize:popup", `popup,left=${z},top=${N},width=${v},height=${b},resizable`);
|
|
134
|
+
if (!c) {
|
|
140
135
|
const E = /* @__PURE__ */ new Error("Failed to open popup");
|
|
141
136
|
r.value.onError?.(E), s.value = !1;
|
|
142
137
|
return;
|
|
143
138
|
}
|
|
144
|
-
let
|
|
145
|
-
function
|
|
139
|
+
let p = -1, A = -1;
|
|
140
|
+
function x(E) {
|
|
146
141
|
if (E.origin === e.url && E.data?.type === "auth-response") {
|
|
147
142
|
if (E.data.status === "success")
|
|
148
143
|
t.value || (localStorage.setItem("vuetify@lastLoginProvider", l), i.value = !1), t.value = E.data.body.user, r.value.onAuth?.({
|
|
@@ -153,62 +148,62 @@ const V = $("auth-core", () => {
|
|
|
153
148
|
const H = new Error(E.data.message || "Authentication failed");
|
|
154
149
|
r.value.onError?.(H);
|
|
155
150
|
}
|
|
156
|
-
|
|
151
|
+
W();
|
|
157
152
|
}
|
|
158
153
|
}
|
|
159
|
-
function
|
|
160
|
-
window.removeEventListener("message",
|
|
154
|
+
function W() {
|
|
155
|
+
window.removeEventListener("message", x), window.clearInterval(p), window.clearTimeout(A), c?.close(), s.value = !1;
|
|
161
156
|
}
|
|
162
|
-
window.addEventListener("message",
|
|
163
|
-
!
|
|
157
|
+
window.addEventListener("message", x), p = window.setInterval(() => {
|
|
158
|
+
!c || c.closed ? (r.value.onError?.(/* @__PURE__ */ new Error("Auth popup closed")), W()) : c.postMessage({ type: "auth-request" }, e.url);
|
|
164
159
|
}, 1e3), A = window.setTimeout(() => {
|
|
165
|
-
|
|
160
|
+
W(), r.value.onError?.(/* @__PURE__ */ new Error("Auth timed out"));
|
|
166
161
|
}, 120 * 1e3);
|
|
167
162
|
}
|
|
168
|
-
async function
|
|
163
|
+
async function h(l) {
|
|
169
164
|
s.value = !0;
|
|
170
|
-
const
|
|
165
|
+
const g = l ? `/auth/${l}/logout` : "/auth/logout";
|
|
171
166
|
try {
|
|
172
|
-
await e.post(
|
|
173
|
-
} catch (
|
|
174
|
-
r.value.onError?.(
|
|
167
|
+
await e.post(g), t.value = null;
|
|
168
|
+
} catch (v) {
|
|
169
|
+
r.value.onError?.(v);
|
|
175
170
|
} finally {
|
|
176
171
|
s.value = !1;
|
|
177
172
|
}
|
|
178
173
|
}
|
|
179
174
|
function T(l) {
|
|
180
|
-
return t.value?.identities.find((
|
|
175
|
+
return t.value?.identities.find((g) => g.provider === l);
|
|
181
176
|
}
|
|
182
|
-
function
|
|
183
|
-
return
|
|
177
|
+
function f() {
|
|
178
|
+
return te ? localStorage.getItem("vuetify@lastLoginProvider") : null;
|
|
184
179
|
}
|
|
185
180
|
return {
|
|
186
181
|
user: t,
|
|
187
182
|
dialog: i,
|
|
188
183
|
isLoading: s,
|
|
189
|
-
isAuthenticated:
|
|
184
|
+
isAuthenticated: u,
|
|
190
185
|
isSuper: a,
|
|
191
186
|
isAdmin: d,
|
|
192
|
-
isEditor:
|
|
187
|
+
isEditor: y,
|
|
193
188
|
setCallbacks: R,
|
|
194
189
|
verify: O,
|
|
195
190
|
login: I,
|
|
196
|
-
logout:
|
|
191
|
+
logout: h,
|
|
197
192
|
findIdentity: T,
|
|
198
|
-
lastLoginProvider:
|
|
193
|
+
lastLoginProvider: f
|
|
199
194
|
};
|
|
200
195
|
}), ve = $("auth-device", () => {
|
|
201
|
-
const e =
|
|
196
|
+
const e = _(), i = Q(), t = S(null), s = L("idle"), r = S(null);
|
|
202
197
|
async function n(d) {
|
|
203
198
|
if (!i.isAuthenticated)
|
|
204
199
|
return r.value = "Must be authenticated to authorize device", !1;
|
|
205
200
|
try {
|
|
206
201
|
return s.value = "pending", await e.post(`/auth/device/${d}/authorize`), s.value = "authorized", !0;
|
|
207
|
-
} catch (
|
|
208
|
-
return s.value = "error", r.value =
|
|
202
|
+
} catch (y) {
|
|
203
|
+
return s.value = "error", r.value = y.message, !1;
|
|
209
204
|
}
|
|
210
205
|
}
|
|
211
|
-
async function
|
|
206
|
+
async function u(d) {
|
|
212
207
|
try {
|
|
213
208
|
return (await e.get(`/auth/device/${d}/status`)).status;
|
|
214
209
|
} catch {
|
|
@@ -223,17 +218,17 @@ const V = $("auth-core", () => {
|
|
|
223
218
|
status: q(s),
|
|
224
219
|
error: q(r),
|
|
225
220
|
authorize: n,
|
|
226
|
-
getStatus:
|
|
221
|
+
getStatus: u,
|
|
227
222
|
reset: a
|
|
228
223
|
};
|
|
229
|
-
}),
|
|
224
|
+
}), se = [
|
|
230
225
|
(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),
|
|
231
226
|
(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),
|
|
232
227
|
(e) => (e.v === 2 && (e.syncSettings = !0, e.disableAds = !1, e.v = 3), e),
|
|
233
228
|
(e) => (e.v === 3 && (e.quickbar = !1, e.v = 4), e),
|
|
234
229
|
(e) => (e.v === 4 && (e.suits = { show: !1, elements: ["app-bar"], suit: "" }, e.notifications = e.notifications || {}, e.notifications.banners = !0, e.v = 5), e)
|
|
235
230
|
];
|
|
236
|
-
function
|
|
231
|
+
function re(e) {
|
|
237
232
|
return {
|
|
238
233
|
version: 6,
|
|
239
234
|
ecosystem: {
|
|
@@ -304,8 +299,8 @@ function F(e) {
|
|
|
304
299
|
}
|
|
305
300
|
};
|
|
306
301
|
}
|
|
307
|
-
function
|
|
308
|
-
const i =
|
|
302
|
+
function oe(e) {
|
|
303
|
+
const i = se.reduce((s, r) => r(s), e), t = re(i);
|
|
309
304
|
return F(t);
|
|
310
305
|
}
|
|
311
306
|
const B = typeof window < "u", C = {
|
|
@@ -371,8 +366,8 @@ const B = typeof window < "u", C = {
|
|
|
371
366
|
sync: !0,
|
|
372
367
|
devmode: !1
|
|
373
368
|
}
|
|
374
|
-
},
|
|
375
|
-
const e =
|
|
369
|
+
}, ie = $("user", () => {
|
|
370
|
+
const e = Y(structuredClone(C));
|
|
376
371
|
j(e, t, { deep: !0 });
|
|
377
372
|
function i() {
|
|
378
373
|
if (!B)
|
|
@@ -382,22 +377,22 @@ const B = typeof window < "u", C = {
|
|
|
382
377
|
try {
|
|
383
378
|
const n = JSON.parse(r);
|
|
384
379
|
if (n.version >= 7) {
|
|
385
|
-
const
|
|
380
|
+
const u = {
|
|
386
381
|
version: 7,
|
|
387
|
-
ecosystem:
|
|
388
|
-
one:
|
|
382
|
+
ecosystem: U(structuredClone(C.ecosystem), n.ecosystem || {}),
|
|
383
|
+
one: U(structuredClone(C.one), n.one || {})
|
|
389
384
|
};
|
|
390
|
-
Object.assign(e,
|
|
385
|
+
Object.assign(e, u);
|
|
391
386
|
} else if (n.version === 6) {
|
|
392
|
-
const
|
|
387
|
+
const u = F(n), a = {
|
|
393
388
|
version: 7,
|
|
394
|
-
ecosystem:
|
|
395
|
-
one:
|
|
389
|
+
ecosystem: U(structuredClone(C.ecosystem), u.ecosystem || {}),
|
|
390
|
+
one: U(structuredClone(C.one), u.one || {})
|
|
396
391
|
};
|
|
397
392
|
Object.assign(e, a);
|
|
398
393
|
} else {
|
|
399
|
-
const
|
|
400
|
-
Object.assign(e,
|
|
394
|
+
const u = oe(n);
|
|
395
|
+
Object.assign(e, u);
|
|
401
396
|
}
|
|
402
397
|
t();
|
|
403
398
|
} catch (n) {
|
|
@@ -411,27 +406,27 @@ const B = typeof window < "u", C = {
|
|
|
411
406
|
B && (Object.assign(e, structuredClone(C)), t());
|
|
412
407
|
}
|
|
413
408
|
return i(), {
|
|
414
|
-
...
|
|
409
|
+
...G(e),
|
|
415
410
|
load: i,
|
|
416
411
|
save: t,
|
|
417
412
|
reset: s
|
|
418
413
|
};
|
|
419
414
|
});
|
|
420
|
-
function
|
|
421
|
-
const e =
|
|
422
|
-
return
|
|
415
|
+
function V() {
|
|
416
|
+
const e = ee();
|
|
417
|
+
return m(
|
|
423
418
|
() => e.query
|
|
424
419
|
);
|
|
425
420
|
}
|
|
426
|
-
const
|
|
427
|
-
const e =
|
|
421
|
+
const M = $("one", () => {
|
|
422
|
+
const e = V(), i = K(), t = X(), s = _(), r = J(), n = L(!1), u = L(!1), a = S(null), d = S([]), y = m(() => e.value.session_id), R = m(() => a.value?.items[0].plan.interval), O = m(() => a.value?.items[0].plan.type), I = S([]), h = m(() => t.user?.sponsorships.find((o) => o.platform === "stripe" && o.tierName.startsWith("sub_"))), T = m(() => !!h.value?.tierName), f = m(() => t.user?.sponsorships.reduce((o, w) => {
|
|
428
423
|
if (!w.isActive || w.interval === "once")
|
|
429
424
|
return o;
|
|
430
425
|
const k = w.interval === "month" ? w.amount : w.amount / 12;
|
|
431
426
|
return o + k / 100;
|
|
432
|
-
}, 0) ?? 0), l =
|
|
433
|
-
j(
|
|
434
|
-
o && await
|
|
427
|
+
}, 0) ?? 0), l = m(() => t.user?.sponsorships.find((o) => o.tierName.startsWith("sub_") && o.isActive)), g = m(() => t.user?.sponsorships.find((o) => o.platform === "github" && o.isActive)), v = m(() => t.user?.sponsorships.find((o) => o.platform === "discord" && o.isActive)), b = m(() => t.user?.sponsorships.find((o) => o.platform === "opencollective" && o.isActive)), z = m(() => !s.url || t.isAdmin || h.value?.isActive || I.value.some((o) => ["one", "one/team"].includes(o)));
|
|
428
|
+
j(u, H), j(y, async (o) => {
|
|
429
|
+
o && await N();
|
|
435
430
|
}, { immediate: !0 }), j(e, (o) => {
|
|
436
431
|
if (o.one !== "subscribe" || t.user)
|
|
437
432
|
return;
|
|
@@ -440,9 +435,9 @@ const X = $("one", () => {
|
|
|
440
435
|
k && (t.dialog = !1, w());
|
|
441
436
|
});
|
|
442
437
|
}, { immediate: !0 });
|
|
443
|
-
async function
|
|
438
|
+
async function N() {
|
|
444
439
|
try {
|
|
445
|
-
n.value = !0, await s.post("/one/activate", { sessionId:
|
|
440
|
+
n.value = !0, await s.post("/one/activate", { sessionId: y.value }), await t.verify(!0), await W();
|
|
446
441
|
const o = new URL(window.location.href), w = o.searchParams;
|
|
447
442
|
w.delete("session_id"), w.delete("team"), history.pushState(null, "", o.toString());
|
|
448
443
|
} catch (o) {
|
|
@@ -451,19 +446,19 @@ const X = $("one", () => {
|
|
|
451
446
|
n.value = !1;
|
|
452
447
|
}
|
|
453
448
|
}
|
|
454
|
-
async function
|
|
449
|
+
async function c() {
|
|
455
450
|
window.open(`${s.url}/one/manage`, "_blank");
|
|
456
451
|
}
|
|
457
|
-
async function
|
|
452
|
+
async function p(o, w) {
|
|
458
453
|
n.value = !0;
|
|
459
454
|
const k = new URL("/one/subscribe", s.url);
|
|
460
455
|
k.searchParams.set("interval", o), k.searchParams.set("type", w), window.location.href = k.toString();
|
|
461
456
|
}
|
|
462
|
-
async function
|
|
463
|
-
if (
|
|
457
|
+
async function A() {
|
|
458
|
+
if (h.value)
|
|
464
459
|
try {
|
|
465
460
|
n.value = !0, await s.post(
|
|
466
|
-
`/one/cancel?subscriptionId=${
|
|
461
|
+
`/one/cancel?subscriptionId=${h.value?.tierName}`
|
|
467
462
|
), await t.verify(!0);
|
|
468
463
|
} catch (o) {
|
|
469
464
|
r.showError(o?.message ?? "Error cancelling subscription, Please contact support");
|
|
@@ -471,11 +466,11 @@ const X = $("one", () => {
|
|
|
471
466
|
n.value = !1;
|
|
472
467
|
}
|
|
473
468
|
}
|
|
474
|
-
async function
|
|
475
|
-
if (
|
|
469
|
+
async function x(o, w) {
|
|
470
|
+
if (h.value)
|
|
476
471
|
try {
|
|
477
472
|
n.value = !0, await s.post("/one/modify", {
|
|
478
|
-
subscriptionId:
|
|
473
|
+
subscriptionId: h.value.tierName,
|
|
479
474
|
interval: o,
|
|
480
475
|
type: w
|
|
481
476
|
}), await t.verify(!0);
|
|
@@ -485,7 +480,7 @@ const X = $("one", () => {
|
|
|
485
480
|
n.value = !1;
|
|
486
481
|
}
|
|
487
482
|
}
|
|
488
|
-
async function
|
|
483
|
+
async function W() {
|
|
489
484
|
try {
|
|
490
485
|
n.value = !0;
|
|
491
486
|
const o = await s.get("/one/info");
|
|
@@ -496,7 +491,7 @@ const X = $("one", () => {
|
|
|
496
491
|
n.value = !1;
|
|
497
492
|
}
|
|
498
493
|
}
|
|
499
|
-
async function
|
|
494
|
+
async function E() {
|
|
500
495
|
try {
|
|
501
496
|
return n.value = !0, (await s.get("/one/activity")).items;
|
|
502
497
|
} catch (o) {
|
|
@@ -505,7 +500,7 @@ const X = $("one", () => {
|
|
|
505
500
|
n.value = !1;
|
|
506
501
|
}
|
|
507
502
|
}
|
|
508
|
-
function
|
|
503
|
+
function H() {
|
|
509
504
|
i.push({
|
|
510
505
|
query: {
|
|
511
506
|
...e.value,
|
|
@@ -519,50 +514,49 @@ const X = $("one", () => {
|
|
|
519
514
|
subscriptionType: O,
|
|
520
515
|
access: I,
|
|
521
516
|
invoices: d,
|
|
522
|
-
sessionId:
|
|
523
|
-
subscription:
|
|
524
|
-
monthlyTotal:
|
|
525
|
-
recentActivity:
|
|
517
|
+
sessionId: y,
|
|
518
|
+
subscription: h,
|
|
519
|
+
monthlyTotal: f,
|
|
520
|
+
recentActivity: E,
|
|
526
521
|
hasBilling: T,
|
|
527
522
|
isLoading: n,
|
|
528
|
-
isOpen:
|
|
529
|
-
isSubscriber:
|
|
523
|
+
isOpen: u,
|
|
524
|
+
isSubscriber: z,
|
|
530
525
|
opencollective: b,
|
|
531
|
-
github:
|
|
532
|
-
discord:
|
|
533
|
-
shopify: W,
|
|
526
|
+
github: g,
|
|
527
|
+
discord: v,
|
|
534
528
|
one: l,
|
|
535
|
-
activate:
|
|
536
|
-
cancel:
|
|
537
|
-
manage:
|
|
538
|
-
modify:
|
|
539
|
-
resetQuery:
|
|
540
|
-
subscribe:
|
|
541
|
-
subscriptionInfo:
|
|
529
|
+
activate: N,
|
|
530
|
+
cancel: A,
|
|
531
|
+
manage: c,
|
|
532
|
+
modify: x,
|
|
533
|
+
resetQuery: H,
|
|
534
|
+
subscribe: p,
|
|
535
|
+
subscriptionInfo: W
|
|
542
536
|
};
|
|
543
|
-
}),
|
|
544
|
-
const e =
|
|
545
|
-
() =>
|
|
537
|
+
}), ae = $("team", () => {
|
|
538
|
+
const e = V(), i = X(), t = M(), s = _(), r = J(), n = L(!1), u = S(null), a = S(!1), d = m(() => e.value.invite), y = m(
|
|
539
|
+
() => u.value ? t.access?.some((f) => ["one/team", "snips/team"].includes(f)) : !1
|
|
546
540
|
);
|
|
547
541
|
j(d, async () => {
|
|
548
542
|
if (d.value) {
|
|
549
543
|
i.user || (i.dialog = !0);
|
|
550
544
|
try {
|
|
551
545
|
n.value = !0;
|
|
552
|
-
const
|
|
553
|
-
|
|
554
|
-
} catch (
|
|
555
|
-
|
|
546
|
+
const f = await s.get(`/one/team/${d.value}`);
|
|
547
|
+
u.value = f.team, a.value = !0;
|
|
548
|
+
} catch (f) {
|
|
549
|
+
h(), r.showError(f.message);
|
|
556
550
|
} finally {
|
|
557
551
|
n.value = !1;
|
|
558
552
|
}
|
|
559
553
|
}
|
|
560
554
|
}, { immediate: !0 });
|
|
561
|
-
async function R(
|
|
555
|
+
async function R(f) {
|
|
562
556
|
try {
|
|
563
|
-
if (n.value = !0, !
|
|
557
|
+
if (n.value = !0, !u.value)
|
|
564
558
|
return;
|
|
565
|
-
await s.post("/one/team/remove", { userId:
|
|
559
|
+
await s.post("/one/team/remove", { userId: f }), u.value.members = u.value.members.filter((l) => l.id !== f);
|
|
566
560
|
} catch (l) {
|
|
567
561
|
r.showError(l?.message ?? "Error removing user from team");
|
|
568
562
|
} finally {
|
|
@@ -571,103 +565,103 @@ const X = $("one", () => {
|
|
|
571
565
|
}
|
|
572
566
|
async function O() {
|
|
573
567
|
try {
|
|
574
|
-
n.value = !0, await s.post("/one/team/leave", { teamId:
|
|
575
|
-
} catch (
|
|
576
|
-
r.showError(
|
|
568
|
+
n.value = !0, await s.post("/one/team/leave", { teamId: u.value?.id }), await i.verify(!0);
|
|
569
|
+
} catch (f) {
|
|
570
|
+
r.showError(f?.message ?? "Error leaving team");
|
|
577
571
|
} finally {
|
|
578
572
|
n.value = !1;
|
|
579
573
|
}
|
|
580
574
|
}
|
|
581
575
|
async function I() {
|
|
582
576
|
try {
|
|
583
|
-
n.value = !0, await s.post("/one/team/join", { inviteCode: d.value }), await i.verify(!0),
|
|
584
|
-
} catch (
|
|
585
|
-
r.showError(
|
|
577
|
+
n.value = !0, await s.post("/one/team/join", { inviteCode: d.value }), await i.verify(!0), h();
|
|
578
|
+
} catch (f) {
|
|
579
|
+
r.showError(f?.message ?? "Error joining team");
|
|
586
580
|
} finally {
|
|
587
581
|
n.value = !1;
|
|
588
582
|
}
|
|
589
583
|
}
|
|
590
|
-
function
|
|
584
|
+
function h() {
|
|
591
585
|
a.value = !1;
|
|
592
|
-
const
|
|
593
|
-
|
|
586
|
+
const f = new URL(window.location.href);
|
|
587
|
+
f.searchParams.delete("invite"), window.history.replaceState({}, "", f.toString());
|
|
594
588
|
}
|
|
595
|
-
const T =
|
|
589
|
+
const T = m(() => i.user?.id === i.user?.team?.owner?.id);
|
|
596
590
|
return {
|
|
597
|
-
team:
|
|
591
|
+
team: u,
|
|
598
592
|
teamInviteDialog: a,
|
|
599
593
|
teamInviteCode: d,
|
|
600
|
-
hasTeamAccess:
|
|
594
|
+
hasTeamAccess: y,
|
|
601
595
|
isTeamOwner: T,
|
|
602
596
|
isLoading: n,
|
|
603
597
|
removeFromTeam: R,
|
|
604
598
|
leaveTeam: O,
|
|
605
599
|
joinTeam: I,
|
|
606
|
-
clearTeamQuery:
|
|
600
|
+
clearTeamQuery: h
|
|
607
601
|
};
|
|
608
|
-
}),
|
|
609
|
-
const e =
|
|
602
|
+
}), ue = typeof window < "u", X = $("auth", () => {
|
|
603
|
+
const e = Q(), i = _(), t = ie(), s = K(), r = M(), n = ae(), u = J(), a = P(() => e.user), d = P(e, "dialog"), y = P(() => e.isLoading), R = P(() => e.isAuthenticated), O = P(() => e.isSuper), I = P(() => e.isAdmin), h = P(() => e.isEditor);
|
|
610
604
|
let T = !!e.lastLoginProvider();
|
|
611
|
-
j(a, (
|
|
612
|
-
if (!
|
|
605
|
+
j(a, (c) => {
|
|
606
|
+
if (!ue || !c?.settings)
|
|
613
607
|
return;
|
|
614
|
-
const
|
|
615
|
-
if (JSON.stringify(
|
|
608
|
+
const p = localStorage.getItem("vuetify@user") || "{}";
|
|
609
|
+
if (JSON.stringify(c.settings, null, 2) === p)
|
|
616
610
|
return;
|
|
617
611
|
T = !0;
|
|
618
|
-
let A =
|
|
612
|
+
let A = c.settings;
|
|
619
613
|
A.version === 6 && (A = F(A));
|
|
620
|
-
const
|
|
614
|
+
const x = {
|
|
621
615
|
version: 7,
|
|
622
|
-
ecosystem:
|
|
623
|
-
one:
|
|
616
|
+
ecosystem: U(structuredClone(C.ecosystem), A.ecosystem || {}),
|
|
617
|
+
one: U(structuredClone(C.one), A.one || {})
|
|
624
618
|
};
|
|
625
|
-
Object.assign(t,
|
|
619
|
+
Object.assign(t, x);
|
|
626
620
|
});
|
|
627
|
-
const
|
|
621
|
+
const f = D(l, 500);
|
|
628
622
|
t.$subscribe(() => {
|
|
629
|
-
T ||
|
|
623
|
+
T || f(), T = !1;
|
|
630
624
|
});
|
|
631
625
|
async function l() {
|
|
632
|
-
if (await
|
|
626
|
+
if (await Z(), !(!a.value || !t.one.sync))
|
|
633
627
|
try {
|
|
634
|
-
await i.post("/user/settings", { settings: t.$state }), await
|
|
635
|
-
} catch (
|
|
636
|
-
|
|
628
|
+
await i.post("/user/settings", { settings: t.$state }), await g(!0);
|
|
629
|
+
} catch (c) {
|
|
630
|
+
u.showError(c?.message ?? "Error syncing settings");
|
|
637
631
|
}
|
|
638
632
|
}
|
|
639
633
|
e.setCallbacks({
|
|
640
|
-
onAuth: (
|
|
641
|
-
r.access =
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
id:
|
|
645
|
-
name:
|
|
646
|
-
inviteCode:
|
|
647
|
-
members:
|
|
648
|
-
owner:
|
|
634
|
+
onAuth: (c) => {
|
|
635
|
+
r.access = c.access;
|
|
636
|
+
const p = c.user?.team;
|
|
637
|
+
p?.inviteCode && p.members && p.owner && (n.team = {
|
|
638
|
+
id: p.id,
|
|
639
|
+
name: p.name,
|
|
640
|
+
inviteCode: p.inviteCode,
|
|
641
|
+
members: p.members,
|
|
642
|
+
owner: p.owner
|
|
649
643
|
});
|
|
650
644
|
},
|
|
651
|
-
onError: (
|
|
652
|
-
|
|
645
|
+
onError: (c) => {
|
|
646
|
+
u.showError(c.message ?? "Authentication error");
|
|
653
647
|
}
|
|
654
648
|
});
|
|
655
|
-
async function
|
|
656
|
-
return e.verify(
|
|
649
|
+
async function g(c = !1) {
|
|
650
|
+
return e.verify(c);
|
|
657
651
|
}
|
|
658
|
-
async function
|
|
659
|
-
await e.login(
|
|
652
|
+
async function v(c = "github") {
|
|
653
|
+
await e.login(c), e.user && (e.dialog = !1, s.push("/user/dashboard"), l());
|
|
660
654
|
}
|
|
661
|
-
async function b(
|
|
662
|
-
await e.logout(
|
|
655
|
+
async function b(c) {
|
|
656
|
+
await e.logout(c), s.push({
|
|
663
657
|
path: "/",
|
|
664
658
|
query: s.currentRoute.value.query
|
|
665
659
|
});
|
|
666
660
|
}
|
|
667
|
-
function
|
|
668
|
-
return e.findIdentity(
|
|
661
|
+
function z(c) {
|
|
662
|
+
return e.findIdentity(c);
|
|
669
663
|
}
|
|
670
|
-
function
|
|
664
|
+
function N() {
|
|
671
665
|
return e.lastLoginProvider();
|
|
672
666
|
}
|
|
673
667
|
return {
|
|
@@ -675,28 +669,28 @@ const X = $("one", () => {
|
|
|
675
669
|
user: a,
|
|
676
670
|
url: i.url,
|
|
677
671
|
dialog: d,
|
|
678
|
-
isLoading:
|
|
672
|
+
isLoading: y,
|
|
679
673
|
isAuthenticated: R,
|
|
680
674
|
isSuper: O,
|
|
681
675
|
isAdmin: I,
|
|
682
|
-
isEditor:
|
|
676
|
+
isEditor: h,
|
|
683
677
|
// Actions
|
|
684
|
-
verify:
|
|
685
|
-
findIdentity:
|
|
686
|
-
login:
|
|
678
|
+
verify: g,
|
|
679
|
+
findIdentity: z,
|
|
680
|
+
login: v,
|
|
687
681
|
logout: b,
|
|
688
|
-
lastLoginProvider:
|
|
682
|
+
lastLoginProvider: N,
|
|
689
683
|
sync: l
|
|
690
684
|
};
|
|
691
685
|
});
|
|
692
686
|
export {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
687
|
+
X as a,
|
|
688
|
+
ie as b,
|
|
689
|
+
M as c,
|
|
690
|
+
V as d,
|
|
691
|
+
_ as e,
|
|
692
|
+
ae as f,
|
|
693
|
+
de as g,
|
|
700
694
|
ve as h,
|
|
701
695
|
J as u
|
|
702
696
|
};
|