@anywalletkit/extension-kit 0.4.0 → 0.5.1

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.cts CHANGED
@@ -1083,8 +1083,9 @@ type SignRequestInfo = {
1083
1083
  text: string; /** What is actually signed (hex or utf-8 string). */
1084
1084
  raw: string; /** Parsed Sign-In with Ethereum (EIP-4361) with the checks against the asking origin, when the text is one. */
1085
1085
  siwe?: SiweInfo; /** `text` had invisible or direction-changing characters (now escaped): the sheet should warn. */
1086
- hiddenChars?: true; /** The message is exactly 32 bytes (`0x` + 64 hex): a blind hash signature that CoW Protocol (`ethsign`), Safe (v > 30) and others accept as an order or a transfer. Only with the wallet's opt-in ({@link SignDeps.allowBlindHash}); the sheet must make it a danger screen. */
1087
- blindHash?: true;
1086
+ hiddenChars?: true; /** The bytes signed are exactly 32: a blind hash signature that CoW Protocol (`ethsign`), Safe (v > 30) and others accept as an order or a transfer. The sheet must make it a danger screen with Reject / Sign anyway; `blindHashForm` says how the message came. */
1087
+ blindHash?: true; /** With `blindHash`: `'hex'` — `0x` + 64 hex, only with the wallet's opt-in ({@link SignDeps.allowBlindHash}); `'text'` — text whose UTF-8 encoding is 32 bytes (a digest a site ground to valid UTF-8, sent as text), always shown, never refused. */
1088
+ blindHashForm?: PersonalSignBlindHashForm;
1088
1089
  } | {
1089
1090
  kind: 'sign-typed-data';
1090
1091
  method: string;
@@ -1103,6 +1104,12 @@ type SignRequestInfo = {
1103
1104
  gas: string | null;
1104
1105
  };
1105
1106
  };
