@holochain/client 0.18.0-dev.4 → 0.18.0-dev.6
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/lib/api/admin/types.d.ts +31 -2
- package/lib/api/admin/websocket.d.ts +2 -1
- package/lib/api/admin/websocket.js +3 -0
- package/lib/api/app/types.d.ts +8 -0
- package/lib/api/app/websocket.d.ts +6 -0
- package/lib/api/app/websocket.js +9 -0
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/utils/hash-parts.d.ts +10 -10
- package/lib/utils/hash-parts.js +21 -13
- package/package.json +1 -1
package/lib/api/admin/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk/index.js";
|
|
2
|
-
import { ActionHash, AgentPubKey, CellId, DnaHash, DnaProperties, Duration, HoloHash, HoloHashB64, InstalledAppId, KitsuneAgent, KitsuneSpace, RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
|
|
2
|
+
import { ActionHash, AgentPubKey, CellId, DnaHash, DnaHashB64, DnaProperties, Duration, HoloHash, HoloHashB64, InstalledAppId, KitsuneAgent, KitsuneSpace, RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
|
|
3
3
|
import { Requester } from "../common.js";
|
|
4
4
|
/**
|
|
5
5
|
* @public
|
|
@@ -52,7 +52,7 @@ export type PausedAppReason = {
|
|
|
52
52
|
/**
|
|
53
53
|
* @public
|
|
54
54
|
*/
|
|
55
|
-
export type DisabledAppReason = "never_started" | "user" | {
|
|
55
|
+
export type DisabledAppReason = "never_started" | "user" | "not_started_after_providing_memproofs" | {
|
|
56
56
|
error: string;
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
@@ -234,6 +234,7 @@ export type CoordinatorZome = ZomeDefinition;
|
|
|
234
234
|
export type DnaDefinition = {
|
|
235
235
|
name: string;
|
|
236
236
|
modifiers: DnaModifiers;
|
|
237
|
+
lineage: DnaHashB64[];
|
|
237
238
|
integrity_zomes: IntegrityZome[];
|
|
238
239
|
coordinator_zomes: CoordinatorZome[];
|
|
239
240
|
};
|
|
@@ -245,6 +246,14 @@ export type GetDnaDefinitionRequest = DnaHash;
|
|
|
245
246
|
* @public
|
|
246
247
|
*/
|
|
247
248
|
export type GetDnaDefinitionResponse = DnaDefinition;
|
|
249
|
+
/**
|
|
250
|
+
* @public
|
|
251
|
+
*/
|
|
252
|
+
export type GetCompatibleCellsRequest = DnaHashB64;
|
|
253
|
+
/**
|
|
254
|
+
* @public
|
|
255
|
+
*/
|
|
256
|
+
export type GetCompatibleCellsResponse = Set<[InstalledAppId, Set<CellId>]>;
|
|
248
257
|
/**
|
|
249
258
|
* @public
|
|
250
259
|
*/
|
|
@@ -610,6 +619,26 @@ export type DnaManifest = {
|
|
|
610
619
|
* The order is significant: it determines initialization order.
|
|
611
620
|
*/
|
|
612
621
|
zomes: Array<ZomeManifest>;
|
|
622
|
+
/**
|
|
623
|
+
* A list of past "ancestors" of this DNA.
|
|
624
|
+
*
|
|
625
|
+
* Whenever a DNA is created which is intended to be used as a migration from
|
|
626
|
+
* a previous DNA, the lineage should be updated to include the hash of the
|
|
627
|
+
* DNA being migrated from. DNA hashes may also be removed from this list if
|
|
628
|
+
* it is desired to remove them from the lineage.
|
|
629
|
+
*
|
|
630
|
+
* The meaning of the "ancestor" relationship is as follows:
|
|
631
|
+
* - For any DNA, there is a migration path from any of its ancestors to itself.
|
|
632
|
+
* - When an app depends on a DnaHash via UseExisting, it means that any installed
|
|
633
|
+
* DNA in the lineage which contains that DnaHash can be used.
|
|
634
|
+
* - The app's Coordinator interface is expected to be compatible across the lineage.
|
|
635
|
+
* (Though this cannot be enforced, since Coordinators can be swapped out at
|
|
636
|
+
* will by the user, the intention is still there.)
|
|
637
|
+
*
|
|
638
|
+
* Holochain does nothing to ensure the correctness of the lineage, it is up to
|
|
639
|
+
* the app developer to make the necessary guarantees.
|
|
640
|
+
*/
|
|
641
|
+
lineage: DnaHashB64[];
|
|
613
642
|
};
|
|
614
643
|
/**
|
|
615
644
|
* @public
|
|
@@ -2,7 +2,7 @@ import { CapSecret, GrantedFunctions } from "../../hdk/index.js";
|
|
|
2
2
|
import type { AgentPubKey, CellId } from "../../types.js";
|
|
3
3
|
import { WsClient } from "../client.js";
|
|
4
4
|
import { Requester, Transformer, WebsocketConnectionOptions } from "../common.js";
|
|
5
|
-
import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpNetworkStatsRequest, DumpNetworkStatsResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, IssueAppAuthenticationTokenRequest, IssueAppAuthenticationTokenResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, StorageInfoRequest, StorageInfoResponse, UninstallAppRequest, UninstallAppResponse, UpdateCoordinatorsRequest, UpdateCoordinatorsResponse } from "./types.js";
|
|
5
|
+
import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpNetworkStatsRequest, DumpNetworkStatsResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetCompatibleCellsRequest, GetCompatibleCellsResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, IssueAppAuthenticationTokenRequest, IssueAppAuthenticationTokenResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, StorageInfoRequest, StorageInfoResponse, UninstallAppRequest, UninstallAppResponse, UpdateCoordinatorsRequest, UpdateCoordinatorsResponse } from "./types.js";
|
|
6
6
|
/**
|
|
7
7
|
* A class for interacting with a conductor's Admin API.
|
|
8
8
|
*
|
|
@@ -61,6 +61,7 @@ export declare class AdminWebsocket implements AdminApi {
|
|
|
61
61
|
* Get the DNA definition for the specified DNA hash.
|
|
62
62
|
*/
|
|
63
63
|
getDnaDefinition: Requester<GetDnaDefinitionRequest, GetDnaDefinitionResponse>;
|
|
64
|
+
getCompatibleCells: Requester<GetCompatibleCellsRequest, GetCompatibleCellsResponse>;
|
|
64
65
|
/**
|
|
65
66
|
* Uninstall the specified app from Holochain.
|
|
66
67
|
*/
|
|
@@ -78,6 +78,9 @@ export class AdminWebsocket {
|
|
|
78
78
|
* Get the DNA definition for the specified DNA hash.
|
|
79
79
|
*/
|
|
80
80
|
getDnaDefinition = this._requester("get_dna_definition");
|
|
81
|
+
/// Find installed cells which use a DNA that's forward-compatible with the given DNA hash.
|
|
82
|
+
/// Namely, this finds cells with DNAs whose manifest lists the given DNA hash in its `lineage` field.
|
|
83
|
+
getCompatibleCells = this._requester("get_compatible_cells");
|
|
81
84
|
/**
|
|
82
85
|
* Uninstall the specified app from Holochain.
|
|
83
86
|
*/
|
package/lib/api/app/types.d.ts
CHANGED
|
@@ -90,6 +90,14 @@ export type ProvideMemproofsRequest = MemproofMap;
|
|
|
90
90
|
* @public
|
|
91
91
|
*/
|
|
92
92
|
export type ProvideMemproofsResponse = void;
|
|
93
|
+
/**
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export type EnableRequest = void;
|
|
97
|
+
/**
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
export type EnableResponse = void;
|
|
93
101
|
/**
|
|
94
102
|
* @public
|
|
95
103
|
*/
|
|
@@ -20,6 +20,7 @@ export declare class AppWebsocket implements AppClient {
|
|
|
20
20
|
private readonly appInfoRequester;
|
|
21
21
|
private readonly callZomeRequester;
|
|
22
22
|
private readonly provideMemproofRequester;
|
|
23
|
+
private readonly enableAppRequester;
|
|
23
24
|
private readonly createCloneCellRequester;
|
|
24
25
|
private readonly enableCloneCellRequester;
|
|
25
26
|
private readonly disableCloneCellRequester;
|
|
@@ -46,6 +47,11 @@ export declare class AppWebsocket implements AppClient {
|
|
|
46
47
|
* @param memproofs - A map of {@link MembraneProof}s.
|
|
47
48
|
*/
|
|
48
49
|
provideMemproofs(memproofs: MemproofMap): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Enablie an app only if the app is in the `AppStatus::Disabled(DisabledAppReason::NotStartedAfterProvidingMemproofs)`
|
|
52
|
+
* state. Attempting to enable the app from other states (other than Running) will fail.
|
|
53
|
+
*/
|
|
54
|
+
enableApp(): Promise<void>;
|
|
49
55
|
/**
|
|
50
56
|
* Get a cell id by its role name or clone id.
|
|
51
57
|
*
|
package/lib/api/app/websocket.js
CHANGED
|
@@ -26,6 +26,7 @@ export class AppWebsocket {
|
|
|
26
26
|
appInfoRequester;
|
|
27
27
|
callZomeRequester;
|
|
28
28
|
provideMemproofRequester;
|
|
29
|
+
enableAppRequester;
|
|
29
30
|
createCloneCellRequester;
|
|
30
31
|
enableCloneCellRequester;
|
|
31
32
|
disableCloneCellRequester;
|
|
@@ -41,6 +42,7 @@ export class AppWebsocket {
|
|
|
41
42
|
this.appInfoRequester = AppWebsocket.requester(this.client, "app_info", this.defaultTimeout);
|
|
42
43
|
this.callZomeRequester = AppWebsocket.requester(this.client, "call_zome", this.defaultTimeout, this.callZomeTransform);
|
|
43
44
|
this.provideMemproofRequester = AppWebsocket.requester(this.client, "provide_memproofs", this.defaultTimeout);
|
|
45
|
+
this.enableAppRequester = AppWebsocket.requester(this.client, "enable_app", this.defaultTimeout);
|
|
44
46
|
this.createCloneCellRequester = AppWebsocket.requester(this.client, "create_clone_cell", this.defaultTimeout);
|
|
45
47
|
this.enableCloneCellRequester = AppWebsocket.requester(this.client, "enable_clone_cell", this.defaultTimeout);
|
|
46
48
|
this.disableCloneCellRequester = AppWebsocket.requester(this.client, "disable_clone_cell", this.defaultTimeout);
|
|
@@ -115,6 +117,13 @@ export class AppWebsocket {
|
|
|
115
117
|
async provideMemproofs(memproofs) {
|
|
116
118
|
await this.provideMemproofRequester(memproofs);
|
|
117
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Enablie an app only if the app is in the `AppStatus::Disabled(DisabledAppReason::NotStartedAfterProvidingMemproofs)`
|
|
122
|
+
* state. Attempting to enable the app from other states (other than Running) will fail.
|
|
123
|
+
*/
|
|
124
|
+
async enableApp() {
|
|
125
|
+
await this.enableAppRequester();
|
|
126
|
+
}
|
|
118
127
|
/**
|
|
119
128
|
* Get a cell id by its role name or clone id.
|
|
120
129
|
*
|
package/lib/tsdoc-metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActionHash, AgentPubKey, EntryHash } from "../types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Hash type labels and their 3 byte values (forming the first 3 bytes of hash)
|
|
3
|
+
* Hash type labels and their 3 byte values (forming the first 3 bytes of hash).
|
|
4
4
|
*
|
|
5
5
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
6
6
|
*
|
|
@@ -14,18 +14,18 @@ export declare const HASH_TYPE_PREFIX: {
|
|
|
14
14
|
External: Uint8Array;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* Get
|
|
17
|
+
* Get hash type (initial 3 bytes) from a hash.
|
|
18
18
|
*
|
|
19
19
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
20
20
|
*
|
|
21
21
|
* @param hash - The full 39 byte hash.
|
|
22
|
-
* @returns The
|
|
22
|
+
* @returns The initial 3 bytes of the hash.
|
|
23
23
|
*
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
26
|
-
export declare function
|
|
26
|
+
export declare function sliceHashType(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array;
|
|
27
27
|
/**
|
|
28
|
-
* Get core
|
|
28
|
+
* Get core hash from a Holochain hash (32 bytes).
|
|
29
29
|
*
|
|
30
30
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
31
31
|
*
|
|
@@ -36,18 +36,18 @@ export declare function sliceDhtLocation(hash: AgentPubKey | EntryHash | ActionH
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function sliceCore32(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array;
|
|
38
38
|
/**
|
|
39
|
-
* Get
|
|
39
|
+
* Get DHT location (last 4 bytes) from a hash.
|
|
40
40
|
*
|
|
41
41
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
42
42
|
*
|
|
43
43
|
* @param hash - The full 39 byte hash.
|
|
44
|
-
* @returns The
|
|
44
|
+
* @returns The last 4 bytes of the hash.
|
|
45
45
|
*
|
|
46
46
|
* @public
|
|
47
47
|
*/
|
|
48
|
-
export declare function
|
|
48
|
+
export declare function sliceDhtLocation(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array;
|
|
49
49
|
/**
|
|
50
|
-
* Generate
|
|
50
|
+
* Generate DHT location (last 4 bytes) from a core hash (middle 32 bytes).
|
|
51
51
|
*
|
|
52
52
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
53
53
|
*
|
|
@@ -58,7 +58,7 @@ export declare function sliceHashType(hash: AgentPubKey | EntryHash | ActionHash
|
|
|
58
58
|
*/
|
|
59
59
|
export declare function dhtLocationFrom32(hashCore: Uint8Array): Uint8Array;
|
|
60
60
|
/**
|
|
61
|
-
* Generate full hash from a core hash (middle 32 bytes) and hash type label
|
|
61
|
+
* Generate full hash from a core hash (middle 32 bytes) and hash type label.
|
|
62
62
|
*
|
|
63
63
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
64
64
|
*
|
package/lib/utils/hash-parts.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import blake2b from "@bitgo/blake2b";
|
|
2
|
+
const HASH_TYPE_START = 0;
|
|
3
|
+
const HASH_TYPE_BYTE_LENGTH = 3;
|
|
4
|
+
const CORE_HASH_BYTE_LENGTH = 32;
|
|
5
|
+
const DHT_LOCATION_BYTE_LENGTH = 4;
|
|
2
6
|
/**
|
|
3
|
-
* Hash type labels and their 3 byte values (forming the first 3 bytes of hash)
|
|
7
|
+
* Hash type labels and their 3 byte values (forming the first 3 bytes of hash).
|
|
4
8
|
*
|
|
5
9
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
6
10
|
*
|
|
@@ -14,20 +18,20 @@ export const HASH_TYPE_PREFIX = {
|
|
|
14
18
|
External: Uint8Array.from([132, 47, 36]),
|
|
15
19
|
};
|
|
16
20
|
/**
|
|
17
|
-
* Get
|
|
21
|
+
* Get hash type (initial 3 bytes) from a hash.
|
|
18
22
|
*
|
|
19
23
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
20
24
|
*
|
|
21
25
|
* @param hash - The full 39 byte hash.
|
|
22
|
-
* @returns The
|
|
26
|
+
* @returns The initial 3 bytes of the hash.
|
|
23
27
|
*
|
|
24
28
|
* @public
|
|
25
29
|
*/
|
|
26
|
-
export function
|
|
27
|
-
return Uint8Array.from(hash.slice(
|
|
30
|
+
export function sliceHashType(hash) {
|
|
31
|
+
return Uint8Array.from(hash.slice(0, 3));
|
|
28
32
|
}
|
|
29
33
|
/**
|
|
30
|
-
* Get core
|
|
34
|
+
* Get core hash from a Holochain hash (32 bytes).
|
|
31
35
|
*
|
|
32
36
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
33
37
|
*
|
|
@@ -37,23 +41,27 @@ export function sliceDhtLocation(hash) {
|
|
|
37
41
|
* @public
|
|
38
42
|
*/
|
|
39
43
|
export function sliceCore32(hash) {
|
|
40
|
-
|
|
44
|
+
const start = HASH_TYPE_START + HASH_TYPE_BYTE_LENGTH;
|
|
45
|
+
const end = start + CORE_HASH_BYTE_LENGTH;
|
|
46
|
+
return Uint8Array.from(hash.slice(start, end));
|
|
41
47
|
}
|
|
42
48
|
/**
|
|
43
|
-
* Get
|
|
49
|
+
* Get DHT location (last 4 bytes) from a hash.
|
|
44
50
|
*
|
|
45
51
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
46
52
|
*
|
|
47
53
|
* @param hash - The full 39 byte hash.
|
|
48
|
-
* @returns The
|
|
54
|
+
* @returns The last 4 bytes of the hash.
|
|
49
55
|
*
|
|
50
56
|
* @public
|
|
51
57
|
*/
|
|
52
|
-
export function
|
|
53
|
-
|
|
58
|
+
export function sliceDhtLocation(hash) {
|
|
59
|
+
const start = HASH_TYPE_START + HASH_TYPE_BYTE_LENGTH + CORE_HASH_BYTE_LENGTH;
|
|
60
|
+
const end = start + DHT_LOCATION_BYTE_LENGTH;
|
|
61
|
+
return Uint8Array.from(hash.slice(start, end));
|
|
54
62
|
}
|
|
55
63
|
/**
|
|
56
|
-
* Generate
|
|
64
|
+
* Generate DHT location (last 4 bytes) from a core hash (middle 32 bytes).
|
|
57
65
|
*
|
|
58
66
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
59
67
|
*
|
|
@@ -75,7 +83,7 @@ export function dhtLocationFrom32(hashCore) {
|
|
|
75
83
|
return out;
|
|
76
84
|
}
|
|
77
85
|
/**
|
|
78
|
-
* Generate full hash from a core hash (middle 32 bytes) and hash type label
|
|
86
|
+
* Generate full hash from a core hash (middle 32 bytes) and hash type label.
|
|
79
87
|
*
|
|
80
88
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
81
89
|
*
|
package/package.json
CHANGED