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 3.2.1-beta.1 to 3.2.1-beta.2

2

dist/cjs/index.d.ts
export { keys } from './utils/keys';
export { ExposedPromise, ExposedPromiseStatus } from './utils/exposed-promise';
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString } from './utils/crypto';
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString, signMessage } from './utils/crypto';
export { generateGUID } from './utils/generate-uuid';
export declare const secretbox_NONCEBYTES = 24;
export declare const secretbox_MACBYTES = 16;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.secretbox_MACBYTES = exports.secretbox_NONCEBYTES = exports.generateGUID = exports.recipientString = exports.openCryptobox = exports.sealCryptobox = exports.getHexHash = exports.encryptCryptoboxPayload = exports.decryptCryptoboxPayload = exports.getAddressFromPublicKey = exports.toHex = exports.getKeypairFromSeed = exports.ExposedPromiseStatus = exports.ExposedPromise = exports.keys = void 0;
exports.secretbox_MACBYTES = exports.secretbox_NONCEBYTES = exports.generateGUID = exports.signMessage = exports.recipientString = exports.openCryptobox = exports.sealCryptobox = exports.getHexHash = exports.encryptCryptoboxPayload = exports.decryptCryptoboxPayload = exports.getAddressFromPublicKey = exports.toHex = exports.getKeypairFromSeed = exports.ExposedPromiseStatus = exports.ExposedPromise = exports.keys = void 0;
var keys_1 = require("./utils/keys");

@@ -19,2 +19,3 @@ Object.defineProperty(exports, "keys", { enumerable: true, get: function () { return keys_1.keys; } });

Object.defineProperty(exports, "recipientString", { enumerable: true, get: function () { return crypto_1.recipientString; } });
Object.defineProperty(exports, "signMessage", { enumerable: true, get: function () { return crypto_1.signMessage; } });
var generate_uuid_1 = require("./utils/generate-uuid");

@@ -21,0 +22,0 @@ Object.defineProperty(exports, "generateGUID", { enumerable: true, get: function () { return generate_uuid_1.generateGUID; } });

@@ -65,1 +65,4 @@ /// <reference types="node" />

export declare function recipientString(recipientHash: string, relayServer: string): string;
export declare const signMessage: (message: string, keypair: {
secretKey: Buffer;
}) => Promise<string>;

@@ -39,3 +39,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.recipientString = exports.getAddressFromPublicKey = exports.openCryptobox = exports.sealCryptobox = exports.decryptCryptoboxPayload = exports.encryptCryptoboxPayload = exports.getKeypairFromSeed = exports.getHexHash = exports.toHex = exports.secretbox_MACBYTES = exports.secretbox_NONCEBYTES = void 0;
exports.signMessage = exports.recipientString = exports.getAddressFromPublicKey = exports.openCryptobox = exports.sealCryptobox = exports.decryptCryptoboxPayload = exports.encryptCryptoboxPayload = exports.getKeypairFromSeed = exports.getHexHash = exports.toHex = exports.secretbox_MACBYTES = exports.secretbox_NONCEBYTES = void 0;
var bs58check = require("bs58check");

@@ -50,2 +50,3 @@ var nacl_1 = require("@stablelib/nacl");

var bytes_1 = require("@stablelib/bytes");
var ed25519_3 = require("@stablelib/ed25519");
exports.secretbox_NONCEBYTES = 24; // crypto_secretbox_NONCEBYTES

@@ -246,3 +247,46 @@ exports.secretbox_MACBYTES = 16; // crypto_secretbox_MACBYTES

exports.recipientString = recipientString;
var toBuffer = function (message) { return __awaiter(void 0, void 0, void 0, function () {
var adjustedMessage, buffer;
return __generator(this, function (_a) {
if (message.length % 2 !== 0) {
return [2 /*return*/, (0, utf8_1.encode)(message)];
}
adjustedMessage = message;
if (message.startsWith('0x')) {
adjustedMessage = message.slice(2);
}
buffer = Buffer.from(adjustedMessage, 'hex');
if (buffer.length === adjustedMessage.length / 2) {
return [2 /*return*/, buffer];
}
return [2 /*return*/, (0, utf8_1.encode)(message)];
});
}); };
var coinlibhash = function (message, size) {
if (size === void 0) { size = 32; }
return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, (0, blake2b_1.hash)(message, size)];
});
});
};
var signMessage = function (message, keypair) { return __awaiter(void 0, void 0, void 0, function () {
var bufferMessage, edsigPrefix, hash, rawSignature, signature;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, toBuffer(message)];
case 1:
bufferMessage = _a.sent();
edsigPrefix = new Uint8Array([9, 245, 205, 134, 18]);
return [4 /*yield*/, coinlibhash(bufferMessage)];
case 2:
hash = _a.sent();
rawSignature = (0, ed25519_3.sign)(keypair.secretKey, hash);
signature = bs58check.encode(Buffer.concat([Buffer.from(edsigPrefix), Buffer.from(rawSignature)]));
return [2 /*return*/, signature];
}
});
}); };
exports.signMessage = signMessage;
/* eslint-enable prefer-arrow/prefer-arrow-functions */
//# sourceMappingURL=crypto.js.map
export { keys } from './utils/keys';
export { ExposedPromise, ExposedPromiseStatus } from './utils/exposed-promise';
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString } from './utils/crypto';
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString, signMessage } from './utils/crypto';
export { generateGUID } from './utils/generate-uuid';
export declare const secretbox_NONCEBYTES = 24;
export declare const secretbox_MACBYTES = 16;
export { keys } from './utils/keys';
export { ExposedPromise, ExposedPromiseStatus } from './utils/exposed-promise';
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString } from './utils/crypto';
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString, signMessage } from './utils/crypto';
export { generateGUID } from './utils/generate-uuid';

@@ -5,0 +5,0 @@ export const secretbox_NONCEBYTES = 24; // crypto_secretbox_NONCEBYTES

@@ -65,1 +65,4 @@ /// <reference types="node" />

export declare function recipientString(recipientHash: string, relayServer: string): string;
export declare const signMessage: (message: string, keypair: {
secretKey: Buffer;
}) => Promise<string>;

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

import { concat } from '@stablelib/bytes';
import { sign } from '@stablelib/ed25519';
export const secretbox_NONCEBYTES = 24; // crypto_secretbox_NONCEBYTES

@@ -186,3 +187,28 @@ export const secretbox_MACBYTES = 16; // crypto_secretbox_MACBYTES

}
const toBuffer = (message) => __awaiter(void 0, void 0, void 0, function* () {
if (message.length % 2 !== 0) {
return encode(message);
}
let adjustedMessage = message;
if (message.startsWith('0x')) {
adjustedMessage = message.slice(2);
}
const buffer = Buffer.from(adjustedMessage, 'hex');
if (buffer.length === adjustedMessage.length / 2) {
return buffer;
}
return encode(message);
});
const coinlibhash = (message, size = 32) => __awaiter(void 0, void 0, void 0, function* () {
return hash(message, size);
});
export const signMessage = (message, keypair) => __awaiter(void 0, void 0, void 0, function* () {
const bufferMessage = yield toBuffer(message);
const edsigPrefix = new Uint8Array([9, 245, 205, 134, 18]);
const hash = yield coinlibhash(bufferMessage);
const rawSignature = sign(keypair.secretKey, hash);
const signature = bs58check.encode(Buffer.concat([Buffer.from(edsigPrefix), Buffer.from(rawSignature)]));
return signature;
});
/* eslint-enable prefer-arrow/prefer-arrow-functions */
//# sourceMappingURL=crypto.js.map
{
"name": "@airgap/beacon-utils",
"version": "3.2.1-beta.1",
"version": "3.2.1-beta.2",
"description": "> TODO: description",

@@ -42,3 +42,3 @@ "author": "Andreas Gassmann <a.gassmann@papers.ch>",

},
"gitHead": "17e75c60a566a732dc67308a525e4888296a9def"
"gitHead": "cfefab8abbfb6e7abce7e28999a4c3ef24c50e3d"
}

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

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