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

@1auth/crypto

Package Overview
Dependencies
Maintainers
0
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@1auth/crypto - npm Package Compare versions

Comparing version 0.0.0-alpha.40 to 0.0.0-alpha.41

48

index.js

@@ -7,2 +7,4 @@ import { promisify } from 'node:util'

createDecipheriv,
createHmac,
timingSafeEqual,
generateKeyPair as generateKeyPairCallback,

@@ -26,2 +28,3 @@ sign as signCallback,

digestAlgorithm: 'sha3-384',
hmacAlgorithm: 'sha256',
signatureEncoding: 'base64'

@@ -384,3 +387,7 @@ }

export const makeSignature = async (data, privateKey, { algorithm } = {}) => {
export const makeAsymmetricSignature = async (
data,
privateKey,
{ algorithm } = {}
) => {
algorithm ??= options.digestAlgorithm

@@ -391,3 +398,3 @@ return (await sign(algorithm, Buffer.from(data), privateKey)).toString(

}
export const verifySignature = async (
export const verifyAsymmetricSignature = async (
data,

@@ -406,1 +413,38 @@ publicKey,

}
export const makeSymmetricSignature = (
data,
encryptionKey,
{ algorithm } = {}
) => {
encryptionKey ??= options.symetricEncryptionKey
algorithm ??= options.hmacAlgorithm
const signature = createHmac('sha256', encryptionKey)
.update(data)
.digest('base64')
.replace(/=+$/, '')
const signedData = data + '.' + signature
return signedData
}
export const verifySymmetricSignature = (
signedData,
encryptionKey,
{ algorithm } = {}
) => {
const data = signedData.slice(0, signedData.lastIndexOf('.'))
const signedDataExpected = makeSymmetricSignature(data, encryptionKey, {
algorithm
})
return safeEqual(signedData, signedDataExpected) && data
}
export const safeEqual = (input, expected) => {
const bufferInput = Buffer.from(input)
const bufferExpected = Buffer.from(expected)
return (
bufferInput.length === bufferExpected.length &&
timingSafeEqual(bufferInput, bufferExpected)
)
}

2

package.json
{
"name": "@1auth/crypto",
"version": "0.0.0-alpha.40",
"version": "0.0.0-alpha.41",
"description": "",

@@ -5,0 +5,0 @@ "type": "module",

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