@fairdatasociety/fdp-lokijs-adapter
Version:
fdp-storage LokiJS DB Adapter
76 lines (75 loc) • 3.2 kB
TypeScript
import { Signer, Utils } from '@ethersphere/bee-js';
import { curve } from 'elliptic';
export declare const TOPIC_BYTES_LENGTH = 32;
export declare const TOPIC_HEX_LENGTH = 64;
export declare const UNCOMPRESSED_RECOVERY_ID = 27;
declare type PlainChunkReference = Bytes<32>;
declare type EncryptedChunkReference = Bytes<64>;
export declare type Bytes<Length extends number = number> = Utils.Bytes.Bytes<Length>;
export declare type HexString<Length extends number = number> = Utils.Hex.HexString<Length>;
export declare type EllipticPublicKey = curve.base.BasePoint;
export declare type EthAddress = Utils.Eth.EthAddress;
export declare type Signature = Bytes<65>;
export declare type ChunkReference = PlainChunkReference | EncryptedChunkReference;
export declare function writeUint64BigEndian(value: number, bytes?: Bytes<8>): Bytes<8>;
/**
* The default signer function that can be used for integrating with
* other applications (e.g. wallets).
*
* @param data The data to be signed
* @param privateKey The private key used for signing the data
*/
export declare function defaultSign(data: Uint8Array, privateKey: Bytes<32>): Signature;
export declare function makeSigner(signer: Signer | Uint8Array | string | unknown): Signer;
export declare function assertSigner(signer: unknown): asserts signer is Signer;
/**
* Creates a singer object that can be used when the private key is known.
*
* @param privateKey The private key
*/
export declare function makePrivateKeySigner(privateKey: Bytes<32>): Signer;
export declare function readUint64BigEndian(bytes: Bytes<8>): number;
/**
* Converts a hex string to Uint8Array
*
* wrapper
*
* @param hex string input without 0x prefix!
*/
export declare function hexToBytes<Length extends number, LengthHex extends number = number>(hex: Utils.Hex.HexString<LengthHex>): Utils.Bytes.Bytes<Length>;
/**
* Converts array of number or Uint8Array to HexString without prefix.
*
* wrapper
*
* @param bytes The input array
* @param len The length of the non prefixed HexString
*/
export declare function bytesToHex<Length extends number = number>(bytes: Uint8Array, len?: Length): Utils.Hex.HexString<Length>;
/**
* Verifies if a byte array has a certain length
*
* wrapper
*
* @param b The byte array
* @param length The specified length
*/
export declare function assertBytes<Length extends number>(b: unknown, length: Length): asserts b is Bytes<Length>;
/**
* Helper function for serialize byte arrays
*
* @param arrays Any number of byte array arguments
*/
export declare function serializeBytes(...arrays: Uint8Array[]): Uint8Array;
/**
* Generally it is discouraged to use `object` type, but in this case I think
* it is best to do so as it is possible to easily convert from `object`to other
* types, which will be usually the case after asserting that the object is
* strictly object. With for example Record<string, unknown> you have to first
* cast it to `unknown` which I think bit defeat the purpose.
*
* @param value
*/
export declare function isStrictlyObject(value: unknown): value is object;
export declare function isObject(value: unknown): value is Record<string, unknown>;
export {};