Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onekeyfe/hd-transport-http

Package Overview
Dependencies
Maintainers
2
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onekeyfe/hd-transport-http - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

19

dist/index.js
'use strict';
var transport = require('@onekeyfe/hd-transport');
var hdShared = require('@onekeyfe/hd-shared');
var axios = require('axios');

@@ -73,6 +74,6 @@

if (typeof resJson === 'object' && resJson != null && resJson.error != null) {
throw new Error(resJson.error);
throw new hdShared.HardwareError({ errorCode: hdShared.HardwareErrorCode.NetworkError, message: resJson.error });
}
else {
throw new Error(res.data);
throw new hdShared.HardwareError({ errorCode: hdShared.HardwareErrorCode.NetworkError, message: res.data });
}

@@ -93,3 +94,3 @@ });

if (this.stopped) {
return Promise.reject('Transport stopped.');
return Promise.reject(hdShared.ERRORS.TypedError('Transport stopped.'));
}

@@ -122,3 +123,3 @@ return request(Object.assign(Object.assign({}, options), { method: 'POST', url: this.url + options.url }));

if (old === null) {
throw new Error('Http-Transport does not support listen without previous.');
throw hdShared.ERRORS.TypedError('Http-Transport does not support listen without previous.');
}

@@ -165,3 +166,3 @@ const devicesS = yield this._post({

if (this._messages == null) {
throw new Error('Transport not configured.');
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
}

@@ -177,3 +178,3 @@ const messages = this._messages;

if (typeof resData !== 'string') {
throw new Error('Returning data is not string.');
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NetworkError, 'Returning data is not string.');
}

@@ -187,3 +188,3 @@ const jsonData = receiveOne(messages, resData);

if (this._messages == null) {
throw new Error('Transport not configured.');
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
}

@@ -201,3 +202,3 @@ const messages = this._messages;

if (this._messages == null) {
throw new Error('Transport not configured.');
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
}

@@ -209,3 +210,3 @@ const messages = this._messages;

if (typeof resData !== 'string') {
throw new Error('Returning data is not string.');
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NetworkError, 'Returning data is not string.');
}

@@ -212,0 +213,0 @@ const jsonData = receiveOne(messages, resData);

{
"name": "@onekeyfe/hd-transport-http",
"version": "0.1.5",
"version": "0.1.6",
"description": "hardware http transport",

@@ -27,6 +27,7 @@ "author": "OneKey",

"dependencies": {
"@onekeyfe/hd-transport": "^0.1.5",
"@onekeyfe/hd-shared": "^0.1.6",
"@onekeyfe/hd-transport": "^0.1.6",
"axios": "^0.27.2"
},
"gitHead": "26a2b960d5e1917d3f2217cef449269200a1a376"
"gitHead": "ebe2789fa24cbfb798c9be445678e71e67e33d71"
}
import axios, { AxiosRequestConfig } from 'axios';
import { HardwareError, HardwareErrorCode } from '@onekeyfe/hd-shared';

@@ -49,6 +50,6 @@ export type HttpRequestOptions = {

if (typeof resJson === 'object' && resJson != null && resJson.error != null) {
throw new Error(resJson.error);
throw new HardwareError({ errorCode: HardwareErrorCode.NetworkError, message: resJson.error });
} else {
throw new Error(res.data);
throw new HardwareError({ errorCode: HardwareErrorCode.NetworkError, message: res.data });
}
}
import transport from '@onekeyfe/hd-transport';
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
import type { AcquireInput, OneKeyDeviceInfoWithSession } from '@onekeyfe/hd-transport';

@@ -28,4 +29,3 @@ import { request as http } from './http';

if (this.stopped) {
// eslint-disable-next-line prefer-promise-reject-errors
return Promise.reject('Transport stopped.');
return Promise.reject(ERRORS.TypedError('Transport stopped.'));
}

@@ -61,3 +61,3 @@ return http({

if (old === null) {
throw new Error('Http-Transport does not support listen without previous.');
throw ERRORS.TypedError('Http-Transport does not support listen without previous.');
}

@@ -102,3 +102,3 @@ const devicesS = await this._post({

if (this._messages == null) {
throw new Error('Transport not configured.');
throw ERRORS.TypedError(HardwareErrorCode.TransportNotConfigured);
}

@@ -123,3 +123,3 @@ const messages = this._messages;

if (typeof resData !== 'string') {
throw new Error('Returning data is not string.');
throw ERRORS.TypedError(HardwareErrorCode.NetworkError, 'Returning data is not string.');
}

@@ -132,3 +132,3 @@ const jsonData = receiveOne(messages, resData);

if (this._messages == null) {
throw new Error('Transport not configured.');
throw ERRORS.TypedError(HardwareErrorCode.TransportNotConfigured);
}

@@ -145,3 +145,3 @@ const messages = this._messages;

if (this._messages == null) {
throw new Error('Transport not configured.');
throw ERRORS.TypedError(HardwareErrorCode.TransportNotConfigured);
}

@@ -153,3 +153,3 @@ const messages = this._messages;

if (typeof resData !== 'string') {
throw new Error('Returning data is not string.');
throw ERRORS.TypedError(HardwareErrorCode.NetworkError, 'Returning data is not string.');
}

@@ -156,0 +156,0 @@ const jsonData = receiveOne(messages, resData);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc