@junobuild/admin 0.0.12 → 0.0.14

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 (46) hide show
  1. package/README.md +1 -1
  2. package/declarations/cmc/cmc.did +122 -0
  3. package/declarations/cmc/cmc.did.d.ts +48 -0
  4. package/declarations/cmc/cmc.factory.did.js +65 -0
  5. package/declarations/cmc/index.d.ts +45 -0
  6. package/declarations/cmc/index.js +32 -0
  7. package/declarations/console/console.did.d.ts +60 -0
  8. package/declarations/console/console.factory.did.js +62 -0
  9. package/declarations/console/console.factory.did.mjs +62 -0
  10. package/declarations/console/index.d.ts +45 -0
  11. package/declarations/console/index.js +32 -0
  12. package/declarations/frontend/frontend.did +188 -0
  13. package/declarations/frontend/frontend.did.d.ts +172 -0
  14. package/declarations/frontend/frontend.factory.did.js +208 -0
  15. package/declarations/frontend/index.d.ts +45 -0
  16. package/declarations/frontend/index.js +32 -0
  17. package/declarations/ic/ic.did +82 -0
  18. package/declarations/ic/ic.did.d.ts +77 -0
  19. package/declarations/ic/ic.factory.did.js +128 -0
  20. package/declarations/internet_identity/index.d.ts +45 -0
  21. package/declarations/internet_identity/index.js +32 -0
  22. package/declarations/internet_identity/internet_identity.did +330 -0
  23. package/declarations/internet_identity/internet_identity.did.d.ts +204 -0
  24. package/declarations/internet_identity/internet_identity.factory.did.js +233 -0
  25. package/declarations/ledger/index.d.ts +45 -0
  26. package/declarations/ledger/index.js +32 -0
  27. package/declarations/ledger/ledger.did +249 -0
  28. package/declarations/ledger/ledger.did.d.ts +100 -0
  29. package/declarations/ledger/ledger.factory.did.js +98 -0
  30. package/declarations/mission_control/index.d.ts +45 -0
  31. package/declarations/mission_control/index.js +32 -0
  32. package/declarations/mission_control/mission_control.did.d.ts +41 -0
  33. package/declarations/mission_control/mission_control.factory.did.js +50 -0
  34. package/declarations/satellite/index.d.ts +45 -0
  35. package/declarations/satellite/index.js +32 -0
  36. package/declarations/satellite/satellite-deprecated.did.d.ts +182 -0
  37. package/declarations/satellite/satellite-deprecated.factory.did.js +191 -0
  38. package/declarations/satellite/satellite-deprecated.factory.did.mjs +191 -0
  39. package/declarations/satellite/satellite.did.d.ts +183 -0
  40. package/declarations/satellite/satellite.factory.did.js +194 -0
  41. package/declarations/satellite/satellite.factory.did.mjs +192 -0
  42. package/dist/browser/index.js +1 -1
  43. package/dist/browser/index.js.map +2 -2
  44. package/dist/node/index.mjs +1 -1
  45. package/dist/node/index.mjs.map +2 -2
  46. package/package.json +3 -3
