aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/gpgmejs.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-05-14 14:23:24 +0000
committerMaximilian Krambach <[email protected]>2018-05-14 14:23:24 +0000
commit987b31746809dfe04966e37edd759a448a28d975 (patch)
tree8f1bc971f712c55740af924333557e21c9a99d86 /lang/js/src/gpgmejs.js
parentjs: more testing of nativeMessaging connection (diff)
downloadgpgme-987b31746809dfe04966e37edd759a448a28d975.tar.gz
gpgme-987b31746809dfe04966e37edd759a448a28d975.zip
js: Tests and improvements for openpgp mode
-- * Added openpgp - Mode tests to the browsertest Extension. These tests require openpgp, which should not be a hard dependency for the main project. Packing openpgpjs into the extension is still TODO * Fixes: - openpgp mode API now correctly handles parameters as an object, similar to openpgpjs - proper check and parsing of openpgpjs Message Objects
Diffstat (limited to '')
-rw-r--r--lang/js/src/gpgmejs.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/lang/js/src/gpgmejs.js b/lang/js/src/gpgmejs.js
index c1a01377..d106f4f7 100644
--- a/lang/js/src/gpgmejs.js
+++ b/lang/js/src/gpgmejs.js
@@ -80,7 +80,6 @@ export class GpgME {
let pubkeys = toKeyIdArray(publicKeys);
msg.setParameter('keys', pubkeys);
-
putData(msg, data);
if (wildcard === true){msg.setParameter('throw-keyids', true);
};
@@ -171,19 +170,32 @@ function putData(message, data){
return gpgme_error('PARAM_WRONG');
} else if (data instanceof Uint8Array){
message.setParameter('base64', true);
+ // TODO: btoa turns the array into a string
+ // of comma separated of numbers
+ // atob(data).split(',') would result in a "normal" array of numbers
+ // atob(btoa(data)).split(',') would result in a "normal" array of numbers
+ // would result in a "normal" array of numbers
message.setParameter ('data', btoa(data));
+
} else if (typeof(data) === 'string') {
message.setParameter('base64', false);
message.setParameter('data', data);
- } else if ( typeof(data) === 'object' && data.hasOwnProperty('getText')){
+ } else if (
+ typeof(data) === 'object' &&
+ typeof(data.getText) === 'function'
+ ){
let txt = data.getText();
if (txt instanceof Uint8Array){
message.setParameter('base64', true);
message.setParameter ('data', btoa(txt));
}
- else {
+ else if (typeof(txt) === 'string'){
+ message.setParameter('base64', false);
+ message.setParameter ('data', txt);
+ } else {
return gpgme_error('PARAM_WRONG');
}
+
} else {
return gpgme_error('PARAM_WRONG');
}