-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a75cfe
commit b3120ca
Showing
4 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
package-lock.json | ||
# Logs | ||
logs | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
# OpenPGP-plugin | ||
# @isomorphic-git/openpgp-plugin | ||
|
||
OpenPGP.js plugin for isomorphic-git 1.x | ||
|
||
## Usage | ||
|
||
```js | ||
const { GitOpenPGP } = require('@isomorphic-git/openpgp-plugin') | ||
const git = require('isomorphic-git') | ||
|
||
git.use(GitOpenPGP) | ||
|
||
// Now you can use git.sign() and git.verify() | ||
``` | ||
|
||
## Tests | ||
|
||
TBD | ||
|
||
## License | ||
|
||
In keeping with the OpenPGP.js license, this project is licensed under the | ||
GNU Lesser General Public License v3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const openpgp = require('openpgp/dist/openpgp.min.js') | ||
|
||
module.exports.GitOpenPGP = { | ||
name: 'GitOpenPGP', | ||
signingHelper: { | ||
async sign ({ payload, secretKey }) { | ||
let { signature } = await openpgp.sign({ | ||
data: payload, | ||
privateKeys: openpgp.key.readArmored(secretKey).keys, | ||
detached: true, | ||
armor: true | ||
}) | ||
return signature | ||
}, | ||
async verify ({ payload, signature, publicKey }) { | ||
// let msg = openpgp.message.readSignedContent(payload, signature) | ||
let {signatures} = await openpgp.verify({ | ||
message: openpgp.message.fromText(payload), | ||
signature: openpgp.signature.readArmored(signature), | ||
publicKeys: openpgp.key.readArmored(publicKey).keys | ||
}) | ||
let invalid = [] | ||
let valid = [] | ||
for (let sig of signatures) { | ||
if (sig.valid) { | ||
valid.push(sig.keyid.toHex()) | ||
} else { | ||
invalid.push(sig.keyid.toHex()) | ||
} | ||
} | ||
// We do this extra mashing to simplify client-side logic that | ||
// is less interested in the values than the presence of values | ||
let result = {} | ||
if (valid.length > 0) result.valid = valid | ||
if (invalid.length > 0) result.invalid = invalid | ||
return result | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@isomorphic-git/openpgp-plugin", | ||
"version": "0.0.0-development", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/isomorphic-git/openpgp-plugin.git" | ||
}, | ||
"keywords": ["isomorphic-git-plugin"], | ||
"author": "William Hilton <wmhilton@gmail.com>", | ||
"license": "LGPL-3.0+", | ||
"bugs": { | ||
"url": "https://github.com/isomorphic-git/openpgp-plugin/issues" | ||
}, | ||
"homepage": "https://github.com/isomorphic-git/openpgp-plugin#readme", | ||
"dependencies": { | ||
"openpgp": "3.0.4" | ||
} | ||
} |