( recoveryCode: string, salt?: Uint8Array, )
| 157 | } |
| 158 | |
| 159 | export function hashRecoveryCode( |
| 160 | recoveryCode: string, |
| 161 | salt?: Uint8Array, |
| 162 | ): Uint8Array { |
| 163 | salt ??= sodium.randombytes_buf(16); |
| 164 | |
| 165 | return concatUint8Arrays( |
| 166 | salt, |
| 167 | cryptoJsWordArrayToUint8Array( |
| 168 | CryptoJS.SHA256(sodium.to_hex(salt) + recoveryCode), |
| 169 | ), |
| 170 | ); |
| 171 | } |
| 172 | export function verifyRecoveryCode( |
| 173 | recoveryCode: string, |
| 174 | hashedRecoveryCode: Uint8Array, |
no test coverage detected