@holochain/client 0.17.0 → 0.17.1

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/hdk/link.d.ts CHANGED
@@ -39,6 +39,7 @@ export type RateUnits = number;
39
39
  */
40
40
  export interface Link {
41
41
  author: AgentPubKey;
42
+ base: AnyLinkableHash;
42
43
  target: AnyLinkableHash;
43
44
  timestamp: Timestamp;
44
45
  zome_index: ZomeIndex;
@@ -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 dht location (last 4 bytes) from a hash
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 last 4 bytes of the hash.
22
+ * @returns The initial 3 bytes of the hash.
23
23
  *
24
24
  * @public
25
25
  */
26
- export declare function sliceDhtLocation(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array;
26
+ export declare function sliceHashType(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array;
27
27
  /**
28
- * Get core (center 32 bytes) from a hash
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 hash type (initial 3 bytes) from a hash
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 initial 3 bytes of the hash.
44
+ * @returns The last 4 bytes of the hash.
45
45
  *
46
46
  * @public
47
47
  */
48
- export declare function sliceHashType(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array;
48
+ export declare function sliceDhtLocation(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array;
49
49
  /**
50
- * Generate dht location (last 4 bytes) from a core hash (middle 32 bytes)
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
  *
@@ -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 dht location (last 4 bytes) from a hash
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 last 4 bytes of the hash.
26
+ * @returns The initial 3 bytes of the hash.
23
27
  *
24
28
  * @public
25
29
  */
26
- export function sliceDhtLocation(hash) {
27
- return Uint8Array.from(hash.slice(36, 40));
30
+ export function sliceHashType(hash) {
31
+ return Uint8Array.from(hash.slice(0, 3));
28
32
  }
29
33
  /**
30
- * Get core (center 32 bytes) from a hash
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
- return Uint8Array.from(hash.slice(3, 36));
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 hash type (initial 3 bytes) from a hash
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 initial 3 bytes of the hash.
54
+ * @returns The last 4 bytes of the hash.
49
55
  *
50
56
  * @public
51
57
  */
52
- export function sliceHashType(hash) {
53
- return Uint8Array.from(hash.slice(0, 3));
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 dht location (last 4 bytes) from a core hash (middle 32 bytes)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holochain/client",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "A JavaScript client for the Holochain Conductor API",
5
5
  "author": "Holochain Foundation <info@holochain.org> (https://holochain.org)",
6
6
  "license": "CAL-1.0",