@onekeyfe/hd-transport-http 1.2.8-alpha.13 → 1.2.8-alpha.14

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
@@ -7,6 +7,7 @@ type IncompleteRequestOptions = {
7
7
  timeout?: number;
8
8
  };
9
9
  declare class HttpTransport {
10
+ private readonly requestTimeout?;
10
11
  _messages: ReturnType<typeof _onekeyfe_hd_transport__default.parseConfigure> | undefined;
11
12
  name: string;
12
13
  configured: boolean;
@@ -14,14 +15,14 @@ declare class HttpTransport {
14
15
  url: string;
15
16
  Log?: any;
16
17
  getProtocolType(_path: string): ProtocolType;
17
- constructor(url?: string);
18
+ constructor(url?: string, requestTimeout?: number | undefined);
18
19
  _post(options: IncompleteRequestOptions): Promise<any>;
19
20
  init(logger: any): Promise<string>;
20
21
  _silentInit(): Promise<string>;
21
22
  configure(signedData: any): void;
22
23
  listen(old?: Array<OneKeyDeviceInfoWithSession>): Promise<OneKeyDeviceInfoWithSession[]>;
23
24
  enumerate(): Promise<{
24
- commType: string;
25
+ commType: "bridge";
25
26
  path: string;
26
27
  session?: string | null | undefined;
27
28
  debugSession?: string | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAM/C,OAAO,KAAK,EACV,YAAY,EACZ,2BAA2B,EAC3B,YAAY,EACb,MAAM,wBAAwB,CAAC;AAIhC,KAAK,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;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,SAAS,EAAE,UAAU,CA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';
134
134
  }
135
- constructor(url) {
135
+ constructor(url, requestTimeout) {
136
+ this.requestTimeout = requestTimeout;
136
137
  this.name = 'HttpTransport';
137
138
  this.configured = false;
138
139
  this.stopped = false;
139
140
  this.url = url == null ? DEFAULT_URL : url;
140
141
  }
141
142
  _post(options) {
143
+ var _a;
142
144
  if (this.stopped) {
143
145
  return Promise.reject(hdShared.ERRORS.TypedError('Transport stopped.'));
144
146
  }
145
- return request(Object.assign(Object.assign({}, options), { method: 'POST', url: this.url + options.url }));
147
+ return request(Object.assign(Object.assign({}, options), { timeout: (_a = options.timeout) !== null && _a !== void 0 ? _a : this.requestTimeout, method: 'POST', url: this.url + options.url }));
146
148
  }
147
149
  init(logger) {
148
150
  return __awaiter(this, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-http",
3
- "version": "1.2.8-alpha.13",
3
+ "version": "1.2.8-alpha.14",
4
4
  "description": "hardware http transport",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -24,10 +24,10 @@
24
24
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
25
25
  },
26
26
  "dependencies": {
27
- "@onekeyfe/hd-shared": "1.2.8-alpha.13",
28
- "@onekeyfe/hd-transport": "1.2.8-alpha.13",
27
+ "@onekeyfe/hd-shared": "1.2.8-alpha.14",
28
+ "@onekeyfe/hd-transport": "1.2.8-alpha.14",
29
29
  "axios": "1.15.2",
30
30
  "secure-json-parse": "^4.0.0"
31
31
  },
32
- "gitHead": "ed22eddce37ce0562b329c42a6985b50949ca412"
32
+ "gitHead": "f2784ca5eb21e4a3ebf167965f689e2ff2cb6249"
33
33
  }
package/src/index.ts CHANGED
@@ -36,7 +36,7 @@ export default class HttpTransport {
36
36
  return 'V1';
37
37
  }
38
38
 
39
- constructor(url?: string) {
39
+ constructor(url?: string, private readonly requestTimeout?: number) {
40
40
  this.url = url == null ? DEFAULT_URL : url;
41
41
  }
42
42
 
@@ -46,6 +46,7 @@ export default class HttpTransport {
46
46
  }
47
47
  return http({
48
48
  ...options,
49
+ timeout: options.timeout ?? this.requestTimeout,
49
50
  method: 'POST',
50
51
  url: this.url + options.url,
51
52
  });
@@ -88,7 +89,7 @@ export default class HttpTransport {
88
89
  async enumerate() {
89
90
  const devicesS = await this._post({ url: '/enumerate' });
90
91
  const devices = check.devices(devicesS);
91
- return devices.map(device => ({ ...device, commType: 'bridge' }));
92
+ return devices.map(device => ({ ...device, commType: 'bridge' as const }));
92
93
  }
93
94
 
94
95
  _acquireMixed(input: AcquireInput) {