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

@1auth/crypto

Package Overview
Dependencies
Maintainers
1
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.10 to 0.0.0-alpha.11

42

./index.js

@@ -262,12 +262,15 @@ import { promisify } from 'node:util'

// assocData = sub or id
export const encryptFields = (values, encryptedKey, assocData, fields = []) => {
// TODO optimize: don't decrypt encryptedKey more than once
for (const key of fields) {
values[key] &&= encrypt(values[key], encryptedKey, assocData)
}
return values
}
export const encrypt = (data, encryptedKey, assocData) => {
if (!encryptedKey) return data
const encryptionKey = __decrypt(
encryptedKey,
Buffer.from(options.encryptionSharedKey, 'hex'),
assocData,
'hex',
'hex'
)
const encryptionKey = __decryptKey(encryptedKey, assocData)
return __encrypt(

@@ -304,11 +307,13 @@ data,

export const decryptFields = (values, encryptedKey, assocData, fields = []) => {
// TODO optimize: don't decrypt encryptedKey more than once
for (const key of fields) {
values[key] &&= decrypt(values[key], encryptedKey, assocData)
}
return values
}
export const decrypt = (encryptedData, encryptedKey, assocData) => {
if (!options.encryptionSharedKey || !encryptedKey) return encryptedData
const encryptionKey = __decrypt(
encryptedKey,
Buffer.from(options.encryptionSharedKey, 'hex'),
assocData,
'hex',
'hex'
)
const encryptionKey = __decryptKey(encryptedKey, assocData)
const data = __decrypt(

@@ -324,2 +329,11 @@ encryptedData,

const __decryptKey = (encryptedKey, assocData) =>
__decrypt(
encryptedKey,
Buffer.from(options.encryptionSharedKey, 'hex'),
assocData,
'hex',
'hex'
)
const __decrypt = (

@@ -326,0 +340,0 @@ data,

@@ -262,12 +262,15 @@ import { promisify } from 'node:util'

// assocData = sub or id
export const encryptFields = (values, encryptedKey, assocData, fields = []) => {
// TODO optimize: don't decrypt encryptedKey more than once
for (const key of fields) {
values[key] &&= encrypt(values[key], encryptedKey, assocData)
}
return values
}
export const encrypt = (data, encryptedKey, assocData) => {
if (!encryptedKey) return data
const encryptionKey = __decrypt(
encryptedKey,
Buffer.from(options.encryptionSharedKey, 'hex'),
assocData,
'hex',
'hex'
)
const encryptionKey = __decryptKey(encryptedKey, assocData)
return __encrypt(

@@ -304,11 +307,13 @@ data,

export const decryptFields = (values, encryptedKey, assocData, fields = []) => {
// TODO optimize: don't decrypt encryptedKey more than once
for (const key of fields) {
values[key] &&= decrypt(values[key], encryptedKey, assocData)
}
return values
}
export const decrypt = (encryptedData, encryptedKey, assocData) => {
if (!options.encryptionSharedKey || !encryptedKey) return encryptedData
const encryptionKey = __decrypt(
encryptedKey,
Buffer.from(options.encryptionSharedKey, 'hex'),
assocData,
'hex',
'hex'
)
const encryptionKey = __decryptKey(encryptedKey, assocData)
const data = __decrypt(

@@ -324,2 +329,11 @@ encryptedData,

const __decryptKey = (encryptedKey, assocData) =>
__decrypt(
encryptedKey,
Buffer.from(options.encryptionSharedKey, 'hex'),
assocData,
'hex',
'hex'
)
const __decrypt = (

@@ -326,0 +340,0 @@ data,

{
"name": "@1auth/crypto",
"version": "0.0.0-alpha.10",
"version": "0.0.0-alpha.11",
"description": "",

@@ -51,3 +51,3 @@ "type": "module",

"homepage": "https://github.com/willfarrell/1auth",
"gitHead": "40d015ce640f9813d809fddb847f60974c596b46",
"gitHead": "7dbe007253726b9dfc6bb9c089cb4dcb19c0fee5",
"dependencies": {

@@ -54,0 +54,0 @@ "@node-rs/argon2": "1.5.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