UNPKG

@ngraveio/ur-sign

Version:

Provides BC-UR types for signature request and response from cold wallets to hot wallets.

57 lines (56 loc) 2.33 kB
import { Keypath } from '@ngraveio/ur-blockchain-commons'; import { UUID } from '@ngraveio/ur-uuid'; import { CoinIdentity } from '@ngraveio/ur-coin-identity'; type NodeBuffer = typeof globalThis extends { Buffer: infer T; } ? T : never; type CompatibleBuffer = Buffer | InstanceType<NodeBuffer>; interface ISignRequestInput { /** Identifier of the signing request */ requestId?: UUID | string | Uint8Array; /** Provides information on the elliptic curve and the blockchain/coin */ coinId: CoinIdentity; /** Key path for signing this request */ derivationPath?: Keypath | string; /** Transaction to be decoded by the offline signer */ signData: CompatibleBuffer | Uint8Array; /** Origin of this sign request, e.g. wallet name */ origin?: string; /** Specify type of transaction required for some blockchains */ txType?: number; /** Specify sender address if not already specified in the sign-data and derivation-path */ address?: string | Uint8Array; } interface ISignRequestData { /** Identifier of the signing request */ requestId: UUID; /** Provides information on the elliptic curve and the blockchain/coin */ coinId: CoinIdentity; /** Key path for signing this request */ derivationPath?: Keypath; /** Transaction to be decoded by the offline signer */ signData: Buffer; /** Origin of this sign request, e.g. wallet name */ origin?: string; /** Specify type of transaction required for some blockchains */ txType?: number; /** Specify sender address if not already specified in the sign-data and derivation-path */ address?: string | Uint8Array; } declare const SignRequest_base: import("@ngraveio/bc-ur").RegistryItemClass<import("@ngraveio/bc-ur").RegistryItemBase>; export declare class SignRequest extends SignRequest_base { data: ISignRequestData; constructor(data: ISignRequestInput); verifyInput: (input: ISignRequestInput) => { valid: boolean; reasons?: Error[]; }; getRequestId: () => UUID; getCoinId: () => CoinIdentity; getDerivationPath: () => Keypath | undefined; getSignData: () => Buffer<ArrayBufferLike>; getOrigin: () => string | undefined; getTxType: () => number | undefined; getAddress: () => string | undefined; } export {};