@aerogel/plugin-solid 0.0.1 → 0.1.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.
Files changed (39) 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 +120 -92
  6. package/dist/aerogel-plugin-solid.js +724 -0
  7. package/dist/aerogel-plugin-solid.js.map +1 -0
  8. package/package.json +35 -28
  9. package/src/auth/Authenticator.ts +10 -8
  10. package/src/auth/authenticators/InruptAuthenticator.lazy.ts +1 -0
  11. package/src/auth/authenticators/InruptAuthenticator.ts +41 -12
  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 +3 -1
  15. package/src/components/SolidAvatar.vue +35 -0
  16. package/src/components/SolidImage.vue +33 -0
  17. package/src/components/SolidLogin.vue +141 -0
  18. package/src/components/index.ts +3 -4
  19. package/src/errors/AuthenticationFailedError.ts +22 -0
  20. package/src/errors/index.ts +3 -4
  21. package/src/forms/validation.ts +11 -0
  22. package/src/index.css +1 -0
  23. package/src/index.test.ts +24 -0
  24. package/src/index.ts +65 -0
  25. package/src/services/Solid.state.ts +12 -16
  26. package/src/services/Solid.ts +317 -139
  27. package/src/testing/setup.ts +11 -0
  28. package/src/types/env.d.ts +1 -0
  29. package/src/types/solid-auth-client.d.ts +21 -0
  30. package/.eslintrc.js +0 -7
  31. package/dist/aerogel-plugin-solid.cjs.js +0 -2
  32. package/dist/aerogel-plugin-solid.cjs.js.map +0 -1
  33. package/dist/aerogel-plugin-solid.esm.js +0 -2
  34. package/dist/aerogel-plugin-solid.esm.js.map +0 -1
  35. package/noeldemartin.config.js +0 -2
  36. package/src/components/AGSolidStatus.ts +0 -5
  37. package/src/components/AGSolidStatus.vue +0 -60
  38. package/src/main.ts +0 -43
  39. package/tsconfig.json +0 -10
