@onekeyfe/hd-transport-http 0.1.14 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -10,9 +10,10 @@ declare class HttpTransport {
10
10
  configured: boolean;
11
11
  stopped: boolean;
12
12
  url: string;
13
+ Log?: any;
13
14
  constructor(url?: string);
14
15
  _post(options: IncompleteRequestOptions): Promise<any>;
15
- init(): Promise<string>;
16
+ init(logger: any): Promise<string>;
16
17
  _silentInit(): Promise<string>;
17
18
  configure(signedData: any): void;
18
19
  listen(old?: Array<OneKeyDeviceInfoWithSession>): Promise<OneKeyDeviceInfoWithSession[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAMxF,aAAK,wBAAwB,GAAG;IAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IACrD,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAIF,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,UAAU,UAAS;IAEnB,OAAO,UAAS;IAEhB,GAAG,EAAE,MAAM,CAAC;gBAEA,GAAG,CAAC,EAAE,MAAM;IAKxB,KAAK,CAAC,OAAO,EAAE,wBAAwB;IAWjC,IAAI;IAKJ,WAAW;IAUjB,SAAS,CAAC,UAAU,EAAE,GAAG;IAMnB,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,2BAA2B,CAAC;IAY/C,SAAS;IAMf,aAAa,CAAC,KAAK,EAAE,YA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Mf,aAAa,CAAC,KAAK,EAAE,YAAY;IAO3B,OAAO,CAAC,KAAK,EAAE,YAAY;IAK3B,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAUzC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAmBjE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAYjE,IAAI,CAAC,OAAO,EAAE,MAAM;IAe1B,aAAa;IAKb,IAAI;IAIJ,MAAM;CAGP"}
package/dist/index.js CHANGED
@@ -84,13 +84,11 @@ function request(options) {
84
84
  const DEFAULT_URL = 'http://localhost:21320';
85
85
 
86
86
  const { check, buildOne, receiveOne, parseConfigure } = transport__default["default"];
87
- const Log = hdShared.initLog('@onekey/hd-transport-http');
88
87
  class HttpTransport {
89
88
  constructor(url) {
90
89
  this.configured = false;
91
90
  this.stopped = false;
92
91
  this.url = url == null ? DEFAULT_URL : url;
93
- hdShared.enableLog(true);
94
92
  }
95
93
  _post(options) {
96
94
  if (this.stopped) {
@@ -98,8 +96,9 @@ class HttpTransport {
98
96
  }
99
97
  return request(Object.assign(Object.assign({}, options), { method: 'POST', url: this.url + options.url }));
100
98
  }
101
- init() {
99
+ init(logger) {
102
100
  return __awaiter(this, void 0, void 0, function* () {
101
+ this.Log = logger;
103
102
  const bridgeVersion = yield this._silentInit();
104
103
  return bridgeVersion;
105
104
  });
@@ -168,7 +167,7 @@ class HttpTransport {
168
167
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
169
168
  }
170
169
  const messages = this._messages;
171
- Log.debug('call-', ' name: ', name, ' data: ', data);
170
+ this.Log.debug('call-', ' name: ', name, ' data: ', data);
172
171
  const o = buildOne(messages, name, data);
173
172
  const outData = o.toString('hex');
174
173
  const resData = yield this._post({
@@ -218,7 +217,7 @@ class HttpTransport {
218
217
  this.stopped = true;
219
218
  }
220
219
  cancel() {
221
- Log.debug('canceled');
220
+ this.Log.debug('canceled');
222
221
  }
223
222
  }
224
223
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-http",
3
- "version": "0.1.14",
3
+ "version": "0.1.18",
4
4
  "description": "hardware http transport",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -15,6 +15,7 @@
15
15
  "access": "public"
16
16
  },
17
17
  "scripts": {
18
+ "dev": "rimraf dist && rollup -c ../../build/rollup.config.js -w",
18
19
  "test": "echo \"Error: run tests from root\" && exit 1",
19
20
  "build": "rimraf dist && rollup -c ../../build/rollup.config.js",
20
21
  "lint": "eslint .",
@@ -24,9 +25,9 @@
24
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
25
26
  },
26
27
  "dependencies": {
27
- "@onekeyfe/hd-shared": "^0.1.14",
28
- "@onekeyfe/hd-transport": "^0.1.14",
28
+ "@onekeyfe/hd-shared": "^0.1.18",
29
+ "@onekeyfe/hd-transport": "^0.1.18",
29
30
  "axios": "^0.27.2"
30
31
  },
31
- "gitHead": "216fee1795067013da0d68f4fc25f583509bb509"
32
+ "gitHead": "eebfd1dd46b146c64a8bfda691dc4d8402fa105b"
32
33
  }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import transport from '@onekeyfe/hd-transport';
2
- import { ERRORS, HardwareErrorCode, enableLog, initLog } from '@onekeyfe/hd-shared';
2
+ import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
3
3
  import type { AcquireInput, OneKeyDeviceInfoWithSession } from '@onekeyfe/hd-transport';
4
4
  import { request as http } from './http';
5
5
  import { DEFAULT_URL } from './constants';
@@ -11,8 +11,6 @@ type IncompleteRequestOptions = {
11
11
  url: string;
12
12
  };
13
13
 
14
- const Log = initLog('@onekey/hd-transport-http');
15
-
16
14
  export default class HttpTransport {
17
15
  _messages: ReturnType<typeof transport.parseConfigure> | undefined;
18
16
 
@@ -22,9 +20,10 @@ export default class HttpTransport {
22
20
 
23
21
  url: string;
24
22
 
23
+ Log?: any;
24
+
25
25
  constructor(url?: string) {
26
26
  this.url = url == null ? DEFAULT_URL : url;
27
- enableLog(true);
28
27
  }
29
28
 
30
29
  _post(options: IncompleteRequestOptions) {
@@ -38,7 +37,8 @@ export default class HttpTransport {
38
37
  });
39
38
  }
40
39
 
41
- async init() {
40
+ async init(logger: any) {
41
+ this.Log = logger;
42
42
  const bridgeVersion = await this._silentInit();
43
43
  return bridgeVersion;
44
44
  }
@@ -104,7 +104,7 @@ export default class HttpTransport {
104
104
  throw ERRORS.TypedError(HardwareErrorCode.TransportNotConfigured);
105
105
  }
106
106
  const messages = this._messages;
107
- Log.debug('call-', ' name: ', name, ' data: ', data);
107
+ this.Log.debug('call-', ' name: ', name, ' data: ', data);
108
108
  const o = buildOne(messages, name, data);
109
109
  const outData = o.toString('hex');
110
110
  const resData = await this._post({
@@ -155,6 +155,6 @@ export default class HttpTransport {
155
155
  }
156
156
 
157
157
  cancel() {
158
- Log.debug('canceled');
158
+ this.Log.debug('canceled');
159
159
  }
160
160
  }