File tree Expand file tree Collapse file tree 4 files changed +86
-1
lines changed Expand file tree Collapse file tree 4 files changed +86
-1
lines changed Original file line number Diff line number Diff line change
1
+ package-lock.json
1
2
# Logs
2
3
logs
3
4
* .log
Original file line number Diff line number Diff line change 1
- # OpenPGP-plugin
1
+ # @isomorphic-git/openpgp-plugin
2
+
3
+ OpenPGP.js plugin for isomorphic-git 1.x
4
+
5
+ ## Usage
6
+
7
+ ``` js
8
+ const { GitOpenPGP } = require (' @isomorphic-git/openpgp-plugin' )
9
+ const git = require (' isomorphic-git' )
10
+
11
+ git .use (GitOpenPGP)
12
+
13
+ // Now you can use git.sign() and git.verify()
14
+ ```
15
+
16
+ ## Tests
17
+
18
+ TBD
19
+
20
+ ## License
21
+
22
+ In keeping with the OpenPGP.js license, this project is licensed under the
23
+ GNU Lesser General Public License v3.0
Original file line number Diff line number Diff line change
1
+ const openpgp = require ( 'openpgp/dist/openpgp.min.js' )
2
+
3
+ module . exports . GitOpenPGP = {
4
+ name : 'GitOpenPGP' ,
5
+ signingHelper : {
6
+ async sign ( { payload, secretKey } ) {
7
+ let { signature } = await openpgp . sign ( {
8
+ data : payload ,
9
+ privateKeys : openpgp . key . readArmored ( secretKey ) . keys ,
10
+ detached : true ,
11
+ armor : true
12
+ } )
13
+ return signature
14
+ } ,
15
+ async verify ( { payload, signature, publicKey } ) {
16
+ // let msg = openpgp.message.readSignedContent(payload, signature)
17
+ let { signatures} = await openpgp . verify ( {
18
+ message : openpgp . message . fromText ( payload ) ,
19
+ signature : openpgp . signature . readArmored ( signature ) ,
20
+ publicKeys : openpgp . key . readArmored ( publicKey ) . keys
21
+ } )
22
+ let invalid = [ ]
23
+ let valid = [ ]
24
+ for ( let sig of signatures ) {
25
+ if ( sig . valid ) {
26
+ valid . push ( sig . keyid . toHex ( ) )
27
+ } else {
28
+ invalid . push ( sig . keyid . toHex ( ) )
29
+ }
30
+ }
31
+ // We do this extra mashing to simplify client-side logic that
32
+ // is less interested in the values than the presence of values
33
+ let result = { }
34
+ if ( valid . length > 0 ) result . valid = valid
35
+ if ( invalid . length > 0 ) result . invalid = invalid
36
+ return result
37
+ }
38
+ }
39
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " @isomorphic-git/openpgp-plugin" ,
3
+ "version" : " 0.0.0-development" ,
4
+ "description" : " " ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "test" : " echo \" Error: no test specified\" && exit 0"
8
+ },
9
+ "repository" : {
10
+ "type" : " git" ,
11
+ "url" : " git+https://github.com/isomorphic-git/openpgp-plugin.git"
12
+ },
13
+ "keywords" : [" isomorphic-git-plugin" ],
14
+ "author" : " William Hilton <wmhilton@gmail.com>" ,
15
+ "license" : " LGPL-3.0+" ,
16
+ "bugs" : {
17
+ "url" : " https://github.com/isomorphic-git/openpgp-plugin/issues"
18
+ },
19
+ "homepage" : " https://github.com/isomorphic-git/openpgp-plugin#readme" ,
20
+ "dependencies" : {
21
+ "openpgp" : " 3.0.4"
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments