[git] GPGME - branch, javascript-binding, updated. gpgme-1.11.1-65-g88e7f8e
by Maximilian Krambach
cvs at cvs.gnupg.org
Wed Jun 20 13:45:48 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 88e7f8ec2ef3d90ca014b0bdb246f4d99f82abc8 (commit)
from d27703ea4f0eed950cddf0157dc78bcb5d8d1c65 (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 88e7f8ec2ef3d90ca014b0bdb246f4d99f82abc8
Author: Maximilian Krambach <maximilian.krambach at intevation.de>
Date: Wed Jun 20 13:42:19 2018 +0200
js: Demoextension update
--
* src/Signature: typo
* src/gpgmejs.js: fixed wrong scope in verification
* right now verify does not succeed in the DemoExtension.
This is probably a problem in conversion or line ending.
diff --git a/lang/js/DemoExtension/maindemo.js b/lang/js/DemoExtension/maindemo.js
index 6230c3f..d0127c7 100644
--- a/lang/js/DemoExtension/maindemo.js
+++ b/lang/js/DemoExtension/maindemo.js
@@ -27,7 +27,7 @@ document.addEventListener('DOMContentLoaded', function() {
Gpgmejs.init().then(function(gpgmejs){
document.getElementById('buttonencrypt').addEventListener('click',
function(){
- let data = document.getElementById('cleartext').value;
+ let data = document.getElementById('inputtext').value;
let keyId = document.getElementById('pubkey').value;
gpgmejs.encrypt(data, keyId).then(
function(answer){
@@ -42,7 +42,7 @@ document.addEventListener('DOMContentLoaded', function() {
document.getElementById('buttondecrypt').addEventListener('click',
function(){
- let data = document.getElementById('ciphertext').value;
+ let data = document.getElementById('inputtext').value;
gpgmejs.decrypt(data).then(
function(answer){
if (answer.data){
@@ -57,11 +57,46 @@ document.addEventListener('DOMContentLoaded', function() {
document.getElementById('getdefaultkey').addEventListener('click',
function(){
gpgmejs.Keyring.getDefaultKey().then(function(answer){
- document.getElementById('defaultkey').textContent =
+ document.getElementById('pubkey').value =
answer.fingerprint;
}, function(errormsg){
alert(errormsg.message);
});
});
+
+ document.getElementById('signtext').addEventListener('click',
+ function(){
+ let data = document.getElementById('inputtext').value;
+ let keyId = document.getElementById('pubkey').value;
+ gpgmejs.sign(data, keyId).then(
+ function(answer){
+ if (answer.data){
+ document.getElementById(
+ 'answer').value = answer.data;
+ }
+ }, function(errormsg){
+ alert( errormsg.message);
+ });
+ });
+
+ document.getElementById('verifytext').addEventListener('click',
+ function(){
+ let data = document.getElementById('inputtext').value;
+ gpgmejs.verify(data).then(
+ function(answer){
+ let vals = '';
+ if (answer.all_valid === true){
+ vals = 'Success! ';
+ } else {
+ vals = 'Failure! ';
+ }
+ vals = vals + (answer.count - answer.failures) + 'of '
+ + answer.count + ' signature(s) were successfully '
+ + 'verified.\n\n' + answer.data;
+ document.getElementById('answer').value = vals;
+ }, function(errormsg){
+ alert( errormsg.message);
+ });
+ });
});
});
diff --git a/lang/js/DemoExtension/mainui.html b/lang/js/DemoExtension/mainui.html
index 91be7bb..b639036 100644
--- a/lang/js/DemoExtension/mainui.html
+++ b/lang/js/DemoExtension/mainui.html
@@ -7,38 +7,37 @@
<script src="maindemo.js"></script>
</head>
<body>
- <ul>
- <li>
- <span class="label">Text: </span>
- <input type="text" id='cleartext' />
- </li>
- <li>
- <span class="label">Public key ID: </span>
- <input type="text" id="pubkey" value="" />
- </li>
- </ul>
- <button id="buttonencrypt">Encrypt</button><br>
- <hr>
- <ul>
- <li>
- <span class="label">Encrypted armored Text: </span>
- <textarea rows="5" cols="65" id="ciphertext" wrap="hard"></textarea>
- </li>
- </ul>
- <button id="buttondecrypt">Decrypt</button><br>
- <hr>
- <h3>Result data:</h3>
- <textarea id="answer" rows="5" cols="65" wrap="hard"></textarea>
+ <div>
- <hr>
- <ul>
- <li>
- <span class="label">Default Key:</span>
- <button id="getdefaultkey">Get</button><br>
- <span id="defaultkey"></span>
- </li>
+ <div class="left">
+ <ul>
+ <li>
+ <span class="label">Input</span>
+ <textarea rows="5" cols="65" id="inputtext" wrap="hard"></textarea>
+ </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>
+ </li>
+ </ul>
+ </div>
+ <div class="right">
+ <ul>
+ <li>
+ <span class="label">Result</span>
+ <textarea id="answer" rows="5" cols="65" wrap="hard"></textarea>
+ </li>
+ </ul>
+ </div>
+ </div>
+ <div class="center">
+ <button id="buttonencrypt">Encrypt input text</button><br>
+ <button id="buttondecrypt">Decrypt input text</button><br>
+ <button id="signtext">Sign input text</button> <br>
+ <button id="verifytext">Verify input text</button><br>
-
- </ul>
- </body>
+ </div>
+</body>
</html>
diff --git a/lang/js/DemoExtension/ui.css b/lang/js/DemoExtension/ui.css
index 9c88698..16dfb5a 100644
--- a/lang/js/DemoExtension/ui.css
+++ b/lang/js/DemoExtension/ui.css
@@ -8,3 +8,26 @@ ul li span {
width: 120px;
margin-top: 6px;
}
+
+div .left {
+ float: left;
+ align-items: stretch;
+ width: 40%;
+}
+div .center {
+ width: 50%;
+ align-content: space-between;
+}
+
+div .center button {
+ align-self: stretch;
+}
+div .right {
+ float: right;
+ align-items: stretch;
+ width: 40%;
+}
+
+div .bottom {
+ clear:both;
+}
\ No newline at end of file
diff --git a/lang/js/src/Signature.js b/lang/js/src/Signature.js
index d7d0598..a07fc4d 100644
--- a/lang/js/src/Signature.js
+++ b/lang/js/src/Signature.js
@@ -35,7 +35,7 @@ export function createSignature(sigObject){
if (
typeof(sigObject) !=='object' ||
!sigObject.hasOwnProperty('summary') ||
- !sigObject.hasOwnProperty('fingerpprint') ||
+ !sigObject.hasOwnProperty('fingerprint') ||
!sigObject.hasOwnProperty('timestamp')
//TODO check if timestamp is mandatory in specification
){
@@ -67,6 +67,7 @@ export function createSignature(sigObject){
}
}
}
+ console.log('sig created');
return new GPGME_Signature(sigObject);
}
@@ -178,7 +179,8 @@ const expSum = {
'crl-missing': 'boolean',
'crl-too-old': 'boolean',
'bad-policy': 'boolean',
- 'sys-error': 'boolean'
+ 'sys-error': 'boolean',
+ 'sigsum': 'object'
};
/**
diff --git a/lang/js/src/gpgmejs.js b/lang/js/src/gpgmejs.js
index a0f7e96..c2a6b8b 100644
--- a/lang/js/src/gpgmejs.js
+++ b/lang/js/src/gpgmejs.js
@@ -168,7 +168,7 @@ export class GpgME {
/**
* Sign a Message
- * @param {String|Object} data text/data to be decrypted. Accepts Strings
+ * @param {String|Object} data text/data to be signed. Accepts Strings
* and Objects with a gettext methos
* @param {GPGME_Key|String|Array<String>|Array<GPGME_Key>} keys The
* key/keys to use for signing
@@ -238,7 +238,7 @@ export class GpgME {
*/
verify(data, signature, base64 = false){
let msg = createMessage('verify');
- let dt = this.putData(msg, data);
+ let dt = putData(msg, data);
if (dt instanceof Error){
return Promise.reject(dt);
}
@@ -317,7 +317,7 @@ function collectSignatures(sigs){
for (let i=0; i< sigs.length; i++){
let sigObj = createSignature(sigs[i]);
if (sigObj instanceof Error){
- return gpgme_error('SIG_WRONG');
+ return gpgme_error(sigObj);
}
if (sigObj.valid !== true){
summary.failures += 1;
-----------------------------------------------------------------------
Summary of changes:
lang/js/DemoExtension/maindemo.js | 41 +++++++++++++++++++++++--
lang/js/DemoExtension/mainui.html | 63 +++++++++++++++++++--------------------
lang/js/DemoExtension/ui.css | 23 ++++++++++++++
lang/js/src/Signature.js | 6 ++--
lang/js/src/gpgmejs.js | 6 ++--
5 files changed, 99 insertions(+), 40 deletions(-)
hooks/post-receive
--
GnuPG Made Easy
http://git.gnupg.org
More information about the Gnupg-commits
mailing list