aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Key.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-07-30 10:31:27 +0000
committerMaximilian Krambach <[email protected]>2018-07-30 10:31:27 +0000
commite16a87e83910ebb6bfdc4148369165f121f0997e (patch)
tree40727a6f9aec8110cc0bfaefc8aa36d14e302ecd /lang/js/src/Key.js
parentjs: fix indentaion (diff)
downloadgpgme-e16a87e83910ebb6bfdc4148369165f121f0997e.tar.gz
gpgme-e16a87e83910ebb6bfdc4148369165f121f0997e.zip
js: Making objects inmutable
-- * An Object.freeze should stop any malicious third party from changing objects' methods once the objects are instantiated (see unittest for an approach that would have worked before) - An initialized gpgmejs- object doesn't have a '_Keyring' property anymore (it still has its 'Keyring') - The internal expect='base64' needed to be turned into a method.
Diffstat (limited to '')
-rw-r--r--lang/js/src/Key.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/lang/js/src/Key.js b/lang/js/src/Key.js
index d5873a70..f431a283 100644
--- a/lang/js/src/Key.js
+++ b/lang/js/src/Key.js
@@ -37,7 +37,7 @@ export function createKey(fingerprint, async = false){
if (!isFingerprint(fingerprint) || typeof(async) !== 'boolean'){
return gpgme_error('PARAM_WRONG');
}
- else return new GPGME_Key(fingerprint, async);
+ else return Object.freeze(new GPGME_Key(fingerprint, async));
}
/**
@@ -104,15 +104,15 @@ export class GPGME_Key {
case 'subkeys':
_data.subkeys = [];
for (let i=0; i< data.subkeys.length; i++) {
- _data.subkeys.push(
- new GPGME_Subkey(data.subkeys[i]));
+ _data.subkeys.push(Object.freeze(
+ new GPGME_Subkey(data.subkeys[i])));
}
break;
case 'userids':
_data.userids = [];
for (let i=0; i< data.userids.length; i++) {
- _data.userids.push(
- new GPGME_UserId(data.userids[i]));
+ _data.userids.push(Object.freeze(
+ new GPGME_UserId(data.userids[i])));
}
break;
case 'last_update':