@junobuild/core-peer 0.0.19 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{Principal as ot}from"@dfinity/principal";var c=t=>t==null,p=t=>!c(t),se=class extends Error{},F=(t,e)=>{if(c(t))throw new se(e)},z="__bigint__",W="__principal__",Y="__uint8array__",oe=(t,e)=>typeof e=="bigint"?{[z]:`${e}`}:p(e)&&e instanceof ot?{[W]:e.toText()}:p(e)&&e instanceof Uint8Array?{[Y]:Array.from(e)}:e,ie=(t,e)=>{let s=o=>e[o];return p(e)&&typeof e=="object"&&z in e?BigInt(s(z)):p(e)&&typeof e=="object"&&W in e?ot.fromText(s(W)):p(e)&&typeof e=="object"&&Y in e?Uint8Array.from(s(Y)):e},_=t=>p(t)?[t]:[],d=t=>t?.[0],it=async t=>{let e=new Blob([JSON.stringify(t,oe)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},V=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),ie)},nt=()=>typeof window<"u";var b=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:s})=>s(e))}subscribe(e){let s=Symbol();return this.callbacks.push({id:s,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:o})=>o!==s)}};var w=class t extends b{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let s=super.subscribe(e);return e(this.authUser),s}reset(){this.authUser=null,this.populate(this.authUser)}};var G=({message:t,detail:e})=>{let s=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(s)};var rt=BigInt(144e11),at=!1,ct={width:576,height:576},lt={width:505,height:705},pt="internetcomputer.org";var R="http://127.0.0.1:5987",dt="rdmx6-jaaaa-aaaaa-aaadq-cai";var x=class t extends b{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let s=super.subscribe(e);return e(this.env),s}};var J=({width:t,height:e})=>{if(!nt()||c(window)||c(window.top))return;let{top:{innerWidth:s,innerHeight:o}}=window,i=o/2+screenY-e/2,n=s/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${n}`};var M=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let s=()=>{let o=x.getInstance().get()?.container;if(c(o)||o===!1)return`https://identity.${this.#t??pt}`;let i=x.getInstance().get(),n=p(i)&&p(i?.internetIdentityId)?i.internetIdentityId:dt,{host:r,protocol:a}=new URL(o===!0?R:o);return/apple/i.test(navigator?.vendor)?`${a}//${r}?canisterId=${n}`:`${a}//${n}.${r.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:J(ct)},identityProvider:s()}}},ut=class{#t;#e;constructor({appName:e,logoUrl:s}){this.#t=e,this.#e=s}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:J(lt)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};import{AuthClient as ne}from"@dfinity/auth-client";var K=()=>ne.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var mt=async({data:t})=>{try{return await V(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var X=async t=>{let{data:e,version:s,description:o}=t;return{description:_(o),data:await it(e),version:_(s)}},Q=t=>{let{version:e}=t;return{version:_(e)}},C=async({doc:t,key:e})=>{let{owner:s,version:o,description:i,data:n,...r}=t;return{key:e,description:d(i),owner:s.toText(),data:await V(n),version:d(o),...r}};import{Principal as re}from"@dfinity/principal";var $=({matcher:t,paginate:e,order:s,owner:o})=>({matcher:c(t)?[]:[{key:_(t.key),description:_(t.description)}],paginate:_(c(e)?void 0:{start_after:_(e.startAfter),limit:_(c(e.limit)?void 0:BigInt(e.limit))}),order:_(c(s)?void 0:{desc:s.desc,field:s.field==="created_at"?{CreatedAt:null}:s.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:_(c(o)?void 0:typeof o=="string"?re.fromText(o):o)});var yt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),s=t.Record({controllers:t.Vec(t.Principal)}),o=t.Variant({Write:t.Null,Admin:t.Null}),i=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:o,expires_at:t.Opt(t.Nat64)}),n=t.Record({version:t.Opt(t.Nat64)}),r=t.Variant({Db:t.Null,Storage:t.Null}),a=t.Record({cycles:t.Nat,destination_id:t.Principal}),l=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),T=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),m=t.Record({key:l,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,T)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),g=t.Record({derivation_origin:t.Opt(t.Text)}),h=t.Record({internet_identity:t.Opt(g)}),v=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),O=t.Variant({Deny:t.Null,Allow:t.Null}),N=t.Record({status_code:t.Nat16,location:t.Text}),S=t.Record({iframe:t.Opt(v),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),raw_access:t.Opt(O),redirects:t.Opt(t.Vec(t.Tuple(t.Text,N)))}),u=t.Record({storage:S}),A=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),j=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),k=t.Variant({Heap:t.Null,Stable:t.Null}),E=t.Record({memory:k,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),H=t.Variant({Callback:t.Record({token:E,callback:t.Func([],[],["query"])})}),$t=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(H),status_code:t.Nat16}),Bt=t.Record({token:t.Opt(E),body:t.Vec(t.Nat8)}),qt=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),jt=t.Record({batch_id:t.Nat}),Ht=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),zt=t.Record({field:Ht,desc:t.Bool}),Wt=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),Yt=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),et=t.Record({order:t.Opt(zt),owner:t.Opt(t.Principal),matcher:t.Opt(Wt),paginate:t.Opt(Yt)}),Gt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,m)),items_length:t.Nat64}),Jt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Xt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,A)),items_length:t.Nat64}),U=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),Qt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:U,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:U}),Zt=t.Record({stable:t.Nat64,heap:t.Nat64}),It=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:o,expires_at:t.Opt(t.Nat64)}),Dt=t.Record({controller:It,controllers:t.Vec(t.Principal)}),st=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Lt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),max_size:t.Opt(t.Nat),read:U,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:U}),te=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),ee=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([s],[t.Vec(t.Tuple(t.Principal,i))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,n],[],[]),del_docs:t.Func([t.Text],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,n))],[],[]),del_rule:t.Func([r,t.Text,n],[],[]),deposit_cycles:t.Func([a],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(m)],["query"]),get_auth_config:t.Func([],[t.Opt(h)],["query"]),get_config:t.Func([],[u],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(A)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(m)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(A)))],["query"]),http_request:t.Func([j],[$t],["query"]),http_request_streaming_callback:t.Func([E],[Bt],["query"]),init_asset_upload:t.Func([qt],[jt],[]),list_assets:t.Func([t.Text,et],[Gt],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,i))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Jt))],["query"]),list_docs:t.Func([t.Text,et],[Xt],["query"]),list_rules:t.Func([r],[t.Vec(t.Tuple(t.Text,Qt))],["query"]),memory_size:t.Func([],[Zt],["query"]),set_auth_config:t.Func([h],[],[]),set_config:t.Func([u],[],[]),set_controllers:t.Func([Dt],[t.Vec(t.Tuple(t.Principal,i))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,st],[A],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,st))],[t.Vec(t.Tuple(t.Text,A))],[]),set_rule:t.Func([r,t.Text,Lt],[],[]),upload_asset_chunk:t.Func([te],[ee],[]),version:t.Func([],[t.Text],["query"])})};import{Actor as ae,HttpAgent as ce}from"@dfinity/agent";var ft=async({satelliteId:t,idlFactory:e,identity:s,fetch:o,container:i})=>{let r=p(i)&&i!==!1?i===!0?R:i:"https://icp-api.io",a=new ce({identity:s,host:r,...o&&{fetch:o}});return p(i)&&await a.fetchRootKey(),ae.createActor(e,{agent:a,canisterId:t})};var Z=({satelliteId:t,container:e})=>{let{satelliteId:s}=I({satelliteId:t}),{container:o}=D({container:e});if(p(o)&&o!==!1){let{host:i,protocol:n}=new URL(o===!0?R:o);return`${n}//${s??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${s??"unknown"}.icp0.io`},I=({satelliteId:t})=>p(t)?{satelliteId:t}:x.getInstance().get()??{satelliteId:void 0},D=({container:t})=>p(t)?{container:t}:x.getInstance().get()??{container:void 0};var y=async({satelliteId:t,container:e,...s})=>{let{satelliteId:o}=I({satelliteId:t});F(o,"No satellite ID defined. Did you initialize Juno?");let{container:i}=D({container:e});return ft({satelliteId:o,container:i,idlFactory:yt,...s})};var gt=async({collection:t,key:e,satellite:s})=>{let o=await y(s),i=d(await o.get_doc(t,e));if(!c(i))return C({doc:i,key:e})},ht=async({docs:t,satellite:e})=>{let{get_many_docs:s}=await y(e),o=t.map(({collection:r,key:a})=>[r,a]),i=await s(o),n=[];for(let[r,a]of i){let l=d(a);n.push(p(l)?await C({key:r,doc:l}):void 0)}return n},_t=async({collection:t,doc:e,satellite:s})=>{let{set_doc:o}=await y(s),{key:i}=e,n=await X(e),r=await o(t,i,n);return await C({key:i,doc:r})},Tt=async({docs:t,satellite:e})=>{let{set_many_docs:s}=await y(e),o=[];for(let{collection:r,doc:a}of t){let{key:l}=a;o.push([r,l,await X(a)])}let i=await s(o),n=[];for(let[r,a]of i)n.push(await C({key:r,doc:a}));return n},At=async({collection:t,doc:e,satellite:s})=>{let{del_doc:o}=await y(s),{key:i}=e;return o(t,i,Q(e))},xt=async({docs:t,satellite:e})=>{let{del_many_docs:s}=await y(e),o=t.map(({collection:i,doc:n})=>[i,n.key,Q(n)]);await s(o)},Pt=async({collection:t,filter:e,satellite:s})=>{let o=await y(s),{items:i,items_page:n,items_length:r,matches_length:a,matches_pages:l}=await o.list_docs(t,$(e)),T=[];for(let[m,g]of i){let{data:h,owner:v,description:O,version:N,...S}=g;T.push({key:m,description:d(O),owner:v.toText(),data:await mt({data:h}),version:d(N),...S})}return{items:T,items_length:r,items_page:d(n),matches_length:a,matches_pages:d(l)}};import{AnonymousIdentity as le}from"@dfinity/agent";var f=t=>t!==void 0?t:B()??new le;var Nt=async({satellite:t,...e})=>{let s=f(t?.identity);return gt({...e,satellite:{...t,identity:s}})},Ts=async({satellite:t,...e})=>{let s=f(t?.identity);return ht({...e,satellite:{...t,identity:s}})},wt=async({satellite:t,...e})=>{let s=f(t?.identity);return _t({...e,satellite:{...t,identity:s}})},As=async({satellite:t,...e})=>{let s=f(t?.identity);return Tt({...e,satellite:{...t,identity:s}})},xs=async({satellite:t,...e})=>{let s=f(t?.identity);return At({...e,satellite:{...t,identity:s}})},Ps=async({satellite:t,...e})=>{let s=f(t?.identity);return xt({...e,satellite:{...t,identity:s}})},Ns=async({satellite:t,filter:e,...s})=>{let o=f(t?.identity);return Pt({...s,filter:e??{},satellite:{...t,identity:o}})};var vt=async t=>{let e=B();if(c(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let s=e.getPrincipal().toText(),o=await Nt({collection:"#user",key:s});return c(o)?await pe({userId:s,provider:t}):o},pe=async({userId:t,...e})=>wt({collection:"#user",doc:{key:t,data:e}});var P,L=async t=>{if(P=P??await K(),!(await P?.isAuthenticated()??!1))return;let s=await vt(t);w.getInstance().set(s)},de=async t=>new Promise(async(e,s)=>{P=P??await K();let o=t?.provider??new M({});await P.login({onSuccess:async()=>{await L(o.id),e()},onError:i=>s(i),maxTimeToLive:t?.maxTimeToLive??rt,allowPinAuthentication:t?.allowPin??at,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...o.signInOptions({windowed:t?.windowed})})}),tt=async()=>{await P?.logout(),P=void 0,w.getInstance().reset()},B=()=>P?.getIdentity(),ue=async()=>(P??await K()).getIdentity();var Ot=t=>{let e=t===!0?"./workers/auth.worker.js":t,s=new Worker(e),o=async()=>{G({message:"junoSignOutAuthTimer"}),await tt()};return s.onmessage=async({data:i})=>{let{msg:n,data:r}=i;switch(n){case"junoSignOutAuthTimer":await o();return;case"junoDelegationRemainingTime":G({message:"junoDelegationRemainingTime",detail:r?.authRemainingTime});return}},w.getInstance().subscribe(i=>{if(c(i)){s.postMessage({msg:"junoStopAuthTimer"});return}s.postMessage({msg:"junoStartAuthTimer"})})};var St=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},bt=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};import"@dfinity/principal";var me=t=>t==null,ye=t=>!me(t),q=t=>ye(t)?[t]:[],fe=()=>typeof window<"u",Rt=async({asset:{data:t,filename:e,collection:s,headers:o,token:i,fullPath:n,encoding:r,description:a},actor:l,init_asset_upload:T})=>{let{batch_id:m}=await T({collection:s,full_path:n,name:e,token:q(i),encoding_type:q(r),description:q(a)}),g=19e5,h=[],v=fe()?new Blob([await t.arrayBuffer()]):t,O=0n;for(let u=0;u<v.size;u+=g){let A=v.slice(u,u+g);h.push({batchId:m,chunk:A,actor:l,orderId:O}),O++}let N=[];for await(let u of ge({uploadChunks:h}))N=[...N,...u];let S=o.find(([u,A])=>u.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await l.commit_asset_upload({batch_id:m,chunk_ids:N.map(({chunk_id:u})=>u),headers:[...o,...S||[]]})};async function*ge({uploadChunks:t,limit:e=12}){for(let s=0;s<t.length;s=s+e){let o=t.slice(s,s+e);yield await Promise.all(o.map(i=>he(i)))}}var he=async({batchId:t,chunk:e,actor:s,orderId:o})=>s.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:q(o)});var kt=async({satellite:t,...e})=>{let s=await y(t);await Rt({actor:s,asset:e,init_asset_upload:async i=>await s.init_asset_upload(i)})},Et=async({collection:t,satellite:e,filter:s})=>{let o=await y(e),{items:i,items_length:n,items_page:r,matches_length:a,matches_pages:l}=await o.list_assets(t,$(s));return{items:i.map(([T,m])=>m),items_length:n,items_page:d(r),matches_length:a,matches_pages:d(l)}},Ct=async({collection:t,fullPath:e,satellite:s})=>(await y(s)).del_asset(t,e),Ut=async({assets:t,satellite:e})=>{let{del_many_assets:s}=await y(e),o=t.map(({collection:i,fullPath:n})=>[i,n]);await s(o)},Ft=async({collection:t,fullPath:e,satellite:s})=>{let{get_asset:o}=await y(s);return d(await o(t,e))},Vt=async({assets:t,satellite:e})=>{let{get_many_assets:s}=await y(e),o=t.map(({collection:n,fullPath:r})=>[n,r]);return(await s(o)).map(([n,r])=>d(r))};var Mt=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var eo=async t=>Kt(t),so=async t=>Kt({filename:t.data.name,...t}),Kt=async({filename:t,data:e,collection:s,headers:o=[],fullPath:i,token:n,satellite:r,encoding:a,description:l})=>{let T=f(r?.identity),m=decodeURI(t),g=i??`/${s}/${m}`,h={...r,identity:T};return await kt({data:e,filename:m,collection:s,token:n,headers:o,fullPath:g,encoding:a,satellite:h,description:l}),{downloadUrl:`${Z(h)}${g}${n!==void 0?`?token=${n}`:""}`,fullPath:g,name:m}},oo=async({collection:t,satellite:e,filter:s})=>{let o={...e,identity:f(e?.identity)},{items:i,...n}=await Et({collection:t,satellite:o,filter:s??{}}),r=Z(o),a=i.map(({key:{full_path:l,token:T,name:m,owner:g,description:h},headers:v,encodings:O,created_at:N,updated_at:S})=>{let u=d(T);return{fullPath:l,description:d(h),name:m,downloadUrl:`${r}${l}${u!==void 0?`?token=${u}`:""}`,token:u,headers:v,encodings:O.reduce((A,[j,{modified:k,sha256:E,total_length:H}])=>({...A,[j]:{modified:k,sha256:Mt(E),total_length:H}}),{}),owner:g.toText(),created_at:N,updated_at:S}});return{items:a,assets:a,...n}},io=async({collection:t,fullPath:e,satellite:s})=>Ct({collection:t,fullPath:e,satellite:{...s,identity:f(s?.identity)}}),no=async({assets:t,satellite:e})=>Ut({assets:t,satellite:{...e,identity:f(e?.identity)}}),ro=async({satellite:t,...e})=>{let s=f(t?.identity);return Ft({...e,satellite:{...t,identity:s}})},ao=async({satellite:t,...e})=>{let s=f(t?.identity);return Vt({...e,satellite:{...t,identity:s}})};var _e=t=>{let e=t?.satelliteId??St();F(e,"Satellite ID is not configured. Juno cannot be initialized.");let s=t?.container??bt();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:s}},go=async t=>Te(t),Te=async t=>{let e=_e(t);x.getInstance().set(e),await L();let s=e.workers?.auth!==void 0?Ot(e.workers.auth):void 0;return[...s?[s]:[]]},ho=t=>w.getInstance().subscribe(t);export{M as InternetIdentityProvider,ut as NFIDProvider,ho as authSubscribe,io as deleteAsset,xs as deleteDoc,no as deleteManyAssets,Ps as deleteManyDocs,ro as getAsset,Nt as getDoc,ao as getManyAssets,Ts as getManyDocs,go as initJuno,Te as initSatellite,oo as listAssets,Ns as listDocs,wt as setDoc,As as setManyDocs,de as signIn,tt as signOut,ue as unsafeIdentity,eo as uploadBlob,so as uploadFile};
1
+ import{Principal as et}from"@dfinity/principal";var l=t=>t==null,c=t=>!l(t),oe=class extends Error{},F=(t,e)=>{if(l(t))throw new oe(e)},H="__bigint__",z="__principal__",W="__uint8array__",ie=(t,e)=>typeof e=="bigint"?{[H]:`${e}`}:c(e)&&e instanceof et?{[z]:e.toText()}:c(e)&&e instanceof Uint8Array?{[W]:Array.from(e)}:e,ne=(t,e)=>{let s=o=>e[o];return c(e)&&typeof e=="object"&&H in e?BigInt(s(H)):c(e)&&typeof e=="object"&&z in e?et.fromText(s(z)):c(e)&&typeof e=="object"&&W in e?Uint8Array.from(s(W)):e},_=t=>c(t)?[t]:[],p=t=>t?.[0],st=async t=>{let e=new Blob([JSON.stringify(t,ie)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},V=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),ne)},ot=()=>typeof window<"u";var b=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:s})=>s(e))}subscribe(e){let s=Symbol();return this.callbacks.push({id:s,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:o})=>o!==s)}};var w=class t extends b{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let s=super.subscribe(e);return e(this.authUser),s}reset(){this.authUser=null,this.populate(this.authUser)}};var Y=({message:t,detail:e})=>{let s=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(s)};var it=BigInt(144e11),nt=!1,rt={width:576,height:576},at={width:505,height:705},ct="internetcomputer.org";var R="http://127.0.0.1:5987",lt="rdmx6-jaaaa-aaaaa-aaadq-cai";var x=class t extends b{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let s=super.subscribe(e);return e(this.env),s}};var G=({width:t,height:e})=>{if(!ot()||l(window)||l(window.top))return;let{top:{innerWidth:s,innerHeight:o}}=window,i=o/2+screenY-e/2,n=s/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${n}`};var M=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let s=()=>{let o=x.getInstance().get()?.container;if(l(o)||o===!1)return`https://identity.${this.#t??ct}`;let i=x.getInstance().get(),n=c(i)&&c(i?.internetIdentityId)?i.internetIdentityId:lt,{host:r,protocol:a}=new URL(o===!0?R:o);return/apple/i.test(navigator?.vendor)?`${a}//${r}?canisterId=${n}`:`${a}//${n}.${r.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:G(rt)},identityProvider:s()}}},pt=class{#t;#e;constructor({appName:e,logoUrl:s}){this.#t=e,this.#e=s}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:G(at)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};import{AuthClient as re}from"@dfinity/auth-client";var K=()=>re.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var dt=async({data:t})=>{try{return await V(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var J=async t=>{let{data:e,version:s,description:o}=t;return{description:_(o),data:await st(e),version:_(s)}},X=t=>{let{version:e}=t;return{version:_(e)}},U=async({doc:t,key:e})=>{let{owner:s,version:o,description:i,data:n,...r}=t;return{key:e,description:p(i),owner:s.toText(),data:await V(n),version:p(o),...r}};import{Principal as ae}from"@dfinity/principal";var $=({matcher:t,paginate:e,order:s,owner:o})=>({matcher:l(t)?[]:[{key:_(t.key),description:_(t.description)}],paginate:_(l(e)?void 0:{start_after:_(e.startAfter),limit:_(l(e.limit)?void 0:BigInt(e.limit))}),order:_(l(s)?void 0:{desc:s.desc,field:s.field==="created_at"?{CreatedAt:null}:s.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:_(l(o)?void 0:typeof o=="string"?ae.fromText(o):o)});var ut=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),s=t.Record({controllers:t.Vec(t.Principal)}),o=t.Variant({Write:t.Null,Admin:t.Null}),i=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:o,expires_at:t.Opt(t.Nat64)}),n=t.Record({version:t.Opt(t.Nat64)}),r=t.Variant({Db:t.Null,Storage:t.Null}),a=t.Record({cycles:t.Nat,destination_id:t.Principal}),d=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),A=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),u=t.Record({key:d,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,A)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),g=t.Record({derivation_origin:t.Opt(t.Text)}),h=t.Record({internet_identity:t.Opt(g)}),v=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),O=t.Variant({Deny:t.Null,Allow:t.Null}),P=t.Record({status_code:t.Nat16,location:t.Text}),S=t.Record({iframe:t.Opt(v),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),raw_access:t.Opt(O),redirects:t.Opt(t.Vec(t.Tuple(t.Text,P)))}),y=t.Record({storage:S}),T=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),j=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),k=t.Variant({Heap:t.Null,Stable:t.Null}),E=t.Record({memory:k,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),$t=t.Variant({Callback:t.Record({token:E,callback:t.Func([],[],["query"])})}),Bt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt($t),status_code:t.Nat16}),qt=t.Record({token:t.Opt(E),body:t.Vec(t.Nat8)}),jt=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),Ht=t.Record({batch_id:t.Nat}),zt=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),Wt=t.Record({field:zt,desc:t.Bool}),Yt=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),Gt=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),L=t.Record({order:t.Opt(Wt),owner:t.Opt(t.Principal),matcher:t.Opt(Yt),paginate:t.Opt(Gt)}),Jt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,u)),items_length:t.Nat64}),Xt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Qt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,T)),items_length:t.Nat64}),C=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),Zt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:C,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:C}),It=t.Record({stable:t.Nat64,heap:t.Nat64}),Dt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:o,expires_at:t.Opt(t.Nat64)}),Lt=t.Record({controller:Dt,controllers:t.Vec(t.Principal)}),tt=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),te=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),max_size:t.Opt(t.Nat),read:C,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:C}),ee=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),se=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([s],[t.Vec(t.Tuple(t.Principal,i))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,n],[],[]),del_docs:t.Func([t.Text],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,n))],[],[]),del_rule:t.Func([r,t.Text,n],[],[]),deposit_cycles:t.Func([a],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(u)],["query"]),get_auth_config:t.Func([],[t.Opt(h)],["query"]),get_config:t.Func([],[y],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(T)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(u)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(T)))],["query"]),http_request:t.Func([j],[Bt],["query"]),http_request_streaming_callback:t.Func([E],[qt],["query"]),init_asset_upload:t.Func([jt],[Ht],[]),list_assets:t.Func([t.Text,L],[Jt],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,i))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Xt))],["query"]),list_docs:t.Func([t.Text,L],[Qt],["query"]),list_rules:t.Func([r],[t.Vec(t.Tuple(t.Text,Zt))],["query"]),memory_size:t.Func([],[It],["query"]),set_auth_config:t.Func([h],[],[]),set_config:t.Func([y],[],[]),set_controllers:t.Func([Lt],[t.Vec(t.Tuple(t.Principal,i))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,tt],[T],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,tt))],[t.Vec(t.Tuple(t.Text,T))],[]),set_rule:t.Func([r,t.Text,te],[],[]),upload_asset_chunk:t.Func([ee],[se],[]),version:t.Func([],[t.Text],["query"])})};import{Actor as ce,HttpAgent as le}from"@dfinity/agent";var mt=async({satelliteId:t,idlFactory:e,identity:s,fetch:o,container:i})=>{let r=c(i)&&i!==!1?i===!0?R:i:"https://icp-api.io",a=new le({identity:s,host:r,...o&&{fetch:o}});return c(i)&&await a.fetchRootKey(),ce.createActor(e,{agent:a,canisterId:t})};var yt=({satelliteId:t,container:e})=>{let{satelliteId:s}=Q({satelliteId:t}),{container:o}=Z({container:e});if(c(o)&&o!==!1){let{host:i,protocol:n}=new URL(o===!0?R:o);return`${n}//${s??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${s??"unknown"}.icp0.io`},Q=({satelliteId:t})=>c(t)?{satelliteId:t}:x.getInstance().get()??{satelliteId:void 0},Z=({container:t})=>c(t)?{container:t}:x.getInstance().get()??{container:void 0};var f=async({satelliteId:t,container:e,...s})=>{let{satelliteId:o}=Q({satelliteId:t});F(o,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Z({container:e});return mt({satelliteId:o,container:i,idlFactory:ut,...s})};var ft=async({collection:t,key:e,satellite:s})=>{let o=await f(s),i=p(await o.get_doc(t,e));if(!l(i))return U({doc:i,key:e})},gt=async({docs:t,satellite:e})=>{let{get_many_docs:s}=await f(e),o=t.map(({collection:r,key:a})=>[r,a]),i=await s(o),n=[];for(let[r,a]of i){let d=p(a);n.push(c(d)?await U({key:r,doc:d}):void 0)}return n},ht=async({collection:t,doc:e,satellite:s})=>{let{set_doc:o}=await f(s),{key:i}=e,n=await J(e),r=await o(t,i,n);return await U({key:i,doc:r})},_t=async({docs:t,satellite:e})=>{let{set_many_docs:s}=await f(e),o=[];for(let{collection:r,doc:a}of t){let{key:d}=a;o.push([r,d,await J(a)])}let i=await s(o),n=[];for(let[r,a]of i)n.push(await U({key:r,doc:a}));return n},At=async({collection:t,doc:e,satellite:s})=>{let{del_doc:o}=await f(s),{key:i}=e;return o(t,i,X(e))},Tt=async({docs:t,satellite:e})=>{let{del_many_docs:s}=await f(e),o=t.map(({collection:i,doc:n})=>[i,n.key,X(n)]);await s(o)},xt=async({collection:t,filter:e,satellite:s})=>{let o=await f(s),{items:i,items_page:n,items_length:r,matches_length:a,matches_pages:d}=await o.list_docs(t,$(e)),A=[];for(let[u,g]of i){let{data:h,owner:v,description:O,version:P,...S}=g;A.push({key:u,description:p(O),owner:v.toText(),data:await dt({data:h}),version:p(P),...S})}return{items:A,items_length:r,items_page:p(n),matches_length:a,matches_pages:p(d)}};import{AnonymousIdentity as pe}from"@dfinity/agent";var m=t=>t!==void 0?t:B()??new pe;var Nt=async({satellite:t,...e})=>{let s=m(t?.identity);return ft({...e,satellite:{...t,identity:s}})},Ts=async({satellite:t,...e})=>{let s=m(t?.identity);return gt({...e,satellite:{...t,identity:s}})},Pt=async({satellite:t,...e})=>{let s=m(t?.identity);return ht({...e,satellite:{...t,identity:s}})},xs=async({satellite:t,...e})=>{let s=m(t?.identity);return _t({...e,satellite:{...t,identity:s}})},Ns=async({satellite:t,...e})=>{let s=m(t?.identity);return At({...e,satellite:{...t,identity:s}})},Ps=async({satellite:t,...e})=>{let s=m(t?.identity);return Tt({...e,satellite:{...t,identity:s}})},ws=async({satellite:t,filter:e,...s})=>{let o=m(t?.identity);return xt({...s,filter:e??{},satellite:{...t,identity:o}})};var wt=async t=>{let e=B();if(l(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let s=e.getPrincipal().toText(),o=await Nt({collection:"#user",key:s});return l(o)?await de({userId:s,provider:t}):o},de=async({userId:t,...e})=>Pt({collection:"#user",doc:{key:t,data:e}});var N,I=async t=>{if(N=N??await K(),!(await N?.isAuthenticated()??!1))return;let s=await wt(t);w.getInstance().set(s)},ue=async t=>new Promise(async(e,s)=>{N=N??await K();let o=t?.provider??new M({});await N.login({onSuccess:async()=>{await I(o.id),e()},onError:i=>s(i),maxTimeToLive:t?.maxTimeToLive??it,allowPinAuthentication:t?.allowPin??nt,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...o.signInOptions({windowed:t?.windowed})})}),D=async()=>{await N?.logout(),N=void 0,w.getInstance().reset()},B=()=>N?.getIdentity(),me=async()=>(N??await K()).getIdentity();var vt=t=>{let e=t===!0?"./workers/auth.worker.js":t,s=new Worker(e),o=async()=>{Y({message:"junoSignOutAuthTimer"}),await D()};return s.onmessage=async({data:i})=>{let{msg:n,data:r}=i;switch(n){case"junoSignOutAuthTimer":await o();return;case"junoDelegationRemainingTime":Y({message:"junoDelegationRemainingTime",detail:r?.authRemainingTime});return}},w.getInstance().subscribe(i=>{if(l(i)){s.postMessage({msg:"junoStopAuthTimer"});return}s.postMessage({msg:"junoStartAuthTimer"})})};var Ot=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},St=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};import"@dfinity/principal";var ye=t=>t==null,fe=t=>!ye(t),q=t=>fe(t)?[t]:[],ge=()=>typeof window<"u",bt=async({asset:{data:t,filename:e,collection:s,headers:o,token:i,fullPath:n,encoding:r,description:a},actor:d,init_asset_upload:A})=>{let{batch_id:u}=await A({collection:s,full_path:n,name:e,token:q(i),encoding_type:q(r),description:q(a)}),g=19e5,h=[],v=ge()?new Blob([await t.arrayBuffer()]):t,O=0n;for(let y=0;y<v.size;y+=g){let T=v.slice(y,y+g);h.push({batchId:u,chunk:T,actor:d,orderId:O}),O++}let P=[];for await(let y of he({uploadChunks:h}))P=[...P,...y];let S=o.find(([y,T])=>y.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await d.commit_asset_upload({batch_id:u,chunk_ids:P.map(({chunk_id:y})=>y),headers:[...o,...S||[]]})};async function*he({uploadChunks:t,limit:e=12}){for(let s=0;s<t.length;s=s+e){let o=t.slice(s,s+e);yield await Promise.all(o.map(i=>_e(i)))}}var _e=async({batchId:t,chunk:e,actor:s,orderId:o})=>s.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:q(o)});var Rt=async({satellite:t,...e})=>{let s=await f(t);await bt({actor:s,asset:e,init_asset_upload:async i=>await s.init_asset_upload(i)})},kt=async({collection:t,satellite:e,filter:s})=>{let o=await f(e),{items:i,items_length:n,items_page:r,matches_length:a,matches_pages:d}=await o.list_assets(t,$(s));return{items:i.map(([A,u])=>u),items_length:n,items_page:p(r),matches_length:a,matches_pages:p(d)}},Et=async({collection:t,fullPath:e,satellite:s})=>(await f(s)).del_asset(t,e),Ut=async({assets:t,satellite:e})=>{let{del_many_assets:s}=await f(e),o=t.map(({collection:i,fullPath:n})=>[i,n]);await s(o)},Ct=async({collection:t,fullPath:e,satellite:s})=>{let{get_asset:o}=await f(s);return p(await o(t,e))},Ft=async({assets:t,satellite:e})=>{let{get_many_assets:s}=await f(e),o=t.map(({collection:n,fullPath:r})=>[n,r]);return(await s(o)).map(([n,r])=>p(r))};var Vt=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var so=async t=>Mt(t),oo=async t=>Mt({filename:t.data.name,...t}),Mt=async({filename:t,data:e,collection:s,headers:o=[],fullPath:i,token:n,satellite:r,encoding:a,description:d})=>{let A=m(r?.identity),u=decodeURI(t),g=i??`/${s}/${u}`,h={...r,identity:A};return await Rt({data:e,filename:u,collection:s,token:n,headers:o,fullPath:g,encoding:a,satellite:h,description:d}),{downloadUrl:Kt({satellite:h,assetKey:{fullPath:g,token:n}}),fullPath:g,name:u}},io=async({collection:t,satellite:e,filter:s})=>{let o={...e,identity:m(e?.identity)},{items:i,...n}=await kt({collection:t,satellite:o,filter:s??{}}),r=i.map(({key:{full_path:a,token:d,name:A,owner:u,description:g},headers:h,encodings:v,created_at:O,updated_at:P})=>{let S=p(d);return{fullPath:a,description:p(g),name:A,downloadUrl:Kt({satellite:o,assetKey:{fullPath:a,token:S}}),token:S,headers:h,encodings:v.reduce((y,[T,{modified:j,sha256:k,total_length:E}])=>({...y,[T]:{modified:j,sha256:Vt(k),total_length:E}}),{}),owner:u.toText(),created_at:O,updated_at:P}});return{items:r,assets:r,...n}},no=async({collection:t,fullPath:e,satellite:s})=>Et({collection:t,fullPath:e,satellite:{...s,identity:m(s?.identity)}}),ro=async({assets:t,satellite:e})=>Ut({assets:t,satellite:{...e,identity:m(e?.identity)}}),ao=async({satellite:t,...e})=>{let s=m(t?.identity);return Ct({...e,satellite:{...t,identity:s}})},co=async({satellite:t,...e})=>{let s=m(t?.identity);return Ft({...e,satellite:{...t,identity:s}})},Kt=({assetKey:{fullPath:t,token:e},satellite:s})=>{let o={...s,identity:m(s?.identity)};return`${yt(o)}${t}${c(e)?`?token=${e}`:""}`};var Ae=t=>{let e=t?.satelliteId??Ot();F(e,"Satellite ID is not configured. Juno cannot be initialized.");let s=t?.container??St();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:s}},ho=async t=>Te(t),Te=async t=>{let e=Ae(t);x.getInstance().set(e),await I();let s=e.workers?.auth!==void 0?vt(e.workers.auth):void 0;return[...s?[s]:[]]},_o=t=>w.getInstance().subscribe(t);export{M as InternetIdentityProvider,pt as NFIDProvider,_o as authSubscribe,no as deleteAsset,Ns as deleteDoc,ro as deleteManyAssets,Ps as deleteManyDocs,Kt as downloadUrl,ao as getAsset,Nt as getDoc,co as getManyAssets,Ts as getManyDocs,ho as initJuno,Te as initSatellite,io as listAssets,ws as listDocs,Pt as setDoc,xs as setManyDocs,ue as signIn,D as signOut,me as unsafeIdentity,so as uploadBlob,oo as uploadFile};
2
2
  //# sourceMappingURL=index.js.map