@aerogel/plugin-solid 0.1.0 → 0.1.1-next.26f3c2c807213724de7500a899a6712abae430ad
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/aerogel-plugin-solid.d.ts +3 -0
- package/dist/aerogel-plugin-solid.js +197 -168
- package/dist/aerogel-plugin-solid.js.map +1 -1
- package/package.json +3 -1
- package/src/index.ts +3 -0
- package/src/services/Solid.state.ts +2 -1
- package/src/services/Solid.ts +55 -2
- package/src/types/env.d.ts +1 -0
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (n, e, t) =>
|
|
4
|
-
import { persistent as
|
|
5
|
-
import { SolidEngine as
|
|
6
|
-
import { JSError as
|
|
7
|
-
import { fetchLoginUserProfile as
|
|
8
|
-
import { setEngine as
|
|
1
|
+
var de = Object.defineProperty;
|
|
2
|
+
var he = (n, e, t) => e in n ? de(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var h = (n, e, t) => he(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { persistent as ge, defineServiceState as fe, Events as g, UI as E, translateWithDefault as u, App as m, Storage as me, Errors as J, defineFormValidationRule as we, computedAsync as pe, Cache as k, useForm as ye, stringInput as Se, requiredStringInput as ve, classes as K, Form as be, Input as Ie, Select as Le, Button as F, Link as Ae, registerErrorHandler as Pe, bootServices as Ce } from "@aerogel/core";
|
|
5
|
+
import { SolidEngine as Ue, SolidTypeIndex as v, SolidContainer as q, SolidACLAuthorization as Ee, SolidDocument as xe, isSolidModel as Te, bootSolidModels as $e } from "soukai-solid";
|
|
6
|
+
import { JSError as V, arr as _e, fail as x, PromisedValue as Re, Storage as O, after as H, required as X, facade as ke, tap as D, arrayUnique as Z, objectWithout as ee, isDevelopment as Fe, resetAsyncMemo as te, asyncMemo as ie, hasLocationQueryParameter as A, getLocationQueryParameter as M, arrayFilter as qe, setAsyncMemo as ne, urlRoot as Oe, requireUrlParse as De, objectWithoutEmpty as Me, parseBoolean as re, arrayWithout as ze } from "@noeldemartin/utils";
|
|
7
|
+
import { fetchLoginUserProfile as Be } from "@noeldemartin/solid-utils";
|
|
8
|
+
import { setEngine as Ne, getBootedModels as je } from "soukai";
|
|
9
9
|
import P from "virtual:aerogel-solid";
|
|
10
|
-
import {
|
|
11
|
-
|
|
10
|
+
import { trackModelsCollection as z, isTrackingModel as Ve } from "@aerogel/plugin-soukai";
|
|
11
|
+
import { markRaw as oe, createElementBlock as p, openBlock as d, createElementVNode as S, defineComponent as W, unref as c, computed as I, createBlock as w, toDisplayString as L, ref as se, resolveDirective as He, normalizeClass as C, withCtx as b, createCommentVNode as B, createVNode as N, withDirectives as We, createTextVNode as U } from "vue";
|
|
12
|
+
class Qe extends V {
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function Ye(n, e) {
|
|
14
15
|
return n;
|
|
15
16
|
}
|
|
16
|
-
class T extends
|
|
17
|
+
class T extends V {
|
|
17
18
|
constructor(t, i, r) {
|
|
18
|
-
super(
|
|
19
|
+
super(Ye(t), r);
|
|
19
20
|
h(this, "description");
|
|
20
21
|
this.description = i;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
class
|
|
24
|
+
class Ge extends V {
|
|
24
25
|
constructor(e, t) {
|
|
25
26
|
super(`Container at ${e.url} is already in use`, t);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
class
|
|
29
|
+
class ae {
|
|
29
30
|
constructor() {
|
|
30
31
|
h(this, "name");
|
|
31
32
|
h(this, "authenticatedFetch");
|
|
32
33
|
h(this, "booted");
|
|
33
|
-
h(this, "listeners",
|
|
34
|
+
h(this, "listeners", _e([]));
|
|
34
35
|
h(this, "_engine");
|
|
35
36
|
}
|
|
36
37
|
get engine() {
|
|
37
|
-
return this._engine = this._engine ?? new
|
|
38
|
+
return this._engine = this._engine ?? new Ue(this.requireAuthenticatedFetch()), this._engine;
|
|
38
39
|
}
|
|
39
40
|
getAuthenticatedFetch() {
|
|
40
41
|
return this.authenticatedFetch ?? null;
|
|
41
42
|
}
|
|
42
43
|
requireAuthenticatedFetch() {
|
|
43
|
-
return this.authenticatedFetch ??
|
|
44
|
+
return this.authenticatedFetch ?? x("Authenticated fetch is not ready");
|
|
44
45
|
}
|
|
45
46
|
addListener(e) {
|
|
46
47
|
return this.listeners.includes(e) || this.listeners.push(e), () => {
|
|
@@ -53,7 +54,7 @@ class oe {
|
|
|
53
54
|
async boot() {
|
|
54
55
|
if (this.booted)
|
|
55
56
|
return this.booted;
|
|
56
|
-
this.booted = new
|
|
57
|
+
this.booted = new Re(), await this.restoreSession(), this.booted.resolve();
|
|
57
58
|
}
|
|
58
59
|
async initAuthenticatedFetch(e) {
|
|
59
60
|
this.authenticatedFetch = e, await this.notifyListeners("onAuthenticatedFetchReady", e);
|
|
@@ -80,8 +81,8 @@ class oe {
|
|
|
80
81
|
);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
const
|
|
84
|
-
class
|
|
84
|
+
const j = "inrupt-authenticator";
|
|
85
|
+
class Je extends ae {
|
|
85
86
|
constructor() {
|
|
86
87
|
super(...arguments);
|
|
87
88
|
h(this, "_events");
|
|
@@ -91,44 +92,44 @@ class Ne extends oe {
|
|
|
91
92
|
h(this, "_handleIncomingRedirect");
|
|
92
93
|
}
|
|
93
94
|
async login(t) {
|
|
94
|
-
O.set(
|
|
95
|
+
O.set(j, t);
|
|
95
96
|
const i = {
|
|
96
97
|
oidcIssuer: t
|
|
97
98
|
};
|
|
98
|
-
return P.clientID && (i.clientId = P.clientID.client_id, i.clientName = P.clientID.client_name, i.redirectUrl = P.clientID.redirect_uris[0]), await this._login(i), await H({ seconds: 60 }),
|
|
99
|
+
return P.clientID && (i.clientId = P.clientID.client_id, i.clientName = P.clientID.client_name, i.redirectUrl = P.clientID.redirect_uris[0]), await this._login(i), await H({ seconds: 60 }), x("Browser should have redirected, but it didn't");
|
|
99
100
|
}
|
|
100
101
|
async logout() {
|
|
101
102
|
await this._logout(), await this.endSession();
|
|
102
103
|
}
|
|
103
104
|
async restoreSession() {
|
|
104
|
-
const { events: t, fetch: i, handleIncomingRedirect: r, login: s, logout:
|
|
105
|
-
this._fetch = i, this._login = s, this._logout =
|
|
105
|
+
const { events: t, fetch: i, handleIncomingRedirect: r, login: s, logout: l } = await import("./InruptAuthenticator.lazy-BvpQLGoj.js");
|
|
106
|
+
this._fetch = i, this._login = s, this._logout = l, this._events = t, this._handleIncomingRedirect = r, await this.loginFromRedirect();
|
|
106
107
|
}
|
|
107
108
|
async loginFromRedirect() {
|
|
108
|
-
const t = O.get(
|
|
109
|
+
const t = O.get(j);
|
|
109
110
|
if (!t)
|
|
110
111
|
return;
|
|
111
112
|
this._events().on("error", (r, s) => {
|
|
112
113
|
r ?? (r = "Error using Inrupt Authenticator method"), typeof s == "object" ? this.failSession(t, new T(r, null, { cause: s })) : this.failSession(t, new T(r, s));
|
|
113
114
|
});
|
|
114
115
|
const i = await this._handleIncomingRedirect(globalThis.location.href);
|
|
115
|
-
O.remove(
|
|
116
|
+
O.remove(j), i != null && i.isLoggedIn && i.webId && await this.initSession(i.webId);
|
|
116
117
|
}
|
|
117
118
|
async initSession(t) {
|
|
118
119
|
await this.initAuthenticatedFetch(this._fetch);
|
|
119
120
|
try {
|
|
120
|
-
const i = await
|
|
121
|
+
const i = await f.requireUserProfile(t);
|
|
121
122
|
await this.startSession({ user: i, loginUrl: t });
|
|
122
123
|
} catch (i) {
|
|
123
124
|
await this.failSession(t, i);
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
|
-
class
|
|
128
|
+
class Ke extends ae {
|
|
128
129
|
constructor() {
|
|
129
130
|
super();
|
|
130
131
|
h(this, "store");
|
|
131
|
-
this.store =
|
|
132
|
+
this.store = ge("legacy-authenticator", {});
|
|
132
133
|
}
|
|
133
134
|
async login(t, i) {
|
|
134
135
|
const { SolidAuthClient: r } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js");
|
|
@@ -141,37 +142,37 @@ class Qe extends oe {
|
|
|
141
142
|
async restoreSession() {
|
|
142
143
|
if (!this.store.loginUrl)
|
|
143
144
|
return;
|
|
144
|
-
const { SolidAuthClient: t } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js"), i = await t.currentSession(), r =
|
|
145
|
-
await this.initAuthenticatedFetch((s,
|
|
145
|
+
const { SolidAuthClient: t } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js"), i = await t.currentSession(), r = X(this.store.loginUrl);
|
|
146
|
+
await this.initAuthenticatedFetch((s, l) => t.fetch(s, l));
|
|
146
147
|
try {
|
|
147
|
-
const s = await
|
|
148
|
+
const s = await f.requireUserProfile(X((i == null ? void 0 : i.webId) ?? this.store.webId));
|
|
148
149
|
await this.startSession({ user: s, loginUrl: r });
|
|
149
150
|
} catch (s) {
|
|
150
151
|
await this.failSession(r, s);
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
|
-
const
|
|
155
|
-
inrupt: new
|
|
156
|
-
legacy: new
|
|
155
|
+
const Q = {}, Xe = {
|
|
156
|
+
inrupt: new Je(),
|
|
157
|
+
legacy: new Ke()
|
|
157
158
|
};
|
|
158
|
-
function
|
|
159
|
-
|
|
159
|
+
function Ze(n) {
|
|
160
|
+
Q.default = n;
|
|
160
161
|
}
|
|
161
|
-
function
|
|
162
|
-
return
|
|
162
|
+
function le(n) {
|
|
163
|
+
return Q[n];
|
|
163
164
|
}
|
|
164
|
-
function
|
|
165
|
-
Object.entries(n).forEach(([e, t]) =>
|
|
165
|
+
function et(n) {
|
|
166
|
+
Object.entries(n).forEach(([e, t]) => tt(e, t));
|
|
166
167
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
168
|
+
function tt(n, e) {
|
|
169
|
+
Q[n] = e, e.name = e.name ?? n;
|
|
169
170
|
}
|
|
170
|
-
const
|
|
171
|
+
const Y = { autoReconnect: !0 }, it = fe({
|
|
171
172
|
name: "solid",
|
|
172
|
-
persist: ["autoReconnect", "dismissed", "previousSession", "profiles", "staleProfiles"],
|
|
173
|
+
persist: ["autoReconnect", "dismissed", "previousSession", "profiles", "staleProfiles", "collections"],
|
|
173
174
|
initialState: {
|
|
174
|
-
autoReconnect:
|
|
175
|
+
autoReconnect: Y.autoReconnect,
|
|
175
176
|
dismissed: !1,
|
|
176
177
|
ignorePreviousSessionError: !1,
|
|
177
178
|
loginStartupError: null,
|
|
@@ -181,7 +182,8 @@ const Q = { autoReconnect: !0 }, Xe = ge({
|
|
|
181
182
|
profiles: {},
|
|
182
183
|
session: null,
|
|
183
184
|
loginStale: !1,
|
|
184
|
-
staleProfiles: []
|
|
185
|
+
staleProfiles: [],
|
|
186
|
+
collections: {}
|
|
185
187
|
},
|
|
186
188
|
serialize(n) {
|
|
187
189
|
var e;
|
|
@@ -206,7 +208,7 @@ const Q = { autoReconnect: !0 }, Xe = ge({
|
|
|
206
208
|
}
|
|
207
209
|
}
|
|
208
210
|
});
|
|
209
|
-
class
|
|
211
|
+
class nt extends it {
|
|
210
212
|
isLoggedIn() {
|
|
211
213
|
return !!this.session;
|
|
212
214
|
}
|
|
@@ -217,20 +219,20 @@ class Ze extends Xe {
|
|
|
217
219
|
return !!(this.session || this.previousSession);
|
|
218
220
|
}
|
|
219
221
|
requireAuthenticator() {
|
|
220
|
-
return this.authenticator ??
|
|
222
|
+
return this.authenticator ?? x("Could not get authenticator");
|
|
221
223
|
}
|
|
222
224
|
requireUser() {
|
|
223
|
-
return this.user ??
|
|
225
|
+
return this.user ?? x("Could not get user profile (are you logged in?)");
|
|
224
226
|
}
|
|
225
227
|
requireUserProfile(e) {
|
|
226
228
|
return this.getUserProfile(e, { required: !0 });
|
|
227
229
|
}
|
|
228
230
|
/* eslint-enable max-len */
|
|
229
231
|
async getUserProfile(e, t = {}) {
|
|
230
|
-
var
|
|
232
|
+
var l;
|
|
231
233
|
let i = null;
|
|
232
|
-
const r = t.markStale ?? !((
|
|
233
|
-
await
|
|
234
|
+
const r = t.markStale ?? !((l = this.authenticator) != null && l.getAuthenticatedFetch()), s = this.profiles[e] ?? await D(
|
|
235
|
+
await Be(e, {
|
|
234
236
|
fetch: this.fetch,
|
|
235
237
|
required: t.required ?? !1,
|
|
236
238
|
onLoaded(o) {
|
|
@@ -238,15 +240,15 @@ class Ze extends Xe {
|
|
|
238
240
|
}
|
|
239
241
|
}),
|
|
240
242
|
async (o) => {
|
|
241
|
-
o && (i && await
|
|
243
|
+
o && (i && await g.emit("solid:user-profile-loaded", [o, i]), this.rememberProfile(o));
|
|
242
244
|
}
|
|
243
245
|
);
|
|
244
|
-
return s && r && this.setState({ staleProfiles:
|
|
246
|
+
return s && r && this.setState({ staleProfiles: Z(this.staleProfiles.concat([s.webId])) }), s;
|
|
245
247
|
}
|
|
246
248
|
async refreshUserProfile() {
|
|
247
249
|
if (!this.isLoggedIn())
|
|
248
250
|
return;
|
|
249
|
-
this.setState({ profiles:
|
|
251
|
+
this.setState({ profiles: ee(this.profiles, [this.user.webId]) });
|
|
250
252
|
const e = await this.requireUserProfile(this.user.webId);
|
|
251
253
|
this.setState({
|
|
252
254
|
session: {
|
|
@@ -256,11 +258,11 @@ class Ze extends Xe {
|
|
|
256
258
|
});
|
|
257
259
|
}
|
|
258
260
|
async login(e, t = {}) {
|
|
259
|
-
if (
|
|
261
|
+
if (Fe() && e === "dev" && (e = "http://localhost:3000"), /^https?:\/\//.test(e) || (t.fallbackUrl ?? (t.fallbackUrl = `http://${e}`), e = `https://${e}`), this.isLoggedIn())
|
|
260
262
|
return !0;
|
|
261
263
|
if (this.loginOngoing)
|
|
262
264
|
throw new Error("Authentication already in progress");
|
|
263
|
-
return t.loading ?
|
|
265
|
+
return t.loading ? E.loading(u("solid.loginOngoing", "Logging in..."), () => this.attemptLogin(e, t)) : this.attemptLogin(e, t);
|
|
264
266
|
}
|
|
265
267
|
async reconnect(e = {}) {
|
|
266
268
|
const { force: t, ...i } = e;
|
|
@@ -271,8 +273,8 @@ class Ze extends Xe {
|
|
|
271
273
|
});
|
|
272
274
|
}
|
|
273
275
|
async logout(e = !1) {
|
|
274
|
-
var
|
|
275
|
-
const t = !m.plugin("@aerogel/local-first") || !!((
|
|
276
|
+
var l, o;
|
|
277
|
+
const t = !m.plugin("@aerogel/local-first") || !!((l = m.service("$cloud")) != null && l.ready), i = !m.plugin("@aerogel/local-first") || !!((o = m.service("$cloud")) != null && o.dirty), [r, s] = e ? [!0, { wipeLocalData: t }] : await E.confirm(
|
|
276
278
|
t ? u("solid.logoutConfirmTitle", "Log out from this device?") : u("solid.disconnectConfirmTitle", "Disconnect account?"),
|
|
277
279
|
t ? i ? u(
|
|
278
280
|
"solid.logoutConfirmMessageWithLocalChanges",
|
|
@@ -311,20 +313,20 @@ class Ze extends Xe {
|
|
|
311
313
|
}
|
|
312
314
|
}
|
|
313
315
|
);
|
|
314
|
-
r && this.previousSession && await
|
|
316
|
+
r && this.previousSession && await E.loading(u("solid.logoutOngoing", "Logging out..."), async () => {
|
|
315
317
|
this.setState({
|
|
316
318
|
dismissed: !1,
|
|
317
319
|
ignorePreviousSessionError: !1,
|
|
318
320
|
loginStartupError: null,
|
|
319
321
|
previousSession: null,
|
|
320
|
-
...
|
|
321
|
-
}), this.isLoggedIn() && await this.authenticator.logout(), (s.wipeLocalData ?? !0) && await
|
|
322
|
+
...Y
|
|
323
|
+
}), this.isLoggedIn() && await this.authenticator.logout(), (s.wipeLocalData ?? !0) && await me.purge(), await g.emit("auth:logout"), await g.emit("auth:after-logout");
|
|
322
324
|
});
|
|
323
325
|
}
|
|
324
326
|
async whenLoggedIn(e) {
|
|
325
327
|
return this.isLoggedIn() ? e(this.session) : new Promise((t) => {
|
|
326
328
|
const i = (r) => t(e(r));
|
|
327
|
-
|
|
329
|
+
g.once("auth:login", i);
|
|
328
330
|
});
|
|
329
331
|
}
|
|
330
332
|
dismiss() {
|
|
@@ -335,21 +337,21 @@ class Ze extends Xe {
|
|
|
335
337
|
}
|
|
336
338
|
async findPrivateTypeIndex(e = {}) {
|
|
337
339
|
const { webId: t, privateTypeIndexUrl: i } = this.requireUser(), r = this.requireAuthenticator().engine;
|
|
338
|
-
return i ? (e.fresh &&
|
|
340
|
+
return i ? (e.fresh && te(`${t}-privateTypeIndex`), ie(`${t}-privateTypeIndex`, () => v.withEngine(r).find(i))) : null;
|
|
339
341
|
}
|
|
340
342
|
async findOrCreatePublicTypeIndex() {
|
|
341
343
|
return await this.findPublicTypeIndex() ?? await this.createPublicTypeIndex();
|
|
342
344
|
}
|
|
343
345
|
async findPublicTypeIndex(e = {}) {
|
|
344
346
|
const { webId: t, publicTypeIndexUrl: i } = this.requireUser(), r = this.requireAuthenticator().engine;
|
|
345
|
-
return i ? (e.fresh &&
|
|
347
|
+
return i ? (e.fresh && te(`${t}-publicTypeIndex`), ie(`${t}-publicTypeIndex`, () => v.withEngine(r).find(i))) : null;
|
|
346
348
|
}
|
|
347
349
|
async createPrivateContainer(e) {
|
|
348
350
|
const t = this.requireAuthenticator().engine;
|
|
349
351
|
return q.withEngine(t, async () => {
|
|
350
352
|
const i = await q.find(e.url);
|
|
351
353
|
if (i && !e.reuseExisting)
|
|
352
|
-
throw new
|
|
354
|
+
throw new Ge(i);
|
|
353
355
|
const r = i ?? new q({ url: e.url, name: e.name });
|
|
354
356
|
if (await r.save(), e.registerFor) {
|
|
355
357
|
const s = await this.findOrCreatePrivateTypeIndex();
|
|
@@ -360,39 +362,39 @@ class Ze extends Xe {
|
|
|
360
362
|
}
|
|
361
363
|
async boot() {
|
|
362
364
|
var e, t;
|
|
363
|
-
await
|
|
364
|
-
preferredAuthenticator:
|
|
365
|
+
await J.booted, A("authenticator") && this.setState({
|
|
366
|
+
preferredAuthenticator: M("authenticator")
|
|
365
367
|
}), A("refreshProfile") && this.setState({
|
|
366
|
-
staleProfiles:
|
|
367
|
-
this.staleProfiles.concat(
|
|
368
|
+
staleProfiles: Z(
|
|
369
|
+
this.staleProfiles.concat(qe([(e = this.session) == null ? void 0 : e.user.webId, (t = this.previousSession) == null ? void 0 : t.loginUrl]))
|
|
368
370
|
)
|
|
369
|
-
}), await this.restorePreviousSession(), await this.startupReconnect();
|
|
371
|
+
}), await this.restorePreviousSession(), await this.startupReconnect(), await this.trackSolidModels();
|
|
370
372
|
}
|
|
371
373
|
async createPrivateTypeIndex() {
|
|
372
|
-
const e = this.requireUser(), t = this.requireAuthenticator(), i = await
|
|
374
|
+
const e = this.requireUser(), t = this.requireAuthenticator(), i = await v.withEngine(t.engine).createPrivate(e);
|
|
373
375
|
return D(i, () => {
|
|
374
|
-
e.privateTypeIndexUrl = i.url,
|
|
376
|
+
e.privateTypeIndexUrl = i.url, ne(`${e.webId}-privateTypeIndex`, i), this.rememberProfile(e);
|
|
375
377
|
});
|
|
376
378
|
}
|
|
377
379
|
async createPublicTypeIndex() {
|
|
378
|
-
const e = this.requireUser(), t = this.requireAuthenticator(), i = await
|
|
380
|
+
const e = this.requireUser(), t = this.requireAuthenticator(), i = await v.withEngine(t.engine).createPublic(e);
|
|
379
381
|
return D(i, () => {
|
|
380
|
-
e.privateTypeIndexUrl = i.url,
|
|
382
|
+
e.privateTypeIndexUrl = i.url, ne(`${e.webId}-publicTypeIndex`, i), this.rememberProfile(e);
|
|
381
383
|
});
|
|
382
384
|
}
|
|
383
385
|
async attemptLogin(e, t) {
|
|
384
|
-
const i = t.authenticator ?? this.preferredAuthenticator ?? "default", r = t.onError ?? ((o) => m.isMounted() ?
|
|
386
|
+
const i = t.authenticator ?? this.preferredAuthenticator ?? "default", r = t.onError ?? ((o) => m.isMounted() ? J.report(o) : this.setState({ loginStartupError: o })), s = setTimeout(() => this.loginStale = !0, 1e4), l = {
|
|
385
387
|
dismissed: this.dismissed,
|
|
386
388
|
ignorePreviousSessionError: this.ignorePreviousSessionError,
|
|
387
389
|
previousSession: this.previousSession
|
|
388
390
|
};
|
|
389
391
|
this.loginOngoing = !0;
|
|
390
392
|
try {
|
|
391
|
-
const o = await this.getUserProfile(e, { markStale: !0 }), $ = (o == null ? void 0 : o.oidcIssuerUrl) ??
|
|
393
|
+
const o = await this.getUserProfile(e, { markStale: !0 }), $ = (o == null ? void 0 : o.oidcIssuerUrl) ?? Oe((o == null ? void 0 : o.webId) ?? e), _ = await this.bootAuthenticator(i), { domain: R } = De(e);
|
|
392
394
|
return this.setState({
|
|
393
395
|
dismissed: !1,
|
|
394
396
|
ignorePreviousSessionError: !0,
|
|
395
|
-
previousSession:
|
|
397
|
+
previousSession: Me({
|
|
396
398
|
profile: o,
|
|
397
399
|
loginUrl: e,
|
|
398
400
|
authenticator: i,
|
|
@@ -402,9 +404,9 @@ class Ze extends Xe {
|
|
|
402
404
|
{ domain: R }
|
|
403
405
|
)
|
|
404
406
|
})
|
|
405
|
-
}), await
|
|
407
|
+
}), await g.emit("auth:before-login"), await _.login($, o), !0;
|
|
406
408
|
} catch (o) {
|
|
407
|
-
return this.setState(
|
|
409
|
+
return this.setState(l), o instanceof Qe ? !1 : t.fallbackUrl ? H().then(() => this.login(t.fallbackUrl ?? "", ee(t, "fallbackUrl"))) : (r(o), !1);
|
|
408
410
|
} finally {
|
|
409
411
|
clearTimeout(s), this.setState({
|
|
410
412
|
loginOngoing: !1,
|
|
@@ -419,13 +421,13 @@ class Ze extends Xe {
|
|
|
419
421
|
this.reconnectOnStartup() && await this.reconnect({ force: this.forcingReconnect() });
|
|
420
422
|
}
|
|
421
423
|
reconnectOnStartup() {
|
|
422
|
-
return A("autoReconnect") ?
|
|
424
|
+
return A("autoReconnect") ? re(M("autoReconnect")) : this.autoReconnect;
|
|
423
425
|
}
|
|
424
426
|
forcingReconnect() {
|
|
425
|
-
return A("autoReconnect") &&
|
|
427
|
+
return A("autoReconnect") && re(M("autoReconnect"));
|
|
426
428
|
}
|
|
427
429
|
async bootAuthenticator(e) {
|
|
428
|
-
const t =
|
|
430
|
+
const t = le(e);
|
|
429
431
|
return t.addListener({
|
|
430
432
|
onSessionStarted: async (i) => {
|
|
431
433
|
this.setState({
|
|
@@ -436,7 +438,7 @@ class Ze extends Xe {
|
|
|
436
438
|
profile: i.user,
|
|
437
439
|
error: null
|
|
438
440
|
}
|
|
439
|
-
}), this.staleProfiles.includes(i.user.webId) && await this.refreshUserProfile(), m.plugin("@aerogel/local-first") ||
|
|
441
|
+
}), this.staleProfiles.includes(i.user.webId) && await this.refreshUserProfile(), m.plugin("@aerogel/local-first") || Ne(i.authenticator.engine), Ee.setEngine(i.authenticator.engine), v.setEngine(i.authenticator.engine), xe.setEngine(i.authenticator.engine), await g.emit("auth:login", i);
|
|
440
442
|
},
|
|
441
443
|
onSessionFailed: async (i, r) => {
|
|
442
444
|
var s;
|
|
@@ -451,7 +453,7 @@ class Ze extends Xe {
|
|
|
451
453
|
});
|
|
452
454
|
},
|
|
453
455
|
onSessionEnded: () => this.setState({ session: null }),
|
|
454
|
-
onAuthenticatedFetchReady: (i) =>
|
|
456
|
+
onAuthenticatedFetchReady: (i) => g.emit("auth:fetch-ready", i)
|
|
455
457
|
}), await t.boot(), t;
|
|
456
458
|
}
|
|
457
459
|
rememberProfile(e) {
|
|
@@ -460,35 +462,62 @@ class Ze extends Xe {
|
|
|
460
462
|
...this.profiles,
|
|
461
463
|
[e.webId]: e
|
|
462
464
|
},
|
|
463
|
-
staleProfiles:
|
|
465
|
+
staleProfiles: ze(this.staleProfiles, e.webId)
|
|
464
466
|
});
|
|
465
467
|
}
|
|
468
|
+
async trackSolidModels() {
|
|
469
|
+
g.on("purge-storage", () => this.collections = {}), g.on("soukai:track-models", async (e) => {
|
|
470
|
+
var t;
|
|
471
|
+
Te(e) && (e.on("created", async (i) => {
|
|
472
|
+
var l;
|
|
473
|
+
const r = i.getContainerUrl();
|
|
474
|
+
if (!r || i.getDefaultCollection() === r || (l = this.collections[i.static().modelName]) != null && l.includes(r))
|
|
475
|
+
return;
|
|
476
|
+
const s = this.collections[i.static().modelName] ?? [];
|
|
477
|
+
s.push(r), this.collections = {
|
|
478
|
+
...this.collections,
|
|
479
|
+
[i.static().modelName]: s
|
|
480
|
+
}, await z(e, r, { refresh: !1 });
|
|
481
|
+
}), await Promise.all(
|
|
482
|
+
((t = this.collections[e.modelName]) == null ? void 0 : t.map(
|
|
483
|
+
(i) => z(e, i),
|
|
484
|
+
{ refresh: !1 }
|
|
485
|
+
)) ?? []
|
|
486
|
+
));
|
|
487
|
+
});
|
|
488
|
+
for (const [e, t] of Object.entries(this.collections)) {
|
|
489
|
+
const i = je().get(e);
|
|
490
|
+
if (!(!i || !Ve(i)))
|
|
491
|
+
for (const r of t)
|
|
492
|
+
await z(i, r);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
466
495
|
}
|
|
467
|
-
const
|
|
468
|
-
function
|
|
469
|
-
|
|
496
|
+
const f = ke(nt);
|
|
497
|
+
function rt() {
|
|
498
|
+
we("container_url", (n) => {
|
|
470
499
|
if (!n.endsWith("/"))
|
|
471
500
|
return "containerEndingSlashMissing";
|
|
472
501
|
});
|
|
473
502
|
}
|
|
474
|
-
const
|
|
503
|
+
const st = {
|
|
475
504
|
viewBox: "0 0 20 20",
|
|
476
505
|
width: "1.2em",
|
|
477
506
|
height: "1.2em"
|
|
478
507
|
};
|
|
479
|
-
function
|
|
480
|
-
return d(), p("svg",
|
|
481
|
-
|
|
508
|
+
function ot(n, e) {
|
|
509
|
+
return d(), p("svg", st, e[0] || (e[0] = [
|
|
510
|
+
S("path", {
|
|
482
511
|
fill: "currentColor",
|
|
483
512
|
d: "M15 2H5L4 8h12zM0 10s2 1 10 1s10-1 10-1l-4-2H4zm8 4h4v1H8z"
|
|
484
513
|
}, null, -1),
|
|
485
|
-
|
|
514
|
+
S("circle", {
|
|
486
515
|
cx: "6",
|
|
487
516
|
cy: "15",
|
|
488
517
|
r: "3",
|
|
489
518
|
fill: "currentColor"
|
|
490
519
|
}, null, -1),
|
|
491
|
-
|
|
520
|
+
S("circle", {
|
|
492
521
|
cx: "14",
|
|
493
522
|
cy: "15",
|
|
494
523
|
r: "3",
|
|
@@ -496,76 +525,76 @@ function it(n, e) {
|
|
|
496
525
|
}, null, -1)
|
|
497
526
|
]));
|
|
498
527
|
}
|
|
499
|
-
const
|
|
528
|
+
const at = oe({ name: "ooui-user-anonymous", render: ot }), lt = ["src"], ct = /* @__PURE__ */ W({
|
|
500
529
|
__name: "SolidImage",
|
|
501
530
|
props: {
|
|
502
531
|
src: {}
|
|
503
532
|
},
|
|
504
533
|
setup(n) {
|
|
505
|
-
const e =
|
|
506
|
-
const i = await
|
|
534
|
+
const e = pe(async () => {
|
|
535
|
+
const i = await k.get(n.src) ?? await t(n.src), r = await (i == null ? void 0 : i.blob());
|
|
507
536
|
return r && URL.createObjectURL(r);
|
|
508
537
|
});
|
|
509
538
|
async function t(i) {
|
|
510
539
|
try {
|
|
511
|
-
const r = await
|
|
512
|
-
return r.status !== 200 ? null : (await
|
|
540
|
+
const r = await f.fetch(i);
|
|
541
|
+
return r.status !== 200 ? null : (await k.store(i, r), k.get(i));
|
|
513
542
|
} catch {
|
|
514
543
|
return null;
|
|
515
544
|
}
|
|
516
545
|
}
|
|
517
|
-
return (i, r) => (d(), p("img", { src:
|
|
546
|
+
return (i, r) => (d(), p("img", { src: c(e) }, null, 8, lt));
|
|
518
547
|
}
|
|
519
|
-
}),
|
|
548
|
+
}), ut = { class: "relative flex items-center justify-center rounded-full bg-gray-200" }, dt = {
|
|
520
549
|
key: 1,
|
|
521
550
|
class: "text-sm font-semibold tracking-wider text-gray-500",
|
|
522
551
|
"aria-hidden": "true"
|
|
523
|
-
},
|
|
552
|
+
}, Ct = /* @__PURE__ */ W({
|
|
524
553
|
__name: "SolidAvatar",
|
|
525
554
|
setup(n) {
|
|
526
555
|
const e = I(() => {
|
|
527
556
|
var i;
|
|
528
|
-
return (((i =
|
|
557
|
+
return (((i = f.user) == null ? void 0 : i.name) ?? "").trim().split(" ").map((r) => {
|
|
529
558
|
var s;
|
|
530
559
|
return (s = r[0]) == null ? void 0 : s.toUpperCase();
|
|
531
560
|
}).join("").slice(0, 3);
|
|
532
561
|
});
|
|
533
562
|
return (t, i) => {
|
|
534
563
|
var r, s;
|
|
535
|
-
return d(), p("div",
|
|
536
|
-
(r = t.$solid.user) != null && r.avatarUrl ? (d(), w(
|
|
564
|
+
return d(), p("div", ut, [
|
|
565
|
+
(r = t.$solid.user) != null && r.avatarUrl ? (d(), w(ct, {
|
|
537
566
|
key: 0,
|
|
538
567
|
src: (s = t.$solid.user) == null ? void 0 : s.avatarUrl,
|
|
539
568
|
alt: "",
|
|
540
569
|
class: "absolute inset-0 size-full rounded-full"
|
|
541
|
-
}, null, 8, ["src"])) : e.value ? (d(), p("span",
|
|
570
|
+
}, null, 8, ["src"])) : e.value ? (d(), p("span", dt, L(e.value), 1)) : (d(), w(c(at), {
|
|
542
571
|
key: 2,
|
|
543
572
|
class: "size-6 text-gray-500"
|
|
544
573
|
}))
|
|
545
574
|
]);
|
|
546
575
|
};
|
|
547
576
|
}
|
|
548
|
-
}),
|
|
577
|
+
}), ht = {
|
|
549
578
|
viewBox: "0 0 24 24",
|
|
550
579
|
width: "1.2em",
|
|
551
580
|
height: "1.2em"
|
|
552
581
|
};
|
|
553
|
-
function
|
|
554
|
-
return d(), p("svg",
|
|
555
|
-
|
|
582
|
+
function gt(n, e) {
|
|
583
|
+
return d(), p("svg", ht, e[0] || (e[0] = [
|
|
584
|
+
S("path", {
|
|
556
585
|
fill: "currentColor",
|
|
557
586
|
d: "M9 2h9c1.1 0 2 .9 2 2v16c0 1.1-.9 2-2 2H9c-1.1 0-2-.9-2-2v-2h2v2h9V4H9v2H7V4c0-1.1.9-2 2-2"
|
|
558
587
|
}, null, -1),
|
|
559
|
-
|
|
588
|
+
S("path", {
|
|
560
589
|
fill: "currentColor",
|
|
561
590
|
d: "M10.09 15.59L11.5 17l5-5l-5-5l-1.41 1.41L12.67 11H3v2h9.67z"
|
|
562
591
|
}, null, -1)
|
|
563
592
|
]));
|
|
564
593
|
}
|
|
565
|
-
const
|
|
594
|
+
const ft = oe({ name: "ic-baseline-log-in", render: gt }), mt = {
|
|
566
595
|
key: 2,
|
|
567
596
|
class: "flex w-full justify-center gap-2"
|
|
568
|
-
},
|
|
597
|
+
}, Ut = /* @__PURE__ */ W({
|
|
569
598
|
__name: "SolidLogin",
|
|
570
599
|
props: {
|
|
571
600
|
class: { default: "" },
|
|
@@ -578,69 +607,69 @@ const ct = se({ name: "ic-baseline-log-in", render: ut }), dt = {
|
|
|
578
607
|
const e = {
|
|
579
608
|
inrupt: "Log in using Inrupt's authentication library",
|
|
580
609
|
legacy: "Log in using the legacy authentication library"
|
|
581
|
-
}, t =
|
|
610
|
+
}, t = ye({
|
|
582
611
|
url: ve(),
|
|
583
|
-
authenticator:
|
|
584
|
-
}), i = Object.keys(e), r =
|
|
612
|
+
authenticator: Se()
|
|
613
|
+
}), i = Object.keys(e), r = se(!1), s = se(!1), l = I(() => !o.value || s.value), o = I(
|
|
585
614
|
() => m.development && (!t.url || t.url === "dev" || t.url.trim().length === 0)
|
|
586
|
-
), $ = I(() =>
|
|
615
|
+
), $ = I(() => K("flex flex-col items-center gap-2 w-full md:w-auto", n.class)), _ = I(() => K("w-full whitespace-nowrap", { "md:w-auto": n.layout === "horizontal" && !t.authenticator }, n.buttonClass));
|
|
587
616
|
function R(a) {
|
|
588
617
|
return u(
|
|
589
618
|
`solid.logIn.switchAuthenticator${a.charAt(0).toUpperCase() + a.slice(1)}`,
|
|
590
619
|
e[a]
|
|
591
620
|
);
|
|
592
621
|
}
|
|
593
|
-
async function
|
|
622
|
+
async function ce() {
|
|
594
623
|
if (n.noLoading) {
|
|
595
|
-
await
|
|
624
|
+
await f.login(t.url, { authenticator: t.authenticator });
|
|
596
625
|
return;
|
|
597
626
|
}
|
|
598
|
-
await
|
|
627
|
+
await E.loading(u("solid.loginOngoing", "Logging in..."), f.login(t.url));
|
|
599
628
|
}
|
|
600
629
|
return (a, y) => {
|
|
601
|
-
const ue =
|
|
602
|
-
return d(), w(
|
|
603
|
-
form:
|
|
630
|
+
const ue = He("measure");
|
|
631
|
+
return d(), w(c(be), {
|
|
632
|
+
form: c(t),
|
|
604
633
|
class: C($.value),
|
|
605
|
-
onSubmit:
|
|
634
|
+
onSubmit: ce
|
|
606
635
|
}, {
|
|
607
636
|
default: b(() => [
|
|
608
|
-
|
|
609
|
-
class: C(["flex w-full flex-col items-center gap-2", { "md:flex-row": a.layout === "horizontal" && !
|
|
637
|
+
S("div", {
|
|
638
|
+
class: C(["flex w-full flex-col items-center gap-2", { "md:flex-row": a.layout === "horizontal" && !c(t).authenticator }])
|
|
610
639
|
}, [
|
|
611
|
-
|
|
640
|
+
l.value ? (d(), w(c(Ie), {
|
|
612
641
|
key: 0,
|
|
613
642
|
name: "url",
|
|
614
643
|
"aria-label": a.$td("solid.logIn.label", "Login url"),
|
|
615
644
|
placeholder: a.$td("solid.logIn.placeholder", "https://me.solidcommunity.net"),
|
|
616
645
|
class: "w-full md:min-w-96"
|
|
617
|
-
}, null, 8, ["aria-label", "placeholder"])) :
|
|
618
|
-
|
|
646
|
+
}, null, 8, ["aria-label", "placeholder"])) : B("", !0),
|
|
647
|
+
c(t).authenticator ? (d(), w(c(Le), {
|
|
619
648
|
key: 1,
|
|
620
649
|
name: "authenticator",
|
|
621
650
|
class: "w-full max-w-full md:min-w-96",
|
|
622
651
|
"label-class": "sr-only",
|
|
623
652
|
"options-class": "md:w-96 w-full max-w-[calc(100vw-4rem)]",
|
|
624
653
|
label: a.$td("solid.logIn.switchAuthenticatorLabel", "Authentication method"),
|
|
625
|
-
options:
|
|
654
|
+
options: c(i),
|
|
626
655
|
"render-option": R
|
|
627
|
-
}, null, 8, ["label", "options"])) :
|
|
628
|
-
o.value && !s.value ? (d(), p("div",
|
|
629
|
-
|
|
656
|
+
}, null, 8, ["label", "options"])) : B("", !0),
|
|
657
|
+
o.value && !s.value ? (d(), p("div", mt, [
|
|
658
|
+
N(c(F), {
|
|
630
659
|
variant: "secondary",
|
|
631
660
|
class: "group gap-0",
|
|
632
661
|
title: a.$td("solid.logIn.manualUrl", "Enter url"),
|
|
633
|
-
onClick: y[0] || (y[0] = (
|
|
662
|
+
onClick: y[0] || (y[0] = (G) => s.value = !0)
|
|
634
663
|
}, {
|
|
635
664
|
default: b(() => [
|
|
636
|
-
|
|
637
|
-
|
|
665
|
+
N(c(ft), { class: "size-4" }),
|
|
666
|
+
We((d(), p("span", {
|
|
638
667
|
class: C(["overflow-hidden pl-1 whitespace-nowrap", {
|
|
639
668
|
"opacity-0": !r.value,
|
|
640
669
|
"w-0 transition-[width] md:group-hover:w-(--width)": r.value
|
|
641
670
|
}])
|
|
642
671
|
}, [
|
|
643
|
-
|
|
672
|
+
U(L(a.$td("solid.logIn.manualUrl", "Enter url")), 1)
|
|
644
673
|
], 2)), [
|
|
645
674
|
[
|
|
646
675
|
ue,
|
|
@@ -652,73 +681,73 @@ const ct = se({ name: "ic-baseline-log-in", render: ut }), dt = {
|
|
|
652
681
|
]),
|
|
653
682
|
_: 1
|
|
654
683
|
}, 8, ["title"]),
|
|
655
|
-
|
|
684
|
+
N(c(F), {
|
|
656
685
|
disabled: a.noLoading && a.$solid.loginOngoing,
|
|
657
686
|
submit: "",
|
|
658
687
|
class: "whitespace-nowrap",
|
|
659
|
-
onClick: y[1] || (y[1] = (
|
|
688
|
+
onClick: y[1] || (y[1] = (G) => c(t).url = "dev")
|
|
660
689
|
}, {
|
|
661
690
|
default: b(() => [
|
|
662
|
-
|
|
691
|
+
U(L(a.$td("solid.logIn.dev", "Log in to dev server")), 1)
|
|
663
692
|
]),
|
|
664
693
|
_: 1
|
|
665
694
|
}, 8, ["disabled"])
|
|
666
|
-
])) : (d(), w(
|
|
695
|
+
])) : (d(), w(c(F), {
|
|
667
696
|
key: 3,
|
|
668
697
|
disabled: a.noLoading && a.$solid.loginOngoing,
|
|
669
698
|
submit: "",
|
|
670
699
|
class: C(_.value)
|
|
671
700
|
}, {
|
|
672
701
|
default: b(() => [
|
|
673
|
-
|
|
702
|
+
U(L(a.$td("solid.logIn.submit", "Log in")), 1)
|
|
674
703
|
]),
|
|
675
704
|
_: 1
|
|
676
705
|
}, 8, ["disabled", "class"]))
|
|
677
706
|
], 2),
|
|
678
|
-
a.allowLegacyAuthenticator &&
|
|
707
|
+
a.allowLegacyAuthenticator && l.value && !c(t).authenticator ? (d(), w(c(Ae), {
|
|
679
708
|
key: 0,
|
|
680
709
|
class: "text-sm font-normal text-gray-700",
|
|
681
|
-
onClick: y[2] || (y[2] = (
|
|
710
|
+
onClick: y[2] || (y[2] = (G) => c(t).authenticator = "inrupt")
|
|
682
711
|
}, {
|
|
683
712
|
default: b(() => [
|
|
684
|
-
|
|
713
|
+
U(L(a.$td("solid.logIn.switchAuthenticator", "Can't log in? Try using a different authentication method")), 1)
|
|
685
714
|
]),
|
|
686
715
|
_: 1
|
|
687
|
-
})) :
|
|
716
|
+
})) : B("", !0)
|
|
688
717
|
]),
|
|
689
718
|
_: 1
|
|
690
719
|
}, 8, ["form", "class"]);
|
|
691
720
|
};
|
|
692
721
|
}
|
|
693
|
-
}),
|
|
694
|
-
function
|
|
722
|
+
}), wt = { $solid: f };
|
|
723
|
+
function Et(n = {}) {
|
|
695
724
|
return {
|
|
696
725
|
async install(e) {
|
|
697
|
-
|
|
726
|
+
$e(), et({ ...Xe, ...n.authenticators ?? {} }), rt(), Ze(le(n.defaultAuthenticator ?? "inrupt")), Pe((t) => {
|
|
698
727
|
if (t instanceof T)
|
|
699
728
|
return t.description ? `${t.message} (${t.description})` : t.message;
|
|
700
|
-
}), typeof n.autoReconnect == "boolean" && (
|
|
729
|
+
}), typeof n.autoReconnect == "boolean" && (Y.autoReconnect = n.autoReconnect, f.hasPersistedState() || (f.autoReconnect = n.autoReconnect)), n.onUserProfileLoaded && g.on("solid:user-profile-loaded", ([t, i]) => {
|
|
701
730
|
var r;
|
|
702
731
|
(r = n.onUserProfileLoaded) == null || r.call(n, t, i);
|
|
703
|
-
}), await
|
|
732
|
+
}), await Ce(e, wt);
|
|
704
733
|
}
|
|
705
734
|
};
|
|
706
735
|
}
|
|
707
736
|
export {
|
|
708
|
-
|
|
737
|
+
Qe as AuthenticationCancelledError,
|
|
709
738
|
T as AuthenticationFailedError,
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
739
|
+
ae as Authenticator,
|
|
740
|
+
Ge as ContainerAlreadyInUse,
|
|
741
|
+
f as Solid,
|
|
742
|
+
Ct as SolidAvatar,
|
|
743
|
+
ct as SolidImage,
|
|
744
|
+
Ut as SolidLogin,
|
|
745
|
+
nt as SolidService,
|
|
746
|
+
Xe as authenticators,
|
|
747
|
+
Et as default,
|
|
748
|
+
le as getAuthenticator,
|
|
749
|
+
tt as registerAuthenticator,
|
|
750
|
+
et as registerAuthenticators,
|
|
751
|
+
Ze as setDefaultAuthenticator
|
|
723
752
|
};
|
|
724
753
|
//# sourceMappingURL=aerogel-plugin-solid.js.map
|