Skip to content

Commit 03defc3

Browse files
committed
fixes
1 parent 2433b82 commit 03defc3

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

extensions/daydreams-x402-auth/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ function buildTaskmarketSentinel(payload: { keystorePath: string; apiUrl?: strin
348348
keystorePath: payload.keystorePath,
349349
};
350350
const apiUrl = payload.apiUrl ? normalizeTaskmarketApiUrl(payload.apiUrl) : "";
351-
if (apiUrl && apiUrl !== FALLBACK_TASKMARKET_API_URL) {
351+
if (apiUrl) {
352352
record.apiUrl = apiUrl;
353353
}
354354
return `${TASKMARKET_SENTINEL_PREFIX}${toBase64Url(JSON.stringify(record))}`;

src/agents/x402-taskmarket-wallet.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ describe("parseTaskmarketWalletConfig", () => {
7777
TaskmarketWalletError,
7878
);
7979
});
80+
81+
it("throws when keystorePath is missing", () => {
82+
const sentinel = createTaskmarketSentinel({
83+
v: 1,
84+
keystorePath: "",
85+
apiUrl: "https://api-market.daydreams.systems",
86+
});
87+
expect(() => parseTaskmarketWalletConfig(sentinel)).toThrow(TaskmarketWalletError);
88+
});
8089
});
8190

8291
describe("decryptTaskmarketPrivateKey", () => {

src/agents/x402-taskmarket-wallet.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const DEFAULT_TASKMARKET_API_URL =
1111
const DEFAULT_ACCOUNT_CACHE_TTL_MS = 15 * 60 * 1000;
1212
const WALLET_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/;
1313
const PRIVATE_KEY_REGEX = /^0x[0-9a-fA-F]{64}$/;
14+
const MIN_ENCRYPTED_KEY_HEX_LENGTH = (12 + 16 + 1) * 2;
1415

1516
export type TaskmarketWalletConfig = {
1617
v: 1;
@@ -101,7 +102,8 @@ function parseTaskmarketKeystore(raw: unknown, sourcePath: string): TaskmarketKe
101102
if (
102103
!encryptedKey ||
103104
!/^[0-9a-fA-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

Comments
 (0)