@junobuild/core-peer 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +3 -3
- package/dist/workers/_auth.worker.handler.js +2 -2
- package/dist/workers/_auth.worker.handler.js.map +1 -1
- package/dist/workers/auth.worker.js +2 -2
- package/dist/workers/auth.worker.js.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
import{assertNonNullish as go}from"@dfinity/utils";import{isNullish as _o}from"@dfinity/utils";var j=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:o})=>o(e))}subscribe(e){let o=Symbol();return this.callbacks.push({id:o,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:s})=>s!==o)}};var y=class t extends j{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 o=super.subscribe(e);return e(this.authUser),o}reset(){this.authUser=null,this.populate(this.authUser)}};var jt=({message:t,detail:e})=>{let o=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(o)};import{ERROR_USER_INTERRUPT as io}from"@dfinity/auth-client";import{isNullish as Ue}from"@dfinity/utils";var It=BigInt(144e11),Lt=!1,te={width:576,height:576},ee={width:505,height:705},oe="internetcomputer.org";import{isNullish as Ze,nonNullish as ae}from"@dfinity/utils";var J="http://127.0.0.1:5987",se="rdmx6-jaaaa-aaaaa-aaadq-cai";var g=class t extends j{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}reset(){this.env=null}subscribe(e){let o=super.subscribe(e);return e(this.env),o}};import{isNullish as re}from"@dfinity/utils";import{jsonReplacer as Ye,jsonReviver as Xe}from"@dfinity/utils";var ne=async t=>{let e=new Blob([JSON.stringify(t,Ye)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},L=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(),Xe)},tt=()=>typeof window<"u";var Jt=({width:t,height:e})=>{if(!tt()||re(window)||re(window.top))return;let{top:{innerWidth:o,innerHeight:s}}=window,n=s/2+screenY-e/2,r=o/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=${r}`};var et=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let o=()=>{let s=g.getInstance().get()?.container;if(Ze(s)||s===!1)return`https://identity.${this.#t??oe}`;let n=g.getInstance().get(),r=ae(n)&&ae(n?.internetIdentityId)?n.internetIdentityId:se,{host:a,protocol:i}=new URL(s===!0?J:s);return/apple/i.test(navigator?.vendor)?`${i}//${a}?canisterId=${r}`:`${i}//${r}.${a.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Jt(te)},identityProvider:o()}}},ie=class{#t;#e;constructor({appName:e,logoUrl:o}){this.#t=e,this.#e=o}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:Jt(ee)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};import{Actor as De}from"@dfinity/agent";import{isNullish as Kt}from"@dfinity/utils";import{isNullish as qt}from"@dfinity/utils";import{HttpAgent as Qe}from"@dfinity/agent";import{nonNullish as ce}from"@dfinity/utils";var le=async({identity:t,container:e})=>{let s=ce(e)&&e!==!1?e===!0?J:e:"https://icp-api.io",n=ce(e);return await Qe.create({identity:t,shouldFetchRootKey:n,host:s})};var q=class t{static instance;#t=void 0;constructor(){}static getInstance(){return qt(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...o}){let s=e.getPrincipal().toText();if(qt(this.#t)||qt(this.#t[s])){let n=await le({identity:e,...o});return this.#t={...this.#t??{},[s]:n},n}return this.#t[s]}reset(){this.#t=null}};var K=class t{static instance;#t=void 0;constructor(){}static getInstance(){return Kt(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:o,actorKey:s,...n}){let r=`${s}#${o.getPrincipal().toText()}#${e};`;if(Kt(this.#t)||Kt(this.#t[r])){let a=await this.createActor({satelliteId:e,identity:o,...n});return this.#t={...this.#t??{},[r]:a},a}return this.#t[r]}reset(){this.#t=null}async createActor({idlFactory:e,satelliteId:o,...s}){let n=await q.getInstance().getAgent(s);return De.createActor(e,{agent:n,canisterId:o})}};var ot=class extends Error{},st=class extends Error{},nt=class extends Error{},rt=class extends Error{},at=class extends Error{};import{AuthClient as Ie}from"@dfinity/auth-client";var it=()=>Ie.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});import{isNullish as ro,nonNullish as Ce}from"@dfinity/utils";var Bt=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var pe="juno.datastore.error.user.cannot_update";import{fromNullable as H,isNullish as eo,nonNullish as oo}from"@dfinity/utils";var de=async({data:t})=>{try{return await L(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};import{fromNullable as ue,toNullable as Ht}from"@dfinity/utils";var Gt=async t=>{let{data:e,version:o,description:s}=t;return{description:Ht(s),data:await ne(e),version:Ht(o)}},zt=t=>{let{version:e}=t;return{version:Ht(e)}},I=async({doc:t,key:e})=>{let{owner:o,version:s,description:n,data:r,...a}=t;return{key:e,description:ue(n),owner:o.toText(),data:await L(r),version:ue(s),...a}};import{Principal as Le}from"@dfinity/principal";import{isNullish as B,toNullable as O}from"@dfinity/utils";var _e=t=>{if(B(t))return O();switch(t.matcher){case"equal":return O({Equal:t.timestamp});case"greaterThan":return O({GreaterThan:t.timestamp});case"lessThan":return O({LessThan:t.timestamp});case"between":return O({Between:[t.timestamps.start,t.timestamps.end]});default:throw new at("Invalid list matcher for timestamp",t)}},S=({matcher:t,paginate:e,order:o,owner:s})=>({matcher:B(t)?[]:[{key:O(t.key),description:O(t.description),created_at:_e(t.createdAt),updated_at:_e(t.updatedAt)}],paginate:O(B(e)?void 0:{start_after:O(e.startAfter),limit:O(B(e.limit)?void 0:BigInt(e.limit))}),order:O(B(o)?void 0:{desc:o.desc,field:o.field==="created_at"?{CreatedAt:null}:o.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:O(B(s)?void 0:typeof s=="string"?Le.fromText(s):s)});import{assertNonNullish as to}from"@dfinity/utils";import{nonNullish as $t}from"@dfinity/utils";var me=({satelliteId:t,container:e})=>{let{satelliteId:o}=Wt({satelliteId:t}),{container:s}=Yt({container:e});if($t(s)&&s!==!1){let{host:n,protocol:r}=new URL(s===!0?J:s);return`${r}//${o??"unknown"}.${n.replace("127.0.0.1","localhost")}`}return`https://${o??"unknown"}.icp0.io`},Wt=({satelliteId:t})=>$t(t)?{satelliteId:t}:g.getInstance().get()??{satelliteId:void 0},Yt=({container:t})=>$t(t)?{container:t}:g.getInstance().get()??{container:void 0};var Xt=({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)}),o=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),s=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:s,desc:t.Bool}),r=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),a=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(r),description:t.Opt(t.Text),created_at:t.Opt(r)}),i=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),c=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(a),paginate:t.Opt(i)}),T=t.Record({controllers:t.Vec(t.Principal)}),d=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),u=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:d,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),_=t.Variant({Db:t.Null,Storage:t.Null}),P=t.Record({version:t.Opt(t.Nat64)}),C=t.Record({proposal_ids:t.Vec(t.Nat)}),F=t.Record({cycles:t.Nat,destination_id:t.Principal}),M=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}),G=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),x=t.Record({key:M,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,G)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),z=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),f=t.Record({internet_identity:t.Opt(z)}),U=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),w=t.Record({max_memory_size:t.Opt(U)}),dt=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),ut=t.Variant({Deny:t.Null,Allow:t.Null}),_t=t.Record({status_code:t.Nat16,location:t.Text}),v=t.Record({iframe:t.Opt(dt),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(U),raw_access:t.Opt(ut),redirects:t.Opt(t.Vec(t.Tuple(t.Text,_t)))}),mt=t.Record({db:t.Opt(w),authentication:t.Opt(f),storage:v}),R=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)}),Ot=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),Nt=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Tt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),$=t.Variant({AssetsUpgrade:Nt,SegmentsDeployment:Tt}),E=t.Record({status:Ot,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:$}),b=t.Variant({Heap:t.Null,Stable:t.Null}),h=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),W=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),V=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:h,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Rt=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.Record({memory:b,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}),yt=t.Variant({Callback:t.Record({token:k,callback:t.Func([],[],["query"])})}),gt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(yt),status_code:t.Nat16}),At=t.Record({token:t.Opt(k),body:t.Vec(t.Nat8)}),Y=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}),X=t.Record({batch_id:t.Nat}),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,x)),items_length:t.Nat64}),ft=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Et=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,R)),items_length:t.Nat64}),ht=t.Record({desc:t.Bool}),St=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Pt=t.Record({order:t.Opt(ht),paginate:t.Opt(St)}),Ct=t.Record({proposal_id:t.Nat}),Ft=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(Ct,E)),items_length:t.Nat64}),Ut=t.Record({include_system:t.Bool}),wt=t.Record({matcher:t.Opt(Ut)}),vt=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,V)),items_length:t.Nat64}),bt=t.Record({stable:t.Nat64,heap:t.Nat64}),Vt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:d,expires_at:t.Opt(t.Nat64)}),kt=t.Record({controller:Vt,controllers:t.Vec(t.Principal)}),Z=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Mt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),max_size:t.Opt(t.Nat),read:h,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Q=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),D=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([o],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,c],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,c],[t.Nat64],["query"]),count_proposals:t.Func([],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([T],[t.Vec(t.Tuple(t.Principal,u))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,c],[],[]),del_filtered_docs:t.Func([t.Text,c],[],[]),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,m))],[],[]),del_rule:t.Func([_,t.Text,P],[],[]),delete_proposal_assets:t.Func([C],[],[]),deposit_cycles:t.Func([F],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(x)],["query"]),get_auth_config:t.Func([],[t.Opt(f)],["query"]),get_config:t.Func([],[mt],[]),get_db_config:t.Func([],[t.Opt(w)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(R)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(x)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(R)))],["query"]),get_proposal:t.Func([t.Nat],[t.Opt(E)],["query"]),get_rule:t.Func([_,t.Text],[t.Opt(V)],["query"]),get_storage_config:t.Func([],[v],["query"]),http_request:t.Func([Rt],[gt],["query"]),http_request_streaming_callback:t.Func([k],[At],["query"]),init_asset_upload:t.Func([Y],[X],[]),init_proposal:t.Func([$],[t.Nat,E],[]),init_proposal_asset_upload:t.Func([Y,t.Nat],[X],[]),list_assets:t.Func([t.Text,c],[xt],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,u))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,ft))],["query"]),list_docs:t.Func([t.Text,c],[Et],["query"]),list_proposals:t.Func([Pt],[Ft],["query"]),list_rules:t.Func([_,wt],[vt],["query"]),memory_size:t.Func([],[bt],["query"]),reject_proposal:t.Func([o],[t.Null],[]),set_auth_config:t.Func([f],[],[]),set_controllers:t.Func([kt],[t.Vec(t.Tuple(t.Principal,u))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([w],[],[]),set_doc:t.Func([t.Text,t.Text,Z],[R],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Z))],[t.Vec(t.Tuple(t.Text,R))],[]),set_rule:t.Func([_,t.Text,Mt],[V],[]),set_storage_config:t.Func([v],[],[]),submit_proposal:t.Func([t.Nat],[t.Nat,E],[]),upload_asset_chunk:t.Func([Q],[D],[]),upload_proposal_asset_chunk:t.Func([Q],[D],[])})};var Zt=({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)}),o=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),s=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:s,desc:t.Bool}),r=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),a=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(r),description:t.Opt(t.Text),created_at:t.Opt(r)}),i=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),c=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(a),paginate:t.Opt(i)}),T=t.Record({controllers:t.Vec(t.Principal)}),d=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),u=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:d,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),_=t.Variant({Db:t.Null,Storage:t.Null}),P=t.Record({version:t.Opt(t.Nat64)}),C=t.Record({proposal_ids:t.Vec(t.Nat)}),F=t.Record({cycles:t.Nat,destination_id:t.Principal}),M=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}),G=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),x=t.Record({key:M,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,G)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),z=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),f=t.Record({internet_identity:t.Opt(z)}),U=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),w=t.Record({max_memory_size:t.Opt(U)}),dt=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),ut=t.Variant({Deny:t.Null,Allow:t.Null}),_t=t.Record({status_code:t.Nat16,location:t.Text}),v=t.Record({iframe:t.Opt(dt),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(U),raw_access:t.Opt(ut),redirects:t.Opt(t.Vec(t.Tuple(t.Text,_t)))}),mt=t.Record({db:t.Opt(w),authentication:t.Opt(f),storage:v}),R=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)}),Ot=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),Nt=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Tt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),$=t.Variant({AssetsUpgrade:Nt,SegmentsDeployment:Tt}),E=t.Record({status:Ot,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:$}),b=t.Variant({Heap:t.Null,Stable:t.Null}),h=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),W=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),V=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:h,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Rt=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.Record({memory:b,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}),yt=t.Variant({Callback:t.Record({token:k,callback:t.Func([],[],[])})}),gt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(yt),status_code:t.Nat16}),At=t.Record({token:t.Opt(k),body:t.Vec(t.Nat8)}),Y=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}),X=t.Record({batch_id:t.Nat}),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,x)),items_length:t.Nat64}),ft=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Et=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,R)),items_length:t.Nat64}),ht=t.Record({desc:t.Bool}),St=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Pt=t.Record({order:t.Opt(ht),paginate:t.Opt(St)}),Ct=t.Record({proposal_id:t.Nat}),Ft=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(Ct,E)),items_length:t.Nat64}),Ut=t.Record({include_system:t.Bool}),wt=t.Record({matcher:t.Opt(Ut)}),vt=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,V)),items_length:t.Nat64}),bt=t.Record({stable:t.Nat64,heap:t.Nat64}),Vt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:d,expires_at:t.Opt(t.Nat64)}),kt=t.Record({controller:Vt,controllers:t.Vec(t.Principal)}),Z=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Mt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),max_size:t.Opt(t.Nat),read:h,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Q=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),D=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([o],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,c],[t.Nat64],[]),count_collection_assets:t.Func([t.Text],[t.Nat64],[]),count_collection_docs:t.Func([t.Text],[t.Nat64],[]),count_docs:t.Func([t.Text,c],[t.Nat64],[]),count_proposals:t.Func([],[t.Nat64],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([T],[t.Vec(t.Tuple(t.Principal,u))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,c],[],[]),del_filtered_docs:t.Func([t.Text,c],[],[]),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,m))],[],[]),del_rule:t.Func([_,t.Text,P],[],[]),delete_proposal_assets:t.Func([C],[],[]),deposit_cycles:t.Func([F],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(x)],[]),get_auth_config:t.Func([],[t.Opt(f)],[]),get_config:t.Func([],[mt],[]),get_db_config:t.Func([],[t.Opt(w)],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(R)],[]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(x)))],[]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(R)))],[]),get_proposal:t.Func([t.Nat],[t.Opt(E)],[]),get_rule:t.Func([_,t.Text],[t.Opt(V)],[]),get_storage_config:t.Func([],[v],[]),http_request:t.Func([Rt],[gt],[]),http_request_streaming_callback:t.Func([k],[At],[]),init_asset_upload:t.Func([Y],[X],[]),init_proposal:t.Func([$],[t.Nat,E],[]),init_proposal_asset_upload:t.Func([Y,t.Nat],[X],[]),list_assets:t.Func([t.Text,c],[xt],[]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,u))],[]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,ft))],[]),list_docs:t.Func([t.Text,c],[Et],[]),list_proposals:t.Func([Pt],[Ft],[]),list_rules:t.Func([_,wt],[vt],[]),memory_size:t.Func([],[bt],[]),reject_proposal:t.Func([o],[t.Null],[]),set_auth_config:t.Func([f],[],[]),set_controllers:t.Func([kt],[t.Vec(t.Tuple(t.Principal,u))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([w],[],[]),set_doc:t.Func([t.Text,t.Text,Z],[R],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Z))],[t.Vec(t.Tuple(t.Text,R))],[]),set_rule:t.Func([_,t.Text,Mt],[V],[]),set_storage_config:t.Func([v],[],[]),submit_proposal:t.Func([t.Nat],[t.Nat,E],[]),upload_asset_chunk:t.Func([Q],[D],[]),upload_proposal_asset_chunk:t.Func([Q],[D],[])})};var p=({satellite:t,options:{certified:e}})=>Ne({idlFactory:e?Zt:Xt,actorKey:`stock#${e?"update":"query"}`,...t}),Oe=({idlFactory:t,...e})=>Ne({idlFactory:t,actorKey:"extended#query",...e}),Ne=async({satelliteId:t,container:e,...o})=>{let{satelliteId:s}=Wt({satelliteId:t});to(s,"No satellite ID defined. Did you initialize Juno?");let{container:n}=Yt({container:e});return await K.getInstance().getActor({satelliteId:s,container:n,...o})};var Te=async({collection:t,key:e,...o})=>{let{get_doc:s}=await p(o),n=H(await s(t,e));if(!eo(n))return I({doc:n,key:e})},Re=async({docs:t,...e})=>{let{get_many_docs:o}=await p(e),s=t.map(({collection:a,key:i})=>[a,i]),n=await o(s),r=[];for(let[a,i]of n){let c=H(i);r.push(oo(c)?await I({key:a,doc:c}):void 0)}return r},ye=async({collection:t,doc:e,...o})=>{let{set_doc:s}=await p(o),{key:n}=e,r=await Gt(e),a=await s(t,n,r);return await I({key:n,doc:a})},ge=async({docs:t,...e})=>{let{set_many_docs:o}=await p(e),s=[];for(let{collection:a,doc:i}of t){let{key:c}=i;s.push([a,c,await Gt(i)])}let n=await o(s),r=[];for(let[a,i]of n)r.push(await I({key:a,doc:i}));return r},Ae=async({collection:t,doc:e,...o})=>{let{del_doc:s}=await p(o),{key:n}=e;return s(t,n,zt(e))},xe=async({docs:t,...e})=>{let{del_many_docs:o}=await p(e),s=t.map(({collection:n,doc:r})=>[n,r.key,zt(r)]);await o(s)},fe=async({collection:t,filter:e,...o})=>{let{del_filtered_docs:s}=await p(o);return s(t,S(e))},Ee=async({collection:t,filter:e,...o})=>{let{list_docs:s}=await p(o),{items:n,items_page:r,items_length:a,matches_length:i,matches_pages:c}=await s(t,S(e)),T=[];for(let[d,u]of n){let{data:m,owner:_,description:P,version:C,...F}=u;T.push({key:d,description:H(P),owner:_.toText(),data:await de({data:m}),version:H(C),...F})}return{items:T,items_length:a,items_page:H(r),matches_length:i,matches_pages:H(c)}},he=async({collection:t,filter:e,...o})=>{let{count_docs:s}=await p(o);return s(t,S(e))};var A={certified:!1};import{AnonymousIdentity as so}from"@dfinity/agent";import{nonNullish as no}from"@dfinity/utils";var l=t=>no(t)?t:ct()??new so;var Se=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await Te({...o,satellite:{...t,identity:s},options:e??A})},$s=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await Re({...o,satellite:{...t,identity:s},options:e??A})},Pe=async({satellite:t,...e})=>{let o=l(t?.identity);return await ye({...e,satellite:{...t,identity:o},options:{certified:!0}})},Ws=async({satellite:t,...e})=>{let o=l(t?.identity);return await ge({...e,satellite:{...t,identity:o},options:{certified:!0}})},Ys=async({satellite:t,...e})=>{let o=l(t?.identity);return await Ae({...e,satellite:{...t,identity:o},options:{certified:!0}})},Xs=async({satellite:t,...e})=>{let o=l(t?.identity);return await xe({...e,satellite:{...t,identity:o},options:{certified:!0}})},Zs=async({satellite:t,filter:e,...o})=>{let s=l(t?.identity);return await fe({...o,filter:e??{},satellite:{...t,identity:s},options:{certified:!0}})},Qs=async({satellite:t,options:e,filter:o,...s})=>{let n=l(t?.identity);return await Ee({...s,filter:o??{},satellite:{...t,identity:n},options:e??A})},Ds=async({satellite:t,options:e,filter:o,...s})=>{let n=l(t?.identity);return await he({...s,filter:o??{},satellite:{...t,identity:n},options:e??A})};var Fe=async t=>{let e=ct();if(ro(e))throw new rt("No identity to initialize the user. Have you initialized Juno?");let o=e.getPrincipal().toText(),s=()=>Se({collection:"#user",key:o}),n=await s();if(Ce(n))return n;try{return await ao({userId:o,provider:t})}catch(r){if(Bt({error:r,type:pe})){let a=await s();if(Ce(a))return a}throw r}},ao=({userId:t,...e})=>Pe({collection:"#user",doc:{key:t,data:e}});var N,Qt=async t=>{if(N=N??await it(),!(await N?.isAuthenticated()??!1))return;let o=await Fe(t);y.getInstance().set(o)},co=t=>new Promise(async(e,o)=>{if(Ue(N)){o(new st("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let s=t?.provider??new et({});await N.login({onSuccess:async()=>{await Qt(s.id),e()},onError:n=>{if(n===io){o(new nt(n));return}o(new ot(n))},maxTimeToLive:t?.maxTimeToLive??It,allowPinAuthentication:t?.allowPin??Lt,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...s.signInOptions({windowed:t?.windowed})})}),Dt=async()=>{await lo(),N=await it()},lo=async()=>{await N?.logout(),N=null,y.getInstance().reset(),K.getInstance().reset(),q.getInstance().reset()},ct=()=>N?.getIdentity(),po=async()=>(N??await it()).getIdentity(),uo=async()=>{let t=y.getInstance().get();return Ue(t)||!(await N?.isAuthenticated()??!1)?null:N?.getIdentity()??null};var we=t=>{let e=t===!0?"./workers/auth.worker.js":t,o=new Worker(e),s=async()=>{jt({message:"junoSignOutAuthTimer"}),await Dt()};return o.onmessage=async({data:n})=>{let{msg:r,data:a}=n;switch(r){case"junoSignOutAuthTimer":await s();return;case"junoDelegationRemainingTime":jt({message:"junoDelegationRemainingTime",detail:a?.authRemainingTime});return}},y.getInstance().subscribe(n=>{if(_o(n)){o.postMessage({msg:"junoStopAuthTimer"});return}o.postMessage({msg:"junoStartAuthTimer"})})};var ve=()=>{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()},be=()=>{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 hn=async({idlFactory:t,satellite:e})=>{let o=l(e?.identity);return await Oe({idlFactory:t,...e,identity:o})};import{fromNullable as ze,nonNullish as yo}from"@dfinity/utils";import{fromNullable as pt}from"@dfinity/utils";import{toNullable as lt}from"@dfinity/utils";var Ve=async({asset:{data:t,headers:e,...o},actor:s})=>{let{init_asset_upload:n,upload_asset_chunk:r,commit_asset_upload:a}=s,{batch_id:i}=await n(mo(o)),{chunkIds:c}=await No({data:t,uploadFn:r,batchId:i});await Oo({commitFn:a,batchId:i,data:t,headers:e,chunkIds:c})};var mo=({filename:t,collection:e,token:o,fullPath:s,encoding:n,description:r})=>({collection:e,full_path:s,name:t,token:lt(o),encoding_type:lt(n),description:lt(r)}),Oo=async({commitFn:t,batchId:e,chunkIds:o,headers:s,data:n})=>{let r=s.find(([a,i])=>a.toLowerCase()==="content-type")===void 0&&n.type!==void 0&&n.type!==""?[["Content-Type",n.type]]:void 0;await t({batch_id:e,chunk_ids:o.map(({chunk_id:a})=>a),headers:[...s,...r??[]]})},No=async({data:t,uploadFn:e,batchId:o})=>{let s=[],n=tt()?new Blob([await t.arrayBuffer()]):t,r=0n;for(let i=0;i<n.size;i+=19e5){let c=n.slice(i,i+19e5);s.push({batchId:o,chunk:c,uploadFn:e,orderId:r}),r++}let a=[];for await(let i of To({uploadChunks:s}))a=[...a,...i];return{chunkIds:a}};async function*To({uploadChunks:t,limit:e=12}){for(let o=0;o<t.length;o=o+e){let s=t.slice(o,o+e);yield await Promise.all(s.map(n=>Ro(n)))}}var Ro=async({batchId:t,chunk:e,uploadFn:o,orderId:s})=>o({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:lt(s)});var ke=async({asset:t,...e})=>{let o=await p(e);await Ve({actor:o,asset:t})},Me=async({collection:t,filter:e,...o})=>{let{list_assets:s}=await p(o),{items:n,items_length:r,items_page:a,matches_length:i,matches_pages:c}=await s(t,S(e));return{items:n.map(([T,d])=>d),items_length:r,items_page:pt(a),matches_length:i,matches_pages:pt(c)}},je=async({collection:t,filter:e,...o})=>{let{count_assets:s}=await p(o);return s(t,S(e))},Je=async({collection:t,fullPath:e,...o})=>(await p(o)).del_asset(t,e),qe=async({assets:t,satellite:e})=>{let{del_many_assets:o}=await p({satellite:e,options:{certified:!0}}),s=t.map(({collection:n,fullPath:r})=>[n,r]);await o(s)},Ke=async({collection:t,filter:e,...o})=>{let{del_filtered_assets:s}=await p(o);return s(t,S(e))},Be=async({collection:t,fullPath:e,...o})=>{let{get_asset:s}=await p(o);return pt(await s(t,e))},He=async({assets:t,...e})=>{let{get_many_assets:o}=await p(e),s=t.map(({collection:r,fullPath:a})=>[r,a]);return(await o(s)).map(([r,a])=>pt(a))};var Ge=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Hn=t=>$e(t),Gn=t=>$e({filename:t.data.name,...t}),$e=async({filename:t,data:e,collection:o,headers:s=[],fullPath:n,token:r,satellite:a,encoding:i,description:c})=>{let T=l(a?.identity),d=decodeURI(t),u=n??`/${o}/${d}`,m={...a,identity:T};return await ke({asset:{data:e,filename:d,collection:o,token:r,headers:s,fullPath:u,encoding:i,description:c},satellite:m,options:{certified:!0}}),{downloadUrl:We({satellite:m,assetKey:{fullPath:u,token:r}}),fullPath:u,name:d}},zn=async({collection:t,filter:e,satellite:o,options:s})=>{let n={...o,identity:l(o?.identity)},{items:r,...a}=await Me({collection:t,filter:e??{},satellite:n,options:s??A}),i=r.map(({key:{full_path:c,token:T,name:d,owner:u,description:m},headers:_,encodings:P,created_at:C,updated_at:F})=>{let M=ze(T);return{fullPath:c,description:ze(m),name:d,downloadUrl:We({satellite:n,assetKey:{fullPath:c,token:M}}),token:M,headers:_,encodings:P.reduce((G,[x,{modified:z,sha256:f,total_length:U}])=>({...G,[x]:{modified:z,sha256:Ge(f),total_length:U}}),{}),owner:u.toText(),created_at:C,updated_at:F}});return{items:i,assets:i,...a}},$n=async({collection:t,filter:e,satellite:o,options:s})=>{let n={...o,identity:l(o?.identity)};return await je({collection:t,satellite:n,filter:e??{},options:s??A})},Wn=({collection:t,fullPath:e,satellite:o})=>Je({collection:t,fullPath:e,satellite:{...o,identity:l(o?.identity)},options:{certified:!0}}),Yn=({assets:t,satellite:e})=>qe({assets:t,satellite:{...e,identity:l(e?.identity)},options:{certified:!0}}),Xn=async({collection:t,satellite:e,filter:o})=>{let s={...e,identity:l(e?.identity)};return await Ke({collection:t,satellite:s,filter:o??{},options:{certified:!0}})},Zn=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await Be({...o,satellite:{...t,identity:s},options:e??A})},Qn=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await He({...o,satellite:{...t,identity:s},options:e??A})},We=({assetKey:{fullPath:t,token:e},satellite:o})=>{let s={...o,identity:l(o?.identity)};return`${me(s)}${t}${yo(e)?`?token=${e}`:""}`};var Ao=t=>{let e=t?.satelliteId??ve();go(e,"Satellite ID is not configured. Juno cannot be initialized.");let o=t?.container??be();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:o}},nr=t=>xo(t),xo=async t=>{let e=Ao(t);g.getInstance().set(e),await Qt();let o=e.workers?.auth!==void 0?we(e.workers.auth):void 0;return[...o?[o]:[]]},rr=t=>y.getInstance().subscribe(t);export{rt as InitError,et as InternetIdentityProvider,at as ListError,ie as NFIDProvider,ot as SignInError,st as SignInInitError,nt as SignInUserInterruptError,rr as authSubscribe,$n as countAssets,Ds as countDocs,Wn as deleteAsset,Ys as deleteDoc,Xn as deleteFilteredAssets,Zs as deleteFilteredDocs,Yn as deleteManyAssets,Xs as deleteManyDocs,We as downloadUrl,Zn as getAsset,Se as getDoc,uo as getIdentityOnce,Qn as getManyAssets,$s as getManyDocs,hn as getSatelliteExtendedActor,nr as initJuno,xo as initSatellite,zn as listAssets,Qs as listDocs,Pe as setDoc,Ws as setManyDocs,co as signIn,Dt as signOut,po as unsafeIdentity,Hn as uploadBlob,Gn as uploadFile};
|
|
3
|
+
import{assertNonNullish as go}from"@dfinity/utils";import{isNullish as _o}from"@dfinity/utils";var j=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:o})=>o(e))}subscribe(e){let o=Symbol();return this.callbacks.push({id:o,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:s})=>s!==o)}};var y=class t extends j{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 o=super.subscribe(e);return e(this.authUser),o}reset(){this.authUser=null,this.populate(this.authUser)}};var jt=({message:t,detail:e})=>{let o=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(o)};import{ERROR_USER_INTERRUPT as io}from"@dfinity/auth-client";import{isNullish as Ue}from"@dfinity/utils";var It=BigInt(144e11),Lt=!1,te={width:576,height:576},ee={width:505,height:705},oe="internetcomputer.org";import{isNullish as Ze,nonNullish as ae}from"@dfinity/utils";var J="http://127.0.0.1:5987",se="rdmx6-jaaaa-aaaaa-aaadq-cai";var g=class t extends j{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}reset(){this.env=null}subscribe(e){let o=super.subscribe(e);return e(this.env),o}};import{isNullish as re}from"@dfinity/utils";import{jsonReplacer as Ye,jsonReviver as Xe}from"@dfinity/utils";var ne=async t=>{let e=new Blob([JSON.stringify(t,Ye)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},L=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(),Xe)},tt=()=>typeof window<"u";var Jt=({width:t,height:e})=>{if(!tt()||re(window)||re(window.top))return;let{top:{innerWidth:o,innerHeight:s}}=window,n=s/2+screenY-e/2,r=o/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=${r}`};var et=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let o=()=>{let s=g.getInstance().get()?.container;if(Ze(s)||s===!1)return`https://identity.${this.#t??oe}`;let n=g.getInstance().get(),r=ae(n)&&ae(n?.internetIdentityId)?n.internetIdentityId:se,{host:a,protocol:i}=new URL(s===!0?J:s);return/apple/i.test(navigator?.vendor)?`${i}//${a}?canisterId=${r}`:`${i}//${r}.${a.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Jt(te)},identityProvider:o()}}},ie=class{#t;#e;constructor({appName:e,logoUrl:o}){this.#t=e,this.#e=o}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:Jt(ee)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};import{Actor as De}from"@dfinity/agent";import{isNullish as Kt}from"@dfinity/utils";import{isNullish as qt}from"@dfinity/utils";import{HttpAgent as Qe}from"@dfinity/agent";import{nonNullish as ce}from"@dfinity/utils";var le=async({identity:t,container:e})=>{let s=ce(e)&&e!==!1?e===!0?J:e:"https://icp-api.io",n=ce(e);return await Qe.create({identity:t,shouldFetchRootKey:n,host:s})};var q=class t{static instance;#t=void 0;constructor(){}static getInstance(){return qt(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...o}){let s=e.getPrincipal().toText();if(qt(this.#t)||qt(this.#t[s])){let n=await le({identity:e,...o});return this.#t={...this.#t??{},[s]:n},n}return this.#t[s]}reset(){this.#t=null}};var K=class t{static instance;#t=void 0;constructor(){}static getInstance(){return Kt(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:o,actorKey:s,...n}){let r=`${s}#${o.getPrincipal().toText()}#${e};`;if(Kt(this.#t)||Kt(this.#t[r])){let a=await this.createActor({satelliteId:e,identity:o,...n});return this.#t={...this.#t??{},[r]:a},a}return this.#t[r]}reset(){this.#t=null}async createActor({idlFactory:e,satelliteId:o,...s}){let n=await q.getInstance().getAgent(s);return De.createActor(e,{agent:n,canisterId:o})}};var ot=class extends Error{},st=class extends Error{},nt=class extends Error{},rt=class extends Error{},at=class extends Error{};import{AuthClient as Ie}from"@dfinity/auth-client";var it=()=>Ie.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});import{isNullish as ro,nonNullish as Ce}from"@dfinity/utils";var Bt=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var pe="juno.datastore.error.user.cannot_update";import{fromNullable as H,isNullish as eo,nonNullish as oo}from"@dfinity/utils";var de=async({data:t})=>{try{return await L(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};import{fromNullable as ue,toNullable as Ht}from"@dfinity/utils";var Gt=async t=>{let{data:e,version:o,description:s}=t;return{description:Ht(s),data:await ne(e),version:Ht(o)}},zt=t=>{let{version:e}=t;return{version:Ht(e)}},I=async({doc:t,key:e})=>{let{owner:o,version:s,description:n,data:r,...a}=t;return{key:e,description:ue(n),owner:o.toText(),data:await L(r),version:ue(s),...a}};import{Principal as Le}from"@dfinity/principal";import{isNullish as B,toNullable as O}from"@dfinity/utils";var _e=t=>{if(B(t))return O();switch(t.matcher){case"equal":return O({Equal:t.timestamp});case"greaterThan":return O({GreaterThan:t.timestamp});case"lessThan":return O({LessThan:t.timestamp});case"between":return O({Between:[t.timestamps.start,t.timestamps.end]});default:throw new at("Invalid list matcher for timestamp",t)}},S=({matcher:t,paginate:e,order:o,owner:s})=>({matcher:B(t)?[]:[{key:O(t.key),description:O(t.description),created_at:_e(t.createdAt),updated_at:_e(t.updatedAt)}],paginate:O(B(e)?void 0:{start_after:O(e.startAfter),limit:O(B(e.limit)?void 0:BigInt(e.limit))}),order:O(B(o)?void 0:{desc:o.desc,field:o.field==="created_at"?{CreatedAt:null}:o.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:O(B(s)?void 0:typeof s=="string"?Le.fromText(s):s)});import{assertNonNullish as to}from"@dfinity/utils";import{nonNullish as $t}from"@dfinity/utils";var me=({satelliteId:t,container:e})=>{let{satelliteId:o}=Wt({satelliteId:t}),{container:s}=Yt({container:e});if($t(s)&&s!==!1){let{host:n,protocol:r}=new URL(s===!0?J:s);return`${r}//${o??"unknown"}.${n.replace("127.0.0.1","localhost")}`}return`https://${o??"unknown"}.icp0.io`},Wt=({satelliteId:t})=>$t(t)?{satelliteId:t}:g.getInstance().get()??{satelliteId:void 0},Yt=({container:t})=>$t(t)?{container:t}:g.getInstance().get()??{container:void 0};var Xt=({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)}),o=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),s=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:s,desc:t.Bool}),r=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),a=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(r),description:t.Opt(t.Text),created_at:t.Opt(r)}),i=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),c=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(a),paginate:t.Opt(i)}),R=t.Record({controllers:t.Vec(t.Principal)}),d=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),u=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:d,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),_=t.Variant({Db:t.Null,Storage:t.Null}),P=t.Record({version:t.Opt(t.Nat64)}),C=t.Record({proposal_ids:t.Vec(t.Nat)}),F=t.Record({cycles:t.Nat,destination_id:t.Principal}),M=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}),G=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),x=t.Record({key:M,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,G)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),z=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),f=t.Record({internet_identity:t.Opt(z)}),U=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),w=t.Record({max_memory_size:t.Opt(U)}),dt=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),ut=t.Variant({Deny:t.Null,Allow:t.Null}),_t=t.Record({status_code:t.Nat16,location:t.Text}),v=t.Record({iframe:t.Opt(dt),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(U),raw_access:t.Opt(ut),redirects:t.Opt(t.Vec(t.Tuple(t.Text,_t)))}),mt=t.Record({db:t.Opt(w),authentication:t.Opt(f),storage:v}),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)}),Ot=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),Nt=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Rt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),$=t.Variant({AssetsUpgrade:Nt,SegmentsDeployment:Rt}),E=t.Record({status:Ot,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:$}),b=t.Variant({Heap:t.Null,Stable:t.Null}),h=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),W=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),V=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:h,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Tt=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.Record({memory:b,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}),yt=t.Variant({Callback:t.Record({token:k,callback:t.Func([],[],["query"])})}),gt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(yt),status_code:t.Nat16}),At=t.Record({token:t.Opt(k),body:t.Vec(t.Nat8)}),Y=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}),X=t.Record({batch_id:t.Nat}),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,x)),items_length:t.Nat64}),ft=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Et=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}),ht=t.Record({desc:t.Bool}),St=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Pt=t.Record({order:t.Opt(ht),paginate:t.Opt(St)}),Ct=t.Record({proposal_id:t.Nat}),Ft=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(Ct,E)),items_length:t.Nat64}),Ut=t.Record({include_system:t.Bool}),wt=t.Record({matcher:t.Opt(Ut)}),vt=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,V)),items_length:t.Nat64}),bt=t.Record({stable:t.Nat64,heap:t.Nat64}),Vt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:d,expires_at:t.Opt(t.Nat64)}),kt=t.Record({controller:Vt,controllers:t.Vec(t.Principal)}),Z=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Mt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),max_size:t.Opt(t.Nat),read:h,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Q=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),D=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([o],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,c],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,c],[t.Nat64],["query"]),count_proposals:t.Func([],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([R],[t.Vec(t.Tuple(t.Principal,u))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,c],[],[]),del_filtered_docs:t.Func([t.Text,c],[],[]),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,m))],[],[]),del_rule:t.Func([_,t.Text,P],[],[]),delete_proposal_assets:t.Func([C],[],[]),deposit_cycles:t.Func([F],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(x)],["query"]),get_auth_config:t.Func([],[t.Opt(f)],["query"]),get_config:t.Func([],[mt],[]),get_db_config:t.Func([],[t.Opt(w)],["query"]),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(x)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(T)))],["query"]),get_proposal:t.Func([t.Nat],[t.Opt(E)],["query"]),get_rule:t.Func([_,t.Text],[t.Opt(V)],["query"]),get_storage_config:t.Func([],[v],["query"]),http_request:t.Func([Tt],[gt],["query"]),http_request_streaming_callback:t.Func([k],[At],["query"]),init_asset_upload:t.Func([Y],[X],[]),init_proposal:t.Func([$],[t.Nat,E],[]),init_proposal_asset_upload:t.Func([Y,t.Nat],[X],[]),list_assets:t.Func([t.Text,c],[xt],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,u))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,ft))],["query"]),list_docs:t.Func([t.Text,c],[Et],["query"]),list_proposals:t.Func([Pt],[Ft],["query"]),list_rules:t.Func([_,wt],[vt],["query"]),memory_size:t.Func([],[bt],["query"]),reject_proposal:t.Func([o],[t.Null],[]),set_auth_config:t.Func([f],[],[]),set_controllers:t.Func([kt],[t.Vec(t.Tuple(t.Principal,u))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([w],[],[]),set_doc:t.Func([t.Text,t.Text,Z],[T],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Z))],[t.Vec(t.Tuple(t.Text,T))],[]),set_rule:t.Func([_,t.Text,Mt],[V],[]),set_storage_config:t.Func([v],[],[]),submit_proposal:t.Func([t.Nat],[t.Nat,E],[]),upload_asset_chunk:t.Func([Q],[D],[]),upload_proposal_asset_chunk:t.Func([Q],[D],[])})};var Zt=({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)}),o=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),s=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:s,desc:t.Bool}),r=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),a=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(r),description:t.Opt(t.Text),created_at:t.Opt(r)}),i=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),c=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(a),paginate:t.Opt(i)}),R=t.Record({controllers:t.Vec(t.Principal)}),d=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),u=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:d,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),_=t.Variant({Db:t.Null,Storage:t.Null}),P=t.Record({version:t.Opt(t.Nat64)}),C=t.Record({proposal_ids:t.Vec(t.Nat)}),F=t.Record({cycles:t.Nat,destination_id:t.Principal}),M=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}),G=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),x=t.Record({key:M,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,G)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),z=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),f=t.Record({internet_identity:t.Opt(z)}),U=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),w=t.Record({max_memory_size:t.Opt(U)}),dt=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),ut=t.Variant({Deny:t.Null,Allow:t.Null}),_t=t.Record({status_code:t.Nat16,location:t.Text}),v=t.Record({iframe:t.Opt(dt),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(U),raw_access:t.Opt(ut),redirects:t.Opt(t.Vec(t.Tuple(t.Text,_t)))}),mt=t.Record({db:t.Opt(w),authentication:t.Opt(f),storage:v}),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)}),Ot=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),Nt=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Rt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),$=t.Variant({AssetsUpgrade:Nt,SegmentsDeployment:Rt}),E=t.Record({status:Ot,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:$}),b=t.Variant({Heap:t.Null,Stable:t.Null}),h=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),W=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),V=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:h,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Tt=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.Record({memory:b,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}),yt=t.Variant({Callback:t.Record({token:k,callback:t.Func([],[],[])})}),gt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(yt),status_code:t.Nat16}),At=t.Record({token:t.Opt(k),body:t.Vec(t.Nat8)}),Y=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}),X=t.Record({batch_id:t.Nat}),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,x)),items_length:t.Nat64}),ft=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Et=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}),ht=t.Record({desc:t.Bool}),St=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Pt=t.Record({order:t.Opt(ht),paginate:t.Opt(St)}),Ct=t.Record({proposal_id:t.Nat}),Ft=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(Ct,E)),items_length:t.Nat64}),Ut=t.Record({include_system:t.Bool}),wt=t.Record({matcher:t.Opt(Ut)}),vt=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,V)),items_length:t.Nat64}),bt=t.Record({stable:t.Nat64,heap:t.Nat64}),Vt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:d,expires_at:t.Opt(t.Nat64)}),kt=t.Record({controller:Vt,controllers:t.Vec(t.Principal)}),Z=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Mt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),max_size:t.Opt(t.Nat),read:h,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Q=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),D=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([o],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,c],[t.Nat64],[]),count_collection_assets:t.Func([t.Text],[t.Nat64],[]),count_collection_docs:t.Func([t.Text],[t.Nat64],[]),count_docs:t.Func([t.Text,c],[t.Nat64],[]),count_proposals:t.Func([],[t.Nat64],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([R],[t.Vec(t.Tuple(t.Principal,u))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,c],[],[]),del_filtered_docs:t.Func([t.Text,c],[],[]),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,m))],[],[]),del_rule:t.Func([_,t.Text,P],[],[]),delete_proposal_assets:t.Func([C],[],[]),deposit_cycles:t.Func([F],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(x)],[]),get_auth_config:t.Func([],[t.Opt(f)],[]),get_config:t.Func([],[mt],[]),get_db_config:t.Func([],[t.Opt(w)],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(T)],[]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(x)))],[]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(T)))],[]),get_proposal:t.Func([t.Nat],[t.Opt(E)],[]),get_rule:t.Func([_,t.Text],[t.Opt(V)],[]),get_storage_config:t.Func([],[v],[]),http_request:t.Func([Tt],[gt],[]),http_request_streaming_callback:t.Func([k],[At],[]),init_asset_upload:t.Func([Y],[X],[]),init_proposal:t.Func([$],[t.Nat,E],[]),init_proposal_asset_upload:t.Func([Y,t.Nat],[X],[]),list_assets:t.Func([t.Text,c],[xt],[]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,u))],[]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,ft))],[]),list_docs:t.Func([t.Text,c],[Et],[]),list_proposals:t.Func([Pt],[Ft],[]),list_rules:t.Func([_,wt],[vt],[]),memory_size:t.Func([],[bt],[]),reject_proposal:t.Func([o],[t.Null],[]),set_auth_config:t.Func([f],[],[]),set_controllers:t.Func([kt],[t.Vec(t.Tuple(t.Principal,u))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([w],[],[]),set_doc:t.Func([t.Text,t.Text,Z],[T],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Z))],[t.Vec(t.Tuple(t.Text,T))],[]),set_rule:t.Func([_,t.Text,Mt],[V],[]),set_storage_config:t.Func([v],[],[]),submit_proposal:t.Func([t.Nat],[t.Nat,E],[]),upload_asset_chunk:t.Func([Q],[D],[]),upload_proposal_asset_chunk:t.Func([Q],[D],[])})};var p=({satellite:t,options:{certified:e}})=>Ne({idlFactory:e?Zt:Xt,actorKey:`stock#${e?"update":"query"}`,...t}),Oe=({idlFactory:t,...e})=>Ne({idlFactory:t,actorKey:"extended#query",...e}),Ne=async({satelliteId:t,container:e,...o})=>{let{satelliteId:s}=Wt({satelliteId:t});to(s,"No satellite ID defined. Did you initialize Juno?");let{container:n}=Yt({container:e});return await K.getInstance().getActor({satelliteId:s,container:n,...o})};var Re=async({collection:t,key:e,...o})=>{let{get_doc:s}=await p(o),n=H(await s(t,e));if(!eo(n))return I({doc:n,key:e})},Te=async({docs:t,...e})=>{let{get_many_docs:o}=await p(e),s=t.map(({collection:a,key:i})=>[a,i]),n=await o(s),r=[];for(let[a,i]of n){let c=H(i);r.push(oo(c)?await I({key:a,doc:c}):void 0)}return r},ye=async({collection:t,doc:e,...o})=>{let{set_doc:s}=await p(o),{key:n}=e,r=await Gt(e),a=await s(t,n,r);return await I({key:n,doc:a})},ge=async({docs:t,...e})=>{let{set_many_docs:o}=await p(e),s=[];for(let{collection:a,doc:i}of t){let{key:c}=i;s.push([a,c,await Gt(i)])}let n=await o(s),r=[];for(let[a,i]of n)r.push(await I({key:a,doc:i}));return r},Ae=async({collection:t,doc:e,...o})=>{let{del_doc:s}=await p(o),{key:n}=e;return s(t,n,zt(e))},xe=async({docs:t,...e})=>{let{del_many_docs:o}=await p(e),s=t.map(({collection:n,doc:r})=>[n,r.key,zt(r)]);await o(s)},fe=async({collection:t,filter:e,...o})=>{let{del_filtered_docs:s}=await p(o);return s(t,S(e))},Ee=async({collection:t,filter:e,...o})=>{let{list_docs:s}=await p(o),{items:n,items_page:r,items_length:a,matches_length:i,matches_pages:c}=await s(t,S(e)),R=[];for(let[d,u]of n){let{data:m,owner:_,description:P,version:C,...F}=u;R.push({key:d,description:H(P),owner:_.toText(),data:await de({data:m}),version:H(C),...F})}return{items:R,items_length:a,items_page:H(r),matches_length:i,matches_pages:H(c)}},he=async({collection:t,filter:e,...o})=>{let{count_docs:s}=await p(o);return s(t,S(e))};var A={certified:!1};import{AnonymousIdentity as so}from"@dfinity/agent";import{nonNullish as no}from"@dfinity/utils";var l=t=>no(t)?t:ct()??new so;var Se=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await Re({...o,satellite:{...t,identity:s},options:e??A})},$s=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await Te({...o,satellite:{...t,identity:s},options:e??A})},Pe=async({satellite:t,...e})=>{let o=l(t?.identity);return await ye({...e,satellite:{...t,identity:o},options:{certified:!0}})},Ws=async({satellite:t,...e})=>{let o=l(t?.identity);return await ge({...e,satellite:{...t,identity:o},options:{certified:!0}})},Ys=async({satellite:t,...e})=>{let o=l(t?.identity);return await Ae({...e,satellite:{...t,identity:o},options:{certified:!0}})},Xs=async({satellite:t,...e})=>{let o=l(t?.identity);return await xe({...e,satellite:{...t,identity:o},options:{certified:!0}})},Zs=async({satellite:t,filter:e,...o})=>{let s=l(t?.identity);return await fe({...o,filter:e??{},satellite:{...t,identity:s},options:{certified:!0}})},Qs=async({satellite:t,options:e,filter:o,...s})=>{let n=l(t?.identity);return await Ee({...s,filter:o??{},satellite:{...t,identity:n},options:e??A})},Ds=async({satellite:t,options:e,filter:o,...s})=>{let n=l(t?.identity);return await he({...s,filter:o??{},satellite:{...t,identity:n},options:e??A})};var Fe=async t=>{let e=ct();if(ro(e))throw new rt("No identity to initialize the user. Have you initialized Juno?");let o=e.getPrincipal().toText(),s=()=>Se({collection:"#user",key:o}),n=await s();if(Ce(n))return n;try{return await ao({userId:o,provider:t})}catch(r){if(Bt({error:r,type:pe})){let a=await s();if(Ce(a))return a}throw r}},ao=({userId:t,...e})=>Pe({collection:"#user",doc:{key:t,data:e}});var N,Qt=async t=>{if(N=N??await it(),!(await N?.isAuthenticated()??!1))return;let o=await Fe(t);y.getInstance().set(o)},co=t=>new Promise(async(e,o)=>{if(Ue(N)){o(new st("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let s=t?.provider??new et({});await N.login({onSuccess:async()=>{await Qt(s.id),e()},onError:n=>{if(n===io){o(new nt(n));return}o(new ot(n))},maxTimeToLive:t?.maxTimeToLive??It,allowPinAuthentication:t?.allowPin??Lt,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...s.signInOptions({windowed:t?.windowed})})}),Dt=async()=>{await lo(),N=await it()},lo=async()=>{await N?.logout(),N=null,y.getInstance().reset(),K.getInstance().reset(),q.getInstance().reset()},ct=()=>N?.getIdentity(),po=async()=>(N??await it()).getIdentity(),uo=async()=>{let t=y.getInstance().get();return Ue(t)||!(await N?.isAuthenticated()??!1)?null:N?.getIdentity()??null};var we=t=>{let e=t===!0?"./workers/auth.worker.js":t,o=new Worker(e),s=async()=>{jt({message:"junoSignOutAuthTimer"}),await Dt()};return o.onmessage=async({data:n})=>{let{msg:r,data:a}=n;switch(r){case"junoSignOutAuthTimer":await s();return;case"junoDelegationRemainingTime":jt({message:"junoDelegationRemainingTime",detail:a?.authRemainingTime});return}},y.getInstance().subscribe(n=>{if(_o(n)){o.postMessage({msg:"junoStopAuthTimer"});return}o.postMessage({msg:"junoStartAuthTimer"})})};var ve=()=>{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()},be=()=>{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 hn=async({idlFactory:t,satellite:e})=>{let o=l(e?.identity);return await Oe({idlFactory:t,...e,identity:o})};import{fromNullable as ze,nonNullish as yo}from"@dfinity/utils";import{fromNullable as pt}from"@dfinity/utils";import{toNullable as lt}from"@dfinity/utils";var Ve=async({asset:{data:t,headers:e,...o},actor:s})=>{let{init_asset_upload:n,upload_asset_chunk:r,commit_asset_upload:a}=s,{batch_id:i}=await n(mo(o)),{chunkIds:c}=await No({data:t,uploadFn:r,batchId:i});await Oo({commitFn:a,batchId:i,data:t,headers:e,chunkIds:c})};var mo=({filename:t,collection:e,token:o,fullPath:s,encoding:n,description:r})=>({collection:e,full_path:s,name:t,token:lt(o),encoding_type:lt(n),description:lt(r)}),Oo=async({commitFn:t,batchId:e,chunkIds:o,headers:s,data:n})=>{let r=s.find(([a,i])=>a.toLowerCase()==="content-type")===void 0&&n.type!==void 0&&n.type!==""?[["Content-Type",n.type]]:void 0;await t({batch_id:e,chunk_ids:o.map(({chunk_id:a})=>a),headers:[...s,...r??[]]})},No=async({data:t,uploadFn:e,batchId:o})=>{let s=[],n=tt()?new Blob([await t.arrayBuffer()]):t,r=0n;for(let i=0;i<n.size;i+=19e5){let c=n.slice(i,i+19e5);s.push({batchId:o,chunk:c,uploadFn:e,orderId:r}),r++}let a=[];for await(let i of Ro({uploadChunks:s}))a=[...a,...i];return{chunkIds:a}};async function*Ro({uploadChunks:t,limit:e=12}){for(let o=0;o<t.length;o=o+e){let s=t.slice(o,o+e);yield await Promise.all(s.map(n=>To(n)))}}var To=async({batchId:t,chunk:e,uploadFn:o,orderId:s})=>o({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:lt(s)});var ke=async({asset:t,...e})=>{let o=await p(e);await Ve({actor:o,asset:t})},Me=async({collection:t,filter:e,...o})=>{let{list_assets:s}=await p(o),{items:n,items_length:r,items_page:a,matches_length:i,matches_pages:c}=await s(t,S(e));return{items:n.map(([R,d])=>d),items_length:r,items_page:pt(a),matches_length:i,matches_pages:pt(c)}},je=async({collection:t,filter:e,...o})=>{let{count_assets:s}=await p(o);return s(t,S(e))},Je=async({collection:t,fullPath:e,...o})=>(await p(o)).del_asset(t,e),qe=async({assets:t,satellite:e})=>{let{del_many_assets:o}=await p({satellite:e,options:{certified:!0}}),s=t.map(({collection:n,fullPath:r})=>[n,r]);await o(s)},Ke=async({collection:t,filter:e,...o})=>{let{del_filtered_assets:s}=await p(o);return s(t,S(e))},Be=async({collection:t,fullPath:e,...o})=>{let{get_asset:s}=await p(o);return pt(await s(t,e))},He=async({assets:t,...e})=>{let{get_many_assets:o}=await p(e),s=t.map(({collection:r,fullPath:a})=>[r,a]);return(await o(s)).map(([r,a])=>pt(a))};var Ge=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Hn=t=>$e(t),Gn=t=>$e({filename:t.data.name,...t}),$e=async({filename:t,data:e,collection:o,headers:s=[],fullPath:n,token:r,satellite:a,encoding:i,description:c})=>{let R=l(a?.identity),d=decodeURI(t),u=n??`/${o}/${d}`,m={...a,identity:R};return await ke({asset:{data:e,filename:d,collection:o,token:r,headers:s,fullPath:u,encoding:i,description:c},satellite:m,options:{certified:!0}}),{downloadUrl:We({satellite:m,assetKey:{fullPath:u,token:r}}),fullPath:u,name:d}},zn=async({collection:t,filter:e,satellite:o,options:s})=>{let n={...o,identity:l(o?.identity)},{items:r,...a}=await Me({collection:t,filter:e??{},satellite:n,options:s??A}),i=r.map(({key:{full_path:c,token:R,name:d,owner:u,description:m},headers:_,encodings:P,created_at:C,updated_at:F})=>{let M=ze(R);return{fullPath:c,description:ze(m),name:d,downloadUrl:We({satellite:n,assetKey:{fullPath:c,token:M}}),token:M,headers:_,encodings:P.reduce((G,[x,{modified:z,sha256:f,total_length:U}])=>({...G,[x]:{modified:z,sha256:Ge(f),total_length:U}}),{}),owner:u.toText(),created_at:C,updated_at:F}});return{items:i,assets:i,...a}},$n=async({collection:t,filter:e,satellite:o,options:s})=>{let n={...o,identity:l(o?.identity)};return await je({collection:t,satellite:n,filter:e??{},options:s??A})},Wn=({collection:t,fullPath:e,satellite:o})=>Je({collection:t,fullPath:e,satellite:{...o,identity:l(o?.identity)},options:{certified:!0}}),Yn=({assets:t,satellite:e})=>qe({assets:t,satellite:{...e,identity:l(e?.identity)},options:{certified:!0}}),Xn=async({collection:t,satellite:e,filter:o})=>{let s={...e,identity:l(e?.identity)};return await Ke({collection:t,satellite:s,filter:o??{},options:{certified:!0}})},Zn=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await Be({...o,satellite:{...t,identity:s},options:e??A})},Qn=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await He({...o,satellite:{...t,identity:s},options:e??A})},We=({assetKey:{fullPath:t,token:e},satellite:o})=>{let s={...o,identity:l(o?.identity)};return`${me(s)}${t}${yo(e)?`?token=${e}`:""}`};var Ao=t=>{let e=t?.satelliteId??ve();go(e,"Satellite ID is not configured. Juno cannot be initialized.");let o=t?.container??be();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:o}},nr=t=>xo(t),xo=async t=>{let e=Ao(t);g.getInstance().set(e),await Qt();let o=e.workers?.auth!==void 0?we(e.workers.auth):void 0;return[...o?[o]:[]]},rr=t=>y.getInstance().subscribe(t);export{rt as InitError,et as InternetIdentityProvider,at as ListError,ie as NFIDProvider,ot as SignInError,st as SignInInitError,nt as SignInUserInterruptError,rr as authSubscribe,$n as countAssets,Ds as countDocs,Wn as deleteAsset,Ys as deleteDoc,Xn as deleteFilteredAssets,Zs as deleteFilteredDocs,Yn as deleteManyAssets,Xs as deleteManyDocs,We as downloadUrl,Zn as getAsset,Se as getDoc,uo as getIdentityOnce,Qn as getManyAssets,$s as getManyDocs,hn as getSatelliteExtendedActor,nr as initJuno,xo as initSatellite,zn as listAssets,Qs as listDocs,Pe as setDoc,Ws as setManyDocs,co as signIn,Dt as signOut,po as unsafeIdentity,Hn as uploadBlob,Gn as uploadFile};
|
|
4
4
|
//# sourceMappingURL=index.mjs.map
|