+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lang/js/BrowserTestExtension/manifest.json b/lang/js/BrowserTestExtension/manifest.json
new file mode 100644
index 00000000..a9e605bc
--- /dev/null
+++ b/lang/js/BrowserTestExtension/manifest.json
@@ -0,0 +1,13 @@
+{
+ "manifest_version": 2,
+
+ "name": "Browsertests for gpgmejs",
+ "description": "Run the browsertests.",
+ "version": "0.1",
+ "content_security_policy": "default-src 'self' filesystem:",
+ "browser_action": {
+ "default_icon": "testicon.png",
+ "default_popup": "popup.html"
+ },
+ "permissions": ["nativeMessaging", "activeTab"]
+ }
diff --git a/lang/js/testapplication_index.html b/lang/js/BrowserTestExtension/popup.html
similarity index 65%
copy from lang/js/testapplication_index.html
copy to lang/js/BrowserTestExtension/popup.html
index 866b1135..f17f262a 100644
--- a/lang/js/testapplication_index.html
+++ b/lang/js/BrowserTestExtension/popup.html
@@ -1,9 +1,9 @@
-
+
\ No newline at end of file
diff --git a/lang/js/test_index.js b/lang/js/BrowserTestExtension/popup.js
similarity index 51%
copy from lang/js/test_index.js
copy to lang/js/BrowserTestExtension/popup.js
index 9119d271..4764df55 100644
--- a/lang/js/test_index.js
+++ b/lang/js/BrowserTestExtension/popup.js
@@ -1,25 +1,44 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see .
* SPDX-License-Identifier: LGPL-2.1+
+ */
+/* gpgme.js - Javascript integration for gpgme
+ * Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
+ *
+ * This file is part of GPGME.
+ *
+ * GPGME is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
*
+ * GPGME is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see .
+ * SPDX-License-Identifier: LGPL-2.1+
*/
+
document.addEventListener('DOMContentLoaded', function() {
chrome.tabs.create({
- url: './ui2.html'
+ url: './browsertest.html'
});
});
diff --git a/lang/js/test_index.js b/lang/js/BrowserTestExtension/runbrowsertest.js
similarity index 87%
copy from lang/js/test_index.js
copy to lang/js/BrowserTestExtension/runbrowsertest.js
index 9119d271..39bc3fb9 100644
--- a/lang/js/test_index.js
+++ b/lang/js/BrowserTestExtension/runbrowsertest.js
@@ -1,25 +1,21 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see .
* SPDX-License-Identifier: LGPL-2.1+
- *
*/
-document.addEventListener('DOMContentLoaded', function() {
- chrome.tabs.create({
- url: './ui2.html'
- });
-});
+
+mocha.run();
diff --git a/lang/js/test_index.js b/lang/js/BrowserTestExtension/setup_testing.js
similarity index 87%
copy from lang/js/test_index.js
copy to lang/js/BrowserTestExtension/setup_testing.js
index 9119d271..7f70d347 100644
--- a/lang/js/test_index.js
+++ b/lang/js/BrowserTestExtension/setup_testing.js
@@ -1,25 +1,22 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see .
* SPDX-License-Identifier: LGPL-2.1+
- *
*/
-document.addEventListener('DOMContentLoaded', function() {
- chrome.tabs.create({
- url: './ui2.html'
- });
-});
+mocha.setup('bdd');
+var expect = chai.expect;
+chai.config.includeStack = true;
\ No newline at end of file
diff --git a/lang/js/testicon.png b/lang/js/BrowserTestExtension/testicon.png
similarity index 100%
copy from lang/js/testicon.png
copy to lang/js/BrowserTestExtension/testicon.png
diff --git a/lang/js/test_index.js b/lang/js/BrowserTestExtension/tests/inputvalues.js
similarity index 83%
copy from lang/js/test_index.js
copy to lang/js/BrowserTestExtension/tests/inputvalues.js
index 9119d271..47600c84 100644
--- a/lang/js/test_index.js
+++ b/lang/js/BrowserTestExtension/tests/inputvalues.js
@@ -1,25 +1,28 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see .
* SPDX-License-Identifier: LGPL-2.1+
- *
*/
-document.addEventListener('DOMContentLoaded', function() {
- chrome.tabs.create({
- url: './ui2.html'
- });
-});
+
+var inputvalues = {
+ encrypt: {
+ good:{
+ data : 'Hello World.',
+ keyid : 'CDC3A2B2860625CCBFC5A5A9FC6D1B604967FC40'
+ }
+ }
+};
diff --git a/lang/js/BrowserTestExtension/tests/startup.js b/lang/js/BrowserTestExtension/tests/startup.js
new file mode 100644
index 00000000..14d12c0a
--- /dev/null
+++ b/lang/js/BrowserTestExtension/tests/startup.js
@@ -0,0 +1,51 @@
+/* gpgme.js - Javascript integration for gpgme
+ * Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
+ *
+ * This file is part of GPGME.
+ *
+ * GPGME is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * GPGME is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see .
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
+
+ describe('GPGME context', function(){
+ it('Starting a GpgME instance', function(done){
+ Gpgmejs.init().then(
+ function(context){
+ expect(context.connection).to.not.be.undefined;
+ expect(context).to.be.an('object');
+ expect(context.connection).to.be.an('object');
+ expect(context.Keyring).to.be.undefined;
+ expect(context.encrypt).to.be.a('function');
+ expect(context.decrypt).to.be.a('function');
+ done();
+ }, function(err){
+ done(err);
+ });
+ });
+ it('Starting an openpgp mode GPGME instance', function(done){
+ Gpgmejs.init({api_style:"gpgme_openpgpjs"}).then(
+ function(context){
+ console.log(context);
+ done();
+ // expect(context).to.be.an('object');
+ // expect(context.connection).to.be.undefined;
+ // expect(context.Keyring).to.be.an('object');
+ // expect(context.encrypt).to.be.a('function');
+ // expect(context.decrypt).to.be.a('function');
+ // done();
+ }, function(err){
+ done(err);
+ });
+ });
+ });
diff --git a/lang/js/CHECKLIST b/lang/js/CHECKLIST
index 49b17265..75664ae5 100644
--- a/lang/js/CHECKLIST
+++ b/lang/js/CHECKLIST
@@ -1,28 +1,28 @@
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)
- [x] encrypt
+ [*] Message handling (encrypt, decrypt verify, sign)
+ [x] encrypt, decrypt
[ ] 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
+ [x] check Permissions (e.g. csp) for the different envs
[X] agree on license
- [ ] tests
+ [*] tests
diff --git a/lang/js/CHECKLIST_build b/lang/js/CHECKLIST_build
index 19eb2146..a7c8d08d 100644
--- a/lang/js/CHECKLIST_build
+++ b/lang/js/CHECKLIST_build
@@ -1,9 +1,3 @@
- Checklist for build/install:
browsers' manifests (see README) need allowedextension added, and the path set
-
-manifest.json/ csp needs adaption
-
-/dist should be built which is used by the example app.
-
-csp in manifest.json MUST NOT contain "unsafe-eval" in production!
diff --git a/lang/js/test_index.js b/lang/js/DemoExtension/entry.js
similarity index 96%
copy from lang/js/test_index.js
copy to lang/js/DemoExtension/entry.js
index 9119d271..7e5e1ffe 100644
--- a/lang/js/test_index.js
+++ b/lang/js/DemoExtension/entry.js
@@ -1,25 +1,25 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see .
* SPDX-License-Identifier: LGPL-2.1+
*
*/
document.addEventListener('DOMContentLoaded', function() {
chrome.tabs.create({
- url: './ui2.html'
+ url: './uimainui.html'
});
});
diff --git a/lang/js/testapplication.js b/lang/js/DemoExtension/maindemo.js
similarity index 100%
rename from lang/js/testapplication.js
rename to lang/js/DemoExtension/maindemo.js
diff --git a/lang/js/ui2.html b/lang/js/DemoExtension/mainui.html
similarity index 89%
rename from lang/js/ui2.html
rename to lang/js/DemoExtension/mainui.html
index 8d0abd97..d85e7a46 100644
--- a/lang/js/ui2.html
+++ b/lang/js/DemoExtension/mainui.html
@@ -1,33 +1,33 @@
-
-
+
+
Text:
Public key ID:
Encrypted armored Text:
Result data:
diff --git a/lang/js/manifest.json b/lang/js/DemoExtension/manifest.json
similarity index 54%
rename from lang/js/manifest.json
rename to lang/js/DemoExtension/manifest.json
index e5e17aa5..9e057b35 100644
--- a/lang/js/manifest.json
+++ b/lang/js/DemoExtension/manifest.json
@@ -1,14 +1,14 @@
{
"manifest_version": 2,
"name": "gpgme-json with native Messaging",
- "description": "This should be able to encrypt a text using gpgme-json",
+ "description": "A simple demo application",
"version": "0.1",
- "content_security_policy": "default-src 'self' 'unsafe-eval' filesystem:",
+ "content_security_policy": "default-src 'self' filesystem:",
"browser_action": {
"default_icon": "testicon.png",
"default_title": "gpgme.js",
- "default_popup": "testapplication_index.html"
+ "default_popup": "popup.html"
},
"permissions": ["nativeMessaging", "activeTab"]
}
diff --git a/lang/js/testapplication_index.html b/lang/js/DemoExtension/popup.html
similarity index 100%
rename from lang/js/testapplication_index.html
rename to lang/js/DemoExtension/popup.html
diff --git a/lang/js/testicon.png b/lang/js/DemoExtension/testicon.png
similarity index 100%
rename from lang/js/testicon.png
rename to lang/js/DemoExtension/testicon.png
diff --git a/lang/js/ui.css b/lang/js/DemoExtension/ui.css
similarity index 100%
rename from lang/js/ui.css
rename to lang/js/DemoExtension/ui.css
diff --git a/lang/js/build_extensions.sh b/lang/js/build_extensions.sh
new file mode 100755
index 00000000..be7b0584
--- /dev/null
+++ b/lang/js/build_extensions.sh
@@ -0,0 +1,14 @@
+#/!bin/bash
+
+npx webpack --config webpack.conf.js
+mkdir -p BrowserTestExtension/libs
+cp node_modules/chai/chai.js \
+ node_modules/mocha/mocha.css \
+ node_modules/mocha/mocha.js \
+ build/gpgmejs.bundle.js BrowserTestExtension/libs
+mkdir -p build/extensions
+zip -r build/extensions/browsertest.zip BrowserTestExtension
+
+mkdir -p DemoExtension/libs
+cp build/gpgmejs.bundle.js DemoExtension/libs
+zip -r build/extensions/demoextension.zip DemoExtension
diff --git a/lang/js/test_index.js b/lang/js/src/Config.js
similarity index 74%
rename from lang/js/test_index.js
rename to lang/js/src/Config.js
index 9119d271..e18728de 100644
--- a/lang/js/test_index.js
+++ b/lang/js/src/Config.js
@@ -1,25 +1,31 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see .
* SPDX-License-Identifier: LGPL-2.1+
- *
*/
-document.addEventListener('DOMContentLoaded', function() {
- chrome.tabs.create({
- url: './ui2.html'
- });
-});
+
+export const availableConf = {
+ api_style: ['gpgme', 'gpgme_openpgpjs'],
+ null_expire_is_never: [true, false],
+ unconsidered_params: ['warn','reject', 'ignore'],
+};
+
+export const defaultConf = {
+ api_style: 'gpgme',
+ null_expire_is_never: false,
+ unconsidered_params: 'reject',
+};
\ No newline at end of file
diff --git a/lang/js/src/Keyring.js b/lang/js/src/Keyring.js
index 470eeeec..364bfb46 100644
--- a/lang/js/src/Keyring.js
+++ b/lang/js/src/Keyring.js
@@ -1,156 +1,157 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see .
* SPDX-License-Identifier: LGPL-2.1+
*/
import {createMessage} from './Message'
import {GPGME_Key} from './Key'
import { isFingerprint, isLongId } from './Helpers';
import { gpgme_error } from './Errors';
+import { Connection } from './Connection';
export class GPGME_Keyring {
constructor(connection){
this.connection = connection;
}
set connection(connection){
if (!this._connection && connection instanceof Connection){
this._connection = connection;
}
}
get connection(){
if (this._connection instanceof Connection){
if (this._connection.isConnected){
return this._connection;
}
return gpgme_error('CONN_DISCONNECTED');
}
return gpgme_error('CONN_NO_CONNECT');
}
/**
* @param {String} (optional) pattern A pattern to search for, in userIds or KeyIds
* @param {Boolean} (optional) Include listing of secret keys
* @returns {Promise.>}
*
*/
getKeys(pattern, include_secret){
let msg = createMessage('listkeys');
if (msg instanceof Error){
return Promise.reject(msg);
}
if (pattern && typeof(pattern) === 'string'){
msg.setParameter('pattern', pattern);
}
if (include_secret){
msg.setParameter('with-secret', true);
}
this.connection.post(msg).then(function(result){
let fpr_list = [];
let resultset = [];
if (!Array.isArray(result.keys)){
//TODO check assumption keys = Array
fpr_list = [result.keys];
} else {
fpr_list = result.keys;
}
for (let i=0; i < fpr_list.length; i++){
let newKey = new GPGME_Key(fpr_list[i]);
if (newKey instanceof GPGME_Key){
resultset.push(newKey);
}
}
return Promise.resolve(resultset);
});
}
/**
* @param {Object} flags subset filter expecting at least one of the
* filters described below. True will filter on the condition, False will
* reverse the filter, if not present or undefined, the filter will not be
* considered. Please note that some combination may not make sense
* @param {Boolean} flags.secret Only Keys containing a secret part.
* @param {Boolean} flags.revoked revoked Keys only
* @param {Boolean} flags.expired Expired Keys only
* @param {String} (optional) pattern A pattern to search for, in userIds or KeyIds
* @returns {Promise Array}
*
*/
getSubset(flags, pattern){
if (flags === undefined) {
throw('ERR_WRONG_PARAM');
};
let secretflag = false;
if (flags.hasOwnProperty(secret) && flags.secret){
secretflag = true;
}
this.getKeys(pattern, secretflag).then(function(queryset){
let resultset = [];
for (let i=0; i < queryset.length; i++ ){
let conditions = [];
let anticonditions = [];
if (secretflag === true){
conditions.push('hasSecret');
} else if (secretflag === false){
anticonditions.push('hasSecret');
}
/**
if (flags.defaultKey === true){
conditions.push('isDefault');
} else if (flags.defaultKey === false){
anticonditions.push('isDefault');
}
*/
/**
* if (flags.valid === true){
anticonditions.push('isInvalid');
} else if (flags.valid === false){
conditions.push('isInvalid');
}
*/
if (flags.revoked === true){
conditions.push('isRevoked');
} else if (flags.revoked === false){
anticonditions.push('isRevoked');
}
if (flags.expired === true){
conditions.push('isExpired');
} else if (flags.expired === false){
anticonditions.push('isExpired');
}
let decision = undefined;
for (let con = 0; con < conditions.length; con ++){
if (queryset[i][conditions[con]] !== true){
decision = false;
}
}
for (let acon = 0; acon < anticonditions.length; acon ++){
if (queryset[i][anticonditions[acon]] === true){
decision = false;
}
}
if (decision !== false){
resultset.push(queryset[i]);
}
}
return Promise.resolve(resultset);
});
}
};
diff --git a/lang/js/src/Message.js b/lang/js/src/Message.js
index 4d242277..9e7a8835 100644
--- a/lang/js/src/Message.js
+++ b/lang/js/src/Message.js
@@ -1,110 +1,110 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see .
* SPDX-License-Identifier: LGPL-2.1+
*/
import { permittedOperations } from './permittedOperations'
import { gpgme_error } from './Errors'
export function createMessage(operation){
if (typeof(operation) !== 'string'){
return gpgme_error('PARAM_WRONG');
}
if (permittedOperations.hasOwnProperty(operation)){
return new GPGME_Message(operation);
} else {
return gpgme_error('MSG_WRONG_OP');
}
}
/**
* Prepares a communication request. It checks operations and parameters in
* ./permittedOperations.
* @param {String} operation
*/
-class GPGME_Message {
+export class GPGME_Message {
//TODO getter
constructor(operation){
this.operation = operation;
}
set operation (op){
}
get operation(){
return this._msg.op;
}
/**
* Sets a parameter for the message. Note that the operation has to be set
* first, to be able to check if the parameter is permittted
* @param {String} param Parameter to set
* @param {any} value Value to set //TODO: Some type checking
* @returns {Boolean} If the parameter was set successfully
*/
setParameter(param,value){
if (!param || typeof(param) !== 'string'){
return gpgme_error('PARAM_WRONG');
}
let po = permittedOperations[this._msg.op];
if (!po){
return gpgme_error('MSG_WRONG_OP');
}
if (po.required.indexOf(param) >= 0 || po.optional.indexOf(param) >= 0){
this._msg[param] = value;
return true;
}
return gpgme_error('PARAM_WRONG');
}
/**
* Check if the message has the minimum requirements to be sent, according
* to the definitions in permittedOperations
* @returns {Boolean}
*/
get isComplete(){
if (!this._msg.op){
return false;
}
let reqParams = permittedOperations[this._msg.op].required;
for (let i=0; i < reqParams.length; i++){
if (!this._msg.hasOwnProperty(reqParams[i])){
console.log(reqParams[i] + 'missing');
return false;
}
}
return true;
}
/**
* Returns the prepared message with parameters and completeness checked
* @returns {Object|null} Object to be posted to gnupg, or null if
* incomplete
*/
get message(){
if (this.isComplete === true){
return this._msg;
}
else {
return null;
}
}
}
diff --git a/lang/js/src/gpgmejs_openpgpjs.js b/lang/js/src/gpgmejs_openpgpjs.js
index 4e5e1ea0..cc2afde1 100644
--- a/lang/js/src/gpgmejs_openpgpjs.js
+++ b/lang/js/src/gpgmejs_openpgpjs.js
@@ -1,281 +1,275 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see .
* SPDX-License-Identifier: LGPL-2.1+
*/
/**
* This is a compatibility API to be used as openpgpjs syntax.
* Non-implemented options will throw an error if set (not null or undefined)
* TODO Some info about differences
*/
import { GpgME } from "./gpgmejs";
import {GPGME_Keyring} from "./Keyring"
import { GPGME_Key } from "./Key";
import { isFingerprint } from "./Helpers"
import { gpgme_error } from "./Errors"
export class GpgME_openpgpmode {
constructor(connection, config = {}){
this.initGpgME(connection, config);
}
get Keyring(){
if (this._keyring){
return this._keyring;
}
return undefined;
}
initGpgME(connection, config = {}){
if (connection && typeof(config) ==='object'){
this._config = config;
if (!this._GPGME){
this._GpgME = new GpgME(connection, config);
}
- if (!this._Keyring){
- this._Keyring = new GPGME_Keyring_openpgpmode(connection);
+ if (!this._keyring){
+ this._keyring = new GPGME_Keyring_openpgpmode(connection);
}
}
}
- get GpgME(){
- if (this._GpGME){
- return this._GpGME;
- }
- }
-
/**
* Encrypt Message
* Supported:
* @param {String|Uint8Array} data
* //an openpgp Message also accepted here. TODO: is this wanted?
* @param {Key|Array} publicKeys
* //Strings of Fingerprints
* @param {Boolean} wildcard
* TODO:
* @param {Key|Array} privateKeys // -> encryptsign
* @param {module:enums.compression} compression //TODO accepts integer, if 0 (no compression) it won't compress
* @param {Boolean} armor // TODO base64 switch
* @param {Boolean} detached // --> encryptsign
* unsupported:
* @param {String|Array} passwords
* @param {Object} sessionKey
* @param {Signature} signature
* @param {Boolean} returnSessionKey
* @param {String} filename
*
* Can be set, but will be ignored:
*
* @returns {Promise