🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@better-auth/utils

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@better-auth/utils - npm Package Compare versions

Comparing version
0.4.1
to
0.4.2
+10
-4
dist/otp.cjs

@@ -11,2 +11,9 @@ 'use strict';

const defaultDigits = 6;
function constantTimeEqualOTP(input, expected) {
let difference = input.length ^ expected.length;
for (let i = 0; i < expected.length; i++) {
difference |= input.charCodeAt(i) ^ expected.charCodeAt(i);
}
return difference === 0;
}
async function generateHOTP(secret, {

@@ -45,2 +52,3 @@ counter,

const counter = Math.floor(Date.now() / milliseconds);
let matched = false;
for (let i = -window; i <= window; i++) {

@@ -51,7 +59,5 @@ const generatedOTP = await generateHOTP(secret, {

});
if (otp === generatedOTP) {
return true;
}
matched = constantTimeEqualOTP(otp, generatedOTP) || matched;
}
return false;
return matched;
}

@@ -58,0 +64,0 @@ function generateQRCode({

@@ -9,2 +9,9 @@ import { base32 } from './base32.mjs';

const defaultDigits = 6;
function constantTimeEqualOTP(input, expected) {
let difference = input.length ^ expected.length;
for (let i = 0; i < expected.length; i++) {
difference |= input.charCodeAt(i) ^ expected.charCodeAt(i);
}
return difference === 0;
}
async function generateHOTP(secret, {

@@ -43,2 +50,3 @@ counter,

const counter = Math.floor(Date.now() / milliseconds);
let matched = false;
for (let i = -window; i <= window; i++) {

@@ -49,7 +57,5 @@ const generatedOTP = await generateHOTP(secret, {

});
if (otp === generatedOTP) {
return true;
}
matched = constantTimeEqualOTP(otp, generatedOTP) || matched;
}
return false;
return matched;
}

@@ -56,0 +62,0 @@ function generateQRCode({

{
"name": "@better-auth/utils",
"version": "0.4.1",
"version": "0.4.2",
"license": "MIT",

@@ -18,3 +18,3 @@ "description": "A collection of utilities for better-auth",

"type": "git",
"url": "https://github.com/better-auth/utils"
"url": "git+https://github.com/better-auth/utils.git"
},

@@ -98,4 +98,5 @@ "devDependencies": {

"build": "unbuild",
"bump": "bumpp",
"lint:fix": "biome check . --write"
}
}