aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-04-24 17:47:48 +0000
committerMaximilian Krambach <[email protected]>2018-04-25 07:23:38 +0000
commit30c47d80a27054aa340cbd6dc39d1b8a5dc5cf22 (patch)
tree8bc8083eb2c0f653d82c86bd62988f3b39b0b688 /lang/js
parentjs: Key object adjustments after discussion (diff)
downloadgpgme-30c47d80a27054aa340cbd6dc39d1b8a5dc5cf22.tar.gz
gpgme-30c47d80a27054aa340cbd6dc39d1b8a5dc5cf22.zip
js: allow openpgp-like Message objects as Data
-- * src/gpgmejs.js: If a message offers a getText, consider it as the message's content
Diffstat (limited to 'lang/js')
-rw-r--r--lang/js/src/gpgmejs.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/lang/js/src/gpgmejs.js b/lang/js/src/gpgmejs.js
index 4b2a03a4..03ed5cb6 100644
--- a/lang/js/src/gpgmejs.js
+++ b/lang/js/src/gpgmejs.js
@@ -159,6 +159,13 @@ function putData(message, data){
} else if (typeof(data) === 'string') {
message.setParameter('base64', false);
message.setParameter('data', data);
+ } else if ( typeof(data) === 'object' && data.hasOwnProperty(getText)){
+ let txt = data.getText();
+ if (txt instanceof Uint8Array){
+ let decoder = new TextDecoder('utf8');
+ message.setParameter('base64', true);
+ message.setParameter ('data', decoder.decode(txt));
+ }
} else {
return new GPGMEJS_Error('WRONGPARAM');
}