/// import { Transport as LedgerTransport } from "@ledgerhq/hw-transport"; /** * APDU Header Flags * * Describes the APDU Class, Instruction-Type, Parameter 1, and Parameter 2. * * APDU Header: ({ CLA + INS + P1 + P2 }) * - CLA: Apdu Class * - INS: Instruction Type * - P1: Instruction Parameter 1 * - P2: Instruction Parameter 2 * * Instruction Types: * - INS_GET_PUBLIC_KEY: Get a PublicKey from a Ledger Device * - INS_GET_VERSION: Get the SXP Application Version from a Ledger Device * - INS_SIGN_TRANSACTION: Sign a Transaction using a Ledger Device * - INS_SIGN_MESSAGE: Sign a Message using a Ledger Device * * App / PublicKey Context: * P1: User Approval * - P1_NON_CONFIRM: Do NOT request user approval * - P1_CONFIRM: Request user approval * * P2: ChainCode * - P2_NO_CHAINCODE: Don't use a ChainCode * - P2_CHAINCODE: Use a Chaincode * * Signing Context: * P1: Payload Segment * - P1_SINGLE: N(1) where N === 1 * - P1_FIRST: N(1) where N > 1 * - P1_MORE: N(2)..N-1 where N > 2 * - P1_LAST: Nth where N > 1 * * P2: * - P2_SCHNORR_LEG: Use Schnorr (bcrypto-v4.1.0) Signatures * */ export declare enum ApduFlag { /** APDU Class */ CLA = 224, /** App / PublicKey Context */ INS_GET_PUBLIC_KEY = 2, INS_GET_VERSION = 6, P1_NON_CONFIRM = 0, P1_CONFIRM = 1, P2_NO_CHAINCODE = 0, P2_CHAINCODE = 1, /** Signing Context */ INS_SIGN_TRANSACTION = 4, INS_SIGN_MESSAGE = 8, P1_SINGLE = 128, P1_FIRST = 0, P1_MORE = 1, P1_LAST = 129, P2_SCHNORR_LEG = 80 } /** * Create and manage an Apdu payload instance for sending to a Ledger device. * * @example const response = await new Apdu(CLA, INS, P1, P2, Payload).send(this.transport); */ export declare class Apdu { readonly cla: number; readonly ins: number; readonly p1: number; readonly p2: number; private readonly _payload; private readonly CHUNK_MAX; private readonly CHUNK_SIZE; private readonly PAYLOAD_MAX; /** * Construct an Apdu instance. * * @param {number} cla a class byte * @param {number} ins an instruction byte * @param {number} p1 a parameter-1 byte * @param {number} p2 a parameter-2 byte * @param {Buffer} payload an optional payload * @throws {PayloadLengthError} if the payload is too big to be processed */ constructor(cla: number, ins: number, p1: number, p2: number, payload?: Buffer); /** * Send a large Apdu payload in chunks for handling by a Ledger device. * * @param {LedgerTransport} transport the transport instance over which the apdu call is sent * @returns {Promise} the apdu response, e.g. from a Ledger device */ send(transport: LedgerTransport): Promise; /** * Split the Apdu Payload into a Chunked Array. * * @param {Buffer} payload the bytes to be chunked * @param {number} chunkSize the element size by which to split the payload * @returns {Buffer[]} the chunked payload of an Apdu instance */ protected getChunks(payload: Buffer, chunkSize: number): Buffer[]; /** * Get the Segment Flag (P1) of a given chunk. * * @param {Buffer} index the index of the current chunk * @param {Buffer} length total length of the payload * @returns {ApduFlag} which segment of a payload is being sent */ private getChunkSegmentFlag; } export { ApduFlag as Flag }; export { Apdu as Builder };