Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@node-rs/bcrypt

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@node-rs/bcrypt - npm Package Compare versions

Comparing version 1.4.2 to 1.5.0

LICENSE

48

index.d.ts

@@ -1,26 +0,26 @@

export const DEFAULT_COST: 12
/* tslint:disable */
/* eslint-disable */
export function hashSync(password: string | Buffer, round?: number): string
export function hash(password: string | Buffer, round?: number): Promise<string>
export function verifySync(password: string | Buffer, hash: string | Buffer): boolean
export function verify(password: string | Buffer, hash: string | Buffer): Promise<boolean>
/**
* The same with `verifySync`
*/
export function compareSync(password: string | Buffer, hash: string | Buffer): boolean
/**
* The same with `verify`
*/
export function compare(password: string | Buffer, hash: string | Buffer): Promise<boolean>
/* auto-generated by NAPI-RS */
export type Version = '2a' | '2x' | '2y' | '2b'
/**
* @param round default 10
* @param version default '2b'
*/
export function genSaltSync(round?: number, version?: Version): string
/**
* @param round default 10
* @param version default '2b'
*/
export function genSalt(round?: number, version?: Version): Promise<string>
export class ExternalObject<T> {
readonly '': {
readonly '': unique symbol
[K: symbol]: T
}
}
export const DEFAULT_COST: number
export function genSaltSync(round: number, version: string): string
export function genSalt(round: number, version: string, signal?: AbortSignal | undefined | null): Promise<string>
export function hashSync(input: string | Buffer, cost?: number | undefined | null): string
export function hash(
input: string | Buffer,
cost?: number | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<string>
export function verifySync(input: string | Buffer, hash: string | Buffer): boolean
export function verify(
password: string | Buffer,
hash: string | Buffer,
signal?: AbortSignal | undefined | null,
): Promise<boolean>

@@ -1,44 +0,203 @@

const { loadBinding } = require('@node-rs/helper')
const { existsSync, readFileSync } = require('fs')
const { join } = require('path')
const binding = loadBinding(__dirname, 'bcrypt', '@node-rs/bcrypt')
const { platform, arch } = process
const DEFAULT_COST = 12
let nativeBinding = null
let localFileExisted = false
let isMusl = false
let loadError = null
function verify(password, hash) {
password = Buffer.isBuffer(password) ? password : Buffer.from(password)
hash = Buffer.isBuffer(hash) ? hash : Buffer.from(hash)
return binding.verify(password, hash)
switch (platform) {
case 'android':
if (arch !== 'arm64') {
throw new Error(`Unsupported architecture on Android ${arch}`)
}
localFileExisted = existsSync(join(__dirname, 'bcrypt.android-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.android-arm64.node')
} else {
nativeBinding = require('@node-rs/bcrypt-android-arm64')
}
} catch (e) {
loadError = e
}
break
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'bcrypt.win32-x64-msvc.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.win32-x64-msvc.node')
} else {
nativeBinding = require('@node-rs/bcrypt-win32-x64-msvc')
}
} catch (e) {
loadError = e
}
break
case 'ia32':
localFileExisted = existsSync(join(__dirname, 'bcrypt.win32-ia32-msvc.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.win32-ia32-msvc.node')
} else {
nativeBinding = require('@node-rs/bcrypt-win32-ia32-msvc')
}
} catch (e) {
loadError = e
}
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'bcrypt.win32-arm64-msvc.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.win32-arm64-msvc.node')
} else {
nativeBinding = require('@node-rs/bcrypt-win32-arm64-msvc')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Windows: ${arch}`)
}
break
case 'darwin':
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'bcrypt.darwin-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.darwin-x64.node')
} else {
nativeBinding = require('@node-rs/bcrypt-darwin-x64')
}
} catch (e) {
loadError = e
}
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'bcrypt.darwin-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.darwin-arm64.node')
} else {
nativeBinding = require('@node-rs/bcrypt-darwin-arm64')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on macOS: ${arch}`)
}
break
case 'freebsd':
if (arch !== 'x64') {
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
}
localFileExisted = existsSync(join(__dirname, 'bcrypt.freebsd-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.freebsd-x64.node')
} else {
nativeBinding = require('@node-rs/bcrypt-freebsd-x64')
}
} catch (e) {
loadError = e
}
break
case 'linux':
switch (arch) {
case 'x64':
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
if (isMusl) {
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-x64-musl.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-x64-musl.node')
} else {
nativeBinding = require('@node-rs/bcrypt-linux-x64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-x64-gnu.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-x64-gnu.node')
} else {
nativeBinding = require('@node-rs/bcrypt-linux-x64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 'arm64':
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
if (isMusl) {
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-arm64-musl.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-arm64-musl.node')
} else {
nativeBinding = require('@node-rs/bcrypt-linux-arm64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-arm64-gnu.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-arm64-gnu.node')
} else {
nativeBinding = require('@node-rs/bcrypt-linux-arm64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 'arm':
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-arm-gnueabihf.node'))
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@node-rs/bcrypt-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Linux: ${arch}`)
}
break
default:
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
}
function verifySync(password, hash) {
password = Buffer.isBuffer(password) ? password : Buffer.from(password)
hash = Buffer.isBuffer(hash) ? hash : Buffer.from(hash)
return binding.verifySync(password, hash)
if (!nativeBinding) {
if (loadError) {
throw loadError
}
throw new Error(`Failed to load native binding`)
}
module.exports = {
DEFAULT_COST: DEFAULT_COST,
const { DEFAULT_COST, genSaltSync, genSalt, hashSync, hash, verifySync, verify } = nativeBinding
genSaltSync: function genSaltSync(round = 10, version = '2b') {
return binding.genSaltSync(round, version)
},
genSalt: function genSalt(round = 10, version = '2b') {
return binding.genSalt(round, version)
},
hashSync: function hashSync(password, round = DEFAULT_COST) {
const input = Buffer.isBuffer(password) ? password : Buffer.from(password)
return binding.hashSync(input, round)
},
hash: function hash(password, round = DEFAULT_COST) {
const input = Buffer.isBuffer(password) ? password : Buffer.from(password)
return binding.hash(input, round)
},
verifySync,
verify,
compareSync: verifySync,
compare: verify,
}
module.exports.DEFAULT_COST = DEFAULT_COST
module.exports.genSaltSync = genSaltSync
module.exports.genSalt = genSalt
module.exports.hashSync = hashSync
module.exports.hash = hash
module.exports.verifySync = verifySync
module.exports.verify = verify
{
"name": "@node-rs/bcrypt",
"version": "1.4.2",
"version": "1.5.0",
"description": "Rust bcrypt binding",

@@ -38,2 +38,3 @@ "keywords": [

"aarch64-linux-android",
"armv7-linux-androideabi",
"x86_64-unknown-freebsd",

@@ -59,4 +60,5 @@ "aarch64-unknown-linux-musl",

"bench": "cross-env NODE_ENV=production node benchmark/bcrypt.js",
"build": "napi build --platform --release",
"build:debug": "napi build --platform",
"build": "napi build --platform --release --pipe \"prettier -w\"",
"build:debug": "napi build --platform --pipe \"prettier -w\"",
"prepublishOnly": "napi prepublish",
"version": "napi version"

@@ -67,5 +69,2 @@ },

},
"dependencies": {
"@node-rs/helper": "^1.2.1"
},
"devDependencies": {

@@ -80,16 +79,18 @@ "@types/bcrypt": "^5.0.0",

},
"gitHead": "baa8a4702e3e71b80f2eeebbf3cb6e384a94eb74",
"optionalDependencies": {
"@node-rs/bcrypt-win32-x64-msvc": "1.4.2",
"@node-rs/bcrypt-darwin-x64": "1.4.2",
"@node-rs/bcrypt-linux-x64-gnu": "1.4.2",
"@node-rs/bcrypt-win32-ia32-msvc": "1.4.2",
"@node-rs/bcrypt-linux-arm-gnueabihf": "1.4.2",
"@node-rs/bcrypt-linux-x64-musl": "1.4.2",
"@node-rs/bcrypt-linux-arm64-gnu": "1.4.2",
"@node-rs/bcrypt-darwin-arm64": "1.4.2",
"@node-rs/bcrypt-android-arm64": "1.4.2",
"@node-rs/bcrypt-freebsd-x64": "1.4.2",
"@node-rs/bcrypt-linux-arm64-musl": "1.4.2",
"@node-rs/bcrypt-win32-arm64-msvc": "1.4.2"
"@node-rs/bcrypt-win32-x64-msvc": "1.5.0",
"@node-rs/bcrypt-darwin-x64": "1.5.0",
"@node-rs/bcrypt-linux-x64-gnu": "1.5.0",
"@node-rs/bcrypt-win32-ia32-msvc": "1.5.0",
"@node-rs/bcrypt-linux-arm-gnueabihf": "1.5.0",
"@node-rs/bcrypt-linux-x64-musl": "1.5.0",
"@node-rs/bcrypt-linux-arm64-gnu": "1.5.0",
"@node-rs/bcrypt-darwin-arm64": "1.5.0",
"@node-rs/bcrypt-android-arm64": "1.5.0",
"@node-rs/bcrypt-android-arm-eabi": "1.5.0",
"@node-rs/bcrypt-freebsd-x64": "1.5.0",
"@node-rs/bcrypt-linux-arm64-musl": "1.5.0",
"@node-rs/bcrypt-win32-arm64-msvc": "1.5.0"
}
}

@@ -23,2 +23,3 @@ # `@node-rs/bcrypt`

| Android arm64 | ✓ | ✓ | ✓ |
| Android armv7 | ✓ | ✓ | ✓ |
| FreeBSD x64 | ✓ | ✓ | ✓ |

@@ -25,0 +26,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc