@@ -11,6 +11,7 @@ const DEFAULT_TASKMARKET_API_URL =
1111const DEFAULT_ACCOUNT_CACHE_TTL_MS = 15 * 60 * 1000 ;
1212const WALLET_ADDRESS_REGEX = / ^ 0 x [ 0 - 9 a - f A - F ] { 40 } $ / ;
1313const PRIVATE_KEY_REGEX = / ^ 0 x [ 0 - 9 a - f A - F ] { 64 } $ / ;
14+ const MIN_ENCRYPTED_KEY_HEX_LENGTH = ( 12 + 16 + 1 ) * 2 ;
1415
1516export type TaskmarketWalletConfig = {
1617 v : 1 ;
@@ -101,7 +102,8 @@ function parseTaskmarketKeystore(raw: unknown, sourcePath: string): TaskmarketKe
101102 if (
102103 ! encryptedKey ||
103104 ! / ^ [ 0 - 9 a - f A - F ] + $ / . test ( encryptedKey ) ||
104- encryptedKey . length < 58 ||
105+ // 12-byte IV + 16-byte tag + at least 1 byte of ciphertext, hex-encoded.
106+ encryptedKey . length < MIN_ENCRYPTED_KEY_HEX_LENGTH ||
105107 encryptedKey . length % 2 !== 0
106108 ) {
107109 throw new TaskmarketWalletError (
@@ -403,12 +405,7 @@ export async function createTaskmarketAccount(params: {
403405 } catch ( error ) {
404406 // Clear any stale cache and retry once for transient auth/network failures.
405407 accountCache . delete ( cacheKey ) ;
406- if (
407- error instanceof TaskmarketWalletError &&
408- ( error . code === "network" ||
409- error . code === "device_auth" ||
410- error . code === "device_not_found" )
411- ) {
408+ if ( error instanceof TaskmarketWalletError && error . code === "network" ) {
412409 return attemptResolveAccount ( ) ;
413410 }
414411 throw error ;
0 commit comments