Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/wallet-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Replace `Math.random()` with `crypto.getRandomValues()` for OTP generation
- Validate peer public keys during session creation ([#70](https://github.com/MetaMask/mobile-wallet-protocol/pull/70))
- Fix client stuck in CONNECTING state when session creation fails ([#70](https://github.com/MetaMask/mobile-wallet-protocol/pull/70))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export class UntrustedConnectionHandler implements IConnectionHandler {
* @returns An object containing the OTP string and its deadline
*/
private _generateOtpWithDeadline(): { otp: string; deadline: number } {
const otp = Math.floor(100000 + Math.random() * 900000).toString();
const buf = new Uint32Array(1);
globalThis.crypto.getRandomValues(buf);
const otp = (100000 + (buf[0] % 900000)).toString();
const deadline = Date.now() + this.otpTimeoutMs;
return { otp, deadline };
}
Expand Down