@onekeyfe/hd-transport 1.2.0-alpha.0 → 1.2.0-alpha.2

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.
@@ -483,7 +483,7 @@ describe('Protocol V2 framing and session', () => {
483
483
  });
484
484
  });
485
485
 
486
- test('probeProtocolV2 accepts Ping success as a normal V2 probe response', async () => {
486
+ test('probeProtocolV2 accepts Success as a normal V2 probe response', async () => {
487
487
  await expect(
488
488
  probeProtocolV2({
489
489
  call: () => Promise.resolve({ type: 'Success', message: {} }),
@@ -729,7 +729,7 @@ describe('Protocol V2 framing and session', () => {
729
729
  });
730
730
 
731
731
  test('probeProtocolV2 only uses Ping for acquire probing', async () => {
732
- const call = jest.fn().mockRejectedValue(new Error('ping timeout'));
732
+ const call = jest.fn().mockRejectedValue(new Error('Ping timeout'));
733
733
  const onProbeFailed = jest.fn();
734
734
 
735
735
  await expect(
@@ -742,7 +742,7 @@ describe('Protocol V2 framing and session', () => {
742
742
  expect(call).toHaveBeenNthCalledWith(
743
743
  1,
744
744
  'Ping',
745
- { message: 'probe' },
745
+ { message: 'protocol-v2-probe' },
746
746
  {
747
747
  timeoutMs: 1,
748
748
  expectedTypes: ['Success'],
package/dist/index.js CHANGED
@@ -1034,20 +1034,20 @@ class ProtocolV2Session {
1034
1034
  function probeProtocolV2({ call, timeoutMs, logger, logPrefix = 'ProtocolV2', onBeforeProbe, onProbeFailed, }) {
1035
1035
  var _a;
1036
1036
  return __awaiter(this, void 0, void 0, function* () {
1037
- let pingError;
1037
+ let probeError;
1038
1038
  try {
1039
1039
  yield (onBeforeProbe === null || onBeforeProbe === void 0 ? void 0 : onBeforeProbe());
1040
- const response = yield call('Ping', { message: 'probe' }, { timeoutMs, expectedTypes: ['Success'] });
1040
+ const response = yield call('Ping', { message: 'protocol-v2-probe' }, { timeoutMs, expectedTypes: ['Success'] });
1041
1041
  if (response.type === 'Success') {
1042
1042
  return true;
1043
1043
  }
1044
- pingError = new Error(`unexpected response type ${response.type}`);
1044
+ probeError = new Error(`unexpected response type ${response.type}`);
1045
1045
  }
1046
1046
  catch (error) {
1047
- pingError = error;
1047
+ probeError = error;
1048
1048
  }
1049
- (_a = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _a === void 0 ? void 0 : _a.call(logger, `[${logPrefix}] Protocol V2 ping probe failed:`, getErrorMessage(pingError));
1050
- yield (onProbeFailed === null || onProbeFailed === void 0 ? void 0 : onProbeFailed(pingError));
1049
+ (_a = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _a === void 0 ? void 0 : _a.call(logger, `[${logPrefix}] Protocol V2 probe failed:`, getErrorMessage(probeError));
1050
+ yield (onProbeFailed === null || onProbeFailed === void 0 ? void 0 : onProbeFailed(probeError));
1051
1051
  return false;
1052
1052
  });
1053
1053
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport",
3
- "version": "1.2.0-alpha.0",
3
+ "version": "1.2.0-alpha.2",
4
4
  "description": "Transport layer abstractions and utilities for OneKey hardware SDK.",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -28,5 +28,5 @@
28
28
  "long": "^4.0.0",
29
29
  "protobufjs": "^6.11.2"
30
30
  },
31
- "gitHead": "de9efe20b83666b641ab9e8d945e6350f6450904"
31
+ "gitHead": "6c183b7f7027f4b4d3db4f427f6360351a6c6680"
32
32
  }
@@ -407,23 +407,23 @@ export async function probeProtocolV2({
407
407
  onBeforeProbe?: () => Promise<void> | void;
408
408
  onProbeFailed?: (error: unknown) => Promise<void> | void;
409
409
  }) {
410
- let pingError: unknown;
410
+ let probeError: unknown;
411
411
  try {
412
412
  await onBeforeProbe?.();
413
413
  const response = await call(
414
414
  'Ping',
415
- { message: 'probe' },
415
+ { message: 'protocol-v2-probe' },
416
416
  { timeoutMs, expectedTypes: ['Success'] }
417
417
  );
418
418
  if (response.type === 'Success') {
419
419
  return true;
420
420
  }
421
- pingError = new Error(`unexpected response type ${response.type}`);
421
+ probeError = new Error(`unexpected response type ${response.type}`);
422
422
  } catch (error) {
423
- pingError = error;
423
+ probeError = error;
424
424
  }
425
425
 
426
- logger?.debug?.(`[${logPrefix}] Protocol V2 ping probe failed:`, getErrorMessage(pingError));
427
- await onProbeFailed?.(pingError);
426
+ logger?.debug?.(`[${logPrefix}] Protocol V2 probe failed:`, getErrorMessage(probeError));
427
+ await onProbeFailed?.(probeError);
428
428
  return false;
429
429
  }