@@ -0,0 +1,724 @@
1
+ var ce = Object.defineProperty;
2
+ var de = (n, e, t) => e in n ? ce(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var h = (n, e, t) => de(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { persistent as he, defineServiceState as ge, Events as f, UI as x, translateWithDefault as u, App as m, Storage as fe, Errors as G, defineFormValidationRule as me, computedAsync as we, Cache as F, useForm as pe, stringInput as ye, requiredStringInput as ve, classes as J, Form as Se, Input as be, Select as Ie, Button as k, Link as Le, registerErrorHandler as Ae, bootServices as Pe } from "@aerogel/core";
5
+ import { SolidEngine as Ce, SolidTypeIndex as S, SolidContainer as q, SolidACLAuthorization as Ee, SolidDocument as xe, bootSolidModels as Ue } from "soukai-solid";
6
+ import { JSError as j, arr as Te, fail as U, PromisedValue as $e, Storage as O, after as H, required as K, facade as _e, tap as D, arrayUnique as X, objectWithout as Z, isDevelopment as Re, resetAsyncMemo as ee, asyncMemo as te, hasLocationQueryParameter as A, getLocationQueryParameter as z, arrayFilter as Fe, setAsyncMemo as ie, urlRoot as ke, requireUrlParse as qe, objectWithoutEmpty as Oe, parseBoolean as ne, arrayWithout as De } from "@noeldemartin/utils";
7
+ import { fetchLoginUserProfile as ze } from "@noeldemartin/solid-utils";
8
+ import { setEngine as Me } from "soukai";
9
+ import P from "virtual:aerogel-solid";
10
+ import { markRaw as se, createElementBlock as p, openBlock as d, createElementVNode as v, defineComponent as W, unref as l, computed as I, createBlock as w, toDisplayString as L, ref as re, resolveDirective as Be, normalizeClass as C, withCtx as b, createCommentVNode as M, createVNode as B, withDirectives as Ve, createTextVNode as E } from "vue";
11
+ class je extends j {
12
+ }
13
+ function He(n, e) {
14
+ return n;
15
+ }
16
+ class T extends j {
17
+ constructor(t, i, r) {
18
+ super(He(t), r);
19
+ h(this, "description");
20
+ this.description = i;
21
+ }
22
+ }
23
+ class We extends j {
24
+ constructor(e, t) {
25
+ super(`Container at ${e.url} is already in use`, t);
26
+ }
27
+ }
28
+ class oe {
29
+ constructor() {
30
+ h(this, "name");
31
+ h(this, "authenticatedFetch");
32
+ h(this, "booted");
33
+ h(this, "listeners", Te([]));
34
+ h(this, "_engine");
35
+ }
36
+ get engine() {
37
+ return this._engine = this._engine ?? new Ce(this.requireAuthenticatedFetch()), this._engine;
38
+ }
39
+ getAuthenticatedFetch() {
40
+ return this.authenticatedFetch ?? null;
41
+ }
42
+ requireAuthenticatedFetch() {
43
+ return this.authenticatedFetch ?? U("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 $e(), 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 t = {
63
+ authenticator: this,
64
+ ...e
65
+ };
66
+ return await this.notifyListeners("onSessionStarted", t), t;
67
+ }
68
+ async failSession(e, t) {
69
+ await this.notifyListeners("onSessionFailed", e, t);
70
+ }
71
+ async endSession() {
72
+ await this.notifyListeners("onSessionEnded");
73
+ }
74
+ async notifyListeners(e, ...t) {
75
+ await Promise.all(
76
+ this.listeners.toArray().map(async (i) => {
77
+ const r = i[e];
78
+ await (r == null ? void 0 : r(...t));
79
+ })
80
+ );
81
+ }
82
+ }
83
+ const V = "inrupt-authenticator";
84
+ class Ne extends oe {
85
+ constructor() {
86
+ super(...arguments);
87
+ h(this, "_events");
88
+ h(this, "_fetch");
89
+ h(this, "_login");
90
+ h(this, "_logout");
91
+ h(this, "_handleIncomingRedirect");
92
+ }
93
+ async login(t) {
94
+ O.set(V, t);
95
+ const i = {
96
+ oidcIssuer: t
97
+ };
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 }), U("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: t, fetch: i, handleIncomingRedirect: r, login: s, logout: c } = await import("./InruptAuthenticator.lazy-BvpQLGoj.js");
105
+ this._fetch = i, this._login = s, this._logout = c, this._events = t, this._handleIncomingRedirect = r, await this.loginFromRedirect();
106
+ }
107
+ async loginFromRedirect() {
108
+ const t = O.get(V);
109
+ if (!t)
110
+ return;
111
+ this._events().on("error", (r, s) => {
112
+ 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
+ const i = await this._handleIncomingRedirect(globalThis.location.href);
115
+ O.remove(V), i != null && i.isLoggedIn && i.webId && await this.initSession(i.webId);
116
+ }
117
+ async initSession(t) {
118
+ await this.initAuthenticatedFetch(this._fetch);
119
+ try {
120
+ const i = await g.requireUserProfile(t);
121
+ await this.startSession({ user: i, loginUrl: t });
122
+ } catch (i) {
123
+ await this.failSession(t, i);
124
+ }
125
+ }
126
+ }
127
+ class Qe extends oe {
128
+ constructor() {
129
+ super();
130
+ h(this, "store");
131
+ this.store = he("legacy-authenticator", {});
132
+ }
133
+ async login(t, i) {
134
+ const { SolidAuthClient: r } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js");
135
+ throw this.store.webId = i == null ? void 0 : i.webId, this.store.loginUrl = (i == null ? void 0 : i.oidcIssuerUrl) ?? t, await r.login(this.store.loginUrl) === null ? (delete this.store.webId, delete this.store.loginUrl, new T("Could not log in with Solid using the legacy authenticator")) : (await H({ seconds: 60 }), new Error("Browser should have redirected, but it didn't"));
136
+ }
137
+ async logout() {
138
+ const { SolidAuthClient: t } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js");
139
+ delete this.store.webId, delete this.store.loginUrl, await t.logout(), await this.endSession();
140
+ }
141
+ async restoreSession() {
142
+ if (!this.store.loginUrl)
143
+ return;
144
+ const { SolidAuthClient: t } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js"), i = await t.currentSession(), r = K(this.store.loginUrl);
145
+ await this.initAuthenticatedFetch((s, c) => t.fetch(s, c));
146
+ try {
147
+ const s = await g.requireUserProfile(K((i == null ? void 0 : i.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 N = {}, Ye = {
155
+ inrupt: new Ne(),
156
+ legacy: new Qe()
157
+ };
158
+ function Ge(n) {
159
+ N.default = n;
160
+ }
161
+ function ae(n) {
162
+ return N[n];
163
+ }
164
+ function Je(n) {
165
+ Object.entries(n).forEach(([e, t]) => Ke(e, t));
166
+ }
167
+ function Ke(n, e) {
168
+ N[n] = e, e.name = e.name ?? n;
169
+ }
170
+ const Q = { autoReconnect: !0 }, Xe = ge({
171
+ name: "solid",
172
+ persist: ["autoReconnect", "dismissed", "previousSession", "profiles", "staleProfiles"],
173
+ initialState: {
174
+ autoReconnect: Q.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, t;
193
+ return ((e = n.session) == null ? void 0 : e.user) ?? ((t = n.previousSession) == null ? void 0 : t.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 Ze extends Xe {
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 ?? U("Could not get authenticator");
221
+ }
222
+ requireUser() {
223
+ return this.user ?? U("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, t = {}) {
230
+ var c;
231
+ let i = null;
232
+ const r = t.markStale ?? !((c = this.authenticator) != null && c.getAuthenticatedFetch()), s = this.profiles[e] ?? await D(
233
+ await ze(e, {
234
+ fetch: this.fetch,
235
+ required: t.required ?? !1,
236
+ onLoaded(o) {
237
+ i = o;
238
+ }
239
+ }),
240
+ async (o) => {
241
+ o && (i && await f.emit("solid:user-profile-loaded", [o, i]), this.rememberProfile(o));
242
+ }
243
+ );
244
+ return s && r && this.setState({ staleProfiles: X(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, t = {}) {
259
+ if (Re() && e === "dev" && (e = "http://localhost:3000"), /^https?:\/\//.test(e) || (t.fallbackUrl ?? (t.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 t.loading ? x.loading(u("solid.loginOngoing", "Logging in..."), () => this.attemptLogin(e, t)) : this.attemptLogin(e, t);
264
+ }
265
+ async reconnect(e = {}) {
266
+ const { force: t, ...i } = e;
267
+ this.isLoggedIn() || !this.previousSession || this.previousSession.error !== null && !t || await this.login(this.previousSession.loginUrl, {
268
+ authenticator: this.previousSession.authenticator,
269
+ ...i,
270
+ loading: i.loading ?? !1
271
+ });
272
+ }
273
+ async logout(e = !1) {
274
+ var c, o;
275
+ const t = !m.plugin("@aerogel/local-first") || !!((c = m.service("$cloud")) != null && c.ready), i = !m.plugin("@aerogel/local-first") || !!((o = m.service("$cloud")) != null && o.dirty), [r, s] = e ? [!0, { wipeLocalData: t }] : await x.confirm(
276
+ t ? u("solid.logoutConfirmTitle", "Log out from this device?") : u("solid.disconnectConfirmTitle", "Disconnect account?"),
277
+ t ? i ? u(
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
+ ) : u(
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
+ ) : u(
284
+ "solid.disconnectConfirmMessage",
285
+ "You'll need to introduce your credentials again to connect to your Solid POD."
286
+ ),
287
+ {
288
+ acceptText: u("solid.logoutConfirmAccept", "Log out"),
289
+ acceptVariant: "danger",
290
+ cancelText: u(
291
+ "solid.logoutConfirmCancel",
292
+ u("ui.cancel", "Cancel")
293
+ ),
294
+ checkboxes: t ? i ? {
295
+ wipeLocalData: {
296
+ label: u(
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: u(
306
+ "solid.logoutConfirmWipe",
307
+ "Also remove all existing data"
308
+ ),
309
+ default: !1
310
+ }
311
+ }
312
+ }
313
+ );
314
+ r && this.previousSession && await x.loading(u("solid.logoutOngoing", "Logging out..."), async () => {
315
+ this.setState({
316
+ dismissed: !1,
317
+ ignorePreviousSessionError: !1,
318
+ loginStartupError: null,
319
+ previousSession: null,
320
+ ...Q
321
+ }), this.isLoggedIn() && await this.authenticator.logout(), (s.wipeLocalData ?? !0) && await fe.purge(), await f.emit("auth:logout"), await f.emit("auth:after-logout");
322
+ });
323
+ }
324
+ async whenLoggedIn(e) {
325
+ return this.isLoggedIn() ? e(this.session) : new Promise((t) => {
326
+ const i = (r) => t(e(r));
327
+ f.once("auth:login", i);
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(e = {}) {
337
+ const { webId: t, privateTypeIndexUrl: i } = this.requireUser(), r = this.requireAuthenticator().engine;
338
+ return i ? (e.fresh && ee(`${t}-privateTypeIndex`), te(`${t}-privateTypeIndex`, () => S.withEngine(r).find(i))) : null;
339
+ }
340
+ async findOrCreatePublicTypeIndex() {
341
+ return await this.findPublicTypeIndex() ?? await this.createPublicTypeIndex();
342
+ }
343
+ async findPublicTypeIndex(e = {}) {
344
+ const { webId: t, publicTypeIndexUrl: i } = this.requireUser(), r = this.requireAuthenticator().engine;
345
+ return i ? (e.fresh && ee(`${t}-publicTypeIndex`), te(`${t}-publicTypeIndex`, () => S.withEngine(r).find(i))) : null;
346
+ }
347
+ async createPrivateContainer(e) {
348
+ const t = this.requireAuthenticator().engine;
349
+ return q.withEngine(t, async () => {
350
+ const i = await q.find(e.url);
351
+ if (i && !e.reuseExisting)
352
+ throw new We(i);
353
+ const r = i ?? new q({ 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, t;
363
+ await G.booted, A("authenticator") && this.setState({
364
+ preferredAuthenticator: z("authenticator")
365
+ }), A("refreshProfile") && this.setState({
366
+ staleProfiles: X(
367
+ this.staleProfiles.concat(Fe([(e = this.session) == null ? void 0 : e.user.webId, (t = this.previousSession) == null ? void 0 : t.loginUrl]))
368
+ )
369
+ }), await this.restorePreviousSession(), await this.startupReconnect();
370
+ }
371
+ async createPrivateTypeIndex() {
372
+ const e = this.requireUser(), t = this.requireAuthenticator(), i = await S.withEngine(t.engine).createPrivate(e);
373
+ return D(i, () => {
374
+ e.privateTypeIndexUrl = i.url, ie(`${e.webId}-privateTypeIndex`, i), this.rememberProfile(e);
375
+ });
376
+ }
377
+ async createPublicTypeIndex() {
378
+ const e = this.requireUser(), t = this.requireAuthenticator(), i = await S.withEngine(t.engine).createPublic(e);
379
+ return D(i, () => {
380
+ e.privateTypeIndexUrl = i.url, ie(`${e.webId}-publicTypeIndex`, i), this.rememberProfile(e);
381
+ });
382
+ }
383
+ async attemptLogin(e, t) {
384
+ const i = t.authenticator ?? this.preferredAuthenticator ?? "default", r = t.onError ?? ((o) => m.isMounted() ? G.report(o) : this.setState({ loginStartupError: o })), s = setTimeout(() => this.loginStale = !0, 1e4), c = {
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 }), $ = (o == null ? void 0 : o.oidcIssuerUrl) ?? ke((o == null ? void 0 : o.webId) ?? e), _ = await this.bootAuthenticator(i), { domain: R } = qe(e);
392
+ return this.setState({
393
+ dismissed: !1,
394
+ ignorePreviousSessionError: !0,
395
+ previousSession: Oe({
396
+ profile: o,
397
+ loginUrl: e,
398
+ authenticator: i,
399
+ error: u(
400
+ "solid.stuckConnecting",
401
+ "We didn't hear back from the identity provider at `{domain}`, maybe try reconnecting?",
402
+ { domain: R }
403
+ )
404
+ })
405
+ }), await f.emit("auth:before-login"), await _.login($, o), !0;
406
+ } catch (o) {
407
+ return this.setState(c), o instanceof je ? !1 : t.fallbackUrl ? H().then(() => this.login(t.fallbackUrl ?? "", Z(t, "fallbackUrl"))) : (r(o), !1);
408
+ } finally {
409
+ clearTimeout(s), this.setState({
410
+ loginOngoing: !1,
411
+ loginStale: !1
412
+ });
413
+ }
414
+ }
415
+ async restorePreviousSession() {
416
+ this.previousSession && await this.bootAuthenticator(this.previousSession.authenticator);
417
+ }
418
+ async startupReconnect() {
419
+ this.reconnectOnStartup() && await this.reconnect({ force: this.forcingReconnect() });
420
+ }
421
+ reconnectOnStartup() {
422
+ return A("autoReconnect") ? ne(z("autoReconnect")) : this.autoReconnect;
423
+ }
424
+ forcingReconnect() {
425
+ return A("autoReconnect") && ne(z("autoReconnect"));
426
+ }
427
+ async bootAuthenticator(e) {
428
+ const t = ae(e);
429
+ return t.addListener({
430
+ onSessionStarted: async (i) => {
431
+ this.setState({
432
+ session: i,
433
+ previousSession: {
434
+ authenticator: t.name,
435
+ loginUrl: i.loginUrl,
436
+ profile: i.user,
437
+ error: null
438
+ }
439
+ }), this.staleProfiles.includes(i.user.webId) && await this.refreshUserProfile(), m.plugin("@aerogel/local-first") || Me(i.authenticator.engine), Ee.setEngine(i.authenticator.engine), S.setEngine(i.authenticator.engine), xe.setEngine(i.authenticator.engine), await f.emit("auth:login", i);
440
+ },
441
+ onSessionFailed: async (i, r) => {
442
+ var s;
443
+ this.setState({
444
+ session: null,
445
+ previousSession: {
446
+ profile: (s = this.previousSession) == null ? void 0 : s.profile,
447
+ authenticator: t.name,
448
+ loginUrl: i,
449
+ error: r
450
+ }
451
+ });
452
+ },
453
+ onSessionEnded: () => this.setState({ session: null }),
454
+ onAuthenticatedFetchReady: (i) => f.emit("auth:fetch-ready", i)
455
+ }), await t.boot(), t;
456
+ }
457
+ rememberProfile(e) {
458
+ this.setState({
459
+ profiles: {
460
+ ...this.profiles,
461
+ [e.webId]: e
462
+ },
463
+ staleProfiles: De(this.staleProfiles, e.webId)
464
+ });
465
+ }
466
+ }
467
+ const g = _e(Ze);
468
+ function et() {
469
+ me("container_url", (n) => {
470
+ if (!n.endsWith("/"))
471
+ return "containerEndingSlashMissing";
472
+ });
473
+ }
474
+ const tt = {
475
+ viewBox: "0 0 20 20",
476
+ width: "1.2em",
477
+ height: "1.2em"
478
+ };
479
+ function it(n, e) {
480
+ return d(), p("svg", tt, e[0] || (e[0] = [
481
+ v("path", {
482
+ fill: "currentColor",
483
+ d: "M15 2H5L4 8h12zM0 10s2 1 10 1s10-1 10-1l-4-2H4zm8 4h4v1H8z"
484
+ }, null, -1),
485
+ v("circle", {
486
+ cx: "6",
487
+ cy: "15",
488
+ r: "3",
489
+ fill: "currentColor"
490
+ }, null, -1),
491
+ v("circle", {
492
+ cx: "14",
493
+ cy: "15",
494
+ r: "3",
495
+ fill: "currentColor"
496
+ }, null, -1)
497
+ ]));
498
+ }
499
+ const nt = se({ name: "ooui-user-anonymous", render: it }), rt = ["src"], st = /* @__PURE__ */ W({
500
+ __name: "SolidImage",
501
+ props: {
502
+ src: {}
503
+ },
504
+ setup(n) {
505
+ const e = we(async () => {
506
+ const i = await F.get(n.src) ?? await t(n.src), r = await (i == null ? void 0 : i.blob());
507
+ return r && URL.createObjectURL(r);
508
+ });
509
+ async function t(i) {
510
+ try {
511
+ const r = await g.fetch(i);
512
+ return r.status !== 200 ? null : (await F.store(i, r), F.get(i));
513
+ } catch {
514
+ return null;
515
+ }
516
+ }
517
+ return (i, r) => (d(), p("img", { src: l(e) }, null, 8, rt));
518
+ }
519
+ }), ot = { class: "relative flex items-center justify-center rounded-full bg-gray-200" }, at = {
520
+ key: 1,
521
+ class: "text-sm font-semibold tracking-wider text-gray-500",
522
+ "aria-hidden": "true"
523
+ }, bt = /* @__PURE__ */ W({
524
+ __name: "SolidAvatar",
525
+ setup(n) {
526
+ const e = I(() => {
527
+ var i;
528
+ return (((i = g.user) == null ? void 0 : i.name) ?? "").trim().split(" ").map((r) => {
529
+ var s;
530
+ return (s = r[0]) == null ? void 0 : s.toUpperCase();
531
+ }).join("").slice(0, 3);
532
+ });
533
+ return (t, i) => {
534
+ var r, s;
535
+ return d(), p("div", ot, [
536
+ (r = t.$solid.user) != null && r.avatarUrl ? (d(), w(st, {
537
+ key: 0,
538
+ src: (s = t.$solid.user) == null ? void 0 : s.avatarUrl,
539
+ alt: "",
540
+ class: "absolute inset-0 size-full rounded-full"
541
+ }, null, 8, ["src"])) : e.value ? (d(), p("span", at, L(e.value), 1)) : (d(), w(l(nt), {
542
+ key: 2,
543
+ class: "size-6 text-gray-500"
544
+ }))
545
+ ]);
546
+ };
547
+ }
548
+ }), lt = {
549
+ viewBox: "0 0 24 24",
550
+ width: "1.2em",
551
+ height: "1.2em"
552
+ };
553
+ function ut(n, e) {
554
+ return d(), p("svg", lt, e[0] || (e[0] = [
555
+ v("path", {
556
+ fill: "currentColor",
557
+ 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
+ }, null, -1),
559
+ v("path", {
560
+ fill: "currentColor",
561
+ d: "M10.09 15.59L11.5 17l5-5l-5-5l-1.41 1.41L12.67 11H3v2h9.67z"
562
+ }, null, -1)
563
+ ]));
564
+ }
565
+ const ct = se({ name: "ic-baseline-log-in", render: ut }), dt = {
566
+ key: 2,
567
+ class: "flex w-full justify-center gap-2"
568
+ }, It = /* @__PURE__ */ W({
569
+ __name: "SolidLogin",
570
+ props: {
571
+ class: { default: "" },
572
+ buttonClass: {},
573
+ layout: { default: "horizontal" },
574
+ noLoading: { type: Boolean },
575
+ allowLegacyAuthenticator: { type: Boolean }
576
+ },
577
+ setup(n) {
578
+ const e = {
579
+ inrupt: "Log in using Inrupt's authentication library",
580
+ legacy: "Log in using the legacy authentication library"
581
+ }, t = pe({
582
+ url: ve(),
583
+ authenticator: ye()
584
+ }), i = Object.keys(e), r = re(!1), s = re(!1), c = I(() => !o.value || s.value), o = I(
585
+ () => m.development && (!t.url || t.url === "dev" || t.url.trim().length === 0)
586
+ ), $ = I(() => J("flex flex-col items-center gap-2 w-full md:w-auto", n.class)), _ = I(() => J("w-full whitespace-nowrap", { "md:w-auto": n.layout === "horizontal" && !t.authenticator }, n.buttonClass));
587
+ function R(a) {
588
+ return u(
589
+ `solid.logIn.switchAuthenticator${a.charAt(0).toUpperCase() + a.slice(1)}`,
590
+ e[a]
591
+ );
592
+ }
593
+ async function le() {
594
+ if (n.noLoading) {
595
+ await g.login(t.url, { authenticator: t.authenticator });
596
+ return;
597
+ }
598
+ await x.loading(u("solid.loginOngoing", "Logging in..."), g.login(t.url));
599
+ }
600
+ return (a, y) => {
601
+ const ue = Be("measure");
602
+ return d(), w(l(Se), {
603
+ form: l(t),
604
+ class: C($.value),
605
+ onSubmit: le
606
+ }, {
607
+ default: b(() => [
608
+ v("div", {
609
+ class: C(["flex w-full flex-col items-center gap-2", { "md:flex-row": a.layout === "horizontal" && !l(t).authenticator }])
610
+ }, [
611
+ c.value ? (d(), w(l(be), {
612
+ key: 0,
613
+ name: "url",
614
+ "aria-label": a.$td("solid.logIn.label", "Login url"),
615
+ placeholder: a.$td("solid.logIn.placeholder", "https://me.solidcommunity.net"),
616
+ class: "w-full md:min-w-96"
617
+ }, null, 8, ["aria-label", "placeholder"])) : M("", !0),
618
+ l(t).authenticator ? (d(), w(l(Ie), {
619
+ key: 1,
620
+ name: "authenticator",
621
+ class: "w-full max-w-full md:min-w-96",
622
+ "label-class": "sr-only",
623
+ "options-class": "md:w-96 w-full max-w-[calc(100vw-4rem)]",
624
+ label: a.$td("solid.logIn.switchAuthenticatorLabel", "Authentication method"),
625
+ options: l(i),
626
+ "render-option": R
627
+ }, null, 8, ["label", "options"])) : M("", !0),
628
+ o.value && !s.value ? (d(), p("div", dt, [
629
+ B(l(k), {
630
+ variant: "secondary",
631
+ class: "group gap-0",
632
+ title: a.$td("solid.logIn.manualUrl", "Enter url"),
633
+ onClick: y[0] || (y[0] = (Y) => s.value = !0)
634
+ }, {
635
+ default: b(() => [
636
+ B(l(ct), { class: "size-4" }),
637
+ Ve((d(), p("span", {
638
+ class: C(["overflow-hidden pl-1 whitespace-nowrap", {
639
+ "opacity-0": !r.value,
640
+ "w-0 transition-[width] md:group-hover:w-(--width)": r.value
641
+ }])
642
+ }, [
643
+ E(L(a.$td("solid.logIn.manualUrl", "Enter url")), 1)
644
+ ], 2)), [
645
+ [
646
+ ue,
647
+ () => r.value = !0,
648
+ void 0,
649
+ { css: !0 }
650
+ ]
651
+ ])
652
+ ]),
653
+ _: 1
654
+ }, 8, ["title"]),
655
+ B(l(k), {
656
+ disabled: a.noLoading && a.$solid.loginOngoing,
657
+ submit: "",
658
+ class: "whitespace-nowrap",
659
+ onClick: y[1] || (y[1] = (Y) => l(t).url = "dev")
660
+ }, {
661
+ default: b(() => [
662
+ E(L(a.$td("solid.logIn.dev", "Log in to dev server")), 1)
663
+ ]),
664
+ _: 1
665
+ }, 8, ["disabled"])
666
+ ])) : (d(), w(l(k), {
667
+ key: 3,
668
+ disabled: a.noLoading && a.$solid.loginOngoing,
669
+ submit: "",
670
+ class: C(_.value)
671
+ }, {
672
+ default: b(() => [
673
+ E(L(a.$td("solid.logIn.submit", "Log in")), 1)
674
+ ]),
675
+ _: 1
676
+ }, 8, ["disabled", "class"]))
677
+ ], 2),
678
+ a.allowLegacyAuthenticator && c.value && !l(t).authenticator ? (d(), w(l(Le), {
679
+ key: 0,
680
+ class: "text-sm font-normal text-gray-700",
681
+ onClick: y[2] || (y[2] = (Y) => l(t).authenticator = "inrupt")
682
+ }, {
683
+ default: b(() => [
684
+ E(L(a.$td("solid.logIn.switchAuthenticator", "Can't log in? Try using a different authentication method")), 1)
685
+ ]),
686
+ _: 1
687
+ })) : M("", !0)
688
+ ]),
689
+ _: 1
690
+ }, 8, ["form", "class"]);
691
+ };
692
+ }
693
+ }), ht = { $solid: g };
694
+ function Lt(n = {}) {
695
+ return {
696
+ async install(e) {
697
+ Ue(), Je({ ...Ye, ...n.authenticators ?? {} }), et(), Ge(ae(n.defaultAuthenticator ?? "inrupt")), Ae((t) => {
698
+ if (t instanceof T)
699
+ return t.description ? `${t.message} (${t.description})` : t.message;
700
+ }), typeof n.autoReconnect == "boolean" && (Q.autoReconnect = n.autoReconnect, g.hasPersistedState() || (g.autoReconnect = n.autoReconnect)), n.onUserProfileLoaded && f.on("solid:user-profile-loaded", ([t, i]) => {
701
+ var r;
702
+ (r = n.onUserProfileLoaded) == null || r.call(n, t, i);
703
+ }), await Pe(e, ht);
704
+ }
705
+ };
706
+ }
707
+ export {
708
+ je as AuthenticationCancelledError,
709
+ T as AuthenticationFailedError,
710
+ oe as Authenticator,
711
+ We as ContainerAlreadyInUse,
712
+ g as Solid,
713
+ bt as SolidAvatar,
714
+ st as SolidImage,
715
+ It as SolidLogin,
716
+ Ze as SolidService,
717
+ Ye as authenticators,
718
+ Lt as default,
719
+ ae as getAuthenticator,
720
+ Ke as registerAuthenticator,
721
+ Je as registerAuthenticators,
722
+ Ge as setDefaultAuthenticator
723
+ };
724
+ //# sourceMappingURL=aerogel-plugin-solid.js.map