@taquito/ledger-signer 17.3.1-beta-RC.0 → 17.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/version.js +2 -2
- package/dist/lib/version.js.map +1 -1
- package/dist/taquito-ledger-signer.es6.js +2 -2
- package/dist/taquito-ledger-signer.es6.js.map +1 -1
- package/dist/taquito-ledger-signer.umd.js +2 -2
- package/dist/taquito-ledger-signer.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/version.ts +2 -2
package/dist/lib/version.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "17.3.1
|
|
6
|
+
"commitHash": "9e27326dabf764c55402c50be4d78681f2c78cca",
|
|
7
|
+
"version": "17.3.1"
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
package/dist/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AACA,2EAA2E;AAC9D,QAAA,OAAO,GAAG;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AACA,2EAA2E;AAC9D,QAAA,OAAO,GAAG;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,QAAQ;CACtB,CAAC"}
|
|
@@ -202,8 +202,8 @@ class InvalidDerivationTypeError extends ParameterValidationError {
|
|
|
202
202
|
|
|
203
203
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
204
204
|
const VERSION = {
|
|
205
|
-
"commitHash": "
|
|
206
|
-
"version": "17.3.1
|
|
205
|
+
"commitHash": "9e27326dabf764c55402c50be4d78681f2c78cca",
|
|
206
|
+
"version": "17.3.1"
|
|
207
207
|
};
|
|
208
208
|
|
|
209
209
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-ledger-signer.es6.js","sources":["../src/utils.ts","../src/errors.ts","../src/version.ts","../src/taquito-ledger-signer.ts"],"sourcesContent":["/*\n * Some code in this file is adapted from sotez\n * Copyright (c) 2018 Andrew Kishino\n */\n\nimport { DerivationType } from './taquito-ledger-signer';\n\nconst MAX_CHUNK_SIZE = 230;\n\n/**\n *\n * @description Convert the path to a buffer that will be used as LC and CDATA in the APDU send to the ledger device (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n *\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @returns A buffer where the first element is the length of the path (default is 4), then 3 bytes for each number of the path to which is added 0x8000000\n */\nexport function transformPathToBuffer(path: string): Buffer {\n const result: number[] = [];\n const components = path.split('/');\n components.forEach((element) => {\n let toNumber = parseInt(element, 10);\n if (Number.isNaN(toNumber)) {\n return;\n }\n if (element.length > 1 && element[element.length - 1] === \"'\") {\n toNumber += 0x80000000;\n }\n result.push(toNumber);\n });\n const buffer = Buffer.alloc(1 + result.length * 4);\n buffer[0] = result.length;\n result.forEach((element, index) => {\n buffer.writeUInt32BE(element, 1 + 4 * index);\n });\n return buffer;\n}\n\n/**\n *\n * @description Converts uncompressed ledger key to standard tezos binary representation\n */\nexport function compressPublicKey(publicKey: Buffer, curve: DerivationType) {\n if (curve === 0x00 || curve === 0x03) {\n publicKey = publicKey.slice(1);\n } else {\n publicKey[0] = 0x02 + (publicKey[64] & 0x01);\n publicKey = publicKey.slice(0, 33);\n }\n return publicKey;\n}\n\nexport function appendWatermark(bytes: string, watermark?: Uint8Array): string {\n let transactionHex = bytes;\n if (typeof watermark !== 'undefined') {\n const hexWatermark = Buffer.from(watermark).toString('hex');\n transactionHex = hexWatermark.concat(bytes);\n }\n return transactionHex;\n}\n\n/**\n *\n * @description In order not to exceed the data length allowed by the Ledger device, split the operation into buffers of 230 bytes (max) and add them to the message to send to the Ledger\n * @param messageToSend The message to send to the Ledger device\n * @param operation The operation which will be chunk if its length is over 230 bytes\n * @returns The instruction to send to the Ledger device\n */\nexport function chunkOperation(messageToSend: any, operation: Buffer) {\n let offset = 0;\n while (offset !== operation.length) {\n const chunkSize =\n offset + MAX_CHUNK_SIZE >= operation.length ? operation.length - offset : MAX_CHUNK_SIZE;\n const buff = Buffer.alloc(chunkSize);\n operation.copy(buff, 0, offset, offset + chunkSize);\n messageToSend.push(buff);\n offset += chunkSize;\n }\n return messageToSend;\n}\n\n/**\n *\n * @description Verify if the signature returned by the ledger for tz2 and tz3 is valid\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns True if valid, false otherwise\n */\nexport function validateResponse(response: Buffer): boolean {\n let valid = true;\n if (response[0] !== 0x31 && response[0] !== 0x30) {\n valid = false;\n }\n if (response[1] + 4 !== response.length) {\n valid = false;\n }\n if (response[2] !== 0x02) {\n valid = false;\n }\n const rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n const idxLengthSVal = 5 + rLength;\n const sLength = response[idxLengthSVal];\n if (idxLengthSVal + 1 + sLength + 2 !== response.length) {\n valid = false;\n }\n return valid;\n}\n\n/**\n *\n * @description Extract a part of the response returned by the Ledger\n * @param idxLength The index in the response from the Ledger that corresponds to the length of the part to extract\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns An object that contains the extracted buffer, the index where it starts in the response and the length of the extracted part\n */\nexport function extractValue(idxLength: number, response: Buffer) {\n const buffer = Buffer.alloc(32);\n buffer.fill(0);\n\n let length = response[idxLength];\n let idxValueStart = idxLength + 1;\n if (length > 32) {\n idxValueStart += length - 32;\n length = 32;\n }\n response.copy(buffer, 32 - length, idxValueStart, idxValueStart + length);\n return { buffer, idxValueStart, length };\n}\n","import { ParameterValidationError, TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates an invalid or unparseable ledger response\n */\nexport class InvalidLedgerResponseError extends TaquitoError {\n constructor(public readonly message: string) {\n super();\n this.name = 'InvalidLedgerResponseError';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates a failure when trying to retrieve a Public Key from Ledger signer\n */\nexport class PublicKeyRetrievalError extends TaquitoError {\n constructor(public readonly cause: any) {\n super();\n this.name = 'PublicKeyRetrievalError';\n this.message = `Unable to retrieve Public Key from Ledger`;\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates a failure when trying to retrieve a Public Key Hash from Ledger signer\n */\nexport class PublicKeyHashRetrievalError extends TaquitoError {\n constructor() {\n super();\n this.name = 'PublicKeyHashRetrievalError';\n this.message = 'Unable to retrieve Public Key Hash from Ledger';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates an invalid derivation type being passed or used\n */\nexport class InvalidDerivationTypeError extends ParameterValidationError {\n constructor(public readonly derivationType: string) {\n super();\n this.name = 'InvalidDerivationTypeError';\n this.message = `Invalid derivation type ${derivationType} expecting one of the following: DerivationType.ED25519, DerivationType.SECP256K1, DerivationType.P256 or DerivationType.BIP32_ED25519`;\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"e1b1d6976a564f925c01cf66e28df9acb0085c3d\",\n \"version\": \"17.3.1-beta-RC.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/ledger-signer\n */\n\nimport { Signer } from '@taquito/taquito';\nimport Transport from '@ledgerhq/hw-transport';\nimport { b58cencode, invalidDetail, prefix, Prefix, ValidationResult } from '@taquito/utils';\nimport {\n appendWatermark,\n transformPathToBuffer,\n compressPublicKey,\n chunkOperation,\n validateResponse,\n extractValue,\n} from './utils';\nimport { hash } from '@stablelib/blake2b';\nimport {\n PublicKeyHashRetrievalError,\n PublicKeyRetrievalError,\n InvalidLedgerResponseError,\n InvalidDerivationTypeError,\n} from './errors';\nimport { InvalidDerivationPathError, ProhibitedActionError } from '@taquito/core';\n\nexport { InvalidDerivationPathError } from '@taquito/core';\n\nexport type LedgerTransport = Pick<Transport, 'send' | 'decorateAppAPIMethods' | 'setScrambleKey'>;\n\nexport enum DerivationType {\n ED25519 = 0x00, // tz1\n SECP256K1 = 0x01, // tz2\n P256 = 0x02, // tz3\n BIP32_ED25519 = 0x03, // tz1 BIP32\n}\n\nexport { InvalidDerivationTypeError } from './errors';\n\nexport const HDPathTemplate = (account: number) => {\n return `44'/1729'/${account}'/0'`;\n};\n\nexport { VERSION } from './version';\n\n/**\n *\n * @description Implementation of the Signer interface that will allow signing operation from a Ledger Nano device\n *\n * @param transport A transport instance from LedgerJS libraries depending on the platform used (e.g. Web, Node)\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @param prompt Whether to prompt the ledger for public key (default is true)\n * @param derivationType The value which defines the curve to use (DerivationType.ED25519(default), DerivationType.SECP256K1, DerivationType.P256, DerivationType.BIP32_ED25519)\n *\n * @example\n * ```\n * import TransportNodeHid from \"@ledgerhq/hw-transport-node-hid\";\n * const transport = await TransportNodeHid.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", false, DerivationType.ED25519);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", true, DerivationType.SECP256K1);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/6'/0'\", true, DerivationType.BIP32_ED25519);\n * ```\n */\nexport class LedgerSigner implements Signer {\n // constants for APDU requests (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n private readonly CLA = 0x80; // Instruction class (always 0x80)\n private readonly INS_GET_PUBLIC_KEY = 0x02; // Instruction code to get the ledger’s internal public key without prompt\n private readonly INS_PROMPT_PUBLIC_KEY = 0x03; // Instruction code to get the ledger’s internal public key with prompt\n private readonly INS_SIGN = 0x04; // Sign a message with the ledger’s key\n private readonly FIRST_MESSAGE_SEQUENCE = 0x00;\n private readonly LAST_MESSAGE_SEQUENCE = 0x81;\n private readonly OTHER_MESSAGE_SEQUENCE = 0x01;\n\n private _publicKey?: string;\n private _publicKeyHash?: string;\n constructor(\n private transport: LedgerTransport,\n private path: string = \"44'/1729'/0'/0'\",\n private prompt: boolean = true,\n private derivationType: DerivationType = DerivationType.ED25519\n ) {\n this.transport.setScrambleKey('XTZ');\n if (!path.startsWith(`44'/1729'`)) {\n throw new InvalidDerivationPathError(\n path,\n `${invalidDetail(ValidationResult.NO_PREFIX_MATCHED)} expecting prefix \"44'/1729'\".`\n );\n }\n if (!Object.values(DerivationType).includes(derivationType)) {\n throw new InvalidDerivationTypeError(derivationType.toString());\n }\n }\n\n async publicKeyHash(): Promise<string> {\n if (!this._publicKeyHash) {\n await this.publicKey();\n }\n if (this._publicKeyHash) {\n return this._publicKeyHash;\n }\n throw new PublicKeyHashRetrievalError();\n }\n\n async publicKey(): Promise<string> {\n if (this._publicKey) {\n return this._publicKey;\n }\n const responseLedger = await this.getLedgerPublicKey();\n const publicKeyLength = responseLedger[0];\n const rawPublicKey = responseLedger.slice(1, 1 + publicKeyLength);\n const compressedPublicKey = compressPublicKey(rawPublicKey, this.derivationType);\n\n const prefixes = this.getPrefixes();\n const publicKey = b58cencode(compressedPublicKey, prefixes.prefPk);\n const publicKeyHash = b58cencode(hash(compressedPublicKey, 20), prefixes.prefPkh);\n\n this._publicKey = publicKey;\n this._publicKeyHash = publicKeyHash;\n return publicKey;\n }\n\n private async getLedgerPublicKey(): Promise<Buffer> {\n try {\n let ins = this.INS_PROMPT_PUBLIC_KEY;\n if (this.prompt === false) {\n ins = this.INS_GET_PUBLIC_KEY;\n }\n const responseLedger = await this.transport.send(\n this.CLA,\n ins,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n transformPathToBuffer(this.path)\n );\n return responseLedger;\n } catch (error) {\n throw new PublicKeyRetrievalError(error);\n }\n }\n\n async secretKey(): Promise<string> {\n throw new ProhibitedActionError('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n const watermarkedBytes = appendWatermark(bytes, watermark);\n const watermarkedBytes2buff = Buffer.from(watermarkedBytes, 'hex');\n let messageToSend = [];\n messageToSend.push(transformPathToBuffer(this.path));\n messageToSend = chunkOperation(messageToSend, watermarkedBytes2buff);\n const ledgerResponse = await this.signWithLedger(messageToSend);\n let signature;\n if (\n this.derivationType === DerivationType.ED25519 ||\n this.derivationType === DerivationType.BIP32_ED25519\n ) {\n signature = ledgerResponse.slice(0, ledgerResponse.length - 2).toString('hex');\n } else {\n if (!validateResponse(ledgerResponse)) {\n throw new InvalidLedgerResponseError(\n 'Invalid signature return by ledger unable to parse the response'\n );\n }\n const idxLengthRVal = 3; // Third element of response is length of r value\n const rValue = extractValue(idxLengthRVal, ledgerResponse);\n const idxLengthSVal = rValue.idxValueStart + rValue.length + 1;\n const sValue = extractValue(idxLengthSVal, ledgerResponse);\n const signatureBuffer = Buffer.concat([rValue.buffer, sValue.buffer]);\n signature = signatureBuffer.toString('hex');\n }\n\n return {\n bytes,\n sig: b58cencode(signature, prefix[Prefix.SIG]),\n prefixSig: b58cencode(signature, this.getPrefixes().prefSig),\n sbytes: bytes + signature,\n };\n }\n\n private async signWithLedger(message: Buffer[]): Promise<Buffer> {\n // first element of the message represents the path\n let ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n message[0]\n );\n for (let i = 1; i < message.length; i++) {\n const p1 =\n i === message.length - 1 ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n p1,\n this.derivationType,\n message[i]\n );\n }\n return ledgerResponse;\n }\n\n private getPrefixes() {\n if (\n this.derivationType === DerivationType.ED25519 ||\n this.derivationType === DerivationType.BIP32_ED25519\n ) {\n return {\n prefPk: prefix[Prefix.EDPK],\n prefPkh: prefix[Prefix.TZ1],\n prefSig: prefix[Prefix.EDSIG],\n };\n } else if (this.derivationType === DerivationType.SECP256K1) {\n return {\n prefPk: prefix[Prefix.SPPK],\n prefPkh: prefix[Prefix.TZ2],\n prefSig: prefix[Prefix.SPSIG],\n };\n } else {\n return {\n prefPk: prefix[Prefix.P2PK],\n prefPkh: prefix[Prefix.TZ3],\n prefSig: prefix[Prefix.P2SIG],\n };\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AAGG;AAIH,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B;;;;;;AAMG;AACG,SAAU,qBAAqB,CAAC,IAAY,EAAA;IAChD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACnC,IAAA,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,KAAI;QAC7B,IAAI,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACrC,QAAA,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;YAC1B,OAAO;AACR,SAAA;AACD,QAAA,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;YAC7D,QAAQ,IAAI,UAAU,CAAC;AACxB,SAAA;AACD,QAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxB,KAAC,CAAC,CAAC;AACH,IAAA,MAAM,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I,CAAC;AAC3B,gBAAA,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;AAC3B,gBAAA,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9B,CAAC;AACH,SAAA;KACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"taquito-ledger-signer.es6.js","sources":["../src/utils.ts","../src/errors.ts","../src/version.ts","../src/taquito-ledger-signer.ts"],"sourcesContent":["/*\n * Some code in this file is adapted from sotez\n * Copyright (c) 2018 Andrew Kishino\n */\n\nimport { DerivationType } from './taquito-ledger-signer';\n\nconst MAX_CHUNK_SIZE = 230;\n\n/**\n *\n * @description Convert the path to a buffer that will be used as LC and CDATA in the APDU send to the ledger device (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n *\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @returns A buffer where the first element is the length of the path (default is 4), then 3 bytes for each number of the path to which is added 0x8000000\n */\nexport function transformPathToBuffer(path: string): Buffer {\n const result: number[] = [];\n const components = path.split('/');\n components.forEach((element) => {\n let toNumber = parseInt(element, 10);\n if (Number.isNaN(toNumber)) {\n return;\n }\n if (element.length > 1 && element[element.length - 1] === \"'\") {\n toNumber += 0x80000000;\n }\n result.push(toNumber);\n });\n const buffer = Buffer.alloc(1 + result.length * 4);\n buffer[0] = result.length;\n result.forEach((element, index) => {\n buffer.writeUInt32BE(element, 1 + 4 * index);\n });\n return buffer;\n}\n\n/**\n *\n * @description Converts uncompressed ledger key to standard tezos binary representation\n */\nexport function compressPublicKey(publicKey: Buffer, curve: DerivationType) {\n if (curve === 0x00 || curve === 0x03) {\n publicKey = publicKey.slice(1);\n } else {\n publicKey[0] = 0x02 + (publicKey[64] & 0x01);\n publicKey = publicKey.slice(0, 33);\n }\n return publicKey;\n}\n\nexport function appendWatermark(bytes: string, watermark?: Uint8Array): string {\n let transactionHex = bytes;\n if (typeof watermark !== 'undefined') {\n const hexWatermark = Buffer.from(watermark).toString('hex');\n transactionHex = hexWatermark.concat(bytes);\n }\n return transactionHex;\n}\n\n/**\n *\n * @description In order not to exceed the data length allowed by the Ledger device, split the operation into buffers of 230 bytes (max) and add them to the message to send to the Ledger\n * @param messageToSend The message to send to the Ledger device\n * @param operation The operation which will be chunk if its length is over 230 bytes\n * @returns The instruction to send to the Ledger device\n */\nexport function chunkOperation(messageToSend: any, operation: Buffer) {\n let offset = 0;\n while (offset !== operation.length) {\n const chunkSize =\n offset + MAX_CHUNK_SIZE >= operation.length ? operation.length - offset : MAX_CHUNK_SIZE;\n const buff = Buffer.alloc(chunkSize);\n operation.copy(buff, 0, offset, offset + chunkSize);\n messageToSend.push(buff);\n offset += chunkSize;\n }\n return messageToSend;\n}\n\n/**\n *\n * @description Verify if the signature returned by the ledger for tz2 and tz3 is valid\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns True if valid, false otherwise\n */\nexport function validateResponse(response: Buffer): boolean {\n let valid = true;\n if (response[0] !== 0x31 && response[0] !== 0x30) {\n valid = false;\n }\n if (response[1] + 4 !== response.length) {\n valid = false;\n }\n if (response[2] !== 0x02) {\n valid = false;\n }\n const rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n const idxLengthSVal = 5 + rLength;\n const sLength = response[idxLengthSVal];\n if (idxLengthSVal + 1 + sLength + 2 !== response.length) {\n valid = false;\n }\n return valid;\n}\n\n/**\n *\n * @description Extract a part of the response returned by the Ledger\n * @param idxLength The index in the response from the Ledger that corresponds to the length of the part to extract\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns An object that contains the extracted buffer, the index where it starts in the response and the length of the extracted part\n */\nexport function extractValue(idxLength: number, response: Buffer) {\n const buffer = Buffer.alloc(32);\n buffer.fill(0);\n\n let length = response[idxLength];\n let idxValueStart = idxLength + 1;\n if (length > 32) {\n idxValueStart += length - 32;\n length = 32;\n }\n response.copy(buffer, 32 - length, idxValueStart, idxValueStart + length);\n return { buffer, idxValueStart, length };\n}\n","import { ParameterValidationError, TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates an invalid or unparseable ledger response\n */\nexport class InvalidLedgerResponseError extends TaquitoError {\n constructor(public readonly message: string) {\n super();\n this.name = 'InvalidLedgerResponseError';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates a failure when trying to retrieve a Public Key from Ledger signer\n */\nexport class PublicKeyRetrievalError extends TaquitoError {\n constructor(public readonly cause: any) {\n super();\n this.name = 'PublicKeyRetrievalError';\n this.message = `Unable to retrieve Public Key from Ledger`;\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates a failure when trying to retrieve a Public Key Hash from Ledger signer\n */\nexport class PublicKeyHashRetrievalError extends TaquitoError {\n constructor() {\n super();\n this.name = 'PublicKeyHashRetrievalError';\n this.message = 'Unable to retrieve Public Key Hash from Ledger';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates an invalid derivation type being passed or used\n */\nexport class InvalidDerivationTypeError extends ParameterValidationError {\n constructor(public readonly derivationType: string) {\n super();\n this.name = 'InvalidDerivationTypeError';\n this.message = `Invalid derivation type ${derivationType} expecting one of the following: DerivationType.ED25519, DerivationType.SECP256K1, DerivationType.P256 or DerivationType.BIP32_ED25519`;\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"9e27326dabf764c55402c50be4d78681f2c78cca\",\n \"version\": \"17.3.1\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/ledger-signer\n */\n\nimport { Signer } from '@taquito/taquito';\nimport Transport from '@ledgerhq/hw-transport';\nimport { b58cencode, invalidDetail, prefix, Prefix, ValidationResult } from '@taquito/utils';\nimport {\n appendWatermark,\n transformPathToBuffer,\n compressPublicKey,\n chunkOperation,\n validateResponse,\n extractValue,\n} from './utils';\nimport { hash } from '@stablelib/blake2b';\nimport {\n PublicKeyHashRetrievalError,\n PublicKeyRetrievalError,\n InvalidLedgerResponseError,\n InvalidDerivationTypeError,\n} from './errors';\nimport { InvalidDerivationPathError, ProhibitedActionError } from '@taquito/core';\n\nexport { InvalidDerivationPathError } from '@taquito/core';\n\nexport type LedgerTransport = Pick<Transport, 'send' | 'decorateAppAPIMethods' | 'setScrambleKey'>;\n\nexport enum DerivationType {\n ED25519 = 0x00, // tz1\n SECP256K1 = 0x01, // tz2\n P256 = 0x02, // tz3\n BIP32_ED25519 = 0x03, // tz1 BIP32\n}\n\nexport { InvalidDerivationTypeError } from './errors';\n\nexport const HDPathTemplate = (account: number) => {\n return `44'/1729'/${account}'/0'`;\n};\n\nexport { VERSION } from './version';\n\n/**\n *\n * @description Implementation of the Signer interface that will allow signing operation from a Ledger Nano device\n *\n * @param transport A transport instance from LedgerJS libraries depending on the platform used (e.g. Web, Node)\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @param prompt Whether to prompt the ledger for public key (default is true)\n * @param derivationType The value which defines the curve to use (DerivationType.ED25519(default), DerivationType.SECP256K1, DerivationType.P256, DerivationType.BIP32_ED25519)\n *\n * @example\n * ```\n * import TransportNodeHid from \"@ledgerhq/hw-transport-node-hid\";\n * const transport = await TransportNodeHid.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", false, DerivationType.ED25519);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", true, DerivationType.SECP256K1);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/6'/0'\", true, DerivationType.BIP32_ED25519);\n * ```\n */\nexport class LedgerSigner implements Signer {\n // constants for APDU requests (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n private readonly CLA = 0x80; // Instruction class (always 0x80)\n private readonly INS_GET_PUBLIC_KEY = 0x02; // Instruction code to get the ledger’s internal public key without prompt\n private readonly INS_PROMPT_PUBLIC_KEY = 0x03; // Instruction code to get the ledger’s internal public key with prompt\n private readonly INS_SIGN = 0x04; // Sign a message with the ledger’s key\n private readonly FIRST_MESSAGE_SEQUENCE = 0x00;\n private readonly LAST_MESSAGE_SEQUENCE = 0x81;\n private readonly OTHER_MESSAGE_SEQUENCE = 0x01;\n\n private _publicKey?: string;\n private _publicKeyHash?: string;\n constructor(\n private transport: LedgerTransport,\n private path: string = \"44'/1729'/0'/0'\",\n private prompt: boolean = true,\n private derivationType: DerivationType = DerivationType.ED25519\n ) {\n this.transport.setScrambleKey('XTZ');\n if (!path.startsWith(`44'/1729'`)) {\n throw new InvalidDerivationPathError(\n path,\n `${invalidDetail(ValidationResult.NO_PREFIX_MATCHED)} expecting prefix \"44'/1729'\".`\n );\n }\n if (!Object.values(DerivationType).includes(derivationType)) {\n throw new InvalidDerivationTypeError(derivationType.toString());\n }\n }\n\n async publicKeyHash(): Promise<string> {\n if (!this._publicKeyHash) {\n await this.publicKey();\n }\n if (this._publicKeyHash) {\n return this._publicKeyHash;\n }\n throw new PublicKeyHashRetrievalError();\n }\n\n async publicKey(): Promise<string> {\n if (this._publicKey) {\n return this._publicKey;\n }\n const responseLedger = await this.getLedgerPublicKey();\n const publicKeyLength = responseLedger[0];\n const rawPublicKey = responseLedger.slice(1, 1 + publicKeyLength);\n const compressedPublicKey = compressPublicKey(rawPublicKey, this.derivationType);\n\n const prefixes = this.getPrefixes();\n const publicKey = b58cencode(compressedPublicKey, prefixes.prefPk);\n const publicKeyHash = b58cencode(hash(compressedPublicKey, 20), prefixes.prefPkh);\n\n this._publicKey = publicKey;\n this._publicKeyHash = publicKeyHash;\n return publicKey;\n }\n\n private async getLedgerPublicKey(): Promise<Buffer> {\n try {\n let ins = this.INS_PROMPT_PUBLIC_KEY;\n if (this.prompt === false) {\n ins = this.INS_GET_PUBLIC_KEY;\n }\n const responseLedger = await this.transport.send(\n this.CLA,\n ins,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n transformPathToBuffer(this.path)\n );\n return responseLedger;\n } catch (error) {\n throw new PublicKeyRetrievalError(error);\n }\n }\n\n async secretKey(): Promise<string> {\n throw new ProhibitedActionError('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n const watermarkedBytes = appendWatermark(bytes, watermark);\n const watermarkedBytes2buff = Buffer.from(watermarkedBytes, 'hex');\n let messageToSend = [];\n messageToSend.push(transformPathToBuffer(this.path));\n messageToSend = chunkOperation(messageToSend, watermarkedBytes2buff);\n const ledgerResponse = await this.signWithLedger(messageToSend);\n let signature;\n if (\n this.derivationType === DerivationType.ED25519 ||\n this.derivationType === DerivationType.BIP32_ED25519\n ) {\n signature = ledgerResponse.slice(0, ledgerResponse.length - 2).toString('hex');\n } else {\n if (!validateResponse(ledgerResponse)) {\n throw new InvalidLedgerResponseError(\n 'Invalid signature return by ledger unable to parse the response'\n );\n }\n const idxLengthRVal = 3; // Third element of response is length of r value\n const rValue = extractValue(idxLengthRVal, ledgerResponse);\n const idxLengthSVal = rValue.idxValueStart + rValue.length + 1;\n const sValue = extractValue(idxLengthSVal, ledgerResponse);\n const signatureBuffer = Buffer.concat([rValue.buffer, sValue.buffer]);\n signature = signatureBuffer.toString('hex');\n }\n\n return {\n bytes,\n sig: b58cencode(signature, prefix[Prefix.SIG]),\n prefixSig: b58cencode(signature, this.getPrefixes().prefSig),\n sbytes: bytes + signature,\n };\n }\n\n private async signWithLedger(message: Buffer[]): Promise<Buffer> {\n // first element of the message represents the path\n let ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n message[0]\n );\n for (let i = 1; i < message.length; i++) {\n const p1 =\n i === message.length - 1 ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n p1,\n this.derivationType,\n message[i]\n );\n }\n return ledgerResponse;\n }\n\n private getPrefixes() {\n if (\n this.derivationType === DerivationType.ED25519 ||\n this.derivationType === DerivationType.BIP32_ED25519\n ) {\n return {\n prefPk: prefix[Prefix.EDPK],\n prefPkh: prefix[Prefix.TZ1],\n prefSig: prefix[Prefix.EDSIG],\n };\n } else if (this.derivationType === DerivationType.SECP256K1) {\n return {\n prefPk: prefix[Prefix.SPPK],\n prefPkh: prefix[Prefix.TZ2],\n prefSig: prefix[Prefix.SPSIG],\n };\n } else {\n return {\n prefPk: prefix[Prefix.P2PK],\n prefPkh: prefix[Prefix.TZ3],\n prefSig: prefix[Prefix.P2SIG],\n };\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AAGG;AAIH,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B;;;;;;AAMG;AACG,SAAU,qBAAqB,CAAC,IAAY,EAAA;IAChD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACnC,IAAA,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,KAAI;QAC7B,IAAI,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACrC,QAAA,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;YAC1B,OAAO;AACR,SAAA;AACD,QAAA,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;YAC7D,QAAQ,IAAI,UAAU,CAAC;AACxB,SAAA;AACD,QAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxB,KAAC,CAAC,CAAC;AACH,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GA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,MAAM,CAAC,GAAG,CAAC;AAC3B,gBAAA,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9B,CAAC;AACH,SAAA;KACF;AACF;;;;"}
|
|
@@ -203,8 +203,8 @@
|
|
|
203
203
|
|
|
204
204
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
205
205
|
const VERSION = {
|
|
206
|
-
"commitHash": "
|
|
207
|
-
"version": "17.3.1
|
|
206
|
+
"commitHash": "9e27326dabf764c55402c50be4d78681f2c78cca",
|
|
207
|
+
"version": "17.3.1"
|
|
208
208
|
};
|
|
209
209
|
|
|
210
210
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-ledger-signer.umd.js","sources":["../src/utils.ts","../src/errors.ts","../src/version.ts","../src/taquito-ledger-signer.ts"],"sourcesContent":["/*\n * Some code in this file is adapted from sotez\n * Copyright (c) 2018 Andrew Kishino\n */\n\nimport { DerivationType } from './taquito-ledger-signer';\n\nconst MAX_CHUNK_SIZE = 230;\n\n/**\n *\n * @description Convert the path to a buffer that will be used as LC and CDATA in the APDU send to the ledger device (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n *\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @returns A buffer where the first element is the length of the path (default is 4), then 3 bytes for each number of the path to which is added 0x8000000\n */\nexport function transformPathToBuffer(path: string): Buffer {\n const result: number[] = [];\n const components = path.split('/');\n components.forEach((element) => {\n let toNumber = parseInt(element, 10);\n if (Number.isNaN(toNumber)) {\n return;\n }\n if (element.length > 1 && element[element.length - 1] === \"'\") {\n toNumber += 0x80000000;\n }\n result.push(toNumber);\n });\n const buffer = Buffer.alloc(1 + result.length * 4);\n buffer[0] = result.length;\n result.forEach((element, index) => {\n buffer.writeUInt32BE(element, 1 + 4 * index);\n });\n return buffer;\n}\n\n/**\n *\n * @description Converts uncompressed ledger key to standard tezos binary representation\n */\nexport function compressPublicKey(publicKey: Buffer, curve: DerivationType) {\n if (curve === 0x00 || curve === 0x03) {\n publicKey = publicKey.slice(1);\n } else {\n publicKey[0] = 0x02 + (publicKey[64] & 0x01);\n publicKey = publicKey.slice(0, 33);\n }\n return publicKey;\n}\n\nexport function appendWatermark(bytes: string, watermark?: Uint8Array): string {\n let transactionHex = bytes;\n if (typeof watermark !== 'undefined') {\n const hexWatermark = Buffer.from(watermark).toString('hex');\n transactionHex = hexWatermark.concat(bytes);\n }\n return transactionHex;\n}\n\n/**\n *\n * @description In order not to exceed the data length allowed by the Ledger device, split the operation into buffers of 230 bytes (max) and add them to the message to send to the Ledger\n * @param messageToSend The message to send to the Ledger device\n * @param operation The operation which will be chunk if its length is over 230 bytes\n * @returns The instruction to send to the Ledger device\n */\nexport function chunkOperation(messageToSend: any, operation: Buffer) {\n let offset = 0;\n while (offset !== operation.length) {\n const chunkSize =\n offset + MAX_CHUNK_SIZE >= operation.length ? operation.length - offset : MAX_CHUNK_SIZE;\n const buff = Buffer.alloc(chunkSize);\n operation.copy(buff, 0, offset, offset + chunkSize);\n messageToSend.push(buff);\n offset += chunkSize;\n }\n return messageToSend;\n}\n\n/**\n *\n * @description Verify if the signature returned by the ledger for tz2 and tz3 is valid\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns True if valid, false otherwise\n */\nexport function validateResponse(response: Buffer): boolean {\n let valid = true;\n if (response[0] !== 0x31 && response[0] !== 0x30) {\n valid = false;\n }\n if (response[1] + 4 !== response.length) {\n valid = false;\n }\n if (response[2] !== 0x02) {\n valid = false;\n }\n const rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n const idxLengthSVal = 5 + rLength;\n const sLength = response[idxLengthSVal];\n if (idxLengthSVal + 1 + sLength + 2 !== response.length) {\n valid = false;\n }\n return valid;\n}\n\n/**\n *\n * @description Extract a part of the response returned by the Ledger\n * @param idxLength The index in the response from the Ledger that corresponds to the length of the part to extract\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns An object that contains the extracted buffer, the index where it starts in the response and the length of the extracted part\n */\nexport function extractValue(idxLength: number, response: Buffer) {\n const buffer = Buffer.alloc(32);\n buffer.fill(0);\n\n let length = response[idxLength];\n let idxValueStart = idxLength + 1;\n if (length > 32) {\n idxValueStart += length - 32;\n length = 32;\n }\n response.copy(buffer, 32 - length, idxValueStart, idxValueStart + length);\n return { buffer, idxValueStart, length };\n}\n","import { ParameterValidationError, TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates an invalid or unparseable ledger response\n */\nexport class InvalidLedgerResponseError extends TaquitoError {\n constructor(public readonly message: string) {\n super();\n this.name = 'InvalidLedgerResponseError';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates a failure when trying to retrieve a Public Key from Ledger signer\n */\nexport class PublicKeyRetrievalError extends TaquitoError {\n constructor(public readonly cause: any) {\n super();\n this.name = 'PublicKeyRetrievalError';\n this.message = `Unable to retrieve Public Key from Ledger`;\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates a failure when trying to retrieve a Public Key Hash from Ledger signer\n */\nexport class PublicKeyHashRetrievalError extends TaquitoError {\n constructor() {\n super();\n this.name = 'PublicKeyHashRetrievalError';\n this.message = 'Unable to retrieve Public Key Hash from Ledger';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates an invalid derivation type being passed or used\n */\nexport class InvalidDerivationTypeError extends ParameterValidationError {\n constructor(public readonly derivationType: string) {\n super();\n this.name = 'InvalidDerivationTypeError';\n this.message = `Invalid derivation type ${derivationType} expecting one of the following: DerivationType.ED25519, DerivationType.SECP256K1, DerivationType.P256 or DerivationType.BIP32_ED25519`;\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"e1b1d6976a564f925c01cf66e28df9acb0085c3d\",\n \"version\": \"17.3.1-beta-RC.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/ledger-signer\n */\n\nimport { Signer } from '@taquito/taquito';\nimport Transport from '@ledgerhq/hw-transport';\nimport { b58cencode, invalidDetail, prefix, Prefix, ValidationResult } from '@taquito/utils';\nimport {\n appendWatermark,\n transformPathToBuffer,\n compressPublicKey,\n chunkOperation,\n validateResponse,\n extractValue,\n} from './utils';\nimport { hash } from '@stablelib/blake2b';\nimport {\n PublicKeyHashRetrievalError,\n PublicKeyRetrievalError,\n InvalidLedgerResponseError,\n InvalidDerivationTypeError,\n} from './errors';\nimport { InvalidDerivationPathError, ProhibitedActionError } from '@taquito/core';\n\nexport { InvalidDerivationPathError } from '@taquito/core';\n\nexport type LedgerTransport = Pick<Transport, 'send' | 'decorateAppAPIMethods' | 'setScrambleKey'>;\n\nexport enum DerivationType {\n ED25519 = 0x00, // tz1\n SECP256K1 = 0x01, // tz2\n P256 = 0x02, // tz3\n BIP32_ED25519 = 0x03, // tz1 BIP32\n}\n\nexport { InvalidDerivationTypeError } from './errors';\n\nexport const HDPathTemplate = (account: number) => {\n return `44'/1729'/${account}'/0'`;\n};\n\nexport { VERSION } from './version';\n\n/**\n *\n * @description Implementation of the Signer interface that will allow signing operation from a Ledger Nano device\n *\n * @param transport A transport instance from LedgerJS libraries depending on the platform used (e.g. Web, Node)\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @param prompt Whether to prompt the ledger for public key (default is true)\n * @param derivationType The value which defines the curve to use (DerivationType.ED25519(default), DerivationType.SECP256K1, DerivationType.P256, DerivationType.BIP32_ED25519)\n *\n * @example\n * ```\n * import TransportNodeHid from \"@ledgerhq/hw-transport-node-hid\";\n * const transport = await TransportNodeHid.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", false, DerivationType.ED25519);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", true, DerivationType.SECP256K1);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/6'/0'\", true, DerivationType.BIP32_ED25519);\n * ```\n */\nexport class LedgerSigner implements Signer {\n // constants for APDU requests (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n private readonly CLA = 0x80; // Instruction class (always 0x80)\n private readonly INS_GET_PUBLIC_KEY = 0x02; // Instruction code to get the ledger’s internal public key without prompt\n private readonly INS_PROMPT_PUBLIC_KEY = 0x03; // Instruction code to get the ledger’s internal public key with prompt\n private readonly INS_SIGN = 0x04; // Sign a message with the ledger’s key\n private readonly FIRST_MESSAGE_SEQUENCE = 0x00;\n private readonly LAST_MESSAGE_SEQUENCE = 0x81;\n private readonly OTHER_MESSAGE_SEQUENCE = 0x01;\n\n private _publicKey?: string;\n private _publicKeyHash?: string;\n constructor(\n private transport: LedgerTransport,\n private path: string = \"44'/1729'/0'/0'\",\n private prompt: boolean = true,\n private derivationType: DerivationType = DerivationType.ED25519\n ) {\n this.transport.setScrambleKey('XTZ');\n if (!path.startsWith(`44'/1729'`)) {\n throw new InvalidDerivationPathError(\n path,\n `${invalidDetail(ValidationResult.NO_PREFIX_MATCHED)} expecting prefix \"44'/1729'\".`\n );\n }\n if (!Object.values(DerivationType).includes(derivationType)) {\n throw new InvalidDerivationTypeError(derivationType.toString());\n }\n }\n\n async publicKeyHash(): Promise<string> {\n if (!this._publicKeyHash) {\n await this.publicKey();\n }\n if (this._publicKeyHash) {\n return this._publicKeyHash;\n }\n throw new PublicKeyHashRetrievalError();\n }\n\n async publicKey(): Promise<string> {\n if (this._publicKey) {\n return this._publicKey;\n }\n const responseLedger = await this.getLedgerPublicKey();\n const publicKeyLength = responseLedger[0];\n const rawPublicKey = responseLedger.slice(1, 1 + publicKeyLength);\n const compressedPublicKey = compressPublicKey(rawPublicKey, this.derivationType);\n\n const prefixes = this.getPrefixes();\n const publicKey = b58cencode(compressedPublicKey, prefixes.prefPk);\n const publicKeyHash = b58cencode(hash(compressedPublicKey, 20), prefixes.prefPkh);\n\n this._publicKey = publicKey;\n this._publicKeyHash = publicKeyHash;\n return publicKey;\n }\n\n private async getLedgerPublicKey(): Promise<Buffer> {\n try {\n let ins = this.INS_PROMPT_PUBLIC_KEY;\n if (this.prompt === false) {\n ins = this.INS_GET_PUBLIC_KEY;\n }\n const responseLedger = await this.transport.send(\n this.CLA,\n ins,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n transformPathToBuffer(this.path)\n );\n return responseLedger;\n } catch (error) {\n throw new PublicKeyRetrievalError(error);\n }\n }\n\n async secretKey(): Promise<string> {\n throw new ProhibitedActionError('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n const watermarkedBytes = appendWatermark(bytes, watermark);\n const watermarkedBytes2buff = Buffer.from(watermarkedBytes, 'hex');\n let messageToSend = [];\n messageToSend.push(transformPathToBuffer(this.path));\n messageToSend = chunkOperation(messageToSend, watermarkedBytes2buff);\n const ledgerResponse = await this.signWithLedger(messageToSend);\n let signature;\n if (\n this.derivationType === DerivationType.ED25519 ||\n this.derivationType === DerivationType.BIP32_ED25519\n ) {\n signature = ledgerResponse.slice(0, ledgerResponse.length - 2).toString('hex');\n } else {\n if (!validateResponse(ledgerResponse)) {\n throw new InvalidLedgerResponseError(\n 'Invalid signature return by ledger unable to parse the response'\n );\n }\n const idxLengthRVal = 3; // Third element of response is length of r value\n const rValue = extractValue(idxLengthRVal, ledgerResponse);\n const idxLengthSVal = rValue.idxValueStart + rValue.length + 1;\n const sValue = extractValue(idxLengthSVal, ledgerResponse);\n const signatureBuffer = Buffer.concat([rValue.buffer, sValue.buffer]);\n signature = signatureBuffer.toString('hex');\n }\n\n return {\n bytes,\n sig: b58cencode(signature, prefix[Prefix.SIG]),\n prefixSig: b58cencode(signature, this.getPrefixes().prefSig),\n sbytes: bytes + signature,\n };\n }\n\n private async signWithLedger(message: Buffer[]): Promise<Buffer> {\n // first element of the message represents the path\n let ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n message[0]\n );\n for (let i = 1; i < message.length; i++) {\n const p1 =\n i === message.length - 1 ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n p1,\n this.derivationType,\n message[i]\n );\n }\n return ledgerResponse;\n }\n\n private getPrefixes() {\n if (\n this.derivationType === DerivationType.ED25519 ||\n this.derivationType === DerivationType.BIP32_ED25519\n ) {\n return {\n prefPk: prefix[Prefix.EDPK],\n prefPkh: prefix[Prefix.TZ1],\n prefSig: prefix[Prefix.EDSIG],\n };\n } else if (this.derivationType === DerivationType.SECP256K1) {\n return {\n prefPk: prefix[Prefix.SPPK],\n prefPkh: prefix[Prefix.TZ2],\n prefSig: prefix[Prefix.SPSIG],\n };\n } else {\n return {\n prefPk: prefix[Prefix.P2PK],\n prefPkh: prefix[Prefix.TZ3],\n prefSig: prefix[Prefix.P2SIG],\n };\n }\n }\n}\n"],"names":["TaquitoError","ParameterValidationError","DerivationType","InvalidDerivationPathError","invalidDetail","ValidationResult","b58cencode","hash","ProhibitedActionError","prefix","Prefix"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;;;IAGG;IAIH,MAAM,cAAc,GAAG,GAAG,CAAC;IAE3B;;;;;;IAMG;IACG,SAAU,qBAAqB,CAAC,IAAY,EAAA;QAChD,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,IAAA,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,KAAI;YAC7B,IAAI,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACrC,Q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,KAAK,CAAC;iBAC9B,CAAC;IACH,SAAA;IAAM,aAAA,IAAI,IAAI,CAAC,cAAc,KAAKR,sBAAc,CAAC,SAAS,EAAE;gBAC3D,OAAO;IACL,gBAAA,MAAM,EAAEO,YAAM,CAACC,YAAM,CAAC,IAAI,CAAC;IAC3B,gBAAA,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,GAAG,CAAC;IAC3B,gBAAA,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,KAAK,CAAC;iBAC9B,CAAC;IACH,SAAA;IAAM,aAAA;gBACL,OAAO;IACL,gBAAA,MAAM,EAAED,YAAM,CAACC,YAAM,CAAC,IAAI,CAAC;IAC3B,gBAAA,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,GAAG,CAAC;IAC3B,gBAAA,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,KAAK,CAAC;iBAC9B,CAAC;IACH,SAAA;SACF;IACF;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"taquito-ledger-signer.umd.js","sources":["../src/utils.ts","../src/errors.ts","../src/version.ts","../src/taquito-ledger-signer.ts"],"sourcesContent":["/*\n * Some code in this file is adapted from sotez\n * Copyright (c) 2018 Andrew Kishino\n */\n\nimport { DerivationType } from './taquito-ledger-signer';\n\nconst MAX_CHUNK_SIZE = 230;\n\n/**\n *\n * @description Convert the path to a buffer that will be used as LC and CDATA in the APDU send to the ledger device (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n *\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @returns A buffer where the first element is the length of the path (default is 4), then 3 bytes for each number of the path to which is added 0x8000000\n */\nexport function transformPathToBuffer(path: string): Buffer {\n const result: number[] = [];\n const components = path.split('/');\n components.forEach((element) => {\n let toNumber = parseInt(element, 10);\n if (Number.isNaN(toNumber)) {\n return;\n }\n if (element.length > 1 && element[element.length - 1] === \"'\") {\n toNumber += 0x80000000;\n }\n result.push(toNumber);\n });\n const buffer = Buffer.alloc(1 + result.length * 4);\n buffer[0] = result.length;\n result.forEach((element, index) => {\n buffer.writeUInt32BE(element, 1 + 4 * index);\n });\n return buffer;\n}\n\n/**\n *\n * @description Converts uncompressed ledger key to standard tezos binary representation\n */\nexport function compressPublicKey(publicKey: Buffer, curve: DerivationType) {\n if (curve === 0x00 || curve === 0x03) {\n publicKey = publicKey.slice(1);\n } else {\n publicKey[0] = 0x02 + (publicKey[64] & 0x01);\n publicKey = publicKey.slice(0, 33);\n }\n return publicKey;\n}\n\nexport function appendWatermark(bytes: string, watermark?: Uint8Array): string {\n let transactionHex = bytes;\n if (typeof watermark !== 'undefined') {\n const hexWatermark = Buffer.from(watermark).toString('hex');\n transactionHex = hexWatermark.concat(bytes);\n }\n return transactionHex;\n}\n\n/**\n *\n * @description In order not to exceed the data length allowed by the Ledger device, split the operation into buffers of 230 bytes (max) and add them to the message to send to the Ledger\n * @param messageToSend The message to send to the Ledger device\n * @param operation The operation which will be chunk if its length is over 230 bytes\n * @returns The instruction to send to the Ledger device\n */\nexport function chunkOperation(messageToSend: any, operation: Buffer) {\n let offset = 0;\n while (offset !== operation.length) {\n const chunkSize =\n offset + MAX_CHUNK_SIZE >= operation.length ? operation.length - offset : MAX_CHUNK_SIZE;\n const buff = Buffer.alloc(chunkSize);\n operation.copy(buff, 0, offset, offset + chunkSize);\n messageToSend.push(buff);\n offset += chunkSize;\n }\n return messageToSend;\n}\n\n/**\n *\n * @description Verify if the signature returned by the ledger for tz2 and tz3 is valid\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns True if valid, false otherwise\n */\nexport function validateResponse(response: Buffer): boolean {\n let valid = true;\n if (response[0] !== 0x31 && response[0] !== 0x30) {\n valid = false;\n }\n if (response[1] + 4 !== response.length) {\n valid = false;\n }\n if (response[2] !== 0x02) {\n valid = false;\n }\n const rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n const idxLengthSVal = 5 + rLength;\n const sLength = response[idxLengthSVal];\n if (idxLengthSVal + 1 + sLength + 2 !== response.length) {\n valid = false;\n }\n return valid;\n}\n\n/**\n *\n * @description Extract a part of the response returned by the Ledger\n * @param idxLength The index in the response from the Ledger that corresponds to the length of the part to extract\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns An object that contains the extracted buffer, the index where it starts in the response and the length of the extracted part\n */\nexport function extractValue(idxLength: number, response: Buffer) {\n const buffer = Buffer.alloc(32);\n buffer.fill(0);\n\n let length = response[idxLength];\n let idxValueStart = idxLength + 1;\n if (length > 32) {\n idxValueStart += length - 32;\n length = 32;\n }\n response.copy(buffer, 32 - length, idxValueStart, idxValueStart + length);\n return { buffer, idxValueStart, length };\n}\n","import { ParameterValidationError, TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates an invalid or unparseable ledger response\n */\nexport class InvalidLedgerResponseError extends TaquitoError {\n constructor(public readonly message: string) {\n super();\n this.name = 'InvalidLedgerResponseError';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates a failure when trying to retrieve a Public Key from Ledger signer\n */\nexport class PublicKeyRetrievalError extends TaquitoError {\n constructor(public readonly cause: any) {\n super();\n this.name = 'PublicKeyRetrievalError';\n this.message = `Unable to retrieve Public Key from Ledger`;\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates a failure when trying to retrieve a Public Key Hash from Ledger signer\n */\nexport class PublicKeyHashRetrievalError extends TaquitoError {\n constructor() {\n super();\n this.name = 'PublicKeyHashRetrievalError';\n this.message = 'Unable to retrieve Public Key Hash from Ledger';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates an invalid derivation type being passed or used\n */\nexport class InvalidDerivationTypeError extends ParameterValidationError {\n constructor(public readonly derivationType: string) {\n super();\n this.name = 'InvalidDerivationTypeError';\n this.message = `Invalid derivation type ${derivationType} expecting one of the following: DerivationType.ED25519, DerivationType.SECP256K1, DerivationType.P256 or DerivationType.BIP32_ED25519`;\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"9e27326dabf764c55402c50be4d78681f2c78cca\",\n \"version\": \"17.3.1\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/ledger-signer\n */\n\nimport { Signer } from '@taquito/taquito';\nimport Transport from '@ledgerhq/hw-transport';\nimport { b58cencode, invalidDetail, prefix, Prefix, ValidationResult } from '@taquito/utils';\nimport {\n appendWatermark,\n transformPathToBuffer,\n compressPublicKey,\n chunkOperation,\n validateResponse,\n extractValue,\n} from './utils';\nimport { hash } from '@stablelib/blake2b';\nimport {\n PublicKeyHashRetrievalError,\n PublicKeyRetrievalError,\n InvalidLedgerResponseError,\n InvalidDerivationTypeError,\n} from './errors';\nimport { InvalidDerivationPathError, ProhibitedActionError } from '@taquito/core';\n\nexport { InvalidDerivationPathError } from '@taquito/core';\n\nexport type LedgerTransport = Pick<Transport, 'send' | 'decorateAppAPIMethods' | 'setScrambleKey'>;\n\nexport enum DerivationType {\n ED25519 = 0x00, // tz1\n SECP256K1 = 0x01, // tz2\n P256 = 0x02, // tz3\n BIP32_ED25519 = 0x03, // tz1 BIP32\n}\n\nexport { InvalidDerivationTypeError } from './errors';\n\nexport const HDPathTemplate = (account: number) => {\n return `44'/1729'/${account}'/0'`;\n};\n\nexport { VERSION } from './version';\n\n/**\n *\n * @description Implementation of the Signer interface that will allow signing operation from a Ledger Nano device\n *\n * @param transport A transport instance from LedgerJS libraries depending on the platform used (e.g. Web, Node)\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @param prompt Whether to prompt the ledger for public key (default is true)\n * @param derivationType The value which defines the curve to use (DerivationType.ED25519(default), DerivationType.SECP256K1, DerivationType.P256, DerivationType.BIP32_ED25519)\n *\n * @example\n * ```\n * import TransportNodeHid from \"@ledgerhq/hw-transport-node-hid\";\n * const transport = await TransportNodeHid.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", false, DerivationType.ED25519);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", true, DerivationType.SECP256K1);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/6'/0'\", true, DerivationType.BIP32_ED25519);\n * ```\n */\nexport class LedgerSigner implements Signer {\n // constants for APDU requests (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n private readonly CLA = 0x80; // Instruction class (always 0x80)\n private readonly INS_GET_PUBLIC_KEY = 0x02; // Instruction code to get the ledger’s internal public key without prompt\n private readonly INS_PROMPT_PUBLIC_KEY = 0x03; // Instruction code to get the ledger’s internal public key with prompt\n private readonly INS_SIGN = 0x04; // Sign a message with the ledger’s key\n private readonly FIRST_MESSAGE_SEQUENCE = 0x00;\n private readonly LAST_MESSAGE_SEQUENCE = 0x81;\n private readonly OTHER_MESSAGE_SEQUENCE = 0x01;\n\n private _publicKey?: string;\n private _publicKeyHash?: string;\n constructor(\n private transport: LedgerTransport,\n private path: string = \"44'/1729'/0'/0'\",\n private prompt: boolean = true,\n private derivationType: DerivationType = DerivationType.ED25519\n ) {\n this.transport.setScrambleKey('XTZ');\n if (!path.startsWith(`44'/1729'`)) {\n throw new InvalidDerivationPathError(\n path,\n `${invalidDetail(ValidationResult.NO_PREFIX_MATCHED)} expecting prefix \"44'/1729'\".`\n );\n }\n if (!Object.values(DerivationType).includes(derivationType)) {\n throw new InvalidDerivationTypeError(derivationType.toString());\n }\n }\n\n async publicKeyHash(): Promise<string> {\n if (!this._publicKeyHash) {\n await this.publicKey();\n }\n if (this._publicKeyHash) {\n return this._publicKeyHash;\n }\n throw new PublicKeyHashRetrievalError();\n }\n\n async publicKey(): Promise<string> {\n if (this._publicKey) {\n return this._publicKey;\n }\n const responseLedger = await this.getLedgerPublicKey();\n const publicKeyLength = responseLedger[0];\n const rawPublicKey = responseLedger.slice(1, 1 + publicKeyLength);\n const compressedPublicKey = compressPublicKey(rawPublicKey, this.derivationType);\n\n const prefixes = this.getPrefixes();\n const publicKey = b58cencode(compressedPublicKey, prefixes.prefPk);\n const publicKeyHash = b58cencode(hash(compressedPublicKey, 20), prefixes.prefPkh);\n\n this._publicKey = publicKey;\n this._publicKeyHash = publicKeyHash;\n return publicKey;\n }\n\n private async getLedgerPublicKey(): Promise<Buffer> {\n try {\n let ins = this.INS_PROMPT_PUBLIC_KEY;\n if (this.prompt === false) {\n ins = this.INS_GET_PUBLIC_KEY;\n }\n const responseLedger = await this.transport.send(\n this.CLA,\n ins,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n transformPathToBuffer(this.path)\n );\n return responseLedger;\n } catch (error) {\n throw new PublicKeyRetrievalError(error);\n }\n }\n\n async secretKey(): Promise<string> {\n throw new ProhibitedActionError('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n const watermarkedBytes = appendWatermark(bytes, watermark);\n const watermarkedBytes2buff = Buffer.from(watermarkedBytes, 'hex');\n let messageToSend = [];\n messageToSend.push(transformPathToBuffer(this.path));\n messageToSend = chunkOperation(messageToSend, watermarkedBytes2buff);\n const ledgerResponse = await this.signWithLedger(messageToSend);\n let signature;\n if (\n this.derivationType === DerivationType.ED25519 ||\n this.derivationType === DerivationType.BIP32_ED25519\n ) {\n signature = ledgerResponse.slice(0, ledgerResponse.length - 2).toString('hex');\n } else {\n if (!validateResponse(ledgerResponse)) {\n throw new InvalidLedgerResponseError(\n 'Invalid signature return by ledger unable to parse the response'\n );\n }\n const idxLengthRVal = 3; // Third element of response is length of r value\n const rValue = extractValue(idxLengthRVal, ledgerResponse);\n const idxLengthSVal = rValue.idxValueStart + rValue.length + 1;\n const sValue = extractValue(idxLengthSVal, ledgerResponse);\n const signatureBuffer = Buffer.concat([rValue.buffer, sValue.buffer]);\n signature = signatureBuffer.toString('hex');\n }\n\n return {\n bytes,\n sig: b58cencode(signature, prefix[Prefix.SIG]),\n prefixSig: b58cencode(signature, this.getPrefixes().prefSig),\n sbytes: bytes + signature,\n };\n }\n\n private async signWithLedger(message: Buffer[]): Promise<Buffer> {\n // first element of the message represents the path\n let ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n message[0]\n );\n for (let i = 1; i < message.length; i++) {\n const p1 =\n i === message.length - 1 ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n p1,\n this.derivationType,\n message[i]\n );\n }\n return ledgerResponse;\n }\n\n private getPrefixes() {\n if (\n this.derivationType === DerivationType.ED25519 ||\n this.derivationType === DerivationType.BIP32_ED25519\n ) {\n return {\n prefPk: prefix[Prefix.EDPK],\n prefPkh: prefix[Prefix.TZ1],\n prefSig: prefix[Prefix.EDSIG],\n };\n } else if (this.derivationType === DerivationType.SECP256K1) {\n return {\n prefPk: prefix[Prefix.SPPK],\n prefPkh: prefix[Prefix.TZ2],\n prefSig: prefix[Prefix.SPSIG],\n };\n } else {\n return {\n prefPk: prefix[Prefix.P2PK],\n prefPkh: prefix[Prefix.TZ3],\n prefSig: prefix[Prefix.P2SIG],\n };\n }\n }\n}\n"],"names":["TaquitoError","ParameterValidationError","DerivationType","InvalidDerivationPathError","invalidDetail","ValidationResult","b58cencode","hash","ProhibitedActionError","prefix","Prefix"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;;;IAGG;IAIH,MAAM,cAAc,GAAG,GAAG,CAAC;IAE3B;;;;;;IAMG;IACG,SAAU,qBAAqB,CAAC,IAAY,EAAA;QAChD,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,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YAAM,CAAC,IAAI,CAAC;IAC3B,gBAAA,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,GAAG,CAAC;IAC3B,gBAAA,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,KAAK,CAAC;iBAC9B,CAAC;IACH,SAAA;IAAM,aAAA,IAAI,IAAI,CAAC,cAAc,KAAKR,sBAAc,CAAC,SAAS,EAAE;gBAC3D,OAAO;IACL,gBAAA,MAAM,EAAEO,YAAM,CAACC,YAAM,CAAC,IAAI,CAAC;IAC3B,gBAAA,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,GAAG,CAAC;IAC3B,gBAAA,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,KAAK,CAAC;iBAC9B,CAAC;IACH,SAAA;IAAM,aAAA;gBACL,OAAO;IACL,gBAAA,MAAM,EAAED,YAAM,CAACC,YAAM,CAAC,IAAI,CAAC;IAC3B,gBAAA,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,GAAG,CAAC;IAC3B,gBAAA,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,KAAK,CAAC;iBAC9B,CAAC;IACH,SAAA;SACF;IACF;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taquito/ledger-signer",
|
|
3
|
-
"version": "17.3.1
|
|
3
|
+
"version": "17.3.1",
|
|
4
4
|
"description": "Ledger signer provider",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tezos",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@ledgerhq/hw-transport": "^6.28.8",
|
|
62
62
|
"@stablelib/blake2b": "^1.0.1",
|
|
63
|
-
"@taquito/taquito": "^17.3.1
|
|
64
|
-
"@taquito/utils": "^17.3.1
|
|
63
|
+
"@taquito/taquito": "^17.3.1",
|
|
64
|
+
"@taquito/utils": "^17.3.1",
|
|
65
65
|
"buffer": "^6.0.3"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"ts-toolbelt": "^9.6.0",
|
|
94
94
|
"typescript": "~4.1.5"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "3eac9219d501eb9c1334ee8d8aaf9f195e8300cb"
|
|
97
97
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
3
3
|
export const VERSION = {
|
|
4
|
-
"commitHash": "
|
|
5
|
-
"version": "17.3.1
|
|
4
|
+
"commitHash": "9e27326dabf764c55402c50be4d78681f2c78cca",
|
|
5
|
+
"version": "17.3.1"
|
|
6
6
|
};
|