diff --git a/packages/provider/src/tasks/powCaptcha/powTasks.ts b/packages/provider/src/tasks/powCaptcha/powTasks.ts index ad0e3618ed..0e1edb424c 100644 --- a/packages/provider/src/tasks/powCaptcha/powTasks.ts +++ b/packages/provider/src/tasks/powCaptcha/powTasks.ts @@ -60,11 +60,13 @@ export class PowCaptchaManager { powDifficulty?: number, ): Promise { const difficulty = powDifficulty || DEFAULT_POW_DIFFICULTY; - const requestedAtTimestamp = Date.now(); + // Create nonce for the challenge + const nonce = Math.floor(Math.random() * 1000000); + // Use blockhash, userAccount and dappAccount for string for challenge - const challenge: PoWChallengeId = `${requestedAtTimestamp}___${userAccount}___${dappAccount}`; + const challenge: PoWChallengeId = `${requestedAtTimestamp}___${userAccount}___${dappAccount}___${nonce}`; const challengeSignature = u8aToHex(this.pair.sign(stringToHex(challenge))); return { challenge, diff --git a/packages/types/src/datasets/captcha.ts b/packages/types/src/datasets/captcha.ts index ced1d4af58..deec4a478a 100644 --- a/packages/types/src/datasets/captcha.ts +++ b/packages/types/src/datasets/captcha.ts @@ -128,7 +128,7 @@ export const PowChallengeIdSchema = custom((val: any) => { const valSplit = val.split(POW_SEPARATOR); try { Number.parseInt(valSplit[0]); - return valSplit.length === 3; + return valSplit.length === 4; } catch (e) { return false; }