@@ -0,0 +1,204 @@
1
+ import type {ActorMethod} from '@dfinity/agent';
2
+ import type {Principal} from '@dfinity/principal';
3
+
4
+ export interface ActiveAnchorCounter {
5
+ counter: bigint;
6
+ start_timestamp: Timestamp;
7
+ }
8
+ export interface ActiveAnchorStatistics {
9
+ completed: CompletedActiveAnchorStats;
10
+ ongoing: OngoingActiveAnchorStats;
11
+ }
12
+ export type AddTentativeDeviceResponse =
13
+ | {
14
+ device_registration_mode_off: null;
15
+ }
16
+ | {another_device_tentatively_added: null}
17
+ | {
18
+ added_tentatively: {
19
+ verification_code: string;
20
+ device_registration_timeout: Timestamp;
21
+ };
22
+ };
23
+ export interface AnchorCredentials {
24
+ recovery_phrases: Array<PublicKey>;
25
+ credentials: Array<WebAuthnCredential>;
26
+ recovery_credentials: Array<WebAuthnCredential>;
27
+ }
28
+ export interface ArchiveConfig {
29
+ polling_interval_ns: bigint;
30
+ entries_buffer_limit: bigint;
31
+ module_hash: Uint8Array | number[];
32
+ entries_fetch_limit: number;
33
+ }
34
+ export interface ArchiveInfo {
35
+ archive_config: [] | [ArchiveConfig];
36
+ archive_canister: [] | [Principal];
37
+ }
38
+ export interface BufferedArchiveEntry {
39
+ sequence_number: bigint;
40
+ entry: Uint8Array | number[];
41
+ anchor_number: UserNumber;
42
+ timestamp: Timestamp;
43
+ }
44
+ export interface Challenge {
45
+ png_base64: string;
46
+ challenge_key: ChallengeKey;
47
+ }
48
+ export type ChallengeKey = string;
49
+ export interface ChallengeResult {
50
+ key: ChallengeKey;
51
+ chars: string;
52
+ }
53
+ export interface CompletedActiveAnchorStats {
54
+ monthly_active_anchors: [] | [ActiveAnchorCounter];
55
+ daily_active_anchors: [] | [ActiveAnchorCounter];
56
+ }
57
+ export type CredentialId = Uint8Array | number[];
58
+ export interface Delegation {
59
+ pubkey: PublicKey;
60
+ targets: [] | [Array<Principal>];
61
+ expiration: Timestamp;
62
+ }
63
+ export type DeployArchiveResult =
64
+ | {creation_in_progress: null}
65
+ | {success: Principal}
66
+ | {failed: string};
67
+ export interface DeviceData {
68
+ alias: string;
69
+ origin: [] | [string];
70
+ protection: DeviceProtection;
71
+ pubkey: DeviceKey;
72
+ key_type: KeyType;
73
+ purpose: Purpose;
74
+ credential_id: [] | [CredentialId];
75
+ }
76
+ export type DeviceKey = PublicKey;
77
+ export type DeviceProtection = {unprotected: null} | {protected: null};
78
+ export interface DeviceRegistrationInfo {
79
+ tentative_device: [] | [DeviceData];
80
+ expiration: Timestamp;
81
+ }
82
+ export interface DeviceWithUsage {
83
+ alias: string;
84
+ last_usage: [] | [Timestamp];
85
+ origin: [] | [string];
86
+ protection: DeviceProtection;
87
+ pubkey: DeviceKey;
88
+ key_type: KeyType;
89
+ purpose: Purpose;
90
+ credential_id: [] | [CredentialId];
91
+ }
92
+ export type FrontendHostname = string;
93
+ export type GetDelegationResponse =
94
+ | {no_such_delegation: null}
95
+ | {signed_delegation: SignedDelegation};
96
+ export type HeaderField = [string, string];
97
+ export interface HttpRequest {
98
+ url: string;
99
+ method: string;
100
+ body: Uint8Array | number[];
101
+ headers: Array<HeaderField>;
102
+ }
103
+ export interface HttpResponse {
104
+ body: Uint8Array | number[];
105
+ headers: Array<HeaderField>;
106
+ upgrade: [] | [boolean];
107
+ streaming_strategy: [] | [StreamingStrategy];
108
+ status_code: number;
109
+ }
110
+ export interface IdentityAnchorInfo {
111
+ devices: Array<DeviceWithUsage>;
112
+ device_registration: [] | [DeviceRegistrationInfo];
113
+ }
114
+ export interface InternetIdentityInit {
115
+ assigned_user_number_range: [] | [[bigint, bigint]];
116
+ archive_config: [] | [ArchiveConfig];
117
+ canister_creation_cycles_cost: [] | [bigint];
118
+ register_rate_limit: [] | [RateLimitConfig];
119
+ }
120
+ export interface InternetIdentityStats {
121
+ storage_layout_version: number;
122
+ users_registered: bigint;
123
+ assigned_user_number_range: [bigint, bigint];
124
+ archive_info: ArchiveInfo;
125
+ canister_creation_cycles_cost: bigint;
126
+ active_anchor_stats: [] | [ActiveAnchorStatistics];
127
+ }
128
+ export type KeyType =
129
+ | {platform: null}
130
+ | {seed_phrase: null}
131
+ | {cross_platform: null}
132
+ | {unknown: null};
133
+ export interface OngoingActiveAnchorStats {
134
+ monthly_active_anchors: Array<ActiveAnchorCounter>;
135
+ daily_active_anchors: ActiveAnchorCounter;
136
+ }
137
+ export type PublicKey = Uint8Array | number[];
138
+ export type Purpose = {authentication: null} | {recovery: null};
139
+ export interface RateLimitConfig {
140
+ max_tokens: bigint;
141
+ time_per_token_ns: bigint;
142
+ }
143
+ export type RegisterResponse =
144
+ | {bad_challenge: null}
145
+ | {canister_full: null}
146
+ | {registered: {user_number: UserNumber}};
147
+ export type SessionKey = PublicKey;
148
+ export interface SignedDelegation {
149
+ signature: Uint8Array | number[];
150
+ delegation: Delegation;
151
+ }
152
+ export interface StreamingCallbackHttpResponse {
153
+ token: [] | [Token];
154
+ body: Uint8Array | number[];
155
+ }
156
+ export type StreamingStrategy = {
157
+ Callback: {token: Token; callback: [Principal, string]};
158
+ };
159
+ export type Timestamp = bigint;
160
+ export type Token = {};
161
+ export type UserKey = PublicKey;
162
+ export type UserNumber = bigint;
163
+ export type VerifyTentativeDeviceResponse =
164
+ | {
165
+ device_registration_mode_off: null;
166
+ }
167
+ | {verified: null}
168
+ | {wrong_code: {retries_left: number}}
169
+ | {no_device_to_verify: null};
170
+ export interface WebAuthnCredential {
171
+ pubkey: PublicKey;
172
+ credential_id: CredentialId;
173
+ }
174
+ export interface _SERVICE {
175
+ acknowledge_entries: ActorMethod<[bigint], undefined>;
176
+ add: ActorMethod<[UserNumber, DeviceData], undefined>;
177
+ add_tentative_device: ActorMethod<[UserNumber, DeviceData], AddTentativeDeviceResponse>;
178
+ create_challenge: ActorMethod<[], Challenge>;
179
+ deploy_archive: ActorMethod<[Uint8Array | number[]], DeployArchiveResult>;
180
+ enter_device_registration_mode: ActorMethod<[UserNumber], Timestamp>;
181
+ exit_device_registration_mode: ActorMethod<[UserNumber], undefined>;
182
+ fetch_entries: ActorMethod<[], Array<BufferedArchiveEntry>>;
183
+ get_anchor_credentials: ActorMethod<[UserNumber], AnchorCredentials>;
184
+ get_anchor_info: ActorMethod<[UserNumber], IdentityAnchorInfo>;
185
+ get_delegation: ActorMethod<
186
+ [UserNumber, FrontendHostname, SessionKey, Timestamp],
187
+ GetDelegationResponse
188
+ >;
189
+ get_principal: ActorMethod<[UserNumber, FrontendHostname], Principal>;
190
+ http_request: ActorMethod<[HttpRequest], HttpResponse>;
191
+ http_request_update: ActorMethod<[HttpRequest], HttpResponse>;
192
+ init_salt: ActorMethod<[], undefined>;
193
+ lookup: ActorMethod<[UserNumber], Array<DeviceData>>;
194
+ prepare_delegation: ActorMethod<
195
+ [UserNumber, FrontendHostname, SessionKey, [] | [bigint]],
196
+ [UserKey, Timestamp]
197
+ >;
198
+ register: ActorMethod<[DeviceData, ChallengeResult], RegisterResponse>;
199
+ remove: ActorMethod<[UserNumber, DeviceKey], undefined>;
200
+ replace: ActorMethod<[UserNumber, DeviceKey, DeviceData], undefined>;
201
+ stats: ActorMethod<[], InternetIdentityStats>;
202
+ update: ActorMethod<[UserNumber, DeviceKey, DeviceData], undefined>;
203
+ verify_tentative_device: ActorMethod<[UserNumber, string], VerifyTentativeDeviceResponse>;
204
+ }
@@ -0,0 +1,233 @@
1
+ export const idlFactory = ({IDL}) => {
2
+ const ArchiveConfig = IDL.Record({
3
+ polling_interval_ns: IDL.Nat64,
4
+ entries_buffer_limit: IDL.Nat64,
5
+ module_hash: IDL.Vec(IDL.Nat8),
6
+ entries_fetch_limit: IDL.Nat16
7
+ });
8
+ const RateLimitConfig = IDL.Record({
9
+ max_tokens: IDL.Nat64,
10
+ time_per_token_ns: IDL.Nat64
11
+ });
12
+ const InternetIdentityInit = IDL.Record({
13
+ assigned_user_number_range: IDL.Opt(IDL.Tuple(IDL.Nat64, IDL.Nat64)),
14
+ archive_config: IDL.Opt(ArchiveConfig),
15
+ canister_creation_cycles_cost: IDL.Opt(IDL.Nat64),
16
+ register_rate_limit: IDL.Opt(RateLimitConfig)
17
+ });
18
+ const UserNumber = IDL.Nat64;
19
+ const DeviceProtection = IDL.Variant({
20
+ unprotected: IDL.Null,
21
+ protected: IDL.Null
22
+ });
23
+ const PublicKey = IDL.Vec(IDL.Nat8);
24
+ const DeviceKey = PublicKey;
25
+ const KeyType = IDL.Variant({
26
+ platform: IDL.Null,
27
+ seed_phrase: IDL.Null,
28
+ cross_platform: IDL.Null,
29
+ unknown: IDL.Null
30
+ });
31
+ const Purpose = IDL.Variant({
32
+ authentication: IDL.Null,
33
+ recovery: IDL.Null
34
+ });
35
+ const CredentialId = IDL.Vec(IDL.Nat8);
36
+ const DeviceData = IDL.Record({
37
+ alias: IDL.Text,
38
+ origin: IDL.Opt(IDL.Text),
39
+ protection: DeviceProtection,
40
+ pubkey: DeviceKey,
41
+ key_type: KeyType,
42
+ purpose: Purpose,
43
+ credential_id: IDL.Opt(CredentialId)
44
+ });
45
+ const Timestamp = IDL.Nat64;
46
+ const AddTentativeDeviceResponse = IDL.Variant({
47
+ device_registration_mode_off: IDL.Null,
48
+ another_device_tentatively_added: IDL.Null,
49
+ added_tentatively: IDL.Record({
50
+ verification_code: IDL.Text,
51
+ device_registration_timeout: Timestamp
52
+ })
53
+ });
54
+ const ChallengeKey = IDL.Text;
55
+ const Challenge = IDL.Record({
56
+ png_base64: IDL.Text,
57
+ challenge_key: ChallengeKey
58
+ });
59
+ const DeployArchiveResult = IDL.Variant({
60
+ creation_in_progress: IDL.Null,
61
+ success: IDL.Principal,
62
+ failed: IDL.Text
63
+ });
64
+ const BufferedArchiveEntry = IDL.Record({
65
+ sequence_number: IDL.Nat64,
66
+ entry: IDL.Vec(IDL.Nat8),
67
+ anchor_number: UserNumber,
68
+ timestamp: Timestamp
69
+ });
70
+ const WebAuthnCredential = IDL.Record({
71
+ pubkey: PublicKey,
72
+ credential_id: CredentialId
73
+ });
74
+ const AnchorCredentials = IDL.Record({
75
+ recovery_phrases: IDL.Vec(PublicKey),
76
+ credentials: IDL.Vec(WebAuthnCredential),
77
+ recovery_credentials: IDL.Vec(WebAuthnCredential)
78
+ });
79
+ const DeviceWithUsage = IDL.Record({
80
+ alias: IDL.Text,
81
+ last_usage: IDL.Opt(Timestamp),
82
+ origin: IDL.Opt(IDL.Text),
83
+ protection: DeviceProtection,
84
+ pubkey: DeviceKey,
85
+ key_type: KeyType,
86
+ purpose: Purpose,
87
+ credential_id: IDL.Opt(CredentialId)
88
+ });
89
+ const DeviceRegistrationInfo = IDL.Record({
90
+ tentative_device: IDL.Opt(DeviceData),
91
+ expiration: Timestamp
92
+ });
93
+ const IdentityAnchorInfo = IDL.Record({
94
+ devices: IDL.Vec(DeviceWithUsage),
95
+ device_registration: IDL.Opt(DeviceRegistrationInfo)
96
+ });
97
+ const FrontendHostname = IDL.Text;
98
+ const SessionKey = PublicKey;
99
+ const Delegation = IDL.Record({
100
+ pubkey: PublicKey,
101
+ targets: IDL.Opt(IDL.Vec(IDL.Principal)),
102
+ expiration: Timestamp
103
+ });
104
+ const SignedDelegation = IDL.Record({
105
+ signature: IDL.Vec(IDL.Nat8),
106
+ delegation: Delegation
107
+ });
108
+ const GetDelegationResponse = IDL.Variant({
109
+ no_such_delegation: IDL.Null,
110
+ signed_delegation: SignedDelegation
111
+ });
112
+ const HeaderField = IDL.Tuple(IDL.Text, IDL.Text);
113
+ const HttpRequest = IDL.Record({
114
+ url: IDL.Text,
115
+ method: IDL.Text,
116
+ body: IDL.Vec(IDL.Nat8),
117
+ headers: IDL.Vec(HeaderField)
118
+ });
119
+ const Token = IDL.Record({});
120
+ const StreamingCallbackHttpResponse = IDL.Record({
121
+ token: IDL.Opt(Token),
122
+ body: IDL.Vec(IDL.Nat8)
123
+ });
124
+ const StreamingStrategy = IDL.Variant({
125
+ Callback: IDL.Record({
126
+ token: Token,
127
+ callback: IDL.Func([Token], [StreamingCallbackHttpResponse], ['query'])
128
+ })
129
+ });
130
+ const HttpResponse = IDL.Record({
131
+ body: IDL.Vec(IDL.Nat8),
132
+ headers: IDL.Vec(HeaderField),
133
+ upgrade: IDL.Opt(IDL.Bool),
134
+ streaming_strategy: IDL.Opt(StreamingStrategy),
135
+ status_code: IDL.Nat16
136
+ });
137
+ const UserKey = PublicKey;
138
+ const ChallengeResult = IDL.Record({
139
+ key: ChallengeKey,
140
+ chars: IDL.Text
141
+ });
142
+ const RegisterResponse = IDL.Variant({
143
+ bad_challenge: IDL.Null,
144
+ canister_full: IDL.Null,
145
+ registered: IDL.Record({user_number: UserNumber})
146
+ });
147
+ const ArchiveInfo = IDL.Record({
148
+ archive_config: IDL.Opt(ArchiveConfig),
149
+ archive_canister: IDL.Opt(IDL.Principal)
150
+ });
151
+ const ActiveAnchorCounter = IDL.Record({
152
+ counter: IDL.Nat64,
153
+ start_timestamp: Timestamp
154
+ });
155
+ const CompletedActiveAnchorStats = IDL.Record({
156
+ monthly_active_anchors: IDL.Opt(ActiveAnchorCounter),
157
+ daily_active_anchors: IDL.Opt(ActiveAnchorCounter)
158
+ });
159
+ const OngoingActiveAnchorStats = IDL.Record({
160
+ monthly_active_anchors: IDL.Vec(ActiveAnchorCounter),
161
+ daily_active_anchors: ActiveAnchorCounter
162
+ });
163
+ const ActiveAnchorStatistics = IDL.Record({
164
+ completed: CompletedActiveAnchorStats,
165
+ ongoing: OngoingActiveAnchorStats
166
+ });
167
+ const InternetIdentityStats = IDL.Record({
168
+ storage_layout_version: IDL.Nat8,
169
+ users_registered: IDL.Nat64,
170
+ assigned_user_number_range: IDL.Tuple(IDL.Nat64, IDL.Nat64),
171
+ archive_info: ArchiveInfo,
172
+ canister_creation_cycles_cost: IDL.Nat64,
173
+ active_anchor_stats: IDL.Opt(ActiveAnchorStatistics)
174
+ });
175
+ const VerifyTentativeDeviceResponse = IDL.Variant({
176
+ device_registration_mode_off: IDL.Null,
177
+ verified: IDL.Null,
178
+ wrong_code: IDL.Record({retries_left: IDL.Nat8}),
179
+ no_device_to_verify: IDL.Null
180
+ });
181
+ return IDL.Service({
182
+ acknowledge_entries: IDL.Func([IDL.Nat64], [], []),
183
+ add: IDL.Func([UserNumber, DeviceData], [], []),
184
+ add_tentative_device: IDL.Func([UserNumber, DeviceData], [AddTentativeDeviceResponse], []),
185
+ create_challenge: IDL.Func([], [Challenge], []),
186
+ deploy_archive: IDL.Func([IDL.Vec(IDL.Nat8)], [DeployArchiveResult], []),
187
+ enter_device_registration_mode: IDL.Func([UserNumber], [Timestamp], []),
188
+ exit_device_registration_mode: IDL.Func([UserNumber], [], []),
189
+ fetch_entries: IDL.Func([], [IDL.Vec(BufferedArchiveEntry)], []),
190
+ get_anchor_credentials: IDL.Func([UserNumber], [AnchorCredentials], ['query']),
191
+ get_anchor_info: IDL.Func([UserNumber], [IdentityAnchorInfo], []),
192
+ get_delegation: IDL.Func(
193
+ [UserNumber, FrontendHostname, SessionKey, Timestamp],
194
+ [GetDelegationResponse],
195
+ ['query']
196
+ ),
197
+ get_principal: IDL.Func([UserNumber, FrontendHostname], [IDL.Principal], ['query']),
198
+ http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
199
+ http_request_update: IDL.Func([HttpRequest], [HttpResponse], []),
200
+ init_salt: IDL.Func([], [], []),
201
+ lookup: IDL.Func([UserNumber], [IDL.Vec(DeviceData)], ['query']),
202
+ prepare_delegation: IDL.Func(
203
+ [UserNumber, FrontendHostname, SessionKey, IDL.Opt(IDL.Nat64)],
204
+ [UserKey, Timestamp],
205
+ []
206
+ ),
207
+ register: IDL.Func([DeviceData, ChallengeResult], [RegisterResponse], []),
208
+ remove: IDL.Func([UserNumber, DeviceKey], [], []),
209
+ replace: IDL.Func([UserNumber, DeviceKey, DeviceData], [], []),
210
+ stats: IDL.Func([], [InternetIdentityStats], ['query']),
211
+ update: IDL.Func([UserNumber, DeviceKey, DeviceData], [], []),
212
+ verify_tentative_device: IDL.Func([UserNumber, IDL.Text], [VerifyTentativeDeviceResponse], [])
213
+ });
214
+ };
215
+ export const init = ({IDL}) => {
216
+ const ArchiveConfig = IDL.Record({
217
+ polling_interval_ns: IDL.Nat64,
218
+ entries_buffer_limit: IDL.Nat64,
219
+ module_hash: IDL.Vec(IDL.Nat8),
220
+ entries_fetch_limit: IDL.Nat16
221
+ });
222
+ const RateLimitConfig = IDL.Record({
223
+ max_tokens: IDL.Nat64,
224
+ time_per_token_ns: IDL.Nat64
225
+ });
226
+ const InternetIdentityInit = IDL.Record({
227
+ assigned_user_number_range: IDL.Opt(IDL.Tuple(IDL.Nat64, IDL.Nat64)),
228
+ archive_config: IDL.Opt(ArchiveConfig),
229
+ canister_creation_cycles_cost: IDL.Opt(IDL.Nat64),
230
+ register_rate_limit: IDL.Opt(RateLimitConfig)
231
+ });
232
+ return [IDL.Opt(InternetIdentityInit)];
233
+ };
@@ -0,0 +1,45 @@
1
+ import type {ActorConfig, ActorSubclass, Agent, HttpAgentOptions} from '@dfinity/agent';
2
+ import type {IDL} from '@dfinity/candid';
3
+ import type {Principal} from '@dfinity/principal';
4
+
5
+ import {_SERVICE} from './ledger.did';
6
+
7
+ export declare const idlFactory: IDL.InterfaceFactory;
8
+ export declare const canisterId: string;
9
+
10
+ export declare interface CreateActorOptions {
11
+ /**
12
+ * @see {@link Agent}
13
+ */
14
+ agent?: Agent;
15
+ /**
16
+ * @see {@link HttpAgentOptions}
17
+ */
18
+ agentOptions?: HttpAgentOptions;
19
+ /**
20
+ * @see {@link ActorConfig}
21
+ */
22
+ actorOptions?: ActorConfig;
23
+ }
24
+
25
+ /**
26
+ * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
27
+ * @constructs {@link ActorSubClass}
28
+ * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
29
+ * @param {CreateActorOptions} options - see {@link CreateActorOptions}
30
+ * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
31
+ * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
32
+ * @see {@link HttpAgentOptions}
33
+ * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
34
+ * @see {@link ActorConfig}
35
+ */
36
+ export declare const createActor: (
37
+ canisterId: string | Principal,
38
+ options?: CreateActorOptions
39
+ ) => ActorSubclass<_SERVICE>;
40
+
41
+ /**
42
+ * Intialized Actor using default settings, ready to talk to a canister using its candid interface
43
+ * @constructs {@link ActorSubClass}
44
+ */
45
+ export declare const ledger: ActorSubclass<_SERVICE>;
@@ -0,0 +1,32 @@
1
+ import {Actor, HttpAgent} from '@dfinity/agent';
2
+
3
+ // Imports and re-exports candid interface
4
+ import {idlFactory} from './ledger.did.js';
5
+ export {idlFactory} from './ledger.did.js';
6
+
7
+ // CANISTER_ID is replaced by webpack based on node environment
8
+
9
+ export const createActor = (canisterId, options = {}) => {
10
+ const agent = options.agent || new HttpAgent({...options.agentOptions});
11
+
12
+ if (options.agent && options.agentOptions) {
13
+ console.warn(
14
+ 'Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.'
15
+ );
16
+ }
17
+
18
+ // Fetch root key for certificate validation during development
19
+ if (process.env.DFX_NETWORK !== 'ic') {
20
+ agent.fetchRootKey().catch((err) => {
21
+ console.warn('Unable to fetch root key. Check to ensure that your local replica is running');
22
+ console.error(err);
23
+ });
24
+ }
25
+
26
+ // Creates an actor with using the candid interface and the HttpAgent
27
+ return Actor.createActor(idlFactory, {
28
+ agent,
29
+ canisterId,
30
+ ...options.actorOptions
31
+ });
32
+ };