@aerogel/plugin-solid 0.0.1-next.0d1cf82f9dfbe1d3e7ec5644f85f97a43c8c2334

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.
Files changed (32) hide show
  1. package/dist/InruptAuthenticator.lazy-BvpQLGoj.js +9 -0
  2. package/dist/InruptAuthenticator.lazy-BvpQLGoj.js.map +1 -0
  3. package/dist/LegacyAuthenticator.lazy-ChFFqP14.js +5 -0
  4. package/dist/LegacyAuthenticator.lazy-ChFFqP14.js.map +1 -0
  5. package/dist/aerogel-plugin-solid.d.ts +309 -0
  6. package/dist/aerogel-plugin-solid.js +683 -0
  7. package/dist/aerogel-plugin-solid.js.map +1 -0
  8. package/package.json +49 -0
  9. package/src/auth/Authenticator.ts +123 -0
  10. package/src/auth/authenticators/InruptAuthenticator.lazy.ts +1 -0
  11. package/src/auth/authenticators/InruptAuthenticator.ts +103 -0
  12. package/src/auth/authenticators/LegacyAuthenticator.lazy.ts +1 -0
  13. package/src/auth/authenticators/LegacyAuthenticator.ts +80 -0
  14. package/src/auth/index.ts +40 -0
  15. package/src/components/AGSolidImage.vue +33 -0
  16. package/src/components/AGSolidStatus.ts +5 -0
  17. package/src/components/AGSolidStatus.vue +68 -0
  18. package/src/components/AGSolidUserAvatar.vue +35 -0
  19. package/src/components/index.ts +4 -0
  20. package/src/errors/AuthenticationCancelledError.ts +3 -0
  21. package/src/errors/AuthenticationFailedError.ts +22 -0
  22. package/src/errors/ContainerAlreadyInUse.ts +11 -0
  23. package/src/errors/index.ts +3 -0
  24. package/src/forms/validation.ts +11 -0
  25. package/src/index.test.ts +24 -0
  26. package/src/index.ts +65 -0
  27. package/src/services/Solid.state.ts +56 -0
  28. package/src/services/Solid.ts +549 -0
  29. package/src/testing/setup.ts +11 -0
  30. package/src/types/env.d.ts +1 -0
  31. package/src/types/shims.d.ts +7 -0
  32. package/src/types/solid-auth-client.d.ts +21 -0
