@holochain/client
Advanced tools
Comparing version 0.17.0 to 0.17.1
@@ -42,2 +42,3 @@ import { ActionHash, AgentPubKey, EntryHash, ExternalHash, Timestamp } from "../types.js"; | ||
author: AgentPubKey; | ||
base: AnyLinkableHash; | ||
target: AnyLinkableHash; | ||
@@ -44,0 +45,0 @@ timestamp: Timestamp; |
import { ActionHash, AgentPubKey, EntryHash } from "../types.js"; | ||
/** | ||
* Hash type labels and their 3 byte values (forming the first 3 bytes of hash) | ||
* Hash type labels and their 3 byte values (forming the first 3 bytes of hash). | ||
* | ||
@@ -17,3 +17,3 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs | ||
/** | ||
* Get dht location (last 4 bytes) from a hash | ||
* Get hash type (initial 3 bytes) from a hash. | ||
* | ||
@@ -23,9 +23,9 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs | ||
* @param hash - The full 39 byte hash. | ||
* @returns The last 4 bytes of the hash. | ||
* @returns The initial 3 bytes of the hash. | ||
* | ||
* @public | ||
*/ | ||
export declare function sliceDhtLocation(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array; | ||
export declare function sliceHashType(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array; | ||
/** | ||
* Get core (center 32 bytes) from a hash | ||
* Get core hash from a Holochain hash (32 bytes). | ||
* | ||
@@ -41,3 +41,3 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs | ||
/** | ||
* Get hash type (initial 3 bytes) from a hash | ||
* Get DHT location (last 4 bytes) from a hash. | ||
* | ||
@@ -47,9 +47,9 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs | ||
* @param hash - The full 39 byte hash. | ||
* @returns The initial 3 bytes of the hash. | ||
* @returns The last 4 bytes of the hash. | ||
* | ||
* @public | ||
*/ | ||
export declare function sliceHashType(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array; | ||
export declare function sliceDhtLocation(hash: AgentPubKey | EntryHash | ActionHash): Uint8Array; | ||
/** | ||
* Generate dht location (last 4 bytes) from a core hash (middle 32 bytes) | ||
* Generate DHT location (last 4 bytes) from a core hash (middle 32 bytes). | ||
* | ||
@@ -65,3 +65,3 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs | ||
/** | ||
* Generate full hash from a core hash (middle 32 bytes) and hash type label | ||
* Generate full hash from a core hash (middle 32 bytes) and hash type label. | ||
* | ||
@@ -68,0 +68,0 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs |
import blake2b from "@bitgo/blake2b"; | ||
const HASH_TYPE_START = 0; | ||
const HASH_TYPE_BYTE_LENGTH = 3; | ||
const CORE_HASH_BYTE_LENGTH = 32; | ||
const DHT_LOCATION_BYTE_LENGTH = 4; | ||
/** | ||
* Hash type labels and their 3 byte values (forming the first 3 bytes of hash) | ||
* Hash type labels and their 3 byte values (forming the first 3 bytes of hash). | ||
* | ||
@@ -17,3 +21,3 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs | ||
/** | ||
* Get dht location (last 4 bytes) from a hash | ||
* Get hash type (initial 3 bytes) from a hash. | ||
* | ||
@@ -23,11 +27,11 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs | ||
* @param hash - The full 39 byte hash. | ||
* @returns The last 4 bytes of the hash. | ||
* @returns The initial 3 bytes of the hash. | ||
* | ||
* @public | ||
*/ | ||
export function sliceDhtLocation(hash) { | ||
return Uint8Array.from(hash.slice(36, 40)); | ||
export function sliceHashType(hash) { | ||
return Uint8Array.from(hash.slice(0, 3)); | ||
} | ||
/** | ||
* Get core (center 32 bytes) from a hash | ||
* Get core hash from a Holochain hash (32 bytes). | ||
* | ||
@@ -42,6 +46,8 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs | ||
export function sliceCore32(hash) { | ||
return Uint8Array.from(hash.slice(3, 36)); | ||
const start = HASH_TYPE_START + HASH_TYPE_BYTE_LENGTH; | ||
const end = start + CORE_HASH_BYTE_LENGTH; | ||
return Uint8Array.from(hash.slice(start, end)); | ||
} | ||
/** | ||
* Get hash type (initial 3 bytes) from a hash | ||
* Get DHT location (last 4 bytes) from a hash. | ||
* | ||
@@ -51,11 +57,13 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs | ||
* @param hash - The full 39 byte hash. | ||
* @returns The initial 3 bytes of the hash. | ||
* @returns The last 4 bytes of the hash. | ||
* | ||
* @public | ||
*/ | ||
export function sliceHashType(hash) { | ||
return Uint8Array.from(hash.slice(0, 3)); | ||
export function sliceDhtLocation(hash) { | ||
const start = HASH_TYPE_START + HASH_TYPE_BYTE_LENGTH + CORE_HASH_BYTE_LENGTH; | ||
const end = start + DHT_LOCATION_BYTE_LENGTH; | ||
return Uint8Array.from(hash.slice(start, end)); | ||
} | ||
/** | ||
* Generate dht location (last 4 bytes) from a core hash (middle 32 bytes) | ||
* Generate DHT location (last 4 bytes) from a core hash (middle 32 bytes). | ||
* | ||
@@ -82,3 +90,3 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs | ||
/** | ||
* Generate full hash from a core hash (middle 32 bytes) and hash type label | ||
* Generate full hash from a core hash (middle 32 bytes) and hash type label. | ||
* | ||
@@ -85,0 +93,0 @@ * From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs |
{ | ||
"name": "@holochain/client", | ||
"version": "0.17.0", | ||
"version": "0.17.1", | ||
"description": "A JavaScript client for the Holochain Conductor API", | ||
@@ -5,0 +5,0 @@ "author": "Holochain Foundation <info@holochain.org> (https://holochain.org)", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126002
3491