@junobuild/core-standalone 0.1.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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/dist/browser/canisterStatus-MTFHSECX.js +2 -0
  4. package/dist/browser/canisterStatus-MTFHSECX.js.map +7 -0
  5. package/dist/browser/chunk-F6RH4LLT.js +69 -0
  6. package/dist/browser/chunk-F6RH4LLT.js.map +7 -0
  7. package/dist/browser/index.js +26 -0
  8. package/dist/browser/index.js.map +7 -0
  9. package/dist/declarations/deprecated/mission_control-0-0-4.did.d.ts +80 -0
  10. package/dist/declarations/deprecated/mission_control-0-0-4.factory.did.js +99 -0
  11. package/dist/declarations/deprecated/satellite-0-0-8.did.d.ts +183 -0
  12. package/dist/declarations/deprecated/satellite-0-0-8.factory.did.js +194 -0
  13. package/dist/declarations/deprecated/satellite-0-0-9.did.d.ts +199 -0
  14. package/dist/declarations/deprecated/satellite-0-0-9.factory.did.js +213 -0
  15. package/dist/declarations/satellite/satellite.did.d.ts +288 -0
  16. package/dist/declarations/satellite/satellite.factory.did.js +316 -0
  17. package/dist/declarations/satellite/satellite.factory.did.mjs +316 -0
  18. package/dist/index.js +1 -0
  19. package/dist/node/index.mjs +104 -0
  20. package/dist/node/index.mjs.map +7 -0
  21. package/dist/types/api/actor.api.d.ts +9 -0
  22. package/dist/types/api/doc.api.d.ts +52 -0
  23. package/dist/types/api/storage.api.d.ts +42 -0
  24. package/dist/types/constants/auth.constants.d.ts +12 -0
  25. package/dist/types/constants/container.constants.d.ts +2 -0
  26. package/dist/types/index.d.ts +38 -0
  27. package/dist/types/providers/auth.providers.d.ts +79 -0
  28. package/dist/types/services/auth-timout.services.d.ts +3 -0
  29. package/dist/types/services/auth.services.d.ts +23 -0
  30. package/dist/types/services/doc.services.d.ts +127 -0
  31. package/dist/types/services/factory.services.d.ts +8 -0
  32. package/dist/types/services/identity.services.d.ts +2 -0
  33. package/dist/types/services/storage.services.d.ts +130 -0
  34. package/dist/types/services/user.services.d.ts +2 -0
  35. package/dist/types/stores/actor.store.d.ts +21 -0
  36. package/dist/types/stores/agent.store.d.ts +13 -0
  37. package/dist/types/stores/auth.store.d.ts +13 -0
  38. package/dist/types/stores/env.store.d.ts +11 -0
  39. package/dist/types/stores/store.d.ts +5 -0
  40. package/dist/types/types/auth.types.d.ts +90 -0
  41. package/dist/types/types/build.types.d.ts +5 -0
  42. package/dist/types/types/doc.types.d.ts +42 -0
  43. package/dist/types/types/env.types.d.ts +43 -0
  44. package/dist/types/types/list.types.d.ts +170 -0
  45. package/dist/types/types/post-message.d.ts +11 -0
  46. package/dist/types/types/satellite.types.d.ts +32 -0
  47. package/dist/types/types/storage.types.d.ts +21 -0
  48. package/dist/types/types/subscription.types.d.ts +6 -0
  49. package/dist/types/utils/auth.utils.d.ts +2 -0
  50. package/dist/types/utils/crypto.utils.d.ts +1 -0
  51. package/dist/types/utils/data.utils.d.ts +2 -0
  52. package/dist/types/utils/doc.utils.d.ts +8 -0
  53. package/dist/types/utils/env.utils.d.ts +4 -0
  54. package/dist/types/utils/events.utils.d.ts +4 -0
  55. package/dist/types/utils/list.utils.d.ts +3 -0
  56. package/dist/types/utils/window.env.utils.d.ts +2 -0
  57. package/dist/types/utils/window.utils.d.ts +4 -0
  58. package/dist/types/workers/auth.worker.d.ts +5 -0
  59. package/dist/workers/auth.worker.js +58 -0
  60. package/dist/workers/auth.worker.js.map +7 -0
  61. package/package.json +64 -0