1107
+ /**
1108
+ * How a 32-byte personal_sign message came ({@link SignRequestInfo} `blindHashForm`): `0x` + 64 hex, or text whose
1109
+ * UTF-8 encoding is 32 bytes. (kit's `EvmSignBlindHashForm` for `WriteIntent` also has `'bytes'`, a raw `Uint8Array`,
1110
+ * which a personal_sign from a site cannot be.)
1111
+ */
1112
+ type PersonalSignBlindHashForm = 'hex' | 'text';
1106
1113
  interface TypedData {
1107
1114
  domain: Record<string, unknown>;
1108
1115
  types: Record<string, Array<{
@@ -1145,6 +1152,11 @@ interface SignApproval {
1145
1152
  preview: unknown;
1146
1153
  }
1147
1154
  interface EvmSigner {
1155
+ /**
1156
+ * EIP-191 personal_sign. Bytes are signed as given, a string as its UTF-8 encoding (what viem
1157
+ * `signMessage`, ethers and wallet-evm `sign` do): the 32-byte check of {@link classifySignRequest}
1158
+ * measures the message that way.
1159
+ */
1148
1160
  signMessage(message: string | Uint8Array): Promise<string>;
1149
1161
  signTypedData(typed: TypedData): Promise<string>;
1150
1162
  /** Fully specified tx (chainId, nonce, gas, fees) → signed raw transaction. */
@@ -1177,8 +1189,10 @@ interface SignDeps {
1177
1189
  /** Tip floor per chain id in wei (default 0.1 gwei everywhere). */
1178
1190
  tipFloor?: (chainId: number) => bigint;
1179
1191
  /**
1180
- * Whether a personal_sign of a raw 32-byte hash may reach the sheet (read per request). Default: refused — a
1181
- * blind hash signature can be a CoW order or a Safe transaction paying someone else (extension audit E55).
1192
+ * Whether a personal_sign of a raw 32-byte hash (`0x` + 64 hex) may reach the sheet (read per request). Default:
1193
+ * refused — a blind hash signature can be a CoW order or a Safe transaction paying someone else (extension
1194
+ * audit E55). Text whose UTF-8 encoding is 32 bytes is not affected: it always reaches the sheet, marked
1195
+ * `blindHash` with `blindHashForm: 'text'`.
1182
1196
  */
1183
1197
  allowBlindHash?: () => boolean | Promise<boolean>;
1184
1198
  /**
@@ -1210,6 +1224,7 @@ declare function messageText(value: unknown): string;
1210
1224
  * signed, not the hex fallback `messageText` shows for unprintable text).
1211
1225
  */
1212
1226
  declare function decodedMessage(value: unknown): string | null;
1227
+ /** Signing method + params → what the window reviews, or the error to answer with. */
1213
1228
  declare function classifySignRequest(input: {
1214
1229
  network: EvmNetwork;
1215
1230
  method: string;
@@ -1217,7 +1232,7 @@ declare function classifySignRequest(input: {
1217
1232
  accounts: string[]; /** The asking page (browser-recorded) — needed for the SIWE domain check. */
1218
1233
  origin?: string; /** Transport note for pseudo-origins (WalletConnect Verify), for the SIWE check. */
1219
1234
  via?: OriginVia;
1220
- now?: number; /** Let a 32-byte hash personal_sign reach the sheet (marked `blindHash`) instead of refusing it. Default false. */
1235
+ now?: number; /** Let a 32-byte hash personal_sign in its hex form (`0x` + 64 hex) reach the sheet (marked `blindHash`) instead of refusing it. Default false. Text whose UTF-8 encoding is 32 bytes always reaches it, marked. */
1221
1236
  allowBlindHash?: boolean;
1222
1237
  }): SignRequestInfo | RelayError;
1223
1238
  /** A page's gas limit above max(estimate × 1.5, estimate + 50 000) is flagged on the sheet (never replaced). */
@@ -2062,4 +2077,4 @@ declare class TokenBucket {
2062
2077
  private prune;
2063
2078
  }
2064
2079
 
2065
- export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, APPROVALS_MAX_PENDING_PER_SITE, APPROVALS_MAX_PENDING_TOTAL, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRateOptions, type ApprovalRequest, type ApprovalRequestOptions, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, GETLOGS_MAX_SPAN_UNCONNECTED, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, MAX_FEE_REASKS, MULTI_LABEL_SUFFIXES, type MacJsonStorage, type MacJsonStorageOptions, type MacRead, type MacState, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, OriginRefused, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageMessageEvent, type PageRequest, type PageResponse, type PageWindow, PermissionStore, type PermissionsState, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RELAY_METHOD_MAX, type RankOptions, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayErrorOptions, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouteWarning, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SIWE_FORBIDDEN_CHARS, SOLANA_CHAIN, SOLANA_RPCS, STORAGE_MAC_FIELD, STORAGE_VERSION_FIELD, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type StorageVersionLedger, type StorageVersionLedgerOptions, type StorageVersionOps, type StorageVersions, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, TokenBucket, type TokenBucketOptions, type TonAddressParts, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_LIMITS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, canonicalJson, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, deriveStorageMacKey, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, gasLimitExcessive, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayMethod, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, macJsonStorage, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, pageRequestFrom, parseAddChainParams, parseRawAddress, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, revealHidden, reviewEarnPlan, reviewSwapPlan, siteOf, siweCrossSite, siweProblems, stampOrigin, storageVersionLedger, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, typedDataMatcher, vaultSecretStorage, verifyAssertion };
2080
+ export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, APPROVALS_MAX_PENDING_PER_SITE, APPROVALS_MAX_PENDING_TOTAL, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRateOptions, type ApprovalRequest, type ApprovalRequestOptions, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, GETLOGS_MAX_SPAN_UNCONNECTED, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, MAX_FEE_REASKS, MULTI_LABEL_SUFFIXES, type MacJsonStorage, type MacJsonStorageOptions, type MacRead, type MacState, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, OriginRefused, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageMessageEvent, type PageRequest, type PageResponse, type PageWindow, PermissionStore, type PermissionsState, type PersonalSignBlindHashForm, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RELAY_METHOD_MAX, type RankOptions, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayErrorOptions, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouteWarning, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SIWE_FORBIDDEN_CHARS, SOLANA_CHAIN, SOLANA_RPCS, STORAGE_MAC_FIELD, STORAGE_VERSION_FIELD, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type StorageVersionLedger, type StorageVersionLedgerOptions, type StorageVersionOps, type StorageVersions, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, TokenBucket, type TokenBucketOptions, type TonAddressParts, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_LIMITS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, canonicalJson, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, deriveStorageMacKey, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, gasLimitExcessive, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayMethod, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, macJsonStorage, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, pageRequestFrom, parseAddChainParams, parseRawAddress, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, revealHidden, reviewEarnPlan, reviewSwapPlan, siteOf, siweCrossSite, siweProblems, stampOrigin, storageVersionLedger, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, typedDataMatcher, vaultSecretStorage, verifyAssertion };
package/dist/index.d.ts CHANGED
@@ -1083,8 +1083,9 @@ type SignRequestInfo = {
1083
1083
  text: string; /** What is actually signed (hex or utf-8 string). */
1084
1084
  raw: string; /** Parsed Sign-In with Ethereum (EIP-4361) with the checks against the asking origin, when the text is one. */
1085
1085
  siwe?: SiweInfo; /** `text` had invisible or direction-changing characters (now escaped): the sheet should warn. */
1086
- hiddenChars?: true; /** The message is exactly 32 bytes (`0x` + 64 hex): a blind hash signature that CoW Protocol (`ethsign`), Safe (v > 30) and others accept as an order or a transfer. Only with the wallet's opt-in ({@link SignDeps.allowBlindHash}); the sheet must make it a danger screen. */
1087
- blindHash?: true;
1086
+ hiddenChars?: true; /** The bytes signed are exactly 32: a blind hash signature that CoW Protocol (`ethsign`), Safe (v > 30) and others accept as an order or a transfer. The sheet must make it a danger screen with Reject / Sign anyway; `blindHashForm` says how the message came. */
1087
+ blindHash?: true; /** With `blindHash`: `'hex'` — `0x` + 64 hex, only with the wallet's opt-in ({@link SignDeps.allowBlindHash}); `'text'` — text whose UTF-8 encoding is 32 bytes (a digest a site ground to valid UTF-8, sent as text), always shown, never refused. */
1088
+ blindHashForm?: PersonalSignBlindHashForm;
1088
1089
  } | {
1089
1090
  kind: 'sign-typed-data';
1090
1091
  method: string;
@@ -1103,6 +1104,12 @@ type SignRequestInfo = {
1103
1104
  gas: string | null;
1104
1105
  };
1105
1106
  };
1107
+ /**
1108
+ * How a 32-byte personal_sign message came ({@link SignRequestInfo} `blindHashForm`): `0x` + 64 hex, or text whose
1109
+ * UTF-8 encoding is 32 bytes. (kit's `EvmSignBlindHashForm` for `WriteIntent` also has `'bytes'`, a raw `Uint8Array`,
1110
+ * which a personal_sign from a site cannot be.)
1111
+ */
1112
+ type PersonalSignBlindHashForm = 'hex' | 'text';
1106
1113
  interface TypedData {
1107
1114
  domain: Record<string, unknown>;
1108
1115
  types: Record<string, Array<{
@@ -1145,6 +1152,11 @@ interface SignApproval {
1145
1152
  preview: unknown;
1146
1153
  }
1147
1154
  interface EvmSigner {
1155
+ /**
1156
+ * EIP-191 personal_sign. Bytes are signed as given, a string as its UTF-8 encoding (what viem
1157
+ * `signMessage`, ethers and wallet-evm `sign` do): the 32-byte check of {@link classifySignRequest}
1158
+ * measures the message that way.
1159
+ */
1148
1160
  signMessage(message: string | Uint8Array): Promise<string>;
1149
1161
  signTypedData(typed: TypedData): Promise<string>;
1150
1162
  /** Fully specified tx (chainId, nonce, gas, fees) → signed raw transaction. */
@@ -1177,8 +1189,10 @@ interface SignDeps {
1177
1189
  /** Tip floor per chain id in wei (default 0.1 gwei everywhere). */
1178
1190
  tipFloor?: (chainId: number) => bigint;
1179
1191
  /**
1180
- * Whether a personal_sign of a raw 32-byte hash may reach the sheet (read per request). Default: refused — a
1181
- * blind hash signature can be a CoW order or a Safe transaction paying someone else (extension audit E55).
1192
+ * Whether a personal_sign of a raw 32-byte hash (`0x` + 64 hex) may reach the sheet (read per request). Default:
1193
+ * refused — a blind hash signature can be a CoW order or a Safe transaction paying someone else (extension
1194
+ * audit E55). Text whose UTF-8 encoding is 32 bytes is not affected: it always reaches the sheet, marked
1195
+ * `blindHash` with `blindHashForm: 'text'`.
1182
1196
  */
1183
1197
  allowBlindHash?: () => boolean | Promise<boolean>;
1184
1198
  /**
@@ -1210,6 +1224,7 @@ declare function messageText(value: unknown): string;
1210
1224
  * signed, not the hex fallback `messageText` shows for unprintable text).
1211
1225
  */
1212
1226
  declare function decodedMessage(value: unknown): string | null;
1227
+ /** Signing method + params → what the window reviews, or the error to answer with. */
1213
1228
  declare function classifySignRequest(input: {
1214
1229
  network: EvmNetwork;
1215
1230
  method: string;
@@ -1217,7 +1232,7 @@ declare function classifySignRequest(input: {
1217
1232
  accounts: string[]; /** The asking page (browser-recorded) — needed for the SIWE domain check. */
1218
1233
  origin?: string; /** Transport note for pseudo-origins (WalletConnect Verify), for the SIWE check. */
1219
1234
  via?: OriginVia;
1220
- now?: number; /** Let a 32-byte hash personal_sign reach the sheet (marked `blindHash`) instead of refusing it. Default false. */
1235
+ now?: number; /** Let a 32-byte hash personal_sign in its hex form (`0x` + 64 hex) reach the sheet (marked `blindHash`) instead of refusing it. Default false. Text whose UTF-8 encoding is 32 bytes always reaches it, marked. */
1221
1236
  allowBlindHash?: boolean;
1222
1237
  }): SignRequestInfo | RelayError;
1223
1238
  /** A page's gas limit above max(estimate × 1.5, estimate + 50 000) is flagged on the sheet (never replaced). */
@@ -2062,4 +2077,4 @@ declare class TokenBucket {
2062
2077
  private prune;
2063
2078
  }
2064
2079
 
2065
- export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, APPROVALS_MAX_PENDING_PER_SITE, APPROVALS_MAX_PENDING_TOTAL, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRateOptions, type ApprovalRequest, type ApprovalRequestOptions, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, GETLOGS_MAX_SPAN_UNCONNECTED, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, MAX_FEE_REASKS, MULTI_LABEL_SUFFIXES, type MacJsonStorage, type MacJsonStorageOptions, type MacRead, type MacState, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, OriginRefused, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageMessageEvent, type PageRequest, type PageResponse, type PageWindow, PermissionStore, type PermissionsState, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RELAY_METHOD_MAX, type RankOptions, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayErrorOptions, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouteWarning, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SIWE_FORBIDDEN_CHARS, SOLANA_CHAIN, SOLANA_RPCS, STORAGE_MAC_FIELD, STORAGE_VERSION_FIELD, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type StorageVersionLedger, type StorageVersionLedgerOptions, type StorageVersionOps, type StorageVersions, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, TokenBucket, type TokenBucketOptions, type TonAddressParts, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_LIMITS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, canonicalJson, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, deriveStorageMacKey, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, gasLimitExcessive, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayMethod, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, macJsonStorage, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, pageRequestFrom, parseAddChainParams, parseRawAddress, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, revealHidden, reviewEarnPlan, reviewSwapPlan, siteOf, siweCrossSite, siweProblems, stampOrigin, storageVersionLedger, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, typedDataMatcher, vaultSecretStorage, verifyAssertion };
2080
+ export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, APPROVALS_MAX_PENDING_PER_SITE, APPROVALS_MAX_PENDING_TOTAL, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRateOptions, type ApprovalRequest, type ApprovalRequestOptions, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, GETLOGS_MAX_SPAN_UNCONNECTED, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, MAX_FEE_REASKS, MULTI_LABEL_SUFFIXES, type MacJsonStorage, type MacJsonStorageOptions, type MacRead, type MacState, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, OriginRefused, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageMessageEvent, type PageRequest, type PageResponse, type PageWindow, PermissionStore, type PermissionsState, type PersonalSignBlindHashForm, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RELAY_METHOD_MAX, type RankOptions, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayErrorOptions, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouteWarning, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SIWE_FORBIDDEN_CHARS, SOLANA_CHAIN, SOLANA_RPCS, STORAGE_MAC_FIELD, STORAGE_VERSION_FIELD, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type StorageVersionLedger, type StorageVersionLedgerOptions, type StorageVersionOps, type StorageVersions, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, TokenBucket, type TokenBucketOptions, type TonAddressParts, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_LIMITS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, canonicalJson, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, deriveStorageMacKey, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, gasLimitExcessive, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayMethod, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, macJsonStorage, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, pageRequestFrom, parseAddChainParams, parseRawAddress, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, revealHidden, reviewEarnPlan, reviewSwapPlan, siteOf, siweCrossSite, siweProblems, stampOrigin, storageVersionLedger, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, typedDataMatcher, vaultSecretStorage, verifyAssertion };
package/dist/index.js CHANGED
@@ -1876,6 +1876,58 @@ var permissionDescriptor = (origin, accounts) => ({
1876
1876
  date: Date.now()
1877
1877
  });
1878
1878
 
1879
+ // src/personal-sign.ts
1880
+ var HEX = /^0x([0-9a-fA-F]{2})*$/;
1881
+ var BLIND_HASH_MAX_CHARS = 66;
1882
+ var hexBytes = (value) => Uint8Array.from(value.slice(2).match(/../g) ?? [], (b) => Number.parseInt(b, 16));
1883
+ function codePoint(s, i) {
1884
+ const c = s.charCodeAt(i);
1885
+ if (c < 55296 || c > 57343) return c;
1886
+ const lo = c <= 56319 && i + 1 < s.length ? s.charCodeAt(i + 1) : 0;
1887
+ return lo >= 56320 && lo <= 57343 ? 65536 + (c - 55296 << 10) + (lo - 56320) : 65533;
1888
+ }
1889
+ function utf8Length(s) {
1890
+ let n = 0;
1891
+ for (let i = 0; i < s.length; i++) {
1892
+ const c = codePoint(s, i);
1893
+ if (c > 65535) {
1894
+ n += 4;
1895
+ i++;
1896
+ } else n += c < 128 ? 1 : c < 2048 ? 2 : 3;
1897
+ }
1898
+ return n;
1899
+ }
1900
+ function utf8Bytes(s) {
1901
+ const out = new Uint8Array(utf8Length(s));
1902
+ let o = 0;
1903
+ for (let i = 0; i < s.length; i++) {
1904
+ const c = codePoint(s, i);
1905
+ if (c < 128) out[o++] = c;
1906
+ else if (c < 2048) {
1907
+ out[o++] = 192 | c >> 6;
1908
+ out[o++] = 128 | c & 63;
1909
+ } else if (c < 65536) {
1910
+ out[o++] = 224 | c >> 12;
1911
+ out[o++] = 128 | c >> 6 & 63;
1912
+ out[o++] = 128 | c & 63;
1913
+ } else {
1914
+ out[o++] = 240 | c >> 18;
1915
+ out[o++] = 128 | c >> 12 & 63;
1916
+ out[o++] = 128 | c >> 6 & 63;
1917
+ out[o++] = 128 | c & 63;
1918
+ i++;
1919
+ }
1920
+ }
1921
+ return out;
1922
+ }
1923
+ function personalSignInput(message) {
1924
+ return HEX.test(message) ? hexBytes(message) : message;
1925
+ }
1926
+ function personalSignBytes(message) {
1927
+ const input = personalSignInput(message);
1928
+ return typeof input === "string" ? utf8Bytes(input) : input;
1929
+ }
1930
+
1879
1931
  // src/siwe.ts
1880
1932
  var SIWE_FORBIDDEN_CHARS = /[\u061c\u200b-\u200f\u202a-\u202e\u2060-\u2064\u2066-\u2069\ufeff]/;
1881
1933
  var HEADER_LINE = /^(?<domain>[^\n]+?) wants you to sign in with your Ethereum account:(?:\n|$)/;
@@ -2004,7 +2056,6 @@ var safeNonce = (n) => {
2004
2056
  };
2005
2057
  var MAX_FEE_REASKS = 3;
2006
2058
  var ADDRESS = /^0x[0-9a-fA-F]{40}$/;
2007
- var HEX = /^0x([0-9a-fA-F]{2})*$/;
2008
2059
  var lc = (s) => s.toLowerCase();
2009
2060
  var INVISIBLE = /[\p{Cf}\u2028\u2029\u115f\u1160\u3164\uffa0\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/gu;
2010
2061
  function revealHidden(text) {
@@ -2040,7 +2091,6 @@ function decodedMessage(value) {
2040
2091
  }
2041
2092
  var HIDDEN_CONTROL = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/;
2042
2093
  var err = (code, message) => ({ code, message });
2043
- var BLIND_HASH = /^0x[0-9a-fA-F]{64}$/;
2044
2094
  function classifySignRequest(input) {
2045
2095
  const { method, params } = input;
2046
2096
  const owned = new Set(input.accounts.map(lc));
@@ -2051,15 +2101,16 @@ function classifySignRequest(input) {
2051
2101
  if (ours(msg) && !ours(addr)) [msg, addr] = [addr, msg];
2052
2102
  if (!ours(addr)) return err(RELAY_ERRORS.unauthorized, "personal_sign for an address this wallet does not hold.");
2053
2103
  if (typeof msg !== "string") return err(RELAY_ERRORS.invalidParams, "personal_sign expects a message string.");
2054
- const blindHash = BLIND_HASH.test(msg);
2055
- if (blindHash && !input.allowBlindHash) return err(RELAY_ERRORS.unsupportedMethod, 'This site asks you to sign a raw 32-byte hash (blind signing). It can be a swap order or a transfer (e.g. CoW Protocol) paying someone else, so this wallet refuses it. "Allow blind hash signatures" in Options turns on a review for such requests.');
2104
+ const thirtyTwo = msg.length <= BLIND_HASH_MAX_CHARS && personalSignBytes(msg).length === 32;
2105
+ const blindHashForm = !thirtyTwo ? void 0 : HEX.test(msg) ? "hex" : "text";
2106
+ if (blindHashForm === "hex" && !input.allowBlindHash) return err(RELAY_ERRORS.unsupportedMethod, 'This site asks you to sign a raw 32-byte hash (blind signing). It can be a swap order or a transfer (e.g. CoW Protocol) paying someone else, so this wallet refuses it. "Allow blind hash signatures" in Options turns on a review for such requests.');
2056
2107
  const shown = shownMessage(msg);
2057
2108
  const text = shown.text;
2058
2109
  const signed = decodedMessage(msg) ?? text;
2059
2110
  const siwe = input.origin ? describeSiwe(signed, { origin: input.origin, account: checksum(addr), chainId: input.network.chainId, ...input.via ? { via: input.via } : {}, ...input.now !== void 0 ? { now: input.now } : {} }) : null;
2060
2111
  if (siwe && HIDDEN_CONTROL.test(signed)) return err(RELAY_ERRORS.invalidParams, "This sign-in message contains hidden control characters \u2014 refused.");
2061
2112
  if (siwe && SIWE_FORBIDDEN_CHARS.test(signed)) return err(RELAY_ERRORS.invalidParams, "This sign-in message contains invisible or text-direction characters \u2014 refused.");
2062
- return { kind: "sign-message", method, account: checksum(addr), text, raw: msg, ...siwe ? { siwe } : {}, ...shown.hidden ? { hiddenChars: true } : {}, ...blindHash ? { blindHash: true } : {} };
2113
+ return { kind: "sign-message", method, account: checksum(addr), text, raw: msg, ...siwe ? { siwe } : {}, ...shown.hidden ? { hiddenChars: true } : {}, ...blindHashForm ? { blindHash: true, blindHashForm } : {} };
2063
2114
  }
2064
2115
  if (method === "eth_signTypedData_v4" || method === "eth_signTypedData_v3" || method === "eth_signTypedData") {
2065
2116
  const [addr, data] = params;
@@ -2223,7 +2274,7 @@ function createSignHandler(deps) {
2223
2274
  try {
2224
2275
  switch (info.kind) {
2225
2276
  case "sign-message":
2226
- return await handle.signer.signMessage(HEX.test(info.raw) ? Uint8Array.from(info.raw.slice(2).match(/../g) ?? [], (b) => Number.parseInt(b, 16)) : info.raw);
2277
+ return await handle.signer.signMessage(personalSignInput(info.raw));
2227
2278
  case "sign-typed-data":
2228
2279
  return await handle.signer.signTypedData(info.typedData);
2229
2280
  }