@junobuild/admin 0.0.3 → 0.0.4
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/cjs/index.cjs.js.map +3 -3
- package/dist/declarations/cmc/cmc.did +122 -0
- package/dist/declarations/cmc/cmc.did.d.ts +48 -0
- package/dist/declarations/cmc/cmc.factory.did.js +65 -0
- package/dist/declarations/cmc/index.d.ts +45 -0
- package/dist/declarations/cmc/index.js +32 -0
- package/dist/declarations/console/console.did.d.ts +47 -0
- package/dist/declarations/console/console.factory.did.js +49 -0
- package/dist/declarations/console/console.factory.did.mjs +49 -0
- package/dist/declarations/console/index.d.ts +45 -0
- package/dist/declarations/console/index.js +32 -0
- package/dist/declarations/frontend/frontend.did +147 -0
- package/dist/declarations/frontend/frontend.did.d.ts +128 -0
- package/dist/declarations/frontend/frontend.factory.did.js +165 -0
- package/dist/declarations/frontend/index.d.ts +45 -0
- package/dist/declarations/frontend/index.js +32 -0
- package/dist/declarations/ic/ic.did +82 -0
- package/dist/declarations/ic/ic.did.d.ts +77 -0
- package/dist/declarations/ic/ic.factory.did.js +128 -0
- package/dist/declarations/internet_identity/index.d.ts +45 -0
- package/dist/declarations/internet_identity/index.js +32 -0
- package/dist/declarations/internet_identity/internet_identity.did +271 -0
- package/dist/declarations/internet_identity/internet_identity.did.d.ts +161 -0
- package/dist/declarations/internet_identity/internet_identity.factory.did.js +187 -0
- package/dist/declarations/ledger/index.d.ts +45 -0
- package/dist/declarations/ledger/index.js +32 -0
- package/dist/declarations/ledger/ledger.did +249 -0
- package/dist/declarations/ledger/ledger.did.d.ts +100 -0
- package/dist/declarations/ledger/ledger.factory.did.js +98 -0
- package/dist/declarations/mission_control/index.d.ts +45 -0
- package/dist/declarations/mission_control/index.js +32 -0
- package/dist/declarations/mission_control/mission_control.did.d.ts +24 -0
- package/dist/declarations/mission_control/mission_control.factory.did.js +28 -0
- package/dist/declarations/satellite/index.d.ts +45 -0
- package/dist/declarations/satellite/index.js +32 -0
- package/dist/declarations/satellite/satellite.did.d.ts +166 -0
- package/dist/declarations/satellite/satellite.factory.did.js +164 -0
- package/dist/declarations/satellite/satellite.factory.did.mjs +164 -0
- package/dist/esm/index.js.map +3 -3
- package/dist/types/api/actor.api.d.ts +4 -4
- package/dist/types/api/satellite.api.d.ts +1 -1
- package/dist/types/types/ic.types.d.ts +1 -1
- package/package.json +9 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {Actor, HttpAgent} from '@dfinity/agent';
|
|
2
|
+
|
|
3
|
+
// Imports and re-exports candid interface
|
|
4
|
+
import {idlFactory} from './internet_identity.did.js';
|
|
5
|
+
export {idlFactory} from './internet_identity.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
|
+
};
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
type UserNumber = nat64;
|
|
2
|
+
type PublicKey = blob;
|
|
3
|
+
type CredentialId = blob;
|
|
4
|
+
type DeviceKey = PublicKey;
|
|
5
|
+
type UserKey = PublicKey;
|
|
6
|
+
type SessionKey = PublicKey;
|
|
7
|
+
type FrontendHostname = text;
|
|
8
|
+
type Timestamp = nat64;
|
|
9
|
+
|
|
10
|
+
type HeaderField = record {
|
|
11
|
+
text;
|
|
12
|
+
text;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type HttpRequest = record {
|
|
16
|
+
method: text;
|
|
17
|
+
url: text;
|
|
18
|
+
headers: vec HeaderField;
|
|
19
|
+
body: blob;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type HttpResponse = record {
|
|
23
|
+
status_code: nat16;
|
|
24
|
+
headers: vec HeaderField;
|
|
25
|
+
body: blob;
|
|
26
|
+
streaming_strategy: opt StreamingStrategy;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type StreamingCallbackHttpResponse = record {
|
|
30
|
+
body: blob;
|
|
31
|
+
token: opt Token;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type Token = record {};
|
|
35
|
+
|
|
36
|
+
type StreamingStrategy = variant {
|
|
37
|
+
Callback: record {
|
|
38
|
+
callback: func (Token) -> (StreamingCallbackHttpResponse) query;
|
|
39
|
+
token: Token;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type Purpose = variant {
|
|
44
|
+
recovery;
|
|
45
|
+
authentication;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type KeyType = variant {
|
|
49
|
+
unknown;
|
|
50
|
+
platform;
|
|
51
|
+
cross_platform;
|
|
52
|
+
seed_phrase;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// This describes whether a device is "protected" or not.
|
|
56
|
+
// When protected, a device can only be updated or removed if the
|
|
57
|
+
// user is authenticated with that very device.
|
|
58
|
+
type DeviceProtection = variant {
|
|
59
|
+
protected;
|
|
60
|
+
unprotected;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type Challenge = record {
|
|
64
|
+
png_base64: text;
|
|
65
|
+
challenge_key: ChallengeKey;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type DeviceData = record {
|
|
69
|
+
pubkey : DeviceKey;
|
|
70
|
+
alias : text;
|
|
71
|
+
credential_id : opt CredentialId;
|
|
72
|
+
purpose: Purpose;
|
|
73
|
+
key_type: KeyType;
|
|
74
|
+
protection: DeviceProtection;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
type RegisterResponse = variant {
|
|
78
|
+
// A new user was successfully registered.
|
|
79
|
+
registered: record {
|
|
80
|
+
user_number: UserNumber;
|
|
81
|
+
};
|
|
82
|
+
// No more registrations are possible in this instance of the II service canister.
|
|
83
|
+
canister_full;
|
|
84
|
+
// The challenge was not successful.
|
|
85
|
+
bad_challenge;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
type AddTentativeDeviceResponse = variant {
|
|
89
|
+
// The device was tentatively added.
|
|
90
|
+
added_tentatively: record {
|
|
91
|
+
verification_code: text;
|
|
92
|
+
device_registration_timeout: Timestamp;
|
|
93
|
+
};
|
|
94
|
+
// Device registration mode is off, either due to timeout or because it was never enabled.
|
|
95
|
+
device_registration_mode_off;
|
|
96
|
+
// There is another device already added tentatively
|
|
97
|
+
another_device_tentatively_added;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
type VerifyTentativeDeviceResponse = variant {
|
|
101
|
+
// The device was successfully verified.
|
|
102
|
+
verified;
|
|
103
|
+
// Wrong verification code entered. Retry with correct code.
|
|
104
|
+
wrong_code: record {
|
|
105
|
+
retries_left: nat8
|
|
106
|
+
};
|
|
107
|
+
// Device registration mode is off, either due to timeout or because it was never enabled.
|
|
108
|
+
device_registration_mode_off;
|
|
109
|
+
// There is no tentative device to be verified.
|
|
110
|
+
no_device_to_verify;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
type Delegation = record {
|
|
114
|
+
pubkey: PublicKey;
|
|
115
|
+
expiration: Timestamp;
|
|
116
|
+
targets: opt vec principal;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
type SignedDelegation = record {
|
|
120
|
+
delegation: Delegation;
|
|
121
|
+
signature: blob;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
type GetDelegationResponse = variant {
|
|
125
|
+
// The signed delegation was successfully retrieved.
|
|
126
|
+
signed_delegation: SignedDelegation;
|
|
127
|
+
|
|
128
|
+
// The signature is not ready. Maybe retry by calling `prepare_delegation`
|
|
129
|
+
no_such_delegation
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type InternetIdentityStats = record {
|
|
133
|
+
users_registered: nat64;
|
|
134
|
+
storage_layout_version: nat8;
|
|
135
|
+
assigned_user_number_range: record {
|
|
136
|
+
nat64;
|
|
137
|
+
nat64;
|
|
138
|
+
};
|
|
139
|
+
archive_info: ArchiveInfo;
|
|
140
|
+
canister_creation_cycles_cost: nat64;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// Configuration parameters related to the archive.
|
|
144
|
+
type ArchiveConfig = record {
|
|
145
|
+
// The allowed module hash of the archive canister.
|
|
146
|
+
// Changing this parameter does _not_ deploy the archive, but enable archive deployments with the
|
|
147
|
+
// corresponding wasm module.
|
|
148
|
+
module_hash : blob;
|
|
149
|
+
// Buffered archive entries limit. If reached, II will stop accepting new anchor operations
|
|
150
|
+
// until the buffered operations are acknowledged by the archive.
|
|
151
|
+
// Currently unused: in preparation of switching the archive integration to pull.
|
|
152
|
+
// Configured value will be discarded for storage_layout_version < 6.
|
|
153
|
+
entries_buffer_limit: nat64;
|
|
154
|
+
// The maximum number of entries to be transferred to the archive per call.
|
|
155
|
+
// Currently unused: in preparation of switching the archive integration to pull.
|
|
156
|
+
// Configured value will be discarded for storage_layout_version < 6.
|
|
157
|
+
entries_fetch_limit: nat16;
|
|
158
|
+
// Polling interval to fetch new entries from II (in nanoseconds).
|
|
159
|
+
// Changes to this parameter will only take effect after an archive deployment.
|
|
160
|
+
// Currently unused: in preparation of switching the archive integration to pull.
|
|
161
|
+
// Configured value will be discarded for storage_layout_version < 6.
|
|
162
|
+
polling_interval_ns: nat64;
|
|
163
|
+
|
|
164
|
+
// How the entries get transferred to the archive.
|
|
165
|
+
// This is opt, so that the config parameter can be removed after switching from push to pull.
|
|
166
|
+
// Configured value will be discarded for storage_layout_version < 6.
|
|
167
|
+
archive_integration: opt variant {
|
|
168
|
+
// II pushes the entries to the archive (legacy variant).
|
|
169
|
+
push;
|
|
170
|
+
// The archive pulls the entries from II.
|
|
171
|
+
pull;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Information about the archive.
|
|
176
|
+
type ArchiveInfo = record {
|
|
177
|
+
// Canister id of the archive or empty if no archive has been deployed yet.
|
|
178
|
+
archive_canister : opt principal;
|
|
179
|
+
// Configuration parameters related to the II archive.
|
|
180
|
+
archive_config: opt ArchiveConfig;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// Init arguments of II which can be supplied on install and upgrade.
|
|
184
|
+
// Setting a value to null keeps the previous value.
|
|
185
|
+
type InternetIdentityInit = record {
|
|
186
|
+
// Set lowest and highest anchor
|
|
187
|
+
assigned_user_number_range : opt record {
|
|
188
|
+
nat64;
|
|
189
|
+
nat64;
|
|
190
|
+
};
|
|
191
|
+
// Configuration parameters related to the II archive.
|
|
192
|
+
// Note: some parameters changes (like the polling interval) will only take effect after an archive deployment.
|
|
193
|
+
// See ArchiveConfig for details.
|
|
194
|
+
archive_config: opt ArchiveConfig;
|
|
195
|
+
// Set the amounts of cycles sent with the create canister message.
|
|
196
|
+
// This is configurable because in the staging environment cycles are required.
|
|
197
|
+
// The canister creation cost on mainnet is currently 100'000'000'000 cycles. If this value is higher thant the
|
|
198
|
+
// canister creation cost, the newly created canister will keep extra cycles.
|
|
199
|
+
canister_creation_cycles_cost : opt nat64;
|
|
200
|
+
// Config flag to upgrade the persistent state. If set to opt true it will migrate the storage layout to version 6.
|
|
201
|
+
upgrade_persistent_state: opt bool;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
type ChallengeKey = text;
|
|
205
|
+
|
|
206
|
+
type ChallengeResult = record {
|
|
207
|
+
key : ChallengeKey;
|
|
208
|
+
chars : text;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
type DeviceRegistrationInfo = record {
|
|
212
|
+
tentative_device : opt DeviceData;
|
|
213
|
+
expiration: Timestamp;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
type IdentityAnchorInfo = record {
|
|
217
|
+
devices : vec DeviceData;
|
|
218
|
+
device_registration: opt DeviceRegistrationInfo;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
type DeployArchiveResult = variant {
|
|
222
|
+
// The archive was deployed successfully and the supplied wasm module has been installed. The principal of the archive
|
|
223
|
+
// canister is returned.
|
|
224
|
+
success: principal;
|
|
225
|
+
// Initial archive creation is already in progress.
|
|
226
|
+
creation_in_progress;
|
|
227
|
+
// Archive deployment failed. An error description is returned.
|
|
228
|
+
failed: text;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
type BufferedArchiveEntry = record {
|
|
232
|
+
anchor_number: UserNumber;
|
|
233
|
+
timestamp: Timestamp;
|
|
234
|
+
sequence_number: nat64;
|
|
235
|
+
entry: blob;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
service : (opt InternetIdentityInit) -> {
|
|
240
|
+
init_salt: () -> ();
|
|
241
|
+
create_challenge : () -> (Challenge);
|
|
242
|
+
register : (DeviceData, ChallengeResult) -> (RegisterResponse);
|
|
243
|
+
add : (UserNumber, DeviceData) -> ();
|
|
244
|
+
update : (UserNumber, DeviceKey, DeviceData) -> ();
|
|
245
|
+
// Atomically replace device matching the device key with the new device data
|
|
246
|
+
replace : (UserNumber, DeviceKey, DeviceData) -> ();
|
|
247
|
+
remove : (UserNumber, DeviceKey) -> ();
|
|
248
|
+
// Returns all devices of the user (authentication and recovery) but no information about device registrations.
|
|
249
|
+
// Note: Will be changed in the future to be more consistent with get_anchor_info.
|
|
250
|
+
lookup : (UserNumber) -> (vec DeviceData) query;
|
|
251
|
+
get_anchor_info : (UserNumber) -> (IdentityAnchorInfo);
|
|
252
|
+
get_principal : (UserNumber, FrontendHostname) -> (principal) query;
|
|
253
|
+
stats : () -> (InternetIdentityStats) query;
|
|
254
|
+
|
|
255
|
+
enter_device_registration_mode : (UserNumber) -> (Timestamp);
|
|
256
|
+
exit_device_registration_mode : (UserNumber) -> ();
|
|
257
|
+
add_tentative_device : (UserNumber, DeviceData) -> (AddTentativeDeviceResponse);
|
|
258
|
+
verify_tentative_device : (UserNumber, verification_code: text) -> (VerifyTentativeDeviceResponse);
|
|
259
|
+
|
|
260
|
+
prepare_delegation : (UserNumber, FrontendHostname, SessionKey, maxTimeToLive : opt nat64) -> (UserKey, Timestamp);
|
|
261
|
+
get_delegation: (UserNumber, FrontendHostname, SessionKey, Timestamp) -> (GetDelegationResponse) query;
|
|
262
|
+
|
|
263
|
+
http_request: (request: HttpRequest) -> (HttpResponse) query;
|
|
264
|
+
|
|
265
|
+
deploy_archive: (wasm: blob) -> (DeployArchiveResult);
|
|
266
|
+
/// Returns a batch of entries _sorted by sequence number_ to be archived.
|
|
267
|
+
/// This is an update call because the archive information _must_ be certified.
|
|
268
|
+
/// Only callable by this IIs archive canister.
|
|
269
|
+
fetch_entries: () -> (vec BufferedArchiveEntry);
|
|
270
|
+
acknowledge_entries: (sequence_number: nat64) -> ();
|
|
271
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type {ActorMethod} from '@dfinity/agent';
|
|
2
|
+
import type {Principal} from '@dfinity/principal';
|
|
3
|
+
|
|
4
|
+
export type AddTentativeDeviceResponse =
|
|
5
|
+
| {
|
|
6
|
+
device_registration_mode_off: null;
|
|
7
|
+
}
|
|
8
|
+
| {another_device_tentatively_added: null}
|
|
9
|
+
| {
|
|
10
|
+
added_tentatively: {
|
|
11
|
+
verification_code: string;
|
|
12
|
+
device_registration_timeout: Timestamp;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export interface ArchiveConfig {
|
|
16
|
+
polling_interval_ns: bigint;
|
|
17
|
+
entries_buffer_limit: bigint;
|
|
18
|
+
archive_integration: [] | [{pull: null} | {push: null}];
|
|
19
|
+
module_hash: Uint8Array;
|
|
20
|
+
entries_fetch_limit: number;
|
|
21
|
+
}
|
|
22
|
+
export interface ArchiveInfo {
|
|
23
|
+
archive_config: [] | [ArchiveConfig];
|
|
24
|
+
archive_canister: [] | [Principal];
|
|
25
|
+
}
|
|
26
|
+
export interface BufferedArchiveEntry {
|
|
27
|
+
sequence_number: bigint;
|
|
28
|
+
entry: Uint8Array;
|
|
29
|
+
anchor_number: UserNumber;
|
|
30
|
+
timestamp: Timestamp;
|
|
31
|
+
}
|
|
32
|
+
export interface Challenge {
|
|
33
|
+
png_base64: string;
|
|
34
|
+
challenge_key: ChallengeKey;
|
|
35
|
+
}
|
|
36
|
+
export type ChallengeKey = string;
|
|
37
|
+
export interface ChallengeResult {
|
|
38
|
+
key: ChallengeKey;
|
|
39
|
+
chars: string;
|
|
40
|
+
}
|
|
41
|
+
export type CredentialId = Uint8Array;
|
|
42
|
+
export interface Delegation {
|
|
43
|
+
pubkey: PublicKey;
|
|
44
|
+
targets: [] | [Array<Principal>];
|
|
45
|
+
expiration: Timestamp;
|
|
46
|
+
}
|
|
47
|
+
export type DeployArchiveResult =
|
|
48
|
+
| {creation_in_progress: null}
|
|
49
|
+
| {success: Principal}
|
|
50
|
+
| {failed: string};
|
|
51
|
+
export interface DeviceData {
|
|
52
|
+
alias: string;
|
|
53
|
+
protection: DeviceProtection;
|
|
54
|
+
pubkey: DeviceKey;
|
|
55
|
+
key_type: KeyType;
|
|
56
|
+
purpose: Purpose;
|
|
57
|
+
credential_id: [] | [CredentialId];
|
|
58
|
+
}
|
|
59
|
+
export type DeviceKey = PublicKey;
|
|
60
|
+
export type DeviceProtection = {unprotected: null} | {protected: null};
|
|
61
|
+
export interface DeviceRegistrationInfo {
|
|
62
|
+
tentative_device: [] | [DeviceData];
|
|
63
|
+
expiration: Timestamp;
|
|
64
|
+
}
|
|
65
|
+
export type FrontendHostname = string;
|
|
66
|
+
export type GetDelegationResponse =
|
|
67
|
+
| {no_such_delegation: null}
|
|
68
|
+
| {signed_delegation: SignedDelegation};
|
|
69
|
+
export type HeaderField = [string, string];
|
|
70
|
+
export interface HttpRequest {
|
|
71
|
+
url: string;
|
|
72
|
+
method: string;
|
|
73
|
+
body: Uint8Array;
|
|
74
|
+
headers: Array<HeaderField>;
|
|
75
|
+
}
|
|
76
|
+
export interface HttpResponse {
|
|
77
|
+
body: Uint8Array;
|
|
78
|
+
headers: Array<HeaderField>;
|
|
79
|
+
streaming_strategy: [] | [StreamingStrategy];
|
|
80
|
+
status_code: number;
|
|
81
|
+
}
|
|
82
|
+
export interface IdentityAnchorInfo {
|
|
83
|
+
devices: Array<DeviceData>;
|
|
84
|
+
device_registration: [] | [DeviceRegistrationInfo];
|
|
85
|
+
}
|
|
86
|
+
export interface InternetIdentityInit {
|
|
87
|
+
upgrade_persistent_state: [] | [boolean];
|
|
88
|
+
assigned_user_number_range: [] | [[bigint, bigint]];
|
|
89
|
+
archive_config: [] | [ArchiveConfig];
|
|
90
|
+
canister_creation_cycles_cost: [] | [bigint];
|
|
91
|
+
}
|
|
92
|
+
export interface InternetIdentityStats {
|
|
93
|
+
storage_layout_version: number;
|
|
94
|
+
users_registered: bigint;
|
|
95
|
+
assigned_user_number_range: [bigint, bigint];
|
|
96
|
+
archive_info: ArchiveInfo;
|
|
97
|
+
canister_creation_cycles_cost: bigint;
|
|
98
|
+
}
|
|
99
|
+
export type KeyType =
|
|
100
|
+
| {platform: null}
|
|
101
|
+
| {seed_phrase: null}
|
|
102
|
+
| {cross_platform: null}
|
|
103
|
+
| {unknown: null};
|
|
104
|
+
export type PublicKey = Uint8Array;
|
|
105
|
+
export type Purpose = {authentication: null} | {recovery: null};
|
|
106
|
+
export type RegisterResponse =
|
|
107
|
+
| {bad_challenge: null}
|
|
108
|
+
| {canister_full: null}
|
|
109
|
+
| {registered: {user_number: UserNumber}};
|
|
110
|
+
export type SessionKey = PublicKey;
|
|
111
|
+
export interface SignedDelegation {
|
|
112
|
+
signature: Uint8Array;
|
|
113
|
+
delegation: Delegation;
|
|
114
|
+
}
|
|
115
|
+
export interface StreamingCallbackHttpResponse {
|
|
116
|
+
token: [] | [Token];
|
|
117
|
+
body: Uint8Array;
|
|
118
|
+
}
|
|
119
|
+
export type StreamingStrategy = {
|
|
120
|
+
Callback: {token: Token; callback: [Principal, string]};
|
|
121
|
+
};
|
|
122
|
+
export type Timestamp = bigint;
|
|
123
|
+
export type Token = {};
|
|
124
|
+
export type UserKey = PublicKey;
|
|
125
|
+
export type UserNumber = bigint;
|
|
126
|
+
export type VerifyTentativeDeviceResponse =
|
|
127
|
+
| {
|
|
128
|
+
device_registration_mode_off: null;
|
|
129
|
+
}
|
|
130
|
+
| {verified: null}
|
|
131
|
+
| {wrong_code: {retries_left: number}}
|
|
132
|
+
| {no_device_to_verify: null};
|
|
133
|
+
export interface _SERVICE {
|
|
134
|
+
acknowledge_entries: ActorMethod<[bigint], undefined>;
|
|
135
|
+
add: ActorMethod<[UserNumber, DeviceData], undefined>;
|
|
136
|
+
add_tentative_device: ActorMethod<[UserNumber, DeviceData], AddTentativeDeviceResponse>;
|
|
137
|
+
create_challenge: ActorMethod<[], Challenge>;
|
|
138
|
+
deploy_archive: ActorMethod<[Uint8Array], DeployArchiveResult>;
|
|
139
|
+
enter_device_registration_mode: ActorMethod<[UserNumber], Timestamp>;
|
|
140
|
+
exit_device_registration_mode: ActorMethod<[UserNumber], undefined>;
|
|
141
|
+
fetch_entries: ActorMethod<[], Array<BufferedArchiveEntry>>;
|
|
142
|
+
get_anchor_info: ActorMethod<[UserNumber], IdentityAnchorInfo>;
|
|
143
|
+
get_delegation: ActorMethod<
|
|
144
|
+
[UserNumber, FrontendHostname, SessionKey, Timestamp],
|
|
145
|
+
GetDelegationResponse
|
|
146
|
+
>;
|
|
147
|
+
get_principal: ActorMethod<[UserNumber, FrontendHostname], Principal>;
|
|
148
|
+
http_request: ActorMethod<[HttpRequest], HttpResponse>;
|
|
149
|
+
init_salt: ActorMethod<[], undefined>;
|
|
150
|
+
lookup: ActorMethod<[UserNumber], Array<DeviceData>>;
|
|
151
|
+
prepare_delegation: ActorMethod<
|
|
152
|
+
[UserNumber, FrontendHostname, SessionKey, [] | [bigint]],
|
|
153
|
+
[UserKey, Timestamp]
|
|
154
|
+
>;
|
|
155
|
+
register: ActorMethod<[DeviceData, ChallengeResult], RegisterResponse>;
|
|
156
|
+
remove: ActorMethod<[UserNumber, DeviceKey], undefined>;
|
|
157
|
+
replace: ActorMethod<[UserNumber, DeviceKey, DeviceData], undefined>;
|
|
158
|
+
stats: ActorMethod<[], InternetIdentityStats>;
|
|
159
|
+
update: ActorMethod<[UserNumber, DeviceKey, DeviceData], undefined>;
|
|
160
|
+
verify_tentative_device: ActorMethod<[UserNumber, string], VerifyTentativeDeviceResponse>;
|
|
161
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
export const idlFactory = ({IDL}) => {
|
|
2
|
+
const ArchiveConfig = IDL.Record({
|
|
3
|
+
polling_interval_ns: IDL.Nat64,
|
|
4
|
+
entries_buffer_limit: IDL.Nat64,
|
|
5
|
+
archive_integration: IDL.Opt(IDL.Variant({pull: IDL.Null, push: IDL.Null})),
|
|
6
|
+
module_hash: IDL.Vec(IDL.Nat8),
|
|
7
|
+
entries_fetch_limit: IDL.Nat16
|
|
8
|
+
});
|
|
9
|
+
const InternetIdentityInit = IDL.Record({
|
|
10
|
+
upgrade_persistent_state: IDL.Opt(IDL.Bool),
|
|
11
|
+
assigned_user_number_range: IDL.Opt(IDL.Tuple(IDL.Nat64, IDL.Nat64)),
|
|
12
|
+
archive_config: IDL.Opt(ArchiveConfig),
|
|
13
|
+
canister_creation_cycles_cost: IDL.Opt(IDL.Nat64)
|
|
14
|
+
});
|
|
15
|
+
const UserNumber = IDL.Nat64;
|
|
16
|
+
const DeviceProtection = IDL.Variant({
|
|
17
|
+
unprotected: IDL.Null,
|
|
18
|
+
protected: IDL.Null
|
|
19
|
+
});
|
|
20
|
+
const PublicKey = IDL.Vec(IDL.Nat8);
|
|
21
|
+
const DeviceKey = PublicKey;
|
|
22
|
+
const KeyType = IDL.Variant({
|
|
23
|
+
platform: IDL.Null,
|
|
24
|
+
seed_phrase: IDL.Null,
|
|
25
|
+
cross_platform: IDL.Null,
|
|
26
|
+
unknown: IDL.Null
|
|
27
|
+
});
|
|
28
|
+
const Purpose = IDL.Variant({
|
|
29
|
+
authentication: IDL.Null,
|
|
30
|
+
recovery: IDL.Null
|
|
31
|
+
});
|
|
32
|
+
const CredentialId = IDL.Vec(IDL.Nat8);
|
|
33
|
+
const DeviceData = IDL.Record({
|
|
34
|
+
alias: IDL.Text,
|
|
35
|
+
protection: DeviceProtection,
|
|
36
|
+
pubkey: DeviceKey,
|
|
37
|
+
key_type: KeyType,
|
|
38
|
+
purpose: Purpose,
|
|
39
|
+
credential_id: IDL.Opt(CredentialId)
|
|
40
|
+
});
|
|
41
|
+
const Timestamp = IDL.Nat64;
|
|
42
|
+
const AddTentativeDeviceResponse = IDL.Variant({
|
|
43
|
+
device_registration_mode_off: IDL.Null,
|
|
44
|
+
another_device_tentatively_added: IDL.Null,
|
|
45
|
+
added_tentatively: IDL.Record({
|
|
46
|
+
verification_code: IDL.Text,
|
|
47
|
+
device_registration_timeout: Timestamp
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
const ChallengeKey = IDL.Text;
|
|
51
|
+
const Challenge = IDL.Record({
|
|
52
|
+
png_base64: IDL.Text,
|
|
53
|
+
challenge_key: ChallengeKey
|
|
54
|
+
});
|
|
55
|
+
const DeployArchiveResult = IDL.Variant({
|
|
56
|
+
creation_in_progress: IDL.Null,
|
|
57
|
+
success: IDL.Principal,
|
|
58
|
+
failed: IDL.Text
|
|
59
|
+
});
|
|
60
|
+
const BufferedArchiveEntry = IDL.Record({
|
|
61
|
+
sequence_number: IDL.Nat64,
|
|
62
|
+
entry: IDL.Vec(IDL.Nat8),
|
|
63
|
+
anchor_number: UserNumber,
|
|
64
|
+
timestamp: Timestamp
|
|
65
|
+
});
|
|
66
|
+
const DeviceRegistrationInfo = IDL.Record({
|
|
67
|
+
tentative_device: IDL.Opt(DeviceData),
|
|
68
|
+
expiration: Timestamp
|
|
69
|
+
});
|
|
70
|
+
const IdentityAnchorInfo = IDL.Record({
|
|
71
|
+
devices: IDL.Vec(DeviceData),
|
|
72
|
+
device_registration: IDL.Opt(DeviceRegistrationInfo)
|
|
73
|
+
});
|
|
74
|
+
const FrontendHostname = IDL.Text;
|
|
75
|
+
const SessionKey = PublicKey;
|
|
76
|
+
const Delegation = IDL.Record({
|
|
77
|
+
pubkey: PublicKey,
|
|
78
|
+
targets: IDL.Opt(IDL.Vec(IDL.Principal)),
|
|
79
|
+
expiration: Timestamp
|
|
80
|
+
});
|
|
81
|
+
const SignedDelegation = IDL.Record({
|
|
82
|
+
signature: IDL.Vec(IDL.Nat8),
|
|
83
|
+
delegation: Delegation
|
|
84
|
+
});
|
|
85
|
+
const GetDelegationResponse = IDL.Variant({
|
|
86
|
+
no_such_delegation: IDL.Null,
|
|
87
|
+
signed_delegation: SignedDelegation
|
|
88
|
+
});
|
|
89
|
+
const HeaderField = IDL.Tuple(IDL.Text, IDL.Text);
|
|
90
|
+
const HttpRequest = IDL.Record({
|
|
91
|
+
url: IDL.Text,
|
|
92
|
+
method: IDL.Text,
|
|
93
|
+
body: IDL.Vec(IDL.Nat8),
|
|
94
|
+
headers: IDL.Vec(HeaderField)
|
|
95
|
+
});
|
|
96
|
+
const Token = IDL.Record({});
|
|
97
|
+
const StreamingCallbackHttpResponse = IDL.Record({
|
|
98
|
+
token: IDL.Opt(Token),
|
|
99
|
+
body: IDL.Vec(IDL.Nat8)
|
|
100
|
+
});
|
|
101
|
+
const StreamingStrategy = IDL.Variant({
|
|
102
|
+
Callback: IDL.Record({
|
|
103
|
+
token: Token,
|
|
104
|
+
callback: IDL.Func([Token], [StreamingCallbackHttpResponse], ['query'])
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
const HttpResponse = IDL.Record({
|
|
108
|
+
body: IDL.Vec(IDL.Nat8),
|
|
109
|
+
headers: IDL.Vec(HeaderField),
|
|
110
|
+
streaming_strategy: IDL.Opt(StreamingStrategy),
|
|
111
|
+
status_code: IDL.Nat16
|
|
112
|
+
});
|
|
113
|
+
const UserKey = PublicKey;
|
|
114
|
+
const ChallengeResult = IDL.Record({
|
|
115
|
+
key: ChallengeKey,
|
|
116
|
+
chars: IDL.Text
|
|
117
|
+
});
|
|
118
|
+
const RegisterResponse = IDL.Variant({
|
|
119
|
+
bad_challenge: IDL.Null,
|
|
120
|
+
canister_full: IDL.Null,
|
|
121
|
+
registered: IDL.Record({user_number: UserNumber})
|
|
122
|
+
});
|
|
123
|
+
const ArchiveInfo = IDL.Record({
|
|
124
|
+
archive_config: IDL.Opt(ArchiveConfig),
|
|
125
|
+
archive_canister: IDL.Opt(IDL.Principal)
|
|
126
|
+
});
|
|
127
|
+
const InternetIdentityStats = IDL.Record({
|
|
128
|
+
storage_layout_version: IDL.Nat8,
|
|
129
|
+
users_registered: IDL.Nat64,
|
|
130
|
+
assigned_user_number_range: IDL.Tuple(IDL.Nat64, IDL.Nat64),
|
|
131
|
+
archive_info: ArchiveInfo,
|
|
132
|
+
canister_creation_cycles_cost: IDL.Nat64
|
|
133
|
+
});
|
|
134
|
+
const VerifyTentativeDeviceResponse = IDL.Variant({
|
|
135
|
+
device_registration_mode_off: IDL.Null,
|
|
136
|
+
verified: IDL.Null,
|
|
137
|
+
wrong_code: IDL.Record({retries_left: IDL.Nat8}),
|
|
138
|
+
no_device_to_verify: IDL.Null
|
|
139
|
+
});
|
|
140
|
+
return IDL.Service({
|
|
141
|
+
acknowledge_entries: IDL.Func([IDL.Nat64], [], []),
|
|
142
|
+
add: IDL.Func([UserNumber, DeviceData], [], []),
|
|
143
|
+
add_tentative_device: IDL.Func([UserNumber, DeviceData], [AddTentativeDeviceResponse], []),
|
|
144
|
+
create_challenge: IDL.Func([], [Challenge], []),
|
|
145
|
+
deploy_archive: IDL.Func([IDL.Vec(IDL.Nat8)], [DeployArchiveResult], []),
|
|
146
|
+
enter_device_registration_mode: IDL.Func([UserNumber], [Timestamp], []),
|
|
147
|
+
exit_device_registration_mode: IDL.Func([UserNumber], [], []),
|
|
148
|
+
fetch_entries: IDL.Func([], [IDL.Vec(BufferedArchiveEntry)], []),
|
|
149
|
+
get_anchor_info: IDL.Func([UserNumber], [IdentityAnchorInfo], []),
|
|
150
|
+
get_delegation: IDL.Func(
|
|
151
|
+
[UserNumber, FrontendHostname, SessionKey, Timestamp],
|
|
152
|
+
[GetDelegationResponse],
|
|
153
|
+
['query']
|
|
154
|
+
),
|
|
155
|
+
get_principal: IDL.Func([UserNumber, FrontendHostname], [IDL.Principal], ['query']),
|
|
156
|
+
http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
|
|
157
|
+
init_salt: IDL.Func([], [], []),
|
|
158
|
+
lookup: IDL.Func([UserNumber], [IDL.Vec(DeviceData)], ['query']),
|
|
159
|
+
prepare_delegation: IDL.Func(
|
|
160
|
+
[UserNumber, FrontendHostname, SessionKey, IDL.Opt(IDL.Nat64)],
|
|
161
|
+
[UserKey, Timestamp],
|
|
162
|
+
[]
|
|
163
|
+
),
|
|
164
|
+
register: IDL.Func([DeviceData, ChallengeResult], [RegisterResponse], []),
|
|
165
|
+
remove: IDL.Func([UserNumber, DeviceKey], [], []),
|
|
166
|
+
replace: IDL.Func([UserNumber, DeviceKey, DeviceData], [], []),
|
|
167
|
+
stats: IDL.Func([], [InternetIdentityStats], ['query']),
|
|
168
|
+
update: IDL.Func([UserNumber, DeviceKey, DeviceData], [], []),
|
|
169
|
+
verify_tentative_device: IDL.Func([UserNumber, IDL.Text], [VerifyTentativeDeviceResponse], [])
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
export const init = ({IDL}) => {
|
|
173
|
+
const ArchiveConfig = IDL.Record({
|
|
174
|
+
polling_interval_ns: IDL.Nat64,
|
|
175
|
+
entries_buffer_limit: IDL.Nat64,
|
|
176
|
+
archive_integration: IDL.Opt(IDL.Variant({pull: IDL.Null, push: IDL.Null})),
|
|
177
|
+
module_hash: IDL.Vec(IDL.Nat8),
|
|
178
|
+
entries_fetch_limit: IDL.Nat16
|
|
179
|
+
});
|
|
180
|
+
const InternetIdentityInit = IDL.Record({
|
|
181
|
+
upgrade_persistent_state: IDL.Opt(IDL.Bool),
|
|
182
|
+
assigned_user_number_range: IDL.Opt(IDL.Tuple(IDL.Nat64, IDL.Nat64)),
|
|
183
|
+
archive_config: IDL.Opt(ArchiveConfig),
|
|
184
|
+
canister_creation_cycles_cost: IDL.Opt(IDL.Nat64)
|
|
185
|
+
});
|
|
186
|
+
return [IDL.Opt(InternetIdentityInit)];
|
|
187
|
+
};
|
|
@@ -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>;
|