@onekeyfe/hd-core 1.2.2-alpha.10 → 1.2.2-alpha.101

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.
@@ -8,8 +8,9 @@ export const LogBlockEvent: Set<string> = new Set([
8
8
  UI_RESPONSE.RECEIVE_PASSPHRASE,
9
9
  ]);
10
10
 
11
- const LogLabelMethod: Set<string> = new Set([
12
- 'openWalletSession',
11
+ // These resource/file APIs did not exist in 1.1.32. Skip the payload so
12
+ // the log layer does not copy huge Base64 or binary data.
13
+ const LogPayloadBlockMethod: Set<string> = new Set([
13
14
  'deviceUploadNft',
14
15
  'deviceUploadWallpaper',
15
16
  'uploadPortfolio',
@@ -17,61 +18,6 @@ const LogLabelMethod: Set<string> = new Set([
17
18
  'fileRead',
18
19
  ]);
19
20
 
20
- // 资源上传参数可能包含很大的 Base64 字符串。这里按方法整段跳过,避免日志层
21
- // 递归复制和序列化这些数据;资源 API 与传输内容本身保持不变。
22
- const LogPayloadBlockMethod: Set<string> = new Set([
23
- 'deviceUploadNft',
24
- 'deviceUploadWallpaper',
25
- 'uploadPortfolio',
26
- ]);
27
-
28
- const SensitiveLogKeys: Set<string> = new Set([
29
- 'devicestate',
30
- 'entropy',
31
- 'expectedpassphrasestate',
32
- 'mnemonic',
33
- 'passphrase',
34
- 'passphrasestate',
35
- 'password',
36
- 'pin',
37
- 'privatekey',
38
- 'seed',
39
- 'session',
40
- 'sessionid',
41
- 'walletsessionid',
42
- 'xprv',
43
- ]);
44
-
45
- const normalizeLogKey = (key: string) => key.replace(/[_-]/g, '').toLowerCase();
46
-
47
- const isSigningMethod = (methodName: string) => /sign/i.test(methodName);
48
-
49
- const redactLogValue = (value: unknown, seen: WeakSet<object>): unknown => {
50
- if (ArrayBuffer.isView(value)) {
51
- return `[BINARY:${value.byteLength}]`;
52
- }
53
- if (value instanceof ArrayBuffer) {
54
- return `[BINARY:${value.byteLength}]`;
55
- }
56
- if (Array.isArray(value)) {
57
- return value.map(item => redactLogValue(item, seen));
58
- }
59
- if (!value || typeof value !== 'object') return value;
60
- if (seen.has(value)) return '[CIRCULAR]';
61
-
62
- seen.add(value);
63
- const redacted = Object.fromEntries(
64
- Object.entries(value as Record<string, unknown>).map(([key, item]) => [
65
- key,
66
- SensitiveLogKeys.has(normalizeLogKey(key)) && item !== null && item !== undefined
67
- ? '[REDACTED]'
68
- : redactLogValue(item, seen),
69
- ])
70
- );
71
- seen.delete(value);
72
- return redacted;
73
- };
74
-
75
21
  export function getLogBlockLabel(message: unknown): string | undefined {
76
22
  if (!message || typeof message !== 'object') return undefined;
77
23
 
@@ -86,7 +32,7 @@ export function getLogBlockLabel(message: unknown): string | undefined {
86
32
  }
87
33
 
88
34
  const methodName = method ?? payload?.method;
89
- if (methodName && (LogLabelMethod.has(methodName) || isSigningMethod(methodName))) {
35
+ if (methodName && LogPayloadBlockMethod.has(methodName)) {
90
36
  return methodName;
91
37
  }
92
38
 
@@ -94,25 +40,10 @@ export function getLogBlockLabel(message: unknown): string | undefined {
94
40
  }
95
41
 
96
42
  export function getSafeLogPayload(value: unknown, blockLabel?: string): unknown {
97
- if (
98
- blockLabel &&
99
- (LogBlockEvent.has(blockLabel) ||
100
- LogPayloadBlockMethod.has(blockLabel) ||
101
- isSigningMethod(blockLabel))
102
- ) {
43
+ if (blockLabel) {
103
44
  return { method: blockLabel, payload: '[REDACTED]' };
104
45
  }
105
-
106
- const redactedValue = redactLogValue(value, new WeakSet());
107
- if (
108
- blockLabel &&
109
- redactedValue &&
110
- typeof redactedValue === 'object' &&
111
- !Array.isArray(redactedValue)
112
- ) {
113
- return { ...redactedValue, method: blockLabel };
114
- }
115
- return redactedValue;
46
+ return value;
116
47
  }
117
48
 
118
49
  export function formatLogMethodLabel(label: string, methodName?: string): string {
@@ -234,9 +234,9 @@ export async function getProtocolV2WalletSession(
234
234
  const forceWalletSelection =
235
235
  options?.forceWalletSelection === true || options?.initSession === true;
236
236
  const readCurrentAttachPinSession = options?.readCurrentAttachPinSession === true;
237
- const sessionIsAttachPinWallet = (session?: { viaAttachPin?: boolean }) =>
237
+ const sessionIsAttachPinWallet = (session?: unknown) =>
238
238
  readCurrentAttachPinSession ||
239
- session?.viaAttachPin === true ||
239
+ (session as { viaAttachPin?: boolean } | undefined)?.viaAttachPin === true ||
240
240
  device.features?.unlockedAttachPin === true;
241
241
 
242
242
  if (forceWalletSelection) {
@@ -455,6 +455,11 @@ export async function getProtocolV2WalletSession(
455
455
  throw error;
456
456
  }
457
457
  resumed = false;
458
+ if (device.features?.unlockedAttachPin === true) {
459
+ // Locking invalidates the old handle, but Attach PIN already selected the wallet.
460
+ // Read the current session and validate its passphrase state below.
461
+ response = await getDeviceSession(device, sessionGetRequest());
462
+ }
458
463
  }
459
464
  } else if (expectedPassphraseState) {
460
465
  try {
@@ -1,6 +1,7 @@
1
1
  import type { CommonParams, Response } from '../params';
2
2
  import type { OnboardingStatus, Success } from '@onekeyfe/hd-transport';
3
3
  import type { DeviceRebootParams } from '../../api/protocol-v2/helpers';
4
+ import type { UploadPortfolioParams } from '../../api/UploadPortfolio';
4
5
  import type {
5
6
  DeviceUploadWallpaperParams,
6
7
  DeviceUploadWallpaperResponse,
@@ -12,6 +13,7 @@ import type {
12
13
 
13
14
  // Re-export implementation parameter types as the single source of truth.
14
15
  export type { DeviceRebootParams, RebootTypeInput } from '../../api/protocol-v2/helpers';
16
+ export type { UploadPortfolioParams } from '../../api/UploadPortfolio';
15
17
  export type {
16
18
  DeviceUploadWallpaperParams,
17
19
  DeviceUploadWallpaperResponse,
@@ -67,8 +69,5 @@ export declare function deviceUploadNft(
67
69
 
68
70
  export declare function uploadPortfolio(
69
71
  connectId: string,
70
- params: {
71
- packageBase64: string;
72
- timeoutMs?: number | string;
73
- }
72
+ params: UploadPortfolioParams
74
73
  ): Response<FileInfo & { portfolioUpdated: true }>;
@@ -15,6 +15,9 @@ export type SolSignOffchainMessageParams = {
15
15
  messageVersion?: SolanaOffChainMessageVersion;
16
16
  messageFormat?: SolanaOffChainMessageFormat;
17
17
  applicationDomainHex?: string;
18
+ sourceFingerprint?: number;
19
+ /** 32-byte public keys encoded as hex, strictly sorted and unique. */
20
+ requiredSigners?: string[];
18
21
  };
19
22
 
20
23
  export declare function solSignOffchainMessage(