[git] GPGME - branch, javascript-binding, updated. gpgme-1.10.0-184-geef3a50

by raimund.renkert@intevation.de cvs at cvs.gnupg.org
Tue Apr 10 18:55:33 CEST 2018


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  eef3a509fa5744e5f09ec8084985e6070b78226b (commit)
       via  5eb261d6028ab2c0ddd9af8e3e1f82e479c6109c (commit)
       via  fed024eff1091056647296ac589a0c88c2be41bb (commit)
       via  60d7a1e8f625ea0db455bff989534dd52f0650c7 (commit)
       via  75a1a1c33efe952986bba56494b81e2f4835b8c4 (commit)
       via  3b91f6af378ccc37dcf8924cbc157894c35b5192 (commit)
       via  d65864989c0560b5f51cb8d05d9ea9f1957b453e (commit)
       via  56bbfd39acea90eb87a28b11a515b0314cdda54c (commit)
       via  5a553f5a317e5ad5ab0274d58854df1ecf390e0d (commit)
       via  2f507b045909d32bf29d23da04db02b078e5fb9d (commit)
       via  5cd419341807d8ae23fec7bd9bb7025a8a2dcb3c (commit)
       via  3345a17dda2222e3c1592235e8a1cd9493192777 (commit)
       via  4b2fa657d195382d14ac99be40b66327e0fc855c (commit)
       via  7c220e387d511b0cf66f99370759c36b729cc444 (commit)
       via  a2eedef630891397f8eccb5bb426a0728588bf41 (commit)
       via  f9159b1d75d3209b1c22bbb0ed4472800b60a522 (commit)
       via  1b5da37a47ceef41545e0b2474738613f36be949 (commit)
       via  5b32efbaf37920b2e99d4bb87cb383b2809b1688 (commit)
       via  40a9dea5d56506400b67b0c11f6e55a1629dc6fe (commit)
       via  3b724aae423f2de01812165d54df2a7b524c82f6 (commit)
       via  dde1aae312958776fab475d6c0cdfa19cc255863 (commit)
       via  22247f658ce2f8e527c26746358cfc2643c4832f (commit)
       via  d0bb4ec4ecdfae4dfd9dd84aef905afb490013d5 (commit)
       via  e6180f2b36cc8a6c6154e5f3d702324af573132a (commit)
       via  4763974ef6932c503e35c3d14fe47a66a5323f48 (commit)
       via  e5abf4827aead50437bbdff8cfdd5e9fdc6ed72d (commit)
       via  b9000bc293164ff62efa7e91e5cf6d5fc19d482f (commit)
       via  eee68c1b13fbe21c123f469712817e0c81f16383 (commit)
       via  c7bb12da5297a7e188766d9759f700dd771faff8 (commit)
       via  65ed4ac82598734551b87fc89deab3cee010bd37 (commit)
       via  5722148bacab5862b40a027861d64683a0f214ea (commit)
       via  76055dd5c7d755c6f8a242b701aeadba621fbc0f (commit)
       via  05e59933056ee8ef8ba7579351a58ed25dd7f754 (commit)
       via  61a988036bd3f0d43f7d55bfa43f5f05bec978c4 (commit)
       via  7ddff71908a85111c8e0da41312197b3b1a77da6 (commit)
       via  c6a0395f0a3a57071f0c943f7815f58a02f9d2f3 (commit)
       via  0a0d57fd41380cd797d29e11cec8a77c7404e960 (commit)
       via  0ccc57c9512246d82d46e7732bfb0f95c18ca9d3 (commit)
       via  8b401bfc76eac762553f76faab53c2f4cd117a8d (commit)
       via  6c6af9a7b0ae4e7182d669bec282c6edaaa7eaa1 (commit)
       via  a4e3f827652c59d850b4e5506a92c1ecd190c1bb (commit)
       via  ad6cb4f9b8b97a2bc501c17fc542a84b725dedea (commit)
       via  ae2767eb27b6a76284ee4403e575869afe2e80a8 (commit)
       via  e57388a69f61d14e3df3c842d227fb450c96c807 (commit)
       via  ac6a552c37147a000de74f49d1bff34dad52252e (commit)
       via  af6cbba18ba5e2bbecce5f8268c146282cd12367 (commit)
       via  6fa2a344282e369e6aca8155bc77dd2c12a29414 (commit)
       via  1fdd1f306d45f6aeee91c7f016f7c37286ee3b3b (commit)
       via  1d2746433c9632fc0c7bc10b59280fca15895545 (commit)
       via  0390ede18696520be9cc1a42f628e23159b7c2eb (commit)
       via  52e262991f1fdf7da93882c3b22c05537376cf49 (commit)
       via  96d0395bccbbff91f73c06cb7bd6c131f04b8a9a (commit)
       via  51258975d763c9471859d635e6080c2ec02e8647 (commit)
       via  29e918171f352c71a90a16c04d4a3dcafa5db682 (commit)
       via  7221bb67642eb01a07957d66d0cbcd4ef8aadbf8 (commit)
       via  f3fe47e8fd2e7bc748016befcae494421223368c (commit)
       via  f0790f224d7af9521efe96e69a8f719fb89a5af2 (commit)
       via  7ab42e79ade89f28507ea42d51148a40b4bfc736 (commit)
       via  cfbdcb7fb3fa438cafba82e4fb8f327df596f98e (commit)
       via  b30ebf89725641018b3b08f77876530f9b983fa2 (commit)
       via  8f7672ad1b267f122f647bb5f984734d0ff66a5c (commit)
       via  6950a63e63d60685ddb6f4cbff7b826b8acb5b13 (commit)
       via  3e0f68fdff1998dae9cb6f8510a3e945a268d1f6 (commit)
       via  d5f6dec048d3d4d94f1fcdb3f4249cf6e71c4b92 (commit)
       via  0fb8a5d45c1c77a5928d6e356271da055aa55994 (commit)
       via  bf67cf433fe82924ed40e79785e95403c07cc068 (commit)
       via  1779d7b9d6769b2e47f1e90260290e25c8c3aa02 (commit)
       via  64c5886132aceefc9d9600a3a6dbbbf404b95b81 (commit)
       via  4811ff7b6c8ef97c7d4858ce235e9bf8227f4917 (commit)
       via  82c5af225f2bdf3acc6fc652a96ee61c9b057395 (commit)
       via  b549f69d0520bb74957b95cec9ea918dba2374f6 (commit)
       via  431897a4c48fe1bc9d37f655097aabaf5b685d11 (commit)
       via  22e2445beee46ed1e527a98e635153c7cf03786f (commit)
       via  94a95ac12364989db7f4be333107f3c023551857 (commit)
       via  3d0c7a2202c8e9bd4f284fd00069d34b8d3d3d4c (commit)
       via  961aea212ef48914ecbfa169addf951b0854b0b4 (commit)
       via  7ac65b10837740caf68cdade791b8c5ce4eb1b03 (commit)
       via  9e3e4a835c64f5d06de821b1fd648af37827ff26 (commit)
       via  b02d9d0a7b96b186eb3063d94bde369339181461 (commit)
       via  5432e5f9d1dfc02812d0b181f8d88cdf4a2bfbfb (commit)
       via  5d1dd2abe5cf787875d12afe46c78c75385d7b31 (commit)
       via  1d05e6aa4ea467c8c5926b827cfcfba357d03312 (commit)
       via  b35aaef7a3b793b8f6f5b42596c0a6a51e87f78c (commit)
       via  6bc12a0eeb20409770cb8b923d08c18c2b730cb8 (commit)
       via  e5c85fba25de1187949697e2dae0e89345b71e89 (commit)
       via  ada059b07178147821b1598c935aa70ae45e3e6c (commit)
       via  ef27f3781a37e264d0eb7d1745eb2c804ec062c4 (commit)
       via  423fdcd4653cb01f07f2b0e72cfcf49554930f70 (commit)
       via  a71205dc3b58970adf591b4e4553824a33f353db (commit)
       via  a10dcb4f138eb5a21881cdbc4806c25129d4ae4e (commit)
       via  952b6042f78017c476452088261af8d352cfa729 (commit)
       via  c92da2c7eb148ce9fb06495a8470dd9caf662f9a (commit)
       via  e489ddd08af29fdad8db8aa0aec0c314daa3678c (commit)
       via  f29bda8d7146b4bc0bf73d6e613131545ff86b73 (commit)
       via  c27a7a3f994dad0eccee890185582f4350fbf233 (commit)
       via  f81adeba992a9fd3b5a199e9a2e242a0f53cf639 (commit)
       via  36dfbdffea60c529a6d1e1ff3e507be016b6a0f6 (commit)
       via  484e9a6229ac9c80c6be4df638bce711f08a74c6 (commit)
       via  a8f48b6f577d562c25fd0191c0cc2cc8e96078c1 (commit)
       via  83b1336ceebb86e13a55bbf220df2d750f6b3ec6 (commit)
       via  0e1300ce777dd0c87f31ac8bc49846b9df242df9 (commit)
       via  7ebc5a357057d01b7ef965521ab68b7cb7e20a8f (commit)
       via  172baaf4d3e4ed03a4d3437be9efa3dfe6a847bc (commit)
       via  f2c1e8d8d54068a7f072efa178fc30460821eff3 (commit)
       via  01686463948ac6096dd8579a110c478d3a1f9a83 (commit)
       via  93252df9dc4c9932467814745655350a8cab900e (commit)
       via  ab81c2d868bba79fdb8f8d7f576b6bd88c6bdf3c (commit)
       via  f685cda281c6148072e8a6cd139c990cb041ea3d (commit)
       via  fa4927146b68dd045903285f1c45fb64deb2e361 (commit)
       via  c767a4a3590bd8a224d0268746df443942cb28c2 (commit)
       via  75463d589522cba427f9e5a3a408192ffad8bb21 (commit)
       via  a98f2c556fe6e33a9cd38279e64e4b09f05cc675 (commit)
       via  e8adab68f8c0cd865ff220f06dfaff7fe183e8a1 (commit)
       via  47d401d159852ea08e90af21d91bb4b93be9000d (commit)
       via  8a76deb11efd7dadfde6e8e7e69fbcd92577982f (commit)
       via  5215d58ae2521d81c3db0b45dfbdce01a679acab (commit)
       via  8f2c0f4534ea2a07f071f360a63e877f60dc52f2 (commit)
       via  d4778bb23d0817ee6fbcbe4f0ff0ff0429bf3669 (commit)
       via  3a746d5d46ffd7d332dc24fd6a4d24efc5fc1230 (commit)
       via  13d2164cd9f313b409b2210d9e63465681cccc99 (commit)
       via  1516c56ee4da28eb720bbacb026892393d10b24a (commit)
       via  f61d4f585f27c13fabf7a23ad295bdc8bea7c838 (commit)
      from  d83482a1d768fc5afd3aa4836f2fefe5c549d02e (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 eef3a509fa5744e5f09ec8084985e6070b78226b
Author: raimund.renkert at intevation.de <raimund.renkert at intevation.de>
Date:   Tue Apr 10 11:33:14 2018 +0200

    js: Initial commit for JavaScript Native Messaging API
    
    --
    
    Note this code misses all the legal boilerplate; please add this as
    soon as possible and provide a DCO so we can merge it into master.
    
    I also removed the dist/ directory because that was not source code.

diff --git a/lang/README b/lang/README
index ee99f0f..afd7b08 100644
--- a/lang/README
+++ b/lang/README
@@ -13,4 +13,4 @@ cl		Common Lisp
 cpp		C++
 qt		Qt-Framework API
 python		Python 2 and 3 (module name: gpg)
-javascript      Native messaging client for the gpgme-json server.
+js              Native messaging client for the gpgme-json server.
diff --git a/lang/js/CHECKLIST b/lang/js/CHECKLIST
new file mode 100644
index 0000000..79a35cb
--- /dev/null
+++ b/lang/js/CHECKLIST
@@ -0,0 +1,30 @@
+NativeConnection:
+
+    [X] nativeConnection: successfully sending an encrypt request,
+receiving an answer
+    [X] nativeConnection successfull on Chromium, chrome and firefox
+    [ ] nativeConnection successfull on Windows, macOS, Linux
+    [ ] nativeConnection with delayed, multipart (> 1MB) answer
+
+replicating Openpgpjs API:
+
+    [*] Message handling (encrypt, verify, sign)
+    [ ] Key handling (import/export, modifying, status queries)
+    [ ] Configuration handling
+    [ ] check for completeness
+    [ ] handling of differences to openpgpjs
+
+Communication with other implementations
+
+    [ ] option to export SECRET Key into localstore used by e.g. mailvelope
+
+Management:
+    [*] Define the gpgme interface
+    [ ] check Permissions (e.g. csp) for the different envs
+    [ ] agree on license
+    [ ] tests
+
+
+Problems:
+    [X] gpgme-json: interactive mode vs. bytelength; filename
+    [X] nativeApp chokes on arrays. We will get rid of that bnativeapp anyhow
diff --git a/lang/js/CHECKLIST_build b/lang/js/CHECKLIST_build
new file mode 100644
index 0000000..fa162a1
--- /dev/null
+++ b/lang/js/CHECKLIST_build
@@ -0,0 +1,9 @@
+- Checklist for build/install:
+
+browsers'  manifests (see README) need allowedextension added, and the path set
+
+manifest.json/ csp needs adaption
+
+/dist contains a current build which is used by example app.
+We may either want to update it on every commit, or never at all, but not
+inconsistently.
diff --git a/lang/js/README b/lang/js/README
new file mode 100644
index 0000000..3ca0743
--- /dev/null
+++ b/lang/js/README
@@ -0,0 +1,52 @@
+This is an example app for gpgme-json.
+As of now, it only encrypts a given text.
+
+Installation
+-------------
+
+gpgmejs uses webpack, the builds can be found in dist/
+(the testapplication uses that script at that location). To create a new
+package, the command is npx webpack --config webpack.conf.js.
+If you want a more debuggable (i.e. not minified) build, just change the mode
+in webpack.conf.js.
+
+Demo WebExtension:
+As soon as a bundled webpack is in dist/ (TODO: .gitignore or not?),
+the gpgmejs folder can just be included in the extensions tab of the browser in
+questions (extension debug mode needs to be active). For chrome, selecting the
+folder is sufficient, for firefox, the manifest.json needs to be selected.
+
+In the browsers' nativeMessaging configuration folder a file 'gpgmejs.json'
+is needed, with the following content:
+
+(The path to the native app gpgme-json may need adaption)
+
+Chromium:
+~/.config/chromium/NativeMessagingHosts/gpgmejson.json
+
+{
+  "name": "gpgmejson",
+  "description": "This is a test application for gpgmejs",
+  "path": "/usr/bin/gpgme-json",
+  "type": "stdio",
+  "allowed_origins": ["chrome-extension://ExtensionIdentifier/"]
+}
+The ExtensionIdentifier can be seen on the chrome://extensions page, and
+changes on each reinstallation. Note the slashes in allowed_origins.
+
+
+Firefox:
+~/.mozilla/native-messaging-hosts/gpgmejson.json
+{
+  "name": "gpgmejson",
+  "description": "This is a test application for gpgmejs",
+  "path": "/usr/bin/gpgme-json",
+  "type": "stdio",
+  "allowed_extensions": ["ExtensionIdentifier at temporary-addon"]
+}
+The ExtensionIdentifier can be seen as Extension ID on the about:addons page if
+addon-debugging is active. In firefox, the temporary addon is removed once
+firefox exits, and the identifier will need to be changed more often.
+
+For testing purposes, it could be a good idea to change the keyID in the
+ui.html, to not having to type it every time.
diff --git a/lang/js/manifest.json b/lang/js/manifest.json
new file mode 100644
index 0000000..8bb5c58
--- /dev/null
+++ b/lang/js/manifest.json
@@ -0,0 +1,18 @@
+{
+  "manifest_version": 2,
+
+  "name": "gpgme-json with native Messaging",
+  "description": "This should be able to encrypt a text using gpgme-json",
+  "version": "0.1",
+  "content_security_policy": "default-src 'self' 'unsafe-eval' filesystem",
+  "browser_action": {
+    "default_icon": "testicon.png",
+    "default_title": "gpgme.js",
+    "default_popup": "ui.html"
+  },
+  "permissions": ["nativeMessaging", "activeTab"],
+
+  "background": {
+    "scripts": [ "dist/gpgmejs.bundle.js"]
+  }
+}
diff --git a/lang/js/package.json b/lang/js/package.json
new file mode 100644
index 0000000..46b60fd
--- /dev/null
+++ b/lang/js/package.json
@@ -0,0 +1,17 @@
+{
+  "name": "gpgmejs",
+  "version": "0.0.1",
+  "description": "javascript part of a nativeMessaging gnupg integration",
+  "main": "src/gpgmejs.js",
+  "private": true,
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "keywords": [],
+  "author": "",
+  "license": "",
+  "devDependencies": {
+    "webpack": "^4.3.0",
+    "webpack-cli": "^2.0.13"
+  }
+}
diff --git a/lang/js/src/Connection.js b/lang/js/src/Connection.js
new file mode 100644
index 0000000..e8fea54
--- /dev/null
+++ b/lang/js/src/Connection.js
@@ -0,0 +1,76 @@
+/**
+ * A connection port will be opened for each communication between gpgmejs and
+ * gnupg. It should be alive as long as there are additional messages to be
+ * expected.
+ */
+
+export function Connection(){
+    if (!this.connection){
+        this.connection = connect();
+        this._msg = {
+            'always-trust': true,
+            // 'no-encrypt-to': false,
+            // 'no-compress': true,
+            // 'throw-keyids': false,
+            // 'wrap': false,
+            'armor': true,
+            'base64': false
+        };
+    };
+
+    this.disconnect = function () {
+        if (this.connection){
+            this.connection.disconnect();
+        }
+    };
+
+    /**
+     * Sends a message and resolves with the answer.
+     * @param {*} operation The interaction requested from gpgme
+     * @param {*} message A json-capable object to pass the operation details.
+     * TODO: _msg should contain configurable parameters
+     */
+    this.post = function(operation, message){
+        let timeout = 5000;
+        let me = this;
+        if (!message || !operation){
+            return Promise.reject('no message'); // TBD
+        }
+
+        let keys = Object.keys(message);
+        for (let i=0; i < keys.length; i++){
+            let property = keys[i];
+            me._msg[property] = message[property];
+        }
+        me._msg['op'] = operation;
+        // TODO fancier checks if what we want is consistent with submitted content
+        return new Promise(function(resolve, reject){
+            me.connection.onMessage.addListener(function(msg) {
+                if (!msg){
+                    reject('empty answer.');
+                }
+                if (msg.type === "error"){
+                    reject(msg.msg);
+                }
+                    resolve(msg);
+            });
+
+            me.connection.postMessage(me._msg);
+            setTimeout(
+                function(){
+                    me.disconnect();
+                    reject('Timeout');
+                }, timeout);
+        });
+     };
+};
+
+
+function connect(){
+    let connection = chrome.runtime.connectNative('gpgmejson');
+    if (!connection){
+        let msg = chrome.runtime.lastError || 'no message'; //TBD
+        throw(msg);
+    }
+    return connection;
+};
diff --git a/lang/js/src/gpgmejs.js b/lang/js/src/gpgmejs.js
new file mode 100644
index 0000000..dedbf80
--- /dev/null
+++ b/lang/js/src/gpgmejs.js
@@ -0,0 +1,187 @@
+import {Connection} from "./Connection"
+
+export function encrypt(data, publicKeys, privateKeys, passwords=null,
+    sessionKey, filename, compression, armor=true, detached=false,
+    signature=null, returnSessionKey=false, wildcard=false, date=new Date()){
+        // gpgme_op_encrypt ( <-gpgme doc on this operation
+            // gpgme_ctx_t ctx,
+            // gpgme_key_t recp[],
+            // gpgme_encrypt_flags_t flags,
+            // gpgme_data_t plain,
+            // gpgme_data_t cipher)
+            // flags:
+            // GPGME_ENCRYPT_ALWAYS_TRUST
+            // GPGME_ENCRYPT_NO_ENCRYPT_TO
+            // GPGME_ENCRYPT_NO_COMPRESS
+            // GPGME_ENCRYPT_PREPARE
+            // GPGME_ENCRYPT_EXPECT_SIGN
+            // GPGME_ENCRYPT_SYMMETRIC
+            // GPGME_ENCRYPT_THROW_KEYIDS
+            // GPGME_ENCRYPT_WRAP
+    if (passwords !== null){
+        throw('Password!'); // TBD
+    }
+
+    let pubkeys = toKeyIdArray(publicKeys);
+    let privkeys = toKeyIdArray(privateKeys);
+
+    // TODO filename: data is supposed to be empty, file is provided
+    // TODO config compression detached signature
+    // TODO signature to add to the encrypted message (?) ||  privateKeys: signature is desired
+    //  gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[], gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher)
+
+    // TODO sign date overwriting implemented in gnupg?
+
+    let conn = new Connection();
+    if (wildcard){
+        // Connection.set('throw-keyids', true); TODO Connection.set not yet existant
+    }
+    return conn.post('encrypt', {
+        'data': data,
+        'keys': publicKeys,
+        'armor': armor});
+};
+
+export function decrypt(message, privateKeys, passwords, sessionKeys, publicKeys,
+    format='utf8', signature=null, date=new Date()) {
+    if (passwords !== null){
+        throw('Password!'); // TBD
+    }
+    if (format === 'binary'){
+        // Connection.set('base64', true);
+    }
+    if (publicKeys || signature){
+        // Connection.set('signature', signature);
+        // request verification, too
+    }
+    //privateKeys optionally if keyId was thrown?
+    // gpgme_op_decrypt (gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain)
+    // response is gpgme_op_decrypt_result (gpgme_ctx_t ctx) (next available?)
+    return conn.post('decrypt', {
+        'data': message
+    });
+}
+
+// BIG TODO.
+export function generateKey({userIds=[], passphrase, numBits=2048, unlocked=false, keyExpirationTime=0, curve="", date=new Date()}){
+    throw('not implemented here');
+        // gpgme_op_createkey (gpgme_ctx_t ctx, const char *userid, const char *algo, unsigned long reserved, unsigned long expires, gpgme_key_t extrakey, unsigned int flags);
+    return false;
+}
+
+export function sign({ data, privateKeys, armor=true, detached=false, date=new Date() }) {
+    //TODO detached GPGME_SIG_MODE_DETACH | GPGME_SIG_MODE_NORMAL
+    // gpgme_op_sign (gpgme_ctx_t ctx, gpgme_data_t plain, gpgme_data_t sig, gpgme_sig_mode_t mode)
+    // TODO date not supported
+
+    let conn = new Connection();
+    let privkeys = toKeyIdArray(privateKeys);
+    return conn.post('sign', {
+        'data': data,
+        'keys': privkeys,
+        'armor': armor});
+};
+
+export function verify({ message, publicKeys, signature=null, date=new Date() }) {
+    //TODO extra signature: sig, signed_text, plain: null
+    // inline sig: signed_text:null, plain as writable (?)
+    // date not supported
+    //gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig, gpgme_data_t signed_text, gpgme_data_t plain)
+    let conn = new Connection();
+    let privkeys = toKeyIdArray(privateKeys);
+    return conn.post('sign', {
+        'data': data,
+        'keys': privkeys,
+        'armor': armor});
+}
+
+
+export function reformatKey(privateKey, userIds=[], passphrase="", unlocked=false, keyExpirationTime=0){
+    let privKey = toKeyIdArray(privateKey);
+    if (privKey.length !== 1){
+        return false; //TODO some error handling. There is not exactly ONE key we are editing
+    }
+    let conn = new Connection();
+    // TODO key management needs to be changed somewhat
+    return conn.post('TODO', {
+        'key': privKey[0],
+        'keyExpirationTime': keyExpirationTime, //TODO check if this is 0 or a positive and plausible number
+        'userIds': userIds //TODO check if empty or plausible strings
+    });
+    // unlocked will be ignored
+}
+
+export function decryptKey({ privateKey, passphrase }) {
+    throw('not implemented here');
+    return false;
+};
+
+export function encryptKey({ privateKey, passphrase }) {
+    throw('not implemented here');
+    return false;
+};
+
+export function encryptSessionKey({data, algorithm, publicKeys, passwords, wildcard=false }) {
+    //openpgpjs:
+    // Encrypt a symmetric session key with public keys, passwords, or both at
+    // once. At least either public keys or passwords must be specified.
+    throw('not implemented here');
+    return false;
+};
+
+export function decryptSessionKeys({ message, privateKeys, passwords }) {
+    throw('not implemented here');
+    return false;
+};
+
+// //TODO worker handling
+
+// //TODO key representation
+// //TODO: keyring handling
+
+
+/**
+ * Helper functions and checks
+ */
+
+/**
+ * Checks if the submitted value is a keyID.
+ * TODO: should accept all strings that are accepted as keyID by gnupg
+ * TODO: See if Key becomes an object later on
+ * @param {*} key input value. Is expected to be a string of 8,16 or 40 chars
+ * representing hex values. Will return false if that expectation is not met
+ */
+function isKeyId(key){
+    if (!key || typeof(key) !== "string"){
+        return false;
+    }
+    if ([8,16,40].indexOf(key.length) < 0){
+        return false;
+    }
+    let regexp= /^[0-9a-fA-F]*$/i;
+    return regexp.test(key);
+};
+
+/**
+ * Tries to return an array of keyID values, either from a string or an array.
+ * Filters out those that do not meet the criteria. (TODO: silently for now)
+ * @param {*} array Input value.
+ */
+function toKeyIdArray(array){
+    let result = [];
+    if (!array){
+        return result;
+    }
+    if (!Array.isArray(array)){
+        if (isKeyId(array) === true){
+            return [keyId];
+        }
+        return result;
+    }
+    for (let i=0; i < array.length; i++){
+        if (isKeyId(array[i]) === true){
+            result.push(array[i]);
+        }
+    }
+    return result;
+};
diff --git a/lang/js/src/index.js b/lang/js/src/index.js
new file mode 100644
index 0000000..02dc919
--- /dev/null
+++ b/lang/js/src/index.js
@@ -0,0 +1,14 @@
+import * as gpgmejs from'./gpgmejs'
+export default gpgmejs;
+
+/**
+ * Export each high level api function separately.
+ * Usage:
+ *
+ *   import { encryptMessage } from 'gpgme.js'
+ *   encryptMessage(keys, text)
+ */
+export {
+    encrypt, decrypt, sign, verify,
+    generateKey, reformatKey
+  } from './gpgmejs';
diff --git a/lang/js/testapplication.js b/lang/js/testapplication.js
new file mode 100644
index 0000000..d01aca9
--- /dev/null
+++ b/lang/js/testapplication.js
@@ -0,0 +1,21 @@
+/**
+* Testing nativeMessaging. This is a temporary plugin using the gpgmejs
+  implemetation as contained in src/
+*/
+function buttonclicked(event){
+    let data = document.getElementById("text0").value;
+    let keyId = document.getElementById("key").value;
+    let enc = Gpgmejs.encrypt(data, [keyId]).then(function(answer){
+        console.log(answer);
+        console.log(answer.type);
+        console.log(answer.data);
+        alert(answer.data);
+    }, function(errormsg){
+        alert('Error: '+ errormsg);
+    });
+};
+
+document.addEventListener('DOMContentLoaded', function() {
+    document.getElementById("button0").addEventListener("click",
+    buttonclicked);
+  });
diff --git a/lang/js/testicon.png b/lang/js/testicon.png
new file mode 100644
index 0000000..12c3f5d
Binary files /dev/null and b/lang/js/testicon.png differ
diff --git a/lang/js/ui.css b/lang/js/ui.css
new file mode 100644
index 0000000..9c88698
--- /dev/null
+++ b/lang/js/ui.css
@@ -0,0 +1,10 @@
+ul {
+    list-style-type: none;
+    padding-left: 0px;
+}
+
+ul li span {
+    float: left;
+    width: 120px;
+    margin-top: 6px;
+}
diff --git a/lang/js/ui.html b/lang/js/ui.html
new file mode 100644
index 0000000..9c56c2e
--- /dev/null
+++ b/lang/js/ui.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <link rel="stylesheet" href="ui.css"/>
+    </head>
+    <body>
+        <!--TODO: replace this mess with require -->
+        <script src="dist/gpgmejs.bundle.js"></script>
+        <script src="testapplication.js"></script>
+	<ul>
+            <li>
+                <span class="label">Text: </span>
+	        <input type="text" id='text0' />
+            </li>
+            <li>
+                <span class="label">Public key ID: </span>
+                <input type="text" id="key" value="Your Public Key ID here" />
+            </li>
+        </ul>
+        <button id="button0">Encrypt</button><br>
+        <div id="answer"></div>
+    </body>
+</html>
diff --git a/lang/js/webpack.conf.js b/lang/js/webpack.conf.js
new file mode 100644
index 0000000..71b7116
--- /dev/null
+++ b/lang/js/webpack.conf.js
@@ -0,0 +1,13 @@
+const path = require('path');
+
+module.exports = {
+  entry: './src/index.js',
+  // mode: 'development',
+  mode: 'production',
+  output: {
+    path: path.resolve(__dirname, 'dist'),
+    filename: 'gpgmejs.bundle.js',
+    libraryTarget: 'var',
+    library: 'Gpgmejs'
+  }
+};

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

Summary of changes:
 .gitignore                                         |    1 -
 TODO                                               |  157 ++-
 doc/gpgme.texi                                     |    5 +
 lang/README                                        |    2 +-
 lang/js/CHECKLIST                                  |   30 +
 lang/js/CHECKLIST_build                            |    9 +
 lang/js/README                                     |   52 +
 lang/js/manifest.json                              |   18 +
 lang/js/package.json                               |   17 +
 lang/js/src/Connection.js                          |   76 ++
 lang/js/src/gpgmejs.js                             |  187 +++
 lang/js/src/index.js                               |   14 +
 lang/js/testapplication.js                         |   21 +
 lang/js/testicon.png                               |  Bin 0 -> 16192 bytes
 lang/js/ui.css                                     |   10 +
 lang/js/ui.html                                    |   24 +
 lang/js/webpack.conf.js                            |   13 +
 lang/python/docs/GPGMEpythonHOWTOen.org            | 1406 ++++++++++++++++++++
 lang/python/docs/TODO.org                          |   77 +-
 lang/python/examples/howto/README.org              |   58 +
 lang/python/examples/howto/add-userid.py           |   62 +
 lang/python/examples/howto/clear-sign-file.py      |   56 +
 lang/python/examples/howto/create-key.py           |   95 ++
 lang/python/examples/howto/decrypt-file.py         |   44 +
 lang/python/examples/howto/detach-sign-file.py     |   64 +
 lang/python/examples/howto/encrypt-file.py         |   71 +
 lang/python/examples/howto/encrypt-sign-file.py    |   70 +
 lang/python/examples/howto/groups.py               |   50 +
 lang/python/examples/howto/keycount.py             |   42 +
 lang/python/examples/howto/revoke-userid.py        |   62 +
 lang/python/examples/howto/sign-file.py            |   64 +
 lang/python/examples/howto/sign-key.py             |   63 +
 lang/python/examples/howto/temp-homedir-config.py  |  126 ++
 lang/python/examples/howto/verify-signatures.py    |   64 +
 lang/python/examples/howto/verify-signed-file.py   |   61 +
 ...crypt-to-all.py => low_level-encrypt_to_all.py} |    0
 lang/qt/tests/t-config.cpp                         |   34 +-
 src/context.h                                      |    3 +
 src/engine-assuan.c                                |   35 +
 src/engine-backend.h                               |    1 +
 src/engine-g13.c                                   |    1 +
 src/engine-gpg.c                                   |   36 +-
 src/engine-gpgconf.c                               |    1 +
 src/engine-gpgsm.c                                 |   35 +
 src/engine-spawn.c                                 |    1 +
 src/engine-uiserver.c                              |    1 +
 src/engine.c                                       |   20 +
 src/engine.h                                       |    1 +
 src/gpgme-json.c                                   |   61 +-
 src/gpgme-tool.c                                   |    2 +-
 src/gpgme.c                                        |   21 +-
 src/keylist.c                                      |    2 +
 src/op-support.c                                   |    2 +
 tests/run-decrypt.c                                |   23 +-
 54 files changed, 3392 insertions(+), 59 deletions(-)
 create mode 100644 lang/js/CHECKLIST
 create mode 100644 lang/js/CHECKLIST_build
 create mode 100644 lang/js/README
 create mode 100644 lang/js/manifest.json
 create mode 100644 lang/js/package.json
 create mode 100644 lang/js/src/Connection.js
 create mode 100644 lang/js/src/gpgmejs.js
 create mode 100644 lang/js/src/index.js
 create mode 100644 lang/js/testapplication.js
 create mode 100644 lang/js/testicon.png
 create mode 100644 lang/js/ui.css
 create mode 100644 lang/js/ui.html
 create mode 100644 lang/js/webpack.conf.js
 create mode 100644 lang/python/docs/GPGMEpythonHOWTOen.org
 create mode 100644 lang/python/examples/howto/README.org
 create mode 100755 lang/python/examples/howto/add-userid.py
 create mode 100755 lang/python/examples/howto/clear-sign-file.py
 create mode 100755 lang/python/examples/howto/create-key.py
 create mode 100755 lang/python/examples/howto/decrypt-file.py
 create mode 100755 lang/python/examples/howto/detach-sign-file.py
 create mode 100755 lang/python/examples/howto/encrypt-file.py
 create mode 100755 lang/python/examples/howto/encrypt-sign-file.py
 create mode 100644 lang/python/examples/howto/groups.py
 create mode 100755 lang/python/examples/howto/keycount.py
 create mode 100755 lang/python/examples/howto/revoke-userid.py
 create mode 100755 lang/python/examples/howto/sign-file.py
 create mode 100755 lang/python/examples/howto/sign-key.py
 create mode 100755 lang/python/examples/howto/temp-homedir-config.py
 create mode 100755 lang/python/examples/howto/verify-signatures.py
 create mode 100755 lang/python/examples/howto/verify-signed-file.py
 rename lang/python/examples/{encrypt-to-all.py => low_level-encrypt_to_all.py} (100%)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list