@airgap/beacon-utils
Advanced tools
Comparing version 4.0.4 to 4.0.5
export { keys } from './utils/keys'; | ||
export { ExposedPromise, ExposedPromiseStatus } from './utils/exposed-promise'; | ||
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString, signMessage } from './utils/crypto'; | ||
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString, signMessage, prefixPublicKey } 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.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; | ||
exports.secretbox_MACBYTES = exports.secretbox_NONCEBYTES = exports.generateGUID = exports.prefixPublicKey = 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"); | ||
@@ -20,2 +20,3 @@ Object.defineProperty(exports, "keys", { enumerable: true, get: function () { return keys_1.keys; } }); | ||
Object.defineProperty(exports, "signMessage", { enumerable: true, get: function () { return crypto_1.signMessage; } }); | ||
Object.defineProperty(exports, "prefixPublicKey", { enumerable: true, get: function () { return crypto_1.prefixPublicKey; } }); | ||
var generate_uuid_1 = require("./utils/generate-uuid"); | ||
@@ -22,0 +23,0 @@ Object.defineProperty(exports, "generateGUID", { enumerable: true, get: function () { return generate_uuid_1.generateGUID; } }); |
@@ -59,2 +59,8 @@ /// <reference types="node" /> | ||
/** | ||
* Prefix the public key if it's not prefixed | ||
* | ||
* @param publicKey | ||
*/ | ||
export declare function prefixPublicKey(publicKey: string): Promise<string>; | ||
/** | ||
* Get the recipient string used in the matrix message | ||
@@ -61,0 +67,0 @@ * |
@@ -39,3 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
exports.signMessage = exports.recipientString = exports.prefixPublicKey = 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"); | ||
@@ -237,2 +237,20 @@ var nacl_1 = require("@stablelib/nacl"); | ||
/** | ||
* Prefix the public key if it's not prefixed | ||
* | ||
* @param publicKey | ||
*/ | ||
function prefixPublicKey(publicKey) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var payload; | ||
return __generator(this, function (_a) { | ||
if (publicKey.length !== 64) { | ||
return [2 /*return*/, publicKey]; | ||
} | ||
payload = Buffer.from(publicKey, 'hex'); | ||
return [2 /*return*/, bs58check.encode(Buffer.concat([new Uint8Array([13, 15, 37, 217]), Buffer.from(payload)]))]; | ||
}); | ||
}); | ||
} | ||
exports.prefixPublicKey = prefixPublicKey; | ||
/** | ||
* Get the recipient string used in the matrix message | ||
@@ -239,0 +257,0 @@ * |
export { keys } from './utils/keys'; | ||
export { ExposedPromise, ExposedPromiseStatus } from './utils/exposed-promise'; | ||
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString, signMessage } from './utils/crypto'; | ||
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString, signMessage, prefixPublicKey } 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, signMessage } from './utils/crypto'; | ||
export { getKeypairFromSeed, toHex, getAddressFromPublicKey, decryptCryptoboxPayload, encryptCryptoboxPayload, getHexHash, sealCryptobox, openCryptobox, recipientString, signMessage, prefixPublicKey } from './utils/crypto'; | ||
export { generateGUID } from './utils/generate-uuid'; | ||
@@ -5,0 +5,0 @@ export const secretbox_NONCEBYTES = 24; // crypto_secretbox_NONCEBYTES |
@@ -59,2 +59,8 @@ /// <reference types="node" /> | ||
/** | ||
* Prefix the public key if it's not prefixed | ||
* | ||
* @param publicKey | ||
*/ | ||
export declare function prefixPublicKey(publicKey: string): Promise<string>; | ||
/** | ||
* Get the recipient string used in the matrix message | ||
@@ -61,0 +67,0 @@ * |
@@ -178,2 +178,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
/** | ||
* Prefix the public key if it's not prefixed | ||
* | ||
* @param publicKey | ||
*/ | ||
export function prefixPublicKey(publicKey) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (publicKey.length !== 64) { | ||
return publicKey; | ||
} | ||
const payload = Buffer.from(publicKey, 'hex'); | ||
return bs58check.encode(Buffer.concat([new Uint8Array([13, 15, 37, 217]), Buffer.from(payload)])); | ||
}); | ||
} | ||
/** | ||
* Get the recipient string used in the matrix message | ||
@@ -180,0 +194,0 @@ * |
{ | ||
"name": "@airgap/beacon-utils", | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"description": "> TODO: description", | ||
@@ -43,3 +43,3 @@ "author": "Andreas Gassmann <a.gassmann@papers.ch>", | ||
}, | ||
"gitHead": "a899e914e59303dce16c8048ac3cec76c008a90a" | ||
"gitHead": "1fb3d33bcdb6527b131364101d9dafa0e9c4db61" | ||
} |
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
66808
1099