UNPKG

@ethersphere/bee-js

Version:
67 lines (66 loc) 3.37 kB
import { BeeRequestOptions, UploadOptions, UploadResult } from '../types'; import { Bytes } from '../utils/bytes'; import { BatchId, EthAddress, Identifier, PrivateKey, Reference, Signature } from '../utils/typed-bytes'; import { Chunk } from './cac'; /** * With single owner chunks, a user can assign arbitrary data to an * address and attest chunk integrity with their digital signature. * * This interface extends the Chunk interface so it has the same * properties, but the address calculation is based on the identifier * and the owner of the chunk. */ export interface SingleOwnerChunk extends Chunk { identifier: Identifier; signature: Signature; owner: EthAddress; } /** * Verifies if the data is a valid single owner chunk * * @param data The chunk data * @param address The address of the single owner chunk * * @returns a single owner chunk or throws error */ export declare function makeSingleOwnerChunkFromData(data: Bytes | Uint8Array, address: Reference | Uint8Array | string): SingleOwnerChunk; export declare function makeSOCAddress(identifier: Identifier, address: EthAddress): Reference; /** * Creates a single owner chunk object * * @param chunk A chunk object used for the span and payload * @param identifier The identifier of the chunk * @param signer The signer interface for signing the chunk */ export declare function makeSingleOwnerChunk(chunk: Chunk, identifier: Identifier | Uint8Array | string, signer: PrivateKey | Uint8Array | string): SingleOwnerChunk; /** * Helper function to upload a chunk. * * It uses the Chunk API and calculates the address before uploading. * * @param requestOptions Options for making requests * @param chunk A chunk object * @param stamp Postage BatchId that will be assigned to uploaded data * @param options Upload options */ export declare function uploadSingleOwnerChunk(requestOptions: BeeRequestOptions, chunk: SingleOwnerChunk, stamp: BatchId | Uint8Array | string, options?: UploadOptions): Promise<UploadResult>; /** * Helper function to create and upload SOC. * * @param requestOptions Options for making requests * @param signer The signer interface for signing the chunk * @param postageBatchId * @param identifier The identifier of the chunk * @param data The chunk data * @param options */ export declare function uploadSingleOwnerChunkData(requestOptions: BeeRequestOptions, signer: PrivateKey | Uint8Array | string, stamp: BatchId | Uint8Array | string, identifier: Identifier | Uint8Array | string, data: Uint8Array, options?: UploadOptions): Promise<UploadResult>; export declare function uploadSingleOwnerChunkWithWrappedChunk(requestOptions: BeeRequestOptions, signer: PrivateKey | Uint8Array | string, stamp: BatchId | Uint8Array | string, identifier: Identifier | Uint8Array | string, rootChunk: Uint8Array, options?: UploadOptions): Promise<UploadResult>; /** * Helper function to download SOC. * * @param url The url of the Bee service * @param ownerAddress The signer interface for signing the chunk * @param identifier The identifier of the chunk */ export declare function downloadSingleOwnerChunk(requestOptions: BeeRequestOptions, ownerAddress: EthAddress | Uint8Array | string, identifier: Identifier | Uint8Array | string): Promise<SingleOwnerChunk>;