@aerogel/plugin-solid 0.0.1-next.f8cdd39997c56dcd46e07c26af8a84d04d610fce → 0.0.1

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@aerogel/core"),t=require("soukai-solid"),i=require("@babel/runtime/helpers/defineProperty");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 r=require("@noeldemartin/utils"),s=require("@noeldemartin/solid-utils");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 o=require("vue");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(i);class AuthenticationCancelledError extends r.JSError{}class l extends r.JSError{constructor(e,t){super(`Container at ${e.url} is already in use`,t)}}class u{constructor(){a.default(this,"name",void 0),a.default(this,"authenticatedFetch",void 0),a.default(this,"booted",void 0),a.default(this,"listeners",r.arr([])),a.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??r.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 r.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 c="inrupt-authenticator";const d={},h={inrupt:new class extends u{constructor(){super(...arguments),a.default(this,"_fetch",void 0),a.default(this,"_login",void 0),a.default(this,"_logout",void 0),a.default(this,"_handleIncomingRedirect",void 0)}async login(e){return r.Storage.set(c,!0),await this._login({oidcIssuer:e}),await r.after({seconds:60}),r.fail("Browser should have redirected, but it didn't")}async logout(){await this._logout(),await this.endSession()}async restoreSession(){const{fetch:e,handleIncomingRedirect:t,login:i,logout:r}=await Promise.resolve().then((function(){return require("./InruptAuthenticator.lazy.hash.cjs.js")}));this._fetch=e,this._login=i,this._logout=r,this._handleIncomingRedirect=t,await this.loginFromRedirect()}async loginFromRedirect(){if(!r.Storage.has(c))return;const e=await this._handleIncomingRedirect(window.location.href);r.Storage.remove(c),e?.isLoggedIn&&e.webId&&await this.initSession(e.webId)}async initSession(e){await this.initAuthenticatedFetch(this._fetch);try{const{default:t}=await Promise.resolve().then((function(){return v})),i=await t.requireUserProfile(e);await this.startSession({user:i,loginUrl:e})}catch(t){await this.failSession(e,t)}}}};function g(e){d.default=e}function f(e){return d[e]}function p(e){Object.entries(e).forEach((e=>{let[t,i]=e;return y(t,i)}))}function y(e,t){d[e]=t,t.name=t.name??e}var S=e.defineServiceState({name:"solid",persist:["autoReconnect","dismissed","previousSession","profiles","staleProfiles"],initialState:{autoReconnect:!1,dismissed:!1,ignorePreviousSessionError:!1,loginError: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:{loggedIn:e=>!!e.session,user:e=>e.session?.user??null,userAvatarUrl:e=>e.session?.user?.avatarUrl??e.previousSession?.avatarUrl??null,wasLoggedIn:e=>!!e.previousSession?.loginUrl,authenticator:e=>e.session?.authenticator??null,hasLoggedIn(){return this.loggedIn||this.wasLoggedIn},fetch(){return this.authenticator?.getAuthenticatedFetch()??window.fetch.bind(window)},error:e=>e.loginError?e.loginError??null:e.ignorePreviousSessionError?null:e.previousSession?.error??null}});class w extends S{constructor(){super(...arguments),a.default(this,"publicTypeIndexes",{}),a.default(this,"privateTypeIndexes",{})}isLoggedIn(){return this.loggedIn}requireAuthenticator(){return this.authenticator??r.fail("Could not get authenticator")}requireUser(){return this.user??r.fail("Could not get user profile")}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]??r.tap(await s.fetchLoginUserProfile(e,{fetch:this.fetch,required:t}),(e=>e&&this.rememberProfile(e)))}async refreshUserProfile(){if(!this.isLoggedIn())return;this.setState({profiles:r.objectWithout(this.profiles,[this.user.webId])});const e=await this.requireUserProfile(this.user.webId);this.setState({session:{...this.session,user:e}})}async login(t,i){if(i=i??this.preferredAuthenticator??"default",e.App.development&&"devserver"===t&&(t="http://localhost:4000"),this.loggedIn)return!0;if(this.loginOngoing)throw new Error("Authentication already in progress");const s=setTimeout((()=>this.loginStale=!0),1e4);this.loginOngoing=!0;try{const s=await this.getUserProfile(t),o=s?.oidcIssuerUrl??r.urlRoot(s?.webId??t),n=await this.bootAuthenticator(i);return this.setState({dismissed:!1,ignorePreviousSessionError:!0,previousSession:{loginUrl:t,avatarUrl:s?.avatarUrl,authenticator:i,error:e.translateWithDefault("auth.stuckConnecting","We didn't hear back from the identity provider, maybe try reconnecting?")}}),await n.login(o),!0}catch(t){return t instanceof AuthenticationCancelledError||(e.App.isMounted?e.Errors.report(t):this.setState({loginError:t})),!1}finally{clearTimeout(s),this.loginOngoing=!1,this.loginStale=!1}}async reconnect(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.loggedIn||!this.previousSession||null!==this.previousSession.error&&!e||await this.login(this.previousSession.loginUrl,this.previousSession.authenticator)}async logout(){(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||await e.UI.confirm(e.translateWithDefault("solid.logoutConfirm","Are you sure you want to log out?")))&&this.previousSession&&(this.setState({previousSession:null}),this.isLoggedIn()&&await this.authenticator.logout(),await e.Events.emit("logout"))}dismiss(){this.setState({dismissed:!0})}async findOrCreatePrivateTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't find or create a type index because the user is not logged in");const e=this.user.webId;return this.privateTypeIndexes[e]=this.privateTypeIndexes[e]??r.PromisedValue.from((async()=>await this.findPrivateTypeIndex()??await this.createPrivateTypeIndex())())}async findOrCreatePublicTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't find or create a type index because the user is not logged in");const e=this.user.webId;return this.publicTypeIndexes[e]=this.publicTypeIndexes[e]??r.PromisedValue.from((async()=>await this.findPublicTypeIndex()??await this.createPublicTypeIndex())())}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 l(i);const r=i??new t.SolidContainer({url:e.url,name:e.url});if(await r.save(),e.registerFor){const t=await this.findOrCreatePrivateTypeIndex();await r.register(t.url,e.registerFor)}return r}))}async boot(){await e.Errors.booted,r.hasLocationQueryParameter("authenticator")&&this.setState({preferredAuthenticator:r.getLocationQueryParameter("authenticator")}),r.hasLocationQueryParameter("refreshProfile")&&this.setState({staleProfiles:r.arrayUnique(this.staleProfiles.concat(r.arrayFilter([this.session?.user.webId,this.previousSession?.loginUrl])))}),await this.restorePreviousSession(),await this.startupReconnect()}async findPrivateTypeIndex(){const e=this.requireUser(),i=this.requireAuthenticator();return t.SolidTypeIndex.withEngine(i.engine,(()=>t.SolidTypeIndex.find(e.privateTypeIndexUrl)))}async createPrivateTypeIndex(){const e=this.requireUser(),i=this.requireAuthenticator(),s=await t.SolidTypeIndex.withEngine(i.engine).createPrivate(e);return r.tap(s,(()=>{e.privateTypeIndexUrl=s.url,this.rememberProfile(e)}))}async findPublicTypeIndex(){return this.user?.publicTypeIndexUrl?t.SolidTypeIndex.find(this.user.publicTypeIndexUrl):null}async createPublicTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't create a type index because the user is not logged in");const e=this.user,i=await t.SolidTypeIndex.withEngine(this.authenticator.engine,(()=>t.SolidTypeIndex.createPublic(e)));return r.tap(i,(()=>{e.publicTypeIndexUrl=i.url,this.rememberProfile(e)}))}async restorePreviousSession(){this.previousSession&&await this.bootAuthenticator(this.previousSession.authenticator)}async startupReconnect(){this.reconnectOnStartup()&&await this.reconnect()}reconnectOnStartup(){return r.hasLocationQueryParameter("autoReconnect")?r.parseBoolean(r.getLocationQueryParameter("autoReconnect")):this.autoReconnect}async bootAuthenticator(i){const r=f(i);return r.addListener({onSessionStarted:async i=>{this.setState({session:i,previousSession:{authenticator:r.name,loginUrl:i.loginUrl,avatarUrl:i.user.avatarUrl,error:null}}),(i.user.cloaked||!i.user.writableProfileUrl||this.staleProfiles.includes(i.user.webId))&&await this.refreshUserProfile(),t.SolidACLAuthorization.setEngine(i.authenticator.engine),await e.Events.emit("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("authenticated-fetch-ready",t)}),await r.boot(),r}rememberProfile(e){this.setState({profiles:{...this.profiles,[e.webId]:e},staleProfiles:r.arrayWithout(this.staleProfiles,e.webId)})}}var m=r.facade(new w),v=Object.freeze({__proto__:null,SolidService:w,default:m});const x={class:"flex flex-col gap-3"},I={class:"flex flex-col"};var b=o.defineComponent({__name:"AGSolidStatus",setup(t){const i=e.useForm({url:e.requiredStringInput()});return(t,r)=>(o.openBlock(),o.createElementBlock("div",null,[t.$solid.loginStale?o.renderSlot(t.$slots,"login-stale",{key:0},(()=>[o.createVNode(o.unref(e.AGMarkdown),{text:t.$td("solid.loginStale","This is taking too long...")},null,8,["text"])])):o.createCommentVNode("v-if",!0),t.$solid.loginOngoing?o.renderSlot(t.$slots,"login-ongoing",{key:1},(()=>[o.createVNode(o.unref(e.AGMarkdown),{text:t.$td("ui.loading","Loading...")},null,8,["text"])])):t.$solid.isLoggedIn()?o.renderSlot(t.$slots,"logged-in",{key:2,session:t.$solid.session},(()=>[o.createElementVNode("div",x,[o.createVNode(o.unref(e.AGMarkdown),{text:t.$td("solid.loggedIn",{userName:t.$solid.user.name??t.$solid.user.webId,userWebId:t.$solid.user.webId},"You are logged in as [{userName}]({userWebId})")},null,8,["text"]),o.createVNode(o.unref(e.AGButton),{onClick:r[0]||(r[0]=e=>t.$solid.logout())},{default:o.withCtx((()=>[o.createTextVNode(o.toDisplayString(t.$td("solid.logout","Logout")),1)])),_:1})])])):o.renderSlot(t.$slots,"logged-out",{key:3},(()=>[o.createElementVNode("div",I,[o.createVNode(o.unref(e.AGForm),{form:o.unref(i),class:"flex",onSubmit:r[1]||(r[1]=e=>t.$solid.login(o.unref(i).url))},{default:o.withCtx((()=>[o.createVNode(o.unref(e.AGInput),{name:"url","aria-label":t.$td("solid.url","Login url"),placeholder:t.$td("solid.placeholder","https://...")},null,8,["aria-label","placeholder"]),o.createVNode(o.unref(e.AGButton),{submit:""},{default:o.withCtx((()=>[o.createTextVNode(o.toDisplayString(t.$td("solid.login","Login")),1)])),_:1})])),_:1},8,["form"]),t.$solid.wasLoggedIn?(o.openBlock(),o.createBlock(o.unref(e.AGButton),{key:0,class:"mt-3",onClick:r[2]||(r[2]=e=>t.$solid.reconnect(!0))},{default:o.withCtx((()=>[o.createTextVNode(o.toDisplayString(t.$td("solid.reconnect","Reconnect")),1)])),_:1})):o.createCommentVNode("v-if",!0),t.$solid.previousSession?.error?(o.openBlock(),o.createBlock(o.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"])):o.createCommentVNode("v-if",!0)])]))]))}});b.__file="src/components/AGSolidStatus.vue";const P={$solid:m};exports.AGSolidStatus=b,exports.AuthenticationCancelledError=AuthenticationCancelledError,exports.ContainerAlreadyInUse=l,exports.Solid=m,exports.authenticators=h,exports.default=function(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{async install(r){t.bootSolidModels(),p({...h,...i.authenticators??{}}),g(f(i.defaultAuthenticator??"inrupt")),await e.bootServices(r,P)}}},exports.getAuthenticator=f,exports.registerAuthenticator=y,exports.registerAuthenticators=p,exports.setDefaultAuthenticator=g;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@aerogel/core"),t=require("soukai-solid"),r=require("@babel/runtime/helpers/defineProperty");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"),s=require("@noeldemartin/solid-utils");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("vue");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var l=o(r);class AuthenticationCancelledError extends i.JSError{}class u extends i.JSError{constructor(e,t){super(`Container at ${e.url} is already in use`,t)}}class c{constructor(){l.default(this,"name",void 0),l.default(this,"authenticatedFetch",void 0),l.default(this,"booted",void 0),l.default(this,"listeners",i.arr([])),l.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,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];await Promise.all(this.listeners.toArray().map((async t=>{const i=t[e];await(i?.(...r))})))}}const d="inrupt-authenticator";const h={},g={inrupt:new class extends c{constructor(){super(...arguments),l.default(this,"_fetch",void 0),l.default(this,"_login",void 0),l.default(this,"_logout",void 0),l.default(this,"_handleIncomingRedirect",void 0)}async login(e){return i.Storage.set(d,!0),await this._login({oidcIssuer:e}),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{fetch:e,handleIncomingRedirect:t,login:r,logout:i}=await Promise.resolve().then((function(){return a(require("@inrupt/solid-client-authn-browser"))}));this._fetch=e,this._login=r,this._logout=i,this._handleIncomingRedirect=t,await this.loginFromRedirect()}async loginFromRedirect(){if(!i.Storage.has(d))return;const e=await this._handleIncomingRedirect(window.location.href);i.Storage.remove(d),e?.isLoggedIn&&e.webId&&await this.initSession(e.webId)}async initSession(e){await this.initAuthenticatedFetch(this._fetch);try{const{default:t}=await Promise.resolve().then((function(){return x})),r=await t.requireUserProfile(e);await this.startSession({user:r,loginUrl:e})}catch(t){await this.failSession(e,t)}}}};function f(e){h.default=e}function p(e){return h[e]}function y(e){Object.entries(e).forEach((e=>{let[t,r]=e;return w(t,r)}))}function w(e,t){h[e]=t,t.name=t.name??e}var S=e.defineServiceState({name:"solid",persist:["autoReconnect","dismissed","previousSession","profiles","staleProfiles"],initialState:{autoReconnect:!1,dismissed:!1,ignorePreviousSessionError:!1,loginError: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:{loggedIn:e=>!!e.session,user:e=>e.session?.user??null,userAvatarUrl:e=>e.session?.user?.avatarUrl??e.previousSession?.avatarUrl??null,wasLoggedIn:e=>!!e.previousSession?.loginUrl,authenticator:e=>e.session?.authenticator??null,hasLoggedIn(){return this.loggedIn||this.wasLoggedIn},fetch(){return this.authenticator?.getAuthenticatedFetch()??window.fetch.bind(window)},error:e=>e.loginError?e.loginError??null:e.ignorePreviousSessionError?null:e.previousSession?.error??null}});class m extends S{constructor(){super(...arguments),l.default(this,"publicTypeIndexes",{}),l.default(this,"privateTypeIndexes",{})}isLoggedIn(){return this.loggedIn}requireAuthenticator(){return this.authenticator??i.fail("Could not get authenticator")}requireUser(){return this.user??i.fail("Could not get user profile")}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 s.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,r){if(r=r??this.preferredAuthenticator??"default",e.App.isDevelopment&&"devserver"===t&&(t="http://localhost:4000"),this.loggedIn)return!0;if(this.loginOngoing)throw new Error("Authentication already in progress");const s=setTimeout((()=>this.loginStale=!0),1e4);this.loginOngoing=!0;try{const s=await this.getUserProfile(t),n=s?.oidcIssuerUrl??i.urlRoot(s?.webId??t),o=await this.bootAuthenticator(r);return this.setState({dismissed:!1,ignorePreviousSessionError:!0,previousSession:{loginUrl:t,avatarUrl:s?.avatarUrl,authenticator:r,error:e.translateWithDefault("auth.stuckConnecting","We didn't hear back from the identity provider, maybe try reconnecting?")}}),await o.login(n),!0}catch(t){return t instanceof AuthenticationCancelledError||(e.App.isMounted?e.Errors.report(t):this.setState({loginError:t})),!1}finally{clearTimeout(s),this.loginOngoing=!1,this.loginStale=!1}}async reconnect(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.loggedIn||!this.previousSession||null!==this.previousSession.error&&!e||await this.login(this.previousSession.loginUrl,this.previousSession.authenticator)}async logout(){(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||await e.UI.confirm(e.translateWithDefault("solid.logoutConfirm","Are you sure you want to log out?")))&&this.previousSession&&(this.setState({previousSession:null}),this.isLoggedIn()&&await this.authenticator.logout(),await e.Events.emit("logout"))}dismiss(){this.setState({dismissed:!0})}async findOrCreatePrivateTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't find or create a type index because the user is not logged in");const e=this.user.webId;return this.privateTypeIndexes[e]=this.privateTypeIndexes[e]??i.PromisedValue.from((async()=>await this.findPrivateTypeIndex()??await this.createPrivateTypeIndex())())}async findOrCreatePublicTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't find or create a type index because the user is not logged in");const e=this.user.webId;return this.publicTypeIndexes[e]=this.publicTypeIndexes[e]??i.PromisedValue.from((async()=>await this.findPublicTypeIndex()??await this.createPublicTypeIndex())())}async createPrivateContainer(e){const r=this.requireAuthenticator().engine;return t.SolidContainer.withEngine(r,(async()=>{const r=await t.SolidContainer.find(e.url);if(r&&!e.reuseExisting)throw new u(r);const i=r??new t.SolidContainer({url:e.url,name:e.url});return await i.save(),e.register&&await i.register(e.register.typeIndex.url,e.register.modelClass),i}))}async boot(){await super.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 findPrivateTypeIndex(){const e=this.requireUser(),r=this.requireAuthenticator();return t.SolidTypeIndex.withEngine(r.engine,(()=>t.SolidTypeIndex.find(e.privateTypeIndexUrl)))}async createPrivateTypeIndex(){const e=this.requireUser(),r=this.requireAuthenticator(),s=await t.SolidTypeIndex.withEngine(r.engine).createPrivate(e);return i.tap(s,(()=>{e.privateTypeIndexUrl=s.url,this.rememberProfile(e)}))}async findPublicTypeIndex(){return this.user?.publicTypeIndexUrl?t.SolidTypeIndex.find(this.user.publicTypeIndexUrl):null}async createPublicTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't create a type index because the user is not logged in");const e=this.user,r=await t.SolidTypeIndex.withEngine(this.authenticator.engine,(()=>t.SolidTypeIndex.createPublic(e)));return i.tap(r,(()=>{e.publicTypeIndexUrl=r.url,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(r){const i=p(r);return i.addListener({onSessionStarted:async r=>{this.setState({session:r,previousSession:{authenticator:i.name,loginUrl:r.loginUrl,avatarUrl:r.user.avatarUrl,error:null}}),(r.user.cloaked||!r.user.writableProfileUrl||this.staleProfiles.includes(r.user.webId))&&await this.refreshUserProfile(),t.SolidACLAuthorization.setEngine(r.authenticator.engine),await e.Events.emit("login",r)},onSessionFailed:async(e,t)=>{this.setState({session:null,previousSession:{authenticator:i.name,loginUrl:e,error:t}})},onSessionEnded:()=>this.setState({session:null}),onAuthenticatedFetchReady:t=>e.Events.emit("authenticated-fetch-ready",t)}),await i.boot(),i}rememberProfile(e){this.setState({profiles:{...this.profiles,[e.webId]:e},staleProfiles:i.arrayWithout(this.staleProfiles,e.webId)})}}var v=i.facade(new m),x=Object.freeze({__proto__:null,SolidService:m,default:v});const b={class:"flex flex-col gap-3"},I={class:"flex flex-col"};var P=n.defineComponent({__name:"AGSolidStatus",setup(t){const r=e.useForm({url:e.requiredStringInput()});return(t,i)=>(n.openBlock(),n.createElementBlock("div",null,[t.$solid.loginStale?n.renderSlot(t.$slots,"login-stale",{key:0},(()=>[n.createVNode(n.unref(e.AGMarkdown),{text:t.$td("solid.loginStale","This is taking too long...")},null,8,["text"])])):n.createCommentVNode("v-if",!0),t.$solid.loginOngoing?n.renderSlot(t.$slots,"login-ongoing",{key:1},(()=>[n.createVNode(n.unref(e.AGMarkdown),{text:t.$td("ui.loading","Loading...")},null,8,["text"])])):t.$solid.isLoggedIn()?n.renderSlot(t.$slots,"logged-in",{key:2,session:t.$solid.session},(()=>[n.createElementVNode("div",b,[n.createVNode(n.unref(e.AGMarkdown),{text:t.$td("solid.loggedIn",{userName:t.$solid.user.name??t.$solid.user.webId,userWebId:t.$solid.user.webId},"You are logged in as [{userName}]({userWebId})")},null,8,["text"]),n.createVNode(n.unref(e.AGButton),{onClick:i[0]||(i[0]=e=>t.$solid.logout())},{default:n.withCtx((()=>[n.createTextVNode(n.toDisplayString(t.$td("solid.logout","Logout")),1)])),_:1})])])):n.renderSlot(t.$slots,"logged-out",{key:3},(()=>[n.createElementVNode("div",I,[n.createVNode(n.unref(e.AGForm),{form:n.unref(r),class:"flex",onSubmit:i[1]||(i[1]=e=>t.$solid.login(n.unref(r).url))},{default:n.withCtx((()=>[n.createVNode(n.unref(e.AGInput),{name:"url","aria-label":t.$td("solid.url","Login url"),placeholder:t.$td("solid.placeholder","https://...")},null,8,["aria-label","placeholder"]),n.createVNode(n.unref(e.AGButton),{submit:""},{default:n.withCtx((()=>[n.createTextVNode(n.toDisplayString(t.$td("solid.login","Login")),1)])),_:1})])),_:1},8,["form"]),t.$solid.wasLoggedIn?(n.openBlock(),n.createBlock(n.unref(e.AGButton),{key:0,class:"mt-3",onClick:i[2]||(i[2]=e=>t.$solid.reconnect(!0))},{default:n.withCtx((()=>[n.createTextVNode(n.toDisplayString(t.$td("solid.reconnect","Reconnect")),1)])),_:1})):n.createCommentVNode("v-if",!0),t.$solid.previousSession?.error?(n.openBlock(),n.createBlock(n.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"])):n.createCommentVNode("v-if",!0)])]))]))}});P.__file="src/components/AGSolidStatus.vue";const A={$solid:v};exports.AGSolidStatus=P,exports.AuthenticationCancelledError=AuthenticationCancelledError,exports.ContainerAlreadyInUse=u,exports.Solid=v,exports.authenticators=g,exports.default=function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{async install(i){t.bootSolidModels(),y({...g,...r.authenticators??{}}),f(p(r.defaultAuthenticator??"inrupt")),await e.bootServices(i,A)}}},exports.getAuthenticator=p,exports.registerAuthenticator=w,exports.registerAuthenticators=y,exports.setDefaultAuthenticator=f;
2
2
  //# sourceMappingURL=aerogel-plugin-solid.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aerogel-plugin-solid.cjs.js","sources":["../src/errors/AuthenticationCancelledError.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/AGSolidStatus.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';\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 { handleIncomingRedirect, login, logout } from '@inrupt/solid-client-authn-browser';\n\nimport Authenticator from '@/auth/Authenticator';\nimport type { AuthSession } from '@/auth/Authenticator';\n\nconst STORAGE_KEY = 'inrupt-authenticator';\n\nexport default class InruptAuthenticator extends Authenticator {\n\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<boolean>(STORAGE_KEY, true);\n\n await this._login({\n oidcIssuer: loginUrl,\n // TODO clientId, clientName, and redirectUrl\n });\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 { fetch, handleIncomingRedirect, login, logout } = await import('./InruptAuthenticator.lazy');\n\n this._fetch = fetch;\n this._login = login;\n this._logout = logout;\n this._handleIncomingRedirect = handleIncomingRedirect;\n\n await this.loginFromRedirect();\n }\n\n protected async loginFromRedirect(): Promise<void> {\n if (!Storage.has(STORAGE_KEY)) {\n return;\n }\n\n const session = await this._handleIncomingRedirect(window.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 default defineServiceState({\n name: 'solid',\n persist: ['autoReconnect', 'dismissed', 'previousSession', 'profiles', 'staleProfiles'],\n initialState: {\n autoReconnect: false,\n dismissed: false,\n ignorePreviousSessionError: false,\n loginError: null as ErrorSource | null,\n loginOngoing: false,\n preferredAuthenticator: null as AuthenticatorName | null,\n previousSession: null as {\n authenticator: AuthenticatorName;\n loginUrl: string;\n avatarUrl?: 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 loggedIn: (state) => !!state.session,\n user: (state) => state.session?.user ?? null,\n userAvatarUrl: (state) => state.session?.user?.avatarUrl ?? state.previousSession?.avatarUrl ?? null,\n wasLoggedIn: (state) => !!state.previousSession?.loginUrl,\n authenticator: (state) => state.session?.authenticator ?? null,\n hasLoggedIn(): boolean {\n return this.loggedIn || this.wasLoggedIn;\n },\n fetch(): Fetch {\n return this.authenticator?.getAuthenticatedFetch() ?? window.fetch.bind(window);\n },\n error(state): ErrorSource | null {\n if (state.loginError) {\n return state.loginError ?? null;\n }\n\n if (state.ignorePreviousSessionError) {\n return null;\n }\n\n return state.previousSession?.error ?? null;\n },\n },\n});\n","import {\n PromisedValue,\n arrayFilter,\n arrayUnique,\n arrayWithout,\n facade,\n fail,\n getLocationQueryParameter,\n hasLocationQueryParameter,\n objectWithout,\n parseBoolean,\n tap,\n urlRoot,\n} from '@noeldemartin/utils';\nimport { fetchLoginUserProfile } from '@noeldemartin/solid-utils';\nimport { App, Errors, Events, UI, translateWithDefault } from '@aerogel/core';\nimport { SolidACLAuthorization, SolidContainer, SolidTypeIndex } from 'soukai-solid';\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 { AuthenticatorName } from '@/auth';\nimport type Authenticator from '@/auth/Authenticator';\nimport type { AuthSession } from '@/auth/Authenticator';\n\nimport Service from './Solid.state';\n\nexport class SolidService extends Service {\n\n protected publicTypeIndexes: Record<string, PromisedValue<SolidTypeIndex>> = {};\n protected privateTypeIndexes: Record<string, PromisedValue<SolidTypeIndex>> = {};\n\n public isLoggedIn(): this is { session: AuthSession; user: SolidUserProfile; authenticator: Authenticator } {\n return this.loggedIn;\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');\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, authenticatorName?: AuthenticatorName): Promise<boolean> {\n authenticatorName = authenticatorName ?? this.preferredAuthenticator ?? 'default';\n\n if (App.development && loginUrl === 'devserver') {\n loginUrl = 'http://localhost:4000';\n }\n\n if (this.loggedIn) {\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 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\n this.setState({\n dismissed: false,\n ignorePreviousSessionError: true,\n previousSession: {\n loginUrl,\n avatarUrl: profile?.avatarUrl,\n authenticator: authenticatorName,\n error: translateWithDefault(\n 'auth.stuckConnecting',\n 'We didn\\'t hear back from the identity provider, maybe try reconnecting?',\n ),\n },\n });\n\n await authenticator.login(oidcIssuerUrl);\n\n return true;\n } catch (error) {\n if (error instanceof AuthenticationCancelledError) {\n return false;\n }\n\n App.isMounted ? Errors.report(error) : this.setState({ loginError: error });\n\n return false;\n } finally {\n clearTimeout(staleTimeout);\n\n this.loginOngoing = false;\n this.loginStale = false;\n }\n }\n\n public async reconnect(force: boolean = false): Promise<void> {\n if (this.loggedIn || !this.previousSession || (this.previousSession.error !== null && !force)) {\n return;\n }\n\n await this.login(this.previousSession.loginUrl, this.previousSession.authenticator);\n }\n\n public async logout(force: boolean = false): Promise<void> {\n const confirmLogout =\n force ||\n (await UI.confirm(translateWithDefault('solid.logoutConfirm', 'Are you sure you want to log out?')));\n\n if (!confirmLogout) {\n return;\n }\n\n if (!this.previousSession) {\n return;\n }\n\n this.setState({ previousSession: null });\n this.isLoggedIn() && (await this.authenticator.logout());\n\n await Events.emit('logout');\n }\n\n public dismiss(): void {\n this.setState({ dismissed: true });\n }\n\n public async findOrCreatePrivateTypeIndex(): Promise<SolidTypeIndex> {\n if (!this.isLoggedIn()) {\n throw new Error('Can\\'t find or create a type index because the user is not logged in');\n }\n\n const webId = this.user.webId;\n\n return (this.privateTypeIndexes[webId] =\n this.privateTypeIndexes[webId] ??\n PromisedValue.from(\n (async () => (await this.findPrivateTypeIndex()) ?? (await this.createPrivateTypeIndex()))(),\n ));\n }\n\n public async findOrCreatePublicTypeIndex(): Promise<SolidTypeIndex> {\n if (!this.isLoggedIn()) {\n throw new Error('Can\\'t find or create a type index because the user is not logged in');\n }\n\n const webId = this.user.webId;\n\n return (this.publicTypeIndexes[webId] =\n this.publicTypeIndexes[webId] ??\n PromisedValue.from(\n (async () => (await this.findPublicTypeIndex()) ?? (await this.createPublicTypeIndex()))(),\n ));\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.url });\n\n await container.save();\n\n if (options.registerFor) {\n const typeIndex = await this.findOrCreatePrivateTypeIndex();\n\n await container.register(typeIndex.url, 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 findPrivateTypeIndex(): Promise<SolidTypeIndex | null> {\n const user = this.requireUser();\n const authenticator = this.requireAuthenticator();\n\n return SolidTypeIndex.withEngine(authenticator.engine, () => SolidTypeIndex.find(user.privateTypeIndexUrl));\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 this.rememberProfile(user);\n });\n }\n\n protected async findPublicTypeIndex(): Promise<SolidTypeIndex | null> {\n if (!this.user?.publicTypeIndexUrl) {\n return null;\n }\n\n return SolidTypeIndex.find(this.user.publicTypeIndexUrl);\n }\n\n public async createPublicTypeIndex(): Promise<SolidTypeIndex> {\n if (!this.isLoggedIn()) {\n throw new Error('Can\\'t create a type index because the user is not logged in');\n }\n\n const user = this.user;\n const typeIndex = await SolidTypeIndex.withEngine(this.authenticator.engine, () =>\n SolidTypeIndex.createPublic(user));\n\n return tap(typeIndex, () => {\n user.publicTypeIndexUrl = typeIndex.url;\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 avatarUrl: session.user.avatarUrl,\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 SolidACLAuthorization.setEngine(session.authenticator.engine);\n\n await Events.emit('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('authenticated-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(new SolidService());\n\ndeclare module '@aerogel/core' {\n export interface EventsPayload {\n 'authenticated-fetch-ready': Fetch;\n login: AuthSession;\n logout: void;\n }\n}\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(\n 'solid.loggedIn',\n {\n userName: $solid.user.name ?? $solid.user.webId,\n userWebId: $solid.user.webId,\n },\n 'You are logged in as [{userName}]({userWebId})'\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(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","import { bootServices } from '@aerogel/core';\nimport { bootSolidModels } from 'soukai-solid';\nimport type { Plugin } from '@aerogel/core';\n\nimport Solid from '@/services/Solid';\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 { Solid };\nexport * from './auth';\nexport * from './components';\nexport * from './errors';\n\nexport interface Options {\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 await bootServices(app, services);\n },\n };\n}\n\ndeclare module '@vue/runtime-core' {\n interface ComponentCustomProperties extends SolidServices {}\n}\n"],"names":["AuthenticationCancelledError","JSError","ContainerAlreadyInUse","constructor","container","options","super","url","Authenticator","_defineProperty","this","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","_login","oidcIssuer","after","seconds","logout","_logout","handleIncomingRedirect","then","require","_fetch","_handleIncomingRedirect","loginFromRedirect","has","window","location","href","isLoggedIn","webId","initSession","default","Solid","Solid$1","user","requireUserProfile","setDefaultAuthenticator","getAuthenticator","name","registerAuthenticators","customAuthenticators","Object","entries","forEach","_ref","registerAuthenticator","Service","defineServiceState","persist","initialState","autoReconnect","dismissed","ignorePreviousSessionError","loginError","loginOngoing","preferredAuthenticator","previousSession","profiles","loginStale","staleProfiles","serialize","state","Error","message","computed","loggedIn","userAvatarUrl","avatarUrl","wasLoggedIn","hasLoggedIn","bind","SolidService","requireAuthenticator","requireUser","getUserProfile","required","tap","fetchLoginUserProfile","profile","rememberProfile","refreshUserProfile","setState","objectWithout","authenticatorName","App","development","staleTimeout","setTimeout","oidcIssuerUrl","urlRoot","bootAuthenticator","translateWithDefault","isMounted","Errors","report","clearTimeout","reconnect","force","undefined","UI","confirm","Events","emit","dismiss","findOrCreatePrivateTypeIndex","privateTypeIndexes","from","findPrivateTypeIndex","createPrivateTypeIndex","findOrCreatePublicTypeIndex","publicTypeIndexes","findPublicTypeIndex","createPublicTypeIndex","createPrivateContainer","SolidContainer","withEngine","existingContainer","find","reuseExisting","save","registerFor","typeIndex","register","hasLocationQueryParameter","getLocationQueryParameter","arrayUnique","concat","arrayFilter","restorePreviousSession","startupReconnect","SolidTypeIndex","privateTypeIndexUrl","createPrivate","publicTypeIndexUrl","createPublic","reconnectOnStartup","parseBoolean","onSessionStarted","cloaked","writableProfileUrl","SolidACLAuthorization","setEngine","onSessionFailed","onSessionEnded","onAuthenticatedFetchReady","arrayWithout","facade","form","useForm","requiredStringInput","services","$solid","install","app","bootSolidModels","baseAuthenticators","defaultAuthenticator","bootServices"],"mappings":"45BAEqB,MAAAA,qCAAqCC,EAAAA,SCErC,MAAAC,UAA8BD,EAAAA,QAE/CE,WAAAA,CAAYC,EAA2BC,GACnCC,sBAAsBF,EAAUG,wBAAyBF,EAC7D,ECqBU,MAAgBG,EAAaL,WAAAA,GAAAM,EAAAA,QAAAC,KAAA,YAAA,GAAAD,EAAAA,QAAAC,KAAA,0BAAA,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gD,KAAKiC,UACxB7E,MAAO,SAKXJ,EAAQgD,KAAKwG,UACZxJ,EAAQgD,KAAKyG,oBACdnL,KAAKmG,cAAcvF,SAASc,EAAQgD,KAAKL,eAEnCrE,KAAKwH,qBAGf4D,EAAAA,sBAAsBC,UAAU3J,EAAQC,cAAczB,cAEhD2I,SAAOC,KAAK,QAASpH,EAAQ,EAEvC4J,gBAAiB3I,MAAOd,EAAUC,KAC9B9B,KAAKyH,SAAS,CACV/F,QAAS,KACTsE,gBAAiB,CACbrE,cAAeA,EAAcmD,KAC7BjD,WACAC,UAEN,EAENyJ,eAAgBA,IAAMvL,KAAKyH,SAAS,CAAE/F,QAAS,OAC/C8J,0BAA4BlK,GAAUuH,EAAAA,OAAOC,KAAK,4BAA6BxH,WAG7EK,EAAcX,OAEbW,CACX,CAEQ4F,eAAAA,CAAgBD,GACpBtH,KAAKyH,SAAS,CACVxB,SAAU,IACHjG,KAAKiG,SACR,CAACqB,EAAQjD,OAAQiD,GAErBnB,cAAesF,EAAAA,aAAazL,KAAKmG,cAAemB,EAAQjD,QAEhE,EAIJ,IAAAG,EAAekH,EAAMA,OAAC,IAAI3E,uLC1T1B,MAAM4E,EAAOC,EAAAA,QAAQ,CAAE/L,IAAKgM,EAAmBA,ynEC5C/C,MAAMC,EAAW,CAAEC,OAAQvH,sLAcb,WAAqC,IAArB7E,yDAAmB,CAAA,EAC7C,MAAO,CACH,aAAMqM,CAAQC,GACVC,EAAAA,kBACAnH,EAAuB,IAAKoH,KAAwBxM,EAAQoD,gBAAkB,KAC9E6B,EAAwBC,EAAiBlF,EAAQyM,sBAAwB,iBAEnEC,EAAYA,aAACJ,EAAKH,EAC5B,EAER"}
1
+ {"version":3,"file":"aerogel-plugin-solid.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -108,7 +108,7 @@ wasLoggedIn: boolean;
108
108
  authenticator: Authenticator | null;
109
109
  hasLoggedIn: boolean;
110
110
  fetch: Fetch_2;
111
- error: unknown;
111
+ error: {} | null;
112
112
  }> & Constructor<Service< {
113
113
  autoReconnect: boolean;
114
114
  dismissed: boolean;
@@ -134,7 +134,7 @@ wasLoggedIn: boolean;
134
134
  authenticator: Authenticator | null;
135
135
  hasLoggedIn: boolean;
136
136
  fetch: Fetch_2;
137
- error: unknown;
137
+ error: {} | null;
138
138
  }, Partial<{
139
139
  autoReconnect: boolean;
140
140
  dismissed: boolean;
@@ -219,7 +219,10 @@ declare class SolidService extends _default {
219
219
  createPrivateContainer(options: {
220
220
  url: string;
221
221
  name: string;
222
- registerFor?: SolidModelConstructor;
222
+ register?: {
223
+ typeIndex: SolidTypeIndex;
224
+ modelClass: SolidModelConstructor;
225
+ };
223
226
  reuseExisting?: boolean;
224
227
  }): Promise<SolidContainer>;
225
228
  protected boot(): Promise<void>;
@@ -1,2 +1,2 @@
1
- import{defineServiceState as e,App as t,translateWithDefault as i,Errors as s,UI as r,Events as n,useForm as o,requiredStringInput as a,AGMarkdown as l,AGButton as u,AGForm as c,AGInput as d,bootServices as h}from"@aerogel/core";import{SolidEngine as g,SolidContainer as f,SolidTypeIndex as p,SolidACLAuthorization as m,bootSolidModels as y}from"soukai-solid";import w from"@babel/runtime/helpers/esm/defineProperty";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 v,arr as S,fail as I,PromisedValue as b,Storage as x,after as P,facade as U,tap as A,objectWithout as _,urlRoot as $,hasLocationQueryParameter as L,getLocationQueryParameter as E,arrayUnique as T,arrayFilter as j,parseBoolean as F,arrayWithout as C}from"@noeldemartin/utils";import{fetchLoginUserProfile as R}from"@noeldemartin/solid-utils";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{defineComponent as k,openBlock as q,createElementBlock as O,renderSlot as z,createVNode as G,unref as W,createCommentVNode as N,createElementVNode as B,withCtx as M,createTextVNode as Y,toDisplayString as D,createBlock as H}from"vue";class AuthenticationCancelledError extends v{}class J extends v{constructor(e,t){super(`Container at ${e.url} is already in use`,t)}}class K{constructor(){w(this,"name",void 0),w(this,"authenticatedFetch",void 0),w(this,"booted",void 0),w(this,"listeners",S([])),w(this,"_engine",void 0)}get engine(){return this._engine=this._engine??new g(this.requireAuthenticatedFetch()),this._engine}getAuthenticatedFetch(){return this.authenticatedFetch??null}requireAuthenticatedFetch(){return this.authenticatedFetch??I("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 b,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 Q="inrupt-authenticator";const V={},X={inrupt:new class extends K{constructor(){super(...arguments),w(this,"_fetch",void 0),w(this,"_login",void 0),w(this,"_logout",void 0),w(this,"_handleIncomingRedirect",void 0)}async login(e){return x.set(Q,!0),await this._login({oidcIssuer:e}),await P({seconds:60}),I("Browser should have redirected, but it didn't")}async logout(){await this._logout(),await this.endSession()}async restoreSession(){const{fetch:e,handleIncomingRedirect:t,login:i,logout:s}=await import("./InruptAuthenticator.lazy.hash.esm.js");this._fetch=e,this._login=i,this._logout=s,this._handleIncomingRedirect=t,await this.loginFromRedirect()}async loginFromRedirect(){if(!x.has(Q))return;const e=await this._handleIncomingRedirect(window.location.href);x.remove(Q),e?.isLoggedIn&&e.webId&&await this.initSession(e.webId)}async initSession(e){await this.initAuthenticatedFetch(this._fetch);try{const{default:t}=await Promise.resolve().then((function(){return oe})),i=await t.requireUserProfile(e);await this.startSession({user:i,loginUrl:e})}catch(t){await this.failSession(e,t)}}}};function Z(e){V.default=e}function ee(e){return V[e]}function te(e){Object.entries(e).forEach((e=>{let[t,i]=e;return ie(t,i)}))}function ie(e,t){V[e]=t,t.name=t.name??e}var se=e({name:"solid",persist:["autoReconnect","dismissed","previousSession","profiles","staleProfiles"],initialState:{autoReconnect:!1,dismissed:!1,ignorePreviousSessionError:!1,loginError: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:{loggedIn:e=>!!e.session,user:e=>e.session?.user??null,userAvatarUrl:e=>e.session?.user?.avatarUrl??e.previousSession?.avatarUrl??null,wasLoggedIn:e=>!!e.previousSession?.loginUrl,authenticator:e=>e.session?.authenticator??null,hasLoggedIn(){return this.loggedIn||this.wasLoggedIn},fetch(){return this.authenticator?.getAuthenticatedFetch()??window.fetch.bind(window)},error:e=>e.loginError?e.loginError??null:e.ignorePreviousSessionError?null:e.previousSession?.error??null}});class re extends se{constructor(){super(...arguments),w(this,"publicTypeIndexes",{}),w(this,"privateTypeIndexes",{})}isLoggedIn(){return this.loggedIn}requireAuthenticator(){return this.authenticator??I("Could not get authenticator")}requireUser(){return this.user??I("Could not get user profile")}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]??A(await R(e,{fetch:this.fetch,required:t}),(e=>e&&this.rememberProfile(e)))}async refreshUserProfile(){if(!this.isLoggedIn())return;this.setState({profiles:_(this.profiles,[this.user.webId])});const e=await this.requireUserProfile(this.user.webId);this.setState({session:{...this.session,user:e}})}async login(e,r){if(r=r??this.preferredAuthenticator??"default",t.development&&"devserver"===e&&(e="http://localhost:4000"),this.loggedIn)return!0;if(this.loginOngoing)throw new Error("Authentication already in progress");const n=setTimeout((()=>this.loginStale=!0),1e4);this.loginOngoing=!0;try{const t=await this.getUserProfile(e),s=t?.oidcIssuerUrl??$(t?.webId??e),n=await this.bootAuthenticator(r);return this.setState({dismissed:!1,ignorePreviousSessionError:!0,previousSession:{loginUrl:e,avatarUrl:t?.avatarUrl,authenticator:r,error:i("auth.stuckConnecting","We didn't hear back from the identity provider, maybe try reconnecting?")}}),await n.login(s),!0}catch(e){return e instanceof AuthenticationCancelledError||(t.isMounted?s.report(e):this.setState({loginError:e})),!1}finally{clearTimeout(n),this.loginOngoing=!1,this.loginStale=!1}}async reconnect(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.loggedIn||!this.previousSession||null!==this.previousSession.error&&!e||await this.login(this.previousSession.loginUrl,this.previousSession.authenticator)}async logout(){(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||await r.confirm(i("solid.logoutConfirm","Are you sure you want to log out?")))&&this.previousSession&&(this.setState({previousSession:null}),this.isLoggedIn()&&await this.authenticator.logout(),await n.emit("logout"))}dismiss(){this.setState({dismissed:!0})}async findOrCreatePrivateTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't find or create a type index because the user is not logged in");const e=this.user.webId;return this.privateTypeIndexes[e]=this.privateTypeIndexes[e]??b.from((async()=>await this.findPrivateTypeIndex()??await this.createPrivateTypeIndex())())}async findOrCreatePublicTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't find or create a type index because the user is not logged in");const e=this.user.webId;return this.publicTypeIndexes[e]=this.publicTypeIndexes[e]??b.from((async()=>await this.findPublicTypeIndex()??await this.createPublicTypeIndex())())}async createPrivateContainer(e){const t=this.requireAuthenticator().engine;return f.withEngine(t,(async()=>{const t=await f.find(e.url);if(t&&!e.reuseExisting)throw new J(t);const i=t??new f({url:e.url,name:e.url});if(await i.save(),e.registerFor){const t=await this.findOrCreatePrivateTypeIndex();await i.register(t.url,e.registerFor)}return i}))}async boot(){await s.booted,L("authenticator")&&this.setState({preferredAuthenticator:E("authenticator")}),L("refreshProfile")&&this.setState({staleProfiles:T(this.staleProfiles.concat(j([this.session?.user.webId,this.previousSession?.loginUrl])))}),await this.restorePreviousSession(),await this.startupReconnect()}async findPrivateTypeIndex(){const e=this.requireUser(),t=this.requireAuthenticator();return p.withEngine(t.engine,(()=>p.find(e.privateTypeIndexUrl)))}async createPrivateTypeIndex(){const e=this.requireUser(),t=this.requireAuthenticator(),i=await p.withEngine(t.engine).createPrivate(e);return A(i,(()=>{e.privateTypeIndexUrl=i.url,this.rememberProfile(e)}))}async findPublicTypeIndex(){return this.user?.publicTypeIndexUrl?p.find(this.user.publicTypeIndexUrl):null}async createPublicTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't create a type index because the user is not logged in");const e=this.user,t=await p.withEngine(this.authenticator.engine,(()=>p.createPublic(e)));return A(t,(()=>{e.publicTypeIndexUrl=t.url,this.rememberProfile(e)}))}async restorePreviousSession(){this.previousSession&&await this.bootAuthenticator(this.previousSession.authenticator)}async startupReconnect(){this.reconnectOnStartup()&&await this.reconnect()}reconnectOnStartup(){return L("autoReconnect")?F(E("autoReconnect")):this.autoReconnect}async bootAuthenticator(e){const t=ee(e);return t.addListener({onSessionStarted:async e=>{this.setState({session:e,previousSession:{authenticator:t.name,loginUrl:e.loginUrl,avatarUrl:e.user.avatarUrl,error:null}}),(e.user.cloaked||!e.user.writableProfileUrl||this.staleProfiles.includes(e.user.webId))&&await this.refreshUserProfile(),m.setEngine(e.authenticator.engine),await n.emit("login",e)},onSessionFailed:async(e,i)=>{this.setState({session:null,previousSession:{authenticator:t.name,loginUrl:e,error:i}})},onSessionEnded:()=>this.setState({session:null}),onAuthenticatedFetchReady:e=>n.emit("authenticated-fetch-ready",e)}),await t.boot(),t}rememberProfile(e){this.setState({profiles:{...this.profiles,[e.webId]:e},staleProfiles:C(this.staleProfiles,e.webId)})}}var ne=U(new re),oe=Object.freeze({__proto__:null,SolidService:re,default:ne});const ae={class:"flex flex-col gap-3"},le={class:"flex flex-col"};var ue=k({__name:"AGSolidStatus",setup(e){const t=o({url:a()});return(e,i)=>(q(),O("div",null,[e.$solid.loginStale?z(e.$slots,"login-stale",{key:0},(()=>[G(W(l),{text:e.$td("solid.loginStale","This is taking too long...")},null,8,["text"])])):N("v-if",!0),e.$solid.loginOngoing?z(e.$slots,"login-ongoing",{key:1},(()=>[G(W(l),{text:e.$td("ui.loading","Loading...")},null,8,["text"])])):e.$solid.isLoggedIn()?z(e.$slots,"logged-in",{key:2,session:e.$solid.session},(()=>[B("div",ae,[G(W(l),{text:e.$td("solid.loggedIn",{userName:e.$solid.user.name??e.$solid.user.webId,userWebId:e.$solid.user.webId},"You are logged in as [{userName}]({userWebId})")},null,8,["text"]),G(W(u),{onClick:i[0]||(i[0]=t=>e.$solid.logout())},{default:M((()=>[Y(D(e.$td("solid.logout","Logout")),1)])),_:1})])])):z(e.$slots,"logged-out",{key:3},(()=>[B("div",le,[G(W(c),{form:W(t),class:"flex",onSubmit:i[1]||(i[1]=i=>e.$solid.login(W(t).url))},{default:M((()=>[G(W(d),{name:"url","aria-label":e.$td("solid.url","Login url"),placeholder:e.$td("solid.placeholder","https://...")},null,8,["aria-label","placeholder"]),G(W(u),{submit:""},{default:M((()=>[Y(D(e.$td("solid.login","Login")),1)])),_:1})])),_:1},8,["form"]),e.$solid.wasLoggedIn?(q(),H(W(u),{key:0,class:"mt-3",onClick:i[2]||(i[2]=t=>e.$solid.reconnect(!0))},{default:M((()=>[Y(D(e.$td("solid.reconnect","Reconnect")),1)])),_:1})):N("v-if",!0),e.$solid.previousSession?.error?(q(),H(W(l),{key:1,class:"mt-1 self-center text-sm text-red-800",text:e.$td("solid.previousLoginError","Previous login attempt failed")},null,8,["text"])):N("v-if",!0)])]))]))}});ue.__file="src/components/AGSolidStatus.vue";const ce={$solid:ne};function de(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{async install(t){y(),te({...X,...e.authenticators??{}}),Z(ee(e.defaultAuthenticator??"inrupt")),await h(t,ce)}}}export{ue as AGSolidStatus,AuthenticationCancelledError,J as ContainerAlreadyInUse,ne as Solid,X as authenticators,de as default,ee as getAuthenticator,ie as registerAuthenticator,te as registerAuthenticators,Z as setDefaultAuthenticator};
1
+ import{defineServiceState as e,App as t,translateWithDefault as i,Errors as s,UI as r,Events as n,useForm as o,requiredStringInput as a,AGMarkdown as l,AGButton as u,AGForm as c,AGInput as d,bootServices as h}from"@aerogel/core";import{SolidEngine as g,SolidContainer as f,SolidTypeIndex as p,SolidACLAuthorization as m,bootSolidModels as w}from"soukai-solid";import y from"@babel/runtime/helpers/esm/defineProperty";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 v,arr as S,fail as b,PromisedValue as I,Storage as x,after as P,facade as U,tap as A,objectWithout as _,urlRoot as $,hasLocationQueryParameter as L,getLocationQueryParameter as E,arrayUnique as T,arrayFilter as j,parseBoolean as C,arrayWithout as F}from"@noeldemartin/utils";import{fetchLoginUserProfile as R}from"@noeldemartin/solid-utils";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{defineComponent as k,openBlock as q,createElementBlock as O,renderSlot as G,createVNode as W,unref as z,createCommentVNode as N,createElementVNode as B,withCtx as D,createTextVNode as M,toDisplayString as Y,createBlock as H}from"vue";class AuthenticationCancelledError extends v{}class J extends v{constructor(e,t){super(`Container at ${e.url} is already in use`,t)}}class K{constructor(){y(this,"name",void 0),y(this,"authenticatedFetch",void 0),y(this,"booted",void 0),y(this,"listeners",S([])),y(this,"_engine",void 0)}get engine(){return this._engine=this._engine??new g(this.requireAuthenticatedFetch()),this._engine}getAuthenticatedFetch(){return this.authenticatedFetch??null}requireAuthenticatedFetch(){return this.authenticatedFetch??b("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,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 Q="inrupt-authenticator";const V={},X={inrupt:new class extends K{constructor(){super(...arguments),y(this,"_fetch",void 0),y(this,"_login",void 0),y(this,"_logout",void 0),y(this,"_handleIncomingRedirect",void 0)}async login(e){return x.set(Q,!0),await this._login({oidcIssuer:e}),await P({seconds:60}),b("Browser should have redirected, but it didn't")}async logout(){await this._logout(),await this.endSession()}async restoreSession(){const{fetch:e,handleIncomingRedirect:t,login:i,logout:s}=await import("@inrupt/solid-client-authn-browser");this._fetch=e,this._login=i,this._logout=s,this._handleIncomingRedirect=t,await this.loginFromRedirect()}async loginFromRedirect(){if(!x.has(Q))return;const e=await this._handleIncomingRedirect(window.location.href);x.remove(Q),e?.isLoggedIn&&e.webId&&await this.initSession(e.webId)}async initSession(e){await this.initAuthenticatedFetch(this._fetch);try{const{default:t}=await Promise.resolve().then((function(){return oe})),i=await t.requireUserProfile(e);await this.startSession({user:i,loginUrl:e})}catch(t){await this.failSession(e,t)}}}};function Z(e){V.default=e}function ee(e){return V[e]}function te(e){Object.entries(e).forEach((e=>{let[t,i]=e;return ie(t,i)}))}function ie(e,t){V[e]=t,t.name=t.name??e}var se=e({name:"solid",persist:["autoReconnect","dismissed","previousSession","profiles","staleProfiles"],initialState:{autoReconnect:!1,dismissed:!1,ignorePreviousSessionError:!1,loginError: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:{loggedIn:e=>!!e.session,user:e=>e.session?.user??null,userAvatarUrl:e=>e.session?.user?.avatarUrl??e.previousSession?.avatarUrl??null,wasLoggedIn:e=>!!e.previousSession?.loginUrl,authenticator:e=>e.session?.authenticator??null,hasLoggedIn(){return this.loggedIn||this.wasLoggedIn},fetch(){return this.authenticator?.getAuthenticatedFetch()??window.fetch.bind(window)},error:e=>e.loginError?e.loginError??null:e.ignorePreviousSessionError?null:e.previousSession?.error??null}});class re extends se{constructor(){super(...arguments),y(this,"publicTypeIndexes",{}),y(this,"privateTypeIndexes",{})}isLoggedIn(){return this.loggedIn}requireAuthenticator(){return this.authenticator??b("Could not get authenticator")}requireUser(){return this.user??b("Could not get user profile")}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]??A(await R(e,{fetch:this.fetch,required:t}),(e=>e&&this.rememberProfile(e)))}async refreshUserProfile(){if(!this.isLoggedIn())return;this.setState({profiles:_(this.profiles,[this.user.webId])});const e=await this.requireUserProfile(this.user.webId);this.setState({session:{...this.session,user:e}})}async login(e,r){if(r=r??this.preferredAuthenticator??"default",t.isDevelopment&&"devserver"===e&&(e="http://localhost:4000"),this.loggedIn)return!0;if(this.loginOngoing)throw new Error("Authentication already in progress");const n=setTimeout((()=>this.loginStale=!0),1e4);this.loginOngoing=!0;try{const t=await this.getUserProfile(e),s=t?.oidcIssuerUrl??$(t?.webId??e),n=await this.bootAuthenticator(r);return this.setState({dismissed:!1,ignorePreviousSessionError:!0,previousSession:{loginUrl:e,avatarUrl:t?.avatarUrl,authenticator:r,error:i("auth.stuckConnecting","We didn't hear back from the identity provider, maybe try reconnecting?")}}),await n.login(s),!0}catch(e){return e instanceof AuthenticationCancelledError||(t.isMounted?s.report(e):this.setState({loginError:e})),!1}finally{clearTimeout(n),this.loginOngoing=!1,this.loginStale=!1}}async reconnect(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.loggedIn||!this.previousSession||null!==this.previousSession.error&&!e||await this.login(this.previousSession.loginUrl,this.previousSession.authenticator)}async logout(){(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||await r.confirm(i("solid.logoutConfirm","Are you sure you want to log out?")))&&this.previousSession&&(this.setState({previousSession:null}),this.isLoggedIn()&&await this.authenticator.logout(),await n.emit("logout"))}dismiss(){this.setState({dismissed:!0})}async findOrCreatePrivateTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't find or create a type index because the user is not logged in");const e=this.user.webId;return this.privateTypeIndexes[e]=this.privateTypeIndexes[e]??I.from((async()=>await this.findPrivateTypeIndex()??await this.createPrivateTypeIndex())())}async findOrCreatePublicTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't find or create a type index because the user is not logged in");const e=this.user.webId;return this.publicTypeIndexes[e]=this.publicTypeIndexes[e]??I.from((async()=>await this.findPublicTypeIndex()??await this.createPublicTypeIndex())())}async createPrivateContainer(e){const t=this.requireAuthenticator().engine;return f.withEngine(t,(async()=>{const t=await f.find(e.url);if(t&&!e.reuseExisting)throw new J(t);const i=t??new f({url:e.url,name:e.url});return await i.save(),e.register&&await i.register(e.register.typeIndex.url,e.register.modelClass),i}))}async boot(){await super.boot(),await s.booted,L("authenticator")&&this.setState({preferredAuthenticator:E("authenticator")}),L("refreshProfile")&&this.setState({staleProfiles:T(this.staleProfiles.concat(j([this.session?.user.webId,this.previousSession?.loginUrl])))}),await this.restorePreviousSession(),await this.startupReconnect()}async findPrivateTypeIndex(){const e=this.requireUser(),t=this.requireAuthenticator();return p.withEngine(t.engine,(()=>p.find(e.privateTypeIndexUrl)))}async createPrivateTypeIndex(){const e=this.requireUser(),t=this.requireAuthenticator(),i=await p.withEngine(t.engine).createPrivate(e);return A(i,(()=>{e.privateTypeIndexUrl=i.url,this.rememberProfile(e)}))}async findPublicTypeIndex(){return this.user?.publicTypeIndexUrl?p.find(this.user.publicTypeIndexUrl):null}async createPublicTypeIndex(){if(!this.isLoggedIn())throw new Error("Can't create a type index because the user is not logged in");const e=this.user,t=await p.withEngine(this.authenticator.engine,(()=>p.createPublic(e)));return A(t,(()=>{e.publicTypeIndexUrl=t.url,this.rememberProfile(e)}))}async restorePreviousSession(){this.previousSession&&await this.bootAuthenticator(this.previousSession.authenticator)}async startupReconnect(){this.reconnectOnStartup()&&await this.reconnect()}reconnectOnStartup(){return L("autoReconnect")?C(E("autoReconnect")):this.autoReconnect}async bootAuthenticator(e){const t=ee(e);return t.addListener({onSessionStarted:async e=>{this.setState({session:e,previousSession:{authenticator:t.name,loginUrl:e.loginUrl,avatarUrl:e.user.avatarUrl,error:null}}),(e.user.cloaked||!e.user.writableProfileUrl||this.staleProfiles.includes(e.user.webId))&&await this.refreshUserProfile(),m.setEngine(e.authenticator.engine),await n.emit("login",e)},onSessionFailed:async(e,i)=>{this.setState({session:null,previousSession:{authenticator:t.name,loginUrl:e,error:i}})},onSessionEnded:()=>this.setState({session:null}),onAuthenticatedFetchReady:e=>n.emit("authenticated-fetch-ready",e)}),await t.boot(),t}rememberProfile(e){this.setState({profiles:{...this.profiles,[e.webId]:e},staleProfiles:F(this.staleProfiles,e.webId)})}}var ne=U(new re),oe=Object.freeze({__proto__:null,SolidService:re,default:ne});const ae={class:"flex flex-col gap-3"},le={class:"flex flex-col"};var ue=k({__name:"AGSolidStatus",setup(e){const t=o({url:a()});return(e,i)=>(q(),O("div",null,[e.$solid.loginStale?G(e.$slots,"login-stale",{key:0},(()=>[W(z(l),{text:e.$td("solid.loginStale","This is taking too long...")},null,8,["text"])])):N("v-if",!0),e.$solid.loginOngoing?G(e.$slots,"login-ongoing",{key:1},(()=>[W(z(l),{text:e.$td("ui.loading","Loading...")},null,8,["text"])])):e.$solid.isLoggedIn()?G(e.$slots,"logged-in",{key:2,session:e.$solid.session},(()=>[B("div",ae,[W(z(l),{text:e.$td("solid.loggedIn",{userName:e.$solid.user.name??e.$solid.user.webId,userWebId:e.$solid.user.webId},"You are logged in as [{userName}]({userWebId})")},null,8,["text"]),W(z(u),{onClick:i[0]||(i[0]=t=>e.$solid.logout())},{default:D((()=>[M(Y(e.$td("solid.logout","Logout")),1)])),_:1})])])):G(e.$slots,"logged-out",{key:3},(()=>[B("div",le,[W(z(c),{form:z(t),class:"flex",onSubmit:i[1]||(i[1]=i=>e.$solid.login(z(t).url))},{default:D((()=>[W(z(d),{name:"url","aria-label":e.$td("solid.url","Login url"),placeholder:e.$td("solid.placeholder","https://...")},null,8,["aria-label","placeholder"]),W(z(u),{submit:""},{default:D((()=>[M(Y(e.$td("solid.login","Login")),1)])),_:1})])),_:1},8,["form"]),e.$solid.wasLoggedIn?(q(),H(z(u),{key:0,class:"mt-3",onClick:i[2]||(i[2]=t=>e.$solid.reconnect(!0))},{default:D((()=>[M(Y(e.$td("solid.reconnect","Reconnect")),1)])),_:1})):N("v-if",!0),e.$solid.previousSession?.error?(q(),H(z(l),{key:1,class:"mt-1 self-center text-sm text-red-800",text:e.$td("solid.previousLoginError","Previous login attempt failed")},null,8,["text"])):N("v-if",!0)])]))]))}});ue.__file="src/components/AGSolidStatus.vue";const ce={$solid:ne};function de(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{async install(t){w(),te({...X,...e.authenticators??{}}),Z(ee(e.defaultAuthenticator??"inrupt")),await h(t,ce)}}}export{ue as AGSolidStatus,AuthenticationCancelledError,J as ContainerAlreadyInUse,ne as Solid,X as authenticators,de as default,ee as getAuthenticator,ie as registerAuthenticator,te as registerAuthenticators,Z as setDefaultAuthenticator};
2
2
  //# sourceMappingURL=aerogel-plugin-solid.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aerogel-plugin-solid.esm.js","sources":["../src/errors/AuthenticationCancelledError.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/AGSolidStatus.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';\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 { handleIncomingRedirect, login, logout } from '@inrupt/solid-client-authn-browser';\n\nimport Authenticator from '@/auth/Authenticator';\nimport type { AuthSession } from '@/auth/Authenticator';\n\nconst STORAGE_KEY = 'inrupt-authenticator';\n\nexport default class InruptAuthenticator extends Authenticator {\n\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<boolean>(STORAGE_KEY, true);\n\n await this._login({\n oidcIssuer: loginUrl,\n // TODO clientId, clientName, and redirectUrl\n });\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 { fetch, handleIncomingRedirect, login, logout } = await import('./InruptAuthenticator.lazy');\n\n this._fetch = fetch;\n this._login = login;\n this._logout = logout;\n this._handleIncomingRedirect = handleIncomingRedirect;\n\n await this.loginFromRedirect();\n }\n\n protected async loginFromRedirect(): Promise<void> {\n if (!Storage.has(STORAGE_KEY)) {\n return;\n }\n\n const session = await this._handleIncomingRedirect(window.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 default defineServiceState({\n name: 'solid',\n persist: ['autoReconnect', 'dismissed', 'previousSession', 'profiles', 'staleProfiles'],\n initialState: {\n autoReconnect: false,\n dismissed: false,\n ignorePreviousSessionError: false,\n loginError: null as ErrorSource | null,\n loginOngoing: false,\n preferredAuthenticator: null as AuthenticatorName | null,\n previousSession: null as {\n authenticator: AuthenticatorName;\n loginUrl: string;\n avatarUrl?: 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 loggedIn: (state) => !!state.session,\n user: (state) => state.session?.user ?? null,\n userAvatarUrl: (state) => state.session?.user?.avatarUrl ?? state.previousSession?.avatarUrl ?? null,\n wasLoggedIn: (state) => !!state.previousSession?.loginUrl,\n authenticator: (state) => state.session?.authenticator ?? null,\n hasLoggedIn(): boolean {\n return this.loggedIn || this.wasLoggedIn;\n },\n fetch(): Fetch {\n return this.authenticator?.getAuthenticatedFetch() ?? window.fetch.bind(window);\n },\n error(state): ErrorSource | null {\n if (state.loginError) {\n return state.loginError ?? null;\n }\n\n if (state.ignorePreviousSessionError) {\n return null;\n }\n\n return state.previousSession?.error ?? null;\n },\n },\n});\n","import {\n PromisedValue,\n arrayFilter,\n arrayUnique,\n arrayWithout,\n facade,\n fail,\n getLocationQueryParameter,\n hasLocationQueryParameter,\n objectWithout,\n parseBoolean,\n tap,\n urlRoot,\n} from '@noeldemartin/utils';\nimport { fetchLoginUserProfile } from '@noeldemartin/solid-utils';\nimport { App, Errors, Events, UI, translateWithDefault } from '@aerogel/core';\nimport { SolidACLAuthorization, SolidContainer, SolidTypeIndex } from 'soukai-solid';\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 { AuthenticatorName } from '@/auth';\nimport type Authenticator from '@/auth/Authenticator';\nimport type { AuthSession } from '@/auth/Authenticator';\n\nimport Service from './Solid.state';\n\nexport class SolidService extends Service {\n\n protected publicTypeIndexes: Record<string, PromisedValue<SolidTypeIndex>> = {};\n protected privateTypeIndexes: Record<string, PromisedValue<SolidTypeIndex>> = {};\n\n public isLoggedIn(): this is { session: AuthSession; user: SolidUserProfile; authenticator: Authenticator } {\n return this.loggedIn;\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');\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, authenticatorName?: AuthenticatorName): Promise<boolean> {\n authenticatorName = authenticatorName ?? this.preferredAuthenticator ?? 'default';\n\n if (App.development && loginUrl === 'devserver') {\n loginUrl = 'http://localhost:4000';\n }\n\n if (this.loggedIn) {\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 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\n this.setState({\n dismissed: false,\n ignorePreviousSessionError: true,\n previousSession: {\n loginUrl,\n avatarUrl: profile?.avatarUrl,\n authenticator: authenticatorName,\n error: translateWithDefault(\n 'auth.stuckConnecting',\n 'We didn\\'t hear back from the identity provider, maybe try reconnecting?',\n ),\n },\n });\n\n await authenticator.login(oidcIssuerUrl);\n\n return true;\n } catch (error) {\n if (error instanceof AuthenticationCancelledError) {\n return false;\n }\n\n App.isMounted ? Errors.report(error) : this.setState({ loginError: error });\n\n return false;\n } finally {\n clearTimeout(staleTimeout);\n\n this.loginOngoing = false;\n this.loginStale = false;\n }\n }\n\n public async reconnect(force: boolean = false): Promise<void> {\n if (this.loggedIn || !this.previousSession || (this.previousSession.error !== null && !force)) {\n return;\n }\n\n await this.login(this.previousSession.loginUrl, this.previousSession.authenticator);\n }\n\n public async logout(force: boolean = false): Promise<void> {\n const confirmLogout =\n force ||\n (await UI.confirm(translateWithDefault('solid.logoutConfirm', 'Are you sure you want to log out?')));\n\n if (!confirmLogout) {\n return;\n }\n\n if (!this.previousSession) {\n return;\n }\n\n this.setState({ previousSession: null });\n this.isLoggedIn() && (await this.authenticator.logout());\n\n await Events.emit('logout');\n }\n\n public dismiss(): void {\n this.setState({ dismissed: true });\n }\n\n public async findOrCreatePrivateTypeIndex(): Promise<SolidTypeIndex> {\n if (!this.isLoggedIn()) {\n throw new Error('Can\\'t find or create a type index because the user is not logged in');\n }\n\n const webId = this.user.webId;\n\n return (this.privateTypeIndexes[webId] =\n this.privateTypeIndexes[webId] ??\n PromisedValue.from(\n (async () => (await this.findPrivateTypeIndex()) ?? (await this.createPrivateTypeIndex()))(),\n ));\n }\n\n public async findOrCreatePublicTypeIndex(): Promise<SolidTypeIndex> {\n if (!this.isLoggedIn()) {\n throw new Error('Can\\'t find or create a type index because the user is not logged in');\n }\n\n const webId = this.user.webId;\n\n return (this.publicTypeIndexes[webId] =\n this.publicTypeIndexes[webId] ??\n PromisedValue.from(\n (async () => (await this.findPublicTypeIndex()) ?? (await this.createPublicTypeIndex()))(),\n ));\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.url });\n\n await container.save();\n\n if (options.registerFor) {\n const typeIndex = await this.findOrCreatePrivateTypeIndex();\n\n await container.register(typeIndex.url, 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 findPrivateTypeIndex(): Promise<SolidTypeIndex | null> {\n const user = this.requireUser();\n const authenticator = this.requireAuthenticator();\n\n return SolidTypeIndex.withEngine(authenticator.engine, () => SolidTypeIndex.find(user.privateTypeIndexUrl));\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 this.rememberProfile(user);\n });\n }\n\n protected async findPublicTypeIndex(): Promise<SolidTypeIndex | null> {\n if (!this.user?.publicTypeIndexUrl) {\n return null;\n }\n\n return SolidTypeIndex.find(this.user.publicTypeIndexUrl);\n }\n\n public async createPublicTypeIndex(): Promise<SolidTypeIndex> {\n if (!this.isLoggedIn()) {\n throw new Error('Can\\'t create a type index because the user is not logged in');\n }\n\n const user = this.user;\n const typeIndex = await SolidTypeIndex.withEngine(this.authenticator.engine, () =>\n SolidTypeIndex.createPublic(user));\n\n return tap(typeIndex, () => {\n user.publicTypeIndexUrl = typeIndex.url;\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 avatarUrl: session.user.avatarUrl,\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 SolidACLAuthorization.setEngine(session.authenticator.engine);\n\n await Events.emit('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('authenticated-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(new SolidService());\n\ndeclare module '@aerogel/core' {\n export interface EventsPayload {\n 'authenticated-fetch-ready': Fetch;\n login: AuthSession;\n logout: void;\n }\n}\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(\n 'solid.loggedIn',\n {\n userName: $solid.user.name ?? $solid.user.webId,\n userWebId: $solid.user.webId,\n },\n 'You are logged in as [{userName}]({userWebId})'\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(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","import { bootServices } from '@aerogel/core';\nimport { bootSolidModels } from 'soukai-solid';\nimport type { Plugin } from '@aerogel/core';\n\nimport Solid from '@/services/Solid';\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 { Solid };\nexport * from './auth';\nexport * from './components';\nexport * from './errors';\n\nexport interface Options {\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 await bootServices(app, services);\n },\n };\n}\n\ndeclare module '@vue/runtime-core' {\n interface ComponentCustomProperties extends SolidServices {}\n}\n"],"names":["AuthenticationCancelledError","JSError","ContainerAlreadyInUse","constructor","container","options","super","url","Authenticator","_defineProperty","this","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","_login","oidcIssuer","after","seconds","logout","_logout","handleIncomingRedirect","import","_fetch","_handleIncomingRedirect","loginFromRedirect","has","window","location","href","isLoggedIn","webId","initSession","default","Solid","then","Solid$1","user","requireUserProfile","setDefaultAuthenticator","getAuthenticator","name","registerAuthenticators","customAuthenticators","Object","entries","forEach","_ref","registerAuthenticator","Service","defineServiceState","persist","initialState","autoReconnect","dismissed","ignorePreviousSessionError","loginError","loginOngoing","preferredAuthenticator","previousSession","profiles","loginStale","staleProfiles","serialize","state","Error","message","computed","loggedIn","userAvatarUrl","avatarUrl","wasLoggedIn","hasLoggedIn","bind","SolidService","requireAuthenticator","requireUser","getUserProfile","required","tap","fetchLoginUserProfile","profile","rememberProfile","refreshUserProfile","setState","objectWithout","authenticatorName","App","development","staleTimeout","setTimeout","oidcIssuerUrl","urlRoot","bootAuthenticator","translateWithDefault","isMounted","Errors","report","clearTimeout","reconnect","force","undefined","UI","confirm","Events","emit","dismiss","findOrCreatePrivateTypeIndex","privateTypeIndexes","from","findPrivateTypeIndex","createPrivateTypeIndex","findOrCreatePublicTypeIndex","publicTypeIndexes","findPublicTypeIndex","createPublicTypeIndex","createPrivateContainer","SolidContainer","withEngine","existingContainer","find","reuseExisting","save","registerFor","typeIndex","register","hasLocationQueryParameter","getLocationQueryParameter","arrayUnique","concat","arrayFilter","restorePreviousSession","startupReconnect","SolidTypeIndex","privateTypeIndexUrl","createPrivate","publicTypeIndexUrl","createPublic","reconnectOnStartup","parseBoolean","onSessionStarted","cloaked","writableProfileUrl","SolidACLAuthorization","setEngine","onSessionFailed","onSessionEnded","onAuthenticatedFetchReady","arrayWithout","facade","form","useForm","requiredStringInput","services","$solid","solid","install","app","bootSolidModels","baseAuthenticators","defaultAuthenticator","bootServices"],"mappings":"mhDAEqB,MAAAA,qCAAqCC,GCErC,MAAAC,UAA8BD,EAE/CE,WAAAA,CAAYC,EAA2BC,GACnCC,sBAAsBF,EAAUG,wBAAyBF,EAC7D,ECqBU,MAAgBG,EAAaL,WAAAA,GAAAM,EAAAC,KAAA,YAAA,GAAAD,EAAAC,KAAA,0BAAA,GAAAD,EAAAC,KAAA,cAAA,GAAAD,EAMiBE,KAAAA,YAAAA,EAA2B,KAAGF,EAAAC,KAAA,eAAA,EAAA,CAOtF,UAAWE,GAGP,OAFAF,KAAKG,QAAUH,KAAKG,SAAW,IAAIC,EAAYJ,KAAKK,6BAE7CL,KAAKG,OAChB,CAEOG,qBAAAA,GACH,OAAON,KAAKO,oBAAsB,IACtC,CAEOF,yBAAAA,GACH,OAAOL,KAAKO,oBAAsBC,EAAK,mCAC3C,CAEOC,WAAAA,CAAYC,GAGf,OAFKV,KAAKW,UAAUC,SAASF,IAAWV,KAAKW,UAAUE,KAAKH,GAErD,KACHV,KAAKc,eAAeJ,EAAS,CAErC,CAEOI,cAAAA,CAAeJ,GACbV,KAAKW,UAAUC,SAASF,IAE7BV,KAAKW,UAAUI,OAAOL,EAC1B,CAEO,UAAMM,GACT,GAAIhB,KAAKiB,OACL,OAAOjB,KAAKiB,OAGhBjB,KAAKiB,OAAS,IAAIC,QAEZlB,KAAKmB,iBAEXnB,KAAKiB,OAAOG,SAChB,CAIU,4BAAMC,CAAuBC,GACnCtB,KAAKO,mBAAqBe,QAEpBtB,KAAKuB,gBAAgB,4BAA6BD,EAC5D,CAEU,kBAAME,CAAaC,GACzB,MAAMC,E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SAAS,CACV/F,UACAsE,gBAAiB,CACbrE,cAAeA,EAAcmD,KAC7BjD,SAAUH,EAAQG,SAClB8E,UAAWjF,EAAQgD,KAAKiC,UACxB7E,MAAO,SAKXJ,EAAQgD,KAAKwG,UACZxJ,EAAQgD,KAAKyG,oBACdnL,KAAKmG,cAAcvF,SAASc,EAAQgD,KAAKN,eAEnCpE,KAAKwH,qBAGf4D,EAAsBC,UAAU3J,EAAQC,cAAczB,cAEhD2I,EAAOC,KAAK,QAASpH,EAAQ,EAEvC4J,gBAAiB3I,MAAOd,EAAUC,KAC9B9B,KAAKyH,SAAS,CACV/F,QAAS,KACTsE,gBAAiB,CACbrE,cAAeA,EAAcmD,KAC7BjD,WACAC,UAEN,EAENyJ,eAAgBA,IAAMvL,KAAKyH,SAAS,CAAE/F,QAAS,OAC/C8J,0BAA4BlK,GAAUuH,EAAOC,KAAK,4BAA6BxH,WAG7EK,EAAcX,OAEbW,CACX,CAEQ4F,eAAAA,CAAgBD,GACpBtH,KAAKyH,SAAS,CACVxB,SAAU,IACHjG,KAAKiG,SACR,CAACqB,EAAQlD,OAAQkD,GAErBnB,cAAesF,EAAazL,KAAKmG,cAAemB,EAAQlD,QAEhE,EAIJ,IAAAG,GAAemH,EAAO,IAAI3E,8KC1T1B,MAAM4E,EAAOC,EAAQ,CAAE/L,IAAKgM,0iDC5C5B,MAAMC,GAAW,CAAEC,OAAQxH,IAcb,SAAUyH,KAA2B,IAArBrM,yDAAmB,CAAA,EAC7C,MAAO,CACH,aAAMsM,CAAQC,GACVC,IACApH,GAAuB,IAAKqH,KAAwBzM,EAAQoD,gBAAkB,KAC9E6B,EAAwBC,GAAiBlF,EAAQ0M,sBAAwB,iBAEnEC,EAAaJ,EAAKJ,GAC5B,EAER"}
1
+ {"version":3,"file":"aerogel-plugin-solid.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aerogel/plugin-solid",
3
3
  "description": "Aerogel Solid plugin",
4
- "version": "0.0.1-next.f8cdd39997c56dcd46e07c26af8a84d04d610fce",
4
+ "version": "0.0.1",
5
5
  "main": "dist/aerogel-plugin-solid.cjs.js",
6
6
  "module": "dist/aerogel-plugin-solid.esm.js",
7
7
  "types": "dist/aerogel-plugin-solid.d.ts",
@@ -34,8 +34,8 @@
34
34
  "soukai-solid": "*"
35
35
  },
36
36
  "dependencies": {
37
- "@inrupt/solid-client-authn-browser": "^1.17.3",
38
- "@noeldemartin/solid-utils": "0.3.0-next.5176c3d9efdc3cf9d06772d0c55c24b2eb49893a",
37
+ "@inrupt/solid-client-authn-browser": "^1.17.1",
38
+ "@noeldemartin/solid-utils": "^0.3.0",
39
39
  "@noeldemartin/utils": "0.4.0-next.ac00beaecf32bb02ed8e335225d7948d946d73bd",
40
40
  "vue": "^3.3.0"
41
41
  }
@@ -69,9 +69,7 @@ export default abstract class Authenticator {
69
69
  }
70
70
 
71
71
  public async boot(): Promise<void> {
72
- if (this.booted) {
73
- return this.booted;
74
- }
72
+ if (this.booted) return this.booted;
75
73
 
76
74
  this.booted = new PromisedValue();
77
75
 
@@ -34,7 +34,7 @@ export default class InruptAuthenticator extends Authenticator {
34
34
  }
35
35
 
36
36
  protected async restoreSession(): Promise<void> {
37
- const { fetch, handleIncomingRedirect, login, logout } = await import('./InruptAuthenticator.lazy');
37
+ const { fetch, handleIncomingRedirect, login, logout } = await import('@inrupt/solid-client-authn-browser');
38
38
 
39
39
  this._fetch = fetch;
40
40
  this._login = login;
@@ -45,7 +45,7 @@ export default defineServiceState({
45
45
  fetch(): Fetch {
46
46
  return this.authenticator?.getAuthenticatedFetch() ?? window.fetch.bind(window);
47
47
  },
48
- error(state): ErrorSource | null {
48
+ error(state) {
49
49
  if (state.loginError) {
50
50
  return state.loginError ?? null;
51
51
  }
@@ -14,8 +14,8 @@ import {
14
14
  } from '@noeldemartin/utils';
15
15
  import { fetchLoginUserProfile } from '@noeldemartin/solid-utils';
16
16
  import { App, Errors, Events, UI, translateWithDefault } from '@aerogel/core';
17
- import { SolidACLAuthorization, SolidContainer, SolidTypeIndex } from 'soukai-solid';
18
17
  import type { Fetch, SolidModelConstructor } from 'soukai-solid';
18
+ import { SolidACLAuthorization, SolidContainer, SolidTypeIndex } from 'soukai-solid';
19
19
  import type { SolidUserProfile } from '@noeldemartin/solid-utils';
20
20
 
21
21
  import AuthenticationCancelledError from '@/errors/AuthenticationCancelledError';
@@ -83,7 +83,7 @@ export class SolidService extends Service {
83
83
  public async login(loginUrl: string, authenticatorName?: AuthenticatorName): Promise<boolean> {
84
84
  authenticatorName = authenticatorName ?? this.preferredAuthenticator ?? 'default';
85
85
 
86
- if (App.development && loginUrl === 'devserver') {
86
+ if (App.isDevelopment && loginUrl === 'devserver') {
87
87
  loginUrl = 'http://localhost:4000';
88
88
  }
89
89
 
@@ -198,7 +198,10 @@ export class SolidService extends Service {
198
198
  public async createPrivateContainer(options: {
199
199
  url: string;
200
200
  name: string;
201
- registerFor?: SolidModelConstructor;
201
+ register?: {
202
+ typeIndex: SolidTypeIndex;
203
+ modelClass: SolidModelConstructor;
204
+ };
202
205
  reuseExisting?: boolean;
203
206
  }): Promise<SolidContainer> {
204
207
  const engine = this.requireAuthenticator().engine;
@@ -214,17 +217,14 @@ export class SolidService extends Service {
214
217
 
215
218
  await container.save();
216
219
 
217
- if (options.registerFor) {
218
- const typeIndex = await this.findOrCreatePrivateTypeIndex();
219
-
220
- await container.register(typeIndex.url, options.registerFor);
221
- }
220
+ options.register && (await container.register(options.register.typeIndex.url, options.register.modelClass));
222
221
 
223
222
  return container;
224
223
  });
225
224
  }
226
225
 
227
226
  protected async boot(): Promise<void> {
227
+ await super.boot();
228
228
  await Errors.booted;
229
229
 
230
230
  if (hasLocationQueryParameter('authenticator')) {
@@ -1,2 +0,0 @@
1
- "use strict";var e=require("@inrupt/solid-client-authn-browser");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
@@ -1 +0,0 @@
1
- {"version":3,"file":"InruptAuthenticator.lazy.hash.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export{fetch,handleIncomingRedirect,login,logout}from"@inrupt/solid-client-authn-browser";
2
- //# sourceMappingURL=InruptAuthenticator.lazy.hash.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InruptAuthenticator.lazy.hash.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export { fetch, handleIncomingRedirect, login, logout } from '@inrupt/solid-client-authn-browser';