@ledgerhq/errors
Advanced tools
Comparing version 4.35.0 to 4.35.1-beta.28
@@ -6,3 +6,6 @@ "use strict"; | ||
}); | ||
exports.DBNotReset = exports.DBWrongPassword = exports.NoDBPathGiven = exports.GenuineCheckFailed = exports.PairingFailed = exports.SyncError = exports.FeeNotLoaded = exports.CantScanQRCode = exports.ETHAddressNonEIP = exports.WrongDeviceForAccount = exports.WebsocketConnectionFailed = exports.WebsocketConnectionError = exports.UserRefusedOnDevice = exports.UserRefusedFirmwareUpdate = exports.UserRefusedAddress = exports.UpdateYourApp = exports.UnexpectedBootloader = exports.TimeoutTagged = exports.PasswordIncorrectError = exports.PasswordsDontMatchError = exports.NotEnoughBalanceBecauseDestinationNotCreated = exports.NotEnoughBalance = exports.NoAddressesFound = exports.NetworkDown = exports.ManagerUninstallBTCDep = exports.ManagerNotEnoughSpaceError = exports.ManagerDeviceLockedError = exports.ManagerAppRelyOnBTCError = exports.ManagerAppAlreadyInstalledError = exports.LedgerAPINotAvailable = exports.LedgerAPIErrorWithMessage = exports.LedgerAPIError = exports.UnknownMCU = exports.LatestMCUInstalledError = exports.InvalidAddress = exports.HardResetFail = exports.FeeEstimationFailed = exports.EnpointConfigError = exports.DisconnectedDevice = exports.DeviceSocketNoBulkStatus = exports.DeviceSocketFail = exports.DeviceOnDashboardExpected = exports.DeviceNotGenuineError = exports.DeviceGenuineSocketEarlyClose = exports.DeviceAppVerifyNotSupported = exports.CantOpenDevice = exports.BtcUnmatchedApp = exports.BluetoothRequired = exports.AccountNameRequiredError = undefined; | ||
exports.StatusCodes = exports.DBNotReset = exports.DBWrongPassword = exports.NoDBPathGiven = exports.GenuineCheckFailed = exports.PairingFailed = exports.SyncError = exports.FeeNotLoaded = exports.CantScanQRCode = exports.ETHAddressNonEIP = exports.WrongDeviceForAccount = exports.WebsocketConnectionFailed = exports.WebsocketConnectionError = exports.UserRefusedOnDevice = exports.UserRefusedFirmwareUpdate = exports.UserRefusedAddress = exports.UpdateYourApp = exports.UnexpectedBootloader = exports.TimeoutTagged = exports.PasswordIncorrectError = exports.PasswordsDontMatchError = exports.NotEnoughBalanceBecauseDestinationNotCreated = exports.NotEnoughBalance = exports.NoAddressesFound = exports.NetworkDown = exports.ManagerUninstallBTCDep = exports.ManagerNotEnoughSpaceError = exports.ManagerDeviceLockedError = exports.ManagerAppRelyOnBTCError = exports.ManagerAppAlreadyInstalledError = exports.LedgerAPINotAvailable = exports.LedgerAPIErrorWithMessage = exports.LedgerAPIError = exports.UnknownMCU = exports.LatestMCUInstalledError = exports.InvalidAddressBecauseDestinationIsAlsoSource = exports.InvalidAddress = exports.HardResetFail = exports.FeeEstimationFailed = exports.EnpointConfigError = exports.DisconnectedDeviceDuringOperation = exports.DisconnectedDevice = exports.DeviceSocketNoBulkStatus = exports.DeviceSocketFail = exports.DeviceOnDashboardExpected = exports.DeviceNotGenuineError = exports.DeviceGenuineSocketEarlyClose = exports.DeviceAppVerifyNotSupported = exports.CantOpenDevice = exports.BtcUnmatchedApp = exports.BluetoothRequired = exports.AccountNameRequiredError = undefined; | ||
exports.TransportError = TransportError; | ||
exports.getAltStatusMessage = getAltStatusMessage; | ||
exports.TransportStatusError = TransportStatusError; | ||
@@ -23,2 +26,3 @@ var _helpers = require("./helpers"); | ||
var DisconnectedDevice = exports.DisconnectedDevice = (0, _helpers.createCustomErrorClass)("DisconnectedDevice"); | ||
var DisconnectedDeviceDuringOperation = exports.DisconnectedDeviceDuringOperation = (0, _helpers.createCustomErrorClass)("DisconnectedDeviceDuringOperation"); | ||
var EnpointConfigError = exports.EnpointConfigError = (0, _helpers.createCustomErrorClass)("EnpointConfig"); | ||
@@ -28,2 +32,3 @@ var FeeEstimationFailed = exports.FeeEstimationFailed = (0, _helpers.createCustomErrorClass)("FeeEstimationFailed"); | ||
var InvalidAddress = exports.InvalidAddress = (0, _helpers.createCustomErrorClass)("InvalidAddress"); | ||
var InvalidAddressBecauseDestinationIsAlsoSource = exports.InvalidAddressBecauseDestinationIsAlsoSource = (0, _helpers.createCustomErrorClass)("InvalidAddressBecauseDestinationIsAlsoSource"); | ||
var LatestMCUInstalledError = exports.LatestMCUInstalledError = (0, _helpers.createCustomErrorClass)("LatestMCUInstalledError"); | ||
@@ -65,2 +70,86 @@ var UnknownMCU = exports.UnknownMCU = (0, _helpers.createCustomErrorClass)("UnknownMCU"); | ||
var DBNotReset = exports.DBNotReset = (0, _helpers.createCustomErrorClass)("DBNotReset"); | ||
/** | ||
* TransportError is used for any generic transport errors. | ||
* e.g. Error thrown when data received by exchanges are incorrect or if exchanged failed to communicate with the device for various reason. | ||
*/ | ||
function TransportError(message, id) { | ||
this.name = "TransportError"; | ||
this.message = message; | ||
this.stack = new Error().stack; | ||
this.id = id; | ||
} | ||
//$FlowFixMe | ||
TransportError.prototype = new Error(); | ||
var StatusCodes = exports.StatusCodes = { | ||
PIN_REMAINING_ATTEMPTS: 0x63c0, | ||
INCORRECT_LENGTH: 0x6700, | ||
COMMAND_INCOMPATIBLE_FILE_STRUCTURE: 0x6981, | ||
SECURITY_STATUS_NOT_SATISFIED: 0x6982, | ||
CONDITIONS_OF_USE_NOT_SATISFIED: 0x6985, | ||
INCORRECT_DATA: 0x6a80, | ||
NOT_ENOUGH_MEMORY_SPACE: 0x6a84, | ||
REFERENCED_DATA_NOT_FOUND: 0x6a88, | ||
FILE_ALREADY_EXISTS: 0x6a89, | ||
INCORRECT_P1_P2: 0x6b00, | ||
INS_NOT_SUPPORTED: 0x6d00, | ||
CLA_NOT_SUPPORTED: 0x6e00, | ||
TECHNICAL_PROBLEM: 0x6f00, | ||
OK: 0x9000, | ||
MEMORY_PROBLEM: 0x9240, | ||
NO_EF_SELECTED: 0x9400, | ||
INVALID_OFFSET: 0x9402, | ||
FILE_NOT_FOUND: 0x9404, | ||
INCONSISTENT_FILE: 0x9408, | ||
ALGORITHM_NOT_SUPPORTED: 0x9484, | ||
INVALID_KCV: 0x9485, | ||
CODE_NOT_INITIALIZED: 0x9802, | ||
ACCESS_CONDITION_NOT_FULFILLED: 0x9804, | ||
CONTRADICTION_SECRET_CODE_STATUS: 0x9808, | ||
CONTRADICTION_INVALIDATION: 0x9810, | ||
CODE_BLOCKED: 0x9840, | ||
MAX_VALUE_REACHED: 0x9850, | ||
GP_AUTH_FAILED: 0x6300, | ||
LICENSING: 0x6f42, | ||
HALTED: 0x6faa | ||
}; | ||
function getAltStatusMessage(code) { | ||
switch (code) { | ||
// improve text of most common errors | ||
case 0x6700: | ||
return "Incorrect length"; | ||
case 0x6982: | ||
return "Security not satisfied (dongle locked or have invalid access rights)"; | ||
case 0x6985: | ||
return "Condition of use not satisfied (denied by the user?)"; | ||
case 0x6a80: | ||
return "Invalid data received"; | ||
case 0x6b00: | ||
return "Invalid parameter received"; | ||
} | ||
if (0x6f00 <= code && code <= 0x6fff) { | ||
return "Internal error, please report"; | ||
} | ||
} | ||
/** | ||
* Error thrown when a device returned a non success status. | ||
* the error.statusCode is one of the `StatusCodes` exported by this library. | ||
*/ | ||
function TransportStatusError(statusCode) { | ||
this.name = "TransportStatusError"; | ||
var statusText = Object.keys(StatusCodes).find(function (k) { | ||
return StatusCodes[k] === statusCode; | ||
}) || "UNKNOWN_ERROR"; | ||
var smsg = getAltStatusMessage(statusCode) || statusText; | ||
var statusCodeStr = statusCode.toString(16); | ||
this.message = "Ledger device: " + smsg + " (0x" + statusCodeStr + ")"; | ||
this.stack = new Error().stack; | ||
this.statusCode = statusCode; | ||
this.statusText = statusText; | ||
} | ||
//$FlowFixMe | ||
TransportStatusError.prototype = new Error(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@ledgerhq/errors", | ||
"version": "4.35.0", | ||
"version": "4.35.1-beta.28+0f83986", | ||
"description": "Ledger common errors", | ||
@@ -22,4 +22,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"flow-bin": "^0.78.0", | ||
"flow-typed": "^2.4.0" | ||
"flow-bin": "^0.92.1", | ||
"flow-typed": "^2.5.1" | ||
}, | ||
@@ -30,4 +30,6 @@ "scripts": { | ||
"build": "bash ../../script/build.sh", | ||
"watch": "bash ../../script/watch.sh" | ||
} | ||
"watch": "bash ../../script/watch.sh", | ||
"doc": "bash ../../script/doc.sh" | ||
}, | ||
"gitHead": "0f839862fcbb7b74581b74162c1534c9897463cf" | ||
} |
@@ -6,1 +6,31 @@ <img src="https://user-images.githubusercontent.com/211411/34776833-6f1ef4da-f618-11e7-8b13-f0697901d6a8.png" height="100" /> | ||
Hodl all possible errors of Ledger (live, ledgerjs) so we can deal with them in a unified way (share between libraries, `instanceof` them,...) | ||
## API | ||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
#### Table of Contents | ||
- [TransportError](#transporterror) | ||
- [Parameters](#parameters) | ||
- [TransportStatusError](#transportstatuserror) | ||
- [Parameters](#parameters-1) | ||
### TransportError | ||
TransportError is used for any generic transport errors. | ||
e.g. Error thrown when data received by exchanges are incorrect or if exchanged failed to communicate with the device for various reason. | ||
#### Parameters | ||
- `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
### TransportStatusError | ||
Error thrown when a device returned a non success status. | ||
the error.statusCode is one of the `StatusCodes` exported by this library. | ||
#### Parameters | ||
- `statusCode` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** |
@@ -39,4 +39,4 @@ // @flow | ||
: typeof object.name === "string" | ||
? errorClasses[object.name] || createCustomErrorClass(object.name) | ||
: Error; | ||
? errorClasses[object.name] || createCustomErrorClass(object.name) | ||
: Error; | ||
@@ -43,0 +43,0 @@ const error = Object.create(constructor.prototype); |
@@ -26,2 +26,5 @@ // @flow | ||
export const DisconnectedDevice = createCustomErrorClass("DisconnectedDevice"); | ||
export const DisconnectedDeviceDuringOperation = createCustomErrorClass( | ||
"DisconnectedDeviceDuringOperation" | ||
); | ||
export const EnpointConfigError = createCustomErrorClass("EnpointConfig"); | ||
@@ -33,2 +36,5 @@ export const FeeEstimationFailed = createCustomErrorClass( | ||
export const InvalidAddress = createCustomErrorClass("InvalidAddress"); | ||
export const InvalidAddressBecauseDestinationIsAlsoSource = createCustomErrorClass( | ||
"InvalidAddressBecauseDestinationIsAlsoSource" | ||
); | ||
export const LatestMCUInstalledError = createCustomErrorClass( | ||
@@ -104,1 +110,85 @@ "LatestMCUInstalledError" | ||
export const DBNotReset = createCustomErrorClass("DBNotReset"); | ||
/** | ||
* TransportError is used for any generic transport errors. | ||
* e.g. Error thrown when data received by exchanges are incorrect or if exchanged failed to communicate with the device for various reason. | ||
*/ | ||
export function TransportError(message: string, id: string) { | ||
this.name = "TransportError"; | ||
this.message = message; | ||
this.stack = new Error().stack; | ||
this.id = id; | ||
} | ||
//$FlowFixMe | ||
TransportError.prototype = new Error(); | ||
export const StatusCodes = { | ||
PIN_REMAINING_ATTEMPTS: 0x63c0, | ||
INCORRECT_LENGTH: 0x6700, | ||
COMMAND_INCOMPATIBLE_FILE_STRUCTURE: 0x6981, | ||
SECURITY_STATUS_NOT_SATISFIED: 0x6982, | ||
CONDITIONS_OF_USE_NOT_SATISFIED: 0x6985, | ||
INCORRECT_DATA: 0x6a80, | ||
NOT_ENOUGH_MEMORY_SPACE: 0x6a84, | ||
REFERENCED_DATA_NOT_FOUND: 0x6a88, | ||
FILE_ALREADY_EXISTS: 0x6a89, | ||
INCORRECT_P1_P2: 0x6b00, | ||
INS_NOT_SUPPORTED: 0x6d00, | ||
CLA_NOT_SUPPORTED: 0x6e00, | ||
TECHNICAL_PROBLEM: 0x6f00, | ||
OK: 0x9000, | ||
MEMORY_PROBLEM: 0x9240, | ||
NO_EF_SELECTED: 0x9400, | ||
INVALID_OFFSET: 0x9402, | ||
FILE_NOT_FOUND: 0x9404, | ||
INCONSISTENT_FILE: 0x9408, | ||
ALGORITHM_NOT_SUPPORTED: 0x9484, | ||
INVALID_KCV: 0x9485, | ||
CODE_NOT_INITIALIZED: 0x9802, | ||
ACCESS_CONDITION_NOT_FULFILLED: 0x9804, | ||
CONTRADICTION_SECRET_CODE_STATUS: 0x9808, | ||
CONTRADICTION_INVALIDATION: 0x9810, | ||
CODE_BLOCKED: 0x9840, | ||
MAX_VALUE_REACHED: 0x9850, | ||
GP_AUTH_FAILED: 0x6300, | ||
LICENSING: 0x6f42, | ||
HALTED: 0x6faa | ||
}; | ||
export function getAltStatusMessage(code: number): ?string { | ||
switch (code) { | ||
// improve text of most common errors | ||
case 0x6700: | ||
return "Incorrect length"; | ||
case 0x6982: | ||
return "Security not satisfied (dongle locked or have invalid access rights)"; | ||
case 0x6985: | ||
return "Condition of use not satisfied (denied by the user?)"; | ||
case 0x6a80: | ||
return "Invalid data received"; | ||
case 0x6b00: | ||
return "Invalid parameter received"; | ||
} | ||
if (0x6f00 <= code && code <= 0x6fff) { | ||
return "Internal error, please report"; | ||
} | ||
} | ||
/** | ||
* Error thrown when a device returned a non success status. | ||
* the error.statusCode is one of the `StatusCodes` exported by this library. | ||
*/ | ||
export function TransportStatusError(statusCode: number) { | ||
this.name = "TransportStatusError"; | ||
const statusText = | ||
Object.keys(StatusCodes).find(k => StatusCodes[k] === statusCode) || | ||
"UNKNOWN_ERROR"; | ||
const smsg = getAltStatusMessage(statusCode) || statusText; | ||
const statusCodeStr = statusCode.toString(16); | ||
this.message = `Ledger device: ${smsg} (0x${statusCodeStr})`; | ||
this.stack = new Error().stack; | ||
this.statusCode = statusCode; | ||
this.statusText = statusText; | ||
} | ||
//$FlowFixMe | ||
TransportStatusError.prototype = new Error(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
636471
13
528
36
1
1