[git] GPGME - branch, javascript-binding, updated. gpgme-1.11.1-67-g1105fc8

[email protected] (by Maximilian Krambach)
Newsgroups gmane.comp.encryption.gpg.cvs
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, javascript-binding has been updated
       via  1105fc87a3bd3e1152aff578b7b84871558418e6 (commit)
      from  a52ec87d406379f1a6acd8d4f34605a4bac8683b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1105fc87a3bd3e1152aff578b7b84871558418e6
Author: Maximilian Krambach <[email protected]>
Date:   Wed Jul 4 12:11:35 2018 +0200

    js: add Key lookup
    
    --
    
    * src/Keyring.js: getKeys() now has the option "search", which will
      trigger a remote lookup (as configured in gpg) for the string given
      as pattern.
    * src/permittedOperations: make use of the new 'locate' option in
      keylist
    * DemoExtension: Add a button for lookup, to demonstrate the
      functionality

diff --git a/lang/js/DemoExtension/maindemo.js b/lang/js/DemoExtension/maindemo.js
index d0127c7..4cae934 100644
--- a/lang/js/DemoExtension/maindemo.js
+++ b/lang/js/DemoExtension/maindemo.js
@@ -98,5 +98,22 @@ document.addEventListener('DOMContentLoaded', function() {
                         alert( errormsg.message);
                     });
             });
+        document.getElementById('searchkey').addEventListener('click',
+            function(){
+                let data = document.getElementById('inputtext').value;
+                gpgmejs.Keyring.getKeys(data, true, true).then(function(keys){
+                    if (keys.length === 1){
+                        document.getElementById(
+                            'pubkey').value = keys[0].fingerprint;
+                    } else if (keys.length > 1) {
+                        alert('The pattern was not unambigious enough for a Key. '
+                        + keys.length + ' Keys were found');
+                    } else {
+                        alert('No keys found');
+                    }
+                }, function(errormsg){
+                    alert( errormsg.message);
+                });
+            });
     });
 });
diff --git a/lang/js/DemoExtension/mainui.html b/lang/js/DemoExtension/mainui.html
index b639036..c773c9b 100644
--- a/lang/js/DemoExtension/mainui.html
+++ b/lang/js/DemoExtension/mainui.html
@@ -17,9 +17,13 @@
                 </li>
                 <li>
                     <span class="label">Fingerprint of Key to use: </span>
-                </li>
-                    <input type="text" id="pubkey" value="" /> <br>
-                    <button id="getdefaultkey">Set to default signing key</button>
+                    <input type="text" id="pubkey" value="" />
+                        <button id="getdefaultkey">
+                            Set to default signing key
+                        </button>&nbsp;
+                        <button id="searchkey">
+                            Look up Key
+                        </button>
                 </li>
             </ul>
         </div>
diff --git a/lang/js/src/Keyring.js b/lang/js/src/Keyring.js
index 8bec1ce..0d7643f 100644
--- a/lang/js/src/Keyring.js
+++ b/lang/js/src/Keyring.js
@@ -39,16 +39,21 @@ export class GPGME_Keyring {
      * inmediately. This allows for full synchronous use. If set to false,
      * these will initially only be available as Promises in getArmor() and
      * getHasSecret()
+     * @param {Boolean} search (optional) retrieve the Keys from servers with
+     * the method(s) defined in gnupg (e.g. WKD/HKP lookup)
      * @returns {Promise.<Array<GPGME_Key>>}
      *
      */
-    getKeys(pattern, prepare_sync){
+    getKeys(pattern, prepare_sync, search){
         return new Promise(function(resolve, reject) {
             let msg = createMessage('keylist');
             if (pattern !== undefined){
                 msg.setParameter('keys', pattern);
             }
             msg.setParameter('sigs', true);
+            if (search === true){
+                msg.setParameter('locate', true);
+            }
             msg.post().then(function(result){
                 let resultset = [];
                 let promises = [];
diff --git a/lang/js/src/permittedOperations.js b/lang/js/src/permittedOperations.js
index 312eaa5..e7f5396 100644
--- a/lang/js/src/permittedOperations.js
+++ b/lang/js/src/permittedOperations.js
@@ -188,6 +188,9 @@ export const permittedOperations = {
             'local':{
                 allowed: ['boolean']
             },
+            'locate': {
+                allowed: ['boolean']
+            },
             'sigs':{
                 allowed: ['boolean']
             },

-----------------------------------------------------------------------

Summary of changes:
 lang/js/DemoExtension/maindemo.js  | 17 +++++++++++++++++
 lang/js/DemoExtension/mainui.html  | 10 +++++++---
 lang/js/src/Keyring.js             |  7 ++++++-
 lang/js/src/permittedOperations.js |  3 +++
 4 files changed, 33 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.