@junobuild/core-peer 0.0.16 → 0.0.17

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 st}from"@dfinity/principal";var c=t=>t==null,l=t=>!c(t),te=class extends Error{},F=(t,e)=>{if(c(t))throw new te(e)},H="__bigint__",z="__principal__",W="__uint8array__",ee=(t,e)=>typeof e=="bigint"?{[H]:`${e}`}:l(e)&&e instanceof st?{[z]:e.toText()}:l(e)&&e instanceof Uint8Array?{[W]:Array.from(e)}:e,se=(t,e)=>{let s=o=>e[o];return l(e)&&typeof e=="object"&&H in e?BigInt(s(H)):l(e)&&typeof e=="object"&&z in e?st.fromText(s(z)):l(e)&&typeof e=="object"&&W in e?Uint8Array.from(s(W)):e},d=t=>l(t)?[t]:[],p=t=>t?.[0],ot=async t=>{let e=new Blob([JSON.stringify(t,ee)],{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(),se)},M=()=>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 v=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 nt=BigInt(144e11),it=!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 P=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 Y=({width:t,height:e})=>{if(!M()||c(window)||c(window.top))return;let{top:{innerWidth:s,innerHeight:o}}=window,n=o/2+screenY-e/2,i=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=${n}, left=${i}`};var $=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let s=()=>{let o=P.getInstance().get()?.container;if(c(o)||o===!1)return`https://identity.${this.#t??ct}`;let n=P.getInstance().get(),i=l(n)&&l(n?.internetIdentityId)?n.internetIdentityId:lt,{host:r,protocol:a}=new URL(o===!0?R:o);return/apple/i.test(navigator?.vendor)?`${a}//${r}?canisterId=${i}`:`${a}//${i}.${r.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Y(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:Y(at)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};import{AuthClient as oe}from"@dfinity/auth-client";var B=()=>oe.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:d(o),data:await ot(e),version:d(s)}},X=t=>{let{version:e}=t;return{version:d(e)}},U=async({doc:t,key:e})=>{let{owner:s,version:o,description:n,data:i,...r}=t;return{key:e,description:p(n),owner:s.toText(),data:await V(i),version:p(o),...r}};import{Principal as ne}from"@dfinity/principal";var K=({matcher:t,paginate:e,order:s,owner:o})=>({matcher:c(t)?[]:[{key:d(t.key),description:d(t.description)}],paginate:d(c(e)?void 0:{start_after:d(e.startAfter),limit:d(c(e.limit)?void 0:BigInt(e.limit))}),order:d(c(s)?void 0:{desc:s.desc,field:s.field==="created_at"?{CreatedAt:null}:s.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:d(c(o)?void 0:typeof o=="string"?ne.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}),n=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)}),i=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}),u=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}),h=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),m=t.Record({key:u,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,h)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),T=t.Record({derivation_origin:t.Opt(t.Text)}),_=t.Record({internet_identity:t.Opt(T)}),O=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),S=t.Variant({Deny:t.Null,Allow:t.Null}),w=t.Record({status_code:t.Nat16,location:t.Text}),A=t.Record({iframe:t.Opt(O),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(S),redirects:t.Opt(t.Vec(t.Tuple(t.Text,w)))}),y=t.Record({storage:A}),x=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}),C=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}),Vt=t.Variant({Callback:t.Record({token:C,callback:t.Func([],[],["query"])})}),Mt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(Vt),status_code:t.Nat16}),$t=t.Record({token:t.Opt(C),body:t.Vec(t.Nat8)}),Bt=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}),Kt=t.Record({batch_id:t.Nat}),qt=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),jt=t.Record({field:qt,desc:t.Bool}),Ht=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),zt=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),tt=t.Record({order:t.Opt(jt),owner:t.Opt(t.Principal),matcher:t.Opt(Ht),paginate:t.Opt(zt)}),Wt=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}),Gt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Yt=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,x)),items_length:t.Nat64}),E=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),Jt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:E,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:E}),Xt=t.Record({stable:t.Nat64,heap:t.Nat64}),Qt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:o,expires_at:t.Opt(t.Nat64)}),Zt=t.Record({controller:Qt,controllers:t.Vec(t.Principal)}),et=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Dt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),max_size:t.Opt(t.Nat),read:E,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:E}),It=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),Lt=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,n))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,i],[],[]),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,i))],[],[]),del_rule:t.Func([r,t.Text,i],[],[]),deposit_cycles:t.Func([a],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(m)],["query"]),get_auth_config:t.Func([],[t.Opt(_)],["query"]),get_config:t.Func([],[y],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(x)],["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(x)))],["query"]),http_request:t.Func([j],[Mt],["query"]),http_request_streaming_callback:t.Func([C],[$t],["query"]),init_asset_upload:t.Func([Bt],[Kt],[]),list_assets:t.Func([t.Text,tt],[Wt],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Gt))],["query"]),list_docs:t.Func([t.Text,tt],[Yt],["query"]),list_rules:t.Func([r],[t.Vec(t.Tuple(t.Text,Jt))],["query"]),memory_size:t.Func([],[Xt],["query"]),set_auth_config:t.Func([_],[],[]),set_config:t.Func([y],[],[]),set_controllers:t.Func([Zt],[t.Vec(t.Tuple(t.Principal,n))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,et],[x],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,et))],[t.Vec(t.Tuple(t.Text,x))],[]),set_rule:t.Func([r,t.Text,Dt],[],[]),upload_asset_chunk:t.Func([It],[Lt],[]),version:t.Func([],[t.Text],["query"])})};import{Actor as ie,HttpAgent as re}from"@dfinity/agent";var mt=async({satelliteId:t,idlFactory:e,identity:s,fetch:o,container:n})=>{let r=l(n)&&n!==!1?n===!0?R:n:"https://icp-api.io",a=new re({identity:s,host:r,...o&&{fetch:o}});return l(n)&&await a.fetchRootKey(),ie.createActor(e,{agent:a,canisterId:t})};var Q=({satelliteId:t,container:e})=>{let{satelliteId:s}=Z({satelliteId:t}),{container:o}=D({container:e});if(l(o)&&o!==!1){let{host:n,protocol:i}=new URL(o===!0?R:o);return`${i}//${s??"unknown"}.${n.replace("127.0.0.1","localhost")}`}return`https://${s??"unknown"}.icp0.io`},Z=({satelliteId:t})=>l(t)?{satelliteId:t}:P.getInstance().get()??{satelliteId:void 0},D=({container:t})=>l(t)?{container:t}:P.getInstance().get()??{container:void 0};var f=async({satelliteId:t,container:e,...s})=>{let{satelliteId:o}=Z({satelliteId:t});F(o,"No satellite ID defined. Did you initialize Juno?");let{container:n}=D({container:e});return mt({satelliteId:o,container:n,idlFactory:ut,...s})};var yt=async({collection:t,key:e,satellite:s})=>{let o=await f(s),n=p(await o.get_doc(t,e));if(!c(n))return U({doc:n,key:e})},ft=async({docs:t,satellite:e})=>{let{get_many_docs:s}=await f(e),o=t.map(({collection:r,key:a})=>[r,a]),n=await s(o),i=[];for(let[r,a]of n){let u=p(a);i.push(l(u)?await U({key:r,doc:u}):void 0)}return i},gt=async({collection:t,doc:e,satellite:s})=>{let{set_doc:o}=await f(s),{key:n}=e,i=await J(e),r=await o(t,n,i);return await U({key:n,doc:r})},ht=async({docs:t,satellite:e})=>{let{set_many_docs:s}=await f(e),o=[];for(let{collection:r,doc:a}of t){let{key:u}=a;o.push([r,u,await J(a)])}let n=await s(o),i=[];for(let[r,a]of n)i.push(await U({key:r,doc:a}));return i},Tt=async({collection:t,doc:e,satellite:s})=>{let{del_doc:o}=await f(s),{key:n}=e;return o(t,n,X(e))},_t=async({docs:t,satellite:e})=>{let{del_many_docs:s}=await f(e),o=t.map(({collection:n,doc:i})=>[n,i.key,X(i)]);await s(o)},At=async({collection:t,filter:e,satellite:s})=>{let o=await f(s),{items:n,items_page:i,items_length:r,matches_length:a,matches_pages:u}=await o.list_docs(t,K(e)),h=[];for(let[m,T]of n){let{data:_,owner:O,description:S,version:w,...A}=T;h.push({key:m,description:p(S),owner:O.toText(),data:await dt({data:_}),version:p(w),...A})}return{items:h,items_length:r,items_page:p(i),matches_length:a,matches_pages:p(u)}};import{AnonymousIdentity as ae}from"@dfinity/agent";var g=t=>t!==void 0?t:q()??new ae;var xt=async({satellite:t,...e})=>{let s=g(t?.identity);return yt({...e,satellite:{...t,identity:s}})},ys=async({satellite:t,...e})=>{let s=g(t?.identity);return ft({...e,satellite:{...t,identity:s}})},Pt=async({satellite:t,...e})=>{let s=g(t?.identity);return gt({...e,satellite:{...t,identity:s}})},fs=async({satellite:t,...e})=>{let s=g(t?.identity);return ht({...e,satellite:{...t,identity:s}})},gs=async({satellite:t,...e})=>{let s=g(t?.identity);return Tt({...e,satellite:{...t,identity:s}})},hs=async({satellite:t,...e})=>{let s=g(t?.identity);return _t({...e,satellite:{...t,identity:s}})},Ts=async({satellite:t,filter:e,...s})=>{let o=g(t?.identity);return At({...s,filter:e??{},satellite:{...t,identity:o}})};var Nt=async t=>{let e=q();if(c(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let s=e.getPrincipal().toText(),o=await xt({collection:"#user",key:s});return c(o)?await ce({userId:s,provider:t}):o},ce=async({userId:t,...e})=>Pt({collection:"#user",doc:{key:t,data:e}});var N,I=async t=>{if(N=N??await B(),!(await N?.isAuthenticated()??!1))return;let s=await Nt(t);v.getInstance().set(s)},le=async t=>new Promise(async(e,s)=>{N=N??await B();let o=t?.provider??new $({});await N.login({onSuccess:async()=>{await I(o.id),e()},onError:n=>s(n),maxTimeToLive:t?.maxTimeToLive??nt,allowPinAuthentication:t?.allowPin??it,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...o.signInOptions({windowed:t?.windowed})})}),L=async()=>{await N?.logout(),N=void 0,v.getInstance().reset()},q=()=>N?.getIdentity(),pe=async()=>(N??await B()).getIdentity();var wt=t=>{let e=t===!0?"./workers/auth.worker.js":t,s=new Worker(e),o=async()=>{G({message:"junoSignOutAuthTimer"}),await L()};return s.onmessage=async({data:n})=>{let{msg:i,data:r}=n;switch(i){case"junoSignOutAuthTimer":await o();return;case"junoDelegationRemainingTime":G({message:"junoDelegationRemainingTime",detail:r?.authRemainingTime});return}},v.getInstance().subscribe(n=>{if(c(n)){s.postMessage({msg:"junoStopAuthTimer"});return}s.postMessage({msg:"junoStartAuthTimer"})})};var vt=()=>{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()},Ot=()=>{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()};var St=async({data:t,filename:e,collection:s,headers:o,token:n,fullPath:i,encoding:r,description:a,satellite:u})=>{let h=await f(u),{batch_id:m}=await h.init_asset_upload({collection:s,full_path:i,name:e,token:d(n),encoding_type:d(r),description:d(a)}),T=19e5,_=[],O=M()?new Blob([await t.arrayBuffer()]):t,S=0n;for(let y=0;y<O.size;y+=T){let x=O.slice(y,y+T);_.push({batchId:m,chunk:x,actor:h,orderId:S}),S++}let w=[];for await(let y of de({uploadChunks:_}))w=[...w,...y];let A=o.find(([y,x])=>y.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await h.commit_asset_upload({batch_id:m,chunk_ids:w.map(({chunk_id:y})=>y),headers:[...o,...A||[]]})};async function*de({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=>ue(i)))}}var ue=async({batchId:t,chunk:e,actor:s,orderId:o})=>s.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:d(o)}),bt=async({collection:t,satellite:e,filter:s})=>{let o=await f(e),{items:n,items_length:i,items_page:r,matches_length:a,matches_pages:u}=await o.list_assets(t,K(s));return{items:n.map(([h,m])=>m),items_length:i,items_page:p(r),matches_length:a,matches_pages:p(u)}},Rt=async({collection:t,fullPath:e,satellite:s})=>(await f(s)).del_asset(t,e),kt=async({assets:t,satellite:e})=>{let{del_many_assets:s}=await f(e),o=t.map(({collection:n,fullPath:i})=>[n,i]);await s(o)},Ct=async({collection:t,fullPath:e,satellite:s})=>{let{get_asset:o}=await f(s);return p(await o(t,e))},Ut=async({assets:t,satellite:e})=>{let{get_many_assets:s}=await f(e),o=t.map(({collection:i,fullPath:r})=>[i,r]);return(await s(o)).map(([i,r])=>p(r))};var Et=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Ys=async t=>Ft(t),Js=async t=>Ft({filename:t.data.name,...t}),Ft=async({filename:t,data:e,collection:s,headers:o=[],fullPath:n,token:i,satellite:r,encoding:a,description:u})=>{let h=g(r?.identity),m=decodeURI(t),T=n??`/${s}/${m}`,_={...r,identity:h};return await St({data:e,filename:m,collection:s,token:i,headers:o,fullPath:T,encoding:a,satellite:_,description:u}),{downloadUrl:`${Q(_)}${T}${i!==void 0?`?token=${i}`:""}`,fullPath:T,name:m}},Xs=async({collection:t,satellite:e,filter:s})=>{let o={...e,identity:g(e?.identity)},{items:n,...i}=await bt({collection:t,satellite:o,filter:s??{}}),r=Q(o);return{assets:n.map(({key:{full_path:a,token:u,name:h,owner:m,description:T},headers:_,encodings:O,created_at:S,updated_at:w})=>{let A=p(u);return{fullPath:a,description:p(T),name:h,downloadUrl:`${r}${a}${A!==void 0?`?token=${A}`:""}`,token:A,headers:_,encodings:O.reduce((y,[x,{modified:j,sha256:k,total_length:C}])=>({...y,[x]:{modified:j,sha256:Et(k),total_length:C}}),{}),owner:m.toText(),created_at:S,updated_at:w}}),...i}},Qs=async({collection:t,fullPath:e,satellite:s})=>Rt({collection:t,fullPath:e,satellite:{...s,identity:g(s?.identity)}}),Zs=async({assets:t,satellite:e})=>kt({assets:t,satellite:{...e,identity:g(e?.identity)}}),Ds=async({satellite:t,...e})=>{let s=g(t?.identity);return Ct({...e,satellite:{...t,identity:s}})},Is=async({satellite:t,...e})=>{let s=g(t?.identity);return Ut({...e,satellite:{...t,identity:s}})};var me=t=>{let e=t?.satelliteId??vt();F(e,"Satellite ID is not configured. Juno cannot be initialized.");let s=t?.container??Ot();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:s}},ro=async t=>ye(t),ye=async t=>{let e=me(t);P.getInstance().set(e),await I();let s=e.workers?.auth!==void 0?wt(e.workers.auth):void 0;return[...s?[s]:[]]},ao=t=>v.getInstance().subscribe(t);export{$ as InternetIdentityProvider,pt as NFIDProvider,ao as authSubscribe,Qs as deleteAsset,gs as deleteDoc,Zs as deleteManyAssets,hs as deleteManyDocs,Ds as getAsset,xt as getDoc,Is as getManyAssets,ys as getManyDocs,ro as initJuno,ye as initSatellite,Xs as listAssets,Ts as listDocs,Pt as setDoc,fs as setManyDocs,le as signIn,L as signOut,pe as unsafeIdentity,Ys as uploadBlob,Js as uploadFile};
1
+ import{Principal as ot}from"@dfinity/principal";var c=t=>t==null,l=t=>!c(t),te=class extends Error{},F=(t,e)=>{if(c(t))throw new te(e)},z="__bigint__",W="__principal__",G="__uint8array__",ee=(t,e)=>typeof e=="bigint"?{[z]:`${e}`}:l(e)&&e instanceof ot?{[W]:e.toText()}:l(e)&&e instanceof Uint8Array?{[G]:Array.from(e)}:e,se=(t,e)=>{let s=o=>e[o];return l(e)&&typeof e=="object"&&z in e?BigInt(s(z)):l(e)&&typeof e=="object"&&W in e?ot.fromText(s(W)):l(e)&&typeof e=="object"&&G in e?Uint8Array.from(s(G)):e},m=t=>l(t)?[t]:[],p=t=>t?.[0],nt=async t=>{let e=new Blob([JSON.stringify(t,ee)],{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(),se)},M=()=>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),rt=!1,at={width:576,height:576},ct={width:505,height:705},lt="internetcomputer.org";var R="http://127.0.0.1:5987",pt="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(!M()||c(window)||c(window.top))return;let{top:{innerWidth:s,innerHeight:o}}=window,n=o/2+screenY-e/2,i=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=${n}, left=${i}`};var $=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??lt}`;let n=x.getInstance().get(),i=l(n)&&l(n?.internetIdentityId)?n.internetIdentityId:pt,{host:r,protocol:a}=new URL(o===!0?R:o);return/apple/i.test(navigator?.vendor)?`${a}//${r}?canisterId=${i}`:`${a}//${i}.${r.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:J(at)},identityProvider:s()}}},dt=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(ct)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};import{AuthClient as oe}from"@dfinity/auth-client";var B=()=>oe.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var ut=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:m(o),data:await nt(e),version:m(s)}},Q=t=>{let{version:e}=t;return{version:m(e)}},U=async({doc:t,key:e})=>{let{owner:s,version:o,description:n,data:i,...r}=t;return{key:e,description:p(n),owner:s.toText(),data:await V(i),version:p(o),...r}};import{Principal as ne}from"@dfinity/principal";var K=({matcher:t,paginate:e,order:s,owner:o})=>({matcher:c(t)?[]:[{key:m(t.key),description:m(t.description)}],paginate:m(c(e)?void 0:{start_after:m(e.startAfter),limit:m(c(e.limit)?void 0:BigInt(e.limit))}),order:m(c(s)?void 0:{desc:s.desc,field:s.field==="created_at"?{CreatedAt:null}:s.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:m(c(o)?void 0:typeof o=="string"?ne.fromText(o):o)});var mt=({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}),n=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)}),i=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}),h=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),y=t.Record({key:d,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,h)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),T=t.Record({derivation_origin:t.Opt(t.Text)}),_=t.Record({internet_identity:t.Opt(T)}),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}),C=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:C,callback:t.Func([],[],["query"])})}),Mt=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}),$t=t.Record({token:t.Opt(C),body:t.Vec(t.Nat8)}),Bt=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}),Kt=t.Record({batch_id:t.Nat}),qt=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),jt=t.Record({field:qt,desc:t.Bool}),Ht=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),zt=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),et=t.Record({order:t.Opt(jt),owner:t.Opt(t.Principal),matcher:t.Opt(Ht),paginate:t.Opt(zt)}),Wt=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,y)),items_length:t.Nat64}),Gt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Yt=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}),E=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),Jt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:E,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:E}),Xt=t.Record({stable:t.Nat64,heap:t.Nat64}),Qt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:o,expires_at:t.Opt(t.Nat64)}),Zt=t.Record({controller:Qt,controllers:t.Vec(t.Principal)}),st=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Dt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),max_size:t.Opt(t.Nat),read:E,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:E}),It=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),Lt=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,n))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,i],[],[]),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,i))],[],[]),del_rule:t.Func([r,t.Text,i],[],[]),deposit_cycles:t.Func([a],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(y)],["query"]),get_auth_config:t.Func([],[t.Opt(_)],["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(y)))],["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],[Mt],["query"]),http_request_streaming_callback:t.Func([C],[$t],["query"]),init_asset_upload:t.Func([Bt],[Kt],[]),list_assets:t.Func([t.Text,et],[Wt],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Gt))],["query"]),list_docs:t.Func([t.Text,et],[Yt],["query"]),list_rules:t.Func([r],[t.Vec(t.Tuple(t.Text,Jt))],["query"]),memory_size:t.Func([],[Xt],["query"]),set_auth_config:t.Func([_],[],[]),set_config:t.Func([u],[],[]),set_controllers:t.Func([Zt],[t.Vec(t.Tuple(t.Principal,n))],[]),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,Dt],[],[]),upload_asset_chunk:t.Func([It],[Lt],[]),version:t.Func([],[t.Text],["query"])})};import{Actor as ie,HttpAgent as re}from"@dfinity/agent";var yt=async({satelliteId:t,idlFactory:e,identity:s,fetch:o,container:n})=>{let r=l(n)&&n!==!1?n===!0?R:n:"https://icp-api.io",a=new re({identity:s,host:r,...o&&{fetch:o}});return l(n)&&await a.fetchRootKey(),ie.createActor(e,{agent:a,canisterId:t})};var Z=({satelliteId:t,container:e})=>{let{satelliteId:s}=D({satelliteId:t}),{container:o}=I({container:e});if(l(o)&&o!==!1){let{host:n,protocol:i}=new URL(o===!0?R:o);return`${i}//${s??"unknown"}.${n.replace("127.0.0.1","localhost")}`}return`https://${s??"unknown"}.icp0.io`},D=({satelliteId:t})=>l(t)?{satelliteId:t}:x.getInstance().get()??{satelliteId:void 0},I=({container:t})=>l(t)?{container:t}:x.getInstance().get()??{container:void 0};var f=async({satelliteId:t,container:e,...s})=>{let{satelliteId:o}=D({satelliteId:t});F(o,"No satellite ID defined. Did you initialize Juno?");let{container:n}=I({container:e});return yt({satelliteId:o,container:n,idlFactory:mt,...s})};var ft=async({collection:t,key:e,satellite:s})=>{let o=await f(s),n=p(await o.get_doc(t,e));if(!c(n))return U({doc:n,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]),n=await s(o),i=[];for(let[r,a]of n){let d=p(a);i.push(l(d)?await U({key:r,doc:d}):void 0)}return i},ht=async({collection:t,doc:e,satellite:s})=>{let{set_doc:o}=await f(s),{key:n}=e,i=await X(e),r=await o(t,n,i);return await U({key:n,doc:r})},Tt=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 X(a)])}let n=await s(o),i=[];for(let[r,a]of n)i.push(await U({key:r,doc:a}));return i},_t=async({collection:t,doc:e,satellite:s})=>{let{del_doc:o}=await f(s),{key:n}=e;return o(t,n,Q(e))},At=async({docs:t,satellite:e})=>{let{del_many_docs:s}=await f(e),o=t.map(({collection:n,doc:i})=>[n,i.key,Q(i)]);await s(o)},xt=async({collection:t,filter:e,satellite:s})=>{let o=await f(s),{items:n,items_page:i,items_length:r,matches_length:a,matches_pages:d}=await o.list_docs(t,K(e)),h=[];for(let[y,T]of n){let{data:_,owner:v,description:O,version:N,...S}=T;h.push({key:y,description:p(O),owner:v.toText(),data:await ut({data:_}),version:p(N),...S})}return{items:h,items_length:r,items_page:p(i),matches_length:a,matches_pages:p(d)}};import{AnonymousIdentity as ae}from"@dfinity/agent";var g=t=>t!==void 0?t:q()??new ae;var Pt=async({satellite:t,...e})=>{let s=g(t?.identity);return ft({...e,satellite:{...t,identity:s}})},ys=async({satellite:t,...e})=>{let s=g(t?.identity);return gt({...e,satellite:{...t,identity:s}})},Nt=async({satellite:t,...e})=>{let s=g(t?.identity);return ht({...e,satellite:{...t,identity:s}})},fs=async({satellite:t,...e})=>{let s=g(t?.identity);return Tt({...e,satellite:{...t,identity:s}})},gs=async({satellite:t,...e})=>{let s=g(t?.identity);return _t({...e,satellite:{...t,identity:s}})},hs=async({satellite:t,...e})=>{let s=g(t?.identity);return At({...e,satellite:{...t,identity:s}})},Ts=async({satellite:t,filter:e,...s})=>{let o=g(t?.identity);return xt({...s,filter:e??{},satellite:{...t,identity:o}})};var wt=async t=>{let e=q();if(c(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let s=e.getPrincipal().toText(),o=await Pt({collection:"#user",key:s});return c(o)?await ce({userId:s,provider:t}):o},ce=async({userId:t,...e})=>Nt({collection:"#user",doc:{key:t,data:e}});var P,L=async t=>{if(P=P??await B(),!(await P?.isAuthenticated()??!1))return;let s=await wt(t);w.getInstance().set(s)},le=async t=>new Promise(async(e,s)=>{P=P??await B();let o=t?.provider??new $({});await P.login({onSuccess:async()=>{await L(o.id),e()},onError:n=>s(n),maxTimeToLive:t?.maxTimeToLive??it,allowPinAuthentication:t?.allowPin??rt,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...o.signInOptions({windowed:t?.windowed})})}),tt=async()=>{await P?.logout(),P=void 0,w.getInstance().reset()},q=()=>P?.getIdentity(),pe=async()=>(P??await B()).getIdentity();var vt=t=>{let e=t===!0?"./workers/auth.worker.js":t,s=new Worker(e),o=async()=>{Y({message:"junoSignOutAuthTimer"}),await tt()};return s.onmessage=async({data:n})=>{let{msg:i,data:r}=n;switch(i){case"junoSignOutAuthTimer":await o();return;case"junoDelegationRemainingTime":Y({message:"junoDelegationRemainingTime",detail:r?.authRemainingTime});return}},w.getInstance().subscribe(n=>{if(c(n)){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()};var bt=async({data:t,filename:e,collection:s,headers:o,token:n,fullPath:i,encoding:r,description:a,satellite:d})=>{let h=await f(d),{batch_id:y}=await h.init_asset_upload({collection:s,full_path:i,name:e,token:m(n),encoding_type:m(r),description:m(a)}),T=19e5,_=[],v=M()?new Blob([await t.arrayBuffer()]):t,O=0n;for(let u=0;u<v.size;u+=T){let A=v.slice(u,u+T);_.push({batchId:y,chunk:A,actor:h,orderId:O}),O++}let N=[];for await(let u of de({uploadChunks:_}))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 h.commit_asset_upload({batch_id:y,chunk_ids:N.map(({chunk_id:u})=>u),headers:[...o,...S||[]]})};async function*de({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=>ue(i)))}}var ue=async({batchId:t,chunk:e,actor:s,orderId:o})=>s.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:m(o)}),Rt=async({collection:t,satellite:e,filter:s})=>{let o=await f(e),{items:n,items_length:i,items_page:r,matches_length:a,matches_pages:d}=await o.list_assets(t,K(s));return{items:n.map(([h,y])=>y),items_length:i,items_page:p(r),matches_length:a,matches_pages:p(d)}},kt=async({collection:t,fullPath:e,satellite:s})=>(await f(s)).del_asset(t,e),Ct=async({assets:t,satellite:e})=>{let{del_many_assets:s}=await f(e),o=t.map(({collection:n,fullPath:i})=>[n,i]);await s(o)},Ut=async({collection:t,fullPath:e,satellite:s})=>{let{get_asset:o}=await f(s);return p(await o(t,e))},Et=async({assets:t,satellite:e})=>{let{get_many_assets:s}=await f(e),o=t.map(({collection:i,fullPath:r})=>[i,r]);return(await s(o)).map(([i,r])=>p(r))};var Ft=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Ys=async t=>Vt(t),Js=async t=>Vt({filename:t.data.name,...t}),Vt=async({filename:t,data:e,collection:s,headers:o=[],fullPath:n,token:i,satellite:r,encoding:a,description:d})=>{let h=g(r?.identity),y=decodeURI(t),T=n??`/${s}/${y}`,_={...r,identity:h};return await bt({data:e,filename:y,collection:s,token:i,headers:o,fullPath:T,encoding:a,satellite:_,description:d}),{downloadUrl:`${Z(_)}${T}${i!==void 0?`?token=${i}`:""}`,fullPath:T,name:y}},Xs=async({collection:t,satellite:e,filter:s})=>{let o={...e,identity:g(e?.identity)},{items:n,...i}=await Rt({collection:t,satellite:o,filter:s??{}}),r=Z(o),a=n.map(({key:{full_path:d,token:h,name:y,owner:T,description:_},headers:v,encodings:O,created_at:N,updated_at:S})=>{let u=p(h);return{fullPath:d,description:p(_),name:y,downloadUrl:`${r}${d}${u!==void 0?`?token=${u}`:""}`,token:u,headers:v,encodings:O.reduce((A,[j,{modified:k,sha256:C,total_length:H}])=>({...A,[j]:{modified:k,sha256:Ft(C),total_length:H}}),{}),owner:T.toText(),created_at:N,updated_at:S}});return{items:a,assets:a,...i}},Qs=async({collection:t,fullPath:e,satellite:s})=>kt({collection:t,fullPath:e,satellite:{...s,identity:g(s?.identity)}}),Zs=async({assets:t,satellite:e})=>Ct({assets:t,satellite:{...e,identity:g(e?.identity)}}),Ds=async({satellite:t,...e})=>{let s=g(t?.identity);return Ut({...e,satellite:{...t,identity:s}})},Is=async({satellite:t,...e})=>{let s=g(t?.identity);return Et({...e,satellite:{...t,identity:s}})};var me=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}},ro=async t=>ye(t),ye=async t=>{let e=me(t);x.getInstance().set(e),await L();let s=e.workers?.auth!==void 0?vt(e.workers.auth):void 0;return[...s?[s]:[]]},ao=t=>w.getInstance().subscribe(t);export{$ as InternetIdentityProvider,dt as NFIDProvider,ao as authSubscribe,Qs as deleteAsset,gs as deleteDoc,Zs as deleteManyAssets,hs as deleteManyDocs,Ds as getAsset,Pt as getDoc,Is as getManyAssets,ys as getManyDocs,ro as initJuno,ye as initSatellite,Xs as listAssets,Ts as listDocs,Nt as setDoc,fs as setManyDocs,le as signIn,tt as signOut,pe as unsafeIdentity,Ys as uploadBlob,Js as uploadFile};
2
2
  //# sourceMappingURL=index.js.map