@holochain/client 0.12.7 → 0.12.8
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 +5 -105
- package/lib/api/admin/websocket.d.ts +2 -8
- package/lib/api/admin/websocket.js +2 -8
- package/lib/api/app/types.d.ts +2 -10
- package/lib/api/app/websocket.d.ts +2 -2
- package/lib/api/app/websocket.js +10 -29
- package/lib/api/app-agent/types.d.ts +1 -6
- package/lib/api/app-agent/websocket.d.ts +3 -11
- package/lib/api/app-agent/websocket.js +8 -24
- package/lib/api/client.d.ts +15 -15
- package/lib/api/client.js +26 -53
- package/lib/api/common.d.ts +1 -9
- package/lib/api/common.js +6 -22
- package/lib/api/index.d.ts +2 -2
- package/lib/api/index.js +2 -2
- package/lib/api/zome-call-signing.d.ts +8 -7
- package/lib/api/zome-call-signing.js +13 -15
- package/lib/environments/launcher.d.ts +3 -25
- package/lib/environments/launcher.js +4 -34
- package/lib/hdk/action.d.ts +3 -13
- package/lib/hdk/capabilities.d.ts +4 -14
- package/lib/hdk/capabilities.js +0 -9
- package/lib/hdk/index.d.ts +0 -1
- package/lib/hdk/index.js +0 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types.d.ts +1 -10
- package/lib/utils/fake-hash.d.ts +4 -8
- package/lib/utils/fake-hash.js +12 -25
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -1
- package/package.json +1 -1
- package/lib/hdk/link.d.ts +0 -48
- package/lib/hdk/link.js +0 -1
- package/lib/utils/hash-parts.d.ts +0 -71
- package/lib/utils/hash-parts.js +0 -94
package/lib/utils/fake-hash.js
CHANGED
|
@@ -1,60 +1,47 @@
|
|
|
1
|
-
import { range } from "lodash-es";
|
|
2
1
|
import { randomByteArray } from "../api/zome-call-signing.js";
|
|
3
|
-
import { dhtLocationFrom32 } from "./hash-parts.js";
|
|
4
|
-
async function fakeValidHash(prefix, coreByte) {
|
|
5
|
-
let core;
|
|
6
|
-
if (coreByte === undefined) {
|
|
7
|
-
core = await randomByteArray(32);
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
core = Uint8Array.from(range(0, 32).map(() => coreByte));
|
|
11
|
-
}
|
|
12
|
-
const checksum = dhtLocationFrom32(core);
|
|
13
|
-
return new Uint8Array([...prefix, ...core, ...Array.from(checksum)]);
|
|
14
|
-
}
|
|
15
2
|
/**
|
|
16
3
|
* Generate a valid hash of a non-existing entry.
|
|
17
4
|
*
|
|
18
5
|
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
19
6
|
*
|
|
20
|
-
* @param coreByte - Optionally specify a byte to repeat for all core 32 bytes. If undefined will generate random core 32 bytes.
|
|
21
7
|
* @returns An {@link EntryHash}.
|
|
22
8
|
*
|
|
23
9
|
* @public
|
|
24
10
|
*/
|
|
25
|
-
export async function fakeEntryHash(
|
|
26
|
-
|
|
11
|
+
export async function fakeEntryHash() {
|
|
12
|
+
const randomBytes = await randomByteArray(36);
|
|
13
|
+
return new Uint8Array([0x84, 0x21, 0x24, ...randomBytes]);
|
|
27
14
|
}
|
|
28
15
|
/**
|
|
29
16
|
* Generate a valid agent key of a non-existing agent.
|
|
30
17
|
*
|
|
31
|
-
* @param coreByte - Optionally specify a byte to repeat for all core 32 bytes. If undefined will generate random core 32 bytes.
|
|
32
18
|
* @returns An {@link AgentPubKey}.
|
|
33
19
|
*
|
|
34
20
|
* @public
|
|
35
21
|
*/
|
|
36
|
-
export async function fakeAgentPubKey(
|
|
37
|
-
|
|
22
|
+
export async function fakeAgentPubKey() {
|
|
23
|
+
const randomBytes = await randomByteArray(36);
|
|
24
|
+
return new Uint8Array([0x84, 0x20, 0x24, ...randomBytes]);
|
|
38
25
|
}
|
|
39
26
|
/**
|
|
40
27
|
* Generate a valid hash of a non-existing action.
|
|
41
28
|
*
|
|
42
|
-
* @param coreByte - Optionally specify a byte to repeat for all core 32 bytes. If undefined will generate random core 32 bytes.
|
|
43
29
|
* @returns An {@link ActionHash}.
|
|
44
30
|
*
|
|
45
31
|
* @public
|
|
46
32
|
*/
|
|
47
|
-
export async function fakeActionHash(
|
|
48
|
-
|
|
33
|
+
export async function fakeActionHash() {
|
|
34
|
+
const randomBytes = await randomByteArray(36);
|
|
35
|
+
return new Uint8Array([0x84, 0x29, 0x24, ...randomBytes]);
|
|
49
36
|
}
|
|
50
37
|
/**
|
|
51
38
|
* Generate a valid hash of a non-existing DNA.
|
|
52
39
|
*
|
|
53
|
-
* @param coreByte - Optionally specify a byte to repeat for all core 32 bytes. If undefined will generate random core 32 bytes.
|
|
54
40
|
* @returns A {@link DnaHash}.
|
|
55
41
|
*
|
|
56
42
|
* @public
|
|
57
43
|
*/
|
|
58
|
-
export async function fakeDnaHash(
|
|
59
|
-
|
|
44
|
+
export async function fakeDnaHash() {
|
|
45
|
+
const randomBytes = await randomByteArray(36);
|
|
46
|
+
return new Uint8Array([0x84, 0x2d, 0x24, ...randomBytes]);
|
|
60
47
|
}
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
package/package.json
CHANGED
package/lib/hdk/link.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { ActionHash, AgentPubKey, EntryHash, ExternalHash, Timestamp } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export type AnyLinkableHash = EntryHash | ActionHash | ExternalHash;
|
|
6
|
-
/**
|
|
7
|
-
* An internal zome index within the DNA, from 0 to 255.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export type ZomeIndex = number;
|
|
12
|
-
/**
|
|
13
|
-
* An internal link type index within the DNA, from 0 to 255.
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export type LinkType = number;
|
|
18
|
-
/**
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
export type LinkTag = Uint8Array;
|
|
22
|
-
/**
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
export interface RateWeight {
|
|
26
|
-
bucket_id: RateBucketId;
|
|
27
|
-
units: RateUnits;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export type RateBucketId = number;
|
|
33
|
-
/**
|
|
34
|
-
* @public
|
|
35
|
-
*/
|
|
36
|
-
export type RateUnits = number;
|
|
37
|
-
/**
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
export interface Link {
|
|
41
|
-
author: AgentPubKey;
|
|
42
|
-
target: AnyLinkableHash;
|
|
43
|
-
timestamp: Timestamp;
|
|
44
|
-
zome_index: ZomeIndex;
|
|
45
|
-
link_type: LinkType;
|
|
46
|
-
tag: Uint8Array;
|
|
47
|
-
create_link_hash: ActionHash;
|
|
48
|
-
}
|
package/lib/hdk/link.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ActionHash, AgentPubKey, EntryHash } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Hash type labels and their 3 byte values (forming the first 3 bytes of hash)
|
|
4
|
-
*
|
|
5
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export declare const HASH_TYPE_PREFIX: {
|
|
10
|
-
Agent: Uint8Array;
|
|
11
|
-
Entry: Uint8Array;
|
|
12
|
-
Dna: Uint8Array;
|
|
13
|
-
Action: Uint8Array;
|
|
14
|
-
External: Uint8Array;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Get dht location (last 4 bytes) from a hash
|
|
18
|
-
*
|
|
19
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
20
|
-
*
|
|
21
|
-
* @param hash - The full 39 byte hash.
|
|
22
|
-
* @returns The last 4 bytes of the hash.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export declare function sliceDhtLocation(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array;
|
|
27
|
-
/**
|
|
28
|
-
* Get core (center 32 bytes) from a hash
|
|
29
|
-
*
|
|
30
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
31
|
-
*
|
|
32
|
-
* @param hash - The full 39 byte hash.
|
|
33
|
-
* @returns The core 32 bytes of the hash.
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export declare function sliceCore32(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array;
|
|
38
|
-
/**
|
|
39
|
-
* Get hash type (initial 3 bytes) from a hash
|
|
40
|
-
*
|
|
41
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
42
|
-
*
|
|
43
|
-
* @param hash - The full 39 byte hash.
|
|
44
|
-
* @returns The initial 3 bytes of the hash.
|
|
45
|
-
*
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
export declare function sliceHashType(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array;
|
|
49
|
-
/**
|
|
50
|
-
* Generate dht location (last 4 bytes) from a core hash (middle 32 bytes)
|
|
51
|
-
*
|
|
52
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
53
|
-
*
|
|
54
|
-
* @param hashCore - The core 32 bytes of the hash.
|
|
55
|
-
* @returns The last 4 bytes of the hash.
|
|
56
|
-
*
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
export declare function dhtLocationFrom32(hashCore: Uint8Array): Uint8Array;
|
|
60
|
-
/**
|
|
61
|
-
* Generate full hash from a core hash (middle 32 bytes) and hash type label
|
|
62
|
-
*
|
|
63
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
64
|
-
*
|
|
65
|
-
* @param hashCore - The core 32 bytes of the hash.
|
|
66
|
-
* @param hashType - The type of the hash.
|
|
67
|
-
* @returns The full 39 byte hash.
|
|
68
|
-
*
|
|
69
|
-
* @public
|
|
70
|
-
*/
|
|
71
|
-
export declare function hashFrom32AndType(hashCore: AgentPubKey | EntryHash | ActionHash, hashType: "Agent" | "Entry" | "Dna" | "Action" | "External"): Uint8Array;
|
package/lib/utils/hash-parts.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import blake2b from "@bitgo/blake2b";
|
|
2
|
-
/**
|
|
3
|
-
* Hash type labels and their 3 byte values (forming the first 3 bytes of hash)
|
|
4
|
-
*
|
|
5
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export const HASH_TYPE_PREFIX = {
|
|
10
|
-
Agent: Uint8Array.from([132, 32, 36]),
|
|
11
|
-
Entry: Uint8Array.from([132, 33, 36]),
|
|
12
|
-
Dna: Uint8Array.from([132, 45, 36]),
|
|
13
|
-
Action: Uint8Array.from([132, 41, 36]),
|
|
14
|
-
External: Uint8Array.from([132, 47, 36]),
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Get dht location (last 4 bytes) from a hash
|
|
18
|
-
*
|
|
19
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
20
|
-
*
|
|
21
|
-
* @param hash - The full 39 byte hash.
|
|
22
|
-
* @returns The last 4 bytes of the hash.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export function sliceDhtLocation(hash) {
|
|
27
|
-
return Uint8Array.from(hash.slice(36, 40));
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Get core (center 32 bytes) from a hash
|
|
31
|
-
*
|
|
32
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
33
|
-
*
|
|
34
|
-
* @param hash - The full 39 byte hash.
|
|
35
|
-
* @returns The core 32 bytes of the hash.
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
*/
|
|
39
|
-
export function sliceCore32(hash) {
|
|
40
|
-
return Uint8Array.from(hash.slice(3, 36));
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get hash type (initial 3 bytes) from a hash
|
|
44
|
-
*
|
|
45
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
46
|
-
*
|
|
47
|
-
* @param hash - The full 39 byte hash.
|
|
48
|
-
* @returns The initial 3 bytes of the hash.
|
|
49
|
-
*
|
|
50
|
-
* @public
|
|
51
|
-
*/
|
|
52
|
-
export function sliceHashType(hash) {
|
|
53
|
-
return Uint8Array.from(hash.slice(0, 3));
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Generate dht location (last 4 bytes) from a core hash (middle 32 bytes)
|
|
57
|
-
*
|
|
58
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
59
|
-
*
|
|
60
|
-
* @param hashCore - The core 32 bytes of the hash.
|
|
61
|
-
* @returns The last 4 bytes of the hash.
|
|
62
|
-
*
|
|
63
|
-
* @public
|
|
64
|
-
*/
|
|
65
|
-
export function dhtLocationFrom32(hashCore) {
|
|
66
|
-
const hash = new Uint8Array(16);
|
|
67
|
-
blake2b(hash.length).update(hashCore).digest(hash);
|
|
68
|
-
const out = hash.slice(0, 4);
|
|
69
|
-
[4, 8, 12].forEach((i) => {
|
|
70
|
-
out[0] ^= hash[i];
|
|
71
|
-
out[1] ^= hash[i + 1];
|
|
72
|
-
out[2] ^= hash[i + 2];
|
|
73
|
-
out[3] ^= hash[i + 3];
|
|
74
|
-
});
|
|
75
|
-
return out;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Generate full hash from a core hash (middle 32 bytes) and hash type label
|
|
79
|
-
*
|
|
80
|
-
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
|
|
81
|
-
*
|
|
82
|
-
* @param hashCore - The core 32 bytes of the hash.
|
|
83
|
-
* @param hashType - The type of the hash.
|
|
84
|
-
* @returns The full 39 byte hash.
|
|
85
|
-
*
|
|
86
|
-
* @public
|
|
87
|
-
*/
|
|
88
|
-
export function hashFrom32AndType(hashCore, hashType) {
|
|
89
|
-
return Uint8Array.from([
|
|
90
|
-
...HASH_TYPE_PREFIX[hashType],
|
|
91
|
-
...hashCore,
|
|
92
|
-
...dhtLocationFrom32(hashCore),
|
|
93
|
-
]);
|
|
94
|
-
}
|