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

nostr-tools

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nostr-tools - npm Package Compare versions

Comparing version 2.2.1 to 2.3.0

15

lib/cjs/nip04.js

@@ -29,2 +29,3 @@ "use strict";

var import_secp256k1 = require("@noble/curves/secp256k1");
var import_aes = require("@noble/ciphers/aes");
var import_base = require("@scure/base");

@@ -37,5 +38,2 @@

// nip04.ts
if (typeof crypto !== "undefined" && !crypto.subtle && crypto.webcrypto) {
crypto.subtle = crypto.webcrypto.subtle;
}
async function encrypt(secretKey, pubkey, text) {

@@ -47,4 +45,3 @@ const privkey = secretKey instanceof Uint8Array ? (0, import_utils.bytesToHex)(secretKey) : secretKey;

let plaintext = utf8Encoder.encode(text);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["encrypt"]);
let ciphertext = await crypto.subtle.encrypt({ name: "AES-CBC", iv }, cryptoKey, plaintext);
let ciphertext = (0, import_aes.cbc)(normalizedKey, iv).encrypt(plaintext);
let ctb64 = import_base.base64.encode(new Uint8Array(ciphertext));

@@ -59,8 +56,6 @@ let ivb64 = import_base.base64.encode(new Uint8Array(iv.buffer));

let normalizedKey = getNormalizedX(key);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["decrypt"]);
let iv = import_base.base64.decode(ivb64);
let ciphertext = import_base.base64.decode(ctb64);
let iv = import_base.base64.decode(ivb64);
let plaintext = await crypto.subtle.decrypt({ name: "AES-CBC", iv }, cryptoKey, ciphertext);
let text = utf8Decoder.decode(plaintext);
return text;
let plaintext = (0, import_aes.cbc)(normalizedKey, iv).decrypt(ciphertext);
return utf8Decoder.decode(plaintext);
}

@@ -67,0 +62,0 @@ function getNormalizedX(key) {

@@ -48,4 +48,2 @@ "use strict";

getMessageKeys(conversationKey, nonce) {
(0, import_utils.ensureBytes)(conversationKey, 32);
(0, import_utils.ensureBytes)(nonce, 32);
const keys = (0, import_hkdf.expand)(import_sha256.sha256, conversationKey, nonce, 76);

@@ -52,0 +50,0 @@ return {

@@ -183,6 +183,4 @@ "use strict";

var import_secp256k12 = require("@noble/curves/secp256k1");
var import_aes = require("@noble/ciphers/aes");
var import_base = require("@scure/base");
if (typeof crypto !== "undefined" && !crypto.subtle && crypto.webcrypto) {
crypto.subtle = crypto.webcrypto.subtle;
}
async function encrypt(secretKey, pubkey, text) {

@@ -194,4 +192,3 @@ const privkey = secretKey instanceof Uint8Array ? (0, import_utils3.bytesToHex)(secretKey) : secretKey;

let plaintext = utf8Encoder.encode(text);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["encrypt"]);
let ciphertext = await crypto.subtle.encrypt({ name: "AES-CBC", iv }, cryptoKey, plaintext);
let ciphertext = (0, import_aes.cbc)(normalizedKey, iv).encrypt(plaintext);
let ctb64 = import_base.base64.encode(new Uint8Array(ciphertext));

@@ -206,8 +203,6 @@ let ivb64 = import_base.base64.encode(new Uint8Array(iv.buffer));

let normalizedKey = getNormalizedX(key);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["decrypt"]);
let iv = import_base.base64.decode(ivb64);
let ciphertext = import_base.base64.decode(ctb64);
let iv = import_base.base64.decode(ivb64);
let plaintext = await crypto.subtle.decrypt({ name: "AES-CBC", iv }, cryptoKey, ciphertext);
let text = utf8Decoder.decode(plaintext);
return text;
let plaintext = (0, import_aes.cbc)(normalizedKey, iv).decrypt(ciphertext);
return utf8Decoder.decode(plaintext);
}

@@ -214,0 +209,0 @@ function getNormalizedX(key) {

@@ -124,6 +124,4 @@ "use strict";

var import_secp256k12 = require("@noble/curves/secp256k1");
var import_aes = require("@noble/ciphers/aes");
var import_base = require("@scure/base");
if (typeof crypto !== "undefined" && !crypto.subtle && crypto.webcrypto) {
crypto.subtle = crypto.webcrypto.subtle;
}
async function encrypt(secretKey, pubkey, text) {

@@ -135,4 +133,3 @@ const privkey = secretKey instanceof Uint8Array ? (0, import_utils3.bytesToHex)(secretKey) : secretKey;

let plaintext = utf8Encoder.encode(text);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["encrypt"]);
let ciphertext = await crypto.subtle.encrypt({ name: "AES-CBC", iv }, cryptoKey, plaintext);
let ciphertext = (0, import_aes.cbc)(normalizedKey, iv).encrypt(plaintext);
let ctb64 = import_base.base64.encode(new Uint8Array(ciphertext));

@@ -139,0 +136,0 @@ let ivb64 = import_base.base64.encode(new Uint8Array(iv.buffer));

@@ -1282,6 +1282,4 @@ var __defProp = Object.defineProperty;

import { secp256k1 } from "@noble/curves/secp256k1";
import { cbc } from "@noble/ciphers/aes";
import { base64 } from "@scure/base";
if (typeof crypto !== "undefined" && !crypto.subtle && crypto.webcrypto) {
crypto.subtle = crypto.webcrypto.subtle;
}
async function encrypt(secretKey, pubkey, text) {

@@ -1293,4 +1291,3 @@ const privkey = secretKey instanceof Uint8Array ? bytesToHex3(secretKey) : secretKey;

let plaintext = utf8Encoder.encode(text);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["encrypt"]);
let ciphertext = await crypto.subtle.encrypt({ name: "AES-CBC", iv }, cryptoKey, plaintext);
let ciphertext = cbc(normalizedKey, iv).encrypt(plaintext);
let ctb64 = base64.encode(new Uint8Array(ciphertext));

@@ -1305,8 +1302,6 @@ let ivb64 = base64.encode(new Uint8Array(iv.buffer));

let normalizedKey = getNormalizedX(key);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["decrypt"]);
let iv = base64.decode(ivb64);
let ciphertext = base64.decode(ctb64);
let iv = base64.decode(ivb64);
let plaintext = await crypto.subtle.decrypt({ name: "AES-CBC", iv }, cryptoKey, ciphertext);
let text = utf8Decoder.decode(plaintext);
return text;
let plaintext = cbc(normalizedKey, iv).decrypt(ciphertext);
return utf8Decoder.decode(plaintext);
}

