@junobuild/core-peer 0.1.17 → 1.0.0
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 +4 -4
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/api/_actor.factory.d.ts +5 -0
- package/dist/types/api/actor.api.d.ts +9 -6
- package/dist/types/api/doc.api.d.ts +21 -30
- package/dist/types/api/storage.api.d.ts +18 -25
- package/dist/types/constants/call-options.constants.d.ts +9 -0
- package/dist/types/index.d.ts +12 -12
- package/dist/types/providers/auth.providers.d.ts +1 -1
- package/dist/types/services/_identity.services.d.ts +2 -0
- package/dist/types/services/{user.services.d.ts → _user.services.d.ts} +1 -1
- package/dist/types/services/auth-timout.services.d.ts +2 -2
- package/dist/types/services/auth.services.d.ts +5 -1
- package/dist/types/services/doc.services.d.ts +33 -17
- package/dist/types/services/functions.services.d.ts +26 -0
- package/dist/types/services/storage.services.d.ts +36 -21
- package/dist/types/stores/_agent.factory.d.ts +4 -0
- package/dist/types/stores/actor.store.d.ts +5 -5
- package/dist/types/stores/agent.store.d.ts +3 -6
- package/dist/types/stores/auth.store.d.ts +3 -3
- package/dist/types/stores/env.store.d.ts +4 -3
- package/dist/types/types/actor.d.ts +51 -0
- package/dist/types/types/{auth.types.d.ts → auth.d.ts} +1 -1
- package/dist/types/types/call-options.d.ts +43 -0
- package/dist/types/types/{doc.types.d.ts → doc.d.ts} +1 -1
- package/dist/types/types/{env.types.d.ts → env.d.ts} +3 -3
- package/dist/types/types/satellite.d.ts +40 -0
- package/dist/types/types/storage.types.d.ts +1 -1
- package/dist/types/utils/doc.utils.d.ts +1 -1
- package/dist/types/utils/env.utils.d.ts +4 -4
- package/dist/types/utils/list.utils.d.ts +1 -1
- package/dist/types/workers/_auth.worker.handler.d.ts +11 -0
- package/dist/types/workers/auth.worker.d.ts +1 -5
- package/dist/workers/_auth.worker.handler.js +43 -0
- package/dist/workers/_auth.worker.handler.js.map +7 -0
- package/dist/workers/auth.worker.js +7 -7
- package/dist/workers/auth.worker.js.map +4 -4
- package/package.json +2 -2
- package/dist/types/services/factory.services.d.ts +0 -8
- package/dist/types/services/identity.services.d.ts +0 -2
- package/dist/types/types/build.types.d.ts +0 -5
- package/dist/types/types/satellite.types.d.ts +0 -27
- /package/dist/types/stores/{store.d.ts → _store.d.ts} +0 -0
- /package/dist/types/types/{errors.types.d.ts → errors.d.ts} +0 -0
- /package/dist/types/types/{list.types.d.ts → list.d.ts} +0 -0
- /package/dist/types/types/{subscription.types.d.ts → subscription.d.ts} +0 -0
- /package/dist/types/types/{utility.types.d.ts → utility.d.ts} +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
3
|
-
type AgentParams = Required<Pick<Satellite, 'identity'>> & Pick<Satellite, 'container'>;
|
|
1
|
+
import type { Agent } from '@dfinity/agent';
|
|
2
|
+
import { type CreateAgentParams } from './_agent.factory';
|
|
4
3
|
export declare class AgentStore {
|
|
5
4
|
#private;
|
|
6
5
|
private static instance;
|
|
7
6
|
private constructor();
|
|
8
7
|
static getInstance(): AgentStore;
|
|
9
|
-
getAgent({ identity, ...rest }:
|
|
8
|
+
getAgent({ identity, ...rest }: CreateAgentParams): Promise<Agent>;
|
|
10
9
|
reset(): void;
|
|
11
|
-
private createAgent;
|
|
12
10
|
}
|
|
13
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { User } from '../types/auth
|
|
2
|
-
import type { Unsubscribe } from '../types/subscription
|
|
3
|
-
import { Store } from './
|
|
1
|
+
import type { User } from '../types/auth';
|
|
2
|
+
import type { Unsubscribe } from '../types/subscription';
|
|
3
|
+
import { Store } from './_store';
|
|
4
4
|
export declare class AuthStore extends Store<User | null> {
|
|
5
5
|
private static instance;
|
|
6
6
|
private authUser;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { Environment } from '../types/env
|
|
2
|
-
import { Store } from './
|
|
1
|
+
import type { Environment } from '../types/env';
|
|
2
|
+
import { Store } from './_store';
|
|
3
3
|
export declare class EnvStore extends Store<Environment | undefined> {
|
|
4
4
|
private static instance;
|
|
5
5
|
private env;
|
|
6
6
|
private constructor();
|
|
7
7
|
static getInstance(): EnvStore;
|
|
8
8
|
set(env: Environment | undefined): void;
|
|
9
|
-
get(): Environment | undefined;
|
|
9
|
+
get(): Environment | undefined | null;
|
|
10
|
+
reset(): void;
|
|
10
11
|
subscribe(callback: (data: Environment | null | undefined) => void): () => void;
|
|
11
12
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ReadOptions, UpdateOptions } from './call-options';
|
|
2
|
+
import type { SatelliteContext } from './satellite';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the type of build.
|
|
5
|
+
* @typedef {'stock' | 'extended'} BuildType
|
|
6
|
+
*/
|
|
7
|
+
export type BuildType = 'stock' | 'extended';
|
|
8
|
+
/**
|
|
9
|
+
* Represents how read calls are handled by the actor.
|
|
10
|
+
*
|
|
11
|
+
* - `'update'`: Query endpoints are implemented as update calls to ensure certification.
|
|
12
|
+
* - `'query'`: Query endpoints use standard query calls without certification.
|
|
13
|
+
*
|
|
14
|
+
* @typedef {'update' | 'query'} ActorReadStrategy
|
|
15
|
+
*/
|
|
16
|
+
export type ActorReadStrategy = 'update' | 'query';
|
|
17
|
+
/**
|
|
18
|
+
* Represents a unique key that identifies an actor configuration.
|
|
19
|
+
* Combines the build type and the read strategy.
|
|
20
|
+
*
|
|
21
|
+
* Example values:
|
|
22
|
+
* - `'stock#update'`
|
|
23
|
+
* - `'extended#query'`
|
|
24
|
+
*
|
|
25
|
+
* @typedef {`${BuildType}#${ActorReadStrategy}`} ActorKey
|
|
26
|
+
*/
|
|
27
|
+
export type ActorKey = `${BuildType}#${ActorReadStrategy}`;
|
|
28
|
+
/**
|
|
29
|
+
* Parameters required to perform a read call using an actor.
|
|
30
|
+
*
|
|
31
|
+
* @property {SatelliteContext} satellite - The satellite configuration.
|
|
32
|
+
* @property {ReadOptions} options - Options controlling read call behavior, such as certification.
|
|
33
|
+
*
|
|
34
|
+
* @interface
|
|
35
|
+
*/
|
|
36
|
+
export interface ActorReadParams {
|
|
37
|
+
satellite: SatelliteContext;
|
|
38
|
+
options: ReadOptions;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parameters required to perform an update call using an actor.
|
|
42
|
+
*
|
|
43
|
+
* @property {SatelliteContext} satellite - The satellite connection configuration.
|
|
44
|
+
* @property {UpdateOptions} options - Options controlling update call behavior. Certification is always enforced.
|
|
45
|
+
*
|
|
46
|
+
* @interface
|
|
47
|
+
*/
|
|
48
|
+
export interface ActorUpdateParams {
|
|
49
|
+
satellite: SatelliteContext;
|
|
50
|
+
options: UpdateOptions;
|
|
51
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InternetIdentityProvider, NFIDProvider } from '../providers/auth.providers';
|
|
2
|
-
import type { Doc } from './doc
|
|
2
|
+
import type { Doc } from './doc';
|
|
3
3
|
/**
|
|
4
4
|
* Type representing the available authentication providers.
|
|
5
5
|
* @typedef {('internet_identity' | 'nfid')} Provider
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options that control the behavior of update call operations.
|
|
3
|
+
*
|
|
4
|
+
* Update calls on the Internet Computer are always certified.
|
|
5
|
+
* This type enforces that `certified` is always `true` and exists
|
|
6
|
+
* for consistency across all call-related configurations.
|
|
7
|
+
*
|
|
8
|
+
* @interface
|
|
9
|
+
*/
|
|
10
|
+
export interface UpdateOptions {
|
|
11
|
+
/**
|
|
12
|
+
* For update calls: always `true`.
|
|
13
|
+
* Certification is enforced by the Internet Computer protocol.
|
|
14
|
+
*
|
|
15
|
+
* @type {true}
|
|
16
|
+
*/
|
|
17
|
+
certified: true;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Options that control the behavior of read call operations.
|
|
21
|
+
*
|
|
22
|
+
* These options apply to methods that perform read calls,
|
|
23
|
+
* such as datastore queries or asset retrievals.
|
|
24
|
+
*/
|
|
25
|
+
export interface ReadOptions {
|
|
26
|
+
/**
|
|
27
|
+
* If true, performs read operations using certified calls.
|
|
28
|
+
* Certified calls provide cryptographic proof that the data is verified by the Internet Computer.
|
|
29
|
+
* This ensures data integrity but may increase latency compared to regular (non-certified) query calls.
|
|
30
|
+
*
|
|
31
|
+
* Defaults to false.
|
|
32
|
+
*
|
|
33
|
+
* @type {boolean}
|
|
34
|
+
* @optional
|
|
35
|
+
*/
|
|
36
|
+
certified?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Union type representing call options for both read and update operations.
|
|
40
|
+
*
|
|
41
|
+
* @typedef {UpdateOptions | ReadOptions} CallOptions
|
|
42
|
+
*/
|
|
43
|
+
export type CallOptions = UpdateOptions | ReadOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SatelliteContext } from './satellite';
|
|
2
2
|
/**
|
|
3
3
|
* Represents the path to a web worker.
|
|
4
4
|
* @typedef {string} EnvironmentWorkerPath
|
|
@@ -31,7 +31,7 @@ export interface EnvironmentWorkers {
|
|
|
31
31
|
export type Environment = {
|
|
32
32
|
internetIdentityId?: string;
|
|
33
33
|
workers?: EnvironmentWorkers;
|
|
34
|
-
} & Required<Pick<
|
|
34
|
+
} & Required<Pick<SatelliteContext, 'satelliteId'>> & Pick<SatelliteContext, 'container'>;
|
|
35
35
|
/**
|
|
36
36
|
* Represents the user environment configuration. i.e. the optional parameters the user is providing to initialize Juno.
|
|
37
37
|
* @typedef {Object} UserEnvironment
|
|
@@ -40,4 +40,4 @@ export type Environment = {
|
|
|
40
40
|
* @property {string} satelliteId - An optional satellite ID. If not provided, the library tries to load the information injected by the Vite and NextJS plugins.
|
|
41
41
|
* @property {string} [container] - The container. If not provided, the library tries to load the information injected by the Vite and NextJS plugins.
|
|
42
42
|
*/
|
|
43
|
-
export type UserEnvironment = Omit<Environment, 'satelliteId'> & Pick<
|
|
43
|
+
export type UserEnvironment = Omit<Environment, 'satelliteId'> & Pick<SatelliteContext, 'satelliteId'>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Identity } from '@dfinity/agent';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for connecting to a satellite.
|
|
4
|
+
* @interface
|
|
5
|
+
*/
|
|
6
|
+
export interface SatelliteContext {
|
|
7
|
+
/**
|
|
8
|
+
* The identity used to authenticate with the satellite.
|
|
9
|
+
* Typically derived from Internet Identity or another supported identity type.
|
|
10
|
+
*
|
|
11
|
+
* @type {Identity}
|
|
12
|
+
*/
|
|
13
|
+
identity: Identity;
|
|
14
|
+
/**
|
|
15
|
+
* The unique ID of the satellite to interact with.
|
|
16
|
+
* If not provided, attempts to use one defined in environment variables.
|
|
17
|
+
* If ultimately none is available, the call will fail.
|
|
18
|
+
*
|
|
19
|
+
* @type {string}
|
|
20
|
+
* @optional
|
|
21
|
+
*/
|
|
22
|
+
satelliteId?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Indicates if the satellite is running in a local container, or provides the container URL.
|
|
25
|
+
* - If `true`, connects to the default local container (for development).
|
|
26
|
+
* - If a string, specifies the full container URL (e.g., "http://localhost:4943").
|
|
27
|
+
* - If not set, connects to the production satellite.
|
|
28
|
+
*
|
|
29
|
+
* @type {boolean | string}
|
|
30
|
+
* @optional
|
|
31
|
+
*/
|
|
32
|
+
container?: boolean | string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Represents partial configuration options for connecting to a satellite.
|
|
36
|
+
* Typically used in Node.js environments or for advanced configuration scenarios in the browser.
|
|
37
|
+
*
|
|
38
|
+
* @typedef {Partial<SatelliteContext>} SatelliteOptions
|
|
39
|
+
*/
|
|
40
|
+
export type SatelliteOptions = Partial<SatelliteContext>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Asset } from '@junobuild/storage';
|
|
2
2
|
import type { AssetNoContent } from '../../declarations/satellite/satellite.did';
|
|
3
|
-
import type { ListResults } from './list
|
|
3
|
+
import type { ListResults } from './list';
|
|
4
4
|
/**
|
|
5
5
|
* Represents a collection of assets with pagination details.
|
|
6
6
|
* @interface
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DelDoc, Doc as DocApi, SetDoc } from '../../declarations/satellite/satellite.did';
|
|
2
|
-
import type { Doc } from '../types/doc
|
|
2
|
+
import type { Doc } from '../types/doc';
|
|
3
3
|
export declare const toSetDoc: <D>(doc: Doc<D>) => Promise<SetDoc>;
|
|
4
4
|
export declare const toDelDoc: <D>(doc: Doc<D>) => DelDoc;
|
|
5
5
|
export declare const fromDoc: <D>({ doc, key }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const satelliteUrl: ({ satelliteId: customSatelliteId, container: customContainer }:
|
|
3
|
-
export declare const customOrEnvSatelliteId: ({ satelliteId }: Pick<
|
|
4
|
-
export declare const customOrEnvContainer: ({ container: customContainer }: Pick<
|
|
1
|
+
import type { SatelliteContext } from '../types/satellite';
|
|
2
|
+
export declare const satelliteUrl: ({ satelliteId: customSatelliteId, container: customContainer }: SatelliteContext) => string;
|
|
3
|
+
export declare const customOrEnvSatelliteId: ({ satelliteId }: Pick<SatelliteContext, "satelliteId">) => Pick<SatelliteContext, "satelliteId">;
|
|
4
|
+
export declare const customOrEnvContainer: ({ container: customContainer }: Pick<SatelliteContext, "container">) => Pick<SatelliteContext, "container">;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ListParams as ListParamsApi } from '../../declarations/satellite/satellite.did';
|
|
2
|
-
import type { ListParams } from '../types/list
|
|
2
|
+
import type { ListParams } from '../types/list';
|
|
3
3
|
export declare const toListParams: ({ matcher, paginate, order, owner }: ListParams) => ListParamsApi;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PostMessage, PostMessageDataRequest } from '../types/post-message';
|
|
2
|
+
export declare const onAuthMessage: ({ data }: MessageEvent<PostMessage<PostMessageDataRequest>>) => void;
|
|
3
|
+
/**
|
|
4
|
+
* The timer is executed only if user has signed in
|
|
5
|
+
*/
|
|
6
|
+
export declare const startTimer: () => NodeJS.Timeout;
|
|
7
|
+
export declare const stopTimer: () => void;
|
|
8
|
+
/**
|
|
9
|
+
* ℹ️ Exported for test purpose only.
|
|
10
|
+
*/
|
|
11
|
+
export declare const onTimerSignOut: () => Promise<void>;
|