@@ -0,0 +1,90 @@
1
+ import type { InternetIdentityProvider, NFIDProvider } from '../providers/auth.providers';
2
+ import type { Doc } from './doc.types';
3
+ /**
4
+ * Type representing the available authentication providers.
5
+ * @typedef {('internet_identity' | 'nfid')} Provider
6
+ */
7
+ export type Provider = 'internet_identity' | 'nfid';
8
+ /**
9
+ * Interface representing user data.
10
+ * @interface UserData
11
+ */
12
+ export interface UserData {
13
+ /**
14
+ * The potential provider used to sign-in. There is no guarantee that the information can be set by the browser during the sign-in flow, therefore it is optional.
15
+ * @type {Provider}
16
+ */
17
+ provider?: Provider;
18
+ }
19
+ /**
20
+ * Type representing a user document.
21
+ * @typedef {Doc<UserData>} User
22
+ */
23
+ export type User = Doc<UserData>;
24
+ /**
25
+ * Interface representing sign-in options.
26
+ * @interface SignInOptions
27
+ */
28
+ export interface SignInOptions {
29
+ /**
30
+ * Maximum time to live for the session. Cannot be extended.
31
+ * @type {bigint}
32
+ */
33
+ maxTimeToLive?: bigint;
34
+ /**
35
+ * Origin for derivation. Useful when sign-in using the same domain - e.g. sign-in on www.hello.com for hello.com.
36
+ * @type {(string | URL)}
37
+ */
38
+ derivationOrigin?: string | URL;
39
+ /**
40
+ * Whether to open the sign-in window.
41
+ * @default true
42
+ * @type {boolean}
43
+ */
44
+ windowed?: boolean;
45
+ /**
46
+ * Whether to allow the infamous PIN authentication.
47
+ * @default false
48
+ * @type {boolean}
49
+ */
50
+ allowPin?: boolean;
51
+ /**
52
+ * The authentication provider to use.
53
+ * @default InternetIdentityProvider
54
+ * @type {(InternetIdentityProvider | NFIDProvider)}
55
+ */
56
+ provider?: InternetIdentityProvider | NFIDProvider;
57
+ }
58
+ /**
59
+ * Type representing the available Internet Identity domains.
60
+ * @typedef {('internetcomputer.org' | 'ic0.app')} InternetIdentityDomain
61
+ */
62
+ export type InternetIdentityDomain = 'internetcomputer.org' | 'ic0.app';
63
+ /**
64
+ * Interface representing the configuration for Internet Identity.
65
+ * @interface InternetIdentityConfig
66
+ */
67
+ export interface InternetIdentityConfig {
68
+ /**
69
+ * The domain for Internet Identity.
70
+ * @default internetcomputer.org
71
+ * @type {InternetIdentityDomain}
72
+ */
73
+ domain?: InternetIdentityDomain;
74
+ }
75
+ /**
76
+ * Interface representing the configuration for NFID.
77
+ * @interface NFIDConfig
78
+ */
79
+ export interface NFIDConfig {
80
+ /**
81
+ * The name of the application.
82
+ * @type {string}
83
+ */
84
+ appName: string;
85
+ /**
86
+ * The URL of the application's logo.
87
+ * @type {string}
88
+ */
89
+ logoUrl: string;
90
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Represents the type of build.
3
+ * @typedef {'stock' | 'extended'} BuildType
4
+ */
5
+ export type BuildType = 'stock' | 'extended';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Represents a document stored in a collection.
3
+ * @template D - The type of data contained in the document.
4
+ * @interface
5
+ */
6
+ export interface Doc<D> {
7
+ /**
8
+ * The unique key identifying the document within the collection.
9
+ * @type {string}
10
+ */
11
+ key: string;
12
+ /**
13
+ * An optional description of the document which can also be used to filter document when listing those.
14
+ * @type {string}
15
+ */
16
+ description?: string;
17
+ /**
18
+ * The data contained in the document.
19
+ * @type {D}
20
+ */
21
+ data: D;
22
+ /**
23
+ * The owner of the document.
24
+ * @type {string}
25
+ */
26
+ owner?: string;
27
+ /**
28
+ * The timestamp when the document was created.
29
+ * @type {bigint}
30
+ */
31
+ created_at?: bigint;
32
+ /**
33
+ * The timestamp when the document was last updated.
34
+ * @type {bigint}
35
+ */
36
+ updated_at?: bigint;
37
+ /**
38
+ * The version of the document. When updating a document, the current version must be provided to ensure the correct document is updated.
39
+ * @type {bigint}
40
+ */
41
+ version?: bigint;
42
+ }
@@ -0,0 +1,43 @@
1
+ import type { Satellite } from './satellite.types';
2
+ /**
3
+ * Represents the path to a web worker.
4
+ * @typedef {string} EnvironmentWorkerPath
5
+ */
6
+ export type EnvironmentWorkerPath = string;
7
+ /**
8
+ * Represents a web worker which can be a enable for default path or provided with a specific path string.
9
+ * @typedef {true | EnvironmentWorkerPath} EnvironmentWorker
10
+ */
11
+ export type EnvironmentWorker = true | EnvironmentWorkerPath;
12
+ /**
13
+ * Represents the environment workers.
14
+ * @interface
15
+ */
16
+ export interface EnvironmentWorkers {
17
+ /**
18
+ * The authentication worker configuration. A worker which takes cares of validating the session and if expired, triggers an event to ultimately logout the user automatically.
19
+ * @type {EnvironmentWorker}
20
+ */
21
+ auth?: EnvironmentWorker;
22
+ }
23
+ /**
24
+ * The environment configuration.
25
+ * @typedef {Object} Environment
26
+ * @property {string} [internetIdentityId] - The optional Internet Identity ID. Generally not provided.
27
+ * @property {EnvironmentWorkers} [workers] - The optional web workers configuration.
28
+ * @property {string} satelliteId - The satellite ID (required).
29
+ * @property {string} [container] - The container. Commonly true to use local development with Docker.
30
+ */
31
+ export type Environment = {
32
+ internetIdentityId?: string;
33
+ workers?: EnvironmentWorkers;
34
+ } & Required<Pick<Satellite, 'satelliteId'>> & Pick<Satellite, 'container'>;
35
+ /**
36
+ * Represents the user environment configuration. i.e. the optional parameters the user is providing to initialize Juno.
37
+ * @typedef {Object} UserEnvironment
38
+ * @property {string} [internetIdentityId] - The optional Internet Identity ID. Generally not provided.
39
+ * @property {EnvironmentWorkers} [workers] - The environment workers configuration.
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
+ * @property {string} [container] - The container. If not provided, the library tries to load the information injected by the Vite and NextJS plugins.
42
+ */
43
+ export type UserEnvironment = Omit<Environment, 'satelliteId'> & Pick<Satellite, 'satelliteId'>;
@@ -0,0 +1,170 @@
1
+ import type { Principal } from '@dfinity/principal';
2
+ /**
3
+ * Represents the results of a list call.
4
+ * @template T - The type of items in the list.
5
+ * @interface
6
+ */
7
+ export interface ListResults<T> {
8
+ /**
9
+ * The data - e.g., the documents or assets depending on which list was called.
10
+ * @type {T[]}
11
+ */
12
+ items: T[];
13
+ /**
14
+ * The number of items - basically items.length.
15
+ * @type {bigint}
16
+ */
17
+ items_length: bigint;
18
+ /**
19
+ * If the query is paginated, the page number (starting from 0) where the items are found.
20
+ * @type {bigint}
21
+ */
22
+ items_page?: bigint;
23
+ /**
24
+ * The total number of matching results.
25
+ * @type {bigint}
26
+ */
27
+ matches_length: bigint;
28
+ /**
29
+ * If the query is paginated, the total number of pages (starting from 0).
30
+ * @type {bigint}
31
+ */
32
+ matches_pages?: bigint;
33
+ }
34
+ /**
35
+ * Represents pagination parameters for a list call.
36
+ * @interface
37
+ */
38
+ export interface ListPaginate {
39
+ /**
40
+ * The key to start after for pagination.
41
+ * @type {string}
42
+ */
43
+ startAfter?: string;
44
+ /**
45
+ * The maximum number of items to return.
46
+ * @type {number}
47
+ */
48
+ limit?: number;
49
+ }
50
+ /**
51
+ * Type representing the fields by which the list can be ordered.
52
+ * @typedef {('keys' | 'updated_at' | 'created_at')} ListOrderField
53
+ */
54
+ export type ListOrderField = 'keys' | 'updated_at' | 'created_at';
55
+ /**
56
+ * Represents the order parameters for a list cal.
57
+ * @interface
58
+ */
59
+ export interface ListOrder {
60
+ /**
61
+ * Whether the order is descending.
62
+ * @type {boolean}
63
+ */
64
+ desc: boolean;
65
+ /**
66
+ * The field by which to order the list.
67
+ * @type {ListOrderField}
68
+ */
69
+ field: ListOrderField;
70
+ }
71
+ /**
72
+ * Type representing the owner of a list item, either a string or a Principal.
73
+ * @typedef {(string | Principal)} ListOwner
74
+ */
75
+ export type ListOwner = string | Principal;
76
+ /**
77
+ * Represents timestamp matching criteria with mutually exclusive options.
78
+ * This type defines various ways to filter based on timestamp values.
79
+ */
80
+ export type ListTimestampMatcher = {
81
+ /**
82
+ * Specifies an exact match for the timestamp.
83
+ */
84
+ matcher: 'equal';
85
+ /**
86
+ * The timestamp value to match exactly.
87
+ */
88
+ timestamp: bigint;
89
+ } | {
90
+ /**
91
+ * Specifies a greater than comparison for the timestamp.
92
+ */
93
+ matcher: 'greaterThan';
94
+ /**
95
+ * The timestamp value that the target should be greater than.
96
+ */
97
+ timestamp: bigint;
98
+ } | {
99
+ /**
100
+ * Specifies a less than comparison for the timestamp.
101
+ */
102
+ matcher: 'lessThan';
103
+ /**
104
+ * The timestamp value that the target should be less than.
105
+ * Used only when `matchType` is 'lessThan'.
106
+ */
107
+ timestamp: bigint;
108
+ } | {
109
+ /**
110
+ * Specifies a range for the timestamp, inclusive of start and end.
111
+ */
112
+ matcher: 'between';
113
+ /**
114
+ * The range of timestamps to match, inclusive of both start and end values.
115
+ */
116
+ timestamps: {
117
+ start: bigint;
118
+ end: bigint;
119
+ };
120
+ };
121
+ /**
122
+ * Represents matching parameters for a list call.
123
+ * @interface
124
+ */
125
+ export interface ListMatcher {
126
+ /**
127
+ * The key to match. Support Regex (must comply with Rust regex).
128
+ * @type {string}
129
+ */
130
+ key?: string;
131
+ /**
132
+ * The description to match. Support Regex (must comply with Rust regex).
133
+ * @type {string}
134
+ */
135
+ description?: string;
136
+ /**
137
+ * Criteria for matching the creation timestamp.
138
+ */
139
+ createdAt?: ListTimestampMatcher;
140
+ /**
141
+ * Criteria for matching the update timestamp.
142
+ */
143
+ updatedAt?: ListTimestampMatcher;
144
+ }
145
+ /**
146
+ * Represents the parameters for a list query.
147
+ * @interface
148
+ */
149
+ export interface ListParams {
150
+ /**
151
+ * The matcher parameters for the query.
152
+ * @type {ListMatcher}
153
+ */
154
+ matcher?: ListMatcher;
155
+ /**
156
+ * The pagination parameters for the query.
157
+ * @type {ListPaginate}
158
+ */
159
+ paginate?: ListPaginate;
160
+ /**
161
+ * The order parameters for the query.
162
+ * @type {ListOrder}
163
+ */
164
+ order?: ListOrder;
165
+ /**
166
+ * The owner of the items to match.
167
+ * @type {ListOwner}
168
+ */
169
+ owner?: ListOwner;
170
+ }
@@ -0,0 +1,11 @@
1
+ export type PostMessageRequest = 'junoStartAuthTimer' | 'junoStopAuthTimer';
2
+ export type PostMessageResponse = 'junoSignOutAuthTimer' | 'junoDelegationRemainingTime';
3
+ export type PostMessageDataRequest = never;
4
+ export type PostMessageDataResponse = object;
5
+ export interface PostMessageDataResponseAuth extends PostMessageDataResponse {
6
+ authRemainingTime: number;
7
+ }
8
+ export interface PostMessage<T extends PostMessageDataRequest | PostMessageDataResponse> {
9
+ msg: PostMessageRequest | PostMessageResponse;
10
+ data?: T;
11
+ }
@@ -0,0 +1,32 @@
1
+ import type { Identity } from '@dfinity/agent';
2
+ /**
3
+ * Represents the configuration for a satellite.
4
+ * @interface
5
+ */
6
+ export interface Satellite {
7
+ /**
8
+ * The identity associated with the satellite.
9
+ * @type {Identity}
10
+ */
11
+ identity: Identity;
12
+ /**
13
+ * The unique identifier for the satellite.
14
+ * @type {string}
15
+ */
16
+ satelliteId?: string;
17
+ /**
18
+ * A custom fetch function to use for network requests.
19
+ * @type {typeof fetch}
20
+ */
21
+ fetch?: typeof fetch;
22
+ /**
23
+ * Specifies whether the satellite is running in a container or provides the container URL. i.e. URL to Docker local development.
24
+ * @type {boolean | string}
25
+ */
26
+ container?: boolean | string;
27
+ }
28
+ /**
29
+ * Represents partial configuration options for a satellite. To be used only on NodeJS or rarely used for browser.
30
+ * @typedef {Partial<Satellite>} SatelliteOptions
31
+ */
32
+ export type SatelliteOptions = Partial<Satellite>;
@@ -0,0 +1,21 @@
1
+ import type { Asset } from '@junobuild/storage';
2
+ import type { AssetNoContent } from '../../declarations/satellite/satellite.did';
3
+ import type { ListResults } from './list.types';
4
+ /**
5
+ * Represents a collection of assets with pagination details.
6
+ * @interface
7
+ * @extends {Pick<ListResults<AssetNoContent>, 'items_length' | 'items_page' | 'matches_length' | 'matches_pages'>}
8
+ */
9
+ export interface Assets extends Omit<ListResults<AssetNoContent>, 'items'> {
10
+ /**
11
+ * The collection of assets.
12
+ * @type {Asset[]}
13
+ */
14
+ items: Asset[];
15
+ /**
16
+ * The collection of assets. Duplicates items for backwards compatibility. It will ultimately be removed.
17
+ * @deprecated Use {@link items} instead.
18
+ * @type {Asset[]}
19
+ */
20
+ assets: Asset[];
21
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Represents a function that unsubscribes from an event or a subscription.
3
+ * @typedef {Function} Unsubscribe
4
+ * @returns {void}
5
+ */
6
+ export type Unsubscribe = () => void;
@@ -0,0 +1,2 @@
1
+ import { AuthClient } from '@dfinity/auth-client';
2
+ export declare const createAuthClient: () => Promise<AuthClient>;
@@ -0,0 +1 @@
1
+ export declare const sha256ToBase64String: (sha256: Iterable<number>) => string;
@@ -0,0 +1,2 @@
1
+ import type { Doc } from '../../declarations/satellite/satellite.did';
2
+ export declare const mapData: <D>({ data }: Pick<Doc, "data">) => Promise<D>;
@@ -0,0 +1,8 @@
1
+ import type { DelDoc, Doc as DocApi, SetDoc } from '../../declarations/satellite/satellite.did';
2
+ import type { Doc } from '../types/doc.types';
3
+ export declare const toSetDoc: <D>(doc: Doc<D>) => Promise<SetDoc>;
4
+ export declare const toDelDoc: <D>(doc: Doc<D>) => DelDoc;
5
+ export declare const fromDoc: <D>({ doc, key }: {
6
+ doc: DocApi;
7
+ key: string;
8
+ }) => Promise<Doc<D>>;
@@ -0,0 +1,4 @@
1
+ import type { Satellite } from '../types/satellite.types';
2
+ export declare const satelliteUrl: ({ satelliteId: customSatelliteId, container: customContainer }: Satellite) => string;
3
+ export declare const customOrEnvSatelliteId: ({ satelliteId }: Pick<Satellite, "satelliteId">) => Pick<Satellite, "satelliteId">;
4
+ export declare const customOrEnvContainer: ({ container: customContainer }: Pick<Satellite, "container">) => Pick<Satellite, "container">;
@@ -0,0 +1,4 @@
1
+ export declare const emit: <T>({ message, detail }: {
2
+ message: string;
3
+ detail?: T | undefined;
4
+ }) => void;
@@ -0,0 +1,3 @@
1
+ import type { ListParams as ListParamsApi } from '../../declarations/satellite/satellite.did';
2
+ import type { ListParams } from '../types/list.types';
3
+ export declare const toListParams: ({ matcher, paginate, order, owner }: ListParams) => ListParamsApi;
@@ -0,0 +1,2 @@
1
+ export declare const envSatelliteId: () => string | undefined;
2
+ export declare const envContainer: () => string | undefined;
@@ -0,0 +1,4 @@
1
+ export declare const popupCenter: ({ width, height }: {
2
+ width: number;
3
+ height: number;
4
+ }) => string | undefined;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The timer is executed only if user has signed in
3
+ */
4
+ export declare const startTimer: () => NodeJS.Timeout;
5
+ export declare const stopTimer: () => void;