import { IConversionOptions } from "protobufjs"; import { Process } from "./process"; import { stratumn } from "./proto/chainscript_pb"; import { LinkReference } from "./ref"; import { Segment } from "./segment"; import { Signature } from "./signature"; /** * Deserialize a link. * @param linkBytes encoded bytes. * @returns the deserialized link. */ export declare function deserialize(linkBytes: Uint8Array): Link; /** * Convert a plain object to a link. * @param link plain object. */ export declare function fromObject(link: any): Link; /** * A link is the immutable part of a segment. * A link contains all the data that represents a process' step. */ export declare class Link { private link; constructor(link: stratumn.chainscript.Link); /** * A link is usually created as a result of an action. * @returns the link's action. */ action(): string; /** * Add a signature to the link. * This will validate the signature before adding it. * @param signature link signature. */ addSignature(signature: Signature): void; /** * The client id allows segment receivers to figure out how the segment was * encoded and can be decoded. * @returns the link's client id. */ clientId(): string; /** * The link data (business logic details about the execution of a process step). * @returns the object containing the link details. */ data(): any; /** * Serialize the link and compute a hash of the resulting bytes. * The serialization and hashing algorithm used depend on the link version. * @returns the hash bytes. */ hash(): Uint8Array; /** * A link always belongs to a specific process map. * @returns the link's map id. */ mapId(): string; /** * The link metadata can contain a custom object. * @returns the object containing the link metadata details. */ metadata(): any; /** * Maximum number of children a link is allowed to have. * This is set to -1 if the link is allowed to have as many children as it * wants. * @returns the maximum number of children allowed. */ outDegree(): number; /** * A link can have a parent, referenced by its link hash. * @returns the parent link hash. */ prevLinkHash(): Uint8Array; /** * The priority can be used to order links. * @returns the link's priority. */ priority(): number; /** * A link always belong to an instance of a process. * @returns the link's process name. */ process(): Process; /** * A link can contain references to other links. * @returns referenced links. */ refs(): LinkReference[]; /** * Create a segment from the link. * @returns the segment wrapping the link. */ segmentify(): Segment; /** * Serialize the link. * @returns link bytes. */ serialize(): Uint8Array; /** * Set the given object as the link's data. * @param data custom data to save with the link. */ setData(data: any): void; /** * Set the given object as the link's metadata. * @param data custom data to save with the link metadata. */ setMetadata(data: any): void; /** * Sign configurable parts of the link with the current signature version. * The payloadPath is used to select what parts of the link need to be signed * with the given private key. If no payloadPath is provided, the whole link * is signed. * The signature is added to the link's signature list. * @param key private key in PEM format (generated by @stratumn/js-crypto). * @param payloadPath link parts that should be signed. */ sign(key: Uint8Array, payloadPath: string): void; /** * @returns the link's signatures (if any). */ signatures(): Signature[]; /** * Compute the bytes that should be signed. * @argument version impacts how those bytes are computed. * @argument payloadPath parts of the link that should be signed. * @returns bytes to be signed. */ signedBytes(version: string, payloadPath: string): Uint8Array; /** * (Optional) A link can be interpreted as a step in a process. * @returns the corresponding process step. */ step(): string; /** * (Optional) A link can be tagged. * Tags are useful to filter link search results. * @returns link tags. */ tags(): string[]; /** * Convert to a plain object. * @argument conversionOpts specify how to convert certain types. * @returns a plain object. */ toObject(conversionOpts?: IConversionOptions): any; /** * Validate checks for errors in a link. */ validate(): void; /** * The link version is used to properly serialize and deserialize it. * @returns the link version. */ version(): string; /** * Check if the link is compatible with the current library. * If not compatible, will throw an exception. */ private verifyCompatibility; } //# sourceMappingURL=link.d.ts.map