@@ -1809,3 +1804,3 @@ function getNormalizedX(key) {

import { chacha20 } from "@noble/ciphers/chacha";
import { ensureBytes, equalBytes } from "@noble/ciphers/utils";
import { equalBytes } from "@noble/ciphers/utils";
import { secp256k1 as secp256k12 } from "@noble/curves/secp256k1";

@@ -1830,4 +1825,2 @@ import { extract as hkdf_extract, expand as hkdf_expand } from "@noble/hashes/hkdf";

getMessageKeys(conversationKey, nonce) {
ensureBytes(conversationKey, 32);
ensureBytes(nonce, 32);
const keys = hkdf_expand(sha2562, conversationKey, nonce, 76);

@@ -1834,0 +1827,0 @@ return {

// nip04.ts
import { bytesToHex, randomBytes } from "@noble/hashes/utils";
import { secp256k1 } from "@noble/curves/secp256k1";
import { cbc } from "@noble/ciphers/aes";
import { base64 } from "@scure/base";

@@ -11,5 +12,2 @@

// nip04.ts
if (typeof crypto !== "undefined" && !crypto.subtle && crypto.webcrypto) {
crypto.subtle = crypto.webcrypto.subtle;
}
async function encrypt(secretKey, pubkey, text) {

@@ -21,4 +19,3 @@ const privkey = secretKey instanceof Uint8Array ? bytesToHex(secretKey) : secretKey;

let plaintext = utf8Encoder.encode(text);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["encrypt"]);
let ciphertext = await crypto.subtle.encrypt({ name: "AES-CBC", iv }, cryptoKey, plaintext);
let ciphertext = cbc(normalizedKey, iv).encrypt(plaintext);
let ctb64 = base64.encode(new Uint8Array(ciphertext));

@@ -33,8 +30,6 @@ let ivb64 = base64.encode(new Uint8Array(iv.buffer));

let normalizedKey = getNormalizedX(key);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["decrypt"]);
let iv = base64.decode(ivb64);
let ciphertext = base64.decode(ctb64);
let iv = base64.decode(ivb64);
let plaintext = await crypto.subtle.decrypt({ name: "AES-CBC", iv }, cryptoKey, ciphertext);
let text = utf8Decoder.decode(plaintext);
return text;
let plaintext = cbc(normalizedKey, iv).decrypt(ciphertext);
return utf8Decoder.decode(plaintext);
}

@@ -41,0 +36,0 @@ function getNormalizedX(key) {

// nip44.ts
import { chacha20 } from "@noble/ciphers/chacha";
import { ensureBytes, equalBytes } from "@noble/ciphers/utils";
import { equalBytes } from "@noble/ciphers/utils";
import { secp256k1 } from "@noble/curves/secp256k1";

@@ -23,4 +23,2 @@ import { extract as hkdf_extract, expand as hkdf_expand } from "@noble/hashes/hkdf";

getMessageKeys(conversationKey, nonce) {
ensureBytes(conversationKey, 32);
ensureBytes(nonce, 32);
const keys = hkdf_expand(sha256, conversationKey, nonce, 76);

@@ -27,0 +25,0 @@ return {

@@ -152,6 +152,4 @@ // pure.ts

import { secp256k1 } from "@noble/curves/secp256k1";
import { cbc } from "@noble/ciphers/aes";
import { base64 } from "@scure/base";
if (typeof crypto !== "undefined" && !crypto.subtle && crypto.webcrypto) {
crypto.subtle = crypto.webcrypto.subtle;
}
async function encrypt(secretKey, pubkey, text) {

@@ -163,4 +161,3 @@ const privkey = secretKey instanceof Uint8Array ? bytesToHex2(secretKey) : secretKey;

let plaintext = utf8Encoder.encode(text);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["encrypt"]);
let ciphertext = await crypto.subtle.encrypt({ name: "AES-CBC", iv }, cryptoKey, plaintext);
let ciphertext = cbc(normalizedKey, iv).encrypt(plaintext);
let ctb64 = base64.encode(new Uint8Array(ciphertext));

@@ -175,8 +172,6 @@ let ivb64 = base64.encode(new Uint8Array(iv.buffer));

let normalizedKey = getNormalizedX(key);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["decrypt"]);
let iv = base64.decode(ivb64);
let ciphertext = base64.decode(ctb64);
let iv = base64.decode(ivb64);
let plaintext = await crypto.subtle.decrypt({ name: "AES-CBC", iv }, cryptoKey, ciphertext);
let text = utf8Decoder.decode(plaintext);
return text;
let plaintext = cbc(normalizedKey, iv).decrypt(ciphertext);
return utf8Decoder.decode(plaintext);
}

@@ -183,0 +178,0 @@ function getNormalizedX(key) {

@@ -97,6 +97,4 @@ // pure.ts

import { secp256k1 } from "@noble/curves/secp256k1";
import { cbc } from "@noble/ciphers/aes";
import { base64 } from "@scure/base";
if (typeof crypto !== "undefined" && !crypto.subtle && crypto.webcrypto) {
crypto.subtle = crypto.webcrypto.subtle;
}
async function encrypt(secretKey, pubkey, text) {

@@ -108,4 +106,3 @@ const privkey = secretKey instanceof Uint8Array ? bytesToHex2(secretKey) : secretKey;

let plaintext = utf8Encoder.encode(text);
let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["encrypt"]);
let ciphertext = await crypto.subtle.encrypt({ name: "AES-CBC", iv }, cryptoKey, plaintext);
let ciphertext = cbc(normalizedKey, iv).encrypt(plaintext);
let ctb64 = base64.encode(new Uint8Array(ciphertext));

@@ -112,0 +109,0 @@ let ivb64 = base64.encode(new Uint8Array(iv.buffer));

{
"type": "module",
"name": "nostr-tools",
"version": "2.2.1",
"version": "2.3.0",
"description": "Tools for making a Nostr client.",

@@ -211,3 +211,3 @@ "repository": {

"dependencies": {
"@noble/ciphers": "0.2.0",
"@noble/ciphers": "^0.5.1",
"@noble/curves": "1.2.0",

@@ -214,0 +214,0 @@ "@noble/hashes": "1.3.1",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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