@junobuild/core-peer 0.1.11 → 0.1.13
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/declarations/satellite/satellite.did.d.ts +0 -7
- package/dist/declarations/satellite/satellite.factory.certified.did.js +1 -5
- package/dist/declarations/satellite/satellite.factory.did.js +1 -5
- package/dist/declarations/satellite/satellite.factory.did.mjs +1 -5
- package/dist/declarations/sputnik/sputnik.did.d.ts +0 -7
- package/dist/declarations/sputnik/sputnik.factory.certified.did.js +1 -5
- package/dist/declarations/sputnik/sputnik.factory.did.js +1 -5
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +3 -3
- package/dist/workers/auth.worker.js +1 -16
- package/package.json +1 -1
|
@@ -143,10 +143,6 @@ export interface ListResults_1 {
|
|
|
143
143
|
items_length: bigint;
|
|
144
144
|
}
|
|
145
145
|
export type Memory = {Heap: null} | {Stable: null};
|
|
146
|
-
export interface MemorySize {
|
|
147
|
-
stable: bigint;
|
|
148
|
-
heap: bigint;
|
|
149
|
-
}
|
|
150
146
|
export type Permission = {Controllers: null} | {Private: null} | {Public: null} | {Managed: null};
|
|
151
147
|
export interface RateConfig {
|
|
152
148
|
max_tokens: bigint;
|
|
@@ -237,7 +233,6 @@ export interface UploadChunkResult {
|
|
|
237
233
|
chunk_id: bigint;
|
|
238
234
|
}
|
|
239
235
|
export interface _SERVICE {
|
|
240
|
-
build_version: ActorMethod<[], string>;
|
|
241
236
|
commit_asset_upload: ActorMethod<[CommitBatch], undefined>;
|
|
242
237
|
count_assets: ActorMethod<[string, ListParams], bigint>;
|
|
243
238
|
count_collection_assets: ActorMethod<[string], bigint>;
|
|
@@ -275,7 +270,6 @@ export interface _SERVICE {
|
|
|
275
270
|
list_custom_domains: ActorMethod<[], Array<[string, CustomDomain]>>;
|
|
276
271
|
list_docs: ActorMethod<[string, ListParams], ListResults_1>;
|
|
277
272
|
list_rules: ActorMethod<[CollectionType], Array<[string, Rule]>>;
|
|
278
|
-
memory_size: ActorMethod<[], MemorySize>;
|
|
279
273
|
set_auth_config: ActorMethod<[AuthenticationConfig], undefined>;
|
|
280
274
|
set_controllers: ActorMethod<[SetControllersArgs], Array<[Principal, Controller]>>;
|
|
281
275
|
set_custom_domain: ActorMethod<[string, [] | [string]], undefined>;
|
|
@@ -285,7 +279,6 @@ export interface _SERVICE {
|
|
|
285
279
|
set_rule: ActorMethod<[CollectionType, string, SetRule], Rule>;
|
|
286
280
|
set_storage_config: ActorMethod<[StorageConfig], undefined>;
|
|
287
281
|
upload_asset_chunk: ActorMethod<[UploadChunk], UploadChunkResult>;
|
|
288
|
-
version: ActorMethod<[], string>;
|
|
289
282
|
}
|
|
290
283
|
export declare const idlFactory: IDL.InterfaceFactory;
|
|
291
284
|
export declare const init: (args: {IDL: typeof IDL}) => IDL.Type[];
|
|
@@ -208,7 +208,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
208
208
|
items: IDL.Vec(IDL.Tuple(IDL.Text, Doc)),
|
|
209
209
|
items_length: IDL.Nat64
|
|
210
210
|
});
|
|
211
|
-
const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
|
|
212
211
|
const SetController = IDL.Record({
|
|
213
212
|
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
214
213
|
scope: ControllerScope,
|
|
@@ -241,7 +240,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
241
240
|
});
|
|
242
241
|
const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
|
|
243
242
|
return IDL.Service({
|
|
244
|
-
build_version: IDL.Func([], [IDL.Text], []),
|
|
245
243
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
246
244
|
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], []),
|
|
247
245
|
count_collection_assets: IDL.Func([IDL.Text], [IDL.Nat64], []),
|
|
@@ -292,7 +290,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
292
290
|
list_custom_domains: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], []),
|
|
293
291
|
list_docs: IDL.Func([IDL.Text, ListParams], [ListResults_1], []),
|
|
294
292
|
list_rules: IDL.Func([CollectionType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], []),
|
|
295
|
-
memory_size: IDL.Func([], [MemorySize], []),
|
|
296
293
|
set_auth_config: IDL.Func([AuthenticationConfig], [], []),
|
|
297
294
|
set_controllers: IDL.Func(
|
|
298
295
|
[SetControllersArgs],
|
|
@@ -309,8 +306,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
309
306
|
),
|
|
310
307
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
311
308
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
312
|
-
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
313
|
-
version: IDL.Func([], [IDL.Text], [])
|
|
309
|
+
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
314
310
|
});
|
|
315
311
|
};
|
|
316
312
|
// @ts-ignore
|
|
@@ -208,7 +208,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
208
208
|
items: IDL.Vec(IDL.Tuple(IDL.Text, Doc)),
|
|
209
209
|
items_length: IDL.Nat64
|
|
210
210
|
});
|
|
211
|
-
const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
|
|
212
211
|
const SetController = IDL.Record({
|
|
213
212
|
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
214
213
|
scope: ControllerScope,
|
|
@@ -241,7 +240,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
241
240
|
});
|
|
242
241
|
const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
|
|
243
242
|
return IDL.Service({
|
|
244
|
-
build_version: IDL.Func([], [IDL.Text], ['query']),
|
|
245
243
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
246
244
|
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']),
|
|
247
245
|
count_collection_assets: IDL.Func([IDL.Text], [IDL.Nat64], ['query']),
|
|
@@ -292,7 +290,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
292
290
|
list_custom_domains: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], ['query']),
|
|
293
291
|
list_docs: IDL.Func([IDL.Text, ListParams], [ListResults_1], ['query']),
|
|
294
292
|
list_rules: IDL.Func([CollectionType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], ['query']),
|
|
295
|
-
memory_size: IDL.Func([], [MemorySize], ['query']),
|
|
296
293
|
set_auth_config: IDL.Func([AuthenticationConfig], [], []),
|
|
297
294
|
set_controllers: IDL.Func(
|
|
298
295
|
[SetControllersArgs],
|
|
@@ -309,8 +306,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
309
306
|
),
|
|
310
307
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
311
308
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
312
|
-
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
313
|
-
version: IDL.Func([], [IDL.Text], ['query'])
|
|
309
|
+
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
314
310
|
});
|
|
315
311
|
};
|
|
316
312
|
// @ts-ignore
|
|
@@ -208,7 +208,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
208
208
|
items: IDL.Vec(IDL.Tuple(IDL.Text, Doc)),
|
|
209
209
|
items_length: IDL.Nat64
|
|
210
210
|
});
|
|
211
|
-
const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
|
|
212
211
|
const SetController = IDL.Record({
|
|
213
212
|
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
214
213
|
scope: ControllerScope,
|
|
@@ -241,7 +240,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
241
240
|
});
|
|
242
241
|
const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
|
|
243
242
|
return IDL.Service({
|
|
244
|
-
build_version: IDL.Func([], [IDL.Text], ['query']),
|
|
245
243
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
246
244
|
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']),
|
|
247
245
|
count_collection_assets: IDL.Func([IDL.Text], [IDL.Nat64], ['query']),
|
|
@@ -292,7 +290,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
292
290
|
list_custom_domains: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], ['query']),
|
|
293
291
|
list_docs: IDL.Func([IDL.Text, ListParams], [ListResults_1], ['query']),
|
|
294
292
|
list_rules: IDL.Func([CollectionType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], ['query']),
|
|
295
|
-
memory_size: IDL.Func([], [MemorySize], ['query']),
|
|
296
293
|
set_auth_config: IDL.Func([AuthenticationConfig], [], []),
|
|
297
294
|
set_controllers: IDL.Func(
|
|
298
295
|
[SetControllersArgs],
|
|
@@ -309,8 +306,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
309
306
|
),
|
|
310
307
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
311
308
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
312
|
-
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
313
|
-
version: IDL.Func([], [IDL.Text], ['query'])
|
|
309
|
+
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
314
310
|
});
|
|
315
311
|
};
|
|
316
312
|
// @ts-ignore
|
|
@@ -143,10 +143,6 @@ export interface ListResults_1 {
|
|
|
143
143
|
items_length: bigint;
|
|
144
144
|
}
|
|
145
145
|
export type Memory = {Heap: null} | {Stable: null};
|
|
146
|
-
export interface MemorySize {
|
|
147
|
-
stable: bigint;
|
|
148
|
-
heap: bigint;
|
|
149
|
-
}
|
|
150
146
|
export type Permission = {Controllers: null} | {Private: null} | {Public: null} | {Managed: null};
|
|
151
147
|
export interface RateConfig {
|
|
152
148
|
max_tokens: bigint;
|
|
@@ -237,7 +233,6 @@ export interface UploadChunkResult {
|
|
|
237
233
|
chunk_id: bigint;
|
|
238
234
|
}
|
|
239
235
|
export interface _SERVICE {
|
|
240
|
-
build_version: ActorMethod<[], string>;
|
|
241
236
|
commit_asset_upload: ActorMethod<[CommitBatch], undefined>;
|
|
242
237
|
count_assets: ActorMethod<[string, ListParams], bigint>;
|
|
243
238
|
count_collection_assets: ActorMethod<[string], bigint>;
|
|
@@ -275,7 +270,6 @@ export interface _SERVICE {
|
|
|
275
270
|
list_custom_domains: ActorMethod<[], Array<[string, CustomDomain]>>;
|
|
276
271
|
list_docs: ActorMethod<[string, ListParams], ListResults_1>;
|
|
277
272
|
list_rules: ActorMethod<[CollectionType], Array<[string, Rule]>>;
|
|
278
|
-
memory_size: ActorMethod<[], MemorySize>;
|
|
279
273
|
set_auth_config: ActorMethod<[AuthenticationConfig], undefined>;
|
|
280
274
|
set_controllers: ActorMethod<[SetControllersArgs], Array<[Principal, Controller]>>;
|
|
281
275
|
set_custom_domain: ActorMethod<[string, [] | [string]], undefined>;
|
|
@@ -285,7 +279,6 @@ export interface _SERVICE {
|
|
|
285
279
|
set_rule: ActorMethod<[CollectionType, string, SetRule], Rule>;
|
|
286
280
|
set_storage_config: ActorMethod<[StorageConfig], undefined>;
|
|
287
281
|
upload_asset_chunk: ActorMethod<[UploadChunk], UploadChunkResult>;
|
|
288
|
-
version: ActorMethod<[], string>;
|
|
289
282
|
}
|
|
290
283
|
export declare const idlFactory: IDL.InterfaceFactory;
|
|
291
284
|
export declare const init: (args: {IDL: typeof IDL}) => IDL.Type[];
|
|
@@ -208,7 +208,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
208
208
|
items: IDL.Vec(IDL.Tuple(IDL.Text, Doc)),
|
|
209
209
|
items_length: IDL.Nat64
|
|
210
210
|
});
|
|
211
|
-
const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
|
|
212
211
|
const SetController = IDL.Record({
|
|
213
212
|
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
214
213
|
scope: ControllerScope,
|
|
@@ -241,7 +240,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
241
240
|
});
|
|
242
241
|
const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
|
|
243
242
|
return IDL.Service({
|
|
244
|
-
build_version: IDL.Func([], [IDL.Text], []),
|
|
245
243
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
246
244
|
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], []),
|
|
247
245
|
count_collection_assets: IDL.Func([IDL.Text], [IDL.Nat64], []),
|
|
@@ -292,7 +290,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
292
290
|
list_custom_domains: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], []),
|
|
293
291
|
list_docs: IDL.Func([IDL.Text, ListParams], [ListResults_1], []),
|
|
294
292
|
list_rules: IDL.Func([CollectionType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], []),
|
|
295
|
-
memory_size: IDL.Func([], [MemorySize], []),
|
|
296
293
|
set_auth_config: IDL.Func([AuthenticationConfig], [], []),
|
|
297
294
|
set_controllers: IDL.Func(
|
|
298
295
|
[SetControllersArgs],
|
|
@@ -309,8 +306,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
309
306
|
),
|
|
310
307
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
311
308
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
312
|
-
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
313
|
-
version: IDL.Func([], [IDL.Text], [])
|
|
309
|
+
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
314
310
|
});
|
|
315
311
|
};
|
|
316
312
|
// @ts-ignore
|
|
@@ -208,7 +208,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
208
208
|
items: IDL.Vec(IDL.Tuple(IDL.Text, Doc)),
|
|
209
209
|
items_length: IDL.Nat64
|
|
210
210
|
});
|
|
211
|
-
const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
|
|
212
211
|
const SetController = IDL.Record({
|
|
213
212
|
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
214
213
|
scope: ControllerScope,
|
|
@@ -241,7 +240,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
241
240
|
});
|
|
242
241
|
const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
|
|
243
242
|
return IDL.Service({
|
|
244
|
-
build_version: IDL.Func([], [IDL.Text], ['query']),
|
|
245
243
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
246
244
|
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']),
|
|
247
245
|
count_collection_assets: IDL.Func([IDL.Text], [IDL.Nat64], ['query']),
|
|
@@ -292,7 +290,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
292
290
|
list_custom_domains: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], ['query']),
|
|
293
291
|
list_docs: IDL.Func([IDL.Text, ListParams], [ListResults_1], ['query']),
|
|
294
292
|
list_rules: IDL.Func([CollectionType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], ['query']),
|
|
295
|
-
memory_size: IDL.Func([], [MemorySize], ['query']),
|
|
296
293
|
set_auth_config: IDL.Func([AuthenticationConfig], [], []),
|
|
297
294
|
set_controllers: IDL.Func(
|
|
298
295
|
[SetControllersArgs],
|
|
@@ -309,8 +306,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
309
306
|
),
|
|
310
307
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
311
308
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
312
|
-
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
313
|
-
version: IDL.Func([], [IDL.Text], ['query'])
|
|
309
|
+
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
314
310
|
});
|
|
315
311
|
};
|
|
316
312
|
// @ts-ignore
|
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 Qe}from"@dfinity/utils";import{isNullish as ze}from"@dfinity/utils";var S=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 h=class t extends S{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 tt=({message:t,detail:e})=>{let s=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(s)};import{ERROR_USER_INTERRUPT as Je}from"@dfinity/auth-client";import{isNullish as $e}from"@dfinity/utils";var _t=BigInt(144e11),gt=!1,At={width:576,height:576},Tt={width:505,height:705},ht="internetcomputer.org";import{isNullish as be,nonNullish as Nt}from"@dfinity/utils";var E="http://127.0.0.1:5987",Ot="rdmx6-jaaaa-aaaaa-aaadq-cai";var g=class t extends S{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}};import{isNullish as Rt}from"@dfinity/utils";import{jsonReplacer as we,jsonReviver as ve}from"@dfinity/utils";var xt=async t=>{let e=new Blob([JSON.stringify(t,we)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},q=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(),ve)},K=()=>typeof window<"u";var et=({width:t,height:e})=>{if(!K()||Rt(window)||Rt(window.top))return;let{top:{innerWidth:s,innerHeight:o}}=window,i=o/2+screenY-e/2,n=s/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${n}`};var B=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let s=()=>{let o=g.getInstance().get()?.container;if(be(o)||o===!1)return`https://identity.${this.#t??ht}`;let i=g.getInstance().get(),n=Nt(i)&&Nt(i?.internetIdentityId)?i.internetIdentityId:Ot,{host:r,protocol:a}=new URL(o===!0?E:o);return/apple/i.test(navigator?.vendor)?`${a}//${r}?canisterId=${n}`:`${a}//${n}.${r.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:et(At)},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:et(Tt)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};import{Actor as ke}from"@dfinity/agent";import{isNullish as ot}from"@dfinity/utils";import{HttpAgent as Ue}from"@dfinity/agent";import{isNullish as st,nonNullish as St}from"@dfinity/utils";var w=class t{static instance;#t=void 0;constructor(){}static getInstance(){return st(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...s}){let o=e.getPrincipal().toText();if(st(this.#t)||st(this.#t[o])){let i=await this.createAgent({identity:e,...s});return this.#t={...this.#t??{},[o]:i},i}return this.#t[o]}reset(){this.#t=null}async createAgent({identity:e,fetch:s,container:o}){let n=St(o)&&o!==!1?o===!0?E:o:"https://icp-api.io",r=St(o);return await Ue.create({identity:e,shouldFetchRootKey:r,host:n,...s&&{fetch:s}})}};var v=class t{static instance;#t=void 0;constructor(){}static getInstance(){return ot(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:s,buildType:o,...i}){let n=`${o}#${s.getPrincipal().toText()}#${e};`;if(ot(this.#t)||ot(this.#t[n])){let r=await this.createActor({satelliteId:e,identity:s,...i});return this.#t={...this.#t??{},[n]:r},r}return this.#t[n]}reset(){this.#t=null}async createActor({idlFactory:e,satelliteId:s,...o}){let i=await w.getInstance().getAgent(o);return ke.createActor(e,{agent:i,canisterId:s})}};var J=class extends Error{},$=class extends Error{},H=class extends Error{},G=class extends Error{},z=class extends Error{};import{AuthClient as Ce}from"@dfinity/auth-client";var W=()=>Ce.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});import{isNullish as Ke,nonNullish as zt}from"@dfinity/utils";var it="juno.datastore.error.user.cannot_update";var nt=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;import{fromNullable as U,isNullish as Ve,nonNullish as je}from"@dfinity/utils";var Et=async({data:t})=>{try{return await q(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};import{fromNullable as wt,toNullable as rt}from"@dfinity/utils";var at=async t=>{let{data:e,version:s,description:o}=t;return{description:rt(o),data:await xt(e),version:rt(s)}},ct=t=>{let{version:e}=t;return{version:rt(e)}},M=async({doc:t,key:e})=>{let{owner:s,version:o,description:i,data:n,...r}=t;return{key:e,description:wt(i),owner:s.toText(),data:await q(n),version:wt(o),...r}};import{Principal as Fe}from"@dfinity/principal";import{isNullish as b,toNullable as _}from"@dfinity/utils";var vt=t=>{if(b(t))return _();switch(t.matcher){case"equal":return _({Equal:t.timestamp});case"greaterThan":return _({GreaterThan:t.timestamp});case"lessThan":return _({LessThan:t.timestamp});case"between":return _({Between:[t.timestamps.start,t.timestamps.end]});default:throw new z("Invalid list matcher for timestamp",t)}},N=({matcher:t,paginate:e,order:s,owner:o})=>({matcher:b(t)?[]:[{key:_(t.key),description:_(t.description),created_at:vt(t.createdAt),updated_at:vt(t.updatedAt)}],paginate:_(b(e)?void 0:{start_after:_(e.startAfter),limit:_(b(e.limit)?void 0:BigInt(e.limit))}),order:_(b(s)?void 0:{desc:s.desc,field:s.field==="created_at"?{CreatedAt:null}:s.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:_(b(o)?void 0:typeof o=="string"?Fe.fromText(o):o)});import{assertNonNullish as Me}from"@dfinity/utils";var bt=({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.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),o=t.Record({field:s,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),n=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),r=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(o),owner:t.Opt(t.Principal),matcher:t.Opt(n),paginate:t.Opt(r)}),p=t.Record({controllers:t.Vec(t.Principal)}),f=t.Variant({Write:t.Null,Admin:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:f,expires_at:t.Opt(t.Nat64)}),y=t.Record({version:t.Opt(t.Nat64)}),m=t.Variant({Db:t.Null,Storage:t.Null}),O=t.Record({version:t.Opt(t.Nat64)}),x=t.Record({cycles:t.Nat,destination_id:t.Principal}),T=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}),R=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),u=t.Record({key:T,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,R)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),P=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),k=t.Record({internet_identity:t.Opt(P)}),V=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),C=t.Record({max_memory_size:t.Opt(V)}),le=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),pe=t.Variant({Deny:t.Null,Allow:t.Null}),de=t.Record({status_code:t.Nat16,location:t.Text}),Z=t.Record({iframe:t.Opt(le),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(V),raw_access:t.Opt(pe),redirects:t.Opt(t.Vec(t.Tuple(t.Text,de)))}),ue=t.Record({db:t.Opt(C),authentication:t.Opt(k),storage:Z}),F=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)}),D=t.Variant({Heap:t.Null,Stable:t.Null}),j=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),yt=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),I=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(D),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:j,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(yt),write:j,max_changes_per_user:t.Opt(t.Nat32)}),me=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)}),L=t.Record({memory:D,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}),ye=t.Variant({Callback:t.Record({token:L,callback:t.Func([],[],["query"])})}),fe=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(ye),status_code:t.Nat16}),_e=t.Record({token:t.Opt(L),body:t.Vec(t.Nat8)}),ge=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}),Ae=t.Record({batch_id:t.Nat}),Te=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,u)),items_length:t.Nat64}),he=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Oe=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,F)),items_length:t.Nat64}),xe=t.Record({stable:t.Nat64,heap:t.Nat64}),Re=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),Ne=t.Record({controller:Re,controllers:t.Vec(t.Principal)}),ft=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Pe=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(D),max_size:t.Opt(t.Nat),read:j,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(yt),write:j,max_changes_per_user:t.Opt(t.Nat32)}),Se=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),Ee=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[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,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([p],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,y],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,a],[],[]),del_filtered_docs:t.Func([t.Text,a],[],[]),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,y))],[],[]),del_rule:t.Func([m,t.Text,O],[],[]),deposit_cycles:t.Func([x],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(u)],["query"]),get_auth_config:t.Func([],[t.Opt(k)],["query"]),get_config:t.Func([],[ue],[]),get_db_config:t.Func([],[t.Opt(C)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(F)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(u)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(F)))],["query"]),get_rule:t.Func([m,t.Text],[t.Opt(I)],["query"]),get_storage_config:t.Func([],[Z],["query"]),http_request:t.Func([me],[fe],["query"]),http_request_streaming_callback:t.Func([L],[_e],["query"]),init_asset_upload:t.Func([ge],[Ae],[]),list_assets:t.Func([t.Text,a],[Te],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,he))],["query"]),list_docs:t.Func([t.Text,a],[Oe],["query"]),list_rules:t.Func([m],[t.Vec(t.Tuple(t.Text,I))],["query"]),memory_size:t.Func([],[xe],["query"]),set_auth_config:t.Func([k],[],[]),set_controllers:t.Func([Ne],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([C],[],[]),set_doc:t.Func([t.Text,t.Text,ft],[F],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,ft))],[t.Vec(t.Tuple(t.Text,F))],[]),set_rule:t.Func([m,t.Text,Pe],[I],[]),set_storage_config:t.Func([Z],[],[]),upload_asset_chunk:t.Func([Se],[Ee],[]),version:t.Func([],[t.Text],["query"])})};import{nonNullish as lt}from"@dfinity/utils";var Ut=({satelliteId:t,container:e})=>{let{satelliteId:s}=pt({satelliteId:t}),{container:o}=dt({container:e});if(lt(o)&&o!==!1){let{host:i,protocol:n}=new URL(o===!0?E:o);return`${n}//${s??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${s??"unknown"}.icp0.io`},pt=({satelliteId:t})=>lt(t)?{satelliteId:t}:g.getInstance().get()??{satelliteId:void 0},dt=({container:t})=>lt(t)?{container:t}:g.getInstance().get()??{container:void 0};var l=t=>Ct({idlFactory:bt,buildType:"stock",...t}),kt=({idlFactory:t,...e})=>Ct({idlFactory:t,buildType:"extended",...e}),Ct=async({satelliteId:t,container:e,...s})=>{let{satelliteId:o}=pt({satelliteId:t});Me(o,"No satellite ID defined. Did you initialize Juno?");let{container:i}=dt({container:e});return await v.getInstance().getActor({satelliteId:o,container:i,...s})};var Ft=async({collection:t,key:e,satellite:s})=>{let{get_doc:o}=await l(s),i=U(await o(t,e));if(!Ve(i))return M({doc:i,key:e})},Mt=async({docs:t,satellite:e})=>{let{get_many_docs:s}=await l(e),o=t.map(({collection:r,key:a})=>[r,a]),i=await s(o),n=[];for(let[r,a]of i){let p=U(a);n.push(je(p)?await M({key:r,doc:p}):void 0)}return n},Vt=async({collection:t,doc:e,satellite:s})=>{let{set_doc:o}=await l(s),{key:i}=e,n=await at(e),r=await o(t,i,n);return await M({key:i,doc:r})},jt=async({docs:t,satellite:e})=>{let{set_many_docs:s}=await l(e),o=[];for(let{collection:r,doc:a}of t){let{key:p}=a;o.push([r,p,await at(a)])}let i=await s(o),n=[];for(let[r,a]of i)n.push(await M({key:r,doc:a}));return n},qt=async({collection:t,doc:e,satellite:s})=>{let{del_doc:o}=await l(s),{key:i}=e;return o(t,i,ct(e))},Kt=async({docs:t,satellite:e})=>{let{del_many_docs:s}=await l(e),o=t.map(({collection:i,doc:n})=>[i,n.key,ct(n)]);await s(o)},Bt=async({collection:t,filter:e,satellite:s})=>{let{del_filtered_docs:o}=await l(s);return o(t,N(e))},Jt=async({collection:t,filter:e,satellite:s})=>{let{list_docs:o}=await l(s),{items:i,items_page:n,items_length:r,matches_length:a,matches_pages:p}=await o(t,N(e)),f=[];for(let[d,y]of i){let{data:m,owner:O,description:x,version:T,...R}=y;f.push({key:d,description:U(x),owner:O.toText(),data:await Et({data:m}),version:U(T),...R})}return{items:f,items_length:r,items_page:U(n),matches_length:a,matches_pages:U(p)}},$t=async({collection:t,filter:e,satellite:s})=>{let{count_docs:o}=await l(s);return o(t,N(e))};import{AnonymousIdentity as qe}from"@dfinity/agent";var c=t=>t!==void 0?t:Y()??new qe;var Ht=async({satellite:t,...e})=>{let s=c(t?.identity);return await Ft({...e,satellite:{...t,identity:s}})},bo=async({satellite:t,...e})=>{let s=c(t?.identity);return await Mt({...e,satellite:{...t,identity:s}})},Gt=async({satellite:t,...e})=>{let s=c(t?.identity);return await Vt({...e,satellite:{...t,identity:s}})},Uo=async({satellite:t,...e})=>{let s=c(t?.identity);return await jt({...e,satellite:{...t,identity:s}})},ko=async({satellite:t,...e})=>{let s=c(t?.identity);return await qt({...e,satellite:{...t,identity:s}})},Co=async({satellite:t,...e})=>{let s=c(t?.identity);return await Kt({...e,satellite:{...t,identity:s}})},Fo=async({satellite:t,filter:e,...s})=>{let o=c(t?.identity);return await Bt({...s,filter:e??{},satellite:{...t,identity:o}})},Mo=async({satellite:t,filter:e,...s})=>{let o=c(t?.identity);return await Jt({...s,filter:e??{},satellite:{...t,identity:o}})},Vo=async({satellite:t,filter:e,...s})=>{let o=c(t?.identity);return await $t({...s,filter:e??{},satellite:{...t,identity:o}})};var Wt=async t=>{let e=Y();if(Ke(e))throw new G("No identity to initialize the user. Have you initialized Juno?");let s=e.getPrincipal().toText(),o=()=>Ht({collection:"#user",key:s}),i=await o();if(zt(i))return i;try{return await Be({userId:s,provider:t})}catch(n){if(nt({error:n,type:it})){let r=await o();if(zt(r))return r}throw n}},Be=({userId:t,...e})=>Gt({collection:"#user",doc:{key:t,data:e}});var A,ut=async t=>{if(A=A??await W(),!(await A?.isAuthenticated()??!1))return;let s=await Wt(t);h.getInstance().set(s)},He=t=>new Promise(async(e,s)=>{if($e(A)){s(new $("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let o=t?.provider??new B({});await A.login({onSuccess:async()=>{await ut(o.id),e()},onError:i=>{if(i===Je){s(new H(i));return}s(new J(i))},maxTimeToLive:t?.maxTimeToLive??_t,allowPinAuthentication:t?.allowPin??gt,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...o.signInOptions({windowed:t?.windowed})})}),mt=async()=>{await A?.logout(),A=null,h.getInstance().reset(),v.getInstance().reset(),w.getInstance().reset(),A=await W()},Y=()=>A?.getIdentity(),Ge=async()=>(A??await W()).getIdentity();var Yt=t=>{let e=t===!0?"./workers/auth.worker.js":t,s=new Worker(e),o=async()=>{tt({message:"junoSignOutAuthTimer"}),await mt()};return s.onmessage=async({data:i})=>{let{msg:n,data:r}=i;switch(n){case"junoSignOutAuthTimer":await o();return;case"junoDelegationRemainingTime":tt({message:"junoDelegationRemainingTime",detail:r?.authRemainingTime});return}},h.getInstance().subscribe(i=>{if(ze(i)){s.postMessage({msg:"junoStopAuthTimer"});return}s.postMessage({msg:"junoStartAuthTimer"})})};var Xt=()=>{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()},Qt=()=>{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 li=async({idlFactory:t,satellite:e})=>{let s=c(e?.identity);return await kt({idlFactory:t,...e,identity:s})};import{fromNullable as re,nonNullish as Xe}from"@dfinity/utils";import{fromNullable as Q}from"@dfinity/utils";import{toNullable as X}from"@dfinity/utils";var Zt=async({asset:{data:t,filename:e,collection:s,headers:o,token:i,fullPath:n,encoding:r,description:a},actor:p,init_asset_upload:f})=>{let{batch_id:d}=await f({collection:s,full_path:n,name:e,token:X(i),encoding_type:X(r),description:X(a)}),y=19e5,m=[],O=K()?new Blob([await t.arrayBuffer()]):t,x=0n;for(let u=0;u<O.size;u+=y){let P=O.slice(u,u+y);m.push({batchId:d,chunk:P,actor:p,orderId:x}),x++}let T=[];for await(let u of We({uploadChunks:m}))T=[...T,...u];let R=o.find(([u,P])=>u.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await p.commit_asset_upload({batch_id:d,chunk_ids:T.map(({chunk_id:u})=>u),headers:[...o,...R??[]]})};async function*We({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=>Ye(i)))}}var Ye=async({batchId:t,chunk:e,actor:s,orderId:o})=>s.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:X(o)});var Dt=async({satellite:t,...e})=>{let s=await l(t);await Zt({actor:s,asset:e,init_asset_upload:async i=>await s.init_asset_upload(i)})},It=async({collection:t,satellite:e,filter:s})=>{let{list_assets:o}=await l(e),{items:i,items_length:n,items_page:r,matches_length:a,matches_pages:p}=await o(t,N(s));return{items:i.map(([f,d])=>d),items_length:n,items_page:Q(r),matches_length:a,matches_pages:Q(p)}},Lt=async({collection:t,satellite:e,filter:s})=>{let{count_assets:o}=await l(e);return o(t,N(s))},te=async({collection:t,fullPath:e,satellite:s})=>(await l(s)).del_asset(t,e),ee=async({assets:t,satellite:e})=>{let{del_many_assets:s}=await l(e),o=t.map(({collection:i,fullPath:n})=>[i,n]);await s(o)},se=async({collection:t,satellite:e,filter:s})=>{let{del_filtered_assets:o}=await l(e);return o(t,N(s))},oe=async({collection:t,fullPath:e,satellite:s})=>{let{get_asset:o}=await l(s);return Q(await o(t,e))},ie=async({assets:t,satellite:e})=>{let{get_many_assets:s}=await l(e),o=t.map(({collection:n,fullPath:r})=>[n,r]);return(await s(o)).map(([n,r])=>Q(r))};var ne=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Pi=t=>ae(t),Si=t=>ae({filename:t.data.name,...t}),ae=async({filename:t,data:e,collection:s,headers:o=[],fullPath:i,token:n,satellite:r,encoding:a,description:p})=>{let f=c(r?.identity),d=decodeURI(t),y=i??`/${s}/${d}`,m={...r,identity:f};return await Dt({data:e,filename:d,collection:s,token:n,headers:o,fullPath:y,encoding:a,satellite:m,description:p}),{downloadUrl:ce({satellite:m,assetKey:{fullPath:y,token:n}}),fullPath:y,name:d}},Ei=async({collection:t,satellite:e,filter:s})=>{let o={...e,identity:c(e?.identity)},{items:i,...n}=await It({collection:t,satellite:o,filter:s??{}}),r=i.map(({key:{full_path:a,token:p,name:f,owner:d,description:y},headers:m,encodings:O,created_at:x,updated_at:T})=>{let R=re(p);return{fullPath:a,description:re(y),name:f,downloadUrl:ce({satellite:o,assetKey:{fullPath:a,token:R}}),token:R,headers:m,encodings:O.reduce((u,[P,{modified:k,sha256:V,total_length:C}])=>({...u,[P]:{modified:k,sha256:ne(V),total_length:C}}),{}),owner:d.toText(),created_at:x,updated_at:T}});return{items:r,assets:r,...n}},wi=async({collection:t,satellite:e,filter:s})=>{let o={...e,identity:c(e?.identity)};return await Lt({collection:t,satellite:o,filter:s??{}})},vi=({collection:t,fullPath:e,satellite:s})=>te({collection:t,fullPath:e,satellite:{...s,identity:c(s?.identity)}}),bi=({assets:t,satellite:e})=>ee({assets:t,satellite:{...e,identity:c(e?.identity)}}),Ui=async({collection:t,satellite:e,filter:s})=>{let o={...e,identity:c(e?.identity)};return await se({collection:t,satellite:o,filter:s??{}})},ki=async({satellite:t,...e})=>{let s=c(t?.identity);return await oe({...e,satellite:{...t,identity:s}})},Ci=async({satellite:t,...e})=>{let s=c(t?.identity);return await ie({...e,satellite:{...t,identity:s}})},ce=({assetKey:{fullPath:t,token:e},satellite:s})=>{let o={...s,identity:c(s?.identity)};return`${Ut(o)}${t}${Xe(e)?`?token=${e}`:""}`};var Ze=t=>{let e=t?.satelliteId??Xt();Qe(e,"Satellite ID is not configured. Juno cannot be initialized.");let s=t?.container??Qt();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:s}},Ji=t=>De(t),De=async t=>{let e=Ze(t);g.getInstance().set(e),await ut();let s=e.workers?.auth!==void 0?Yt(e.workers.auth):void 0;return[...s?[s]:[]]},$i=t=>h.getInstance().subscribe(t);export{G as InitError,B as InternetIdentityProvider,z as ListError,Pt as NFIDProvider,J as SignInError,$ as SignInInitError,H as SignInUserInterruptError,$i as authSubscribe,wi as countAssets,Vo as countDocs,vi as deleteAsset,ko as deleteDoc,Ui as deleteFilteredAssets,Fo as deleteFilteredDocs,bi as deleteManyAssets,Co as deleteManyDocs,ce as downloadUrl,ki as getAsset,Ht as getDoc,Ci as getManyAssets,bo as getManyDocs,li as getSatelliteExtendedActor,Ji as initJuno,De as initSatellite,Ei as listAssets,Mo as listDocs,Gt as setDoc,Uo as setManyDocs,He as signIn,mt as signOut,Ge as unsafeIdentity,Pi as uploadBlob,Si as uploadFile};
|
|
3
|
+
import{assertNonNullish as Xe}from"@dfinity/utils";import{isNullish as Ge}from"@dfinity/utils";var S=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 h=class t extends S{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 tt=({message:t,detail:e})=>{let s=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(s)};import{ERROR_USER_INTERRUPT as Be}from"@dfinity/auth-client";import{isNullish as Je}from"@dfinity/utils";var _t=BigInt(144e11),gt=!1,At={width:576,height:576},Tt={width:505,height:705},ht="internetcomputer.org";import{isNullish as ve,nonNullish as Nt}from"@dfinity/utils";var E="http://127.0.0.1:5987",Ot="rdmx6-jaaaa-aaaaa-aaadq-cai";var g=class t extends S{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}};import{isNullish as Rt}from"@dfinity/utils";import{jsonReplacer as Ee,jsonReviver as we}from"@dfinity/utils";var xt=async t=>{let e=new Blob([JSON.stringify(t,Ee)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},K=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(),we)},q=()=>typeof window<"u";var et=({width:t,height:e})=>{if(!q()||Rt(window)||Rt(window.top))return;let{top:{innerWidth:s,innerHeight:o}}=window,i=o/2+screenY-e/2,n=s/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${n}`};var B=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let s=()=>{let o=g.getInstance().get()?.container;if(ve(o)||o===!1)return`https://identity.${this.#t??ht}`;let i=g.getInstance().get(),n=Nt(i)&&Nt(i?.internetIdentityId)?i.internetIdentityId:Ot,{host:r,protocol:a}=new URL(o===!0?E:o);return/apple/i.test(navigator?.vendor)?`${a}//${r}?canisterId=${n}`:`${a}//${n}.${r.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:et(At)},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:et(Tt)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};import{Actor as Ue}from"@dfinity/agent";import{isNullish as ot}from"@dfinity/utils";import{HttpAgent as be}from"@dfinity/agent";import{isNullish as st,nonNullish as St}from"@dfinity/utils";var w=class t{static instance;#t=void 0;constructor(){}static getInstance(){return st(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...s}){let o=e.getPrincipal().toText();if(st(this.#t)||st(this.#t[o])){let i=await this.createAgent({identity:e,...s});return this.#t={...this.#t??{},[o]:i},i}return this.#t[o]}reset(){this.#t=null}async createAgent({identity:e,fetch:s,container:o}){let n=St(o)&&o!==!1?o===!0?E:o:"https://icp-api.io",r=St(o);return await be.create({identity:e,shouldFetchRootKey:r,host:n,...s&&{fetch:s}})}};var v=class t{static instance;#t=void 0;constructor(){}static getInstance(){return ot(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:s,buildType:o,...i}){let n=`${o}#${s.getPrincipal().toText()}#${e};`;if(ot(this.#t)||ot(this.#t[n])){let r=await this.createActor({satelliteId:e,identity:s,...i});return this.#t={...this.#t??{},[n]:r},r}return this.#t[n]}reset(){this.#t=null}async createActor({idlFactory:e,satelliteId:s,...o}){let i=await w.getInstance().getAgent(o);return Ue.createActor(e,{agent:i,canisterId:s})}};var J=class extends Error{},$=class extends Error{},H=class extends Error{},G=class extends Error{},W=class extends Error{};import{AuthClient as ke}from"@dfinity/auth-client";var z=()=>ke.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});import{isNullish as Ke,nonNullish as Wt}from"@dfinity/utils";var it="juno.datastore.error.user.cannot_update";var nt=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;import{fromNullable as U,isNullish as Me,nonNullish as Ve}from"@dfinity/utils";var Et=async({data:t})=>{try{return await K(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};import{fromNullable as wt,toNullable as rt}from"@dfinity/utils";var at=async t=>{let{data:e,version:s,description:o}=t;return{description:rt(o),data:await xt(e),version:rt(s)}},ct=t=>{let{version:e}=t;return{version:rt(e)}},M=async({doc:t,key:e})=>{let{owner:s,version:o,description:i,data:n,...r}=t;return{key:e,description:wt(i),owner:s.toText(),data:await K(n),version:wt(o),...r}};import{Principal as Ce}from"@dfinity/principal";import{isNullish as b,toNullable as _}from"@dfinity/utils";var vt=t=>{if(b(t))return _();switch(t.matcher){case"equal":return _({Equal:t.timestamp});case"greaterThan":return _({GreaterThan:t.timestamp});case"lessThan":return _({LessThan:t.timestamp});case"between":return _({Between:[t.timestamps.start,t.timestamps.end]});default:throw new W("Invalid list matcher for timestamp",t)}},N=({matcher:t,paginate:e,order:s,owner:o})=>({matcher:b(t)?[]:[{key:_(t.key),description:_(t.description),created_at:vt(t.createdAt),updated_at:vt(t.updatedAt)}],paginate:_(b(e)?void 0:{start_after:_(e.startAfter),limit:_(b(e.limit)?void 0:BigInt(e.limit))}),order:_(b(s)?void 0:{desc:s.desc,field:s.field==="created_at"?{CreatedAt:null}:s.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:_(b(o)?void 0:typeof o=="string"?Ce.fromText(o):o)});import{assertNonNullish as Fe}from"@dfinity/utils";var bt=({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.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),o=t.Record({field:s,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),n=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),r=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(o),owner:t.Opt(t.Principal),matcher:t.Opt(n),paginate:t.Opt(r)}),p=t.Record({controllers:t.Vec(t.Principal)}),f=t.Variant({Write:t.Null,Admin:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:f,expires_at:t.Opt(t.Nat64)}),y=t.Record({version:t.Opt(t.Nat64)}),m=t.Variant({Db:t.Null,Storage:t.Null}),O=t.Record({version:t.Opt(t.Nat64)}),x=t.Record({cycles:t.Nat,destination_id:t.Principal}),T=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}),R=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),u=t.Record({key:T,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,R)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),P=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),k=t.Record({internet_identity:t.Opt(P)}),V=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),C=t.Record({max_memory_size:t.Opt(V)}),le=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),pe=t.Variant({Deny:t.Null,Allow:t.Null}),de=t.Record({status_code:t.Nat16,location:t.Text}),Z=t.Record({iframe:t.Opt(le),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(V),raw_access:t.Opt(pe),redirects:t.Opt(t.Vec(t.Tuple(t.Text,de)))}),ue=t.Record({db:t.Opt(C),authentication:t.Opt(k),storage:Z}),F=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)}),D=t.Variant({Heap:t.Null,Stable:t.Null}),j=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),yt=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),I=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(D),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:j,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(yt),write:j,max_changes_per_user:t.Opt(t.Nat32)}),me=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)}),L=t.Record({memory:D,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}),ye=t.Variant({Callback:t.Record({token:L,callback:t.Func([],[],["query"])})}),fe=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(ye),status_code:t.Nat16}),_e=t.Record({token:t.Opt(L),body:t.Vec(t.Nat8)}),ge=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}),Ae=t.Record({batch_id:t.Nat}),Te=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,u)),items_length:t.Nat64}),he=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Oe=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,F)),items_length:t.Nat64}),xe=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),Re=t.Record({controller:xe,controllers:t.Vec(t.Principal)}),ft=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Ne=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(D),max_size:t.Opt(t.Nat),read:j,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(yt),write:j,max_changes_per_user:t.Opt(t.Nat32)}),Pe=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),Se=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[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,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([p],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,y],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,a],[],[]),del_filtered_docs:t.Func([t.Text,a],[],[]),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,y))],[],[]),del_rule:t.Func([m,t.Text,O],[],[]),deposit_cycles:t.Func([x],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(u)],["query"]),get_auth_config:t.Func([],[t.Opt(k)],["query"]),get_config:t.Func([],[ue],[]),get_db_config:t.Func([],[t.Opt(C)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(F)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(u)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(F)))],["query"]),get_rule:t.Func([m,t.Text],[t.Opt(I)],["query"]),get_storage_config:t.Func([],[Z],["query"]),http_request:t.Func([me],[fe],["query"]),http_request_streaming_callback:t.Func([L],[_e],["query"]),init_asset_upload:t.Func([ge],[Ae],[]),list_assets:t.Func([t.Text,a],[Te],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,he))],["query"]),list_docs:t.Func([t.Text,a],[Oe],["query"]),list_rules:t.Func([m],[t.Vec(t.Tuple(t.Text,I))],["query"]),set_auth_config:t.Func([k],[],[]),set_controllers:t.Func([Re],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([C],[],[]),set_doc:t.Func([t.Text,t.Text,ft],[F],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,ft))],[t.Vec(t.Tuple(t.Text,F))],[]),set_rule:t.Func([m,t.Text,Ne],[I],[]),set_storage_config:t.Func([Z],[],[]),upload_asset_chunk:t.Func([Pe],[Se],[])})};import{nonNullish as lt}from"@dfinity/utils";var Ut=({satelliteId:t,container:e})=>{let{satelliteId:s}=pt({satelliteId:t}),{container:o}=dt({container:e});if(lt(o)&&o!==!1){let{host:i,protocol:n}=new URL(o===!0?E:o);return`${n}//${s??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${s??"unknown"}.icp0.io`},pt=({satelliteId:t})=>lt(t)?{satelliteId:t}:g.getInstance().get()??{satelliteId:void 0},dt=({container:t})=>lt(t)?{container:t}:g.getInstance().get()??{container:void 0};var l=t=>Ct({idlFactory:bt,buildType:"stock",...t}),kt=({idlFactory:t,...e})=>Ct({idlFactory:t,buildType:"extended",...e}),Ct=async({satelliteId:t,container:e,...s})=>{let{satelliteId:o}=pt({satelliteId:t});Fe(o,"No satellite ID defined. Did you initialize Juno?");let{container:i}=dt({container:e});return await v.getInstance().getActor({satelliteId:o,container:i,...s})};var Ft=async({collection:t,key:e,satellite:s})=>{let{get_doc:o}=await l(s),i=U(await o(t,e));if(!Me(i))return M({doc:i,key:e})},Mt=async({docs:t,satellite:e})=>{let{get_many_docs:s}=await l(e),o=t.map(({collection:r,key:a})=>[r,a]),i=await s(o),n=[];for(let[r,a]of i){let p=U(a);n.push(Ve(p)?await M({key:r,doc:p}):void 0)}return n},Vt=async({collection:t,doc:e,satellite:s})=>{let{set_doc:o}=await l(s),{key:i}=e,n=await at(e),r=await o(t,i,n);return await M({key:i,doc:r})},jt=async({docs:t,satellite:e})=>{let{set_many_docs:s}=await l(e),o=[];for(let{collection:r,doc:a}of t){let{key:p}=a;o.push([r,p,await at(a)])}let i=await s(o),n=[];for(let[r,a]of i)n.push(await M({key:r,doc:a}));return n},Kt=async({collection:t,doc:e,satellite:s})=>{let{del_doc:o}=await l(s),{key:i}=e;return o(t,i,ct(e))},qt=async({docs:t,satellite:e})=>{let{del_many_docs:s}=await l(e),o=t.map(({collection:i,doc:n})=>[i,n.key,ct(n)]);await s(o)},Bt=async({collection:t,filter:e,satellite:s})=>{let{del_filtered_docs:o}=await l(s);return o(t,N(e))},Jt=async({collection:t,filter:e,satellite:s})=>{let{list_docs:o}=await l(s),{items:i,items_page:n,items_length:r,matches_length:a,matches_pages:p}=await o(t,N(e)),f=[];for(let[d,y]of i){let{data:m,owner:O,description:x,version:T,...R}=y;f.push({key:d,description:U(x),owner:O.toText(),data:await Et({data:m}),version:U(T),...R})}return{items:f,items_length:r,items_page:U(n),matches_length:a,matches_pages:U(p)}},$t=async({collection:t,filter:e,satellite:s})=>{let{count_docs:o}=await l(s);return o(t,N(e))};import{AnonymousIdentity as je}from"@dfinity/agent";var c=t=>t!==void 0?t:Y()??new je;var Ht=async({satellite:t,...e})=>{let s=c(t?.identity);return await Ft({...e,satellite:{...t,identity:s}})},vo=async({satellite:t,...e})=>{let s=c(t?.identity);return await Mt({...e,satellite:{...t,identity:s}})},Gt=async({satellite:t,...e})=>{let s=c(t?.identity);return await Vt({...e,satellite:{...t,identity:s}})},bo=async({satellite:t,...e})=>{let s=c(t?.identity);return await jt({...e,satellite:{...t,identity:s}})},Uo=async({satellite:t,...e})=>{let s=c(t?.identity);return await Kt({...e,satellite:{...t,identity:s}})},ko=async({satellite:t,...e})=>{let s=c(t?.identity);return await qt({...e,satellite:{...t,identity:s}})},Co=async({satellite:t,filter:e,...s})=>{let o=c(t?.identity);return await Bt({...s,filter:e??{},satellite:{...t,identity:o}})},Fo=async({satellite:t,filter:e,...s})=>{let o=c(t?.identity);return await Jt({...s,filter:e??{},satellite:{...t,identity:o}})},Mo=async({satellite:t,filter:e,...s})=>{let o=c(t?.identity);return await $t({...s,filter:e??{},satellite:{...t,identity:o}})};var zt=async t=>{let e=Y();if(Ke(e))throw new G("No identity to initialize the user. Have you initialized Juno?");let s=e.getPrincipal().toText(),o=()=>Ht({collection:"#user",key:s}),i=await o();if(Wt(i))return i;try{return await qe({userId:s,provider:t})}catch(n){if(nt({error:n,type:it})){let r=await o();if(Wt(r))return r}throw n}},qe=({userId:t,...e})=>Gt({collection:"#user",doc:{key:t,data:e}});var A,ut=async t=>{if(A=A??await z(),!(await A?.isAuthenticated()??!1))return;let s=await zt(t);h.getInstance().set(s)},$e=t=>new Promise(async(e,s)=>{if(Je(A)){s(new $("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let o=t?.provider??new B({});await A.login({onSuccess:async()=>{await ut(o.id),e()},onError:i=>{if(i===Be){s(new H(i));return}s(new J(i))},maxTimeToLive:t?.maxTimeToLive??_t,allowPinAuthentication:t?.allowPin??gt,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...o.signInOptions({windowed:t?.windowed})})}),mt=async()=>{await A?.logout(),A=null,h.getInstance().reset(),v.getInstance().reset(),w.getInstance().reset(),A=await z()},Y=()=>A?.getIdentity(),He=async()=>(A??await z()).getIdentity();var Yt=t=>{let e=t===!0?"./workers/auth.worker.js":t,s=new Worker(e),o=async()=>{tt({message:"junoSignOutAuthTimer"}),await mt()};return s.onmessage=async({data:i})=>{let{msg:n,data:r}=i;switch(n){case"junoSignOutAuthTimer":await o();return;case"junoDelegationRemainingTime":tt({message:"junoDelegationRemainingTime",detail:r?.authRemainingTime});return}},h.getInstance().subscribe(i=>{if(Ge(i)){s.postMessage({msg:"junoStopAuthTimer"});return}s.postMessage({msg:"junoStartAuthTimer"})})};var Xt=()=>{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()},Qt=()=>{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 ci=async({idlFactory:t,satellite:e})=>{let s=c(e?.identity);return await kt({idlFactory:t,...e,identity:s})};import{fromNullable as re,nonNullish as Ye}from"@dfinity/utils";import{fromNullable as Q}from"@dfinity/utils";import{toNullable as X}from"@dfinity/utils";var Zt=async({asset:{data:t,filename:e,collection:s,headers:o,token:i,fullPath:n,encoding:r,description:a},actor:p,init_asset_upload:f})=>{let{batch_id:d}=await f({collection:s,full_path:n,name:e,token:X(i),encoding_type:X(r),description:X(a)}),y=19e5,m=[],O=q()?new Blob([await t.arrayBuffer()]):t,x=0n;for(let u=0;u<O.size;u+=y){let P=O.slice(u,u+y);m.push({batchId:d,chunk:P,actor:p,orderId:x}),x++}let T=[];for await(let u of We({uploadChunks:m}))T=[...T,...u];let R=o.find(([u,P])=>u.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await p.commit_asset_upload({batch_id:d,chunk_ids:T.map(({chunk_id:u})=>u),headers:[...o,...R??[]]})};async function*We({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=>ze(i)))}}var ze=async({batchId:t,chunk:e,actor:s,orderId:o})=>s.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:X(o)});var Dt=async({satellite:t,...e})=>{let s=await l(t);await Zt({actor:s,asset:e,init_asset_upload:async i=>await s.init_asset_upload(i)})},It=async({collection:t,satellite:e,filter:s})=>{let{list_assets:o}=await l(e),{items:i,items_length:n,items_page:r,matches_length:a,matches_pages:p}=await o(t,N(s));return{items:i.map(([f,d])=>d),items_length:n,items_page:Q(r),matches_length:a,matches_pages:Q(p)}},Lt=async({collection:t,satellite:e,filter:s})=>{let{count_assets:o}=await l(e);return o(t,N(s))},te=async({collection:t,fullPath:e,satellite:s})=>(await l(s)).del_asset(t,e),ee=async({assets:t,satellite:e})=>{let{del_many_assets:s}=await l(e),o=t.map(({collection:i,fullPath:n})=>[i,n]);await s(o)},se=async({collection:t,satellite:e,filter:s})=>{let{del_filtered_assets:o}=await l(e);return o(t,N(s))},oe=async({collection:t,fullPath:e,satellite:s})=>{let{get_asset:o}=await l(s);return Q(await o(t,e))},ie=async({assets:t,satellite:e})=>{let{get_many_assets:s}=await l(e),o=t.map(({collection:n,fullPath:r})=>[n,r]);return(await s(o)).map(([n,r])=>Q(r))};var ne=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Ni=t=>ae(t),Pi=t=>ae({filename:t.data.name,...t}),ae=async({filename:t,data:e,collection:s,headers:o=[],fullPath:i,token:n,satellite:r,encoding:a,description:p})=>{let f=c(r?.identity),d=decodeURI(t),y=i??`/${s}/${d}`,m={...r,identity:f};return await Dt({data:e,filename:d,collection:s,token:n,headers:o,fullPath:y,encoding:a,satellite:m,description:p}),{downloadUrl:ce({satellite:m,assetKey:{fullPath:y,token:n}}),fullPath:y,name:d}},Si=async({collection:t,satellite:e,filter:s})=>{let o={...e,identity:c(e?.identity)},{items:i,...n}=await It({collection:t,satellite:o,filter:s??{}}),r=i.map(({key:{full_path:a,token:p,name:f,owner:d,description:y},headers:m,encodings:O,created_at:x,updated_at:T})=>{let R=re(p);return{fullPath:a,description:re(y),name:f,downloadUrl:ce({satellite:o,assetKey:{fullPath:a,token:R}}),token:R,headers:m,encodings:O.reduce((u,[P,{modified:k,sha256:V,total_length:C}])=>({...u,[P]:{modified:k,sha256:ne(V),total_length:C}}),{}),owner:d.toText(),created_at:x,updated_at:T}});return{items:r,assets:r,...n}},Ei=async({collection:t,satellite:e,filter:s})=>{let o={...e,identity:c(e?.identity)};return await Lt({collection:t,satellite:o,filter:s??{}})},wi=({collection:t,fullPath:e,satellite:s})=>te({collection:t,fullPath:e,satellite:{...s,identity:c(s?.identity)}}),vi=({assets:t,satellite:e})=>ee({assets:t,satellite:{...e,identity:c(e?.identity)}}),bi=async({collection:t,satellite:e,filter:s})=>{let o={...e,identity:c(e?.identity)};return await se({collection:t,satellite:o,filter:s??{}})},Ui=async({satellite:t,...e})=>{let s=c(t?.identity);return await oe({...e,satellite:{...t,identity:s}})},ki=async({satellite:t,...e})=>{let s=c(t?.identity);return await ie({...e,satellite:{...t,identity:s}})},ce=({assetKey:{fullPath:t,token:e},satellite:s})=>{let o={...s,identity:c(s?.identity)};return`${Ut(o)}${t}${Ye(e)?`?token=${e}`:""}`};var Qe=t=>{let e=t?.satelliteId??Xt();Xe(e,"Satellite ID is not configured. Juno cannot be initialized.");let s=t?.container??Qt();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:s}},Bi=t=>Ze(t),Ze=async t=>{let e=Qe(t);g.getInstance().set(e),await ut();let s=e.workers?.auth!==void 0?Yt(e.workers.auth):void 0;return[...s?[s]:[]]},Ji=t=>h.getInstance().subscribe(t);export{G as InitError,B as InternetIdentityProvider,W as ListError,Pt as NFIDProvider,J as SignInError,$ as SignInInitError,H as SignInUserInterruptError,Ji as authSubscribe,Ei as countAssets,Mo as countDocs,wi as deleteAsset,Uo as deleteDoc,bi as deleteFilteredAssets,Co as deleteFilteredDocs,vi as deleteManyAssets,ko as deleteManyDocs,ce as downloadUrl,Ui as getAsset,Ht as getDoc,ki as getManyAssets,vo as getManyDocs,ci as getSatelliteExtendedActor,Bi as initJuno,Ze as initSatellite,Si as listAssets,Fo as listDocs,Gt as setDoc,bo as setManyDocs,$e as signIn,mt as signOut,He as unsafeIdentity,Ni as uploadBlob,Pi as uploadFile};
|
|
4
4
|
//# sourceMappingURL=index.mjs.map
|