@coasys/ad4m-connect 0.10.1-release-candidate-1-dev1 → 0.10.1-release-candidate-1-dev3
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.
- package/dist/core.js +1 -1
- package/dist/utils.js +1 -1
- package/dist/web.js +1 -1
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1389,6 +1389,6 @@ input VoiceActivityParamsInput {
|
|
|
1389
1389
|
startWindow: Float
|
|
1390
1390
|
timeBeforeSpeech: Float
|
|
1391
1391
|
}
|
|
1392
|
-
`;function Bp(t){return t?.length?t.length===1?t.toString():t.length===2?t.join(" and "):t.slice(0,-1).join(", ")+", and "+t.slice(-1):""}function BI(t){let e=t.can.includes("*")?["READ","WRITE","UPDATE"]:t.can,r=t.with.domain==="*"?"":t.with.domain,n=t.with.pointers.includes("*")?["all AD4M data"]:t.with.pointers;return`${Bp(e)} your ${r} actions, with access to ${Bp(n)}`}var rn=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},G=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},tt,Ft,qo,_e,Vp=class{constructor(t,e,r){tt.set(this,void 0),Ft.set(this,void 0),qo.set(this,void 0),_e.set(this,void 0),rn(this,tt,e||Mt.from(Vd(24)).toUrl(),"f"),rn(this,_e,t,"f"),rn(this,qo,r||"ad4m://self","f")}get baseExpression(){return G(this,tt,"f")}get perspective(){return G(this,_e,"f")}async getData(t){let e=t??G(this,tt,"f"),r=await G(this,_e,"f").getSubjectData(G(this,Ft,"f"),e);return Object.assign(this,r),rn(this,tt,e,"f"),this}async setProperty(key,value){let setters=await G(this,_e,"f").infer(`subject_class("${G(this,Ft,"f")}", C), property_setter(C, "${key}", Setter)`);if(setters&&setters.length>0){let actions=eval(setters[0].Setter),resolveLanguageResults=await G(this,_e,"f").infer(`subject_class("${G(this,Ft,"f")}", C), property_resolve_language(C, "${key}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),resolveLanguage&&(value=await G(this,_e,"f").createExpression(value,resolveLanguage)),await G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value}])}}async setCollectionSetter(key,value){let collectionSetters=await G(this,_e,"f").infer(`subject_class("${G(this,Ft,"f")}", C), collection_setter(C, "${fr(key)}", Setter)`);if(collectionSetters||(collectionSetters=[]),collectionSetters.length>0){let actions=eval(collectionSetters[0].Setter);value&&(Array.isArray(value)?await G(this,_e,"f").executeAction(actions,G(this,tt,"f"),value.map(t=>({name:"value",value:t}))):await G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value}]))}}async setCollectionAdder(key,value){let adders=await G(this,_e,"f").infer(`subject_class("${G(this,Ft,"f")}", C), collection_adder(C, "${fr(key)}", Adder)`);if(adders||(adders=[]),adders.length>0){let actions=eval(adders[0].Adder);value&&(Array.isArray(value)?await Promise.all(value.map(t=>G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value:t}]))):await G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value}]))}}async setCollectionRemover(key,value){let removers=await G(this,_e,"f").infer(`subject_class("${G(this,Ft,"f")}", C), collection_remover(C, "${fr(key)}", Remover)`);if(removers||(removers=[]),removers.length>0){let actions=eval(removers[0].Remover);value&&(Array.isArray(value)?await Promise.all(value.map(t=>G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value:t}]))):await G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value}]))}}async save(){rn(this,Ft,await G(this,_e,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await G(this,_e,"f").createSubject(this,G(this,tt,"f")),await G(this,_e,"f").add(new vn({source:G(this,qo,"f"),predicate:"ad4m://has_child",target:this.baseExpression})),await this.update()}async update(){rn(this,Ft,await G(this,_e,"f").stringOrTemplateObjectToSubjectClass(this),"f");let t=Object.entries(this);for(let[e,r]of t)if(r!=null)if(r?.action)switch(r.action){case"setter":await this.setCollectionSetter(e,r.value);break;case"adder":await this.setCollectionAdder(e,r.value);break;case"remover":await this.setCollectionRemover(e,r.value);default:await this.setCollectionSetter(e,r.value);break}else Array.isArray(r)&&r.length>0?await this.setCollectionSetter(e,r):r!=null&&r!==""&&await this.setProperty(e,r);await this.getData()}async get(){return rn(this,Ft,await G(this,_e,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await this.getData()}async delete(){await G(this,_e,"f").removeSubject(this,G(this,tt,"f"))}static async all(t){let e=await t.stringOrTemplateObjectToSubjectClass(this),r=await t.getAllSubjectProxies(e),n=[];if(r){for(let i of r){let a=new this(t,i.X);n.push(await a.get())}return n}return[]}static async query(t,e){let r=e?.source||"ad4m://self",n=await t.stringOrTemplateObjectToSubjectClass(this),i=[],a=`subject_class("${n}", C), instance(C, Base), link("${r}", Predicate, Base, Timestamp, Author)`;if(e){if(e.where)if(e.where.condition)a+=", "+e.where.condition;else{let s=Object.entries(e.where);for(let u of s){let c=u[0],l=u[1];a+=`, property_getter(C, Base, "${c}", "${l}")`}}try{if((await t.infer(`findall([Timestamp, Base], (${a}), AllData), sort(AllData, SortedData), length(SortedData, DataLength).`))[0].DataLength>=e.size){let u=`findall([Timestamp, Base], (${a}), AllData), sort(AllData, SortedData), reverse(SortedData, ReverseSortedData), paginate(ReverseSortedData, ${e.page}, ${e.size}, PageData).`;i=await t.infer(u),i=i[0].PageData.map(c=>({Base:c[1],Timestamp:c[0]}))}else i=await t.infer(a)}catch(s){console.log("Query failed",s)}}else i=await t.infer(a);return i?await Promise.all(i.map(async s=>await new this(t,s.Base).get())):[]}};tt=new WeakMap,Ft=new WeakMap,qo=new WeakMap,_e=new WeakMap;var P=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},E=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},pe=function(t,e){return function(r,n){e(r,n,t)}},Aa=new Fr;Aa.author="did:ad4m:test";Aa.timestamp=Date.now();Aa.data={source:"root",target:"neighbourhood://Qm12345"};Aa.proof={signature:"",key:"",valid:!0};var Dr=new bn;Dr.author="did:ad4m:test";Dr.timestamp=Date.now().toString();Dr.proof=new pr("","");Dr.data=new Zt([Aa]);var fs=class{};P([m(),E("design:type",String)],fs.prototype,"recipient",void 0);P([m(),E("design:type",bn)],fs.prototype,"message",void 0);fs=P([z()],fs);var li=class{};P([m(),E("design:type",String)],li.prototype,"ad4mExecutorVersion",void 0);P([m(),E("design:type",Boolean)],li.prototype,"isInitialized",void 0);P([m(),E("design:type",Boolean)],li.prototype,"isUnlocked",void 0);li=P([z()],li);var Tn=class{};P([m(),E("design:type",String)],Tn.prototype,"title",void 0);P([m(),E("design:type",String)],Tn.prototype,"message",void 0);P([m(),E("design:type",String)],Tn.prototype,"type",void 0);P([m(),E("design:type",String)],Tn.prototype,"addon",void 0);Tn=P([z()],Tn);var Ot=class{};P([m(),E("design:type",String)],Ot.prototype,"description",void 0);P([m(),E("design:type",String)],Ot.prototype,"appName",void 0);P([m(),E("design:type",String)],Ot.prototype,"appUrl",void 0);P([m(),E("design:type",String)],Ot.prototype,"appIconPath",void 0);P([m(),E("design:type",String)],Ot.prototype,"trigger",void 0);P([m(),E("design:type",Array)],Ot.prototype,"perspectiveIds",void 0);P([m(),E("design:type",String)],Ot.prototype,"webhookUrl",void 0);P([m(),E("design:type",String)],Ot.prototype,"webhookAuth",void 0);Ot=P([qe()],Ot);var vt=class{};P([m(),E("design:type",String)],vt.prototype,"id",void 0);P([m(),E("design:type",Boolean)],vt.prototype,"granted",void 0);P([m(),E("design:type",String)],vt.prototype,"description",void 0);P([m(),E("design:type",String)],vt.prototype,"appName",void 0);P([m(),E("design:type",String)],vt.prototype,"appUrl",void 0);P([m(),E("design:type",String)],vt.prototype,"appIconPath",void 0);P([m(),E("design:type",String)],vt.prototype,"trigger",void 0);P([m(),E("design:type",Array)],vt.prototype,"perspectiveIds",void 0);P([m(),E("design:type",String)],vt.prototype,"webhookUrl",void 0);P([m(),E("design:type",String)],vt.prototype,"webhookAuth",void 0);vt=P([z()],vt);var fi=class{};P([m(),E("design:type",vt)],fi.prototype,"notification",void 0);P([m(),E("design:type",String)],fi.prototype,"perspectiveId",void 0);P([m(),E("design:type",String)],fi.prototype,"triggerMatch",void 0);fi=P([z()],fi);var Ue=class{};P([m(),E("design:type",Number)],Ue.prototype,"total",void 0);P([m(),E("design:type",Number)],Ue.prototype,"imported",void 0);P([m(),E("design:type",Number)],Ue.prototype,"failed",void 0);P([m(),E("design:type",Number)],Ue.prototype,"omitted",void 0);P([m(),E("design:type",Array)],Ue.prototype,"errors",void 0);Ue=P([z()],Ue);var bt=class{};P([m(),E("design:type",Ue)],bt.prototype,"perspectives",void 0);P([m(),E("design:type",Ue)],bt.prototype,"links",void 0);P([m(),E("design:type",Ue)],bt.prototype,"expressions",void 0);P([m(),E("design:type",Ue)],bt.prototype,"perspectiveDiffs",void 0);P([m(),E("design:type",Ue)],bt.prototype,"notifications",void 0);P([m(),E("design:type",Ue)],bt.prototype,"models",void 0);P([m(),E("design:type",Ue)],bt.prototype,"defaultModels",void 0);P([m(),E("design:type",Ue)],bt.prototype,"tasks",void 0);P([m(),E("design:type",Ue)],bt.prototype,"friends",void 0);P([m(),E("design:type",Ue)],bt.prototype,"trustedAgents",void 0);P([m(),E("design:type",Ue)],bt.prototype,"knownLinkLanguages",void 0);bt=P([z()],bt);var ne=class{runtimeQuit(){return!0}runtimeOpenLink(e){return!0}runtimeInfo(){return{ad4mExecutorVersion:"x.x.x",isInitialized:!0,isUnlocked:!0}}addTrustedAgents(e){return e}deleteTrustedAgents(e){return[]}getTrustedAgents(){return["agentPubKey"]}runtimeKnownLinkLanguageTemplates(){return["Qm12345abcdef"]}runtimeAddKnownLinkLanguageTemplates(e){return e}runtimeRemoveKnownLinkLanguageTemplates(e){return[]}runtimeFriends(){return["did:test:friend"]}runtimeAddFriends(e){return e}runtimeRemoveFriends(e){return[]}runtimeHcAgentInfos(){return JSON.stringify([{agent:{type:"Buffer",data:[9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186]},signature:{type:"Buffer",data:[195,143,170,36,234,123,255,85,188,138,124,2,91,18,53,231,44,41,240,8,80,131,100,150,165,125,146,90,17,200,190,129,114,211,11,146,150,128,198,199,79,118,157,101,194,68,58,245,98,182,79,139,140,41,143,129,8,136,87,77,180,231,218,11]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,101,83,52,86,112,54,109,118,80,48,122,116,85,101,104,114,117,113,89,52,102,66,53,101,69,98,121,48,69,66,100,89,84,50,95,67,48,69,112,77,111,76,111,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,104,189,50,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38]},signature:{type:"Buffer",data:[233,192,38,3,59,248,124,231,57,255,40,154,50,60,119,252,68,198,154,109,175,155,106,217,211,155,109,223,249,91,221,210,17,132,72,230,11,230,247,119,72,244,145,91,75,7,67,5,130,151,44,231,52,220,28,154,212,82,58,90,203,211,236,4]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,55,101,77,106,48,73,83,72,56,56,81,56,45,89,51,74,89,70,53,76,72,57,83,54,68,119,71,73,49,88,45,115,87,53,68,104,66,87,121,71,119,78,115,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,103,45,197,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109]},signature:{type:"Buffer",data:[88,189,229,122,44,171,194,156,90,79,148,49,207,224,34,199,219,88,24,243,103,127,123,41,87,171,127,92,6,216,198,171,26,226,237,217,122,78,98,146,55,255,68,240,202,83,58,140,147,185,3,66,15,216,210,22,99,197,73,234,120,17,74,1]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,114,70,71,83,100,113,104,101,68,107,70,70,56,69,102,109,45,69,116,55,119,81,101,120,83,88,55,65,112,69,51,89,86,99,45,120,102,52,104,106,77,115,77,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,23,220,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56]},signature:{type:"Buffer",data:[129,12,55,104,239,121,138,2,86,106,136,51,219,79,170,8,195,69,81,188,225,192,247,196,54,39,164,110,75,39,240,56,245,189,154,77,72,11,97,250,202,149,242,97,128,28,47,164,236,104,136,82,212,246,44,143,132,119,255,135,112,11,20,13]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56,164,117,114,108,115,145,217,97,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,104,121,112,115,86,121,103,117,80,84,115,53,118,73,80,65,102,97,112,90,88,113,117,84,115,79,80,100,67,81,79,79,117,103,57,51,82,103,106,95,114,85,73,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,54,53,46,50,50,46,51,50,46,49,49,47,112,47,53,55,55,57,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,188,123,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}}])}runtimeHcAddAgentInfos(e){return!0}runtimeVerifyStringSignedByDid(e,r,n,i){return!0}runtimeSetStatus(e){return!0}runtimeFriendStatus(e){return Dr}runtimeFriendSendMessage(e,r){return!0}runtimeMessageInbox(e){return[Dr]}runtimeMessageOutbox(e){return[{recipient:"did:test:recipient",message:Dr}]}runtimeMessageReceived(){return Dr}exceptionOccurred(){return{title:"Test title",message:"Test message",type:bu.LanguageIsNotLoaded}}runtimeRequestInstallNotification(e){return"new-notification-id"}runtimeNotifications(){return[{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}]}runtimeUpdateNotification(e,r){return!0}runtimeRemoveNotification(e){return!0}runtimeGrantNotification(e){return!0}runtimeNotificationTriggered(){return{perspectiveId:"test-perspective-id",triggerMatch:"test-trigger-match",notification:{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}}}runtimeExportDb(e){return!0}runtimeImportDb(e){return!0}runtimeExportPerspective(e,r){return!0}runtimeImportPerspective(e){return!0}};P([Me(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Boolean)],ne.prototype,"runtimeQuit",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeOpenLink",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",li)],ne.prototype,"runtimeInfo",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"addTrustedAgents",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"deleteTrustedAgents",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ne.prototype,"getTrustedAgents",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ne.prototype,"runtimeKnownLinkLanguageTemplates",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"runtimeAddKnownLinkLanguageTemplates",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"runtimeRemoveKnownLinkLanguageTemplates",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ne.prototype,"runtimeFriends",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"runtimeAddFriends",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"runtimeRemoveFriends",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",String)],ne.prototype,"runtimeHcAgentInfos",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Boolean)],ne.prototype,"runtimeHcAddAgentInfos",null);P([er(),pe(0,fe()),pe(1,fe()),pe(2,fe()),pe(3,fe()),E("design:type",Function),E("design:paramtypes",[String,String,String,String]),E("design:returntype",void 0)],ne.prototype,"runtimeVerifyStringSignedByDid",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Zt]),E("design:returntype",Boolean)],ne.prototype,"runtimeSetStatus",null);P([er(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",bn)],ne.prototype,"runtimeFriendStatus",null);P([Me(),pe(0,fe()),pe(1,fe()),E("design:type",Function),E("design:paramtypes",[String,Wo]),E("design:returntype",Boolean)],ne.prototype,"runtimeFriendSendMessage",null);P([er(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Array)],ne.prototype,"runtimeMessageInbox",null);P([er(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Array)],ne.prototype,"runtimeMessageOutbox",null);P([Su(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",bn)],ne.prototype,"runtimeMessageReceived",null);P([Su(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Tn)],ne.prototype,"exceptionOccurred",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Ot]),E("design:returntype",String)],ne.prototype,"runtimeRequestInstallNotification",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ne.prototype,"runtimeNotifications",null);P([Me(),pe(0,fe()),pe(1,fe()),E("design:type",Function),E("design:paramtypes",[String,Ot]),E("design:returntype",Boolean)],ne.prototype,"runtimeUpdateNotification",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeRemoveNotification",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeGrantNotification",null);P([Su(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",fi)],ne.prototype,"runtimeNotificationTriggered",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeExportDb",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeImportDb",null);P([Me(),pe(0,fe()),pe(1,fe()),E("design:type",Function),E("design:paramtypes",[String,String]),E("design:returntype",Boolean)],ne.prototype,"runtimeExportPerspective",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeImportPerspective",null);ne=P([Lg()],ne);var Qd="0.10.1-release-candidate-1-dev1";var bs=12e3;function n_(){console.log("!! timeout yo!");let t=new AbortController;return setTimeout(()=>t.abort(),20),t}function _s(t,e=1e4){return Je(this,null,function*(){return Promise.race([new Promise((r,n)=>{try{t.includes("localhost")||r(new WebSocket(t));let i=new WebSocket(t);i.onopen=()=>{r(i)},i.onerror=a=>{n(a)}}catch(i){n(i)}}),new Promise((r,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},e)})])})}function Fu(t){return Je(this,null,function*(){try{let e=yield fetch(`http://localhost:${t}/graphql/`,{signal:n_().signal,mode:"cors"});if(e.status===400||e.status===0||e.status===200)return t;throw new Error(`Could not connect to port ${t}`)}catch(e){throw new Error(`Could not connect to port ${t}`)}})}function i_(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(t){return!1}return!0}function zd(t,e){i_()&&localStorage.setItem(`${Qd}/${t}`,e)}var a_=t=>{let e=new Set;do for(let r of Reflect.ownKeys(t))e.add([t,r]);while((t=Reflect.getPrototypeOf(t))&&t!==Object.prototype);return e};function Mu(t,{include:e,exclude:r}={}){let n=i=>{let a=o=>typeof o=="string"?i===o:o.test(i);return e?e.some(a):r?!r.some(a):!0};for(let[i,a]of a_(t.constructor.prototype)){if(a==="constructor"||!n(a))continue;let o=Reflect.getOwnPropertyDescriptor(i,a);o&&typeof o.value=="function"&&(t[a]=t[a].bind(t))}return t}var $u=class{constructor({appName:e,appDesc:r,appIconPath:n,appUrl:i,appDomain:a,capabilities:o,port:s,token:u,url:c,hosting:l}){this.activeSocket=null;this.requestedRestart=!1;this.authState="unauthenticated";this.connectionState="not_connected";this.port=bs;this.capabilities=[];this.isHosting=!1;this.listeners={authstatechange:[],configstatechange:[],connectionstatechange:[]};Mu(this);this.appName=e,this.appDesc=r,this.appDomain=a,this.appUrl=i,this.appIconPath=n,this.capabilities=o,this.port=s||this.port,this.url=c||`ws://localhost:${this.port}/graphql`,this.token=u||this.token,this.isHosting=l||!1,this.buildClient()}notifyConfigChange(e,r){this.listeners.configstatechange.forEach(n=>{n(e,r)})}notifyConnectionChange(e){this.connectionState!==e&&(this.connectionState=e,this.listeners.connectionstatechange.forEach(r=>{r(e)}))}notifyAuthChange(e){this.authState!==e&&(this.authState=e,this.listeners.authstatechange.forEach(r=>{r(e)}))}setPort(e){this.port!==e&&(this.port=e,this.setUrl(`ws://localhost:${this.port}/graphql`),this.notifyConfigChange("port",e))}setUrl(e){this.url!==e&&(this.url=e,this.notifyConfigChange("url",e))}setToken(e){this.token!==e&&(this.token=e,this.notifyConfigChange("token",e))}on(e,r){console.log("!!!on!!!",e,r),this.listeners[e].push(r)}connect(e){return Je(this,null,function*(){try{if(e){yield _s(e),this.setUrl(e);let r=this.buildClient();return yield this.checkAuth(),r}else{this.notifyConnectionChange("checking_local");try{yield _s(`ws://localhost:${this.port}/graphql`,2e3);let r=this.buildClient();return yield this.checkAuth(),r}catch(r){let n=yield this.ensureConnection();return yield this.checkAuth(),n}}}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}loginToHosting(e,r){return Je(this,null,function*(){try{let n=yield fetch("https://hosting.ad4m.dev/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:r})});if(n.status===200){let i=yield n.json();localStorage.setItem("hosting_token",i.token);let a=localStorage.getItem("hosting_token"),o=yield fetch("https://hosting.ad4m.dev/api/service/info",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+a}});if(o.status===200){let s=yield o.json();if(s.serviceId)if(this.setPort(s.port),this.setUrl(s.url),this.isHosting=!0,zd("ad4mhosting","true"),!s.paused)this.connect();else throw new Error("Hosting is not running")}}else if((yield n.json()).message==="Passwords did not match")throw new Error("Passwords did not match")}catch(n){throw console.log(n),new Error(`Error logging in ${n}`)}})}checkEmail(e){return Je(this,null,function*(){try{return(yield fetch(`https://hosting.ad4m.dev/api/auth/check-email?email=${e}`,{method:"GET",headers:{"Content-Type":"application/json"}})).status===200}catch(r){console.log(r)}})}connectToPort(e){return Je(this,null,function*(){try{if(e){let r=yield Fu(e);return this.setPort(r),this.buildClient()}else if(this.url.includes("localhost")){let r=yield this.findPort();return this.setPort(r),this.buildClient()}}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}ensureConnection(){return Je(this,null,function*(){var r,n;if(((r=this.activeSocket)==null?void 0:r.readyState)===WebSocket.OPEN&&((n=this.activeSocket)==null?void 0:n.url)===this.url&&this.ad4mClient)return this.ad4mClient;try{return this.notifyConnectionChange("connecting"),yield _s(this.url),this.buildClient()}catch(i){return this.notifyConnectionChange("not_connected"),this.connectToPort()}})}findPort(){return Je(this,null,function*(){let e=[...Array(10).keys()].map((i,a)=>Fu(bs+a)),n=(yield Promise.allSettled(e)).find(i=>i.status==="fulfilled");if(n)return n.value;throw Error("Couldn't find an open port")})}buildClient(){this.notifyConnectionChange("connecting");try{let e=new WebSocket(this.url)}catch(e){this.notifyConnectionChange("not_connected");return}return this.apolloClient&&this.wsClient&&(this.requestedRestart=!0,this.wsClient.dispose(),this.apolloClient.stop(),this.wsClient=null,this.apolloClient=null),this.wsClient=Cf({url:this.url,connectionParams:()=>Je(this,null,function*(){return{headers:{authorization:this.token}}}),on:{opened:e=>{this.activeSocket=e,e.onmessage=r=>{console.log("!!! ws.onmessage at",performance.now(),r.data)}},error:e=>{this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")},connected:()=>{this.notifyConnectionChange("connected"),this.checkAuth()},closed:e=>Je(this,null,function*(){if(!e.wasClean&&!this.requestedRestart)if(!this.token)this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1;else{let r=yield this.connect();r?this.ad4mClient=r:(this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1)}})}}),this.apolloClient=new Ac({link:new Lf(this.wsClient),cache:new co({resultCaching:!1,addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache"},query:{fetchPolicy:"no-cache"},mutate:{fetchPolicy:"no-cache"}}}),this.ad4mClient=new as(this.apolloClient),this.ad4mClient}checkAuth(){return Je(this,null,function*(){try{return(yield this.ad4mClient.agent.isLocked())?this.notifyAuthChange("locked"):(yield this.ad4mClient.agent.status(),this.notifyAuthChange("authenticated")),!0}catch(e){return e.message==="Socket closed with event 4500 Cannot extractByTags from a ciphered wallet. You must unlock first."?(this.notifyAuthChange("locked"),!0):(this.notifyAuthChange("unauthenticated"),!1)}})}requestCapability(e=!1){return Je(this,null,function*(){var r;if(e&&this.setToken(null),this.isHosting){let n=localStorage.getItem("hosting_token");(yield fetch("https://hosting.ad4m.dev/api/service/checkStatus",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+n}})).status!==200&&console.error("Looks like the client is not running you might not recieve the mail with the code, please check your dashboard logs.")}return this.requestId=yield(r=this.ad4mClient)==null?void 0:r.agent.requestCapability({appName:this.appName,appDesc:this.appDesc,appUrl:this.appUrl,appIconPath:this.appIconPath,appDomain:this.appDomain,capabilities:this.capabilities}),this.requestId})}verifyCode(e){return Je(this,null,function*(){var r;try{let n=yield(r=this.ad4mClient)==null?void 0:r.agent.generateJwt(this.requestId,e);return this.setToken(n),yield this.buildClient(),yield this.checkAuth(),this.token}catch(n){throw new Error("Invalid code")}})}clearState(){this.setToken(null),this.setPort(bs),this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}};export{$u as default};
|
|
1392
|
+
`;function Bp(t){return t?.length?t.length===1?t.toString():t.length===2?t.join(" and "):t.slice(0,-1).join(", ")+", and "+t.slice(-1):""}function BI(t){let e=t.can.includes("*")?["READ","WRITE","UPDATE"]:t.can,r=t.with.domain==="*"?"":t.with.domain,n=t.with.pointers.includes("*")?["all AD4M data"]:t.with.pointers;return`${Bp(e)} your ${r} actions, with access to ${Bp(n)}`}var rn=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},G=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},tt,Ft,qo,_e,Vp=class{constructor(t,e,r){tt.set(this,void 0),Ft.set(this,void 0),qo.set(this,void 0),_e.set(this,void 0),rn(this,tt,e||Mt.from(Vd(24)).toUrl(),"f"),rn(this,_e,t,"f"),rn(this,qo,r||"ad4m://self","f")}get baseExpression(){return G(this,tt,"f")}get perspective(){return G(this,_e,"f")}async getData(t){let e=t??G(this,tt,"f"),r=await G(this,_e,"f").getSubjectData(G(this,Ft,"f"),e);return Object.assign(this,r),rn(this,tt,e,"f"),this}async setProperty(key,value){let setters=await G(this,_e,"f").infer(`subject_class("${G(this,Ft,"f")}", C), property_setter(C, "${key}", Setter)`);if(setters&&setters.length>0){let actions=eval(setters[0].Setter),resolveLanguageResults=await G(this,_e,"f").infer(`subject_class("${G(this,Ft,"f")}", C), property_resolve_language(C, "${key}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),resolveLanguage&&(value=await G(this,_e,"f").createExpression(value,resolveLanguage)),await G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value}])}}async setCollectionSetter(key,value){let collectionSetters=await G(this,_e,"f").infer(`subject_class("${G(this,Ft,"f")}", C), collection_setter(C, "${fr(key)}", Setter)`);if(collectionSetters||(collectionSetters=[]),collectionSetters.length>0){let actions=eval(collectionSetters[0].Setter);value&&(Array.isArray(value)?await G(this,_e,"f").executeAction(actions,G(this,tt,"f"),value.map(t=>({name:"value",value:t}))):await G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value}]))}}async setCollectionAdder(key,value){let adders=await G(this,_e,"f").infer(`subject_class("${G(this,Ft,"f")}", C), collection_adder(C, "${fr(key)}", Adder)`);if(adders||(adders=[]),adders.length>0){let actions=eval(adders[0].Adder);value&&(Array.isArray(value)?await Promise.all(value.map(t=>G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value:t}]))):await G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value}]))}}async setCollectionRemover(key,value){let removers=await G(this,_e,"f").infer(`subject_class("${G(this,Ft,"f")}", C), collection_remover(C, "${fr(key)}", Remover)`);if(removers||(removers=[]),removers.length>0){let actions=eval(removers[0].Remover);value&&(Array.isArray(value)?await Promise.all(value.map(t=>G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value:t}]))):await G(this,_e,"f").executeAction(actions,G(this,tt,"f"),[{name:"value",value}]))}}async save(){rn(this,Ft,await G(this,_e,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await G(this,_e,"f").createSubject(this,G(this,tt,"f")),await G(this,_e,"f").add(new vn({source:G(this,qo,"f"),predicate:"ad4m://has_child",target:this.baseExpression})),await this.update()}async update(){rn(this,Ft,await G(this,_e,"f").stringOrTemplateObjectToSubjectClass(this),"f");let t=Object.entries(this);for(let[e,r]of t)if(r!=null)if(r?.action)switch(r.action){case"setter":await this.setCollectionSetter(e,r.value);break;case"adder":await this.setCollectionAdder(e,r.value);break;case"remover":await this.setCollectionRemover(e,r.value);default:await this.setCollectionSetter(e,r.value);break}else Array.isArray(r)&&r.length>0?await this.setCollectionSetter(e,r):r!=null&&r!==""&&await this.setProperty(e,r);await this.getData()}async get(){return rn(this,Ft,await G(this,_e,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await this.getData()}async delete(){await G(this,_e,"f").removeSubject(this,G(this,tt,"f"))}static async all(t){let e=await t.stringOrTemplateObjectToSubjectClass(this),r=await t.getAllSubjectProxies(e),n=[];if(r){for(let i of r){let a=new this(t,i.X);n.push(await a.get())}return n}return[]}static async query(t,e){let r=e?.source||"ad4m://self",n=await t.stringOrTemplateObjectToSubjectClass(this),i=[],a=`subject_class("${n}", C), instance(C, Base), link("${r}", Predicate, Base, Timestamp, Author)`;if(e){if(e.where)if(e.where.condition)a+=", "+e.where.condition;else{let s=Object.entries(e.where);for(let u of s){let c=u[0],l=u[1];a+=`, property_getter(C, Base, "${c}", "${l}")`}}try{if((await t.infer(`findall([Timestamp, Base], (${a}), AllData), sort(AllData, SortedData), length(SortedData, DataLength).`))[0].DataLength>=e.size){let u=`findall([Timestamp, Base], (${a}), AllData), sort(AllData, SortedData), reverse(SortedData, ReverseSortedData), paginate(ReverseSortedData, ${e.page}, ${e.size}, PageData).`;i=await t.infer(u),i=i[0].PageData.map(c=>({Base:c[1],Timestamp:c[0]}))}else i=await t.infer(a)}catch(s){console.log("Query failed",s)}}else i=await t.infer(a);return i?await Promise.all(i.map(async s=>await new this(t,s.Base).get())):[]}};tt=new WeakMap,Ft=new WeakMap,qo=new WeakMap,_e=new WeakMap;var P=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},E=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},pe=function(t,e){return function(r,n){e(r,n,t)}},Aa=new Fr;Aa.author="did:ad4m:test";Aa.timestamp=Date.now();Aa.data={source:"root",target:"neighbourhood://Qm12345"};Aa.proof={signature:"",key:"",valid:!0};var Dr=new bn;Dr.author="did:ad4m:test";Dr.timestamp=Date.now().toString();Dr.proof=new pr("","");Dr.data=new Zt([Aa]);var fs=class{};P([m(),E("design:type",String)],fs.prototype,"recipient",void 0);P([m(),E("design:type",bn)],fs.prototype,"message",void 0);fs=P([z()],fs);var li=class{};P([m(),E("design:type",String)],li.prototype,"ad4mExecutorVersion",void 0);P([m(),E("design:type",Boolean)],li.prototype,"isInitialized",void 0);P([m(),E("design:type",Boolean)],li.prototype,"isUnlocked",void 0);li=P([z()],li);var Tn=class{};P([m(),E("design:type",String)],Tn.prototype,"title",void 0);P([m(),E("design:type",String)],Tn.prototype,"message",void 0);P([m(),E("design:type",String)],Tn.prototype,"type",void 0);P([m(),E("design:type",String)],Tn.prototype,"addon",void 0);Tn=P([z()],Tn);var Ot=class{};P([m(),E("design:type",String)],Ot.prototype,"description",void 0);P([m(),E("design:type",String)],Ot.prototype,"appName",void 0);P([m(),E("design:type",String)],Ot.prototype,"appUrl",void 0);P([m(),E("design:type",String)],Ot.prototype,"appIconPath",void 0);P([m(),E("design:type",String)],Ot.prototype,"trigger",void 0);P([m(),E("design:type",Array)],Ot.prototype,"perspectiveIds",void 0);P([m(),E("design:type",String)],Ot.prototype,"webhookUrl",void 0);P([m(),E("design:type",String)],Ot.prototype,"webhookAuth",void 0);Ot=P([qe()],Ot);var vt=class{};P([m(),E("design:type",String)],vt.prototype,"id",void 0);P([m(),E("design:type",Boolean)],vt.prototype,"granted",void 0);P([m(),E("design:type",String)],vt.prototype,"description",void 0);P([m(),E("design:type",String)],vt.prototype,"appName",void 0);P([m(),E("design:type",String)],vt.prototype,"appUrl",void 0);P([m(),E("design:type",String)],vt.prototype,"appIconPath",void 0);P([m(),E("design:type",String)],vt.prototype,"trigger",void 0);P([m(),E("design:type",Array)],vt.prototype,"perspectiveIds",void 0);P([m(),E("design:type",String)],vt.prototype,"webhookUrl",void 0);P([m(),E("design:type",String)],vt.prototype,"webhookAuth",void 0);vt=P([z()],vt);var fi=class{};P([m(),E("design:type",vt)],fi.prototype,"notification",void 0);P([m(),E("design:type",String)],fi.prototype,"perspectiveId",void 0);P([m(),E("design:type",String)],fi.prototype,"triggerMatch",void 0);fi=P([z()],fi);var Ue=class{};P([m(),E("design:type",Number)],Ue.prototype,"total",void 0);P([m(),E("design:type",Number)],Ue.prototype,"imported",void 0);P([m(),E("design:type",Number)],Ue.prototype,"failed",void 0);P([m(),E("design:type",Number)],Ue.prototype,"omitted",void 0);P([m(),E("design:type",Array)],Ue.prototype,"errors",void 0);Ue=P([z()],Ue);var bt=class{};P([m(),E("design:type",Ue)],bt.prototype,"perspectives",void 0);P([m(),E("design:type",Ue)],bt.prototype,"links",void 0);P([m(),E("design:type",Ue)],bt.prototype,"expressions",void 0);P([m(),E("design:type",Ue)],bt.prototype,"perspectiveDiffs",void 0);P([m(),E("design:type",Ue)],bt.prototype,"notifications",void 0);P([m(),E("design:type",Ue)],bt.prototype,"models",void 0);P([m(),E("design:type",Ue)],bt.prototype,"defaultModels",void 0);P([m(),E("design:type",Ue)],bt.prototype,"tasks",void 0);P([m(),E("design:type",Ue)],bt.prototype,"friends",void 0);P([m(),E("design:type",Ue)],bt.prototype,"trustedAgents",void 0);P([m(),E("design:type",Ue)],bt.prototype,"knownLinkLanguages",void 0);bt=P([z()],bt);var ne=class{runtimeQuit(){return!0}runtimeOpenLink(e){return!0}runtimeInfo(){return{ad4mExecutorVersion:"x.x.x",isInitialized:!0,isUnlocked:!0}}addTrustedAgents(e){return e}deleteTrustedAgents(e){return[]}getTrustedAgents(){return["agentPubKey"]}runtimeKnownLinkLanguageTemplates(){return["Qm12345abcdef"]}runtimeAddKnownLinkLanguageTemplates(e){return e}runtimeRemoveKnownLinkLanguageTemplates(e){return[]}runtimeFriends(){return["did:test:friend"]}runtimeAddFriends(e){return e}runtimeRemoveFriends(e){return[]}runtimeHcAgentInfos(){return JSON.stringify([{agent:{type:"Buffer",data:[9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186]},signature:{type:"Buffer",data:[195,143,170,36,234,123,255,85,188,138,124,2,91,18,53,231,44,41,240,8,80,131,100,150,165,125,146,90,17,200,190,129,114,211,11,146,150,128,198,199,79,118,157,101,194,68,58,245,98,182,79,139,140,41,143,129,8,136,87,77,180,231,218,11]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,101,83,52,86,112,54,109,118,80,48,122,116,85,101,104,114,117,113,89,52,102,66,53,101,69,98,121,48,69,66,100,89,84,50,95,67,48,69,112,77,111,76,111,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,104,189,50,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38]},signature:{type:"Buffer",data:[233,192,38,3,59,248,124,231,57,255,40,154,50,60,119,252,68,198,154,109,175,155,106,217,211,155,109,223,249,91,221,210,17,132,72,230,11,230,247,119,72,244,145,91,75,7,67,5,130,151,44,231,52,220,28,154,212,82,58,90,203,211,236,4]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,55,101,77,106,48,73,83,72,56,56,81,56,45,89,51,74,89,70,53,76,72,57,83,54,68,119,71,73,49,88,45,115,87,53,68,104,66,87,121,71,119,78,115,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,103,45,197,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109]},signature:{type:"Buffer",data:[88,189,229,122,44,171,194,156,90,79,148,49,207,224,34,199,219,88,24,243,103,127,123,41,87,171,127,92,6,216,198,171,26,226,237,217,122,78,98,146,55,255,68,240,202,83,58,140,147,185,3,66,15,216,210,22,99,197,73,234,120,17,74,1]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,114,70,71,83,100,113,104,101,68,107,70,70,56,69,102,109,45,69,116,55,119,81,101,120,83,88,55,65,112,69,51,89,86,99,45,120,102,52,104,106,77,115,77,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,23,220,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56]},signature:{type:"Buffer",data:[129,12,55,104,239,121,138,2,86,106,136,51,219,79,170,8,195,69,81,188,225,192,247,196,54,39,164,110,75,39,240,56,245,189,154,77,72,11,97,250,202,149,242,97,128,28,47,164,236,104,136,82,212,246,44,143,132,119,255,135,112,11,20,13]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56,164,117,114,108,115,145,217,97,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,104,121,112,115,86,121,103,117,80,84,115,53,118,73,80,65,102,97,112,90,88,113,117,84,115,79,80,100,67,81,79,79,117,103,57,51,82,103,106,95,114,85,73,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,54,53,46,50,50,46,51,50,46,49,49,47,112,47,53,55,55,57,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,188,123,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}}])}runtimeHcAddAgentInfos(e){return!0}runtimeVerifyStringSignedByDid(e,r,n,i){return!0}runtimeSetStatus(e){return!0}runtimeFriendStatus(e){return Dr}runtimeFriendSendMessage(e,r){return!0}runtimeMessageInbox(e){return[Dr]}runtimeMessageOutbox(e){return[{recipient:"did:test:recipient",message:Dr}]}runtimeMessageReceived(){return Dr}exceptionOccurred(){return{title:"Test title",message:"Test message",type:bu.LanguageIsNotLoaded}}runtimeRequestInstallNotification(e){return"new-notification-id"}runtimeNotifications(){return[{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}]}runtimeUpdateNotification(e,r){return!0}runtimeRemoveNotification(e){return!0}runtimeGrantNotification(e){return!0}runtimeNotificationTriggered(){return{perspectiveId:"test-perspective-id",triggerMatch:"test-trigger-match",notification:{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}}}runtimeExportDb(e){return!0}runtimeImportDb(e){return!0}runtimeExportPerspective(e,r){return!0}runtimeImportPerspective(e){return!0}};P([Me(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Boolean)],ne.prototype,"runtimeQuit",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeOpenLink",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",li)],ne.prototype,"runtimeInfo",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"addTrustedAgents",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"deleteTrustedAgents",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ne.prototype,"getTrustedAgents",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ne.prototype,"runtimeKnownLinkLanguageTemplates",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"runtimeAddKnownLinkLanguageTemplates",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"runtimeRemoveKnownLinkLanguageTemplates",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ne.prototype,"runtimeFriends",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"runtimeAddFriends",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ne.prototype,"runtimeRemoveFriends",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",String)],ne.prototype,"runtimeHcAgentInfos",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Boolean)],ne.prototype,"runtimeHcAddAgentInfos",null);P([er(),pe(0,fe()),pe(1,fe()),pe(2,fe()),pe(3,fe()),E("design:type",Function),E("design:paramtypes",[String,String,String,String]),E("design:returntype",void 0)],ne.prototype,"runtimeVerifyStringSignedByDid",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Zt]),E("design:returntype",Boolean)],ne.prototype,"runtimeSetStatus",null);P([er(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",bn)],ne.prototype,"runtimeFriendStatus",null);P([Me(),pe(0,fe()),pe(1,fe()),E("design:type",Function),E("design:paramtypes",[String,Wo]),E("design:returntype",Boolean)],ne.prototype,"runtimeFriendSendMessage",null);P([er(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Array)],ne.prototype,"runtimeMessageInbox",null);P([er(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Array)],ne.prototype,"runtimeMessageOutbox",null);P([Su(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",bn)],ne.prototype,"runtimeMessageReceived",null);P([Su(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Tn)],ne.prototype,"exceptionOccurred",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[Ot]),E("design:returntype",String)],ne.prototype,"runtimeRequestInstallNotification",null);P([er(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ne.prototype,"runtimeNotifications",null);P([Me(),pe(0,fe()),pe(1,fe()),E("design:type",Function),E("design:paramtypes",[String,Ot]),E("design:returntype",Boolean)],ne.prototype,"runtimeUpdateNotification",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeRemoveNotification",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeGrantNotification",null);P([Su(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",fi)],ne.prototype,"runtimeNotificationTriggered",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeExportDb",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeImportDb",null);P([Me(),pe(0,fe()),pe(1,fe()),E("design:type",Function),E("design:paramtypes",[String,String]),E("design:returntype",Boolean)],ne.prototype,"runtimeExportPerspective",null);P([Me(),pe(0,fe()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ne.prototype,"runtimeImportPerspective",null);ne=P([Lg()],ne);var Qd="0.10.1-release-candidate-1-dev3";var bs=12e3;function n_(){console.log("!! timeout yo!");let t=new AbortController;return setTimeout(()=>t.abort(),20),t}function _s(t,e=1e4){return Je(this,null,function*(){return Promise.race([new Promise((r,n)=>{try{t.includes("localhost")||r(new WebSocket(t));let i=new WebSocket(t);i.onopen=()=>{r(i)},i.onerror=a=>{n(a)}}catch(i){n(i)}}),new Promise((r,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},e)})])})}function Fu(t){return Je(this,null,function*(){try{let e=yield fetch(`http://localhost:${t}/graphql/`,{signal:n_().signal,mode:"cors"});if(e.status===400||e.status===0||e.status===200)return t;throw new Error(`Could not connect to port ${t}`)}catch(e){throw new Error(`Could not connect to port ${t}`)}})}function i_(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(t){return!1}return!0}function zd(t,e){i_()&&localStorage.setItem(`${Qd}/${t}`,e)}var a_=t=>{let e=new Set;do for(let r of Reflect.ownKeys(t))e.add([t,r]);while((t=Reflect.getPrototypeOf(t))&&t!==Object.prototype);return e};function Mu(t,{include:e,exclude:r}={}){let n=i=>{let a=o=>typeof o=="string"?i===o:o.test(i);return e?e.some(a):r?!r.some(a):!0};for(let[i,a]of a_(t.constructor.prototype)){if(a==="constructor"||!n(a))continue;let o=Reflect.getOwnPropertyDescriptor(i,a);o&&typeof o.value=="function"&&(t[a]=t[a].bind(t))}return t}var $u=class{constructor({appName:e,appDesc:r,appIconPath:n,appUrl:i,appDomain:a,capabilities:o,port:s,token:u,url:c,hosting:l}){this.activeSocket=null;this.requestedRestart=!1;this.authState="unauthenticated";this.connectionState="not_connected";this.port=bs;this.capabilities=[];this.isHosting=!1;this.listeners={authstatechange:[],configstatechange:[],connectionstatechange:[]};Mu(this);this.appName=e,this.appDesc=r,this.appDomain=a,this.appUrl=i,this.appIconPath=n,this.capabilities=o,this.port=s||this.port,this.url=c||`ws://localhost:${this.port}/graphql`,this.token=u||this.token,this.isHosting=l||!1,this.buildClient()}notifyConfigChange(e,r){this.listeners.configstatechange.forEach(n=>{n(e,r)})}notifyConnectionChange(e){this.connectionState!==e&&(this.connectionState=e,this.listeners.connectionstatechange.forEach(r=>{r(e)}))}notifyAuthChange(e){this.authState!==e&&(this.authState=e,this.listeners.authstatechange.forEach(r=>{r(e)}))}setPort(e){this.port!==e&&(this.port=e,this.setUrl(`ws://localhost:${this.port}/graphql`),this.notifyConfigChange("port",e))}setUrl(e){this.url!==e&&(this.url=e,this.notifyConfigChange("url",e))}setToken(e){this.token!==e&&(this.token=e,this.notifyConfigChange("token",e))}on(e,r){console.log("!!!on!!!",e,r),this.listeners[e].push(r)}connect(e){return Je(this,null,function*(){try{if(e){yield _s(e),this.setUrl(e);let r=this.buildClient();return yield this.checkAuth(),r}else{this.notifyConnectionChange("checking_local");try{yield _s(`ws://localhost:${this.port}/graphql`,2e3);let r=this.buildClient();return yield this.checkAuth(),r}catch(r){let n=yield this.ensureConnection();return yield this.checkAuth(),n}}}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}loginToHosting(e,r){return Je(this,null,function*(){try{let n=yield fetch("https://hosting.ad4m.dev/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:r})});if(n.status===200){let i=yield n.json();localStorage.setItem("hosting_token",i.token);let a=localStorage.getItem("hosting_token"),o=yield fetch("https://hosting.ad4m.dev/api/service/info",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+a}});if(o.status===200){let s=yield o.json();if(s.serviceId)if(this.setPort(s.port),this.setUrl(s.url),this.isHosting=!0,zd("ad4mhosting","true"),!s.paused)this.connect();else throw new Error("Hosting is not running")}}else if((yield n.json()).message==="Passwords did not match")throw new Error("Passwords did not match")}catch(n){throw console.log(n),new Error(`Error logging in ${n}`)}})}checkEmail(e){return Je(this,null,function*(){try{return(yield fetch(`https://hosting.ad4m.dev/api/auth/check-email?email=${e}`,{method:"GET",headers:{"Content-Type":"application/json"}})).status===200}catch(r){console.log(r)}})}connectToPort(e){return Je(this,null,function*(){try{if(e){let r=yield Fu(e);return this.setPort(r),this.buildClient()}else if(this.url.includes("localhost")){let r=yield this.findPort();return this.setPort(r),this.buildClient()}}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}ensureConnection(){return Je(this,null,function*(){var r,n;if(((r=this.activeSocket)==null?void 0:r.readyState)===WebSocket.OPEN&&((n=this.activeSocket)==null?void 0:n.url)===this.url&&this.ad4mClient)return this.ad4mClient;try{return this.notifyConnectionChange("connecting"),yield _s(this.url),this.buildClient()}catch(i){return this.notifyConnectionChange("not_connected"),this.connectToPort()}})}findPort(){return Je(this,null,function*(){let e=[...Array(10).keys()].map((i,a)=>Fu(bs+a)),n=(yield Promise.allSettled(e)).find(i=>i.status==="fulfilled");if(n)return n.value;throw Error("Couldn't find an open port")})}buildClient(){this.notifyConnectionChange("connecting");try{let e=new WebSocket(this.url)}catch(e){this.notifyConnectionChange("not_connected");return}return this.apolloClient&&this.wsClient&&(this.requestedRestart=!0,this.wsClient.dispose(),this.apolloClient.stop(),this.wsClient=null,this.apolloClient=null),this.wsClient=Cf({url:this.url,connectionParams:()=>Je(this,null,function*(){return{headers:{authorization:this.token}}}),on:{opened:e=>{var n;this.activeSocket=e;let r=(n=e.onmessage)==null?void 0:n.bind(e);e.onmessage=i=>{console.log("!!! ws.onmessage at",performance.now(),i.data),r==null||r(i)}},error:e=>{this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")},connected:()=>{this.notifyConnectionChange("connected"),this.checkAuth()},closed:e=>Je(this,null,function*(){if(!e.wasClean&&!this.requestedRestart)if(!this.token)this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1;else{let r=yield this.connect();r?this.ad4mClient=r:(this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1)}})}}),this.apolloClient=new Ac({link:new Lf(this.wsClient),cache:new co({resultCaching:!1,addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache"},query:{fetchPolicy:"no-cache"},mutate:{fetchPolicy:"no-cache"}}}),this.ad4mClient=new as(this.apolloClient),this.ad4mClient}checkAuth(){return Je(this,null,function*(){try{return(yield this.ad4mClient.agent.isLocked())?this.notifyAuthChange("locked"):(yield this.ad4mClient.agent.status(),this.notifyAuthChange("authenticated")),!0}catch(e){return e.message==="Socket closed with event 4500 Cannot extractByTags from a ciphered wallet. You must unlock first."?(this.notifyAuthChange("locked"),!0):(this.notifyAuthChange("unauthenticated"),!1)}})}requestCapability(e=!1){return Je(this,null,function*(){var r;if(e&&this.setToken(null),this.isHosting){let n=localStorage.getItem("hosting_token");(yield fetch("https://hosting.ad4m.dev/api/service/checkStatus",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+n}})).status!==200&&console.error("Looks like the client is not running you might not recieve the mail with the code, please check your dashboard logs.")}return this.requestId=yield(r=this.ad4mClient)==null?void 0:r.agent.requestCapability({appName:this.appName,appDesc:this.appDesc,appUrl:this.appUrl,appIconPath:this.appIconPath,appDomain:this.appDomain,capabilities:this.capabilities}),this.requestId})}verifyCode(e){return Je(this,null,function*(){var r;try{let n=yield(r=this.ad4mClient)==null?void 0:r.agent.generateJwt(this.requestId,e);return this.setToken(n),yield this.buildClient(),yield this.checkAuth(),this.token}catch(n){throw new Error("Invalid code")}})}clearState(){this.setToken(null),this.setPort(bs),this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}};export{$u as default};
|
|
1393
1393
|
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
|
|
1394
1394
|
//! @fayeed - make it support node.js
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var u=(e,t,o)=>new Promise((n,s)=>{var c=r=>{try{l(o.next(r))}catch(a){s(a)}},p=r=>{try{l(o.throw(r))}catch(a){s(a)}},l=r=>r.done?n(r.value):Promise.resolve(r.value).then(c,p);l((o=o.apply(e,t)).next())});var i="0.10.1-release-candidate-1-
|
|
1
|
+
var u=(e,t,o)=>new Promise((n,s)=>{var c=r=>{try{l(o.next(r))}catch(a){s(a)}},p=r=>{try{l(o.throw(r))}catch(a){s(a)}},l=r=>r.done?n(r.value):Promise.resolve(r.value).then(c,p);l((o=o.apply(e,t)).next())});var i="0.10.1-release-candidate-1-dev3";var w=12e3;function b(){console.log("!! timeout yo!");let e=new AbortController;return setTimeout(()=>e.abort(),20),e}function j(e,t=1e4){return u(this,null,function*(){return Promise.race([new Promise((o,n)=>{try{e.includes("localhost")||o(new WebSocket(e));let s=new WebSocket(e);s.onopen=()=>{o(s)},s.onerror=c=>{n(c)}}catch(s){n(s)}}),new Promise((o,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},t)})])})}function y(e){return u(this,null,function*(){try{let t=yield fetch(`http://localhost:${e}/graphql/`,{signal:b().signal,mode:"cors"});if(t.status===400||t.status===0||t.status===200)return e;throw new Error(`Could not connect to port ${e}`)}catch(t){throw new Error(`Could not connect to port ${e}`)}})}function v(){return new Promise((e,t)=>{let o=document.querySelector("ad4m-connect"),n=o==null?void 0:o.getAd4mClient();n?e(n):t("No Ad4mClient found")})}function S(e){let t=document.querySelector("ad4m-connect");t==null||t.addEventListener("authstatechange",o=>{e(o.detail)})}function x(){let e=navigator.userAgent,t="";return e.search("Windows")!==-1?t="Windows":e.search("Mac")!==-1?t="MacOS":e.search("X11")!==-1&&e.search("Linux")===-1?t="UNIX":e.search("Linux")!==-1&&e.search("X11")!==-1&&(t="Linux"),t}function d(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(e){return!1}return!0}function A(e,t){d()&&localStorage.setItem(`${i}/${e}`,t)}function C(e){return d()?localStorage.getItem(`${i}/${e}`):null}function $(e){d()&&localStorage.removeItem(`${i}/${e}`)}export{w as DEFAULT_PORT,y as checkPort,j as connectWebSocket,x as detectOS,v as getAd4mClient,C as getForVersion,S as onAuthStateChanged,$ as removeForVersion,A as setForVersion};
|
package/dist/web.js
CHANGED
|
@@ -1391,7 +1391,7 @@ input VoiceActivityParamsInput {
|
|
|
1391
1391
|
startWindow: Float
|
|
1392
1392
|
timeBeforeSpeech: Float
|
|
1393
1393
|
}
|
|
1394
|
-
`;function Eh(t){return t?.length?t.length===1?t.toString():t.length===2?t.join(" and "):t.slice(0,-1).join(", ")+", and "+t.slice(-1):""}function k1(t){let e=t.can.includes("*")?["READ","WRITE","UPDATE"]:t.can,r=t.with.domain==="*"?"":t.with.domain,n=t.with.pointers.includes("*")?["all AD4M data"]:t.with.pointers;return`${Eh(e)} your ${r} actions, with access to ${Eh(n)}`}var xn=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},K=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ct,zt,xs,ke,Ch=class{constructor(t,e,r){ct.set(this,void 0),zt.set(this,void 0),xs.set(this,void 0),ke.set(this,void 0),xn(this,ct,e||Qt.from(C1(24)).toUrl(),"f"),xn(this,ke,t,"f"),xn(this,xs,r||"ad4m://self","f")}get baseExpression(){return K(this,ct,"f")}get perspective(){return K(this,ke,"f")}async getData(t){let e=t??K(this,ct,"f"),r=await K(this,ke,"f").getSubjectData(K(this,zt,"f"),e);return Object.assign(this,r),xn(this,ct,e,"f"),this}async setProperty(key,value){let setters=await K(this,ke,"f").infer(`subject_class("${K(this,zt,"f")}", C), property_setter(C, "${key}", Setter)`);if(setters&&setters.length>0){let actions=eval(setters[0].Setter),resolveLanguageResults=await K(this,ke,"f").infer(`subject_class("${K(this,zt,"f")}", C), property_resolve_language(C, "${key}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),resolveLanguage&&(value=await K(this,ke,"f").createExpression(value,resolveLanguage)),await K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value}])}}async setCollectionSetter(key,value){let collectionSetters=await K(this,ke,"f").infer(`subject_class("${K(this,zt,"f")}", C), collection_setter(C, "${wr(key)}", Setter)`);if(collectionSetters||(collectionSetters=[]),collectionSetters.length>0){let actions=eval(collectionSetters[0].Setter);value&&(Array.isArray(value)?await K(this,ke,"f").executeAction(actions,K(this,ct,"f"),value.map(t=>({name:"value",value:t}))):await K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value}]))}}async setCollectionAdder(key,value){let adders=await K(this,ke,"f").infer(`subject_class("${K(this,zt,"f")}", C), collection_adder(C, "${wr(key)}", Adder)`);if(adders||(adders=[]),adders.length>0){let actions=eval(adders[0].Adder);value&&(Array.isArray(value)?await Promise.all(value.map(t=>K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value:t}]))):await K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value}]))}}async setCollectionRemover(key,value){let removers=await K(this,ke,"f").infer(`subject_class("${K(this,zt,"f")}", C), collection_remover(C, "${wr(key)}", Remover)`);if(removers||(removers=[]),removers.length>0){let actions=eval(removers[0].Remover);value&&(Array.isArray(value)?await Promise.all(value.map(t=>K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value:t}]))):await K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value}]))}}async save(){xn(this,zt,await K(this,ke,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await K(this,ke,"f").createSubject(this,K(this,ct,"f")),await K(this,ke,"f").add(new Mn({source:K(this,xs,"f"),predicate:"ad4m://has_child",target:this.baseExpression})),await this.update()}async update(){xn(this,zt,await K(this,ke,"f").stringOrTemplateObjectToSubjectClass(this),"f");let t=Object.entries(this);for(let[e,r]of t)if(r!=null)if(r?.action)switch(r.action){case"setter":await this.setCollectionSetter(e,r.value);break;case"adder":await this.setCollectionAdder(e,r.value);break;case"remover":await this.setCollectionRemover(e,r.value);default:await this.setCollectionSetter(e,r.value);break}else Array.isArray(r)&&r.length>0?await this.setCollectionSetter(e,r):r!=null&&r!==""&&await this.setProperty(e,r);await this.getData()}async get(){return xn(this,zt,await K(this,ke,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await this.getData()}async delete(){await K(this,ke,"f").removeSubject(this,K(this,ct,"f"))}static async all(t){let e=await t.stringOrTemplateObjectToSubjectClass(this),r=await t.getAllSubjectProxies(e),n=[];if(r){for(let i of r){let a=new this(t,i.X);n.push(await a.get())}return n}return[]}static async query(t,e){let r=e?.source||"ad4m://self",n=await t.stringOrTemplateObjectToSubjectClass(this),i=[],a=`subject_class("${n}", C), instance(C, Base), link("${r}", Predicate, Base, Timestamp, Author)`;if(e){if(e.where)if(e.where.condition)a+=", "+e.where.condition;else{let s=Object.entries(e.where);for(let u of s){let c=u[0],l=u[1];a+=`, property_getter(C, Base, "${c}", "${l}")`}}try{if((await t.infer(`findall([Timestamp, Base], (${a}), AllData), sort(AllData, SortedData), length(SortedData, DataLength).`))[0].DataLength>=e.size){let u=`findall([Timestamp, Base], (${a}), AllData), sort(AllData, SortedData), reverse(SortedData, ReverseSortedData), paginate(ReverseSortedData, ${e.page}, ${e.size}, PageData).`;i=await t.infer(u),i=i[0].PageData.map(c=>({Base:c[1],Timestamp:c[0]}))}else i=await t.infer(a)}catch(s){console.log("Query failed",s)}}else i=await t.infer(a);return i?await Promise.all(i.map(async s=>await new this(t,s.Base).get())):[]}};ct=new WeakMap,zt=new WeakMap,xs=new WeakMap,ke=new WeakMap;var N=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},E=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},ye=function(t,e){return function(r,n){e(r,n,t)}},no=new Zr;no.author="did:ad4m:test";no.timestamp=Date.now();no.data={source:"root",target:"neighbourhood://Qm12345"};no.proof={signature:"",key:"",valid:!0};var zr=new Un;zr.author="did:ad4m:test";zr.timestamp=Date.now().toString();zr.proof=new Sr("","");zr.data=new or([no]);var Hs=class{};N([m(),E("design:type",String)],Hs.prototype,"recipient",void 0);N([m(),E("design:type",Un)],Hs.prototype,"message",void 0);Hs=N([H()],Hs);var Ri=class{};N([m(),E("design:type",String)],Ri.prototype,"ad4mExecutorVersion",void 0);N([m(),E("design:type",Boolean)],Ri.prototype,"isInitialized",void 0);N([m(),E("design:type",Boolean)],Ri.prototype,"isUnlocked",void 0);Ri=N([H()],Ri);var Qn=class{};N([m(),E("design:type",String)],Qn.prototype,"title",void 0);N([m(),E("design:type",String)],Qn.prototype,"message",void 0);N([m(),E("design:type",String)],Qn.prototype,"type",void 0);N([m(),E("design:type",String)],Qn.prototype,"addon",void 0);Qn=N([H()],Qn);var Ft=class{};N([m(),E("design:type",String)],Ft.prototype,"description",void 0);N([m(),E("design:type",String)],Ft.prototype,"appName",void 0);N([m(),E("design:type",String)],Ft.prototype,"appUrl",void 0);N([m(),E("design:type",String)],Ft.prototype,"appIconPath",void 0);N([m(),E("design:type",String)],Ft.prototype,"trigger",void 0);N([m(),E("design:type",Array)],Ft.prototype,"perspectiveIds",void 0);N([m(),E("design:type",String)],Ft.prototype,"webhookUrl",void 0);N([m(),E("design:type",String)],Ft.prototype,"webhookAuth",void 0);Ft=N([Ke()],Ft);var kt=class{};N([m(),E("design:type",String)],kt.prototype,"id",void 0);N([m(),E("design:type",Boolean)],kt.prototype,"granted",void 0);N([m(),E("design:type",String)],kt.prototype,"description",void 0);N([m(),E("design:type",String)],kt.prototype,"appName",void 0);N([m(),E("design:type",String)],kt.prototype,"appUrl",void 0);N([m(),E("design:type",String)],kt.prototype,"appIconPath",void 0);N([m(),E("design:type",String)],kt.prototype,"trigger",void 0);N([m(),E("design:type",Array)],kt.prototype,"perspectiveIds",void 0);N([m(),E("design:type",String)],kt.prototype,"webhookUrl",void 0);N([m(),E("design:type",String)],kt.prototype,"webhookAuth",void 0);kt=N([H()],kt);var Pi=class{};N([m(),E("design:type",kt)],Pi.prototype,"notification",void 0);N([m(),E("design:type",String)],Pi.prototype,"perspectiveId",void 0);N([m(),E("design:type",String)],Pi.prototype,"triggerMatch",void 0);Pi=N([H()],Pi);var He=class{};N([m(),E("design:type",Number)],He.prototype,"total",void 0);N([m(),E("design:type",Number)],He.prototype,"imported",void 0);N([m(),E("design:type",Number)],He.prototype,"failed",void 0);N([m(),E("design:type",Number)],He.prototype,"omitted",void 0);N([m(),E("design:type",Array)],He.prototype,"errors",void 0);He=N([H()],He);var Tt=class{};N([m(),E("design:type",He)],Tt.prototype,"perspectives",void 0);N([m(),E("design:type",He)],Tt.prototype,"links",void 0);N([m(),E("design:type",He)],Tt.prototype,"expressions",void 0);N([m(),E("design:type",He)],Tt.prototype,"perspectiveDiffs",void 0);N([m(),E("design:type",He)],Tt.prototype,"notifications",void 0);N([m(),E("design:type",He)],Tt.prototype,"models",void 0);N([m(),E("design:type",He)],Tt.prototype,"defaultModels",void 0);N([m(),E("design:type",He)],Tt.prototype,"tasks",void 0);N([m(),E("design:type",He)],Tt.prototype,"friends",void 0);N([m(),E("design:type",He)],Tt.prototype,"trustedAgents",void 0);N([m(),E("design:type",He)],Tt.prototype,"knownLinkLanguages",void 0);Tt=N([H()],Tt);var ae=class{runtimeQuit(){return!0}runtimeOpenLink(e){return!0}runtimeInfo(){return{ad4mExecutorVersion:"x.x.x",isInitialized:!0,isUnlocked:!0}}addTrustedAgents(e){return e}deleteTrustedAgents(e){return[]}getTrustedAgents(){return["agentPubKey"]}runtimeKnownLinkLanguageTemplates(){return["Qm12345abcdef"]}runtimeAddKnownLinkLanguageTemplates(e){return e}runtimeRemoveKnownLinkLanguageTemplates(e){return[]}runtimeFriends(){return["did:test:friend"]}runtimeAddFriends(e){return e}runtimeRemoveFriends(e){return[]}runtimeHcAgentInfos(){return JSON.stringify([{agent:{type:"Buffer",data:[9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186]},signature:{type:"Buffer",data:[195,143,170,36,234,123,255,85,188,138,124,2,91,18,53,231,44,41,240,8,80,131,100,150,165,125,146,90,17,200,190,129,114,211,11,146,150,128,198,199,79,118,157,101,194,68,58,245,98,182,79,139,140,41,143,129,8,136,87,77,180,231,218,11]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,101,83,52,86,112,54,109,118,80,48,122,116,85,101,104,114,117,113,89,52,102,66,53,101,69,98,121,48,69,66,100,89,84,50,95,67,48,69,112,77,111,76,111,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,104,189,50,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38]},signature:{type:"Buffer",data:[233,192,38,3,59,248,124,231,57,255,40,154,50,60,119,252,68,198,154,109,175,155,106,217,211,155,109,223,249,91,221,210,17,132,72,230,11,230,247,119,72,244,145,91,75,7,67,5,130,151,44,231,52,220,28,154,212,82,58,90,203,211,236,4]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,55,101,77,106,48,73,83,72,56,56,81,56,45,89,51,74,89,70,53,76,72,57,83,54,68,119,71,73,49,88,45,115,87,53,68,104,66,87,121,71,119,78,115,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,103,45,197,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109]},signature:{type:"Buffer",data:[88,189,229,122,44,171,194,156,90,79,148,49,207,224,34,199,219,88,24,243,103,127,123,41,87,171,127,92,6,216,198,171,26,226,237,217,122,78,98,146,55,255,68,240,202,83,58,140,147,185,3,66,15,216,210,22,99,197,73,234,120,17,74,1]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,114,70,71,83,100,113,104,101,68,107,70,70,56,69,102,109,45,69,116,55,119,81,101,120,83,88,55,65,112,69,51,89,86,99,45,120,102,52,104,106,77,115,77,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,23,220,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56]},signature:{type:"Buffer",data:[129,12,55,104,239,121,138,2,86,106,136,51,219,79,170,8,195,69,81,188,225,192,247,196,54,39,164,110,75,39,240,56,245,189,154,77,72,11,97,250,202,149,242,97,128,28,47,164,236,104,136,82,212,246,44,143,132,119,255,135,112,11,20,13]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56,164,117,114,108,115,145,217,97,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,104,121,112,115,86,121,103,117,80,84,115,53,118,73,80,65,102,97,112,90,88,113,117,84,115,79,80,100,67,81,79,79,117,103,57,51,82,103,106,95,114,85,73,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,54,53,46,50,50,46,51,50,46,49,49,47,112,47,53,55,55,57,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,188,123,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}}])}runtimeHcAddAgentInfos(e){return!0}runtimeVerifyStringSignedByDid(e,r,n,i){return!0}runtimeSetStatus(e){return!0}runtimeFriendStatus(e){return zr}runtimeFriendSendMessage(e,r){return!0}runtimeMessageInbox(e){return[zr]}runtimeMessageOutbox(e){return[{recipient:"did:test:recipient",message:zr}]}runtimeMessageReceived(){return zr}exceptionOccurred(){return{title:"Test title",message:"Test message",type:wl.LanguageIsNotLoaded}}runtimeRequestInstallNotification(e){return"new-notification-id"}runtimeNotifications(){return[{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}]}runtimeUpdateNotification(e,r){return!0}runtimeRemoveNotification(e){return!0}runtimeGrantNotification(e){return!0}runtimeNotificationTriggered(){return{perspectiveId:"test-perspective-id",triggerMatch:"test-trigger-match",notification:{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}}}runtimeExportDb(e){return!0}runtimeImportDb(e){return!0}runtimeExportPerspective(e,r){return!0}runtimeImportPerspective(e){return!0}};N([Ve(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Boolean)],ae.prototype,"runtimeQuit",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeOpenLink",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Ri)],ae.prototype,"runtimeInfo",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"addTrustedAgents",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"deleteTrustedAgents",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ae.prototype,"getTrustedAgents",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ae.prototype,"runtimeKnownLinkLanguageTemplates",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"runtimeAddKnownLinkLanguageTemplates",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"runtimeRemoveKnownLinkLanguageTemplates",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ae.prototype,"runtimeFriends",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"runtimeAddFriends",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"runtimeRemoveFriends",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",String)],ae.prototype,"runtimeHcAgentInfos",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Boolean)],ae.prototype,"runtimeHcAddAgentInfos",null);N([cr(),ye(0,ge()),ye(1,ge()),ye(2,ge()),ye(3,ge()),E("design:type",Function),E("design:paramtypes",[String,String,String,String]),E("design:returntype",void 0)],ae.prototype,"runtimeVerifyStringSignedByDid",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[or]),E("design:returntype",Boolean)],ae.prototype,"runtimeSetStatus",null);N([cr(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Un)],ae.prototype,"runtimeFriendStatus",null);N([Ve(),ye(0,ge()),ye(1,ge()),E("design:type",Function),E("design:paramtypes",[String,Os]),E("design:returntype",Boolean)],ae.prototype,"runtimeFriendSendMessage",null);N([cr(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Array)],ae.prototype,"runtimeMessageInbox",null);N([cr(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Array)],ae.prototype,"runtimeMessageOutbox",null);N([El(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Un)],ae.prototype,"runtimeMessageReceived",null);N([El(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Qn)],ae.prototype,"exceptionOccurred",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Ft]),E("design:returntype",String)],ae.prototype,"runtimeRequestInstallNotification",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ae.prototype,"runtimeNotifications",null);N([Ve(),ye(0,ge()),ye(1,ge()),E("design:type",Function),E("design:paramtypes",[String,Ft]),E("design:returntype",Boolean)],ae.prototype,"runtimeUpdateNotification",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeRemoveNotification",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeGrantNotification",null);N([El(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Pi)],ae.prototype,"runtimeNotificationTriggered",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeExportDb",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeImportDb",null);N([Ve(),ye(0,ge()),ye(1,ge()),E("design:type",Function),E("design:paramtypes",[String,String]),E("design:returntype",Boolean)],ae.prototype,"runtimeExportPerspective",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeImportPerspective",null);ae=N([Iy()],ae);var tc="0.10.1-release-candidate-1-dev1";var Er=12e3;function Yv(){console.log("!! timeout yo!");let t=new AbortController;return setTimeout(()=>t.abort(),20),t}function rc(t,e=1e4){return me(this,null,function*(){return Promise.race([new Promise((r,n)=>{try{t.includes("localhost")||r(new WebSocket(t));let i=new WebSocket(t);i.onopen=()=>{r(i)},i.onerror=a=>{n(a)}}catch(i){n(i)}}),new Promise((r,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},e)})])})}function Ml(t){return me(this,null,function*(){try{let e=yield fetch(`http://localhost:${t}/graphql/`,{signal:Yv().signal,mode:"cors"});if(e.status===400||e.status===0||e.status===200)return t;throw new Error(`Could not connect to port ${t}`)}catch(e){throw new Error(`Could not connect to port ${t}`)}})}function Jv(){return new Promise((t,e)=>{let r=document.querySelector("ad4m-connect"),n=r==null?void 0:r.getAd4mClient();n?t(n):e("No Ad4mClient found")})}function Ul(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(t){return!1}return!0}function nc(t,e){Ul()&&localStorage.setItem(`${tc}/${t}`,e)}function lr(t){return Ul()?localStorage.getItem(`${tc}/${t}`):null}function jl(t){Ul()&&localStorage.removeItem(`${tc}/${t}`)}var Xv=t=>{let e=new Set;do for(let r of Reflect.ownKeys(t))e.add([t,r]);while((t=Reflect.getPrototypeOf(t))&&t!==Object.prototype);return e};function io(t,{include:e,exclude:r}={}){let n=i=>{let a=o=>typeof o=="string"?i===o:o.test(i);return e?e.some(a):r?!r.some(a):!0};for(let[i,a]of Xv(t.constructor.prototype)){if(a==="constructor"||!n(a))continue;let o=Reflect.getOwnPropertyDescriptor(i,a);o&&typeof o.value=="function"&&(t[a]=t[a].bind(t))}return t}var ao=class{constructor({appName:e,appDesc:r,appIconPath:n,appUrl:i,appDomain:a,capabilities:o,port:s,token:u,url:c,hosting:l}){this.activeSocket=null;this.requestedRestart=!1;this.authState="unauthenticated";this.connectionState="not_connected";this.port=Er;this.capabilities=[];this.isHosting=!1;this.listeners={authstatechange:[],configstatechange:[],connectionstatechange:[]};io(this);this.appName=e,this.appDesc=r,this.appDomain=a,this.appUrl=i,this.appIconPath=n,this.capabilities=o,this.port=s||this.port,this.url=c||`ws://localhost:${this.port}/graphql`,this.token=u||this.token,this.isHosting=l||!1,this.buildClient()}notifyConfigChange(e,r){this.listeners.configstatechange.forEach(n=>{n(e,r)})}notifyConnectionChange(e){this.connectionState!==e&&(this.connectionState=e,this.listeners.connectionstatechange.forEach(r=>{r(e)}))}notifyAuthChange(e){this.authState!==e&&(this.authState=e,this.listeners.authstatechange.forEach(r=>{r(e)}))}setPort(e){this.port!==e&&(this.port=e,this.setUrl(`ws://localhost:${this.port}/graphql`),this.notifyConfigChange("port",e))}setUrl(e){this.url!==e&&(this.url=e,this.notifyConfigChange("url",e))}setToken(e){this.token!==e&&(this.token=e,this.notifyConfigChange("token",e))}on(e,r){console.log("!!!on!!!",e,r),this.listeners[e].push(r)}connect(e){return me(this,null,function*(){try{if(e){yield rc(e),this.setUrl(e);let r=this.buildClient();return yield this.checkAuth(),r}else{this.notifyConnectionChange("checking_local");try{yield rc(`ws://localhost:${this.port}/graphql`,2e3);let r=this.buildClient();return yield this.checkAuth(),r}catch(r){let n=yield this.ensureConnection();return yield this.checkAuth(),n}}}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}loginToHosting(e,r){return me(this,null,function*(){try{let n=yield fetch("https://hosting.ad4m.dev/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:r})});if(n.status===200){let i=yield n.json();localStorage.setItem("hosting_token",i.token);let a=localStorage.getItem("hosting_token"),o=yield fetch("https://hosting.ad4m.dev/api/service/info",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+a}});if(o.status===200){let s=yield o.json();if(s.serviceId)if(this.setPort(s.port),this.setUrl(s.url),this.isHosting=!0,nc("ad4mhosting","true"),!s.paused)this.connect();else throw new Error("Hosting is not running")}}else if((yield n.json()).message==="Passwords did not match")throw new Error("Passwords did not match")}catch(n){throw console.log(n),new Error(`Error logging in ${n}`)}})}checkEmail(e){return me(this,null,function*(){try{return(yield fetch(`https://hosting.ad4m.dev/api/auth/check-email?email=${e}`,{method:"GET",headers:{"Content-Type":"application/json"}})).status===200}catch(r){console.log(r)}})}connectToPort(e){return me(this,null,function*(){try{if(e){let r=yield Ml(e);return this.setPort(r),this.buildClient()}else if(this.url.includes("localhost")){let r=yield this.findPort();return this.setPort(r),this.buildClient()}}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}ensureConnection(){return me(this,null,function*(){var r,n;if(((r=this.activeSocket)==null?void 0:r.readyState)===WebSocket.OPEN&&((n=this.activeSocket)==null?void 0:n.url)===this.url&&this.ad4mClient)return this.ad4mClient;try{return this.notifyConnectionChange("connecting"),yield rc(this.url),this.buildClient()}catch(i){return this.notifyConnectionChange("not_connected"),this.connectToPort()}})}findPort(){return me(this,null,function*(){let e=[...Array(10).keys()].map((i,a)=>Ml(Er+a)),n=(yield Promise.allSettled(e)).find(i=>i.status==="fulfilled");if(n)return n.value;throw Error("Couldn't find an open port")})}buildClient(){this.notifyConnectionChange("connecting");try{let e=new WebSocket(this.url)}catch(e){this.notifyConnectionChange("not_connected");return}return this.apolloClient&&this.wsClient&&(this.requestedRestart=!0,this.wsClient.dispose(),this.apolloClient.stop(),this.wsClient=null,this.apolloClient=null),this.wsClient=gd({url:this.url,connectionParams:()=>me(this,null,function*(){return{headers:{authorization:this.token}}}),on:{opened:e=>{this.activeSocket=e,e.onmessage=r=>{console.log("!!! ws.onmessage at",performance.now(),r.data)}},error:e=>{this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")},connected:()=>{this.notifyConnectionChange("connected"),this.checkAuth()},closed:e=>me(this,null,function*(){if(!e.wasClean&&!this.requestedRestart)if(!this.token)this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1;else{let r=yield this.connect();r?this.ad4mClient=r:(this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1)}})}}),this.apolloClient=new Du({link:new yd(this.wsClient),cache:new Qo({resultCaching:!1,addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache"},query:{fetchPolicy:"no-cache"},mutate:{fetchPolicy:"no-cache"}}}),this.ad4mClient=new Bs(this.apolloClient),this.ad4mClient}checkAuth(){return me(this,null,function*(){try{return(yield this.ad4mClient.agent.isLocked())?this.notifyAuthChange("locked"):(yield this.ad4mClient.agent.status(),this.notifyAuthChange("authenticated")),!0}catch(e){return e.message==="Socket closed with event 4500 Cannot extractByTags from a ciphered wallet. You must unlock first."?(this.notifyAuthChange("locked"),!0):(this.notifyAuthChange("unauthenticated"),!1)}})}requestCapability(e=!1){return me(this,null,function*(){var r;if(e&&this.setToken(null),this.isHosting){let n=localStorage.getItem("hosting_token");(yield fetch("https://hosting.ad4m.dev/api/service/checkStatus",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+n}})).status!==200&&console.error("Looks like the client is not running you might not recieve the mail with the code, please check your dashboard logs.")}return this.requestId=yield(r=this.ad4mClient)==null?void 0:r.agent.requestCapability({appName:this.appName,appDesc:this.appDesc,appUrl:this.appUrl,appIconPath:this.appIconPath,appDomain:this.appDomain,capabilities:this.capabilities}),this.requestId})}verifyCode(e){return me(this,null,function*(){var r;try{let n=yield(r=this.ad4mClient)==null?void 0:r.agent.generateJwt(this.requestId,e);return this.setToken(n),yield this.buildClient(),yield this.checkAuth(),this.token}catch(n){throw new Error("Invalid code")}})}clearState(){this.setToken(null),this.setPort(Er),this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}};function Bl({unlockAgent:t,reconnect:e}){return z`
|
|
1394
|
+
`;function Eh(t){return t?.length?t.length===1?t.toString():t.length===2?t.join(" and "):t.slice(0,-1).join(", ")+", and "+t.slice(-1):""}function k1(t){let e=t.can.includes("*")?["READ","WRITE","UPDATE"]:t.can,r=t.with.domain==="*"?"":t.with.domain,n=t.with.pointers.includes("*")?["all AD4M data"]:t.with.pointers;return`${Eh(e)} your ${r} actions, with access to ${Eh(n)}`}var xn=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},K=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ct,zt,xs,ke,Ch=class{constructor(t,e,r){ct.set(this,void 0),zt.set(this,void 0),xs.set(this,void 0),ke.set(this,void 0),xn(this,ct,e||Qt.from(C1(24)).toUrl(),"f"),xn(this,ke,t,"f"),xn(this,xs,r||"ad4m://self","f")}get baseExpression(){return K(this,ct,"f")}get perspective(){return K(this,ke,"f")}async getData(t){let e=t??K(this,ct,"f"),r=await K(this,ke,"f").getSubjectData(K(this,zt,"f"),e);return Object.assign(this,r),xn(this,ct,e,"f"),this}async setProperty(key,value){let setters=await K(this,ke,"f").infer(`subject_class("${K(this,zt,"f")}", C), property_setter(C, "${key}", Setter)`);if(setters&&setters.length>0){let actions=eval(setters[0].Setter),resolveLanguageResults=await K(this,ke,"f").infer(`subject_class("${K(this,zt,"f")}", C), property_resolve_language(C, "${key}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),resolveLanguage&&(value=await K(this,ke,"f").createExpression(value,resolveLanguage)),await K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value}])}}async setCollectionSetter(key,value){let collectionSetters=await K(this,ke,"f").infer(`subject_class("${K(this,zt,"f")}", C), collection_setter(C, "${wr(key)}", Setter)`);if(collectionSetters||(collectionSetters=[]),collectionSetters.length>0){let actions=eval(collectionSetters[0].Setter);value&&(Array.isArray(value)?await K(this,ke,"f").executeAction(actions,K(this,ct,"f"),value.map(t=>({name:"value",value:t}))):await K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value}]))}}async setCollectionAdder(key,value){let adders=await K(this,ke,"f").infer(`subject_class("${K(this,zt,"f")}", C), collection_adder(C, "${wr(key)}", Adder)`);if(adders||(adders=[]),adders.length>0){let actions=eval(adders[0].Adder);value&&(Array.isArray(value)?await Promise.all(value.map(t=>K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value:t}]))):await K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value}]))}}async setCollectionRemover(key,value){let removers=await K(this,ke,"f").infer(`subject_class("${K(this,zt,"f")}", C), collection_remover(C, "${wr(key)}", Remover)`);if(removers||(removers=[]),removers.length>0){let actions=eval(removers[0].Remover);value&&(Array.isArray(value)?await Promise.all(value.map(t=>K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value:t}]))):await K(this,ke,"f").executeAction(actions,K(this,ct,"f"),[{name:"value",value}]))}}async save(){xn(this,zt,await K(this,ke,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await K(this,ke,"f").createSubject(this,K(this,ct,"f")),await K(this,ke,"f").add(new Mn({source:K(this,xs,"f"),predicate:"ad4m://has_child",target:this.baseExpression})),await this.update()}async update(){xn(this,zt,await K(this,ke,"f").stringOrTemplateObjectToSubjectClass(this),"f");let t=Object.entries(this);for(let[e,r]of t)if(r!=null)if(r?.action)switch(r.action){case"setter":await this.setCollectionSetter(e,r.value);break;case"adder":await this.setCollectionAdder(e,r.value);break;case"remover":await this.setCollectionRemover(e,r.value);default:await this.setCollectionSetter(e,r.value);break}else Array.isArray(r)&&r.length>0?await this.setCollectionSetter(e,r):r!=null&&r!==""&&await this.setProperty(e,r);await this.getData()}async get(){return xn(this,zt,await K(this,ke,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await this.getData()}async delete(){await K(this,ke,"f").removeSubject(this,K(this,ct,"f"))}static async all(t){let e=await t.stringOrTemplateObjectToSubjectClass(this),r=await t.getAllSubjectProxies(e),n=[];if(r){for(let i of r){let a=new this(t,i.X);n.push(await a.get())}return n}return[]}static async query(t,e){let r=e?.source||"ad4m://self",n=await t.stringOrTemplateObjectToSubjectClass(this),i=[],a=`subject_class("${n}", C), instance(C, Base), link("${r}", Predicate, Base, Timestamp, Author)`;if(e){if(e.where)if(e.where.condition)a+=", "+e.where.condition;else{let s=Object.entries(e.where);for(let u of s){let c=u[0],l=u[1];a+=`, property_getter(C, Base, "${c}", "${l}")`}}try{if((await t.infer(`findall([Timestamp, Base], (${a}), AllData), sort(AllData, SortedData), length(SortedData, DataLength).`))[0].DataLength>=e.size){let u=`findall([Timestamp, Base], (${a}), AllData), sort(AllData, SortedData), reverse(SortedData, ReverseSortedData), paginate(ReverseSortedData, ${e.page}, ${e.size}, PageData).`;i=await t.infer(u),i=i[0].PageData.map(c=>({Base:c[1],Timestamp:c[0]}))}else i=await t.infer(a)}catch(s){console.log("Query failed",s)}}else i=await t.infer(a);return i?await Promise.all(i.map(async s=>await new this(t,s.Base).get())):[]}};ct=new WeakMap,zt=new WeakMap,xs=new WeakMap,ke=new WeakMap;var N=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},E=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},ye=function(t,e){return function(r,n){e(r,n,t)}},no=new Zr;no.author="did:ad4m:test";no.timestamp=Date.now();no.data={source:"root",target:"neighbourhood://Qm12345"};no.proof={signature:"",key:"",valid:!0};var zr=new Un;zr.author="did:ad4m:test";zr.timestamp=Date.now().toString();zr.proof=new Sr("","");zr.data=new or([no]);var Hs=class{};N([m(),E("design:type",String)],Hs.prototype,"recipient",void 0);N([m(),E("design:type",Un)],Hs.prototype,"message",void 0);Hs=N([H()],Hs);var Ri=class{};N([m(),E("design:type",String)],Ri.prototype,"ad4mExecutorVersion",void 0);N([m(),E("design:type",Boolean)],Ri.prototype,"isInitialized",void 0);N([m(),E("design:type",Boolean)],Ri.prototype,"isUnlocked",void 0);Ri=N([H()],Ri);var Qn=class{};N([m(),E("design:type",String)],Qn.prototype,"title",void 0);N([m(),E("design:type",String)],Qn.prototype,"message",void 0);N([m(),E("design:type",String)],Qn.prototype,"type",void 0);N([m(),E("design:type",String)],Qn.prototype,"addon",void 0);Qn=N([H()],Qn);var Ft=class{};N([m(),E("design:type",String)],Ft.prototype,"description",void 0);N([m(),E("design:type",String)],Ft.prototype,"appName",void 0);N([m(),E("design:type",String)],Ft.prototype,"appUrl",void 0);N([m(),E("design:type",String)],Ft.prototype,"appIconPath",void 0);N([m(),E("design:type",String)],Ft.prototype,"trigger",void 0);N([m(),E("design:type",Array)],Ft.prototype,"perspectiveIds",void 0);N([m(),E("design:type",String)],Ft.prototype,"webhookUrl",void 0);N([m(),E("design:type",String)],Ft.prototype,"webhookAuth",void 0);Ft=N([Ke()],Ft);var kt=class{};N([m(),E("design:type",String)],kt.prototype,"id",void 0);N([m(),E("design:type",Boolean)],kt.prototype,"granted",void 0);N([m(),E("design:type",String)],kt.prototype,"description",void 0);N([m(),E("design:type",String)],kt.prototype,"appName",void 0);N([m(),E("design:type",String)],kt.prototype,"appUrl",void 0);N([m(),E("design:type",String)],kt.prototype,"appIconPath",void 0);N([m(),E("design:type",String)],kt.prototype,"trigger",void 0);N([m(),E("design:type",Array)],kt.prototype,"perspectiveIds",void 0);N([m(),E("design:type",String)],kt.prototype,"webhookUrl",void 0);N([m(),E("design:type",String)],kt.prototype,"webhookAuth",void 0);kt=N([H()],kt);var Pi=class{};N([m(),E("design:type",kt)],Pi.prototype,"notification",void 0);N([m(),E("design:type",String)],Pi.prototype,"perspectiveId",void 0);N([m(),E("design:type",String)],Pi.prototype,"triggerMatch",void 0);Pi=N([H()],Pi);var He=class{};N([m(),E("design:type",Number)],He.prototype,"total",void 0);N([m(),E("design:type",Number)],He.prototype,"imported",void 0);N([m(),E("design:type",Number)],He.prototype,"failed",void 0);N([m(),E("design:type",Number)],He.prototype,"omitted",void 0);N([m(),E("design:type",Array)],He.prototype,"errors",void 0);He=N([H()],He);var Tt=class{};N([m(),E("design:type",He)],Tt.prototype,"perspectives",void 0);N([m(),E("design:type",He)],Tt.prototype,"links",void 0);N([m(),E("design:type",He)],Tt.prototype,"expressions",void 0);N([m(),E("design:type",He)],Tt.prototype,"perspectiveDiffs",void 0);N([m(),E("design:type",He)],Tt.prototype,"notifications",void 0);N([m(),E("design:type",He)],Tt.prototype,"models",void 0);N([m(),E("design:type",He)],Tt.prototype,"defaultModels",void 0);N([m(),E("design:type",He)],Tt.prototype,"tasks",void 0);N([m(),E("design:type",He)],Tt.prototype,"friends",void 0);N([m(),E("design:type",He)],Tt.prototype,"trustedAgents",void 0);N([m(),E("design:type",He)],Tt.prototype,"knownLinkLanguages",void 0);Tt=N([H()],Tt);var ae=class{runtimeQuit(){return!0}runtimeOpenLink(e){return!0}runtimeInfo(){return{ad4mExecutorVersion:"x.x.x",isInitialized:!0,isUnlocked:!0}}addTrustedAgents(e){return e}deleteTrustedAgents(e){return[]}getTrustedAgents(){return["agentPubKey"]}runtimeKnownLinkLanguageTemplates(){return["Qm12345abcdef"]}runtimeAddKnownLinkLanguageTemplates(e){return e}runtimeRemoveKnownLinkLanguageTemplates(e){return[]}runtimeFriends(){return["did:test:friend"]}runtimeAddFriends(e){return e}runtimeRemoveFriends(e){return[]}runtimeHcAgentInfos(){return JSON.stringify([{agent:{type:"Buffer",data:[9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186]},signature:{type:"Buffer",data:[195,143,170,36,234,123,255,85,188,138,124,2,91,18,53,231,44,41,240,8,80,131,100,150,165,125,146,90,17,200,190,129,114,211,11,146,150,128,198,199,79,118,157,101,194,68,58,245,98,182,79,139,140,41,143,129,8,136,87,77,180,231,218,11]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,101,83,52,86,112,54,109,118,80,48,122,116,85,101,104,114,117,113,89,52,102,66,53,101,69,98,121,48,69,66,100,89,84,50,95,67,48,69,112,77,111,76,111,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,104,189,50,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38]},signature:{type:"Buffer",data:[233,192,38,3,59,248,124,231,57,255,40,154,50,60,119,252,68,198,154,109,175,155,106,217,211,155,109,223,249,91,221,210,17,132,72,230,11,230,247,119,72,244,145,91,75,7,67,5,130,151,44,231,52,220,28,154,212,82,58,90,203,211,236,4]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,55,101,77,106,48,73,83,72,56,56,81,56,45,89,51,74,89,70,53,76,72,57,83,54,68,119,71,73,49,88,45,115,87,53,68,104,66,87,121,71,119,78,115,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,103,45,197,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109]},signature:{type:"Buffer",data:[88,189,229,122,44,171,194,156,90,79,148,49,207,224,34,199,219,88,24,243,103,127,123,41,87,171,127,92,6,216,198,171,26,226,237,217,122,78,98,146,55,255,68,240,202,83,58,140,147,185,3,66,15,216,210,22,99,197,73,234,120,17,74,1]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,114,70,71,83,100,113,104,101,68,107,70,70,56,69,102,109,45,69,116,55,119,81,101,120,83,88,55,65,112,69,51,89,86,99,45,120,102,52,104,106,77,115,77,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,23,220,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56]},signature:{type:"Buffer",data:[129,12,55,104,239,121,138,2,86,106,136,51,219,79,170,8,195,69,81,188,225,192,247,196,54,39,164,110,75,39,240,56,245,189,154,77,72,11,97,250,202,149,242,97,128,28,47,164,236,104,136,82,212,246,44,143,132,119,255,135,112,11,20,13]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56,164,117,114,108,115,145,217,97,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,104,121,112,115,86,121,103,117,80,84,115,53,118,73,80,65,102,97,112,90,88,113,117,84,115,79,80,100,67,81,79,79,117,103,57,51,82,103,106,95,114,85,73,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,54,53,46,50,50,46,51,50,46,49,49,47,112,47,53,55,55,57,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,188,123,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}}])}runtimeHcAddAgentInfos(e){return!0}runtimeVerifyStringSignedByDid(e,r,n,i){return!0}runtimeSetStatus(e){return!0}runtimeFriendStatus(e){return zr}runtimeFriendSendMessage(e,r){return!0}runtimeMessageInbox(e){return[zr]}runtimeMessageOutbox(e){return[{recipient:"did:test:recipient",message:zr}]}runtimeMessageReceived(){return zr}exceptionOccurred(){return{title:"Test title",message:"Test message",type:wl.LanguageIsNotLoaded}}runtimeRequestInstallNotification(e){return"new-notification-id"}runtimeNotifications(){return[{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}]}runtimeUpdateNotification(e,r){return!0}runtimeRemoveNotification(e){return!0}runtimeGrantNotification(e){return!0}runtimeNotificationTriggered(){return{perspectiveId:"test-perspective-id",triggerMatch:"test-trigger-match",notification:{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}}}runtimeExportDb(e){return!0}runtimeImportDb(e){return!0}runtimeExportPerspective(e,r){return!0}runtimeImportPerspective(e){return!0}};N([Ve(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Boolean)],ae.prototype,"runtimeQuit",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeOpenLink",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Ri)],ae.prototype,"runtimeInfo",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"addTrustedAgents",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"deleteTrustedAgents",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ae.prototype,"getTrustedAgents",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ae.prototype,"runtimeKnownLinkLanguageTemplates",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"runtimeAddKnownLinkLanguageTemplates",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"runtimeRemoveKnownLinkLanguageTemplates",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ae.prototype,"runtimeFriends",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"runtimeAddFriends",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Array]),E("design:returntype",Array)],ae.prototype,"runtimeRemoveFriends",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",String)],ae.prototype,"runtimeHcAgentInfos",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Boolean)],ae.prototype,"runtimeHcAddAgentInfos",null);N([cr(),ye(0,ge()),ye(1,ge()),ye(2,ge()),ye(3,ge()),E("design:type",Function),E("design:paramtypes",[String,String,String,String]),E("design:returntype",void 0)],ae.prototype,"runtimeVerifyStringSignedByDid",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[or]),E("design:returntype",Boolean)],ae.prototype,"runtimeSetStatus",null);N([cr(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Un)],ae.prototype,"runtimeFriendStatus",null);N([Ve(),ye(0,ge()),ye(1,ge()),E("design:type",Function),E("design:paramtypes",[String,Os]),E("design:returntype",Boolean)],ae.prototype,"runtimeFriendSendMessage",null);N([cr(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Array)],ae.prototype,"runtimeMessageInbox",null);N([cr(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Array)],ae.prototype,"runtimeMessageOutbox",null);N([El(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Un)],ae.prototype,"runtimeMessageReceived",null);N([El(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Qn)],ae.prototype,"exceptionOccurred",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[Ft]),E("design:returntype",String)],ae.prototype,"runtimeRequestInstallNotification",null);N([cr(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Array)],ae.prototype,"runtimeNotifications",null);N([Ve(),ye(0,ge()),ye(1,ge()),E("design:type",Function),E("design:paramtypes",[String,Ft]),E("design:returntype",Boolean)],ae.prototype,"runtimeUpdateNotification",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeRemoveNotification",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeGrantNotification",null);N([El(),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Pi)],ae.prototype,"runtimeNotificationTriggered",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeExportDb",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeImportDb",null);N([Ve(),ye(0,ge()),ye(1,ge()),E("design:type",Function),E("design:paramtypes",[String,String]),E("design:returntype",Boolean)],ae.prototype,"runtimeExportPerspective",null);N([Ve(),ye(0,ge()),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Boolean)],ae.prototype,"runtimeImportPerspective",null);ae=N([Iy()],ae);var tc="0.10.1-release-candidate-1-dev3";var Er=12e3;function Yv(){console.log("!! timeout yo!");let t=new AbortController;return setTimeout(()=>t.abort(),20),t}function rc(t,e=1e4){return me(this,null,function*(){return Promise.race([new Promise((r,n)=>{try{t.includes("localhost")||r(new WebSocket(t));let i=new WebSocket(t);i.onopen=()=>{r(i)},i.onerror=a=>{n(a)}}catch(i){n(i)}}),new Promise((r,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},e)})])})}function Ml(t){return me(this,null,function*(){try{let e=yield fetch(`http://localhost:${t}/graphql/`,{signal:Yv().signal,mode:"cors"});if(e.status===400||e.status===0||e.status===200)return t;throw new Error(`Could not connect to port ${t}`)}catch(e){throw new Error(`Could not connect to port ${t}`)}})}function Jv(){return new Promise((t,e)=>{let r=document.querySelector("ad4m-connect"),n=r==null?void 0:r.getAd4mClient();n?t(n):e("No Ad4mClient found")})}function Ul(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(t){return!1}return!0}function nc(t,e){Ul()&&localStorage.setItem(`${tc}/${t}`,e)}function lr(t){return Ul()?localStorage.getItem(`${tc}/${t}`):null}function jl(t){Ul()&&localStorage.removeItem(`${tc}/${t}`)}var Xv=t=>{let e=new Set;do for(let r of Reflect.ownKeys(t))e.add([t,r]);while((t=Reflect.getPrototypeOf(t))&&t!==Object.prototype);return e};function io(t,{include:e,exclude:r}={}){let n=i=>{let a=o=>typeof o=="string"?i===o:o.test(i);return e?e.some(a):r?!r.some(a):!0};for(let[i,a]of Xv(t.constructor.prototype)){if(a==="constructor"||!n(a))continue;let o=Reflect.getOwnPropertyDescriptor(i,a);o&&typeof o.value=="function"&&(t[a]=t[a].bind(t))}return t}var ao=class{constructor({appName:e,appDesc:r,appIconPath:n,appUrl:i,appDomain:a,capabilities:o,port:s,token:u,url:c,hosting:l}){this.activeSocket=null;this.requestedRestart=!1;this.authState="unauthenticated";this.connectionState="not_connected";this.port=Er;this.capabilities=[];this.isHosting=!1;this.listeners={authstatechange:[],configstatechange:[],connectionstatechange:[]};io(this);this.appName=e,this.appDesc=r,this.appDomain=a,this.appUrl=i,this.appIconPath=n,this.capabilities=o,this.port=s||this.port,this.url=c||`ws://localhost:${this.port}/graphql`,this.token=u||this.token,this.isHosting=l||!1,this.buildClient()}notifyConfigChange(e,r){this.listeners.configstatechange.forEach(n=>{n(e,r)})}notifyConnectionChange(e){this.connectionState!==e&&(this.connectionState=e,this.listeners.connectionstatechange.forEach(r=>{r(e)}))}notifyAuthChange(e){this.authState!==e&&(this.authState=e,this.listeners.authstatechange.forEach(r=>{r(e)}))}setPort(e){this.port!==e&&(this.port=e,this.setUrl(`ws://localhost:${this.port}/graphql`),this.notifyConfigChange("port",e))}setUrl(e){this.url!==e&&(this.url=e,this.notifyConfigChange("url",e))}setToken(e){this.token!==e&&(this.token=e,this.notifyConfigChange("token",e))}on(e,r){console.log("!!!on!!!",e,r),this.listeners[e].push(r)}connect(e){return me(this,null,function*(){try{if(e){yield rc(e),this.setUrl(e);let r=this.buildClient();return yield this.checkAuth(),r}else{this.notifyConnectionChange("checking_local");try{yield rc(`ws://localhost:${this.port}/graphql`,2e3);let r=this.buildClient();return yield this.checkAuth(),r}catch(r){let n=yield this.ensureConnection();return yield this.checkAuth(),n}}}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}loginToHosting(e,r){return me(this,null,function*(){try{let n=yield fetch("https://hosting.ad4m.dev/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:r})});if(n.status===200){let i=yield n.json();localStorage.setItem("hosting_token",i.token);let a=localStorage.getItem("hosting_token"),o=yield fetch("https://hosting.ad4m.dev/api/service/info",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+a}});if(o.status===200){let s=yield o.json();if(s.serviceId)if(this.setPort(s.port),this.setUrl(s.url),this.isHosting=!0,nc("ad4mhosting","true"),!s.paused)this.connect();else throw new Error("Hosting is not running")}}else if((yield n.json()).message==="Passwords did not match")throw new Error("Passwords did not match")}catch(n){throw console.log(n),new Error(`Error logging in ${n}`)}})}checkEmail(e){return me(this,null,function*(){try{return(yield fetch(`https://hosting.ad4m.dev/api/auth/check-email?email=${e}`,{method:"GET",headers:{"Content-Type":"application/json"}})).status===200}catch(r){console.log(r)}})}connectToPort(e){return me(this,null,function*(){try{if(e){let r=yield Ml(e);return this.setPort(r),this.buildClient()}else if(this.url.includes("localhost")){let r=yield this.findPort();return this.setPort(r),this.buildClient()}}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}ensureConnection(){return me(this,null,function*(){var r,n;if(((r=this.activeSocket)==null?void 0:r.readyState)===WebSocket.OPEN&&((n=this.activeSocket)==null?void 0:n.url)===this.url&&this.ad4mClient)return this.ad4mClient;try{return this.notifyConnectionChange("connecting"),yield rc(this.url),this.buildClient()}catch(i){return this.notifyConnectionChange("not_connected"),this.connectToPort()}})}findPort(){return me(this,null,function*(){let e=[...Array(10).keys()].map((i,a)=>Ml(Er+a)),n=(yield Promise.allSettled(e)).find(i=>i.status==="fulfilled");if(n)return n.value;throw Error("Couldn't find an open port")})}buildClient(){this.notifyConnectionChange("connecting");try{let e=new WebSocket(this.url)}catch(e){this.notifyConnectionChange("not_connected");return}return this.apolloClient&&this.wsClient&&(this.requestedRestart=!0,this.wsClient.dispose(),this.apolloClient.stop(),this.wsClient=null,this.apolloClient=null),this.wsClient=gd({url:this.url,connectionParams:()=>me(this,null,function*(){return{headers:{authorization:this.token}}}),on:{opened:e=>{var n;this.activeSocket=e;let r=(n=e.onmessage)==null?void 0:n.bind(e);e.onmessage=i=>{console.log("!!! ws.onmessage at",performance.now(),i.data),r==null||r(i)}},error:e=>{this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")},connected:()=>{this.notifyConnectionChange("connected"),this.checkAuth()},closed:e=>me(this,null,function*(){if(!e.wasClean&&!this.requestedRestart)if(!this.token)this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1;else{let r=yield this.connect();r?this.ad4mClient=r:(this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1)}})}}),this.apolloClient=new Du({link:new yd(this.wsClient),cache:new Qo({resultCaching:!1,addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache"},query:{fetchPolicy:"no-cache"},mutate:{fetchPolicy:"no-cache"}}}),this.ad4mClient=new Bs(this.apolloClient),this.ad4mClient}checkAuth(){return me(this,null,function*(){try{return(yield this.ad4mClient.agent.isLocked())?this.notifyAuthChange("locked"):(yield this.ad4mClient.agent.status(),this.notifyAuthChange("authenticated")),!0}catch(e){return e.message==="Socket closed with event 4500 Cannot extractByTags from a ciphered wallet. You must unlock first."?(this.notifyAuthChange("locked"),!0):(this.notifyAuthChange("unauthenticated"),!1)}})}requestCapability(e=!1){return me(this,null,function*(){var r;if(e&&this.setToken(null),this.isHosting){let n=localStorage.getItem("hosting_token");(yield fetch("https://hosting.ad4m.dev/api/service/checkStatus",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+n}})).status!==200&&console.error("Looks like the client is not running you might not recieve the mail with the code, please check your dashboard logs.")}return this.requestId=yield(r=this.ad4mClient)==null?void 0:r.agent.requestCapability({appName:this.appName,appDesc:this.appDesc,appUrl:this.appUrl,appIconPath:this.appIconPath,appDomain:this.appDomain,capabilities:this.capabilities}),this.requestId})}verifyCode(e){return me(this,null,function*(){var r;try{let n=yield(r=this.ad4mClient)==null?void 0:r.agent.generateJwt(this.requestId,e);return this.setToken(n),yield this.buildClient(),yield this.checkAuth(),this.token}catch(n){throw new Error("Invalid code")}})}clearState(){this.setToken(null),this.setPort(Er),this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}};function Bl({unlockAgent:t,reconnect:e}){return z`
|
|
1395
1395
|
<div class="text-center">
|
|
1396
1396
|
<div class="items">
|
|
1397
1397
|
<div>
|
package/package.json
CHANGED