Socket
Socket
Sign inDemoInstall

@onekeyfe/hd-shared

Package Overview
Dependencies
0
Maintainers
2
Versions
190
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.27 to 0.1.28

6

dist/HardwareError.d.ts
export interface IHardwareError {
errorCode: ValueOf<typeof HardwareErrorCode>;
message?: string;
params?: any;
}

@@ -13,2 +14,3 @@ declare type ValueOf<P extends object> = P[keyof P];

message: string;
params: any;
constructor(hardwareError: IHardwareError | string);

@@ -39,2 +41,4 @@ }

readonly FirmwareUpdateDownloadFailed: 406;
readonly CallMethodNeedUpgradeFirmware: 407;
readonly CallMethodDeprecated: 408;
readonly NetworkError: 500;

@@ -69,3 +73,3 @@ readonly TransportNotConfigured: 600;

export declare const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping;
export declare const TypedError: (hardwareError: ErrorCodeUnion | string, message?: string | undefined) => HardwareError;
export declare const TypedError: (hardwareError: ErrorCodeUnion | string, message?: string | undefined, params?: any) => HardwareError;
export declare const serializeError: (payload: any) => any;

@@ -72,0 +76,0 @@ export declare const CreateErrorByMessage: (message: string) => HardwareError;

@@ -13,2 +13,3 @@ declare type Deferred<T, I = any, D = any> = {

message?: string;
params?: any;
}

@@ -23,2 +24,3 @@ declare type ValueOf<P extends object> = P[keyof P];

message: string;
params: any;
constructor(hardwareError: IHardwareError | string);

@@ -49,2 +51,4 @@ }

readonly FirmwareUpdateDownloadFailed: 406;
readonly CallMethodNeedUpgradeFirmware: 407;
readonly CallMethodDeprecated: 408;
readonly NetworkError: 500;

@@ -79,3 +83,3 @@ readonly TransportNotConfigured: 600;

declare const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping;
declare const TypedError: (hardwareError: ErrorCodeUnion | string, message?: string | undefined) => HardwareError;
declare const TypedError: (hardwareError: ErrorCodeUnion | string, message?: string | undefined, params?: any) => HardwareError;
declare const serializeError: (payload: any) => any;

@@ -82,0 +86,0 @@ declare const CreateErrorByMessage: (message: string) => HardwareError;

@@ -68,2 +68,3 @@ 'use strict';

this.message = '';
this.params = {};
const errorMessageMapping = HardwareErrorCodeMessage;

@@ -80,2 +81,3 @@ this.message = errorMessageMapping[HardwareErrorCode.UnknownError];

}
this.params = hardwareError.params;
this.errorCode = hardwareError.errorCode;

@@ -109,2 +111,4 @@ }

FirmwareUpdateDownloadFailed: 406,
CallMethodNeedUpgradeFirmware: 407,
CallMethodDeprecated: 408,
NetworkError: 500,

@@ -161,2 +165,4 @@ TransportNotConfigured: 600,

[HardwareErrorCode.FirmwareUpdateDownloadFailed]: 'Firmware update download failed',
[HardwareErrorCode.CallMethodNeedUpgradeFirmware]: 'Call method need upgrade firmware',
[HardwareErrorCode.CallMethodDeprecated]: 'Call method is deprecated',
[HardwareErrorCode.NetworkError]: 'Network request error',

@@ -190,11 +196,15 @@ [HardwareErrorCode.TransportNotConfigured]: 'Transport not configured',

};
const TypedError = (hardwareError, message) => {
const TypedError = (hardwareError, message, params) => {
if (typeof hardwareError === 'string') {
return new HardwareError(hardwareError);
}
return new HardwareError({ errorCode: hardwareError, message: message !== null && message !== void 0 ? message : '' });
return new HardwareError({ errorCode: hardwareError, message: message !== null && message !== void 0 ? message : '', params });
};
const serializeError = (payload) => {
if (payload && payload.error instanceof HardwareError) {
return { error: payload.error.message, code: payload.error.errorCode };
return {
error: payload.error.message,
code: payload.error.errorCode,
params: payload.error.params,
};
}

@@ -201,0 +211,0 @@ if (payload && payload.error instanceof Error) {

4

package.json
{
"name": "@onekeyfe/hd-shared",
"version": "0.1.27",
"version": "0.1.28",
"description": "Hardware SDK's shared tool library",

@@ -28,3 +28,3 @@ "keywords": [

},
"gitHead": "ef1b7644ea5ac5e94eda3e83dbf03f1d2ad1a688"
"gitHead": "84236b7baecf937399e557aa2d9a5b47ecd01d3f"
}
export interface IHardwareError {
errorCode: ValueOf<typeof HardwareErrorCode>;
message?: string;
params?: any;
}

@@ -22,2 +23,4 @@

params: any = {};
constructor(hardwareError: IHardwareError | string) {

@@ -36,2 +39,3 @@ super();

}
this.params = hardwareError.params;
this.errorCode = hardwareError.errorCode;

@@ -157,2 +161,14 @@ }

/**
* Call method not supported, need update firmware
* @params: { current: string, require: string }
*/
CallMethodNeedUpgradeFirmware: 407,
/**
* Call method not supported, is deprecated
* @params: { current: string, deprecated: string }
*/
CallMethodDeprecated: 408,
/**
* Netword request error

@@ -291,2 +307,4 @@ */

[HardwareErrorCode.FirmwareUpdateDownloadFailed]: 'Firmware update download failed',
[HardwareErrorCode.CallMethodNeedUpgradeFirmware]: 'Call method need upgrade firmware',
[HardwareErrorCode.CallMethodDeprecated]: 'Call method is deprecated',

@@ -337,7 +355,11 @@ /**

export const TypedError = (hardwareError: ErrorCodeUnion | string, message?: string) => {
export const TypedError = (
hardwareError: ErrorCodeUnion | string,
message?: string,
params?: any
) => {
if (typeof hardwareError === 'string') {
return new HardwareError(hardwareError);
}
return new HardwareError({ errorCode: hardwareError, message: message ?? '' });
return new HardwareError({ errorCode: hardwareError, message: message ?? '', params });
};

@@ -347,3 +369,7 @@

if (payload && payload.error instanceof HardwareError) {
return { error: payload.error.message, code: payload.error.errorCode };
return {
error: payload.error.message,
code: payload.error.errorCode,
params: payload.error.params,
};
}

@@ -350,0 +376,0 @@ if (payload && payload.error instanceof Error) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc