@github-did/lib
Advanced tools
Comparing version 0.0.0 to 0.0.1
{ | ||
"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 | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42817
897
+ Added@types/node@22.10.1(transitive)
+ Added@types/pbkdf2@3.1.2(transitive)
+ Added@types/secp256k1@4.0.6(transitive)
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedasn1.js@5.4.1(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasync@2.6.4(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedbase-x@3.0.10(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbase64url@3.0.1(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedbip39@2.6.0(transitive)
+ Addedbip66@1.1.5(transitive)
+ Addedblakejs@1.2.1(transitive)
+ Addedbn.js@4.12.15.2.1(transitive)
+ Addedbrorand@1.1.0(transitive)
+ Addedbrowserify-aes@1.2.0(transitive)
+ Addedbs58@4.0.1(transitive)
+ Addedbs58check@2.1.2(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedbuffer-xor@1.0.3(transitive)
+ Addedcanonicalize@1.0.8(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcids@0.5.8(transitive)
+ Addedcipher-base@1.0.6(transitive)
+ Addedclass-is@1.1.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addedcreate-hash@1.2.0(transitive)
+ Addedcreate-hmac@1.1.7(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addeddid-resolver@0.0.4(transitive)
+ Addeddrbg.js@1.0.1(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedelliptic@6.6.1(transitive)
+ Addedethereum-cryptography@0.1.3(transitive)
+ Addedethereumjs-util@5.2.1(transitive)
+ Addedethjs-util@0.1.6(transitive)
+ Addedevp_bytestokey@1.0.3(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedfs-extra@7.0.1(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhash-base@3.1.0(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedhdkey@1.1.2(transitive)
+ Addedhmac-drbg@1.0.1(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedipfs-unixfs@0.1.16(transitive)
+ Addedis-hex-prefixed@1.0.0(transitive)
+ Addedis-promise@1.0.1(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjs-sha3@0.8.0(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-deterministic@1.0.12(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addedjsonld@1.8.1(transitive)
+ Addedjsonschema@1.4.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedkeccak@3.0.4(transitive)
+ Addedlibsodium@0.7.15(transitive)
+ Addedlibsodium-wrappers@0.7.15(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedmd5.js@1.3.5(transitive)
+ Addedmerge@2.1.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedminimalistic-crypto-utils@1.0.1(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addedmultibase@0.6.10.7.0(transitive)
+ Addedmulticodec@0.5.7(transitive)
+ Addedmultihashes@0.4.21(transitive)
+ Addedmultihashing-async@0.5.2(transitive)
+ Addedmurmurhash3js@3.0.1(transitive)
+ Addednan@2.22.0(transitive)
+ Addednode-addon-api@2.0.25.1.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednode-forge@0.10.0(transitive)
+ Addednode-gyp-build@4.8.4(transitive)
+ Addednode-localstorage@1.3.1(transitive)
+ Addednodeify@1.0.1(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedopenpgp@4.10.11(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedpbkdf2@3.1.2(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpromise@1.3.0(transitive)
+ Addedprotocol-buffers-schema@3.6.0(transitive)
+ Addedpsl@1.15.0(transitive)
+ Addedpull-stream@3.7.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedrdf-canonize@1.2.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedripemd160@2.0.2(transitive)
+ Addedrlp@2.2.7(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedscrypt-js@3.0.1(transitive)
+ Addedsecp256k1@3.8.14.0.4(transitive)
+ Addedsemver@5.7.26.3.1(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedsha.js@2.4.11(transitive)
+ Addedsigned-varint@2.0.1(transitive)
+ Addedslide@1.1.6(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedstable@0.1.8(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-hex-prefix@1.0.0(transitive)
+ Addedtmp@0.0.33(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addeduniversalify@0.1.2(transitive)
+ Addedunorm@1.6.0(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedvarint@5.0.2(transitive)
+ Addedverror@1.10.0(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedwrite-file-atomic@1.3.4(transitive)
+ Addedxmldom@0.1.19(transitive)