Skip to content

Commit

Permalink
Checks if the generated nonce is valid. (#124)
Browse files Browse the repository at this point in the history
* Checks if the generated nonce is valid.

* Short circuit if clause
  • Loading branch information
w4ll3 committed Oct 10, 2022
1 parent 80feb1b commit 763c662
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/siwe/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ export const checkContractWalletSignature = async (
* an alphanumeric character set.
*/
export const generateNonce = (): string => {
return randomStringForEntropy(96);
const nonce = randomStringForEntropy(96);
if (!nonce || nonce.length < 8) {
throw new Error('Error during nonce creation.');
}
return nonce;
};

export const checkInvalidKeys = <T>(obj: T, keys: Array<keyof T>) : Array<keyof T> => {
Expand Down

0 comments on commit 763c662

Please sign in to comment.