@metamask-previews/hw-wallet-sdk 0.2.0-412b185 → 0.5.0-fd40efd

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/CHANGELOG.md CHANGED
@@ -7,6 +7,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.0]
11
+
12
+ ### Added
13
+
14
+ - Add error mapping for status code `0x6a83` indicating Ethereum app closed while on Solana ([#446](https://github.com/MetaMask/accounts/pull/446))
15
+
16
+ ### Fixed
17
+
18
+ - Fix error mappings for status codes `0x650f` and `0x6d00` to map to `DeviceStateEthAppClosed` instead of incorrect error codes ([#466](https://github.com/MetaMask/accounts/pull/466))
19
+ - `0x650f`: changed from `ConnectionClosed` to `DeviceStateEthAppClosed`.
20
+ - `0x6d00`: changed from `DeviceStateOnlyV4Supported` to `DeviceStateEthAppClosed`.
21
+
22
+ ## [0.4.0]
23
+
24
+ ### Added
25
+
26
+ - Add `ErrorMapping` type ([#446](https://github.com/MetaMask/accounts/pull/446))
27
+
28
+ ## [0.3.0]
29
+
30
+ ### Added
31
+
32
+ - Add hardware wallet connection types and improved error handling ([#456](https://github.com/MetaMask/accounts/pull/456))
33
+ - Add `HardwareWalletType`, `ConnectionStatus`, `DeviceEvent` enums and `HardwareWalletConnectionState`, `DeviceEventPayload` types.
34
+ - Add Ledger error mappings for device locked and Ethereum app closed states.
35
+ - Add `isHardwareWalletError` static method to `HardwareWalletError` class for type-safe error checking.
36
+
10
37
  ## [0.2.0]
11
38
 
12
39
  ### Added
@@ -20,6 +47,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
20
47
  - Add hardware related error mappings and custom hardware error ([#421](https://github.com/MetaMask/accounts/pull/421))
21
48
  - Add BLE and mobile error mappings with new error codes for Bluetooth permissions, connection states, and mobile support ([#433](https://github.com/MetaMask/accounts/pull/433))
22
49
 
23
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/hw-wallet-sdk@0.2.0...HEAD
50
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/hw-wallet-sdk@0.5.0...HEAD
51
+ [0.5.0]: https://github.com/MetaMask/accounts/compare/@metamask/hw-wallet-sdk@0.4.0...@metamask/hw-wallet-sdk@0.5.0
52
+ [0.4.0]: https://github.com/MetaMask/accounts/compare/@metamask/hw-wallet-sdk@0.3.0...@metamask/hw-wallet-sdk@0.4.0
53
+ [0.3.0]: https://github.com/MetaMask/accounts/compare/@metamask/hw-wallet-sdk@0.2.0...@metamask/hw-wallet-sdk@0.3.0
24
54
  [0.2.0]: https://github.com/MetaMask/accounts/compare/@metamask/hw-wallet-sdk@0.1.0...@metamask/hw-wallet-sdk@0.2.0
25
55
  [0.1.0]: https://github.com/MetaMask/accounts/releases/tag/@metamask/hw-wallet-sdk@0.1.0
@@ -58,11 +58,11 @@ exports.LEDGER_ERROR_MAPPINGS = {
58
58
  userMessage: 'Your device is blocked due to too many failed attempts. Please follow device recovery procedures.',
59
59
  },
60
60
  '0x650f': {
61
- code: hardware_errors_enums_1.ErrorCode.ConnectionClosed,
62
- message: 'App closed or connection issue',
61
+ code: hardware_errors_enums_1.ErrorCode.DeviceStateEthAppClosed,
62
+ message: 'Ethereum app closed',
63
63
  severity: hardware_errors_enums_1.Severity.Err,
64
- category: hardware_errors_enums_1.Category.Connection,
65
- userMessage: 'Connection lost or app closed. Please open the corresponding app on your Ledger device.',
64
+ category: hardware_errors_enums_1.Category.DeviceState,
65
+ userMessage: 'Ethereum app is closed. Please open it on your Ledger device to continue.',
66
66
  },
67
67
  '0x5515': {
68
68
  code: hardware_errors_enums_1.ErrorCode.AuthenticationDeviceLocked,
@@ -85,12 +85,19 @@ exports.LEDGER_ERROR_MAPPINGS = {
85
85
  category: hardware_errors_enums_1.Category.DeviceState,
86
86
  userMessage: 'Blind signing is not supported on this device.',
87
87
  },
88
+ '0x6a83': {
89
+ code: hardware_errors_enums_1.ErrorCode.DeviceStateEthAppClosed,
90
+ message: 'Ethereum app closed',
91
+ severity: hardware_errors_enums_1.Severity.Err,
92
+ category: hardware_errors_enums_1.Category.DeviceState,
93
+ userMessage: 'Ethereum app is closed. Currently on solana. Please open it to continue.',
94
+ },
88
95
  '0x6d00': {
89
- code: hardware_errors_enums_1.ErrorCode.DeviceStateOnlyV4Supported,
90
- message: 'Ledger Only V4 supported',
96
+ code: hardware_errors_enums_1.ErrorCode.DeviceStateEthAppClosed,
97
+ message: 'Ethereum app closed',
91
98
  severity: hardware_errors_enums_1.Severity.Err,
92
99
  category: hardware_errors_enums_1.Category.DeviceState,
93
- userMessage: 'Only V4 is supported on this device.',
100
+ userMessage: 'Ethereum app is closed. Currently on bitcoin. Please open it to continue.',
94
101
  },
95
102
  '0x6e00': {
96
103
  code: hardware_errors_enums_1.ErrorCode.DeviceStateEthAppClosed,
@@ -113,6 +120,27 @@ exports.LEDGER_ERROR_MAPPINGS = {
113
120
  category: hardware_errors_enums_1.Category.DeviceState,
114
121
  userMessage: 'Your device is not responding. Please disconnect and reconnect your device.',
115
122
  },
123
+ '0x6b0c': {
124
+ code: hardware_errors_enums_1.ErrorCode.AuthenticationDeviceLocked,
125
+ message: 'Device locked',
126
+ severity: hardware_errors_enums_1.Severity.Err,
127
+ category: hardware_errors_enums_1.Category.Authentication,
128
+ userMessage: 'Please unlock your Ledger device to continue.',
129
+ },
130
+ '0x6a15': {
131
+ code: hardware_errors_enums_1.ErrorCode.DeviceStateEthAppClosed,
132
+ message: 'Ethereum app closed',
133
+ severity: hardware_errors_enums_1.Severity.Err,
134
+ category: hardware_errors_enums_1.Category.DeviceState,
135
+ userMessage: 'Ethereum app is closed. Please open it to continue.',
136
+ },
137
+ '0x6511': {
138
+ code: hardware_errors_enums_1.ErrorCode.DeviceStateEthAppClosed,
139
+ message: 'Ethereum app closed',
140
+ severity: hardware_errors_enums_1.Severity.Err,
141
+ category: hardware_errors_enums_1.Category.DeviceState,
142
+ userMessage: 'Ethereum app is closed. Please open it to continue.',
143
+ },
116
144
  };
117
145
  exports.BLE_ERROR_MAPPINGS = {
118
146
  BLUETOOTH_PERMISSION_DENIED: {
@@ -1 +1 @@
1
- {"version":3,"file":"hardware-error-mappings.cjs","sourceRoot":"","sources":["../src/hardware-error-mappings.ts"],"names":[],"mappings":";;;AAAA,uEAAwE;AAE3D,QAAA,qBAAqB,GAAG;IACnC,QAAQ,EAAE;QACR,IAAI,EAAE,iCAAS,CAAC,OAAO;QACvB,OAAO,EAAE,sBAAsB;QAC/B,QAAQ,EAAE,gCAAQ,CAAC,IAAI;QACvB,QAAQ,EAAE,gCAAQ,CAAC,OAAO;KAC3B;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,iCAAS,CAAC,oBAAoB;QACpC,OAAO,EAAE,uBAAuB;QAChC,QAAQ,EAAE,gCAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,gCAAQ,CAAC,cAAc;QACjC,WAAW,EAAE,wDAAwD;KACtE;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,iCAAS,CAAC,kCAAkC;QAClD,OAAO,EAAE,wBAAwB;QACjC,QAAQ,EAAE,gCAAQ,CAAC,OAAO;QAC1B,QAAQ,EAAE,gCAAQ,CAAC,cAAc;QACjC,WAAW,EAAE,kCAAkC;KAChD;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,iCAAS,CAAC,+BAA+B;QAC/C,OAAO,EAAE,mCAAmC;QAC5C,QAAQ,EAAE,gCAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,gCAAQ,CAAC,cAAc;QAEjC,WAAW,EACT,gFAAgF;KACnF;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,iCAAS,CAAC,YAAY;QAC5B,OAAO,EAAE,gCAAgC;QACzC,QAAQ,EAAE,gCAAQ,CAAC,OAAO;QAC1B,QAAQ,EAAE,gCAAQ,CAAC,UAAU;QAE7B,WAAW,EACT,sEAAsE;KACzE;IACD,QAAQ,EAAE;QACR,IA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message: 'Operation successful',\n severity: Severity.Info,\n category: Category.Success,\n },\n '0x6300': {\n code: ErrorCode.AuthenticationFailed,\n message: 'Authentication failed',\n severity: Severity.Err,\n category: Category.Authentication,\n userMessage: 'Authentication failed. Please verify your credentials.',\n },\n '0x63c0': {\n code: ErrorCode.AuthenticationPinAttemptsRemaining,\n message: 'PIN attempts remaining',\n severity: Severity.Warning,\n category: Category.Authentication,\n userMessage: 'Incorrect PIN. Please try again.',\n },\n '0x6982': {\n code: ErrorCode.AuthenticationSecurityCondition,\n message: 'Security conditions not satisfied',\n severity: Severity.Err,\n category: Category.Authentication,\n\n userMessage:\n 'Device is locked or access rights are insufficient. Please unlock your device.',\n },\n '0x6985': {\n code: ErrorCode.UserRejected,\n message: 'User rejected action on device',\n severity: Severity.Warning,\n category: Category.UserAction,\n\n userMessage:\n 'Transaction was rejected. Please approve on your device to continue.',\n },\n '0x9804': {\n code: ErrorCode.AuthenticationSecurityCondition,\n message: 'App update required',\n severity: Severity.Err,\n category: Category.Authentication,\n\n userMessage: 'Please update your Ledger app to continue.',\n },\n '0x9808': {\n code: ErrorCode.AuthenticationFailed,\n message: 'Contradiction in secret code status',\n severity: Severity.Err,\n category: Category.Authentication,\n },\n '0x9840': {\n code: ErrorCode.AuthenticationDeviceBlocked,\n message: 'Code blocked',\n severity: Severity.Critical,\n category: Category.Authentication,\n\n userMessage:\n 'Your device is blocked due to too many failed attempts. Please follow device recovery procedures.',\n },\n '0x650f': {\n code: ErrorCode.ConnectionClosed,\n message: 'App closed or connection issue',\n severity: Severity.Err,\n category: Category.Connection,\n userMessage:\n 'Connection lost or app closed. Please open the corresponding app on your Ledger device.',\n },\n '0x5515': {\n code: ErrorCode.AuthenticationDeviceLocked,\n message: 'Device is locked',\n severity: Severity.Err,\n category: Category.Authentication,\n userMessage: 'Please unlock your Ledger device to continue.',\n },\n '0x5501': {\n code: ErrorCode.UserRejected,\n message: 'User refused on device',\n severity: Severity.Warning,\n category: Category.UserAction,\n userMessage:\n 'Operation was rejected. Please approve on your device to continue.',\n },\n '0x6a80': {\n code: ErrorCode.DeviceStateBlindSignNotSupported,\n message: 'Blind signing not supported',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Blind signing is not supported on this device.',\n },\n '0x6d00': {\n code: ErrorCode.DeviceStateOnlyV4Supported,\n message: 'Ledger Only V4 supported',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Only V4 is supported on this device.',\n },\n '0x6e00': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is closed. Please open it to continue.',\n },\n '0x6501': {\n code: ErrorCode.DeviceStateEthAppOutOfDate,\n message: 'Ethereum app out of date',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is out of date. Please update it to continue.',\n },\n '0x6f00': {\n code: ErrorCode.DeviceUnresponsive,\n message: 'Device unresponsive',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage:\n 'Your device is not responding. Please disconnect and reconnect your device.',\n },\n};\n\nexport const BLE_ERROR_MAPPINGS = {\n BLUETOOTH_PERMISSION_DENIED: {\n code: ErrorCode.PermissionBluetoothDenied,\n message: 'Bluetooth permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Bluetooth permission is required to connect to your hardware wallet. Please enable it in your device settings.',\n },\n LOCATION_PERMISSION_DENIED: {\n code: ErrorCode.PermissionLocationDenied,\n message: 'Location permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Location permission is required for Bluetooth scanning on Android. Please enable it in your device settings.',\n },\n NEARBY_DEVICES_PERMISSION_DENIED: {\n code: ErrorCode.PermissionNearbyDevicesDenied,\n message: 'Nearby devices permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Nearby devices permission is required to scan for your hardware wallet. Please enable it in your device settings.',\n },\n BLUETOOTH_DISABLED: {\n code: ErrorCode.BluetoothDisabled,\n message: 'Bluetooth is turned off',\n severity: Severity.Warning,\n category: Category.Connection,\n userMessage:\n 'Bluetooth is turned off. Please enable Bluetooth to connect to your hardware wallet.',\n },\n BLUETOOTH_SCAN_FAILED: {\n code: ErrorCode.BluetoothScanFailed,\n message: 'Bluetooth scanning failed',\n severity: Severity.Err,\n category: Category.Connection,\n userMessage: 'Unable to scan for Bluetooth devices. Please try again.',\n },\n BLUETOOTH_CONNECTION_FAILED: {\n code: ErrorCode.BluetoothConnectionFailed,\n message: 'Bluetooth connection failed',\n severity: Severity.Err,\n category: Category.Connection,\n userMessage:\n 'Failed to connect via Bluetooth. Please make sure your device is nearby and try again.',\n },\n};\n\nexport const MOBILE_ERROR_MAPPINGS = {\n NOT_SUPPORTED: {\n code: ErrorCode.MobileNotSupported,\n message: 'Operation not supported on mobile',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'This operation is not supported on mobile devices.',\n },\n};\n"]}
1
+ {"version":3,"file":"hardware-error-mappings.cjs","sourceRoot":"","sources":["../src/hardware-error-mappings.ts"],"names":[],"mappings":";;;AAAA,uEAAwE;AAU3D,QAAA,qBAAqB,GAAiC;IACjE,QAAQ,EAAE;QACR,IAAI,EAAE,iCAAS,CAAC,OAAO;QACvB,OAAO,EAAE,sBAAsB;QAC/B,QAAQ,EAAE,gCAAQ,CAAC,IAAI;QACvB,QAAQ,EAAE,gCAAQ,CAAC,OAAO;KAC3B;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,iCAAS,CAAC,oBAAoB;QACpC,OAAO,EAAE,uBAAuB;QAChC,QAAQ,EAAE,gCAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,gCAAQ,CAAC,cAAc;QACjC,WAAW,EAAE,wDAAwD;KACtE;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,iCAAS,CAAC,kCAAkC;QAClD,OAAO,EAAE,wBAAwB;QACjC,QAAQ,EAAE,gCAAQ,CAAC,OAAO;QAC1B,QAAQ,EAAE,gCAAQ,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AAQ,EAAE,gCAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,gCAAQ,CAAC,aAAa;QAChC,WAAW,EACT,8GAA8G;KACjH;IACD,gCAAgC,EAAE;QAChC,IAAI,EAAE,iCAAS,CAAC,6BAA6B;QAC7C,OAAO,EAAE,kCAAkC;QAC3C,QAAQ,EAAE,gCAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,gCAAQ,CAAC,aAAa;QAChC,WAAW,EACT,mHAAmH;KACtH;IACD,kBAAkB,EAAE;QAClB,IAAI,EAAE,iCAAS,CAAC,iBAAiB;QACjC,OAAO,EAAE,yBAAyB;QAClC,QAAQ,EAAE,gCAAQ,CAAC,OAAO;QAC1B,QAAQ,EAAE,gCAAQ,CAAC,UAAU;QAC7B,WAAW,EACT,sFAAsF;KACzF;IACD,qBAAqB,EAAE;QACrB,IAAI,EAAE,iCAAS,CAAC,mBAAmB;QACnC,OAAO,EAAE,2BAA2B;QACpC,QAAQ,EAAE,gCAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,gCAAQ,CAAC,UAAU;QAC7B,WAAW,EAAE,yDAAyD;KACvE;IACD,2BAA2B,EAAE;QAC3B,IAAI,EAAE,iCAAS,CAAC,yBAAyB;QACzC,OAAO,EAAE,6BAA6B;QACtC,QAAQ,EAAE,gCAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,gCAAQ,CAAC,UAAU;QAC7B,WAAW,EACT,wFAAwF;KAC3F;CACF,CAAC;AAEW,QAAA,qBAAqB,GAAG;IACnC,aAAa,EAAE;QACb,IAAI,EAAE,iCAAS,CAAC,kBAAkB;QAClC,OAAO,EAAE,mCAAmC;QAC5C,QAAQ,EAAE,gCAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,gCAAQ,CAAC,WAAW;QAC9B,WAAW,EAAE,oDAAoD;KAClE;CACF,CAAC","sourcesContent":["import { ErrorCode, Severity, Category } from './hardware-errors-enums';\n\nexport type ErrorMapping = {\n code: ErrorCode;\n message: string;\n severity: Severity;\n category: Category;\n userMessage?: string;\n};\n\nexport const LEDGER_ERROR_MAPPINGS: Record<string, ErrorMapping> = {\n '0x9000': {\n code: ErrorCode.Success,\n message: 'Operation successful',\n severity: Severity.Info,\n category: Category.Success,\n },\n '0x6300': {\n code: ErrorCode.AuthenticationFailed,\n message: 'Authentication failed',\n severity: Severity.Err,\n category: Category.Authentication,\n userMessage: 'Authentication failed. Please verify your credentials.',\n },\n '0x63c0': {\n code: ErrorCode.AuthenticationPinAttemptsRemaining,\n message: 'PIN attempts remaining',\n severity: Severity.Warning,\n category: Category.Authentication,\n userMessage: 'Incorrect PIN. Please try again.',\n },\n '0x6982': {\n code: ErrorCode.AuthenticationSecurityCondition,\n message: 'Security conditions not satisfied',\n severity: Severity.Err,\n category: Category.Authentication,\n\n userMessage:\n 'Device is locked or access rights are insufficient. Please unlock your device.',\n },\n '0x6985': {\n code: ErrorCode.UserRejected,\n message: 'User rejected action on device',\n severity: Severity.Warning,\n category: Category.UserAction,\n\n userMessage:\n 'Transaction was rejected. Please approve on your device to continue.',\n },\n '0x9804': {\n code: ErrorCode.AuthenticationSecurityCondition,\n message: 'App update required',\n severity: Severity.Err,\n category: Category.Authentication,\n\n userMessage: 'Please update your Ledger app to continue.',\n },\n '0x9808': {\n code: ErrorCode.AuthenticationFailed,\n message: 'Contradiction in secret code status',\n severity: Severity.Err,\n category: Category.Authentication,\n },\n '0x9840': {\n code: ErrorCode.AuthenticationDeviceBlocked,\n message: 'Code blocked',\n severity: Severity.Critical,\n category: Category.Authentication,\n\n userMessage:\n 'Your device is blocked due to too many failed attempts. Please follow device recovery procedures.',\n },\n '0x650f': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage:\n 'Ethereum app is closed. Please open it on your Ledger device to continue.',\n },\n '0x5515': {\n code: ErrorCode.AuthenticationDeviceLocked,\n message: 'Device is locked',\n severity: Severity.Err,\n category: Category.Authentication,\n userMessage: 'Please unlock your Ledger device to continue.',\n },\n '0x5501': {\n code: ErrorCode.UserRejected,\n message: 'User refused on device',\n severity: Severity.Warning,\n category: Category.UserAction,\n userMessage:\n 'Operation was rejected. Please approve on your device to continue.',\n },\n '0x6a80': {\n code: ErrorCode.DeviceStateBlindSignNotSupported,\n message: 'Blind signing not supported',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Blind signing is not supported on this device.',\n },\n '0x6a83': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage:\n 'Ethereum app is closed. Currently on solana. Please open it to continue.',\n },\n '0x6d00': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage:\n 'Ethereum app is closed. Currently on bitcoin. Please open it to continue.',\n },\n '0x6e00': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is closed. Please open it to continue.',\n },\n '0x6501': {\n code: ErrorCode.DeviceStateEthAppOutOfDate,\n message: 'Ethereum app out of date',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is out of date. Please update it to continue.',\n },\n '0x6f00': {\n code: ErrorCode.DeviceUnresponsive,\n message: 'Device unresponsive',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage:\n 'Your device is not responding. Please disconnect and reconnect your device.',\n },\n '0x6b0c': {\n code: ErrorCode.AuthenticationDeviceLocked,\n message: 'Device locked',\n severity: Severity.Err,\n category: Category.Authentication,\n userMessage: 'Please unlock your Ledger device to continue.',\n },\n '0x6a15': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is closed. Please open it to continue.',\n },\n '0x6511': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is closed. Please open it to continue.',\n },\n};\n\nexport const BLE_ERROR_MAPPINGS = {\n BLUETOOTH_PERMISSION_DENIED: {\n code: ErrorCode.PermissionBluetoothDenied,\n message: 'Bluetooth permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Bluetooth permission is required to connect to your hardware wallet. Please enable it in your device settings.',\n },\n LOCATION_PERMISSION_DENIED: {\n code: ErrorCode.PermissionLocationDenied,\n message: 'Location permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Location permission is required for Bluetooth scanning on Android. Please enable it in your device settings.',\n },\n NEARBY_DEVICES_PERMISSION_DENIED: {\n code: ErrorCode.PermissionNearbyDevicesDenied,\n message: 'Nearby devices permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Nearby devices permission is required to scan for your hardware wallet. Please enable it in your device settings.',\n },\n BLUETOOTH_DISABLED: {\n code: ErrorCode.BluetoothDisabled,\n message: 'Bluetooth is turned off',\n severity: Severity.Warning,\n category: Category.Connection,\n userMessage:\n 'Bluetooth is turned off. Please enable Bluetooth to connect to your hardware wallet.',\n },\n BLUETOOTH_SCAN_FAILED: {\n code: ErrorCode.BluetoothScanFailed,\n message: 'Bluetooth scanning failed',\n severity: Severity.Err,\n category: Category.Connection,\n userMessage: 'Unable to scan for Bluetooth devices. Please try again.',\n },\n BLUETOOTH_CONNECTION_FAILED: {\n code: ErrorCode.BluetoothConnectionFailed,\n message: 'Bluetooth connection failed',\n severity: Severity.Err,\n category: Category.Connection,\n userMessage:\n 'Failed to connect via Bluetooth. Please make sure your device is nearby and try again.',\n },\n};\n\nexport const MOBILE_ERROR_MAPPINGS = {\n NOT_SUPPORTED: {\n code: ErrorCode.MobileNotSupported,\n message: 'Operation not supported on mobile',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'This operation is not supported on mobile devices.',\n },\n};\n"]}
@@ -1,116 +1,12 @@
1
1
  import { ErrorCode, Severity, Category } from "./hardware-errors-enums.cjs";
2
- export declare const LEDGER_ERROR_MAPPINGS: {
3
- '0x9000': {
4
- code: ErrorCode;
5
- message: string;
6
- severity: Severity;
7
- category: Category;
8
- };
9
- '0x6300': {
10
- code: ErrorCode;
11
- message: string;
12
- severity: Severity;
13
- category: Category;
14
- userMessage: string;
15
- };
16
- '0x63c0': {
17
- code: ErrorCode;
18
- message: string;
19
- severity: Severity;
20
- category: Category;
21
- userMessage: string;
22
- };
23
- '0x6982': {
24
- code: ErrorCode;
25
- message: string;
26
- severity: Severity;
27
- category: Category;
28
- userMessage: string;
29
- };
30
- '0x6985': {
31
- code: ErrorCode;
32
- message: string;
33
- severity: Severity;
34
- category: Category;
35
- userMessage: string;
36
- };
37
- '0x9804': {
38
- code: ErrorCode;
39
- message: string;
40
- severity: Severity;
41
- category: Category;
42
- userMessage: string;
43
- };
44
- '0x9808': {
45
- code: ErrorCode;
46
- message: string;
47
- severity: Severity;
48
- category: Category;
49
- };
50
- '0x9840': {
51
- code: ErrorCode;
52
- message: string;
53
- severity: Severity;
54
- category: Category;
55
- userMessage: string;
56
- };
57
- '0x650f': {
58
- code: ErrorCode;
59
- message: string;
60
- severity: Severity;
61
- category: Category;
62
- userMessage: string;
63
- };
64
- '0x5515': {
65
- code: ErrorCode;
66
- message: string;
67
- severity: Severity;
68
- category: Category;
69
- userMessage: string;
70
- };
71
- '0x5501': {
72
- code: ErrorCode;
73
- message: string;
74
- severity: Severity;
75
- category: Category;
76
- userMessage: string;
77
- };
78
- '0x6a80': {
79
- code: ErrorCode;
80
- message: string;
81
- severity: Severity;
82
- category: Category;
83
- userMessage: string;
84
- };
85
- '0x6d00': {
86
- code: ErrorCode;
87
- message: string;
88
- severity: Severity;
89
- category: Category;
90
- userMessage: string;
91
- };
92
- '0x6e00': {
93
- code: ErrorCode;
94
- message: string;
95
- severity: Severity;
96
- category: Category;
97
- userMessage: string;
98
- };
99
- '0x6501': {
100
- code: ErrorCode;
101
- message: string;
102
- severity: Severity;
103
- category: Category;
104
- userMessage: string;
105
- };
106
- '0x6f00': {
107
- code: ErrorCode;
108
- message: string;
109
- severity: Severity;
110
- category: Category;
111
- userMessage: string;
112
- };
2
+ export type ErrorMapping = {
3
+ code: ErrorCode;
4
+ message: string;
5
+ severity: Severity;
6
+ category: Category;
7
+ userMessage?: string;
113
8
  };
9
+ export declare const LEDGER_ERROR_MAPPINGS: Record<string, ErrorMapping>;
114
10
  export declare const BLE_ERROR_MAPPINGS: {
115
11
  BLUETOOTH_PERMISSION_DENIED: {
116
12
  code: ErrorCode;
@@ -1 +1 @@
1
- {"version":3,"file":"hardware-error-mappings.d.cts","sourceRoot":"","sources":["../src/hardware-error-mappings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,oCAAgC;AAExE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHjC,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgD9B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;CAQjC,CAAC"}
1
+ {"version":3,"file":"hardware-error-mappings.d.cts","sourceRoot":"","sources":["../src/hardware-error-mappings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,oCAAgC;AAExE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAuJ9D,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgD9B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;CAQjC,CAAC"}
@@ -1,116 +1,12 @@
1
1
  import { ErrorCode, Severity, Category } from "./hardware-errors-enums.mjs";
2
- export declare const LEDGER_ERROR_MAPPINGS: {
3
- '0x9000': {
4
- code: ErrorCode;
5
- message: string;
6
- severity: Severity;
7
- category: Category;
8
- };
9
- '0x6300': {
10
- code: ErrorCode;
11
- message: string;
12
- severity: Severity;
13
- category: Category;
14
- userMessage: string;
15
- };
16
- '0x63c0': {
17
- code: ErrorCode;
18
- message: string;
19
- severity: Severity;
20
- category: Category;
21
- userMessage: string;
22
- };
23
- '0x6982': {
24
- code: ErrorCode;
25
- message: string;
26
- severity: Severity;
27
- category: Category;
28
- userMessage: string;
29
- };
30
- '0x6985': {
31
- code: ErrorCode;
32
- message: string;
33
- severity: Severity;
34
- category: Category;
35
- userMessage: string;
36
- };
37
- '0x9804': {
38
- code: ErrorCode;
39
- message: string;
40
- severity: Severity;
41
- category: Category;
42
- userMessage: string;
43
- };
44
- '0x9808': {
45
- code: ErrorCode;
46
- message: string;
47
- severity: Severity;
48
- category: Category;
49
- };
50
- '0x9840': {
51
- code: ErrorCode;
52
- message: string;
53
- severity: Severity;
54
- category: Category;
55
- userMessage: string;
56
- };
57
- '0x650f': {
58
- code: ErrorCode;
59
- message: string;
60
- severity: Severity;
61
- category: Category;
62
- userMessage: string;
63
- };
64
- '0x5515': {
65
- code: ErrorCode;
66
- message: string;
67
- severity: Severity;
68
- category: Category;
69
- userMessage: string;
70
- };
71
- '0x5501': {
72
- code: ErrorCode;
73
- message: string;
74
- severity: Severity;
75
- category: Category;
76
- userMessage: string;
77
- };
78
- '0x6a80': {
79
- code: ErrorCode;
80
- message: string;
81
- severity: Severity;
82
- category: Category;
83
- userMessage: string;
84
- };
85
- '0x6d00': {
86
- code: ErrorCode;
87
- message: string;
88
- severity: Severity;
89
- category: Category;
90
- userMessage: string;
91
- };
92
- '0x6e00': {
93
- code: ErrorCode;
94
- message: string;
95
- severity: Severity;
96
- category: Category;
97
- userMessage: string;
98
- };
99
- '0x6501': {
100
- code: ErrorCode;
101
- message: string;
102
- severity: Severity;
103
- category: Category;
104
- userMessage: string;
105
- };
106
- '0x6f00': {
107
- code: ErrorCode;
108
- message: string;
109
- severity: Severity;
110
- category: Category;
111
- userMessage: string;
112
- };
2
+ export type ErrorMapping = {
3
+ code: ErrorCode;
4
+ message: string;
5
+ severity: Severity;
6
+ category: Category;
7
+ userMessage?: string;
113
8
  };
9
+ export declare const LEDGER_ERROR_MAPPINGS: Record<string, ErrorMapping>;
114
10
  export declare const BLE_ERROR_MAPPINGS: {
115
11
  BLUETOOTH_PERMISSION_DENIED: {
116
12
  code: ErrorCode;
@@ -1 +1 @@
1
- {"version":3,"file":"hardware-error-mappings.d.mts","sourceRoot":"","sources":["../src/hardware-error-mappings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,oCAAgC;AAExE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHjC,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgD9B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;CAQjC,CAAC"}
1
+ {"version":3,"file":"hardware-error-mappings.d.mts","sourceRoot":"","sources":["../src/hardware-error-mappings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,oCAAgC;AAExE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAuJ9D,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgD9B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;CAQjC,CAAC"}
@@ -55,11 +55,11 @@ export const LEDGER_ERROR_MAPPINGS = {
55
55
  userMessage: 'Your device is blocked due to too many failed attempts. Please follow device recovery procedures.',
56
56
  },
57
57
  '0x650f': {
58
- code: ErrorCode.ConnectionClosed,
59
- message: 'App closed or connection issue',
58
+ code: ErrorCode.DeviceStateEthAppClosed,
59
+ message: 'Ethereum app closed',
60
60
  severity: Severity.Err,
61
- category: Category.Connection,
62
- userMessage: 'Connection lost or app closed. Please open the corresponding app on your Ledger device.',
61
+ category: Category.DeviceState,
62
+ userMessage: 'Ethereum app is closed. Please open it on your Ledger device to continue.',
63
63
  },
64
64
  '0x5515': {
65
65
  code: ErrorCode.AuthenticationDeviceLocked,
@@ -82,12 +82,19 @@ export const LEDGER_ERROR_MAPPINGS = {
82
82
  category: Category.DeviceState,
83
83
  userMessage: 'Blind signing is not supported on this device.',
84
84
  },
85
+ '0x6a83': {
86
+ code: ErrorCode.DeviceStateEthAppClosed,
87
+ message: 'Ethereum app closed',
88
+ severity: Severity.Err,
89
+ category: Category.DeviceState,
90
+ userMessage: 'Ethereum app is closed. Currently on solana. Please open it to continue.',
91
+ },
85
92
  '0x6d00': {
86
- code: ErrorCode.DeviceStateOnlyV4Supported,
87
- message: 'Ledger Only V4 supported',
93
+ code: ErrorCode.DeviceStateEthAppClosed,
94
+ message: 'Ethereum app closed',
88
95
  severity: Severity.Err,
89
96
  category: Category.DeviceState,
90
- userMessage: 'Only V4 is supported on this device.',
97
+ userMessage: 'Ethereum app is closed. Currently on bitcoin. Please open it to continue.',
91
98
  },
92
99
  '0x6e00': {
93
100
  code: ErrorCode.DeviceStateEthAppClosed,
@@ -110,6 +117,27 @@ export const LEDGER_ERROR_MAPPINGS = {
110
117
  category: Category.DeviceState,
111
118
  userMessage: 'Your device is not responding. Please disconnect and reconnect your device.',
112
119
  },
120
+ '0x6b0c': {
121
+ code: ErrorCode.AuthenticationDeviceLocked,
122
+ message: 'Device locked',
123
+ severity: Severity.Err,
124
+ category: Category.Authentication,
125
+ userMessage: 'Please unlock your Ledger device to continue.',
126
+ },
127
+ '0x6a15': {
128
+ code: ErrorCode.DeviceStateEthAppClosed,
129
+ message: 'Ethereum app closed',
130
+ severity: Severity.Err,
131
+ category: Category.DeviceState,
132
+ userMessage: 'Ethereum app is closed. Please open it to continue.',
133
+ },
134
+ '0x6511': {
135
+ code: ErrorCode.DeviceStateEthAppClosed,
136
+ message: 'Ethereum app closed',
137
+ severity: Severity.Err,
138
+ category: Category.DeviceState,
139
+ userMessage: 'Ethereum app is closed. Please open it to continue.',
140
+ },
113
141
  };
114
142
  export const BLE_ERROR_MAPPINGS = {
115
143
  BLUETOOTH_PERMISSION_DENIED: {
@@ -1 +1 @@
1
- {"version":3,"file":"hardware-error-mappings.mjs","sourceRoot":"","sources":["../src/hardware-error-mappings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,oCAAgC;AAExE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS,CAAC,OAAO;QACvB,OAAO,EAAE,sBAAsB;QAC/B,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,QAAQ,EAAE,QAAQ,CAAC,OAAO;KAC3B;IACD,QAAQ,EAAE;QACR,IAAI,EAAE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EAAE,SAAS,CAAC,mBAAmB;QACnC,OAAO,EAAE,2BAA2B;QACpC,QAAQ,EAAE,QAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,QAAQ,CAAC,UAAU;QAC7B,WAAW,EAAE,yDAAyD;KACvE;IACD,2BAA2B,EAAE;QAC3B,IAAI,EAAE,SAAS,CAAC,yBAAyB;QACzC,OAAO,EAAE,6BAA6B;QACtC,QAAQ,EAAE,QAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,QAAQ,CAAC,UAAU;QAC7B,WAAW,EACT,wFAAwF;KAC3F;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,aAAa,EAAE;QACb,IAAI,EAAE,SAAS,CAAC,kBAAkB;QAClC,OAAO,EAAE,mCAAmC;QAC5C,QAAQ,EAAE,QAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,QAAQ,CAAC,WAAW;QAC9B,WAAW,EAAE,oDAAoD;KAClE;CACF,CAAC","sourcesContent":["import { ErrorCode, Severity, Category } from './hardware-errors-enums';\n\nexport const LEDGER_ERROR_MAPPINGS = {\n '0x9000': {\n code: ErrorCode.Success,\n message: 'Operation successful',\n severity: Severity.Info,\n category: Category.Success,\n },\n '0x6300': {\n code: ErrorCode.AuthenticationFailed,\n message: 'Authentication failed',\n severity: Severity.Err,\n category: Category.Authentication,\n userMessage: 'Authentication failed. Please verify your credentials.',\n },\n '0x63c0': {\n code: ErrorCode.AuthenticationPinAttemptsRemaining,\n message: 'PIN attempts remaining',\n severity: Severity.Warning,\n category: Category.Authentication,\n userMessage: 'Incorrect PIN. Please try again.',\n },\n '0x6982': {\n code: ErrorCode.AuthenticationSecurityCondition,\n message: 'Security conditions not satisfied',\n severity: Severity.Err,\n category: Category.Authentication,\n\n userMessage:\n 'Device is locked or access rights are insufficient. Please unlock your device.',\n },\n '0x6985': {\n code: ErrorCode.UserRejected,\n message: 'User rejected action on device',\n severity: Severity.Warning,\n category: Category.UserAction,\n\n userMessage:\n 'Transaction was rejected. Please approve on your device to continue.',\n },\n '0x9804': {\n code: ErrorCode.AuthenticationSecurityCondition,\n message: 'App update required',\n severity: Severity.Err,\n category: Category.Authentication,\n\n userMessage: 'Please update your Ledger app to continue.',\n },\n '0x9808': {\n code: ErrorCode.AuthenticationFailed,\n message: 'Contradiction in secret code status',\n severity: Severity.Err,\n category: Category.Authentication,\n },\n '0x9840': {\n code: ErrorCode.AuthenticationDeviceBlocked,\n message: 'Code blocked',\n severity: Severity.Critical,\n category: Category.Authentication,\n\n userMessage:\n 'Your device is blocked due to too many failed attempts. Please follow device recovery procedures.',\n },\n '0x650f': {\n code: ErrorCode.ConnectionClosed,\n message: 'App closed or connection issue',\n severity: Severity.Err,\n category: Category.Connection,\n userMessage:\n 'Connection lost or app closed. Please open the corresponding app on your Ledger device.',\n },\n '0x5515': {\n code: ErrorCode.AuthenticationDeviceLocked,\n message: 'Device is locked',\n severity: Severity.Err,\n category: Category.Authentication,\n userMessage: 'Please unlock your Ledger device to continue.',\n },\n '0x5501': {\n code: ErrorCode.UserRejected,\n message: 'User refused on device',\n severity: Severity.Warning,\n category: Category.UserAction,\n userMessage:\n 'Operation was rejected. Please approve on your device to continue.',\n },\n '0x6a80': {\n code: ErrorCode.DeviceStateBlindSignNotSupported,\n message: 'Blind signing not supported',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Blind signing is not supported on this device.',\n },\n '0x6d00': {\n code: ErrorCode.DeviceStateOnlyV4Supported,\n message: 'Ledger Only V4 supported',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Only V4 is supported on this device.',\n },\n '0x6e00': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is closed. Please open it to continue.',\n },\n '0x6501': {\n code: ErrorCode.DeviceStateEthAppOutOfDate,\n message: 'Ethereum app out of date',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is out of date. Please update it to continue.',\n },\n '0x6f00': {\n code: ErrorCode.DeviceUnresponsive,\n message: 'Device unresponsive',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage:\n 'Your device is not responding. Please disconnect and reconnect your device.',\n },\n};\n\nexport const BLE_ERROR_MAPPINGS = {\n BLUETOOTH_PERMISSION_DENIED: {\n code: ErrorCode.PermissionBluetoothDenied,\n message: 'Bluetooth permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Bluetooth permission is required to connect to your hardware wallet. Please enable it in your device settings.',\n },\n LOCATION_PERMISSION_DENIED: {\n code: ErrorCode.PermissionLocationDenied,\n message: 'Location permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Location permission is required for Bluetooth scanning on Android. Please enable it in your device settings.',\n },\n NEARBY_DEVICES_PERMISSION_DENIED: {\n code: ErrorCode.PermissionNearbyDevicesDenied,\n message: 'Nearby devices permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Nearby devices permission is required to scan for your hardware wallet. Please enable it in your device settings.',\n },\n BLUETOOTH_DISABLED: {\n code: ErrorCode.BluetoothDisabled,\n message: 'Bluetooth is turned off',\n severity: Severity.Warning,\n category: Category.Connection,\n userMessage:\n 'Bluetooth is turned off. Please enable Bluetooth to connect to your hardware wallet.',\n },\n BLUETOOTH_SCAN_FAILED: {\n code: ErrorCode.BluetoothScanFailed,\n message: 'Bluetooth scanning failed',\n severity: Severity.Err,\n category: Category.Connection,\n userMessage: 'Unable to scan for Bluetooth devices. Please try again.',\n },\n BLUETOOTH_CONNECTION_FAILED: {\n code: ErrorCode.BluetoothConnectionFailed,\n message: 'Bluetooth connection failed',\n severity: Severity.Err,\n category: Category.Connection,\n userMessage:\n 'Failed to connect via Bluetooth. Please make sure your device is nearby and try again.',\n },\n};\n\nexport const MOBILE_ERROR_MAPPINGS = {\n NOT_SUPPORTED: {\n code: ErrorCode.MobileNotSupported,\n message: 'Operation not supported on mobile',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'This operation is not supported on mobile devices.',\n },\n};\n"]}
1
+ {"version":3,"file":"hardware-error-mappings.mjs","sourceRoot":"","sources":["../src/hardware-error-mappings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,oCAAgC;AAUxE,MAAM,CAAC,MAAM,qBAAqB,GAAiC;IACjE,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS,CAAC,OAAO;QACvB,OAAO,EAAE,sBAAsB;QAC/B,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,QAAQ,EAAE,QAAQ,CAAC,OAAO;KAC3B;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS,CAAC,oBAAoB;QACpC,OAAO,EAAE,uBAAuB;QAChC,QAAQ,EAAE,QAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,QAAQ,CAAC,cAAc;QACjC,WAAW,EAAE,wDAAwD;KACtE;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS,CAAC,kCAAkC;QAClD,OAAO,EAAE,wBAAwB;QACjC,QAAQ,EAAE,QAAQ,CAAC,OAAO;QAC1B,QAAQ,EAAE,QAAQ,CAAC,cAAc;QACjC,WAAW,EAAE,kCAAkC;KAChD;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS,CAAC,+BAA+B;QAC/C,OAAO,EAAE,mCAAmC;QAC5C,QAAQ,EAAE,QAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,QAAQ,CAAC,cAAc;QAEjC,WAAW,EACT,gFAAgF;KACnF;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS,CAAC,YAAY;QAC5B,OAAO,EAAE,gCAAgC;QACzC,QAAQ,EAAE,QAAQ,CAAC,OAAO;QAC1B,QAAQ,EAAE,QAAQ,CAAC,UAAU;QAE7B,WAAW,EACT,sEAAsE;KACzE;IACD,QAAQ,EAAE;QACR,IAAI,EAAE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AAI,EAAE,SAAS,CAAC,mBAAmB;QACnC,OAAO,EAAE,2BAA2B;QACpC,QAAQ,EAAE,QAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,QAAQ,CAAC,UAAU;QAC7B,WAAW,EAAE,yDAAyD;KACvE;IACD,2BAA2B,EAAE;QAC3B,IAAI,EAAE,SAAS,CAAC,yBAAyB;QACzC,OAAO,EAAE,6BAA6B;QACtC,QAAQ,EAAE,QAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,QAAQ,CAAC,UAAU;QAC7B,WAAW,EACT,wFAAwF;KAC3F;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,aAAa,EAAE;QACb,IAAI,EAAE,SAAS,CAAC,kBAAkB;QAClC,OAAO,EAAE,mCAAmC;QAC5C,QAAQ,EAAE,QAAQ,CAAC,GAAG;QACtB,QAAQ,EAAE,QAAQ,CAAC,WAAW;QAC9B,WAAW,EAAE,oDAAoD;KAClE;CACF,CAAC","sourcesContent":["import { ErrorCode, Severity, Category } from './hardware-errors-enums';\n\nexport type ErrorMapping = {\n code: ErrorCode;\n message: string;\n severity: Severity;\n category: Category;\n userMessage?: string;\n};\n\nexport const LEDGER_ERROR_MAPPINGS: Record<string, ErrorMapping> = {\n '0x9000': {\n code: ErrorCode.Success,\n message: 'Operation successful',\n severity: Severity.Info,\n category: Category.Success,\n },\n '0x6300': {\n code: ErrorCode.AuthenticationFailed,\n message: 'Authentication failed',\n severity: Severity.Err,\n category: Category.Authentication,\n userMessage: 'Authentication failed. Please verify your credentials.',\n },\n '0x63c0': {\n code: ErrorCode.AuthenticationPinAttemptsRemaining,\n message: 'PIN attempts remaining',\n severity: Severity.Warning,\n category: Category.Authentication,\n userMessage: 'Incorrect PIN. Please try again.',\n },\n '0x6982': {\n code: ErrorCode.AuthenticationSecurityCondition,\n message: 'Security conditions not satisfied',\n severity: Severity.Err,\n category: Category.Authentication,\n\n userMessage:\n 'Device is locked or access rights are insufficient. Please unlock your device.',\n },\n '0x6985': {\n code: ErrorCode.UserRejected,\n message: 'User rejected action on device',\n severity: Severity.Warning,\n category: Category.UserAction,\n\n userMessage:\n 'Transaction was rejected. Please approve on your device to continue.',\n },\n '0x9804': {\n code: ErrorCode.AuthenticationSecurityCondition,\n message: 'App update required',\n severity: Severity.Err,\n category: Category.Authentication,\n\n userMessage: 'Please update your Ledger app to continue.',\n },\n '0x9808': {\n code: ErrorCode.AuthenticationFailed,\n message: 'Contradiction in secret code status',\n severity: Severity.Err,\n category: Category.Authentication,\n },\n '0x9840': {\n code: ErrorCode.AuthenticationDeviceBlocked,\n message: 'Code blocked',\n severity: Severity.Critical,\n category: Category.Authentication,\n\n userMessage:\n 'Your device is blocked due to too many failed attempts. Please follow device recovery procedures.',\n },\n '0x650f': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage:\n 'Ethereum app is closed. Please open it on your Ledger device to continue.',\n },\n '0x5515': {\n code: ErrorCode.AuthenticationDeviceLocked,\n message: 'Device is locked',\n severity: Severity.Err,\n category: Category.Authentication,\n userMessage: 'Please unlock your Ledger device to continue.',\n },\n '0x5501': {\n code: ErrorCode.UserRejected,\n message: 'User refused on device',\n severity: Severity.Warning,\n category: Category.UserAction,\n userMessage:\n 'Operation was rejected. Please approve on your device to continue.',\n },\n '0x6a80': {\n code: ErrorCode.DeviceStateBlindSignNotSupported,\n message: 'Blind signing not supported',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Blind signing is not supported on this device.',\n },\n '0x6a83': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage:\n 'Ethereum app is closed. Currently on solana. Please open it to continue.',\n },\n '0x6d00': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage:\n 'Ethereum app is closed. Currently on bitcoin. Please open it to continue.',\n },\n '0x6e00': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is closed. Please open it to continue.',\n },\n '0x6501': {\n code: ErrorCode.DeviceStateEthAppOutOfDate,\n message: 'Ethereum app out of date',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is out of date. Please update it to continue.',\n },\n '0x6f00': {\n code: ErrorCode.DeviceUnresponsive,\n message: 'Device unresponsive',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage:\n 'Your device is not responding. Please disconnect and reconnect your device.',\n },\n '0x6b0c': {\n code: ErrorCode.AuthenticationDeviceLocked,\n message: 'Device locked',\n severity: Severity.Err,\n category: Category.Authentication,\n userMessage: 'Please unlock your Ledger device to continue.',\n },\n '0x6a15': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is closed. Please open it to continue.',\n },\n '0x6511': {\n code: ErrorCode.DeviceStateEthAppClosed,\n message: 'Ethereum app closed',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'Ethereum app is closed. Please open it to continue.',\n },\n};\n\nexport const BLE_ERROR_MAPPINGS = {\n BLUETOOTH_PERMISSION_DENIED: {\n code: ErrorCode.PermissionBluetoothDenied,\n message: 'Bluetooth permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Bluetooth permission is required to connect to your hardware wallet. Please enable it in your device settings.',\n },\n LOCATION_PERMISSION_DENIED: {\n code: ErrorCode.PermissionLocationDenied,\n message: 'Location permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Location permission is required for Bluetooth scanning on Android. Please enable it in your device settings.',\n },\n NEARBY_DEVICES_PERMISSION_DENIED: {\n code: ErrorCode.PermissionNearbyDevicesDenied,\n message: 'Nearby devices permission denied',\n severity: Severity.Err,\n category: Category.Configuration,\n userMessage:\n 'Nearby devices permission is required to scan for your hardware wallet. Please enable it in your device settings.',\n },\n BLUETOOTH_DISABLED: {\n code: ErrorCode.BluetoothDisabled,\n message: 'Bluetooth is turned off',\n severity: Severity.Warning,\n category: Category.Connection,\n userMessage:\n 'Bluetooth is turned off. Please enable Bluetooth to connect to your hardware wallet.',\n },\n BLUETOOTH_SCAN_FAILED: {\n code: ErrorCode.BluetoothScanFailed,\n message: 'Bluetooth scanning failed',\n severity: Severity.Err,\n category: Category.Connection,\n userMessage: 'Unable to scan for Bluetooth devices. Please try again.',\n },\n BLUETOOTH_CONNECTION_FAILED: {\n code: ErrorCode.BluetoothConnectionFailed,\n message: 'Bluetooth connection failed',\n severity: Severity.Err,\n category: Category.Connection,\n userMessage:\n 'Failed to connect via Bluetooth. Please make sure your device is nearby and try again.',\n },\n};\n\nexport const MOBILE_ERROR_MAPPINGS = {\n NOT_SUPPORTED: {\n code: ErrorCode.MobileNotSupported,\n message: 'Operation not supported on mobile',\n severity: Severity.Err,\n category: Category.DeviceState,\n userMessage: 'This operation is not supported on mobile devices.',\n },\n};\n"]}
@@ -133,6 +133,9 @@ class HardwareWalletError extends Error {
133
133
  }
134
134
  return details.join('\n');
135
135
  }
136
+ static isHardwareWalletError(error) {
137
+ return error instanceof HardwareWalletError;
138
+ }
136
139
  }
137
140
  exports.HardwareWalletError = HardwareWalletError;
138
141
  _HardwareWalletError_instances = new WeakSet(), _HardwareWalletError_getErrorPrefix = function _HardwareWalletError_getErrorPrefix() {
@@ -1 +1 @@
1
- {"version":3,"file":"hardware-error.cjs","sourceRoot":"","sources":["../src/hardware-error.ts"],"names":[],"mappings":";;;;;;;;;AACA,uEAA8D;AAE9D;;;;GAIG;AACH,SAAS,eAAe;IACtB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,yEAAyE;IACzE,MAAM,UAAU,GAAG,IAAI,CAAC,M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AgB;QACd,MAAM,OAAO,GAAG;YACd,IAAI,CAAC,QAAQ,EAAE;YACf,iBAAiB,IAAI,CAAC,WAAW,EAAE;YACnC,aAAa,IAAI,CAAC,QAAQ,EAAE;YAC5B,aAAa,IAAI,CAAC,QAAQ,EAAE;YAC5B,cAAc,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE;SAC7C,CAAC;QAEF,IAAI,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CAMF;AA3ID,kDA2IC;;IAHG,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC;AACnD,CAAC","sourcesContent":["import type { Category } from './hardware-errors-enums';\nimport { ErrorCode, Severity } from './hardware-errors-enums';\n\n/**\n * Generates a unique error ID using timestamp and random values.\n *\n * @returns A unique error ID string.\n */\nfunction generateErrorId(): string {\n const timestamp = Date.now().toString(36);\n // Random string will be formatted as: 0.fa4dmg7flr8, so we skip 0. part.\n const randomPart = Math.random().toString(36).substring(2, 9);\n return `err_${timestamp}_${randomPart}`;\n}\n\n/**\n * Gets the human-readable name for an error code using enum reverse mapping.\n *\n * @param code - The error code enum value.\n * @returns The string name of the error code, or 'Unknown' if not found.\n */\nfunction getErrorCodeName(code: ErrorCode): string {\n // Numeric enums have a reverse mapping at runtime: ErrorCode[1000] => \"AuthFailed\"\n return ErrorCode[code] ?? ErrorCode[ErrorCode.Unknown];\n}\n\nexport type HardwareWalletErrorOptions = {\n code: ErrorCode;\n severity: Severity;\n category: Category;\n userMessage: string;\n cause?: Error;\n metadata?: Record<string, unknown>;\n};\n\nexport class HardwareWalletError extends Error {\n public readonly id: string;\n\n public readonly code: ErrorCode;\n\n public readonly severity: Severity;\n\n public readonly category: Category;\n\n public readonly userMessage: string;\n\n public readonly timestamp: Date;\n\n public readonly metadata: Record<string, unknown> | undefined;\n\n public readonly cause: Error | undefined;\n\n constructor(message: string, options: HardwareWalletErrorOptions) {\n super(message);\n this.name = 'HardwareWalletError';\n this.id = generateErrorId();\n this.code = options.code;\n this.severity = options.severity;\n this.category = options.category;\n this.userMessage = options.userMessage;\n this.timestamp = new Date();\n this.metadata = options.metadata;\n this.cause = options.cause;\n }\n\n /**\n * Checks if this error is critical.\n *\n * @returns True if the error is critical, false otherwise.\n */\n isCritical(): boolean {\n return this.severity === Severity.Critical;\n }\n\n /**\n * Checks if this error is a warning.\n *\n * @returns True if the error is a warning, false otherwise.\n */\n isWarning(): boolean {\n return this.severity === Severity.Warning;\n }\n\n /**\n * Creates a new error instance with additional metadata.\n *\n * @param additionalMetadata - Additional metadata to merge with existing metadata.\n * @returns A new HardwareWalletError instance with merged metadata.\n */\n withMetadata(\n additionalMetadata: Record<string, unknown>,\n ): HardwareWalletError {\n const options: HardwareWalletErrorOptions = {\n code: this.code,\n severity: this.severity,\n category: this.category,\n userMessage: this.userMessage,\n metadata: { ...(this.metadata ?? {}), ...additionalMetadata },\n };\n\n if (this.cause !== undefined) {\n options.cause = this.cause;\n }\n\n return new HardwareWalletError(this.message, options);\n }\n\n /**\n * Serializes the error to a JSON-compatible object.\n * Note: The cause property is serialized if it exists.\n *\n * @returns A JSON-compatible object representation of the error.\n */\n toJSON(): Record<string, unknown> {\n const json: Record<string, unknown> = {\n id: this.id,\n name: this.name,\n message: this.message,\n code: this.code,\n severity: this.severity,\n category: this.category,\n userMessage: this.userMessage,\n timestamp: this.timestamp.toISOString(),\n metadata: this.metadata,\n };\n\n if (this.cause !== undefined) {\n json.cause = {\n name: this.cause.name,\n message: this.cause.message,\n };\n }\n\n return json;\n }\n\n /**\n * Returns a user-friendly string representation of the error.\n *\n * @returns A user-friendly string representation of the error.\n */\n toString(): string {\n return `${this.#getErrorPrefix()}: ${this.message}`;\n }\n\n /**\n * Returns a detailed string representation for debugging.\n *\n * @returns A detailed string representation of the error for debugging.\n */\n toDetailedString(): string {\n const details = [\n this.toString(),\n `User Message: ${this.userMessage}`,\n `Severity: ${this.severity}`,\n `Category: ${this.category}`,\n `Timestamp: ${this.timestamp.toISOString()}`,\n ];\n\n if (this.metadata && Object.keys(this.metadata).length > 0) {\n details.push(`Metadata: ${JSON.stringify(this.metadata, null, 2)}`);\n }\n\n if (this.cause !== undefined) {\n details.push(`Caused by: ${this.cause.message}`);\n }\n\n return details.join('\\n');\n }\n\n #getErrorPrefix(): string {\n const codeName = getErrorCodeName(this.code);\n return `${this.name} [${codeName}:${this.code}]`;\n }\n}\n"]}
1
+ {"version":3,"file":"hardware-error.cjs","sourceRoot":"","sources":["../src/hardware-error.ts"],"names":[],"mappings":";;;;;;;;;AACA,uEAA8D;AAE9D;;;;GAIG;AACH,SAAS,eAAe;IACtB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,yEAAyE;IACzE,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,OAAO,OAAO,SAAS,IAAI,UAAU,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,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I,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE;SAC7C,CAAC;QAEF,IAAI,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAOD,MAAM,CAAC,qBAAqB,CAAC,KAAc;QACzC,OAAO,KAAK,YAAY,mBAAmB,CAAC;IAC9C,CAAC;CACF;AA/ID,kDA+IC;;IAPG,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC;AACnD,CAAC","sourcesContent":["import type { Category } from './hardware-errors-enums';\nimport { ErrorCode, Severity } from './hardware-errors-enums';\n\n/**\n * Generates a unique error ID using timestamp and random values.\n *\n * @returns A unique error ID string.\n */\nfunction generateErrorId(): string {\n const timestamp = Date.now().toString(36);\n // Random string will be formatted as: 0.fa4dmg7flr8, so we skip 0. part.\n const randomPart = Math.random().toString(36).substring(2, 9);\n return `err_${timestamp}_${randomPart}`;\n}\n\n/**\n * Gets the human-readable name for an error code using enum reverse mapping.\n *\n * @param code - The error code enum value.\n * @returns The string name of the error code, or 'Unknown' if not found.\n */\nfunction getErrorCodeName(code: ErrorCode): string {\n // Numeric enums have a reverse mapping at runtime: ErrorCode[1000] => \"AuthFailed\"\n return ErrorCode[code] ?? ErrorCode[ErrorCode.Unknown];\n}\n\nexport type HardwareWalletErrorOptions = {\n code: ErrorCode;\n severity: Severity;\n category: Category;\n userMessage: string;\n cause?: Error;\n metadata?: Record<string, unknown>;\n};\n\nexport class HardwareWalletError extends Error {\n public readonly id: string;\n\n public readonly code: ErrorCode;\n\n public readonly severity: Severity;\n\n public readonly category: Category;\n\n public readonly userMessage: string;\n\n public readonly timestamp: Date;\n\n public readonly metadata: Record<string, unknown> | undefined;\n\n public readonly cause: Error | undefined;\n\n constructor(message: string, options: HardwareWalletErrorOptions) {\n super(message);\n this.name = 'HardwareWalletError';\n this.id = generateErrorId();\n this.code = options.code;\n this.severity = options.severity;\n this.category = options.category;\n this.userMessage = options.userMessage;\n this.timestamp = new Date();\n this.metadata = options.metadata;\n this.cause = options.cause;\n }\n\n /**\n * Checks if this error is critical.\n *\n * @returns True if the error is critical, false otherwise.\n */\n isCritical(): boolean {\n return this.severity === Severity.Critical;\n }\n\n /**\n * Checks if this error is a warning.\n *\n * @returns True if the error is a warning, false otherwise.\n */\n isWarning(): boolean {\n return this.severity === Severity.Warning;\n }\n\n /**\n * Creates a new error instance with additional metadata.\n *\n * @param additionalMetadata - Additional metadata to merge with existing metadata.\n * @returns A new HardwareWalletError instance with merged metadata.\n */\n withMetadata(\n additionalMetadata: Record<string, unknown>,\n ): HardwareWalletError {\n const options: HardwareWalletErrorOptions = {\n code: this.code,\n severity: this.severity,\n category: this.category,\n userMessage: this.userMessage,\n metadata: { ...(this.metadata ?? {}), ...additionalMetadata },\n };\n\n if (this.cause !== undefined) {\n options.cause = this.cause;\n }\n\n return new HardwareWalletError(this.message, options);\n }\n\n /**\n * Serializes the error to a JSON-compatible object.\n * Note: The cause property is serialized if it exists.\n *\n * @returns A JSON-compatible object representation of the error.\n */\n toJSON(): Record<string, unknown> {\n const json: Record<string, unknown> = {\n id: this.id,\n name: this.name,\n message: this.message,\n code: this.code,\n severity: this.severity,\n category: this.category,\n userMessage: this.userMessage,\n timestamp: this.timestamp.toISOString(),\n metadata: this.metadata,\n };\n\n if (this.cause !== undefined) {\n json.cause = {\n name: this.cause.name,\n message: this.cause.message,\n };\n }\n\n return json;\n }\n\n /**\n * Returns a user-friendly string representation of the error.\n *\n * @returns A user-friendly string representation of the error.\n */\n toString(): string {\n return `${this.#getErrorPrefix()}: ${this.message}`;\n }\n\n /**\n * Returns a detailed string representation for debugging.\n *\n * @returns A detailed string representation of the error for debugging.\n */\n toDetailedString(): string {\n const details = [\n this.toString(),\n `User Message: ${this.userMessage}`,\n `Severity: ${this.severity}`,\n `Category: ${this.category}`,\n `Timestamp: ${this.timestamp.toISOString()}`,\n ];\n\n if (this.metadata && Object.keys(this.metadata).length > 0) {\n details.push(`Metadata: ${JSON.stringify(this.metadata, null, 2)}`);\n }\n\n if (this.cause !== undefined) {\n details.push(`Caused by: ${this.cause.message}`);\n }\n\n return details.join('\\n');\n }\n\n #getErrorPrefix(): string {\n const codeName = getErrorCodeName(this.code);\n return `${this.name} [${codeName}:${this.code}]`;\n }\n\n static isHardwareWalletError(error: unknown): error is HardwareWalletError {\n return error instanceof HardwareWalletError;\n }\n}\n"]}
@@ -57,5 +57,6 @@ export declare class HardwareWalletError extends Error {
57
57
  * @returns A detailed string representation of the error for debugging.
58
58
  */
59
59
  toDetailedString(): string;
60
+ static isHardwareWalletError(error: unknown): error is HardwareWalletError;
60
61
  }
61
62
  //# sourceMappingURL=hardware-error.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hardware-error.d.cts","sourceRoot":"","sources":["../src/hardware-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,oCAAgC;AACxD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,oCAAgC;AAyB9D,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,C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,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,KAAK;;IAC5C,SAAgB,EAAE,EAAE,MAAM,CAAC;IAE3B,SAAgB,IAAI,EAAE,SAAS,CAAC;IAEhC,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC,SAAgB,SAAS,EAAE,IAAI,CAAC;IAEhC,SAAgB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAE9D,SAAgB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;gBAE7B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,0BAA0B;IAahE;;;;OAIG;IACH,UAAU,IAAI,OAAO;IAIrB;;;;OAIG;IACH,SAAS,IAAI,OAAO;IAIpB;;;;;OAKG;IACH,YAAY,CACV,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC1C,mBAAmB;IAgBtB;;;;;OAKG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAuBjC;;;;OAIG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,gBAAgB,IAAI,MAAM;IAyB1B,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB;CAG3E"}
@@ -57,5 +57,6 @@ export declare class HardwareWalletError extends Error {
57
57
  * @returns A detailed string representation of the error for debugging.
58
58
  */
59
59
  toDetailedString(): string;
60
+ static isHardwareWalletError(error: unknown): error is HardwareWalletError;
60
61
  }
61
62
  //# sourceMappingURL=hardware-error.d.mts.map
@@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;OAIG;IACH,gBAAgB,IAAI,MAAM;IAyB1B,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB;CAG3E"}
@@ -130,6 +130,9 @@ export class HardwareWalletError extends Error {
130
130
  }
131
131
  return details.join('\n');
132
132
  }
133
+ static isHardwareWalletError(error) {
134
+ return error instanceof HardwareWalletError;
135
+ }
133
136
  }
134
137
  _HardwareWalletError_instances = new WeakSet(), _HardwareWalletError_getErrorPrefix = function _HardwareWalletError_getErrorPrefix() {
135
138
  const codeName = getErrorCodeName(this.code);
@@ -1 +1 @@
1
- {"version":3,"file":"hardware-error.mjs","sourceRoot":"","sources":["../src/hardware-error.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,oCAAgC;AAE9D;;;;GAIG;AACH,SAAS,eAAe;IACtB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,yEAAyE;IACzE,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,OAAO,OAAO,SAAS,IAAI,UAAU,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,IAAe;IACvC,mFAAmF;IACnF,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACzD,CAAC;AAWD,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAiB5C,YAAY,OAAe,EAAE,OAAmC;QAC9D,KAAK,CAAC,OAAO,CAAC,CAAC;;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,EAAE,GAAG,eAAe,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,OAAO,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AAC;YAC7B,OAAO,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CAMF;;IAHG,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC;AACnD,CAAC","sourcesContent":["import type { Category } from './hardware-errors-enums';\nimport { ErrorCode, Severity } from './hardware-errors-enums';\n\n/**\n * Generates a unique error ID using timestamp and random values.\n *\n * @returns A unique error ID string.\n */\nfunction generateErrorId(): string {\n const timestamp = Date.now().toString(36);\n // Random string will be formatted as: 0.fa4dmg7flr8, so we skip 0. part.\n const randomPart = Math.random().toString(36).substring(2, 9);\n return `err_${timestamp}_${randomPart}`;\n}\n\n/**\n * Gets the human-readable name for an error code using enum reverse mapping.\n *\n * @param code - The error code enum value.\n * @returns The string name of the error code, or 'Unknown' if not found.\n */\nfunction getErrorCodeName(code: ErrorCode): string {\n // Numeric enums have a reverse mapping at runtime: ErrorCode[1000] => \"AuthFailed\"\n return ErrorCode[code] ?? ErrorCode[ErrorCode.Unknown];\n}\n\nexport type HardwareWalletErrorOptions = {\n code: ErrorCode;\n severity: Severity;\n category: Category;\n userMessage: string;\n cause?: Error;\n metadata?: Record<string, unknown>;\n};\n\nexport class HardwareWalletError extends Error {\n public readonly id: string;\n\n public readonly code: ErrorCode;\n\n public readonly severity: Severity;\n\n public readonly category: Category;\n\n public readonly userMessage: string;\n\n public readonly timestamp: Date;\n\n public readonly metadata: Record<string, unknown> | undefined;\n\n public readonly cause: Error | undefined;\n\n constructor(message: string, options: HardwareWalletErrorOptions) {\n super(message);\n this.name = 'HardwareWalletError';\n this.id = generateErrorId();\n this.code = options.code;\n this.severity = options.severity;\n this.category = options.category;\n this.userMessage = options.userMessage;\n this.timestamp = new Date();\n this.metadata = options.metadata;\n this.cause = options.cause;\n }\n\n /**\n * Checks if this error is critical.\n *\n * @returns True if the error is critical, false otherwise.\n */\n isCritical(): boolean {\n return this.severity === Severity.Critical;\n }\n\n /**\n * Checks if this error is a warning.\n *\n * @returns True if the error is a warning, false otherwise.\n */\n isWarning(): boolean {\n return this.severity === Severity.Warning;\n }\n\n /**\n * Creates a new error instance with additional metadata.\n *\n * @param additionalMetadata - Additional metadata to merge with existing metadata.\n * @returns A new HardwareWalletError instance with merged metadata.\n */\n withMetadata(\n additionalMetadata: Record<string, unknown>,\n ): HardwareWalletError {\n const options: HardwareWalletErrorOptions = {\n code: this.code,\n severity: this.severity,\n category: this.category,\n userMessage: this.userMessage,\n metadata: { ...(this.metadata ?? {}), ...additionalMetadata },\n };\n\n if (this.cause !== undefined) {\n options.cause = this.cause;\n }\n\n return new HardwareWalletError(this.message, options);\n }\n\n /**\n * Serializes the error to a JSON-compatible object.\n * Note: The cause property is serialized if it exists.\n *\n * @returns A JSON-compatible object representation of the error.\n */\n toJSON(): Record<string, unknown> {\n const json: Record<string, unknown> = {\n id: this.id,\n name: this.name,\n message: this.message,\n code: this.code,\n severity: this.severity,\n category: this.category,\n userMessage: this.userMessage,\n timestamp: this.timestamp.toISOString(),\n metadata: this.metadata,\n };\n\n if (this.cause !== undefined) {\n json.cause = {\n name: this.cause.name,\n message: this.cause.message,\n };\n }\n\n return json;\n }\n\n /**\n * Returns a user-friendly string representation of the error.\n *\n * @returns A user-friendly string representation of the error.\n */\n toString(): string {\n return `${this.#getErrorPrefix()}: ${this.message}`;\n }\n\n /**\n * Returns a detailed string representation for debugging.\n *\n * @returns A detailed string representation of the error for debugging.\n */\n toDetailedString(): string {\n const details = [\n this.toString(),\n `User Message: ${this.userMessage}`,\n `Severity: ${this.severity}`,\n `Category: ${this.category}`,\n `Timestamp: ${this.timestamp.toISOString()}`,\n ];\n\n if (this.metadata && Object.keys(this.metadata).length > 0) {\n details.push(`Metadata: ${JSON.stringify(this.metadata, null, 2)}`);\n }\n\n if (this.cause !== undefined) {\n details.push(`Caused by: ${this.cause.message}`);\n }\n\n return details.join('\\n');\n }\n\n #getErrorPrefix(): string {\n const codeName = getErrorCodeName(this.code);\n return `${this.name} [${codeName}:${this.code}]`;\n }\n}\n"]}
1
+ {"version":3,"file":"hardware-error.mjs","sourceRoot":"","sources":["../src/hardware-error.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,oCAAgC;AAE9D;;;;GAIG;AACH,SAAS,eAAe;IACtB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,yEAAyE;IACzE,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,OAAO,OAAO,SAAS,IAAI,UAAU,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,IAAe;IACvC,mFAAmF;IACnF,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACzD,CAAC;AAWD,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAiB5C,YAAY,OAAe,EAAE,OAAmC;QAC9D,KAAK,CAAC,OAAO,CAAC,CAAC;;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,EAAE,GAAG,eAAe,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,OAAO,CA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AOD,MAAM,CAAC,qBAAqB,CAAC,KAAc;QACzC,OAAO,KAAK,YAAY,mBAAmB,CAAC;IAC9C,CAAC;CACF;;IAPG,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC;AACnD,CAAC","sourcesContent":["import type { Category } from './hardware-errors-enums';\nimport { ErrorCode, Severity } from './hardware-errors-enums';\n\n/**\n * Generates a unique error ID using timestamp and random values.\n *\n * @returns A unique error ID string.\n */\nfunction generateErrorId(): string {\n const timestamp = Date.now().toString(36);\n // Random string will be formatted as: 0.fa4dmg7flr8, so we skip 0. part.\n const randomPart = Math.random().toString(36).substring(2, 9);\n return `err_${timestamp}_${randomPart}`;\n}\n\n/**\n * Gets the human-readable name for an error code using enum reverse mapping.\n *\n * @param code - The error code enum value.\n * @returns The string name of the error code, or 'Unknown' if not found.\n */\nfunction getErrorCodeName(code: ErrorCode): string {\n // Numeric enums have a reverse mapping at runtime: ErrorCode[1000] => \"AuthFailed\"\n return ErrorCode[code] ?? ErrorCode[ErrorCode.Unknown];\n}\n\nexport type HardwareWalletErrorOptions = {\n code: ErrorCode;\n severity: Severity;\n category: Category;\n userMessage: string;\n cause?: Error;\n metadata?: Record<string, unknown>;\n};\n\nexport class HardwareWalletError extends Error {\n public readonly id: string;\n\n public readonly code: ErrorCode;\n\n public readonly severity: Severity;\n\n public readonly category: Category;\n\n public readonly userMessage: string;\n\n public readonly timestamp: Date;\n\n public readonly metadata: Record<string, unknown> | undefined;\n\n public readonly cause: Error | undefined;\n\n constructor(message: string, options: HardwareWalletErrorOptions) {\n super(message);\n this.name = 'HardwareWalletError';\n this.id = generateErrorId();\n this.code = options.code;\n this.severity = options.severity;\n this.category = options.category;\n this.userMessage = options.userMessage;\n this.timestamp = new Date();\n this.metadata = options.metadata;\n this.cause = options.cause;\n }\n\n /**\n * Checks if this error is critical.\n *\n * @returns True if the error is critical, false otherwise.\n */\n isCritical(): boolean {\n return this.severity === Severity.Critical;\n }\n\n /**\n * Checks if this error is a warning.\n *\n * @returns True if the error is a warning, false otherwise.\n */\n isWarning(): boolean {\n return this.severity === Severity.Warning;\n }\n\n /**\n * Creates a new error instance with additional metadata.\n *\n * @param additionalMetadata - Additional metadata to merge with existing metadata.\n * @returns A new HardwareWalletError instance with merged metadata.\n */\n withMetadata(\n additionalMetadata: Record<string, unknown>,\n ): HardwareWalletError {\n const options: HardwareWalletErrorOptions = {\n code: this.code,\n severity: this.severity,\n category: this.category,\n userMessage: this.userMessage,\n metadata: { ...(this.metadata ?? {}), ...additionalMetadata },\n };\n\n if (this.cause !== undefined) {\n options.cause = this.cause;\n }\n\n return new HardwareWalletError(this.message, options);\n }\n\n /**\n * Serializes the error to a JSON-compatible object.\n * Note: The cause property is serialized if it exists.\n *\n * @returns A JSON-compatible object representation of the error.\n */\n toJSON(): Record<string, unknown> {\n const json: Record<string, unknown> = {\n id: this.id,\n name: this.name,\n message: this.message,\n code: this.code,\n severity: this.severity,\n category: this.category,\n userMessage: this.userMessage,\n timestamp: this.timestamp.toISOString(),\n metadata: this.metadata,\n };\n\n if (this.cause !== undefined) {\n json.cause = {\n name: this.cause.name,\n message: this.cause.message,\n };\n }\n\n return json;\n }\n\n /**\n * Returns a user-friendly string representation of the error.\n *\n * @returns A user-friendly string representation of the error.\n */\n toString(): string {\n return `${this.#getErrorPrefix()}: ${this.message}`;\n }\n\n /**\n * Returns a detailed string representation for debugging.\n *\n * @returns A detailed string representation of the error for debugging.\n */\n toDetailedString(): string {\n const details = [\n this.toString(),\n `User Message: ${this.userMessage}`,\n `Severity: ${this.severity}`,\n `Category: ${this.category}`,\n `Timestamp: ${this.timestamp.toISOString()}`,\n ];\n\n if (this.metadata && Object.keys(this.metadata).length > 0) {\n details.push(`Metadata: ${JSON.stringify(this.metadata, null, 2)}`);\n }\n\n if (this.cause !== undefined) {\n details.push(`Caused by: ${this.cause.message}`);\n }\n\n return details.join('\\n');\n }\n\n #getErrorPrefix(): string {\n const codeName = getErrorCodeName(this.code);\n return `${this.name} [${codeName}:${this.code}]`;\n }\n\n static isHardwareWalletError(error: unknown): error is HardwareWalletError {\n return error instanceof HardwareWalletError;\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./hardware-errors-enums.cjs"), exports);
18
18
  __exportStar(require("./hardware-error-mappings.cjs"), exports);
19
19
  __exportStar(require("./hardware-error.cjs"), exports);
20
+ __exportStar(require("./types.cjs"), exports);
20
21
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAAwC;AACxC,gEAA0C;AAC1C,uDAAiC","sourcesContent":["export * from './hardware-errors-enums';\nexport * from './hardware-error-mappings';\nexport * from './hardware-error';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAAwC;AACxC,gEAA0C;AAC1C,uDAAiC;AACjC,8CAAwB","sourcesContent":["export * from './hardware-errors-enums';\nexport * from './hardware-error-mappings';\nexport * from './hardware-error';\nexport * from './types';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./hardware-errors-enums.cjs";
2
2
  export * from "./hardware-error-mappings.cjs";
3
3
  export * from "./hardware-error.cjs";
4
+ export * from "./types.cjs";
4
5
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAAwC;AACxC,8CAA0C;AAC1C,qCAAiC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAAwC;AACxC,8CAA0C;AAC1C,qCAAiC;AACjC,4BAAwB"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./hardware-errors-enums.mjs";
2
2
  export * from "./hardware-error-mappings.mjs";
3
3
  export * from "./hardware-error.mjs";
4
+ export * from "./types.mjs";
4
5
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAAwC;AACxC,8CAA0C;AAC1C,qCAAiC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAAwC;AACxC,8CAA0C;AAC1C,qCAAiC;AACjC,4BAAwB"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./hardware-errors-enums.mjs";
2
2
  export * from "./hardware-error-mappings.mjs";
3
3
  export * from "./hardware-error.mjs";
4
+ export * from "./types.mjs";
4
5
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAAwC;AACxC,8CAA0C;AAC1C,qCAAiC","sourcesContent":["export * from './hardware-errors-enums';\nexport * from './hardware-error-mappings';\nexport * from './hardware-error';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAAwC;AACxC,8CAA0C;AAC1C,qCAAiC;AACjC,4BAAwB","sourcesContent":["export * from './hardware-errors-enums';\nexport * from './hardware-error-mappings';\nexport * from './hardware-error';\nexport * from './types';\n"]}
package/dist/types.cjs ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ // istanbul ignore file
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DeviceEvent = exports.ConnectionStatus = exports.HardwareWalletType = void 0;
5
+ var HardwareWalletType;
6
+ (function (HardwareWalletType) {
7
+ HardwareWalletType["Ledger"] = "ledger";
8
+ HardwareWalletType["Trezor"] = "trezor";
9
+ HardwareWalletType["OneKey"] = "onekey";
10
+ HardwareWalletType["Lattice"] = "lattice";
11
+ HardwareWalletType["Qr"] = "qr";
12
+ HardwareWalletType["Unknown"] = "unknown";
13
+ })(HardwareWalletType || (exports.HardwareWalletType = HardwareWalletType = {}));
14
+ var ConnectionStatus;
15
+ (function (ConnectionStatus) {
16
+ ConnectionStatus["Disconnected"] = "disconnected";
17
+ ConnectionStatus["Scanning"] = "scanning";
18
+ ConnectionStatus["Connecting"] = "connecting";
19
+ ConnectionStatus["Connected"] = "connected";
20
+ ConnectionStatus["Ready"] = "ready";
21
+ ConnectionStatus["AwaitingApp"] = "awaiting_app";
22
+ ConnectionStatus["AwaitingConfirmation"] = "awaiting_confirmation";
23
+ ConnectionStatus["ErrorState"] = "error";
24
+ })(ConnectionStatus || (exports.ConnectionStatus = ConnectionStatus = {}));
25
+ var DeviceEvent;
26
+ (function (DeviceEvent) {
27
+ DeviceEvent["Connected"] = "connected";
28
+ DeviceEvent["Disconnected"] = "disconnected";
29
+ DeviceEvent["ConnectionFailed"] = "connection_failed";
30
+ DeviceEvent["DeviceLocked"] = "device_locked";
31
+ DeviceEvent["AppOpened"] = "app_opened";
32
+ DeviceEvent["AppNotOpen"] = "app_not_open";
33
+ DeviceEvent["AppChanged"] = "app_changed";
34
+ DeviceEvent["ConfirmationRequired"] = "confirmation_required";
35
+ DeviceEvent["ConfirmationReceived"] = "confirmation_received";
36
+ DeviceEvent["ConfirmationRejected"] = "confirmation_rejected";
37
+ DeviceEvent["OperationTimeout"] = "operation_timeout";
38
+ DeviceEvent["PermissionChanged"] = "permission_changed";
39
+ })(DeviceEvent || (exports.DeviceEvent = DeviceEvent = {}));
40
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,uBAAuB;;;AAIvB,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,yCAAmB,CAAA;IACnB,+BAAS,CAAA;IACT,yCAAmB,CAAA;AACrB,CAAC,EAPW,kBAAkB,kCAAlB,kBAAkB,QAO7B;AAED,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,2CAAuB,CAAA;IACvB,mCAAe,CAAA;IACf,gDAA4B,CAAA;IAC5B,kEAA8C,CAAA;IAC9C,wCAAoB,CAAA;AACtB,CAAC,EATW,gBAAgB,gCAAhB,gBAAgB,QAS3B;AAED,IAAY,WAaX;AAbD,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,4CAA6B,CAAA;IAC7B,qDAAsC,CAAA;IACtC,6CAA8B,CAAA;IAC9B,uCAAwB,CAAA;IACxB,0CAA2B,CAAA;IAC3B,yCAA0B,CAAA;IAC1B,6DAA8C,CAAA;IAC9C,6DAA8C,CAAA;IAC9C,6DAA8C,CAAA;IAC9C,qDAAsC,CAAA;IACtC,uDAAwC,CAAA;AAC1C,CAAC,EAbW,WAAW,2BAAX,WAAW,QAatB","sourcesContent":["// istanbul ignore file\n\nimport { type HardwareWalletError } from './hardware-error';\n\nexport enum HardwareWalletType {\n Ledger = 'ledger',\n Trezor = 'trezor',\n OneKey = 'onekey',\n Lattice = 'lattice',\n Qr = 'qr',\n Unknown = 'unknown',\n}\n\nexport enum ConnectionStatus {\n Disconnected = 'disconnected',\n Scanning = 'scanning',\n Connecting = 'connecting',\n Connected = 'connected',\n Ready = 'ready',\n AwaitingApp = 'awaiting_app',\n AwaitingConfirmation = 'awaiting_confirmation',\n ErrorState = 'error',\n}\n\nexport enum DeviceEvent {\n Connected = 'connected',\n Disconnected = 'disconnected',\n ConnectionFailed = 'connection_failed',\n DeviceLocked = 'device_locked',\n AppOpened = 'app_opened',\n AppNotOpen = 'app_not_open',\n AppChanged = 'app_changed',\n ConfirmationRequired = 'confirmation_required',\n ConfirmationReceived = 'confirmation_received',\n ConfirmationRejected = 'confirmation_rejected',\n OperationTimeout = 'operation_timeout',\n PermissionChanged = 'permission_changed',\n}\n\nexport type HardwareWalletConnectionState =\n | { status: ConnectionStatus.Disconnected }\n | { status: ConnectionStatus.Scanning }\n | { status: ConnectionStatus.Connecting; deviceId?: string }\n | { status: ConnectionStatus.Connected; deviceId: string }\n | { status: ConnectionStatus.Ready; deviceId?: string }\n | { status: ConnectionStatus.AwaitingApp; deviceId: string; appName?: string }\n | {\n status: ConnectionStatus.AwaitingConfirmation;\n deviceId: string;\n operationType?: string;\n }\n | { status: ConnectionStatus.ErrorState; error: HardwareWalletError };\n\nexport type DeviceEventPayload = {\n event: DeviceEvent;\n deviceId?: string;\n deviceName?: string;\n currentAppName?: string;\n previousAppName?: string;\n error?: Error;\n metadata?: Record<string, unknown>;\n};\n"]}
@@ -0,0 +1,68 @@
1
+ import { type HardwareWalletError } from "./hardware-error.cjs";
2
+ export declare enum HardwareWalletType {
3
+ Ledger = "ledger",
4
+ Trezor = "trezor",
5
+ OneKey = "onekey",
6
+ Lattice = "lattice",
7
+ Qr = "qr",
8
+ Unknown = "unknown"
9
+ }
10
+ export declare enum ConnectionStatus {
11
+ Disconnected = "disconnected",
12
+ Scanning = "scanning",
13
+ Connecting = "connecting",
14
+ Connected = "connected",
15
+ Ready = "ready",
16
+ AwaitingApp = "awaiting_app",
17
+ AwaitingConfirmation = "awaiting_confirmation",
18
+ ErrorState = "error"
19
+ }
20
+ export declare enum DeviceEvent {
21
+ Connected = "connected",
22
+ Disconnected = "disconnected",
23
+ ConnectionFailed = "connection_failed",
24
+ DeviceLocked = "device_locked",
25
+ AppOpened = "app_opened",
26
+ AppNotOpen = "app_not_open",
27
+ AppChanged = "app_changed",
28
+ ConfirmationRequired = "confirmation_required",
29
+ ConfirmationReceived = "confirmation_received",
30
+ ConfirmationRejected = "confirmation_rejected",
31
+ OperationTimeout = "operation_timeout",
32
+ PermissionChanged = "permission_changed"
33
+ }
34
+ export type HardwareWalletConnectionState = {
35
+ status: ConnectionStatus.Disconnected;
36
+ } | {
37
+ status: ConnectionStatus.Scanning;
38
+ } | {
39
+ status: ConnectionStatus.Connecting;
40
+ deviceId?: string;
41
+ } | {
42
+ status: ConnectionStatus.Connected;
43
+ deviceId: string;
44
+ } | {
45
+ status: ConnectionStatus.Ready;
46
+ deviceId?: string;
47
+ } | {
48
+ status: ConnectionStatus.AwaitingApp;
49
+ deviceId: string;
50
+ appName?: string;
51
+ } | {
52
+ status: ConnectionStatus.AwaitingConfirmation;
53
+ deviceId: string;
54
+ operationType?: string;
55
+ } | {
56
+ status: ConnectionStatus.ErrorState;
57
+ error: HardwareWalletError;
58
+ };
59
+ export type DeviceEventPayload = {
60
+ event: DeviceEvent;
61
+ deviceId?: string;
62
+ deviceName?: string;
63
+ currentAppName?: string;
64
+ previousAppName?: string;
65
+ error?: Error;
66
+ metadata?: Record<string, unknown>;
67
+ };
68
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,mBAAmB,EAAE,6BAAyB;AAE5D,oBAAY,kBAAkB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,EAAE,OAAO;IACT,OAAO,YAAY;CACpB;AAED,oBAAY,gBAAgB;IAC1B,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,WAAW,iBAAiB;IAC5B,oBAAoB,0BAA0B;IAC9C,UAAU,UAAU;CACrB;AAED,oBAAY,WAAW;IACrB,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,gBAAgB,sBAAsB;IAC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AE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { type HardwareWalletError } from "./hardware-error.mjs";
2
+ export declare enum HardwareWalletType {
3
+ Ledger = "ledger",
4
+ Trezor = "trezor",
5
+ OneKey = "onekey",
6
+ Lattice = "lattice",
7
+ Qr = "qr",
8
+ Unknown = "unknown"
9
+ }
10
+ export declare enum ConnectionStatus {
11
+ Disconnected = "disconnected",
12
+ Scanning = "scanning",
13
+ Connecting = "connecting",
14
+ Connected = "connected",
15
+ Ready = "ready",
16
+ AwaitingApp = "awaiting_app",
17
+ AwaitingConfirmation = "awaiting_confirmation",
18
+ ErrorState = "error"
19
+ }
20
+ export declare enum DeviceEvent {
21
+ Connected = "connected",
22
+ Disconnected = "disconnected",
23
+ ConnectionFailed = "connection_failed",
24
+ DeviceLocked = "device_locked",
25
+ AppOpened = "app_opened",
26
+ AppNotOpen = "app_not_open",
27
+ AppChanged = "app_changed",
28
+ ConfirmationRequired = "confirmation_required",
29
+ ConfirmationReceived = "confirmation_received",
30
+ ConfirmationRejected = "confirmation_rejected",
31
+ OperationTimeout = "operation_timeout",
32
+ PermissionChanged = "permission_changed"
33
+ }
34
+ export type HardwareWalletConnectionState = {
35
+ status: ConnectionStatus.Disconnected;
36
+ } | {
37
+ status: ConnectionStatus.Scanning;
38
+ } | {
39
+ status: ConnectionStatus.Connecting;
40
+ deviceId?: string;
41
+ } | {
42
+ status: ConnectionStatus.Connected;
43
+ deviceId: string;
44
+ } | {
45
+ status: ConnectionStatus.Ready;
46
+ deviceId?: string;
47
+ } | {
48
+ status: ConnectionStatus.AwaitingApp;
49
+ deviceId: string;
50
+ appName?: string;
51
+ } | {
52
+ status: ConnectionStatus.AwaitingConfirmation;
53
+ deviceId: string;
54
+ operationType?: string;
55
+ } | {
56
+ status: ConnectionStatus.ErrorState;
57
+ error: HardwareWalletError;
58
+ };
59
+ export type DeviceEventPayload = {
60
+ event: DeviceEvent;
61
+ deviceId?: string;
62
+ deviceName?: string;
63
+ currentAppName?: string;
64
+ previousAppName?: string;
65
+ error?: Error;
66
+ metadata?: Record<string, unknown>;
67
+ };
68
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,mBAAmB,EAAE,6BAAyB;AAE5D,oBAAY,kBAAkB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,EAAE,OAAO;IACT,OAAO,YAAY;CACpB;AAED,oBAAY,gBAAgB;IAC1B,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,WAAW,iBAAiB;IAC5B,oBAAoB,0BAA0B;IAC9C,UAAU,UAAU;CACrB;AAED,oBAAY,WAAW;IACrB,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,gBAAgB,sBAAsB;IACtC,YAAY,kBAAkB;IAC9B,SAAS,eAAe;IACxB,UAAU,iBAAiB;IAC3B,UAAU,gBAAgB;IAC1B,oBAAoB,0BAA0B;IAC9C,oBAAoB,0BAA0B;IAC9C,oBAAoB,0BAA0B;IAC9C,gBAAgB,sBAAsB;IACtC,iBAAiB,uBAAuB;CACzC;AAED,MAAM,MAAM,6BAA6B,GACrC;IAAE,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAA;CAAE,GACzC;IAAE,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAA;CAAE,GACrC;IAAE,MAAM,EAAE,gBAAgB,CAAC,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,MAAM,EAAE,gBAAgB,CAAC,WAAW,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5E;IACE,MAAM,EAAE,gBAAgB,CAAC,oBAAoB,CAAC;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,MAAM,EAAE,gBAAgB,CAAC,UAAU,CAAC;IAAC,KAAK,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC"}
package/dist/types.mjs ADDED
@@ -0,0 +1,37 @@
1
+ // istanbul ignore file
2
+ export var HardwareWalletType;
3
+ (function (HardwareWalletType) {
4
+ HardwareWalletType["Ledger"] = "ledger";
5
+ HardwareWalletType["Trezor"] = "trezor";
6
+ HardwareWalletType["OneKey"] = "onekey";
7
+ HardwareWalletType["Lattice"] = "lattice";
8
+ HardwareWalletType["Qr"] = "qr";
9
+ HardwareWalletType["Unknown"] = "unknown";
10
+ })(HardwareWalletType || (HardwareWalletType = {}));
11
+ export var ConnectionStatus;
12
+ (function (ConnectionStatus) {
13
+ ConnectionStatus["Disconnected"] = "disconnected";
14
+ ConnectionStatus["Scanning"] = "scanning";
15
+ ConnectionStatus["Connecting"] = "connecting";
16
+ ConnectionStatus["Connected"] = "connected";
17
+ ConnectionStatus["Ready"] = "ready";
18
+ ConnectionStatus["AwaitingApp"] = "awaiting_app";
19
+ ConnectionStatus["AwaitingConfirmation"] = "awaiting_confirmation";
20
+ ConnectionStatus["ErrorState"] = "error";
21
+ })(ConnectionStatus || (ConnectionStatus = {}));
22
+ export var DeviceEvent;
23
+ (function (DeviceEvent) {
24
+ DeviceEvent["Connected"] = "connected";
25
+ DeviceEvent["Disconnected"] = "disconnected";
26
+ DeviceEvent["ConnectionFailed"] = "connection_failed";
27
+ DeviceEvent["DeviceLocked"] = "device_locked";
28
+ DeviceEvent["AppOpened"] = "app_opened";
29
+ DeviceEvent["AppNotOpen"] = "app_not_open";
30
+ DeviceEvent["AppChanged"] = "app_changed";
31
+ DeviceEvent["ConfirmationRequired"] = "confirmation_required";
32
+ DeviceEvent["ConfirmationReceived"] = "confirmation_received";
33
+ DeviceEvent["ConfirmationRejected"] = "confirmation_rejected";
34
+ DeviceEvent["OperationTimeout"] = "operation_timeout";
35
+ DeviceEvent["PermissionChanged"] = "permission_changed";
36
+ })(DeviceEvent || (DeviceEvent = {}));
37
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,uBAAuB;AAIvB,MAAM,CAAN,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,yCAAmB,CAAA;IACnB,+BAAS,CAAA;IACT,yCAAmB,CAAA;AACrB,CAAC,EAPW,kBAAkB,KAAlB,kBAAkB,QAO7B;AAED,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,2CAAuB,CAAA;IACvB,mCAAe,CAAA;IACf,gDAA4B,CAAA;IAC5B,kEAA8C,CAAA;IAC9C,wCAAoB,CAAA;AACtB,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;AAED,MAAM,CAAN,IAAY,WAaX;AAbD,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,4CAA6B,CAAA;IAC7B,qDAAsC,CAAA;IACtC,6CAA8B,CAAA;IAC9B,uCAAwB,CAAA;IACxB,0CAA2B,CAAA;IAC3B,yCAA0B,CAAA;IAC1B,6DAA8C,CAAA;IAC9C,6DAA8C,CAAA;IAC9C,6DAA8C,CAAA;IAC9C,qDAAsC,CAAA;IACtC,uDAAwC,CAAA;AAC1C,CAAC,EAbW,WAAW,KAAX,WAAW,QAatB","sourcesContent":["// istanbul ignore file\n\nimport { type HardwareWalletError } from './hardware-error';\n\nexport enum HardwareWalletType {\n Ledger = 'ledger',\n Trezor = 'trezor',\n OneKey = 'onekey',\n Lattice = 'lattice',\n Qr = 'qr',\n Unknown = 'unknown',\n}\n\nexport enum ConnectionStatus {\n Disconnected = 'disconnected',\n Scanning = 'scanning',\n Connecting = 'connecting',\n Connected = 'connected',\n Ready = 'ready',\n AwaitingApp = 'awaiting_app',\n AwaitingConfirmation = 'awaiting_confirmation',\n ErrorState = 'error',\n}\n\nexport enum DeviceEvent {\n Connected = 'connected',\n Disconnected = 'disconnected',\n ConnectionFailed = 'connection_failed',\n DeviceLocked = 'device_locked',\n AppOpened = 'app_opened',\n AppNotOpen = 'app_not_open',\n AppChanged = 'app_changed',\n ConfirmationRequired = 'confirmation_required',\n ConfirmationReceived = 'confirmation_received',\n ConfirmationRejected = 'confirmation_rejected',\n OperationTimeout = 'operation_timeout',\n PermissionChanged = 'permission_changed',\n}\n\nexport type HardwareWalletConnectionState =\n | { status: ConnectionStatus.Disconnected }\n | { status: ConnectionStatus.Scanning }\n | { status: ConnectionStatus.Connecting; deviceId?: string }\n | { status: ConnectionStatus.Connected; deviceId: string }\n | { status: ConnectionStatus.Ready; deviceId?: string }\n | { status: ConnectionStatus.AwaitingApp; deviceId: string; appName?: string }\n | {\n status: ConnectionStatus.AwaitingConfirmation;\n deviceId: string;\n operationType?: string;\n }\n | { status: ConnectionStatus.ErrorState; error: HardwareWalletError };\n\nexport type DeviceEventPayload = {\n event: DeviceEvent;\n deviceId?: string;\n deviceName?: string;\n currentAppName?: string;\n previousAppName?: string;\n error?: Error;\n metadata?: Record<string, unknown>;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/hw-wallet-sdk",
3
- "version": "0.2.0-412b185",
3
+ "version": "0.5.0-fd40efd",
4
4
  "description": "MetaMask Hardware Device SDK",
5
5
  "keywords": [
6
6
  "metamask",