aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Errors.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/Errors.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 'lang/js/src/Errors.js')
-rw-r--r--lang/js/src/Errors.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/lang/js/src/Errors.js b/lang/js/src/Errors.js
index 0cf1af19..39e3a74a 100644
--- a/lang/js/src/Errors.js
+++ b/lang/js/src/Errors.js
@@ -119,7 +119,7 @@ const err_list = {
export function gpgme_error(code = 'GENERIC_ERROR', info){
if (err_list.hasOwnProperty(code)){
if (err_list[code].type === 'error'){
- return new GPGME_Error(code);
+ return Object.freeze(new GPGME_Error(code));
}
if (err_list[code].type === 'warning'){
// eslint-disable-next-line no-console
@@ -127,10 +127,10 @@ export function gpgme_error(code = 'GENERIC_ERROR', info){
}
return null;
} else if (code === 'GNUPG_ERROR'){
- return new GPGME_Error(code, info);
+ return Object.freeze(new GPGME_Error(code, info));
}
else {
- return new GPGME_Error('GENERIC_ERROR');
+ return Object.freeze(new GPGME_Error('GENERIC_ERROR'));
}
}