@aerogel/plugin-solid 0.0.1-next.13b88f634a31caf3669d61e53e7d3fa95e20488c

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aerogel-plugin-solid.esm.js","sources":["../src/errors/AuthenticationCancelledError.ts","../src/errors/AuthenticationFailedError.ts","../src/errors/ContainerAlreadyInUse.ts","../src/auth/Authenticator.ts","../src/auth/authenticators/InruptAuthenticator.ts","../src/auth/index.ts","../src/services/Solid.state.ts","../src/services/Solid.ts","../src/components/AGSolidImage.vue","../src/components/AGSolidStatus.vue","../src/components/AGSolidUserAvatar.vue","../src/main.ts"],"sourcesContent":["import { JSError } from '@noeldemartin/utils';\n\nexport default class AuthenticationCancelledError extends JSError {}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class AuthenticationFailedError extends JSError {\n\n public readonly description?: string | null;\n\n constructor(message: string, description?: string | null, options?: JSErrorOptions) {\n super(message, options);\n\n this.description = description;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\nimport type { SolidContainer } from 'soukai-solid';\n\nexport default class ContainerAlreadyInUse extends JSError {\n\n constructor(container: SolidContainer, options?: JSErrorOptions) {\n super(`Container at ${container.url} is already in use`, options);\n }\n\n}\n","import { PromisedValue, arr, fail } from '@noeldemartin/utils';\nimport { SolidEngine } from 'soukai-solid';\nimport type { Closure, FluentArray, GetClosureArgs } from '@noeldemartin/utils';\nimport type { Engine } from 'soukai';\nimport type { Fetch } from 'soukai-solid';\nimport type { SolidUserProfile } from '@noeldemartin/solid-utils';\nimport type { ErrorSource } from '@aerogel/core';\n\nimport type { AuthenticatorName } from '@/auth';\n\ntype ListenerEvent = keyof AuthenticatorListener;\ntype ListenerEventPayload<\n Event extends ListenerEvent,\n Callback = AuthenticatorListener[Event]\n> = Callback extends Closure ? GetClosureArgs<Callback> : never;\n\nexport interface AuthSession {\n user: SolidUserProfile;\n loginUrl: string;\n authenticator: Authenticator;\n}\n\nexport interface AuthenticatorListener {\n onSessionStarted?: (session: AuthSession) => Promise<void> | void;\n onSessionFailed?: (loginUrl: string, error: ErrorSource) => Promise<void> | void;\n onSessionEnded?: () => Promise<void> | void;\n onAuthenticatedFetchReady?: (fetch: Fetch) => Promise<void> | void;\n}\n\nexport default abstract class Authenticator {\n\n public name!: AuthenticatorName;\n\n private authenticatedFetch?: Fetch;\n private booted?: PromisedValue<void>;\n private listeners: FluentArray<AuthenticatorListener> = arr<AuthenticatorListener>([]);\n private _engine?: SolidEngine;\n\n public abstract login(loginUrl: string, user?: SolidUserProfile): Promise<AuthSession>;\n\n public abstract logout(): Promise<void>;\n\n public get engine(): Engine {\n this._engine = this._engine ?? new SolidEngine(this.requireAuthenticatedFetch());\n\n return this._engine;\n }\n\n public getAuthenticatedFetch(): Fetch | null {\n return this.authenticatedFetch ?? null;\n }\n\n public requireAuthenticatedFetch(): Fetch {\n return this.authenticatedFetch ?? fail('Authenticated fetch is not ready');\n }\n\n public addListener(listener: AuthenticatorListener): () => void {\n if (!this.listeners.includes(listener)) this.listeners.push(listener);\n\n return () => {\n this.removeListener(listener);\n };\n }\n\n public removeListener(listener: AuthenticatorListener): void {\n if (!this.listeners.includes(listener)) return;\n\n this.listeners.remove(listener);\n }\n\n public async boot(): Promise<void> {\n if (this.booted) {\n return this.booted;\n }\n\n this.booted = new PromisedValue();\n\n await this.restoreSession();\n\n this.booted.resolve();\n }\n\n protected abstract restoreSession(): Promise<void>;\n\n protected async initAuthenticatedFetch(fetch: Fetch): Promise<void> {\n this.authenticatedFetch = fetch;\n\n await this.notifyListeners('onAuthenticatedFetchReady', fetch);\n }\n\n protected async startSession(sessionData: Omit<AuthSession, 'authenticator'>): Promise<AuthSession> {\n const session: AuthSession = {\n authenticator: this,\n ...sessionData,\n };\n\n await this.notifyListeners('onSessionStarted', session);\n\n return session;\n }\n\n protected async failSession(loginUrl: string, error: ErrorSource): Promise<void> {\n await this.notifyListeners('onSessionFailed', loginUrl, error);\n }\n\n protected async endSession(): Promise<void> {\n await this.notifyListeners('onSessionEnded');\n }\n\n protected async notifyListeners<Event extends ListenerEvent>(\n event: Event,\n ...payload: ListenerEventPayload<Event>\n ): Promise<void> {\n await Promise.all(\n this.listeners.toArray().map(async (listener) => {\n const callback = listener[event] as Closure | undefined;\n\n await callback?.(...payload);\n }),\n );\n }\n\n}\n","import { Storage, after, fail } from '@noeldemartin/utils';\nimport type { Fetch } from 'soukai-solid';\nimport type {\n ILoginInputOptions,\n events,\n handleIncomingRedirect,\n login,\n logout,\n} from '@inrupt/solid-client-authn-browser';\n\nimport Authenticator from '@/auth/Authenticator';\nimport AuthenticationFailedError from '@/errors/AuthenticationFailedError';\nimport type { AuthSession } from '@/auth/Authenticator';\n\nimport AerogelSolid from 'virtual:aerogel-solid';\n\nconst STORAGE_KEY = 'inrupt-authenticator';\n\nexport default class InruptAuthenticator extends Authenticator {\n\n private _events!: typeof events;\n private _fetch!: Fetch;\n private _login!: typeof login;\n private _logout!: typeof logout;\n private _handleIncomingRedirect!: typeof handleIncomingRedirect;\n\n public async login(loginUrl: string): Promise<AuthSession> {\n Storage.set<string>(STORAGE_KEY, loginUrl);\n\n const options: ILoginInputOptions = {\n oidcIssuer: loginUrl,\n };\n\n if (AerogelSolid.clientID) {\n options.clientId = AerogelSolid.clientID.client_id;\n options.clientName = AerogelSolid.clientID.client_name;\n options.redirectUrl = AerogelSolid.clientID.redirect_uris[0];\n }\n\n await this._login(options);\n\n // Browser should redirect, so just make it wait for a while.\n await after({ seconds: 60 });\n\n return fail('Browser should have redirected, but it didn\\'t');\n }\n\n public async logout(): Promise<void> {\n await this._logout();\n await this.endSession();\n }\n\n protected async restoreSession(): Promise<void> {\n const { events, fetch, handleIncomingRedirect, login, logout } = await import('./InruptAuthenticator.lazy');\n\n this._fetch = fetch;\n this._login = login;\n this._logout = logout;\n this._events = events;\n this._handleIncomingRedirect = handleIncomingRedirect;\n\n await this.loginFromRedirect();\n }\n\n protected async loginFromRedirect(): Promise<void> {\n const loginUrl = Storage.get<string>(STORAGE_KEY);\n if (!loginUrl) {\n return;\n }\n\n this._events().on('error', (error: string | null, errorDescription?: string | null) => {\n error ??= 'Error using Inrupt Authenticator method';\n\n this.failSession(loginUrl, new AuthenticationFailedError(error, errorDescription));\n });\n\n const session = await this._handleIncomingRedirect(globalThis.location.href);\n\n Storage.remove(STORAGE_KEY);\n\n if (session?.isLoggedIn && session.webId) {\n await this.initSession(session.webId);\n }\n }\n\n protected async initSession(webId: string): Promise<void> {\n await this.initAuthenticatedFetch(this._fetch);\n\n try {\n const { default: Solid } = await import('@/services/Solid');\n const user = await Solid.requireUserProfile(webId);\n\n await this.startSession({ user, loginUrl: webId });\n } catch (error) {\n await this.failSession(webId, error);\n }\n }\n\n}\n","import InruptAuthenticator from './authenticators/InruptAuthenticator';\nimport type Authenticator from './Authenticator';\n\nconst _authenticators = {} as Authenticators;\n\ntype BaseAuthenticators = typeof authenticators;\n\nexport * from './Authenticator';\nexport { Authenticator };\n\nexport const authenticators = {\n inrupt: new InruptAuthenticator(),\n};\n\nexport function setDefaultAuthenticator(authenticator: Authenticator): void {\n _authenticators.default = authenticator;\n}\n\nexport function getAuthenticator<T extends AuthenticatorName>(name: T): Authenticators[T] {\n return _authenticators[name];\n}\n\nexport function registerAuthenticators(customAuthenticators: Record<string, Authenticator>): void {\n Object.entries(customAuthenticators).forEach(([name, authenticator]) =>\n registerAuthenticator(name as AuthenticatorName, authenticator));\n}\n\nexport function registerAuthenticator<T extends AuthenticatorName>(name: T, authenticator: Authenticators[T]): void {\n _authenticators[name] = authenticator;\n\n authenticator.name = authenticator.name ?? name;\n}\n\nexport type AuthenticatorName = keyof Authenticators;\n\nexport interface Authenticators extends BaseAuthenticators {\n default: Authenticator;\n}\n","import { defineServiceState } from '@aerogel/core';\nimport type { ErrorSource } from '@aerogel/core';\nimport type { Fetch, SolidUserProfile } from '@noeldemartin/solid-utils';\n\nimport type { AuthSession } from '@/auth/Authenticator';\nimport type { AuthenticatorName } from '@/auth';\n\nexport const DEFAULT_STATE = { autoReconnect: true };\n\nexport default defineServiceState({\n name: 'solid',\n persist: ['autoReconnect', 'dismissed', 'previousSession', 'profiles', 'staleProfiles'],\n initialState: {\n autoReconnect: DEFAULT_STATE.autoReconnect,\n dismissed: false,\n ignorePreviousSessionError: false,\n loginStartupError: null as ErrorSource | null,\n loginOngoing: false,\n preferredAuthenticator: null as AuthenticatorName | null,\n previousSession: null as {\n profile?: SolidUserProfile;\n authenticator: AuthenticatorName;\n loginUrl: string;\n error: ErrorSource | null;\n } | null,\n profiles: {} as Record<string, SolidUserProfile>,\n session: null as AuthSession | null,\n loginStale: false,\n staleProfiles: [] as string[],\n },\n serialize(state) {\n if (state.previousSession?.error instanceof Error) {\n state.previousSession.error = state.previousSession.error.message;\n }\n\n return state;\n },\n computed: {\n user: (state) => state.session?.user ?? state.previousSession?.profile ?? null,\n authenticator: (state) => state.session?.authenticator ?? null,\n fetch(): Fetch {\n return this.authenticator?.getAuthenticatedFetch() ?? globalThis.fetch.bind(globalThis);\n },\n error(state): ErrorSource | null {\n if (state.loginStartupError) {\n return state.loginStartupError ?? null;\n }\n\n if (state.ignorePreviousSessionError) {\n return null;\n }\n\n return state.previousSession?.error ?? null;\n },\n },\n});\n","import {\n after,\n arrayFilter,\n arrayUnique,\n arrayWithout,\n asyncMemo,\n facade,\n fail,\n getLocationQueryParameter,\n hasLocationQueryParameter,\n objectWithout,\n objectWithoutEmpty,\n parseBoolean,\n requireUrlParse,\n setAsyncMemo,\n tap,\n urlRoot,\n} from '@noeldemartin/utils';\nimport { App, Colors, Errors, Events, UI, translateWithDefault } from '@aerogel/core';\nimport { fetchLoginUserProfile } from '@noeldemartin/solid-utils';\nimport { setEngine } from 'soukai';\nimport { SolidACLAuthorization, SolidContainer, SolidDocument, SolidTypeIndex } from 'soukai-solid';\nimport type { ErrorSource } from '@aerogel/core';\nimport type { Fetch, SolidModelConstructor } from 'soukai-solid';\nimport type { SolidUserProfile } from '@noeldemartin/solid-utils';\n\nimport AuthenticationCancelledError from '@/errors/AuthenticationCancelledError';\nimport { ContainerAlreadyInUse } from '@/errors';\nimport { getAuthenticator } from '@/auth';\nimport type Authenticator from '@/auth/Authenticator';\nimport type { AuthenticatorName } from '@/auth';\nimport type { AuthSession } from '@/auth/Authenticator';\n\nimport Service, { DEFAULT_STATE } from './Solid.state';\n\nexport type LoginOptions = {\n authenticator?: AuthenticatorName;\n onError?(error: ErrorSource): unknown;\n fallbackUrl?: string;\n};\n\nexport type ReconnectOptions = Omit<LoginOptions, 'authenticator'> & {\n force?: boolean;\n};\n\nexport class SolidService extends Service {\n\n public isLoggedIn(): this is { session: AuthSession; user: SolidUserProfile; authenticator: Authenticator } {\n return !!this.session;\n }\n\n public wasLoggedIn(): this is { user: SolidUserProfile } {\n return !!this.previousSession;\n }\n\n public hasLoggedIn(): this is { user: SolidUserProfile } {\n return !!(this.session || this.previousSession);\n }\n\n public requireAuthenticator(): Authenticator {\n return this.authenticator ?? fail('Could not get authenticator');\n }\n\n public requireUser(): SolidUserProfile {\n return this.user ?? fail('Could not get user profile (are you logged in?)');\n }\n\n public requireUserProfile(url: string): Promise<SolidUserProfile> {\n return this.getUserProfile(url, true);\n }\n\n public async getUserProfile(url: string, required: true): Promise<SolidUserProfile>;\n public async getUserProfile(url: string, required?: false): Promise<SolidUserProfile | null>;\n public async getUserProfile(url: string, required: boolean = false): Promise<SolidUserProfile | null> {\n return (\n this.profiles[url] ??\n tap(\n await fetchLoginUserProfile(url, {\n fetch: this.fetch,\n required,\n }),\n (profile) => profile && this.rememberProfile(profile),\n )\n );\n }\n\n public async refreshUserProfile(): Promise<void> {\n if (!this.isLoggedIn()) {\n return;\n }\n\n this.setState({ profiles: objectWithout(this.profiles, [this.user.webId]) });\n\n const user = await this.requireUserProfile(this.user.webId);\n\n this.setState({\n session: {\n ...this.session,\n user,\n },\n });\n }\n\n public async login(loginUrl: string, options: LoginOptions = {}): Promise<boolean> {\n const authenticatorName = options.authenticator ?? this.preferredAuthenticator ?? 'default';\n const handleLoginError =\n options.onError ??\n ((error: ErrorSource) =>\n App.isMounted() ? Errors.report(error) : this.setState({ loginStartupError: error }));\n\n if (App.development && loginUrl === 'devserver') {\n loginUrl = 'http://localhost:3000';\n }\n\n if (!/^https?:\\/\\//.test(loginUrl)) {\n options.fallbackUrl ??= `http://${loginUrl}`;\n loginUrl = `https://${loginUrl}`;\n }\n\n if (this.isLoggedIn()) {\n return true;\n }\n\n if (this.loginOngoing) {\n throw new Error('Authentication already in progress');\n }\n\n const staleTimeout = setTimeout(() => (this.loginStale = true), 10000);\n const initialState = {\n dismissed: this.dismissed,\n ignorePreviousSessionError: this.ignorePreviousSessionError,\n previousSession: this.previousSession,\n };\n this.loginOngoing = true;\n\n try {\n const profile = await this.getUserProfile(loginUrl);\n const oidcIssuerUrl = profile?.oidcIssuerUrl ?? urlRoot(profile?.webId ?? loginUrl);\n const authenticator = await this.bootAuthenticator(authenticatorName);\n const { domain: loginDomain } = requireUrlParse(loginUrl);\n\n this.setState({\n dismissed: false,\n ignorePreviousSessionError: true,\n previousSession: objectWithoutEmpty({\n profile,\n loginUrl,\n authenticator: authenticatorName,\n error: translateWithDefault(\n 'auth.stuckConnecting',\n `We didn't hear back from the identity provider at \\`${loginDomain}\\`, maybe try reconnecting?`,\n ),\n }),\n });\n\n await Events.emit('auth:before-login');\n\n // This should redirect away from the app, so in most cases\n // the rest of the code won't be reached.\n await authenticator.login(oidcIssuerUrl);\n\n return true;\n } catch (error) {\n this.setState(initialState);\n\n if (error instanceof AuthenticationCancelledError) {\n return false;\n }\n\n if (options.fallbackUrl) {\n return after().then(() => this.login(options.fallbackUrl ?? '', objectWithout(options, 'fallbackUrl')));\n }\n\n handleLoginError(error);\n\n return false;\n } finally {\n clearTimeout(staleTimeout);\n\n this.setState({\n loginOngoing: false,\n loginStale: false,\n });\n }\n }\n\n public async reconnect(options: ReconnectOptions = {}): Promise<void> {\n const { force, ...loginOptions } = options;\n if (this.isLoggedIn() || !this.previousSession || (this.previousSession.error !== null && !force)) {\n return;\n }\n\n await this.login(this.previousSession.loginUrl, {\n authenticator: this.previousSession.authenticator,\n ...loginOptions,\n });\n }\n\n public async logout(force: boolean = false): Promise<void> {\n const confirmLogout =\n force ||\n (await UI.confirm(\n translateWithDefault('solid.logoutConfirmTitle', 'Log out from this device?'),\n translateWithDefault(\n 'solid.logoutConfirmMessage',\n 'Logging out will remove all the data from this device, ' +\n 'but you\\'ll still have it in your Solid POD.',\n ),\n {\n acceptText: translateWithDefault('solid.logoutConfirmAccept', 'Log out'),\n acceptColor: Colors.Danger,\n cancelText: translateWithDefault(\n 'solid.logoutConfirmCancel',\n translateWithDefault('ui.cancel', 'Cancel'),\n ),\n },\n ));\n\n if (!confirmLogout) {\n return;\n }\n\n if (!this.previousSession) {\n return;\n }\n\n await UI.loading(translateWithDefault('solid.logoutOngoing', 'Logging out...'), async () => {\n this.setState({\n previousSession: null,\n ...DEFAULT_STATE,\n });\n this.isLoggedIn() && (await this.authenticator.logout());\n\n await Events.emit('auth:logout');\n await Events.emit('auth:after-logout');\n });\n }\n\n public async whenLoggedIn<T>(callback: (session: AuthSession) => T): Promise<T> {\n if (this.isLoggedIn()) {\n return callback(this.session);\n }\n\n return new Promise((resolve) => {\n const onLogin = (session: AuthSession) => resolve(callback(session));\n\n Events.once('auth:login', onLogin);\n });\n }\n\n public dismiss(): void {\n this.setState({ dismissed: true });\n }\n\n public async findOrCreatePrivateTypeIndex(): Promise<SolidTypeIndex> {\n return (await this.findPrivateTypeIndex()) ?? (await this.createPrivateTypeIndex());\n }\n\n public async findPrivateTypeIndex(): Promise<SolidTypeIndex | null> {\n const { webId, privateTypeIndexUrl } = this.requireUser();\n const engine = this.requireAuthenticator().engine;\n\n if (!privateTypeIndexUrl) {\n return null;\n }\n\n return asyncMemo(`${webId}-privateTypeIndex`, () =>\n SolidTypeIndex.withEngine(engine).find(privateTypeIndexUrl));\n }\n\n public async findOrCreatePublicTypeIndex(): Promise<SolidTypeIndex> {\n return (await this.findPublicTypeIndex()) ?? (await this.createPublicTypeIndex());\n }\n\n protected async findPublicTypeIndex(): Promise<SolidTypeIndex | null> {\n const { webId, publicTypeIndexUrl } = this.requireUser();\n const engine = this.requireAuthenticator().engine;\n\n if (!publicTypeIndexUrl) {\n return null;\n }\n\n return asyncMemo(`${webId}-publicTypeIndex`, () => SolidTypeIndex.withEngine(engine).find(publicTypeIndexUrl));\n }\n\n public async createPrivateContainer(options: {\n url: string;\n name?: string;\n registerFor?: SolidModelConstructor;\n reuseExisting?: boolean;\n }): Promise<SolidContainer> {\n const engine = this.requireAuthenticator().engine;\n\n return SolidContainer.withEngine(engine, async () => {\n const existingContainer = await SolidContainer.find(options.url);\n\n if (existingContainer && !options.reuseExisting) {\n throw new ContainerAlreadyInUse(existingContainer);\n }\n\n const container = existingContainer ?? new SolidContainer({ url: options.url, name: options.name });\n\n await container.save();\n\n if (options.registerFor) {\n const typeIndex = await this.findOrCreatePrivateTypeIndex();\n\n await container.register(typeIndex, options.registerFor);\n }\n\n return container;\n });\n }\n\n protected async boot(): Promise<void> {\n await Errors.booted;\n\n if (hasLocationQueryParameter('authenticator')) {\n this.setState({\n preferredAuthenticator: getLocationQueryParameter('authenticator') as AuthenticatorName,\n });\n }\n\n if (hasLocationQueryParameter('refreshProfile')) {\n this.setState({\n staleProfiles: arrayUnique(\n this.staleProfiles.concat(arrayFilter([this.session?.user.webId, this.previousSession?.loginUrl])),\n ),\n });\n }\n\n await this.restorePreviousSession();\n await this.startupReconnect();\n }\n\n protected async createPrivateTypeIndex(): Promise<SolidTypeIndex> {\n const user = this.requireUser();\n const authenticator = this.requireAuthenticator();\n const typeIndex = await SolidTypeIndex.withEngine(authenticator.engine).createPrivate(user);\n\n return tap(typeIndex, () => {\n user.privateTypeIndexUrl = typeIndex.url;\n\n setAsyncMemo(`${user.webId}-privateTypeIndex`, typeIndex);\n\n this.rememberProfile(user);\n });\n }\n\n public async createPublicTypeIndex(): Promise<SolidTypeIndex> {\n const user = this.requireUser();\n const authenticator = this.requireAuthenticator();\n const typeIndex = await SolidTypeIndex.withEngine(authenticator.engine).createPublic(user);\n\n return tap(typeIndex, () => {\n user.privateTypeIndexUrl = typeIndex.url;\n\n setAsyncMemo(`${user.webId}-publicTypeIndex`, typeIndex);\n\n this.rememberProfile(user);\n });\n }\n\n private async restorePreviousSession(): Promise<void> {\n if (!this.previousSession) {\n return;\n }\n\n await this.bootAuthenticator(this.previousSession.authenticator);\n }\n\n private async startupReconnect(): Promise<void> {\n if (!this.reconnectOnStartup()) {\n return;\n }\n\n await this.reconnect();\n }\n\n private reconnectOnStartup(): boolean {\n if (hasLocationQueryParameter('autoReconnect')) {\n return parseBoolean(getLocationQueryParameter('autoReconnect'));\n }\n\n return this.autoReconnect;\n }\n\n private async bootAuthenticator(name: AuthenticatorName): Promise<Authenticator> {\n const authenticator = getAuthenticator(name);\n\n authenticator.addListener({\n onSessionStarted: async (session) => {\n this.setState({\n session,\n previousSession: {\n authenticator: authenticator.name,\n loginUrl: session.loginUrl,\n profile: session.user,\n error: null,\n },\n });\n\n if (\n session.user.cloaked ||\n !session.user.writableProfileUrl ||\n this.staleProfiles.includes(session.user.webId)\n ) {\n await this.refreshUserProfile();\n }\n\n App.plugin('@aerogel/offline-first') || setEngine(session.authenticator.engine);\n\n SolidACLAuthorization.setEngine(session.authenticator.engine);\n SolidTypeIndex.setEngine(session.authenticator.engine);\n SolidDocument.setEngine(session.authenticator.engine);\n\n await Events.emit('auth:login', session);\n },\n onSessionFailed: async (loginUrl, error) => {\n this.setState({\n session: null,\n previousSession: {\n authenticator: authenticator.name,\n loginUrl,\n error,\n },\n });\n },\n onSessionEnded: () => this.setState({ session: null }),\n onAuthenticatedFetchReady: (fetch) => Events.emit('auth:fetch-ready', fetch),\n });\n\n await authenticator.boot();\n\n return authenticator;\n }\n\n private rememberProfile(profile: SolidUserProfile): void {\n this.setState({\n profiles: {\n ...this.profiles,\n [profile.webId]: profile,\n },\n staleProfiles: arrayWithout(this.staleProfiles, profile.webId),\n });\n }\n\n}\n\nexport default facade(SolidService);\n\ndeclare module '@aerogel/core' {\n export interface EventsPayload {\n 'auth:fetch-ready': Fetch;\n 'auth:before-login': void;\n 'auth:login': AuthSession;\n 'auth:logout': void;\n 'auth:after-logout': void;\n }\n}\n","<template>\n <img :src=\"sourceUrl\">\n</template>\n\n<script setup lang=\"ts\">\nimport { Cache, computedAsync, requiredStringProp } from '@aerogel/core';\n\nimport Solid from '@/services/Solid';\n\nconst props = defineProps({ src: requiredStringProp() });\nconst sourceUrl = computedAsync(async () => {\n const cachedResponse = (await Cache.get(props.src)) ?? (await downloadImage(props.src));\n const blob = await cachedResponse?.blob();\n\n return blob && URL.createObjectURL(blob);\n});\n\nasync function downloadImage(url: string) {\n try {\n const response = await Solid.fetch(url);\n\n if (response.status !== 200) {\n return null;\n }\n\n await Cache.store(url, response);\n\n return Cache.get(url);\n } catch (error) {\n return null;\n }\n}\n</script>\n","<template>\n <div>\n <slot v-if=\"$solid.loginStale\" name=\"login-stale\">\n <AGMarkdown :text=\"$td('solid.loginStale', 'This is taking too long...')\" />\n </slot>\n\n <slot v-if=\"$solid.loginOngoing\" name=\"login-ongoing\">\n <AGMarkdown :text=\"$td('ui.loading', 'Loading...')\" />\n </slot>\n\n <slot v-else-if=\"$solid.isLoggedIn()\" name=\"logged-in\" :session=\"$solid.session\">\n <div class=\"flex flex-col gap-3\">\n <AGMarkdown\n :text=\"\n $td('solid.loggedIn', 'You are logged in as [{userName}]({userWebId})', {\n userName: $solid.user.name ?? $solid.user.webId,\n userWebId: $solid.user.webId,\n })\n \"\n />\n <AGButton @click=\"$solid.logout()\">\n {{ $td('solid.logout', 'Logout') }}\n </AGButton>\n </div>\n </slot>\n\n <slot v-else name=\"logged-out\">\n <div class=\"flex flex-col\">\n <AGForm :form=\"form\" class=\"flex\" @submit=\"$solid.login(form.url)\">\n <AGInput\n name=\"url\"\n :aria-label=\"$td('solid.url', 'Login url')\"\n :placeholder=\"$td('solid.placeholder', 'https://...')\"\n />\n <AGButton submit>\n {{ $td('solid.login', 'Login') }}\n </AGButton>\n </AGForm>\n <AGButton v-if=\"$solid.wasLoggedIn()\" class=\"mt-3\" @click=\"$solid.reconnect({ force: true })\">\n {{ $td('solid.reconnect', 'Reconnect') }}\n </AGButton>\n <AGMarkdown\n v-if=\"$solid.previousSession?.error\"\n class=\"mt-1 self-center text-sm text-red-800\"\n :text=\"$td('solid.previousLoginError', 'Previous login attempt failed')\"\n />\n </div>\n </slot>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { AGButton, AGForm, AGInput, AGMarkdown, requiredStringInput, useForm } from '@aerogel/core';\n\nconst form = useForm({ url: requiredStringInput() });\n</script>\n","<template>\n <div class=\"relative flex items-center justify-center rounded-full bg-gray-200\">\n <AGSolidImage\n v-if=\"$solid.user?.avatarUrl\"\n :src=\"$solid.user?.avatarUrl\"\n alt=\"\"\n class=\"absolute inset-0 h-full w-full rounded-full\"\n />\n <span v-else-if=\"userInitials\" class=\"text-sm font-semibold tracking-wider text-gray-500\" aria-hidden=\"true\">\n {{ userInitials }}\n </span>\n <IconAnonymous v-else class=\"h-6 w-6 text-gray-500\" />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport IconAnonymous from '~icons/ooui/user-anonymous';\n\nimport { computed } from 'vue';\n\nimport Solid from '@/services/Solid';\n\nimport AGSolidImage from './AGSolidImage.vue';\n\nconst userInitials = computed(() => {\n const name = Solid.user?.name ?? '';\n\n return name\n .trim()\n .split(' ')\n .map((part) => part[0]?.toUpperCase())\n .join('')\n .slice(0, 3);\n});\n</script>\n","import { bootServices } from '@aerogel/core';\nimport { bootSolidModels } from 'soukai-solid';\nimport type { Plugin } from '@aerogel/core';\n\nimport Solid from '@/services/Solid';\nimport { DEFAULT_STATE } from '@/services/Solid.state';\nimport {\n authenticators as baseAuthenticators,\n getAuthenticator,\n registerAuthenticators,\n setDefaultAuthenticator,\n} from '@/auth';\nimport type Authenticator from '@/auth/Authenticator';\nimport type { AuthenticatorName } from '@/auth';\n\nconst services = { $solid: Solid };\n\nexport * from './auth';\nexport * from './components';\nexport * from './errors';\nexport * from './services/Solid';\nexport { Solid };\n\nexport interface Options {\n autoReconnect?: boolean;\n authenticators?: Record<string, Authenticator>;\n defaultAuthenticator?: AuthenticatorName;\n}\n\nexport type SolidServices = typeof services;\n\nexport default function solid(options: Options = {}): Plugin {\n return {\n async install(app) {\n bootSolidModels();\n registerAuthenticators({ ...baseAuthenticators, ...(options.authenticators ?? {}) });\n setDefaultAuthenticator(getAuthenticator(options.defaultAuthenticator ?? 'inrupt'));\n\n if (typeof options.autoReconnect === 'boolean') {\n DEFAULT_STATE.autoReconnect = options.autoReconnect;\n\n Solid.hasPersistedState() || (Solid.autoReconnect = options.autoReconnect);\n }\n\n await bootServices(app, services);\n },\n };\n}\n\ndeclare module '@vue/runtime-core' {\n interface ComponentCustomProperties extends SolidServices {}\n}\n"],"names":["AuthenticationCancelledError","JSError","AuthenticationFailedError","constructor","message","description","options","super","_defineProperty","this","ContainerAlreadyInUse","container","url","Authenticator","arr","engine","_engine","SolidEngine","requireAuthenticatedFetch","getAuthenticatedFetch","authenticatedFetch","fail","addListener","listener","listeners","includes","push","removeListener","remove","boot","booted","PromisedValue","restoreSession","resolve","initAuthenticatedFetch","fetch","notifyListeners","startSession","sessionData","session","authenticator","failSession","loginUrl","error","endSession","event","_len","arguments","length","payload","Array","_key","Promise","all","toArray","map","async","callback","STORAGE_KEY","_authenticators","authenticators","inrupt","login","Storage","set","oidcIssuer","AerogelSolid","clientID","clientId","client_id","clientName","client_name","redirectUrl","redirect_uris","_login","after","seconds","logout","_logout","events","handleIncomingRedirect","import","_fetch","_events","_handleIncomingRedirect","loginFromRedirect","get","on","errorDescription","globalThis","location","href","isLoggedIn","webId","initSession","default","Solid","then","Solid$1","user","requireUserProfile","setDefaultAuthenticator","getAuthenticator","name","registerAuthenticators","customAuthenticators","Object","entries","forEach","_ref","registerAuthenticator","DEFAULT_STATE","autoReconnect","Service","defineServiceState","persist","initialState","dismissed","ignorePreviousSessionError","loginStartupError","loginOngoing","preferredAuthenticator","previousSession","profiles","loginStale","staleProfiles","serialize","state","Error","computed","profile","bind","SolidService","wasLoggedIn","hasLoggedIn","requireAuthenticator","requireUser","getUserProfile","required","tap","fetchLoginUserProfile","rememberProfile","refreshUserProfile","setState","objectWithout","authenticatorName","handleLoginError","onError","App","isMounted","Errors","report","development","test","fallbackUrl","staleTimeout","setTimeout","oidcIssuerUrl","urlRoot","bootAuthenticator","domain","loginDomain","requireUrlParse","objectWithoutEmpty","translateWithDefault","Events","emit","clearTimeout","reconnect","undefined","force","loginOptions","UI","confirm","acceptText","acceptColor","Colors","Danger","cancelText","loading","whenLoggedIn","once","dismiss","findOrCreatePrivateTypeIndex","findPrivateTypeIndex","createPrivateTypeIndex","privateTypeIndexUrl","asyncMemo","SolidTypeIndex","withEngine","find","findOrCreatePublicTypeIndex","findPublicTypeIndex","createPublicTypeIndex","publicTypeIndexUrl","createPrivateContainer","SolidContainer","existingContainer","reuseExisting","save","registerFor","typeIndex","register","hasLocationQueryParameter","getLocationQueryParameter","arrayUnique","concat","arrayFilter","restorePreviousSession","startupReconnect","createPrivate","setAsyncMemo","createPublic","reconnectOnStartup","parseBoolean","onSessionStarted","cloaked","writableProfileUrl","plugin","setEngine","SolidACLAuthorization","SolidDocument","onSessionFailed","onSessionEnded","onAuthenticatedFetchReady","arrayWithout","facade","props","__props","sourceUrl","computedAsync","cachedResponse","Cache","src","response","status","store","downloadImage","blob","URL","createObjectURL","form","useForm","requiredStringInput","userInitials","trim","split","part","toUpperCase","join","slice","services","$solid","solid","install","app","bootSolidModels","baseAuthenticators","defaultAuthenticator","hasPersistedState","bootServices"],"mappings":"kxDAEqB,MAAAA,qCAAqCC,GCCrC,MAAAC,kCAAkCD,EAInDE,WAAAA,CAAYC,EAAiBC,EAA6BC,G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AC9EyC,GAAwBC,GAAiBhG,EAAQ4P,sBAAwB,WAEpC,kBAA1B5P,EAAQ0G,gBACfD,GAAcC,cAAgB1G,EAAQ0G,cAEtChB,GAAMmK,sBAAwBnK,GAAMgB,cAAgB1G,EAAQ0G,sBAG1DoJ,EAAaL,EAAKJ,GAC5B,EAER"}
@@ -0,0 +1,5 @@
1
+ /** @type {import('@noeldemartin/scripts').Config} */
2
+ module.exports = {
3
+ vue: true,
4
+ icons: true,
5
+ };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@aerogel/plugin-solid",
3
+ "description": "Aerogel Solid plugin",
4
+ "version": "0.0.1-next.13b88f634a31caf3669d61e53e7d3fa95e20488c",
5
+ "main": "dist/aerogel-plugin-solid.cjs.js",
6
+ "module": "dist/aerogel-plugin-solid.esm.js",
7
+ "types": "dist/aerogel-plugin-solid.d.ts",
8
+ "sideEffects": false,
9
+ "scripts": {
10
+ "build": "rm dist -rf && npm run build:js && npm run build:types",
11
+ "build:js": "noeldemartin-build-javascript",
12
+ "build:types": "noeldemartin-build-types",
13
+ "publish-next": "noeldemartin-publish-next",
14
+ "lint": "noeldemartin-lint src"
15
+ },
16
+ "engines": {
17
+ "node": ">=18.x"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/NoelDeMartin/aerogeljs.git"
22
+ },
23
+ "keywords": [
24
+ "javascript",
25
+ "aerogel"
26
+ ],
27
+ "author": "Noel De Martin",
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/NoelDeMartin/aerogeljs/issues"
31
+ },
32
+ "peerDependencies": {
33
+ "@aerogel/core": "*",
34
+ "@aerogel/vite": "*",
35
+ "soukai": "*",
36
+ "soukai-solid": "*"
37
+ },
38
+ "dependencies": {
39
+ "@inrupt/solid-client-authn-browser": "^2.1.0",
40
+ "@noeldemartin/solid-utils": "0.4.0-next.30aceafb9d58f505d02a146d8e81f2e3a041b92f",
41
+ "@noeldemartin/utils": "0.5.1-next.82707467527729a9fe7c2155959beb4b5ea30b81",
42
+ "vue": "^3.3.0"
43
+ },
44
+ "eslintConfig": {
45
+ "extends": [
46
+ "@noeldemartin/eslint-config-vue"
47
+ ]
48
+ }
49
+ }
@@ -0,0 +1,123 @@
1
+ import { PromisedValue, arr, fail } from '@noeldemartin/utils';
2
+ import { SolidEngine } from 'soukai-solid';
3
+ import type { Closure, FluentArray, GetClosureArgs } from '@noeldemartin/utils';
4
+ import type { Engine } from 'soukai';
5
+ import type { Fetch } from 'soukai-solid';
6
+ import type { SolidUserProfile } from '@noeldemartin/solid-utils';
7
+ import type { ErrorSource } from '@aerogel/core';
8
+
9
+ import type { AuthenticatorName } from '@/auth';
10
+
11
+ type ListenerEvent = keyof AuthenticatorListener;
12
+ type ListenerEventPayload<
13
+ Event extends ListenerEvent,
14
+ Callback = AuthenticatorListener[Event]
15
+ > = Callback extends Closure ? GetClosureArgs<Callback> : never;
16
+
17
+ export interface AuthSession {
18
+ user: SolidUserProfile;
19
+ loginUrl: string;
20
+ authenticator: Authenticator;
21
+ }
22
+
23
+ export interface AuthenticatorListener {
24
+ onSessionStarted?: (session: AuthSession) => Promise<void> | void;
25
+ onSessionFailed?: (loginUrl: string, error: ErrorSource) => Promise<void> | void;
26
+ onSessionEnded?: () => Promise<void> | void;
27
+ onAuthenticatedFetchReady?: (fetch: Fetch) => Promise<void> | void;
28
+ }
29
+
30
+ export default abstract class Authenticator {
31
+
32
+ public name!: AuthenticatorName;
33
+
34
+ private authenticatedFetch?: Fetch;
35
+ private booted?: PromisedValue<void>;
36
+ private listeners: FluentArray<AuthenticatorListener> = arr<AuthenticatorListener>([]);
37
+ private _engine?: SolidEngine;
38
+
39
+ public abstract login(loginUrl: string, user?: SolidUserProfile): Promise<AuthSession>;
40
+
41
+ public abstract logout(): Promise<void>;
42
+
43
+ public get engine(): Engine {
44
+ this._engine = this._engine ?? new SolidEngine(this.requireAuthenticatedFetch());
45
+
46
+ return this._engine;
47
+ }
48
+
49
+ public getAuthenticatedFetch(): Fetch | null {
50
+ return this.authenticatedFetch ?? null;
51
+ }
52
+
53
+ public requireAuthenticatedFetch(): Fetch {
54
+ return this.authenticatedFetch ?? fail('Authenticated fetch is not ready');
55
+ }
56
+
57
+ public addListener(listener: AuthenticatorListener): () => void {
58
+ if (!this.listeners.includes(listener)) this.listeners.push(listener);
59
+
60
+ return () => {
61
+ this.removeListener(listener);
62
+ };
63
+ }
64
+
65
+ public removeListener(listener: AuthenticatorListener): void {
66
+ if (!this.listeners.includes(listener)) return;
67
+
68
+ this.listeners.remove(listener);
69
+ }
70
+
71
+ public async boot(): Promise<void> {
72
+ if (this.booted) {
73
+ return this.booted;
74
+ }
75
+
76
+ this.booted = new PromisedValue();
77
+
78
+ await this.restoreSession();
79
+
80
+ this.booted.resolve();
81
+ }
82
+
83
+ protected abstract restoreSession(): Promise<void>;
84
+
85
+ protected async initAuthenticatedFetch(fetch: Fetch): Promise<void> {
86
+ this.authenticatedFetch = fetch;
87
+
88
+ await this.notifyListeners('onAuthenticatedFetchReady', fetch);
89
+ }
90
+
91
+ protected async startSession(sessionData: Omit<AuthSession, 'authenticator'>): Promise<AuthSession> {
92
+ const session: AuthSession = {
93
+ authenticator: this,
94
+ ...sessionData,
95
+ };
96
+
97
+ await this.notifyListeners('onSessionStarted', session);
98
+
99
+ return session;
100
+ }
101
+
102
+ protected async failSession(loginUrl: string, error: ErrorSource): Promise<void> {
103
+ await this.notifyListeners('onSessionFailed', loginUrl, error);
104
+ }
105
+
106
+ protected async endSession(): Promise<void> {
107
+ await this.notifyListeners('onSessionEnded');
108
+ }
109
+
110
+ protected async notifyListeners<Event extends ListenerEvent>(
111
+ event: Event,
112
+ ...payload: ListenerEventPayload<Event>
113
+ ): Promise<void> {
114
+ await Promise.all(
115
+ this.listeners.toArray().map(async (listener) => {
116
+ const callback = listener[event] as Closure | undefined;
117
+
118
+ await callback?.(...payload);
119
+ }),
120
+ );
121
+ }
122
+
123
+ }
@@ -0,0 +1 @@
1
+ export { events, fetch, handleIncomingRedirect, login, logout } from '@inrupt/solid-client-authn-browser';
@@ -0,0 +1,99 @@
1
+ import { Storage, after, fail } from '@noeldemartin/utils';
2
+ import type { Fetch } from 'soukai-solid';
3
+ import type {
4
+ ILoginInputOptions,
5
+ events,
6
+ handleIncomingRedirect,
7
+ login,
8
+ logout,
9
+ } from '@inrupt/solid-client-authn-browser';
10
+
11
+ import Authenticator from '@/auth/Authenticator';
12
+ import AuthenticationFailedError from '@/errors/AuthenticationFailedError';
13
+ import type { AuthSession } from '@/auth/Authenticator';
14
+
15
+ import AerogelSolid from 'virtual:aerogel-solid';
16
+
17
+ const STORAGE_KEY = 'inrupt-authenticator';
18
+
19
+ export default class InruptAuthenticator extends Authenticator {
20
+
21
+ private _events!: typeof events;
22
+ private _fetch!: Fetch;
23
+ private _login!: typeof login;
24
+ private _logout!: typeof logout;
25
+ private _handleIncomingRedirect!: typeof handleIncomingRedirect;
26
+
27
+ public async login(loginUrl: string): Promise<AuthSession> {
28
+ Storage.set<string>(STORAGE_KEY, loginUrl);
29
+
30
+ const options: ILoginInputOptions = {
31
+ oidcIssuer: loginUrl,
32
+ };
33
+
34
+ if (AerogelSolid.clientID) {
35
+ options.clientId = AerogelSolid.clientID.client_id;
36
+ options.clientName = AerogelSolid.clientID.client_name;
37
+ options.redirectUrl = AerogelSolid.clientID.redirect_uris[0];
38
+ }
39
+
40
+ await this._login(options);
41
+
42
+ // Browser should redirect, so just make it wait for a while.
43
+ await after({ seconds: 60 });
44
+
45
+ return fail('Browser should have redirected, but it didn\'t');
46
+ }
47
+
48
+ public async logout(): Promise<void> {
49
+ await this._logout();
50
+ await this.endSession();
51
+ }
52
+
53
+ protected async restoreSession(): Promise<void> {
54
+ const { events, fetch, handleIncomingRedirect, login, logout } = await import('./InruptAuthenticator.lazy');
55
+
56
+ this._fetch = fetch;
57
+ this._login = login;
58
+ this._logout = logout;
59
+ this._events = events;
60
+ this._handleIncomingRedirect = handleIncomingRedirect;
61
+
62
+ await this.loginFromRedirect();
63
+ }
64
+
65
+ protected async loginFromRedirect(): Promise<void> {
66
+ const loginUrl = Storage.get<string>(STORAGE_KEY);
67
+ if (!loginUrl) {
68
+ return;
69
+ }
70
+
71
+ this._events().on('error', (error: string | null, errorDescription?: string | null) => {
72
+ error ??= 'Error using Inrupt Authenticator method';
73
+
74
+ this.failSession(loginUrl, new AuthenticationFailedError(error, errorDescription));
75
+ });
76
+
77
+ const session = await this._handleIncomingRedirect(globalThis.location.href);
78
+
79
+ Storage.remove(STORAGE_KEY);
80
+
81
+ if (session?.isLoggedIn && session.webId) {
82
+ await this.initSession(session.webId);
83
+ }
84
+ }
85
+
86
+ protected async initSession(webId: string): Promise<void> {
87
+ await this.initAuthenticatedFetch(this._fetch);
88
+
89
+ try {
90
+ const { default: Solid } = await import('@/services/Solid');
91
+ const user = await Solid.requireUserProfile(webId);
92
+
93
+ await this.startSession({ user, loginUrl: webId });
94
+ } catch (error) {
95
+ await this.failSession(webId, error);
96
+ }
97
+ }
98
+
99
+ }
@@ -0,0 +1,38 @@
1
+ import InruptAuthenticator from './authenticators/InruptAuthenticator';
2
+ import type Authenticator from './Authenticator';
3
+
4
+ const _authenticators = {} as Authenticators;
5
+
6
+ type BaseAuthenticators = typeof authenticators;
7
+
8
+ export * from './Authenticator';
9
+ export { Authenticator };
10
+
11
+ export const authenticators = {
12
+ inrupt: new InruptAuthenticator(),
13
+ };
14
+
15
+ export function setDefaultAuthenticator(authenticator: Authenticator): void {
16
+ _authenticators.default = authenticator;
17
+ }
18
+
19
+ export function getAuthenticator<T extends AuthenticatorName>(name: T): Authenticators[T] {
20
+ return _authenticators[name];
21
+ }
22
+
23
+ export function registerAuthenticators(customAuthenticators: Record<string, Authenticator>): void {
24
+ Object.entries(customAuthenticators).forEach(([name, authenticator]) =>
25
+ registerAuthenticator(name as AuthenticatorName, authenticator));
26
+ }
27
+
28
+ export function registerAuthenticator<T extends AuthenticatorName>(name: T, authenticator: Authenticators[T]): void {
29
+ _authenticators[name] = authenticator;
30
+
31
+ authenticator.name = authenticator.name ?? name;
32
+ }
33
+
34
+ export type AuthenticatorName = keyof Authenticators;
35
+
36
+ export interface Authenticators extends BaseAuthenticators {
37
+ default: Authenticator;
38
+ }
@@ -0,0 +1,33 @@
1
+ <template>
2
+ <img :src="sourceUrl">
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { Cache, computedAsync, requiredStringProp } from '@aerogel/core';
7
+
8
+ import Solid from '@/services/Solid';
9
+
10
+ const props = defineProps({ src: requiredStringProp() });
11
+ const sourceUrl = computedAsync(async () => {
12
+ const cachedResponse = (await Cache.get(props.src)) ?? (await downloadImage(props.src));
13
+ const blob = await cachedResponse?.blob();
14
+
15
+ return blob && URL.createObjectURL(blob);
16
+ });
17
+
18
+ async function downloadImage(url: string) {
19
+ try {
20
+ const response = await Solid.fetch(url);
21
+
22
+ if (response.status !== 200) {
23
+ return null;
24
+ }
25
+
26
+ await Cache.store(url, response);
27
+
28
+ return Cache.get(url);
29
+ } catch (error) {
30
+ return null;
31
+ }
32
+ }
33
+ </script>
@@ -0,0 +1,5 @@
1
+ import type { AuthSession } from '@/auth/Authenticator';
2
+
3
+ export interface IAGSolidStatusLoggedInSlotProps {
4
+ session: AuthSession;
5
+ }
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <div>
3
+ <slot v-if="$solid.loginStale" name="login-stale">
4
+ <AGMarkdown :text="$td('solid.loginStale', 'This is taking too long...')" />
5
+ </slot>
6
+
7
+ <slot v-if="$solid.loginOngoing" name="login-ongoing">
8
+ <AGMarkdown :text="$td('ui.loading', 'Loading...')" />
9
+ </slot>
10
+
11
+ <slot v-else-if="$solid.isLoggedIn()" name="logged-in" :session="$solid.session">
12
+ <div class="flex flex-col gap-3">
13
+ <AGMarkdown
14
+ :text="
15
+ $td('solid.loggedIn', 'You are logged in as [{userName}]({userWebId})', {
16
+ userName: $solid.user.name ?? $solid.user.webId,
17
+ userWebId: $solid.user.webId,
18
+ })
19
+ "
20
+ />
21
+ <AGButton @click="$solid.logout()">
22
+ {{ $td('solid.logout', 'Logout') }}
23
+ </AGButton>
24
+ </div>
25
+ </slot>
26
+
27
+ <slot v-else name="logged-out">
28
+ <div class="flex flex-col">
29
+ <AGForm :form="form" class="flex" @submit="$solid.login(form.url)">
30
+ <AGInput
31
+ name="url"
32
+ :aria-label="$td('solid.url', 'Login url')"
33
+ :placeholder="$td('solid.placeholder', 'https://...')"
34
+ />
35
+ <AGButton submit>
36
+ {{ $td('solid.login', 'Login') }}
37
+ </AGButton>
38
+ </AGForm>
39
+ <AGButton v-if="$solid.wasLoggedIn()" class="mt-3" @click="$solid.reconnect({ force: true })">
40
+ {{ $td('solid.reconnect', 'Reconnect') }}
41
+ </AGButton>
42
+ <AGMarkdown
43
+ v-if="$solid.previousSession?.error"
44
+ class="mt-1 self-center text-sm text-red-800"
45
+ :text="$td('solid.previousLoginError', 'Previous login attempt failed')"
46
+ />
47
+ </div>
48
+ </slot>
49
+ </div>
50
+ </template>
51
+
52
+ <script setup lang="ts">
53
+ import { AGButton, AGForm, AGInput, AGMarkdown, requiredStringInput, useForm } from '@aerogel/core';
54
+
55
+ const form = useForm({ url: requiredStringInput() });
56
+ </script>
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <div class="relative flex items-center justify-center rounded-full bg-gray-200">
3
+ <AGSolidImage
4
+ v-if="$solid.user?.avatarUrl"
5
+ :src="$solid.user?.avatarUrl"
6
+ alt=""
7
+ class="absolute inset-0 h-full w-full rounded-full"
8
+ />
9
+ <span v-else-if="userInitials" class="text-sm font-semibold tracking-wider text-gray-500" aria-hidden="true">
10
+ {{ userInitials }}
11
+ </span>
12
+ <IconAnonymous v-else class="h-6 w-6 text-gray-500" />
13
+ </div>
14
+ </template>
15
+
16
+ <script setup lang="ts">
17
+ import IconAnonymous from '~icons/ooui/user-anonymous';
18
+
19
+ import { computed } from 'vue';
20
+
21
+ import Solid from '@/services/Solid';
22
+
23
+ import AGSolidImage from './AGSolidImage.vue';
24
+
25
+ const userInitials = computed(() => {
26
+ const name = Solid.user?.name ?? '';
27
+
28
+ return name
29
+ .trim()
30
+ .split(' ')
31
+ .map((part) => part[0]?.toUpperCase())
32
+ .join('')
33
+ .slice(0, 3);
34
+ });
35
+ </script>
@@ -0,0 +1,6 @@
1
+ import AGSolidImage from './AGSolidImage.vue';
2
+ import AGSolidStatus from './AGSolidStatus.vue';
3
+ import AGSolidUserAvatar from './AGSolidUserAvatar.vue';
4
+ import { IAGSolidStatusLoggedInSlotProps } from './AGSolidStatus';
5
+
6
+ export { AGSolidImage, AGSolidStatus, AGSolidUserAvatar, IAGSolidStatusLoggedInSlotProps };
@@ -0,0 +1,3 @@
1
+ import { JSError } from '@noeldemartin/utils';
2
+
3
+ export default class AuthenticationCancelledError extends JSError {}
@@ -0,0 +1,14 @@
1
+ import { JSError } from '@noeldemartin/utils';
2
+ import type { JSErrorOptions } from '@noeldemartin/utils';
3
+
4
+ export default class AuthenticationFailedError extends JSError {
5
+
6
+ public readonly description?: string | null;
7
+
8
+ constructor(message: string, description?: string | null, options?: JSErrorOptions) {
9
+ super(message, options);
10
+
11
+ this.description = description;
12
+ }
13
+
14
+ }
@@ -0,0 +1,11 @@
1
+ import { JSError } from '@noeldemartin/utils';
2
+ import type { JSErrorOptions } from '@noeldemartin/utils';
3
+ import type { SolidContainer } from 'soukai-solid';
4
+
5
+ export default class ContainerAlreadyInUse extends JSError {
6
+
7
+ constructor(container: SolidContainer, options?: JSErrorOptions) {
8
+ super(`Container at ${container.url} is already in use`, options);
9
+ }
10
+
11
+ }
@@ -0,0 +1,3 @@
1
+ export { default as AuthenticationCancelledError } from '@/errors/AuthenticationCancelledError';
2
+ export { default as AuthenticationFailedError } from '@/errors/AuthenticationFailedError';
3
+ export { default as ContainerAlreadyInUse } from '@/errors/ContainerAlreadyInUse';