@@ -0,0 +1,683 @@
1
+ var ne = Object.defineProperty;
2
+ var re = (n, e, i) => e in n ? ne(n, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[e] = i;
3
+ var u = (n, e, i) => re(n, typeof e != "symbol" ? e + "" : e, i);
4
+ import { persistent as se, defineServiceState as oe, Events as g, UI as T, translateWithDefault as c, App as m, Colors as ae, Storage as le, Errors as B, defineFormValidationRule as ue, requiredStringProp as ce, computedAsync as de, Cache as R, useForm as he, requiredStringInput as ge, AGMarkdown as A, AGButton as P, AGForm as fe, AGInput as me, AGLink as pe, registerErrorHandler as we, bootServices as Se } from "@aerogel/core";
5
+ import { SolidEngine as ye, SolidTypeIndex as y, SolidContainer as k, SolidACLAuthorization as ve, SolidDocument as be, bootSolidModels as Ie } from "soukai-solid";
6
+ import { JSError as O, arr as Ae, fail as C, PromisedValue as Pe, Storage as x, after as G, required as V, facade as Le, tap as F, arrayUnique as j, objectWithout as z, isDevelopment as J, asyncMemo as H, hasLocationQueryParameter as L, getLocationQueryParameter as q, arrayFilter as $e, setAsyncMemo as Y, urlRoot as Ee, requireUrlParse as Ce, objectWithoutEmpty as Ue, parseBoolean as Q, arrayWithout as Te } from "@noeldemartin/utils";
7
+ import { fetchLoginUserProfile as Re } from "@noeldemartin/solid-utils";
8
+ import { setEngine as ke } from "soukai";
9
+ import { defineComponent as M, createElementBlock as S, openBlock as d, unref as a, computed as K, renderSlot as $, createCommentVNode as _, createVNode as h, createElementVNode as b, withCtx as p, createTextVNode as v, toDisplayString as w, createBlock as I } from "vue";
10
+ class xe extends O {
11
+ }
12
+ function Fe(n, e) {
13
+ return n;
14
+ }
15
+ class U extends O {
16
+ constructor(i, t, r) {
17
+ super(Fe(i), r);
18
+ u(this, "description");
19
+ this.description = t;
20
+ }
21
+ }
22
+ class qe extends O {
23
+ constructor(e, i) {
24
+ super(`Container at ${e.url} is already in use`, i);
25
+ }
26
+ }
27
+ const E = {};
28
+ class X {
29
+ constructor() {
30
+ u(this, "name");
31
+ u(this, "authenticatedFetch");
32
+ u(this, "booted");
33
+ u(this, "listeners", Ae([]));
34
+ u(this, "_engine");
35
+ }
36
+ get engine() {
37
+ return this._engine = this._engine ?? new ye(this.requireAuthenticatedFetch()), this._engine;
38
+ }
39
+ getAuthenticatedFetch() {
40
+ return this.authenticatedFetch ?? null;
41
+ }
42
+ requireAuthenticatedFetch() {
43
+ return this.authenticatedFetch ?? C("Authenticated fetch is not ready");
44
+ }
45
+ addListener(e) {
46
+ return this.listeners.includes(e) || this.listeners.push(e), () => {
47
+ this.removeListener(e);
48
+ };
49
+ }
50
+ removeListener(e) {
51
+ this.listeners.includes(e) && this.listeners.remove(e);
52
+ }
53
+ async boot() {
54
+ if (this.booted)
55
+ return this.booted;
56
+ this.booted = new Pe(), await this.restoreSession(), this.booted.resolve();
57
+ }
58
+ async initAuthenticatedFetch(e) {
59
+ this.authenticatedFetch = e, await this.notifyListeners("onAuthenticatedFetchReady", e);
60
+ }
61
+ async startSession(e) {
62
+ const i = {
63
+ authenticator: this,
64
+ ...e
65
+ };
66
+ return await this.notifyListeners("onSessionStarted", i), i;
67
+ }
68
+ async failSession(e, i) {
69
+ await this.notifyListeners("onSessionFailed", e, i);
70
+ }
71
+ async endSession() {
72
+ await this.notifyListeners("onSessionEnded");
73
+ }
74
+ async notifyListeners(e, ...i) {
75
+ await Promise.all(
76
+ this.listeners.toArray().map(async (t) => {
77
+ const r = t[e];
78
+ await (r == null ? void 0 : r(...i));
79
+ })
80
+ );
81
+ }
82
+ }
83
+ const D = "inrupt-authenticator";
84
+ class _e extends X {
85
+ constructor() {
86
+ super(...arguments);
87
+ u(this, "_events");
88
+ u(this, "_fetch");
89
+ u(this, "_login");
90
+ u(this, "_logout");
91
+ u(this, "_handleIncomingRedirect");
92
+ }
93
+ async login(i) {
94
+ x.set(D, i);
95
+ const t = {
96
+ oidcIssuer: i
97
+ };
98
+ return E.clientID && (t.clientId = E.clientID.client_id, t.clientName = E.clientID.client_name, t.redirectUrl = E.clientID.redirect_uris[0]), await this._login(t), await G({ seconds: 60 }), C("Browser should have redirected, but it didn't");
99
+ }
100
+ async logout() {
101
+ await this._logout(), await this.endSession();
102
+ }
103
+ async restoreSession() {
104
+ const { events: i, fetch: t, handleIncomingRedirect: r, login: s, logout: l } = await import("./InruptAuthenticator.lazy-BvpQLGoj.js");
105
+ this._fetch = t, this._login = s, this._logout = l, this._events = i, this._handleIncomingRedirect = r, await this.loginFromRedirect();
106
+ }
107
+ async loginFromRedirect() {
108
+ const i = x.get(D);
109
+ if (!i)
110
+ return;
111
+ this._events().on("error", (r, s) => {
112
+ r ?? (r = "Error using Inrupt Authenticator method"), typeof s == "object" ? this.failSession(i, new U(r, null, { cause: s })) : this.failSession(i, new U(r, s));
113
+ });
114
+ const t = await this._handleIncomingRedirect(globalThis.location.href);
115
+ x.remove(D), t != null && t.isLoggedIn && t.webId && await this.initSession(t.webId);
116
+ }
117
+ async initSession(i) {
118
+ await this.initAuthenticatedFetch(this._fetch);
119
+ try {
120
+ const t = await f.requireUserProfile(i);
121
+ await this.startSession({ user: t, loginUrl: i });
122
+ } catch (t) {
123
+ await this.failSession(i, t);
124
+ }
125
+ }
126
+ }
127
+ class De extends X {
128
+ constructor() {
129
+ super();
130
+ u(this, "store");
131
+ this.store = se("legacy-authenticator", {});
132
+ }
133
+ async login(i, t) {
134
+ const { SolidAuthClient: r } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js");
135
+ throw this.store.webId = t == null ? void 0 : t.webId, this.store.loginUrl = (t == null ? void 0 : t.oidcIssuerUrl) ?? i, await r.login(this.store.loginUrl) === null ? (delete this.store.webId, delete this.store.loginUrl, new U("Could not log in with Solid using the legacy authenticator")) : (await G({ seconds: 60 }), new Error("Browser should have redirected, but it didn't"));
136
+ }
137
+ async logout() {
138
+ const { SolidAuthClient: i } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js");
139
+ delete this.store.webId, delete this.store.loginUrl, await i.logout(), await this.endSession();
140
+ }
141
+ async restoreSession() {
142
+ if (!this.store.loginUrl)
143
+ return;
144
+ const { SolidAuthClient: i } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js"), t = await i.currentSession(), r = V(this.store.loginUrl);
145
+ await this.initAuthenticatedFetch((s, l) => i.fetch(s, l));
146
+ try {
147
+ const s = await f.requireUserProfile(V((t == null ? void 0 : t.webId) ?? this.store.webId));
148
+ await this.startSession({ user: s, loginUrl: r });
149
+ } catch (s) {
150
+ await this.failSession(r, s);
151
+ }
152
+ }
153
+ }
154
+ const W = {}, Oe = {
155
+ inrupt: new _e(),
156
+ legacy: new De()
157
+ };
158
+ function Ge(n) {
159
+ W.default = n;
160
+ }
161
+ function Z(n) {
162
+ return W[n];
163
+ }
164
+ function Me(n) {
165
+ Object.entries(n).forEach(([e, i]) => We(e, i));
166
+ }
167
+ function We(n, e) {
168
+ W[n] = e, e.name = e.name ?? n;
169
+ }
170
+ const N = { autoReconnect: !0 }, Ne = oe({
171
+ name: "solid",
172
+ persist: ["autoReconnect", "dismissed", "previousSession", "profiles", "staleProfiles"],
173
+ initialState: {
174
+ autoReconnect: N.autoReconnect,
175
+ dismissed: !1,
176
+ ignorePreviousSessionError: !1,
177
+ loginStartupError: null,
178
+ loginOngoing: !1,
179
+ preferredAuthenticator: null,
180
+ previousSession: null,
181
+ profiles: {},
182
+ session: null,
183
+ loginStale: !1,
184
+ staleProfiles: []
185
+ },
186
+ serialize(n) {
187
+ var e;
188
+ return ((e = n.previousSession) == null ? void 0 : e.error) instanceof Error && (n.previousSession.error = n.previousSession.error.message), n;
189
+ },
190
+ computed: {
191
+ user: (n) => {
192
+ var e, i;
193
+ return ((e = n.session) == null ? void 0 : e.user) ?? ((i = n.previousSession) == null ? void 0 : i.profile) ?? null;
194
+ },
195
+ authenticator: (n) => {
196
+ var e;
197
+ return ((e = n.session) == null ? void 0 : e.authenticator) ?? null;
198
+ },
199
+ fetch() {
200
+ var n;
201
+ return ((n = this.authenticator) == null ? void 0 : n.getAuthenticatedFetch()) ?? globalThis.fetch.bind(globalThis);
202
+ },
203
+ error(n) {
204
+ var e;
205
+ return n.loginStartupError ? n.loginStartupError ?? null : n.ignorePreviousSessionError ? null : ((e = n.previousSession) == null ? void 0 : e.error) ?? null;
206
+ }
207
+ }
208
+ });
209
+ class Be extends Ne {
210
+ isLoggedIn() {
211
+ return !!this.session;
212
+ }
213
+ wasLoggedIn() {
214
+ return !!this.previousSession;
215
+ }
216
+ hasLoggedIn() {
217
+ return !!(this.session || this.previousSession);
218
+ }
219
+ requireAuthenticator() {
220
+ return this.authenticator ?? C("Could not get authenticator");
221
+ }
222
+ requireUser() {
223
+ return this.user ?? C("Could not get user profile (are you logged in?)");
224
+ }
225
+ requireUserProfile(e) {
226
+ return this.getUserProfile(e, { required: !0 });
227
+ }
228
+ /* eslint-enable max-len */
229
+ async getUserProfile(e, i = {}) {
230
+ var l;
231
+ let t = null;
232
+ const r = i.markStale ?? !((l = this.authenticator) != null && l.getAuthenticatedFetch()), s = this.profiles[e] ?? await F(
233
+ await Re(e, {
234
+ fetch: this.fetch,
235
+ required: i.required ?? !1,
236
+ onLoaded(o) {
237
+ t = o;
238
+ }
239
+ }),
240
+ async (o) => {
241
+ o && (t && await g.emit("solid:user-profile-loaded", [o, t]), this.rememberProfile(o));
242
+ }
243
+ );
244
+ return s && r && this.setState({ staleProfiles: j(this.staleProfiles.concat([s.webId])) }), s;
245
+ }
246
+ async refreshUserProfile() {
247
+ if (!this.isLoggedIn())
248
+ return;
249
+ this.setState({ profiles: z(this.profiles, [this.user.webId]) });
250
+ const e = await this.requireUserProfile(this.user.webId);
251
+ this.setState({
252
+ session: {
253
+ ...this.session,
254
+ user: e
255
+ }
256
+ });
257
+ }
258
+ async login(e, i = {}) {
259
+ if (J() && e === "dev" && (e = "http://localhost:3000"), /^https?:\/\//.test(e) || (i.fallbackUrl ?? (i.fallbackUrl = `http://${e}`), e = `https://${e}`), this.isLoggedIn())
260
+ return !0;
261
+ if (this.loginOngoing)
262
+ throw new Error("Authentication already in progress");
263
+ return i.loading ? T.loading(c("solid.loggingIn", "Logging in..."), () => this.attemptLogin(e, i)) : this.attemptLogin(e, i);
264
+ }
265
+ async reconnect(e = {}) {
266
+ const { force: i, ...t } = e;
267
+ this.isLoggedIn() || !this.previousSession || this.previousSession.error !== null && !i || await this.login(this.previousSession.loginUrl, {
268
+ authenticator: this.previousSession.authenticator,
269
+ ...t,
270
+ loading: t.loading ?? !1
271
+ });
272
+ }
273
+ async logout(e = !1) {
274
+ var l, o;
275
+ const i = !m.plugin("@aerogel/local-first") || !!((l = m.service("$cloud")) != null && l.ready), t = !m.plugin("@aerogel/local-first") || !!((o = m.service("$cloud")) != null && o.dirty), [r, s] = e ? [!0, { wipeLocalData: i }] : await T.confirm(
276
+ i ? c("solid.logoutConfirmTitle", "Log out from this device?") : c("solid.disconnectConfirmTitle", "Disconnect account?"),
277
+ i ? t ? c(
278
+ "solid.logoutConfirmMessageWithLocalChanges",
279
+ "There are some changes that haven't been synchronized and will be lost, but the rest of the data will remain in your Solid POD."
280
+ ) : c(
281
+ "solid.logoutConfirmMessage",
282
+ "Logging out will remove all the data from this device, but you'll still have it in your Solid POD."
283
+ ) : c(
284
+ "solid.disconnectConfirmMessage",
285
+ "You'll need to introduce your credentials again to connect to your Solid POD."
286
+ ),
287
+ {
288
+ acceptText: c("solid.logoutConfirmAccept", "Log out"),
289
+ acceptColor: ae.Danger,
290
+ cancelText: c(
291
+ "solid.logoutConfirmCancel",
292
+ c("ui.cancel", "Cancel")
293
+ ),
294
+ checkboxes: i ? t ? {
295
+ wipeLocalData: {
296
+ label: c(
297
+ "solid.logoutConfirmWipeNotice",
298
+ "I understand that changes that haven't been synchronized will be lost."
299
+ ),
300
+ default: !1,
301
+ required: !0
302
+ }
303
+ } : void 0 : {
304
+ wipeLocalData: {
305
+ label: c(
306
+ "solid.logoutConfirmWipe",
307
+ "Also remove all existing data (tasks, lists, etc.)"
308
+ ),
309
+ default: !1
310
+ }
311
+ }
312
+ }
313
+ );
314
+ r && this.previousSession && await T.loading(c("solid.logoutOngoing", "Logging out..."), async () => {
315
+ this.setState({
316
+ dismissed: !1,
317
+ ignorePreviousSessionError: !1,
318
+ loginStartupError: null,
319
+ previousSession: null,
320
+ ...N
321
+ }), this.isLoggedIn() && await this.authenticator.logout(), (s.wipeLocalData ?? !0) && await le.purge(), await g.emit("auth:logout"), await g.emit("auth:after-logout");
322
+ });
323
+ }
324
+ async whenLoggedIn(e) {
325
+ return this.isLoggedIn() ? e(this.session) : new Promise((i) => {
326
+ const t = (r) => i(e(r));
327
+ g.once("auth:login", t);
328
+ });
329
+ }
330
+ dismiss() {
331
+ this.setState({ dismissed: !0 });
332
+ }
333
+ async findOrCreatePrivateTypeIndex() {
334
+ return await this.findPrivateTypeIndex() ?? await this.createPrivateTypeIndex();
335
+ }
336
+ async findPrivateTypeIndex() {
337
+ const { webId: e, privateTypeIndexUrl: i } = this.requireUser(), t = this.requireAuthenticator().engine;
338
+ return i ? H(`${e}-privateTypeIndex`, () => y.withEngine(t).find(i)) : null;
339
+ }
340
+ async findOrCreatePublicTypeIndex() {
341
+ return await this.findPublicTypeIndex() ?? await this.createPublicTypeIndex();
342
+ }
343
+ async findPublicTypeIndex() {
344
+ const { webId: e, publicTypeIndexUrl: i } = this.requireUser(), t = this.requireAuthenticator().engine;
345
+ return i ? H(`${e}-publicTypeIndex`, () => y.withEngine(t).find(i)) : null;
346
+ }
347
+ async createPrivateContainer(e) {
348
+ const i = this.requireAuthenticator().engine;
349
+ return k.withEngine(i, async () => {
350
+ const t = await k.find(e.url);
351
+ if (t && !e.reuseExisting)
352
+ throw new qe(t);
353
+ const r = t ?? new k({ url: e.url, name: e.name });
354
+ if (await r.save(), e.registerFor) {
355
+ const s = await this.findOrCreatePrivateTypeIndex();
356
+ await r.register(s, e.registerFor);
357
+ }
358
+ return r;
359
+ });
360
+ }
361
+ async boot() {
362
+ var e, i;
363
+ await B.booted, L("authenticator") && this.setState({
364
+ preferredAuthenticator: q("authenticator")
365
+ }), L("refreshProfile") && this.setState({
366
+ staleProfiles: j(
367
+ this.staleProfiles.concat($e([(e = this.session) == null ? void 0 : e.user.webId, (i = this.previousSession) == null ? void 0 : i.loginUrl]))
368
+ )
369
+ }), await this.restorePreviousSession(), await this.startupReconnect();
370
+ }
371
+ async createPrivateTypeIndex() {
372
+ const e = this.requireUser(), i = this.requireAuthenticator(), t = await y.withEngine(i.engine).createPrivate(e);
373
+ return F(t, () => {
374
+ e.privateTypeIndexUrl = t.url, Y(`${e.webId}-privateTypeIndex`, t), this.rememberProfile(e);
375
+ });
376
+ }
377
+ async createPublicTypeIndex() {
378
+ const e = this.requireUser(), i = this.requireAuthenticator(), t = await y.withEngine(i.engine).createPublic(e);
379
+ return F(t, () => {
380
+ e.privateTypeIndexUrl = t.url, Y(`${e.webId}-publicTypeIndex`, t), this.rememberProfile(e);
381
+ });
382
+ }
383
+ async attemptLogin(e, i) {
384
+ const t = i.authenticator ?? this.preferredAuthenticator ?? "default", r = i.onError ?? ((o) => m.isMounted() ? B.report(o) : this.setState({ loginStartupError: o })), s = setTimeout(() => this.loginStale = !0, 1e4), l = {
385
+ dismissed: this.dismissed,
386
+ ignorePreviousSessionError: this.ignorePreviousSessionError,
387
+ previousSession: this.previousSession
388
+ };
389
+ this.loginOngoing = !0;
390
+ try {
391
+ const o = await this.getUserProfile(e, { markStale: !0 }), ee = (o == null ? void 0 : o.oidcIssuerUrl) ?? Ee((o == null ? void 0 : o.webId) ?? e), te = await this.bootAuthenticator(t), { domain: ie } = Ce(e);
392
+ return this.setState({
393
+ dismissed: !1,
394
+ ignorePreviousSessionError: !0,
395
+ previousSession: Ue({
396
+ profile: o,
397
+ loginUrl: e,
398
+ authenticator: t,
399
+ error: c(
400
+ "auth.stuckConnecting",
401
+ `We didn't hear back from the identity provider at \`${ie}\`, maybe try reconnecting?`
402
+ )
403
+ })
404
+ }), await g.emit("auth:before-login"), await te.login(ee, o), !0;
405
+ } catch (o) {
406
+ return this.setState(l), o instanceof xe ? !1 : i.fallbackUrl ? G().then(() => this.login(i.fallbackUrl ?? "", z(i, "fallbackUrl"))) : (r(o), !1);
407
+ } finally {
408
+ clearTimeout(s), this.setState({
409
+ loginOngoing: !1,
410
+ loginStale: !1
411
+ });
412
+ }
413
+ }
414
+ async restorePreviousSession() {
415
+ this.previousSession && await this.bootAuthenticator(this.previousSession.authenticator);
416
+ }
417
+ async startupReconnect() {
418
+ this.reconnectOnStartup() && await this.reconnect({ force: this.forcingReconnect() });
419
+ }
420
+ reconnectOnStartup() {
421
+ return L("autoReconnect") ? Q(q("autoReconnect")) : this.autoReconnect;
422
+ }
423
+ forcingReconnect() {
424
+ return L("autoReconnect") && Q(q("autoReconnect"));
425
+ }
426
+ async bootAuthenticator(e) {
427
+ const i = Z(e);
428
+ return i.addListener({
429
+ onSessionStarted: async (t) => {
430
+ this.setState({
431
+ session: t,
432
+ previousSession: {
433
+ authenticator: i.name,
434
+ loginUrl: t.loginUrl,
435
+ profile: t.user,
436
+ error: null
437
+ }
438
+ }), this.staleProfiles.includes(t.user.webId) && await this.refreshUserProfile(), m.plugin("@aerogel/local-first") || ke(t.authenticator.engine), ve.setEngine(t.authenticator.engine), y.setEngine(t.authenticator.engine), be.setEngine(t.authenticator.engine), await g.emit("auth:login", t);
439
+ },
440
+ onSessionFailed: async (t, r) => {
441
+ var s;
442
+ this.setState({
443
+ session: null,
444
+ previousSession: {
445
+ profile: (s = this.previousSession) == null ? void 0 : s.profile,
446
+ authenticator: i.name,
447
+ loginUrl: t,
448
+ error: r
449
+ }
450
+ });
451
+ },
452
+ onSessionEnded: () => this.setState({ session: null }),
453
+ onAuthenticatedFetchReady: (t) => g.emit("auth:fetch-ready", t)
454
+ }), await i.boot(), i;
455
+ }
456
+ rememberProfile(e) {
457
+ this.setState({
458
+ profiles: {
459
+ ...this.profiles,
460
+ [e.webId]: e
461
+ },
462
+ staleProfiles: Te(this.staleProfiles, e.webId)
463
+ });
464
+ }
465
+ }
466
+ const f = Le(Be);
467
+ function Ve() {
468
+ ue("container_url", (n) => {
469
+ if (!n.endsWith("/"))
470
+ return "containerEndingSlashMissing";
471
+ });
472
+ }
473
+ const je = ["src"], ze = /* @__PURE__ */ M({
474
+ __name: "AGSolidImage",
475
+ props: { src: ce() },
476
+ setup(n) {
477
+ const e = n, i = de(async () => {
478
+ const r = await R.get(e.src) ?? await t(e.src), s = await (r == null ? void 0 : r.blob());
479
+ return s && URL.createObjectURL(s);
480
+ });
481
+ async function t(r) {
482
+ try {
483
+ const s = await f.fetch(r);
484
+ return s.status !== 200 ? null : (await R.store(r, s), R.get(r));
485
+ } catch {
486
+ return null;
487
+ }
488
+ }
489
+ return (r, s) => (d(), S("img", { src: a(i) }, null, 8, je));
490
+ }
491
+ }), He = { class: "flex flex-col gap-3" }, Ye = { class: "flex flex-col" }, Qe = {
492
+ key: 1,
493
+ class: "mt-1 self-center text-sm text-red-800"
494
+ }, ut = /* @__PURE__ */ M({
495
+ __name: "AGSolidStatus",
496
+ setup(n) {
497
+ const e = he({ url: ge() }), i = K(
498
+ () => J() && (!e.url || e.url === "dev" || e.url.trim().length === 0)
499
+ );
500
+ return (t, r) => (d(), S("div", null, [
501
+ t.$solid.loginStale ? $(t.$slots, "login-stale", { key: 0 }, () => [
502
+ h(a(A), {
503
+ text: t.$td("solid.loginStale", "This is taking too long...")
504
+ }, null, 8, ["text"])
505
+ ]) : _("", !0),
506
+ t.$solid.loginOngoing ? $(t.$slots, "login-ongoing", { key: 1 }, () => [
507
+ h(a(A), {
508
+ text: t.$td("ui.loading", "Loading...")
509
+ }, null, 8, ["text"])
510
+ ]) : t.$solid.isLoggedIn() ? $(t.$slots, "logged-in", {
511
+ key: 2,
512
+ session: t.$solid.session
513
+ }, () => [
514
+ b("div", He, [
515
+ h(a(A), {
516
+ text: t.$td("solid.loggedIn", "You are logged in as [{userName}]({userWebId})", {
517
+ userName: t.$solid.user.name ?? t.$solid.user.webId,
518
+ userWebId: t.$solid.user.webId
519
+ })
520
+ }, null, 8, ["text"]),
521
+ h(a(P), {
522
+ onClick: r[0] || (r[0] = (s) => t.$solid.logout())
523
+ }, {
524
+ default: p(() => [
525
+ v(w(t.$td("solid.logout", "Logout")), 1)
526
+ ]),
527
+ _: 1
528
+ })
529
+ ])
530
+ ]) : $(t.$slots, "logged-out", { key: 3 }, () => {
531
+ var s;
532
+ return [
533
+ b("div", Ye, [
534
+ h(a(fe), {
535
+ form: a(e),
536
+ class: "flex",
537
+ onSubmit: r[2] || (r[2] = (l) => t.$solid.login(a(e).url))
538
+ }, {
539
+ default: p(() => [
540
+ h(a(me), {
541
+ name: "url",
542
+ "aria-label": t.$td("solid.url", "Login url"),
543
+ placeholder: t.$td("solid.placeholder", "https://...")
544
+ }, null, 8, ["aria-label", "placeholder"]),
545
+ i.value ? (d(), I(a(P), {
546
+ key: 0,
547
+ submit: "",
548
+ onClick: r[1] || (r[1] = (l) => a(e).url = "dev")
549
+ }, {
550
+ default: p(() => [
551
+ v(w(t.$td("solid.devLogin", "Dev login")), 1)
552
+ ]),
553
+ _: 1
554
+ })) : (d(), I(a(P), {
555
+ key: 1,
556
+ submit: ""
557
+ }, {
558
+ default: p(() => [
559
+ v(w(t.$td("solid.login", "Login")), 1)
560
+ ]),
561
+ _: 1
562
+ }))
563
+ ]),
564
+ _: 1
565
+ }, 8, ["form"]),
566
+ t.$solid.wasLoggedIn() ? (d(), I(a(P), {
567
+ key: 0,
568
+ class: "mt-3",
569
+ onClick: r[3] || (r[3] = (l) => t.$solid.reconnect({ force: !0 }))
570
+ }, {
571
+ default: p(() => [
572
+ v(w(t.$td("solid.reconnect", "Reconnect")), 1)
573
+ ]),
574
+ _: 1
575
+ })) : _("", !0),
576
+ (s = t.$solid.previousSession) != null && s.error || t.$solid.loginStartupError ? (d(), S("p", Qe, [
577
+ h(a(A), {
578
+ text: t.$td("solid.previousLoginError", "Previous login attempt failed"),
579
+ inline: ""
580
+ }, null, 8, ["text"]),
581
+ h(a(pe), {
582
+ onClick: r[4] || (r[4] = (l) => {
583
+ var o;
584
+ return t.$errors.inspect(((o = t.$solid.previousSession) == null ? void 0 : o.error) || t.$solid.loginStartupError);
585
+ })
586
+ }, {
587
+ default: p(() => [
588
+ v(" (" + w(t.$td("errors.viewDetails", "View details")) + ") ", 1)
589
+ ]),
590
+ _: 1
591
+ })
592
+ ])) : _("", !0)
593
+ ])
594
+ ];
595
+ })
596
+ ]));
597
+ }
598
+ }), Je = {
599
+ viewBox: "0 0 20 20",
600
+ width: "1.2em",
601
+ height: "1.2em"
602
+ };
603
+ function Ke(n, e) {
604
+ return d(), S("svg", Je, e[0] || (e[0] = [
605
+ b("path", {
606
+ fill: "currentColor",
607
+ d: "M15 2H5L4 8h12zM0 10s2 1 10 1s10-1 10-1l-4-2H4zm8 4h4v1H8z"
608
+ }, null, -1),
609
+ b("circle", {
610
+ cx: "6",
611
+ cy: "15",
612
+ r: "3",
613
+ fill: "currentColor"
614
+ }, null, -1),
615
+ b("circle", {
616
+ cx: "14",
617
+ cy: "15",
618
+ r: "3",
619
+ fill: "currentColor"
620
+ }, null, -1)
621
+ ]));
622
+ }
623
+ const Xe = { name: "ooui-user-anonymous", render: Ke }, Ze = { class: "relative flex items-center justify-center rounded-full bg-gray-200" }, et = {
624
+ key: 1,
625
+ class: "text-sm font-semibold tracking-wider text-gray-500",
626
+ "aria-hidden": "true"
627
+ }, ct = /* @__PURE__ */ M({
628
+ __name: "AGSolidUserAvatar",
629
+ setup(n) {
630
+ const e = K(() => {
631
+ var t;
632
+ return (((t = f.user) == null ? void 0 : t.name) ?? "").trim().split(" ").map((r) => {
633
+ var s;
634
+ return (s = r[0]) == null ? void 0 : s.toUpperCase();
635
+ }).join("").slice(0, 3);
636
+ });
637
+ return (i, t) => {
638
+ var r, s;
639
+ return d(), S("div", Ze, [
640
+ (r = i.$solid.user) != null && r.avatarUrl ? (d(), I(ze, {
641
+ key: 0,
642
+ src: (s = i.$solid.user) == null ? void 0 : s.avatarUrl,
643
+ alt: "",
644
+ class: "absolute inset-0 h-full w-full rounded-full"
645
+ }, null, 8, ["src"])) : e.value ? (d(), S("span", et, w(e.value), 1)) : (d(), I(a(Xe), {
646
+ key: 2,
647
+ class: "h-6 w-6 text-gray-500"
648
+ }))
649
+ ]);
650
+ };
651
+ }
652
+ }), tt = { $solid: f };
653
+ function dt(n = {}) {
654
+ return {
655
+ async install(e) {
656
+ Ie(), Me({ ...Oe, ...n.authenticators ?? {} }), Ve(), Ge(Z(n.defaultAuthenticator ?? "inrupt")), we((i) => {
657
+ if (i instanceof U)
658
+ return i.description ? `${i.message} (${i.description})` : i.message;
659
+ }), typeof n.autoReconnect == "boolean" && (N.autoReconnect = n.autoReconnect, f.hasPersistedState() || (f.autoReconnect = n.autoReconnect)), n.onUserProfileLoaded && g.on("solid:user-profile-loaded", ([i, t]) => {
660
+ var r;
661
+ (r = n.onUserProfileLoaded) == null || r.call(n, i, t);
662
+ }), await Se(e, tt);
663
+ }
664
+ };
665
+ }
666
+ export {
667
+ ze as AGSolidImage,
668
+ ut as AGSolidStatus,
669
+ ct as AGSolidUserAvatar,
670
+ xe as AuthenticationCancelledError,
671
+ U as AuthenticationFailedError,
672
+ X as Authenticator,
673
+ qe as ContainerAlreadyInUse,
674
+ f as Solid,
675
+ Be as SolidService,
676
+ Oe as authenticators,
677
+ dt as default,
678
+ Z as getAuthenticator,
679
+ We as registerAuthenticator,
680
+ Me as registerAuthenticators,
681
+ Ge as setDefaultAuthenticator
682
+ };
683
+ //# sourceMappingURL=aerogel-plugin-solid.js.map