New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@airgap/beacon-utils

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@airgap/beacon-utils - npm Package Compare versions

Comparing version 0.0.1-beta.4 to 0.0.1-beta.5

2

dist/cjs/utils/crypto.d.ts
/// <reference types="node" />
import * as sodium from 'libsodium-wrappers';
import sodium from 'libsodium-wrappers';
/**

@@ -4,0 +4,0 @@ * Convert a value to hex

@@ -57,6 +57,9 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.recipientString = exports.getAddressFromPublicKey = exports.openCryptobox = exports.sealCryptobox = exports.decryptCryptoboxPayload = exports.encryptCryptoboxPayload = exports.getKeypairFromSeed = exports.getHexHash = exports.toHex = void 0;
var bs58check = __importStar(require("bs58check"));
var sodium = __importStar(require("libsodium-wrappers"));
var libsodium_wrappers_1 = __importDefault(require("libsodium-wrappers"));
/* eslint-disable prefer-arrow/prefer-arrow-functions */

@@ -82,6 +85,6 @@ /**

switch (_a.label) {
case 0: return [4 /*yield*/, sodium.ready];
case 0: return [4 /*yield*/, libsodium_wrappers_1.default.ready];
case 1:
_a.sent();
return [2 /*return*/, toHex(sodium.crypto_generichash(32, key))];
return [2 /*return*/, toHex(libsodium_wrappers_1.default.crypto_generichash(32, key))];
}

@@ -101,6 +104,6 @@ });

switch (_a.label) {
case 0: return [4 /*yield*/, sodium.ready];
case 0: return [4 /*yield*/, libsodium_wrappers_1.default.ready];
case 1:
_a.sent();
return [2 /*return*/, sodium.crypto_sign_seed_keypair(sodium.crypto_generichash(32, sodium.from_string(seed)))];
return [2 /*return*/, libsodium_wrappers_1.default.crypto_sign_seed_keypair(libsodium_wrappers_1.default.crypto_generichash(32, libsodium_wrappers_1.default.from_string(seed)))];
}

@@ -122,9 +125,9 @@ });

switch (_a.label) {
case 0: return [4 /*yield*/, sodium.ready];
case 0: return [4 /*yield*/, libsodium_wrappers_1.default.ready];
case 1:
_a.sent();
nonce = Buffer.from(sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES));
nonce = Buffer.from(libsodium_wrappers_1.default.randombytes_buf(libsodium_wrappers_1.default.crypto_secretbox_NONCEBYTES));
combinedPayload = Buffer.concat([
nonce,
Buffer.from(sodium.crypto_secretbox_easy(Buffer.from(message, 'utf8'), nonce, sharedKey))
Buffer.from(libsodium_wrappers_1.default.crypto_secretbox_easy(Buffer.from(message, 'utf8'), nonce, sharedKey))
]);

@@ -148,8 +151,8 @@ return [2 /*return*/, toHex(combinedPayload)];

switch (_a.label) {
case 0: return [4 /*yield*/, sodium.ready];
case 0: return [4 /*yield*/, libsodium_wrappers_1.default.ready];
case 1:
_a.sent();
nonce = payload.slice(0, sodium.crypto_secretbox_NONCEBYTES);
ciphertext = payload.slice(sodium.crypto_secretbox_NONCEBYTES);
return [2 /*return*/, Buffer.from(sodium.crypto_secretbox_open_easy(ciphertext, nonce, sharedKey)).toString('utf8')];
nonce = payload.slice(0, libsodium_wrappers_1.default.crypto_secretbox_NONCEBYTES);
ciphertext = payload.slice(libsodium_wrappers_1.default.crypto_secretbox_NONCEBYTES);
return [2 /*return*/, Buffer.from(libsodium_wrappers_1.default.crypto_secretbox_open_easy(ciphertext, nonce, sharedKey)).toString('utf8')];
}

@@ -171,8 +174,8 @@ });

switch (_a.label) {
case 0: return [4 /*yield*/, sodium.ready];
case 0: return [4 /*yield*/, libsodium_wrappers_1.default.ready];
case 1:
_a.sent();
kxSelfPublicKey = sodium.crypto_sign_ed25519_pk_to_curve25519(Buffer.from(publicKey)) // Secret bytes to scalar bytes
kxSelfPublicKey = libsodium_wrappers_1.default.crypto_sign_ed25519_pk_to_curve25519(Buffer.from(publicKey)) // Secret bytes to scalar bytes
;
encryptedMessage = sodium.crypto_box_seal(payload, kxSelfPublicKey);
encryptedMessage = libsodium_wrappers_1.default.crypto_box_seal(payload, kxSelfPublicKey);
return [2 /*return*/, toHex(encryptedMessage)];

@@ -196,10 +199,10 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, sodium.ready];
case 0: return [4 /*yield*/, libsodium_wrappers_1.default.ready];
case 1:
_a.sent();
kxSelfPrivateKey = sodium.crypto_sign_ed25519_sk_to_curve25519(Buffer.from(privateKey)) // Secret bytes to scalar bytes
kxSelfPrivateKey = libsodium_wrappers_1.default.crypto_sign_ed25519_sk_to_curve25519(Buffer.from(privateKey)) // Secret bytes to scalar bytes
;
kxSelfPublicKey = sodium.crypto_sign_ed25519_pk_to_curve25519(Buffer.from(publicKey)) // Secret bytes to scalar bytes
kxSelfPublicKey = libsodium_wrappers_1.default.crypto_sign_ed25519_pk_to_curve25519(Buffer.from(publicKey)) // Secret bytes to scalar bytes
;
decryptedMessage = sodium.crypto_box_seal_open(encryptedPayload, kxSelfPublicKey, kxSelfPrivateKey);
decryptedMessage = libsodium_wrappers_1.default.crypto_box_seal_open(encryptedPayload, kxSelfPublicKey, kxSelfPrivateKey);
return [2 /*return*/, Buffer.from(decryptedMessage).toString()];

@@ -221,3 +224,3 @@ }

switch (_b.label) {
case 0: return [4 /*yield*/, sodium.ready];
case 0: return [4 /*yield*/, libsodium_wrappers_1.default.ready];
case 1:

@@ -261,3 +264,3 @@ _b.sent();

}
payload = sodium.crypto_generichash(20, Buffer.from(plainPublicKey, 'hex'));
payload = libsodium_wrappers_1.default.crypto_generichash(20, Buffer.from(plainPublicKey, 'hex'));
return [2 /*return*/, bs58check.encode(Buffer.concat([prefix, Buffer.from(payload)]))];

@@ -264,0 +267,0 @@ }

/// <reference types="node" />
import * as sodium from 'libsodium-wrappers';
import sodium from 'libsodium-wrappers';
/**

@@ -4,0 +4,0 @@ * Convert a value to hex

@@ -11,3 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import * as bs58check from 'bs58check';
import * as sodium from 'libsodium-wrappers';
import sodium from 'libsodium-wrappers';
/* eslint-disable prefer-arrow/prefer-arrow-functions */

@@ -14,0 +14,0 @@ /**

{
"name": "@airgap/beacon-utils",
"version": "0.0.1-beta.4",
"version": "0.0.1-beta.5",
"description": "> TODO: description",

@@ -36,3 +36,3 @@ "author": "Andreas Gassmann <andreas@andreasgassmann.ch>",

},
"gitHead": "e1fa737a1879c772fa882f9d2d997f5ac439f37f"
"gitHead": "85337526d2d7599e17b89c202a3aa82b63782785"
}

Sorry, the diff of this file is not supported yet

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