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

@github-did/lib

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@github-did/lib - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

4

package.json
{
"name": "@github-did/lib",
"version": "0.0.0",
"version": "0.0.1",
"description": "Github DID Library",

@@ -21,3 +21,3 @@ "main": "./src/index.js",

"@transmute/openpgpsignature2019": "^0.1.1",
"@transmute/transmute-did": "^1.0.2-0",
"@transmute/transmute-did": "^1.1.8",
"node-fetch": "^2.3.0",

@@ -24,0 +24,0 @@ "openpgp": "^4.4.3",

@@ -6,3 +6,5 @@ const fetch = require("node-fetch");

constructDIDPublicKeyID,
DIDLinkedDataSignatureVerifier
DIDLinkedDataSignatureVerifier,
TransmuteDIDWallet,
getPublicKeyFromDIDDocByKID
} = require("@transmute/transmute-did");

@@ -23,2 +25,20 @@

const cipherTextWalletJsonToPlainTextWalletJson = async (
cipherTextWalletJson,
password
) => {
const instance = new TransmuteDIDWallet(cipherTextWalletJson);
await instance.decrypt(password);
return instance.data;
};
const plainTextWalletJsonToCipherTextWalletJson = async (
plainTextWalletJson,
password
) => {
const instance = new TransmuteDIDWallet(plainTextWalletJson);
await instance.encrypt(password);
return instance.data;
};
const createDID = (method, user, repo, kid) => {

@@ -149,2 +169,49 @@ return `did:${method}:${user}~${repo}~${kid}`;

const getPublicKeyByKeyId = async keyId => {
const document = await resolver.resolve(keyId.split("#kid=")[0]);
return await getPublicKeyFromDIDDocByKID(document, keyId);
};
const encryptFor = async ({
fromKeyId,
toKeyId,
publicKey,
privateKey,
data
}) => {
const message = JSON.stringify(data);
const options = {
message: openpgp.message.fromText(message), // input as String (or Uint8Array)
publicKeys: (await openpgp.key.readArmored(publicKey)).keys, // for encryption
privateKeys: [privateKey] // for signing (optional)
};
const cipherText = await openpgp.encrypt(options).then(ciphertext => {
const encrypted = ciphertext.data; // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
return encrypted;
});
return {
fromKeyId,
toKeyId,
cipherText
};
};
const decryptFor = async ({ fromKeyId, cipherText, privateKey }) => {
const publicKey = await getPublicKeyByKeyId(fromKeyId);
const options = {
message: await openpgp.message.readArmored(cipherText), // parse armored message
publicKeys: (await openpgp.key.readArmored(publicKey)).keys, // for verification (optional)
privateKeys: [privateKey] // for decryption
};
const plainText = await openpgp
.decrypt(options)
.then(plaintext => plaintext.data);
return JSON.parse(plainText);
};
module.exports = {

@@ -160,3 +227,8 @@ constructDIDPublicKeyID,

verifyCapability,
resolver
resolver,
cipherTextWalletJsonToPlainTextWalletJson,
plainTextWalletJsonToCipherTextWalletJson,
getPublicKeyByKeyId,
encryptFor,
decryptFor
};
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