@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,2 @@
1
+ "use strict";var e=require("@inrupt/solid-client-authn-browser");Object.defineProperty(exports,"events",{enumerable:!0,get:function(){return e.events}}),Object.defineProperty(exports,"fetch",{enumerable:!0,get:function(){return e.fetch}}),Object.defineProperty(exports,"handleIncomingRedirect",{enumerable:!0,get:function(){return e.handleIncomingRedirect}}),Object.defineProperty(exports,"login",{enumerable:!0,get:function(){return e.login}}),Object.defineProperty(exports,"logout",{enumerable:!0,get:function(){return e.logout}});
2
+ //# sourceMappingURL=InruptAuthenticator.lazy.hash.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InruptAuthenticator.lazy.hash.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export{events,fetch,handleIncomingRedirect,login,logout}from"@inrupt/solid-client-authn-browser";
2
+ //# sourceMappingURL=InruptAuthenticator.lazy.hash.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InruptAuthenticator.lazy.hash.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@aerogel/core"),t=require("soukai-solid");require("core-js/modules/esnext.async-iterator.find.js"),require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.find.js");var i=require("@noeldemartin/utils"),r=require("@noeldemartin/solid-utils"),o=require("soukai"),s=require("@babel/runtime/helpers/defineProperty");require("core-js/modules/esnext.async-iterator.for-each.js"),require("core-js/modules/esnext.iterator.for-each.js"),require("core-js/modules/esnext.async-iterator.map.js"),require("core-js/modules/esnext.iterator.map.js"),require("core-js/modules/esnext.async-iterator.constructor.js"),require("core-js/modules/esnext.async-iterator.to-array.js"),require("core-js/modules/esnext.iterator.to-array.js");var n=require("virtual:aerogel-solid"),a=require("vue");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=l(s),c=l(n);class AuthenticationCancelledError extends i.JSError{}class AuthenticationFailedError extends i.JSError{constructor(e,t,i){super(e,i),u.default(this,"description",void 0),this.description=t}}class d extends i.JSError{constructor(e,t){super(`Container at ${e.url} is already in use`,t)}}class h{constructor(){u.default(this,"name",void 0),u.default(this,"authenticatedFetch",void 0),u.default(this,"booted",void 0),u.default(this,"listeners",i.arr([])),u.default(this,"_engine",void 0)}get engine(){return this._engine=this._engine??new t.SolidEngine(this.requireAuthenticatedFetch()),this._engine}getAuthenticatedFetch(){return this.authenticatedFetch??null}requireAuthenticatedFetch(){return this.authenticatedFetch??i.fail("Authenticated fetch is not ready")}addListener(e){return this.listeners.includes(e)||this.listeners.push(e),()=>{this.removeListener(e)}}removeListener(e){this.listeners.includes(e)&&this.listeners.remove(e)}async boot(){if(this.booted)return this.booted;this.booted=new i.PromisedValue,await this.restoreSession(),this.booted.resolve()}async initAuthenticatedFetch(e){this.authenticatedFetch=e,await this.notifyListeners("onAuthenticatedFetchReady",e)}async startSession(e){const t={authenticator:this,...e};return await this.notifyListeners("onSessionStarted",t),t}async failSession(e,t){await this.notifyListeners("onSessionFailed",e,t)}async endSession(){await this.notifyListeners("onSessionEnded")}async notifyListeners(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];await Promise.all(this.listeners.toArray().map((async t=>{const r=t[e];await(r?.(...i))})))}}const g="inrupt-authenticator";const f={},p={inrupt:new class extends h{constructor(){super(...arguments),u.default(this,"_events",void 0),u.default(this,"_fetch",void 0),u.default(this,"_login",void 0),u.default(this,"_logout",void 0),u.default(this,"_handleIncomingRedirect",void 0)}async login(e){i.Storage.set(g,e);const t={oidcIssuer:e};return c.default.clientID&&(t.clientId=c.default.clientID.client_id,t.clientName=c.default.clientID.client_name,t.redirectUrl=c.default.clientID.redirect_uris[0]),await this._login(t),await i.after({seconds:60}),i.fail("Browser should have redirected, but it didn't")}async logout(){await this._logout(),await this.endSession()}async restoreSession(){const{events:e,fetch:t,handleIncomingRedirect:i,login:r,logout:o}=await Promise.resolve().then((function(){return require("./InruptAuthenticator.lazy.hash.cjs.js")}));this._fetch=t,this._login=r,this._logout=o,this._events=e,this._handleIncomingRedirect=i,await this.loginFromRedirect()}async loginFromRedirect(){const e=i.Storage.get(g);if(!e)return;this._events().on("error",((t,i)=>{t??="Error using Inrupt Authenticator method",this.failSession(e,new AuthenticationFailedError(t,i))}));const t=await this._handleIncomingRedirect(globalThis.location.href);i.Storage.remove(g),t?.isLoggedIn&&t.webId&&await this.initSession(t.webId)}async initSession(e){await this.initAuthenticatedFetch(this._fetch);try{const{default:t}=await Promise.resolve().then((function(){return A})),i=await t.requireUserProfile(e);await this.startSession({user:i,loginUrl:e})}catch(t){await this.failSession(e,t)}}}};function m(e){f.default=e}function y(e){return f[e]}function v(e){Object.entries(e).forEach((e=>{let[t,i]=e;return S(t,i)}))}function S(e,t){f[e]=t,t.name=t.name??e}const w={autoReconnect:!0};var x=e.defineServiceState({name:"solid",persist:["autoReconnect","dismissed","previousSession","profiles","staleProfiles"],initialState:{autoReconnect:w.autoReconnect,dismissed:!1,ignorePreviousSessionError:!1,loginStartupError:null,loginOngoing:!1,preferredAuthenticator:null,previousSession:null,profiles:{},session:null,loginStale:!1,staleProfiles:[]},serialize:e=>(e.previousSession?.error instanceof Error&&(e.previousSession.error=e.previousSession.error.message),e),computed:{user:e=>e.session?.user??e.previousSession?.profile??null,authenticator:e=>e.session?.authenticator??null,fetch(){return this.authenticator?.getAuthenticatedFetch()??globalThis.fetch.bind(globalThis)},error:e=>e.loginStartupError?e.loginStartupError??null:e.ignorePreviousSessionError?null:e.previousSession?.error??null}});class b extends x{isLoggedIn(){return!!this.session}wasLoggedIn(){return!!this.previousSession}hasLoggedIn(){return!(!this.session&&!this.previousSession)}requireAuthenticator(){return this.authenticator??i.fail("Could not get authenticator")}requireUser(){return this.user??i.fail("Could not get user profile (are you logged in?)")}requireUserProfile(e){return this.getUserProfile(e,!0)}async getUserProfile(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.profiles[e]??i.tap(await r.fetchLoginUserProfile(e,{fetch:this.fetch,required:t}),(e=>e&&this.rememberProfile(e)))}async refreshUserProfile(){if(!this.isLoggedIn())return;this.setState({profiles:i.objectWithout(this.profiles,[this.user.webId])});const e=await this.requireUserProfile(this.user.webId);this.setState({session:{...this.session,user:e}})}async login(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=r.authenticator??this.preferredAuthenticator??"default",s=r.onError??(t=>e.App.isMounted()?e.Errors.report(t):this.setState({loginStartupError:t}));if(e.App.development&&"devserver"===t&&(t="http://localhost:3000"),/^https?:\/\//.test(t)||(r.fallbackUrl??=`http://${t}`,t=`https://${t}`),this.isLoggedIn())return!0;if(this.loginOngoing)throw new Error("Authentication already in progress");const n=setTimeout((()=>this.loginStale=!0),1e4),a={dismissed:this.dismissed,ignorePreviousSessionError:this.ignorePreviousSessionError,previousSession:this.previousSession};this.loginOngoing=!0;try{const r=await this.getUserProfile(t),s=r?.oidcIssuerUrl??i.urlRoot(r?.webId??t),n=await this.bootAuthenticator(o),{domain:a}=i.requireUrlParse(t);return this.setState({dismissed:!1,ignorePreviousSessionError:!0,previousSession:i.objectWithoutEmpty({profile:r,loginUrl:t,authenticator:o,error:e.translateWithDefault("auth.stuckConnecting",`We didn't hear back from the identity provider at \`${a}\`, maybe try reconnecting?`)})}),await e.Events.emit("auth:before-login"),await n.login(s),!0}catch(e){return this.setState(a),e instanceof AuthenticationCancelledError?!1:r.fallbackUrl?i.after().then((()=>this.login(r.fallbackUrl??"",i.objectWithout(r,"fallbackUrl")))):(s(e),!1)}finally{clearTimeout(n),this.setState({loginOngoing:!1,loginStale:!1})}}async reconnect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{force:t,...i}=e;this.isLoggedIn()||!this.previousSession||null!==this.previousSession.error&&!t||await this.login(this.previousSession.loginUrl,{authenticator:this.previousSession.authenticator,...i})}async logout(){(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||await e.UI.confirm(e.translateWithDefault("solid.logoutConfirmTitle","Log out from this device?"),e.translateWithDefault("solid.logoutConfirmMessage","Logging out will remove all the data from this device, but you'll still have it in your Solid POD."),{acceptText:e.translateWithDefault("solid.logoutConfirmAccept","Log out"),acceptColor:e.Colors.Danger,cancelText:e.translateWithDefault("solid.logoutConfirmCancel",e.translateWithDefault("ui.cancel","Cancel"))}))&&this.previousSession&&await e.UI.loading(e.translateWithDefault("solid.logoutOngoing","Logging out..."),(async()=>{this.setState({previousSession:null,...w}),this.isLoggedIn()&&await this.authenticator.logout(),await e.Events.emit("auth:logout"),await e.Events.emit("auth:after-logout")}))}async whenLoggedIn(t){return this.isLoggedIn()?t(this.session):new Promise((i=>{e.Events.once("auth:login",(e=>i(t(e))))}))}dismiss(){this.setState({dismissed:!0})}async findOrCreatePrivateTypeIndex(){return await this.findPrivateTypeIndex()??await this.createPrivateTypeIndex()}async findPrivateTypeIndex(){const{webId:e,privateTypeIndexUrl:r}=this.requireUser(),o=this.requireAuthenticator().engine;return r?i.asyncMemo(`${e}-privateTypeIndex`,(()=>t.SolidTypeIndex.withEngine(o).find(r))):null}async findOrCreatePublicTypeIndex(){return await this.findPublicTypeIndex()??await this.createPublicTypeIndex()}async findPublicTypeIndex(){const{webId:e,publicTypeIndexUrl:r}=this.requireUser(),o=this.requireAuthenticator().engine;return r?i.asyncMemo(`${e}-publicTypeIndex`,(()=>t.SolidTypeIndex.withEngine(o).find(r))):null}async createPrivateContainer(e){const i=this.requireAuthenticator().engine;return t.SolidContainer.withEngine(i,(async()=>{const i=await t.SolidContainer.find(e.url);if(i&&!e.reuseExisting)throw new d(i);const r=i??new t.SolidContainer({url:e.url,name:e.name});if(await r.save(),e.registerFor){const t=await this.findOrCreatePrivateTypeIndex();await r.register(t,e.registerFor)}return r}))}async boot(){await e.Errors.booted,i.hasLocationQueryParameter("authenticator")&&this.setState({preferredAuthenticator:i.getLocationQueryParameter("authenticator")}),i.hasLocationQueryParameter("refreshProfile")&&this.setState({staleProfiles:i.arrayUnique(this.staleProfiles.concat(i.arrayFilter([this.session?.user.webId,this.previousSession?.loginUrl])))}),await this.restorePreviousSession(),await this.startupReconnect()}async createPrivateTypeIndex(){const e=this.requireUser(),r=this.requireAuthenticator(),o=await t.SolidTypeIndex.withEngine(r.engine).createPrivate(e);return i.tap(o,(()=>{e.privateTypeIndexUrl=o.url,i.setAsyncMemo(`${e.webId}-privateTypeIndex`,o),this.rememberProfile(e)}))}async createPublicTypeIndex(){const e=this.requireUser(),r=this.requireAuthenticator(),o=await t.SolidTypeIndex.withEngine(r.engine).createPublic(e);return i.tap(o,(()=>{e.privateTypeIndexUrl=o.url,i.setAsyncMemo(`${e.webId}-publicTypeIndex`,o),this.rememberProfile(e)}))}async restorePreviousSession(){this.previousSession&&await this.bootAuthenticator(this.previousSession.authenticator)}async startupReconnect(){this.reconnectOnStartup()&&await this.reconnect()}reconnectOnStartup(){return i.hasLocationQueryParameter("autoReconnect")?i.parseBoolean(i.getLocationQueryParameter("autoReconnect")):this.autoReconnect}async bootAuthenticator(i){const r=y(i);return r.addListener({onSessionStarted:async i=>{this.setState({session:i,previousSession:{authenticator:r.name,loginUrl:i.loginUrl,profile:i.user,error:null}}),(i.user.cloaked||!i.user.writableProfileUrl||this.staleProfiles.includes(i.user.webId))&&await this.refreshUserProfile(),e.App.plugin("@aerogel/offline-first")||o.setEngine(i.authenticator.engine),t.SolidACLAuthorization.setEngine(i.authenticator.engine),t.SolidTypeIndex.setEngine(i.authenticator.engine),t.SolidDocument.setEngine(i.authenticator.engine),await e.Events.emit("auth:login",i)},onSessionFailed:async(e,t)=>{this.setState({session:null,previousSession:{authenticator:r.name,loginUrl:e,error:t}})},onSessionEnded:()=>this.setState({session:null}),onAuthenticatedFetchReady:t=>e.Events.emit("auth:fetch-ready",t)}),await r.boot(),r}rememberProfile(e){this.setState({profiles:{...this.profiles,[e.webId]:e},staleProfiles:i.arrayWithout(this.staleProfiles,e.webId)})}}var I=i.facade(b),A=Object.freeze({__proto__:null,SolidService:b,default:I});const P=["src"];var E=a.defineComponent({__name:"AGSolidImage",props:{src:e.requiredStringProp()},setup(t){const i=t,r=e.computedAsync((async()=>{const t=await e.Cache.get(i.src)??await async function(t){try{const i=await I.fetch(t);return 200!==i.status?null:(await e.Cache.store(t,i),e.Cache.get(t))}catch(e){return null}}(i.src),r=await(t?.blob());return r&&URL.createObjectURL(r)}));return(e,t)=>(a.openBlock(),a.createElementBlock("img",{src:a.unref(r)},null,8,P))}});E.__file="src/components/AGSolidImage.vue";const U={class:"flex flex-col gap-3"},k={class:"flex flex-col"};var C=a.defineComponent({__name:"AGSolidStatus",setup(t){const i=e.useForm({url:e.requiredStringInput()});return(t,r)=>(a.openBlock(),a.createElementBlock("div",null,[t.$solid.loginStale?a.renderSlot(t.$slots,"login-stale",{key:0},(()=>[a.createVNode(a.unref(e.AGMarkdown),{text:t.$td("solid.loginStale","This is taking too long...")},null,8,["text"])])):a.createCommentVNode("v-if",!0),t.$solid.loginOngoing?a.renderSlot(t.$slots,"login-ongoing",{key:1},(()=>[a.createVNode(a.unref(e.AGMarkdown),{text:t.$td("ui.loading","Loading...")},null,8,["text"])])):t.$solid.isLoggedIn()?a.renderSlot(t.$slots,"logged-in",{key:2,session:t.$solid.session},(()=>[a.createElementVNode("div",U,[a.createVNode(a.unref(e.AGMarkdown),{text:t.$td("solid.loggedIn","You are logged in as [{userName}]({userWebId})",{userName:t.$solid.user.name??t.$solid.user.webId,userWebId:t.$solid.user.webId})},null,8,["text"]),a.createVNode(a.unref(e.AGButton),{onClick:r[0]||(r[0]=e=>t.$solid.logout())},{default:a.withCtx((()=>[a.createTextVNode(a.toDisplayString(t.$td("solid.logout","Logout")),1)])),_:1})])])):a.renderSlot(t.$slots,"logged-out",{key:3},(()=>[a.createElementVNode("div",k,[a.createVNode(a.unref(e.AGForm),{form:a.unref(i),class:"flex",onSubmit:r[1]||(r[1]=e=>t.$solid.login(a.unref(i).url))},{default:a.withCtx((()=>[a.createVNode(a.unref(e.AGInput),{name:"url","aria-label":t.$td("solid.url","Login url"),placeholder:t.$td("solid.placeholder","https://...")},null,8,["aria-label","placeholder"]),a.createVNode(a.unref(e.AGButton),{submit:""},{default:a.withCtx((()=>[a.createTextVNode(a.toDisplayString(t.$td("solid.login","Login")),1)])),_:1})])),_:1},8,["form"]),t.$solid.wasLoggedIn()?(a.openBlock(),a.createBlock(a.unref(e.AGButton),{key:0,class:"mt-3",onClick:r[2]||(r[2]=e=>t.$solid.reconnect({force:!0}))},{default:a.withCtx((()=>[a.createTextVNode(a.toDisplayString(t.$td("solid.reconnect","Reconnect")),1)])),_:1})):a.createCommentVNode("v-if",!0),t.$solid.previousSession?.error?(a.openBlock(),a.createBlock(a.unref(e.AGMarkdown),{key:1,class:"mt-1 self-center text-sm text-red-800",text:t.$td("solid.previousLoginError","Previous login attempt failed")},null,8,["text"])):a.createCommentVNode("v-if",!0)])]))]))}});C.__file="src/components/AGSolidStatus.vue";const _={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"},q=[a.createElementVNode("path",{fill:"currentColor",d:"M15 2H5L4 8h12zM0 10s2 1 10 1s10-1 10-1l-4-2H4zm8 4h4v1H8z"},null,-1),a.createElementVNode("circle",{cx:"6",cy:"15",r:"3",fill:"currentColor"},null,-1),a.createElementVNode("circle",{cx:"14",cy:"15",r:"3",fill:"currentColor"},null,-1)];var L={name:"ooui-user-anonymous",render:function(e,t){return a.openBlock(),a.createElementBlock("svg",_,[...q])}};const T={class:"relative flex items-center justify-center rounded-full bg-gray-200"},$={key:1,class:"text-sm font-semibold tracking-wider text-gray-500","aria-hidden":"true"};var j=a.defineComponent({__name:"AGSolidUserAvatar",setup(e){const t=a.computed((()=>(I.user?.name??"").trim().split(" ").map((e=>e[0]?.toUpperCase())).join("").slice(0,3)));return(e,i)=>(a.openBlock(),a.createElementBlock("div",T,[e.$solid.user?.avatarUrl?(a.openBlock(),a.createBlock(E,{key:0,src:e.$solid.user?.avatarUrl,alt:"",class:"absolute inset-0 h-full w-full rounded-full"},null,8,["src"])):t.value?(a.openBlock(),a.createElementBlock("span",$,a.toDisplayString(t.value),1)):(a.openBlock(),a.createBlock(a.unref(L),{key:2,class:"h-6 w-6 text-gray-500"}))]))}});j.__file="src/components/AGSolidUserAvatar.vue";const R={$solid:I};exports.AGSolidImage=E,exports.AGSolidStatus=C,exports.AGSolidUserAvatar=j,exports.AuthenticationCancelledError=AuthenticationCancelledError,exports.AuthenticationFailedError=AuthenticationFailedError,exports.ContainerAlreadyInUse=d,exports.Solid=I,exports.SolidService=b,exports.authenticators=p,exports.default=function(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{async install(r){t.bootSolidModels(),v({...p,...i.authenticators??{}}),m(y(i.defaultAuthenticator??"inrupt")),"boolean"==typeof i.autoReconnect&&(w.autoReconnect=i.autoReconnect,I.hasPersistedState()||(I.autoReconnect=i.autoReconnect)),await e.bootServices(r,R)}}},exports.getAuthenticator=y,exports.registerAuthenticator=S,exports.registerAuthenticators=v,exports.setDefaultAuthenticator=m;
2
+ //# sourceMappingURL=aerogel-plugin-solid.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aerogel-plugin-solid.cjs.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","then","require","_fetch","_events","_handleIncomingRedirect","loginFromRedirect","get","on","errorDescription","globalThis","location","href","isLoggedIn","webId","initSession","default","Solid","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","install","app","bootSolidModels","baseAuthenticators","defaultAuthenticator","hasPersistedState","bootServices"],"mappings":"09BAEqB,MAAAA,qCAAqCC,EAAAA,SCCrC,MAAAC,kCAAkCD,EAAAA,QAInDE,WAAAA,CAAYC,EAAiBC,EAA6BC,GACtDC,MAAMH,EAASE,GAASE,EAAAA,QAAAC,KAAA,mBAAA,GAExBA,KAAKJ,YAAcA,CACvB,ECPiB,MAAAK,UAA8BT,EAAAA,QAE/CE,WAAAA,CAAYQ,EAA2BL,GACnCC,sBAAsBI,EAAUC,wBAAyBN,EAC7D,ECqBU,MAAgBO,EAAaV,WAAAA,GAAAK,EAAAA,QAAAC,KAAA,YAAA,GAAAD,EAAAA,QAAAC,KAAA,0BAAA,GAAAD,EAAAA,QAAAC,KAAA,cAAA,GAAAD,EAAAA,QAMiBM,KAAAA,YAAAA,EAAAA,IAA2B,KAAGN,EAAAA,QAAAC,KAAA,eAAA,EAAA,CAOtF,UAAWM,GAGP,OAFAN,KAAKO,QAAUP,KAAKO,SAAW,IAAIC,EAAAA,YAAYR,KAAKS,6BAE7CT,KAAKO,OAChB,CAEOG,qBAAAA,GACH,OAAOV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EAAAA,kBACAvJ,EAAuB,IAAKwJ,KAAwB1P,EAAQsD,gBAAkB,KAC9EyC,EAAwBC,EAAiBhG,EAAQ2P,sBAAwB,WAEpC,kBAA1B3P,EAAQ0G,gBACfD,EAAcC,cAAgB1G,EAAQ0G,cAEtCf,EAAMiK,sBAAwBjK,EAAMe,cAAgB1G,EAAQ0G,sBAG1DmJ,EAAYA,aAACL,EAAKH,EAC5B,EAER"}
@@ -0,0 +1,288 @@
1
+ import type { Closure } from '@noeldemartin/utils';
2
+ import { ComponentOptionsMixin } from 'vue';
3
+ import { Constructor } from '@noeldemartin/utils';
4
+ import { DefineComponent } from 'vue';
5
+ import type { Engine } from 'soukai';
6
+ import type { ErrorSource } from '@aerogel/core';
7
+ import { ExtractPropTypes } from 'vue';
8
+ import { Facade } from '@noeldemartin/utils';
9
+ import type { Fetch } from 'soukai-solid';
10
+ import type { Fetch as Fetch_2 } from '@noeldemartin/solid-utils';
11
+ import type { GetClosureArgs } from '@noeldemartin/utils';
12
+ import { JSError } from '@noeldemartin/utils';
13
+ import type { JSErrorOptions } from '@noeldemartin/utils';
14
+ import type { Plugin as Plugin_2 } from '@aerogel/core';
15
+ import { PropType } from 'vue';
16
+ import { PublicProps } from 'vue';
17
+ import { RendererElement } from 'vue';
18
+ import { RendererNode } from 'vue';
19
+ import { Service } from '@aerogel/core';
20
+ import { SolidContainer } from 'soukai-solid';
21
+ import type { SolidModelConstructor } from 'soukai-solid';
22
+ import { SolidTypeIndex } from 'soukai-solid';
23
+ import type { SolidUserProfile } from '@noeldemartin/solid-utils';
24
+ import { UnrefServiceState } from '@aerogel/core';
25
+ import { VNode } from 'vue';
26
+
27
+ export declare const AGSolidImage: DefineComponent< {
28
+ src: {
29
+ type?: PropType<string> | undefined;
30
+ validator?(value: unknown): boolean;
31
+ } & {
32
+ required: true;
33
+ };
34
+ }, (_ctx: any, _cache: any) => VNode<RendererNode, RendererElement, {
35
+ [key: string]: any;
36
+ }>, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
37
+ src: {
38
+ type?: PropType<string> | undefined;
39
+ validator?(value: unknown): boolean;
40
+ } & {
41
+ required: true;
42
+ };
43
+ }>>, {}, {}>;
44
+
45
+ export declare const AGSolidStatus: DefineComponent< {}, (_ctx: any, _cache: any) => VNode<RendererNode, RendererElement, {
46
+ [key: string]: any;
47
+ }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {}>>, {}, {}>;
48
+
49
+ export declare const AGSolidUserAvatar: DefineComponent< {}, (_ctx: any, _cache: any) => VNode<RendererNode, RendererElement, {
50
+ [key: string]: any;
51
+ }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {}>>, {}, {}>;
52
+
53
+ export declare class AuthenticationCancelledError extends JSError {
54
+ }
55
+
56
+ export declare class AuthenticationFailedError extends JSError {
57
+ readonly description?: string | null;
58
+ constructor(message: string, description?: string | null, options?: JSErrorOptions);
59
+ }
60
+
61
+ export declare abstract class Authenticator {
62
+ name: AuthenticatorName;
63
+ private authenticatedFetch?;
64
+ private booted?;
65
+ private listeners;
66
+ private _engine?;
67
+ abstract login(loginUrl: string, user?: SolidUserProfile): Promise<AuthSession>;
68
+ abstract logout(): Promise<void>;
69
+ get engine(): Engine;
70
+ getAuthenticatedFetch(): Fetch | null;
71
+ requireAuthenticatedFetch(): Fetch;
72
+ addListener(listener: AuthenticatorListener): () => void;
73
+ removeListener(listener: AuthenticatorListener): void;
74
+ boot(): Promise<void>;
75
+ protected abstract restoreSession(): Promise<void>;
76
+ protected initAuthenticatedFetch(fetch: Fetch): Promise<void>;
77
+ protected startSession(sessionData: Omit<AuthSession, 'authenticator'>): Promise<AuthSession>;
78
+ protected failSession(loginUrl: string, error: ErrorSource): Promise<void>;
79
+ protected endSession(): Promise<void>;
80
+ protected notifyListeners<Event extends ListenerEvent>(event: Event, ...payload: ListenerEventPayload<Event>): Promise<void>;
81
+ }
82
+
83
+ export declare interface AuthenticatorListener {
84
+ onSessionStarted?: (session: AuthSession) => Promise<void> | void;
85
+ onSessionFailed?: (loginUrl: string, error: ErrorSource) => Promise<void> | void;
86
+ onSessionEnded?: () => Promise<void> | void;
87
+ onAuthenticatedFetchReady?: (fetch: Fetch) => Promise<void> | void;
88
+ }
89
+
90
+ export declare type AuthenticatorName = keyof Authenticators;
91
+
92
+ export declare interface Authenticators extends BaseAuthenticators {
93
+ default: Authenticator;
94
+ }
95
+
96
+ export declare const authenticators: {
97
+ inrupt: InruptAuthenticator;
98
+ };
99
+
100
+ export declare interface AuthSession {
101
+ user: SolidUserProfile;
102
+ loginUrl: string;
103
+ authenticator: Authenticator;
104
+ }
105
+
106
+ declare type BaseAuthenticators = typeof authenticators;
107
+
108
+ export declare class ContainerAlreadyInUse extends JSError {
109
+ constructor(container: SolidContainer, options?: JSErrorOptions);
110
+ }
111
+
112
+ declare const _default: Constructor<UnrefServiceState< {
113
+ autoReconnect: boolean;
114
+ dismissed: boolean;
115
+ ignorePreviousSessionError: boolean;
116
+ loginStartupError: unknown;
117
+ loginOngoing: boolean;
118
+ preferredAuthenticator: keyof Authenticators | null;
119
+ previousSession: {
120
+ profile?: SolidUserProfile | undefined;
121
+ authenticator: AuthenticatorName;
122
+ loginUrl: string;
123
+ error: ErrorSource | null;
124
+ } | null;
125
+ profiles: Record<string, SolidUserProfile>;
126
+ session: AuthSession | null;
127
+ loginStale: boolean;
128
+ staleProfiles: string[];
129
+ }>> & Constructor< {
130
+ user: SolidUserProfile | null;
131
+ authenticator: Authenticator | null;
132
+ fetch: Fetch_2;
133
+ error: unknown;
134
+ }> & Constructor<Service<UnrefServiceState< {
135
+ autoReconnect: boolean;
136
+ dismissed: boolean;
137
+ ignorePreviousSessionError: boolean;
138
+ loginStartupError: unknown;
139
+ loginOngoing: boolean;
140
+ preferredAuthenticator: keyof Authenticators | null;
141
+ previousSession: {
142
+ profile?: SolidUserProfile | undefined;
143
+ authenticator: AuthenticatorName;
144
+ loginUrl: string;
145
+ error: ErrorSource | null;
146
+ } | null;
147
+ profiles: Record<string, SolidUserProfile>;
148
+ session: AuthSession | null;
149
+ loginStale: boolean;
150
+ staleProfiles: string[];
151
+ }>, {
152
+ user: SolidUserProfile | null;
153
+ authenticator: Authenticator | null;
154
+ fetch: Fetch_2;
155
+ error: unknown;
156
+ }, Partial<UnrefServiceState< {
157
+ autoReconnect: boolean;
158
+ dismissed: boolean;
159
+ ignorePreviousSessionError: boolean;
160
+ loginStartupError: unknown;
161
+ loginOngoing: boolean;
162
+ preferredAuthenticator: keyof Authenticators | null;
163
+ previousSession: {
164
+ profile?: SolidUserProfile | undefined;
165
+ authenticator: AuthenticatorName;
166
+ loginUrl: string;
167
+ error: ErrorSource | null;
168
+ } | null;
169
+ profiles: Record<string, SolidUserProfile>;
170
+ session: AuthSession | null;
171
+ loginStale: boolean;
172
+ staleProfiles: string[];
173
+ }>>>>;
174
+
175
+ export declare function getAuthenticator<T extends AuthenticatorName>(name: T): Authenticators[T];
176
+
177
+ export declare interface IAGSolidStatusLoggedInSlotProps {
178
+ session: AuthSession;
179
+ }
180
+
181
+ declare class InruptAuthenticator extends Authenticator {
182
+ private _events;
183
+ private _fetch;
184
+ private _login;
185
+ private _logout;
186
+ private _handleIncomingRedirect;
187
+ login(loginUrl: string): Promise<AuthSession>;
188
+ logout(): Promise<void>;
189
+ protected restoreSession(): Promise<void>;
190
+ protected loginFromRedirect(): Promise<void>;
191
+ protected initSession(webId: string): Promise<void>;
192
+ }
193
+
194
+ declare type ListenerEvent = keyof AuthenticatorListener;
195
+
196
+ declare type ListenerEventPayload<Event extends ListenerEvent, Callback = AuthenticatorListener[Event]> = Callback extends Closure ? GetClosureArgs<Callback> : never;
197
+
198
+ export declare type LoginOptions = {
199
+ authenticator?: AuthenticatorName;
200
+ onError?(error: ErrorSource): unknown;
201
+ fallbackUrl?: string;
202
+ };
203
+
204
+ export declare interface Options {
205
+ autoReconnect?: boolean;
206
+ authenticators?: Record<string, Authenticator>;
207
+ defaultAuthenticator?: AuthenticatorName;
208
+ }
209
+
210
+ export declare type ReconnectOptions = Omit<LoginOptions, 'authenticator'> & {
211
+ force?: boolean;
212
+ };
213
+
214
+ export declare function registerAuthenticator<T extends AuthenticatorName>(name: T, authenticator: Authenticators[T]): void;
215
+
216
+ export declare function registerAuthenticators(customAuthenticators: Record<string, Authenticator>): void;
217
+
218
+ declare const services: {
219
+ $solid: Facade<SolidService, SolidService>;
220
+ };
221
+
222
+ export declare function setDefaultAuthenticator(authenticator: Authenticator): void;
223
+
224
+ export declare const Solid: Facade<SolidService, SolidService>;
225
+
226
+ declare function solid(options?: Options): Plugin_2;
227
+ export default solid;
228
+
229
+ export declare class SolidService extends _default {
230
+ isLoggedIn(): this is {
231
+ session: AuthSession;
232
+ user: SolidUserProfile;
233
+ authenticator: Authenticator;
234
+ };
235
+ wasLoggedIn(): this is {
236
+ user: SolidUserProfile;
237
+ };
238
+ hasLoggedIn(): this is {
239
+ user: SolidUserProfile;
240
+ };
241
+ requireAuthenticator(): Authenticator;
242
+ requireUser(): SolidUserProfile;
243
+ requireUserProfile(url: string): Promise<SolidUserProfile>;
244
+ getUserProfile(url: string, required: true): Promise<SolidUserProfile>;
245
+ getUserProfile(url: string, required?: false): Promise<SolidUserProfile | null>;
246
+ refreshUserProfile(): Promise<void>;
247
+ login(loginUrl: string, options?: LoginOptions): Promise<boolean>;
248
+ reconnect(options?: ReconnectOptions): Promise<void>;
249
+ logout(force?: boolean): Promise<void>;
250
+ whenLoggedIn<T>(callback: (session: AuthSession) => T): Promise<T>;
251
+ dismiss(): void;
252
+ findOrCreatePrivateTypeIndex(): Promise<SolidTypeIndex>;
253
+ findPrivateTypeIndex(): Promise<SolidTypeIndex | null>;
254
+ findOrCreatePublicTypeIndex(): Promise<SolidTypeIndex>;
255
+ protected findPublicTypeIndex(): Promise<SolidTypeIndex | null>;
256
+ createPrivateContainer(options: {
257
+ url: string;
258
+ name?: string;
259
+ registerFor?: SolidModelConstructor;
260
+ reuseExisting?: boolean;
261
+ }): Promise<SolidContainer>;
262
+ protected boot(): Promise<void>;
263
+ protected createPrivateTypeIndex(): Promise<SolidTypeIndex>;
264
+ createPublicTypeIndex(): Promise<SolidTypeIndex>;
265
+ private restorePreviousSession;
266
+ private startupReconnect;
267
+ private reconnectOnStartup;
268
+ private bootAuthenticator;
269
+ private rememberProfile;
270
+ }
271
+
272
+ export declare type SolidServices = typeof services;
273
+
274
+ export { }
275
+
276
+ declare module '@vue/runtime-core' {
277
+ interface ComponentCustomProperties extends SolidServices {}
278
+ }
279
+
280
+ declare module '@aerogel/core' {
281
+ export interface EventsPayload {
282
+ 'auth:fetch-ready': Fetch;
283
+ 'auth:before-login': void;
284
+ 'auth:login': AuthSession;
285
+ 'auth:logout': void;
286
+ 'auth:after-logout': void;
287
+ }
288
+ }
@@ -0,0 +1,2 @@
1
+ import{defineServiceState as e,App as t,Errors as i,translateWithDefault as s,Events as r,UI as o,Colors as n,requiredStringProp as a,computedAsync as l,Cache as c,useForm as u,requiredStringInput as d,AGMarkdown as h,AGButton as g,AGForm as f,AGInput as p,bootServices as m}from"@aerogel/core";import{SolidEngine as v,SolidTypeIndex as y,SolidContainer as w,SolidACLAuthorization as S,SolidDocument as b,bootSolidModels as I}from"soukai-solid";import"core-js/modules/esnext.async-iterator.find.js";import"core-js/modules/esnext.iterator.constructor.js";import"core-js/modules/esnext.iterator.find.js";import{JSError as x,arr as P,fail as A,PromisedValue as _,Storage as U,after as $,facade as L,tap as E,objectWithout as T,urlRoot as j,requireUrlParse as R,objectWithoutEmpty as C,asyncMemo as k,hasLocationQueryParameter as F,getLocationQueryParameter as q,arrayUnique as O,arrayFilter as G,setAsyncMemo as z,parseBoolean as D,arrayWithout as M}from"@noeldemartin/utils";import{fetchLoginUserProfile as H}from"@noeldemartin/solid-utils";import{setEngine as N}from"soukai";import W from"@babel/runtime/helpers/esm/defineProperty";import"core-js/modules/esnext.async-iterator.for-each.js";import"core-js/modules/esnext.iterator.for-each.js";import"core-js/modules/esnext.async-iterator.map.js";import"core-js/modules/esnext.iterator.map.js";import"core-js/modules/esnext.async-iterator.constructor.js";import"core-js/modules/esnext.async-iterator.to-array.js";import"core-js/modules/esnext.iterator.to-array.js";import B from"virtual:aerogel-solid";import{defineComponent as Y,openBlock as J,createElementBlock as K,unref as Q,renderSlot as V,createVNode as X,createCommentVNode as Z,createElementVNode as ee,withCtx as te,createTextVNode as ie,toDisplayString as se,createBlock as re,computed as oe}from"vue";class AuthenticationCancelledError extends x{}class AuthenticationFailedError extends x{constructor(e,t,i){super(e,i),W(this,"description",void 0),this.description=t}}class ne extends x{constructor(e,t){super(`Container at ${e.url} is already in use`,t)}}class ae{constructor(){W(this,"name",void 0),W(this,"authenticatedFetch",void 0),W(this,"booted",void 0),W(this,"listeners",P([])),W(this,"_engine",void 0)}get engine(){return this._engine=this._engine??new v(this.requireAuthenticatedFetch()),this._engine}getAuthenticatedFetch(){return this.authenticatedFetch??null}requireAuthenticatedFetch(){return this.authenticatedFetch??A("Authenticated fetch is not ready")}addListener(e){return this.listeners.includes(e)||this.listeners.push(e),()=>{this.removeListener(e)}}removeListener(e){this.listeners.includes(e)&&this.listeners.remove(e)}async boot(){if(this.booted)return this.booted;this.booted=new _,await this.restoreSession(),this.booted.resolve()}async initAuthenticatedFetch(e){this.authenticatedFetch=e,await this.notifyListeners("onAuthenticatedFetchReady",e)}async startSession(e){const t={authenticator:this,...e};return await this.notifyListeners("onSessionStarted",t),t}async failSession(e,t){await this.notifyListeners("onSessionFailed",e,t)}async endSession(){await this.notifyListeners("onSessionEnded")}async notifyListeners(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];await Promise.all(this.listeners.toArray().map((async t=>{const s=t[e];await(s?.(...i))})))}}const le="inrupt-authenticator";const ce={},ue={inrupt:new class extends ae{constructor(){super(...arguments),W(this,"_events",void 0),W(this,"_fetch",void 0),W(this,"_login",void 0),W(this,"_logout",void 0),W(this,"_handleIncomingRedirect",void 0)}async login(e){U.set(le,e);const t={oidcIssuer:e};return B.clientID&&(t.clientId=B.clientID.client_id,t.clientName=B.clientID.client_name,t.redirectUrl=B.clientID.redirect_uris[0]),await this._login(t),await $({seconds:60}),A("Browser should have redirected, but it didn't")}async logout(){await this._logout(),await this.endSession()}async restoreSession(){const{events:e,fetch:t,handleIncomingRedirect:i,login:s,logout:r}=await import("./InruptAuthenticator.lazy.hash.esm.js");this._fetch=t,this._login=s,this._logout=r,this._events=e,this._handleIncomingRedirect=i,await this.loginFromRedirect()}async loginFromRedirect(){const e=U.get(le);if(!e)return;this._events().on("error",((t,i)=>{t??="Error using Inrupt Authenticator method",this.failSession(e,new AuthenticationFailedError(t,i))}));const t=await this._handleIncomingRedirect(globalThis.location.href);U.remove(le),t?.isLoggedIn&&t.webId&&await this.initSession(t.webId)}async initSession(e){await this.initAuthenticatedFetch(this._fetch);try{const{default:t}=await Promise.resolve().then((function(){return we})),i=await t.requireUserProfile(e);await this.startSession({user:i,loginUrl:e})}catch(t){await this.failSession(e,t)}}}};function de(e){ce.default=e}function he(e){return ce[e]}function ge(e){Object.entries(e).forEach((e=>{let[t,i]=e;return fe(t,i)}))}function fe(e,t){ce[e]=t,t.name=t.name??e}const pe={autoReconnect:!0};var me=e({name:"solid",persist:["autoReconnect","dismissed","previousSession","profiles","staleProfiles"],initialState:{autoReconnect:pe.autoReconnect,dismissed:!1,ignorePreviousSessionError:!1,loginStartupError:null,loginOngoing:!1,preferredAuthenticator:null,previousSession:null,profiles:{},session:null,loginStale:!1,staleProfiles:[]},serialize:e=>(e.previousSession?.error instanceof Error&&(e.previousSession.error=e.previousSession.error.message),e),computed:{user:e=>e.session?.user??e.previousSession?.profile??null,authenticator:e=>e.session?.authenticator??null,fetch(){return this.authenticator?.getAuthenticatedFetch()??globalThis.fetch.bind(globalThis)},error:e=>e.loginStartupError?e.loginStartupError??null:e.ignorePreviousSessionError?null:e.previousSession?.error??null}});class ve extends me{isLoggedIn(){return!!this.session}wasLoggedIn(){return!!this.previousSession}hasLoggedIn(){return!(!this.session&&!this.previousSession)}requireAuthenticator(){return this.authenticator??A("Could not get authenticator")}requireUser(){return this.user??A("Could not get user profile (are you logged in?)")}requireUserProfile(e){return this.getUserProfile(e,!0)}async getUserProfile(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.profiles[e]??E(await H(e,{fetch:this.fetch,required:t}),(e=>e&&this.rememberProfile(e)))}async refreshUserProfile(){if(!this.isLoggedIn())return;this.setState({profiles:T(this.profiles,[this.user.webId])});const e=await this.requireUserProfile(this.user.webId);this.setState({session:{...this.session,user:e}})}async login(e){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=o.authenticator??this.preferredAuthenticator??"default",a=o.onError??(e=>t.isMounted()?i.report(e):this.setState({loginStartupError:e}));if(t.development&&"devserver"===e&&(e="http://localhost:3000"),/^https?:\/\//.test(e)||(o.fallbackUrl??=`http://${e}`,e=`https://${e}`),this.isLoggedIn())return!0;if(this.loginOngoing)throw new Error("Authentication already in progress");const l=setTimeout((()=>this.loginStale=!0),1e4),c={dismissed:this.dismissed,ignorePreviousSessionError:this.ignorePreviousSessionError,previousSession:this.previousSession};this.loginOngoing=!0;try{const t=await this.getUserProfile(e),i=t?.oidcIssuerUrl??j(t?.webId??e),o=await this.bootAuthenticator(n),{domain:a}=R(e);return this.setState({dismissed:!1,ignorePreviousSessionError:!0,previousSession:C({profile:t,loginUrl:e,authenticator:n,error:s("auth.stuckConnecting",`We didn't hear back from the identity provider at \`${a}\`, maybe try reconnecting?`)})}),await r.emit("auth:before-login"),await o.login(i),!0}catch(e){return this.setState(c),e instanceof AuthenticationCancelledError?!1:o.fallbackUrl?$().then((()=>this.login(o.fallbackUrl??"",T(o,"fallbackUrl")))):(a(e),!1)}finally{clearTimeout(l),this.setState({loginOngoing:!1,loginStale:!1})}}async reconnect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{force:t,...i}=e;this.isLoggedIn()||!this.previousSession||null!==this.previousSession.error&&!t||await this.login(this.previousSession.loginUrl,{authenticator:this.previousSession.authenticator,...i})}async logout(){(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||await o.confirm(s("solid.logoutConfirmTitle","Log out from this device?"),s("solid.logoutConfirmMessage","Logging out will remove all the data from this device, but you'll still have it in your Solid POD."),{acceptText:s("solid.logoutConfirmAccept","Log out"),acceptColor:n.Danger,cancelText:s("solid.logoutConfirmCancel",s("ui.cancel","Cancel"))}))&&this.previousSession&&await o.loading(s("solid.logoutOngoing","Logging out..."),(async()=>{this.setState({previousSession:null,...pe}),this.isLoggedIn()&&await this.authenticator.logout(),await r.emit("auth:logout"),await r.emit("auth:after-logout")}))}async whenLoggedIn(e){return this.isLoggedIn()?e(this.session):new Promise((t=>{r.once("auth:login",(i=>t(e(i))))}))}dismiss(){this.setState({dismissed:!0})}async findOrCreatePrivateTypeIndex(){return await this.findPrivateTypeIndex()??await this.createPrivateTypeIndex()}async findPrivateTypeIndex(){const{webId:e,privateTypeIndexUrl:t}=this.requireUser(),i=this.requireAuthenticator().engine;return t?k(`${e}-privateTypeIndex`,(()=>y.withEngine(i).find(t))):null}async findOrCreatePublicTypeIndex(){return await this.findPublicTypeIndex()??await this.createPublicTypeIndex()}async findPublicTypeIndex(){const{webId:e,publicTypeIndexUrl:t}=this.requireUser(),i=this.requireAuthenticator().engine;return t?k(`${e}-publicTypeIndex`,(()=>y.withEngine(i).find(t))):null}async createPrivateContainer(e){const t=this.requireAuthenticator().engine;return w.withEngine(t,(async()=>{const t=await w.find(e.url);if(t&&!e.reuseExisting)throw new ne(t);const i=t??new w({url:e.url,name:e.name});if(await i.save(),e.registerFor){const t=await this.findOrCreatePrivateTypeIndex();await i.register(t,e.registerFor)}return i}))}async boot(){await i.booted,F("authenticator")&&this.setState({preferredAuthenticator:q("authenticator")}),F("refreshProfile")&&this.setState({staleProfiles:O(this.staleProfiles.concat(G([this.session?.user.webId,this.previousSession?.loginUrl])))}),await this.restorePreviousSession(),await this.startupReconnect()}async createPrivateTypeIndex(){const e=this.requireUser(),t=this.requireAuthenticator(),i=await y.withEngine(t.engine).createPrivate(e);return E(i,(()=>{e.privateTypeIndexUrl=i.url,z(`${e.webId}-privateTypeIndex`,i),this.rememberProfile(e)}))}async createPublicTypeIndex(){const e=this.requireUser(),t=this.requireAuthenticator(),i=await y.withEngine(t.engine).createPublic(e);return E(i,(()=>{e.privateTypeIndexUrl=i.url,z(`${e.webId}-publicTypeIndex`,i),this.rememberProfile(e)}))}async restorePreviousSession(){this.previousSession&&await this.bootAuthenticator(this.previousSession.authenticator)}async startupReconnect(){this.reconnectOnStartup()&&await this.reconnect()}reconnectOnStartup(){return F("autoReconnect")?D(q("autoReconnect")):this.autoReconnect}async bootAuthenticator(e){const i=he(e);return i.addListener({onSessionStarted:async e=>{this.setState({session:e,previousSession:{authenticator:i.name,loginUrl:e.loginUrl,profile:e.user,error:null}}),(e.user.cloaked||!e.user.writableProfileUrl||this.staleProfiles.includes(e.user.webId))&&await this.refreshUserProfile(),t.plugin("@aerogel/offline-first")||N(e.authenticator.engine),S.setEngine(e.authenticator.engine),y.setEngine(e.authenticator.engine),b.setEngine(e.authenticator.engine),await r.emit("auth:login",e)},onSessionFailed:async(e,t)=>{this.setState({session:null,previousSession:{authenticator:i.name,loginUrl:e,error:t}})},onSessionEnded:()=>this.setState({session:null}),onAuthenticatedFetchReady:e=>r.emit("auth:fetch-ready",e)}),await i.boot(),i}rememberProfile(e){this.setState({profiles:{...this.profiles,[e.webId]:e},staleProfiles:M(this.staleProfiles,e.webId)})}}var ye=L(ve),we=Object.freeze({__proto__:null,SolidService:ve,default:ye});const Se=["src"];var be=Y({__name:"AGSolidImage",props:{src:a()},setup(e){const t=e,i=l((async()=>{const e=await c.get(t.src)??await async function(e){try{const t=await ye.fetch(e);return 200!==t.status?null:(await c.store(e,t),c.get(e))}catch(e){return null}}(t.src),i=await(e?.blob());return i&&URL.createObjectURL(i)}));return(e,t)=>(J(),K("img",{src:Q(i)},null,8,Se))}});be.__file="src/components/AGSolidImage.vue";const Ie={class:"flex flex-col gap-3"},xe={class:"flex flex-col"};var Pe=Y({__name:"AGSolidStatus",setup(e){const t=u({url:d()});return(e,i)=>(J(),K("div",null,[e.$solid.loginStale?V(e.$slots,"login-stale",{key:0},(()=>[X(Q(h),{text:e.$td("solid.loginStale","This is taking too long...")},null,8,["text"])])):Z("v-if",!0),e.$solid.loginOngoing?V(e.$slots,"login-ongoing",{key:1},(()=>[X(Q(h),{text:e.$td("ui.loading","Loading...")},null,8,["text"])])):e.$solid.isLoggedIn()?V(e.$slots,"logged-in",{key:2,session:e.$solid.session},(()=>[ee("div",Ie,[X(Q(h),{text:e.$td("solid.loggedIn","You are logged in as [{userName}]({userWebId})",{userName:e.$solid.user.name??e.$solid.user.webId,userWebId:e.$solid.user.webId})},null,8,["text"]),X(Q(g),{onClick:i[0]||(i[0]=t=>e.$solid.logout())},{default:te((()=>[ie(se(e.$td("solid.logout","Logout")),1)])),_:1})])])):V(e.$slots,"logged-out",{key:3},(()=>[ee("div",xe,[X(Q(f),{form:Q(t),class:"flex",onSubmit:i[1]||(i[1]=i=>e.$solid.login(Q(t).url))},{default:te((()=>[X(Q(p),{name:"url","aria-label":e.$td("solid.url","Login url"),placeholder:e.$td("solid.placeholder","https://...")},null,8,["aria-label","placeholder"]),X(Q(g),{submit:""},{default:te((()=>[ie(se(e.$td("solid.login","Login")),1)])),_:1})])),_:1},8,["form"]),e.$solid.wasLoggedIn()?(J(),re(Q(g),{key:0,class:"mt-3",onClick:i[2]||(i[2]=t=>e.$solid.reconnect({force:!0}))},{default:te((()=>[ie(se(e.$td("solid.reconnect","Reconnect")),1)])),_:1})):Z("v-if",!0),e.$solid.previousSession?.error?(J(),re(Q(h),{key:1,class:"mt-1 self-center text-sm text-red-800",text:e.$td("solid.previousLoginError","Previous login attempt failed")},null,8,["text"])):Z("v-if",!0)])]))]))}});Pe.__file="src/components/AGSolidStatus.vue";const Ae={viewBox:"0 0 20 20",width:"1.2em",height:"1.2em"},_e=[ee("path",{fill:"currentColor",d:"M15 2H5L4 8h12zM0 10s2 1 10 1s10-1 10-1l-4-2H4zm8 4h4v1H8z"},null,-1),ee("circle",{cx:"6",cy:"15",r:"3",fill:"currentColor"},null,-1),ee("circle",{cx:"14",cy:"15",r:"3",fill:"currentColor"},null,-1)];var Ue={name:"ooui-user-anonymous",render:function(e,t){return J(),K("svg",Ae,[..._e])}};const $e={class:"relative flex items-center justify-center rounded-full bg-gray-200"},Le={key:1,class:"text-sm font-semibold tracking-wider text-gray-500","aria-hidden":"true"};var Ee=Y({__name:"AGSolidUserAvatar",setup(e){const t=oe((()=>(ye.user?.name??"").trim().split(" ").map((e=>e[0]?.toUpperCase())).join("").slice(0,3)));return(e,i)=>(J(),K("div",$e,[e.$solid.user?.avatarUrl?(J(),re(be,{key:0,src:e.$solid.user?.avatarUrl,alt:"",class:"absolute inset-0 h-full w-full rounded-full"},null,8,["src"])):t.value?(J(),K("span",Le,se(t.value),1)):(J(),re(Q(Ue),{key:2,class:"h-6 w-6 text-gray-500"}))]))}});Ee.__file="src/components/AGSolidUserAvatar.vue";const Te={$solid:ye};function je(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{async install(t){I(),ge({...ue,...e.authenticators??{}}),de(he(e.defaultAuthenticator??"inrupt")),"boolean"==typeof e.autoReconnect&&(pe.autoReconnect=e.autoReconnect,ye.hasPersistedState()||(ye.autoReconnect=e.autoReconnect)),await m(t,Te)}}}export{be as AGSolidImage,Pe as AGSolidStatus,Ee as AGSolidUserAvatar,AuthenticationCancelledError,AuthenticationFailedError,ne as ContainerAlreadyInUse,ye as Solid,ve as SolidService,ue as authenticators,je as default,he as getAuthenticator,fe as registerAuthenticator,ge as registerAuthenticators,de as setDefaultAuthenticator};
2
+ //# sourceMappingURL=aerogel-plugin-solid.esm.js.map