diff options
author | Maximilian Krambach <[email protected]> | 2018-07-27 18:36:21 +0000 |
---|---|---|
committer | Maximilian Krambach <[email protected]> | 2018-07-27 18:36:21 +0000 |
commit | 94ee0988d4eaac27785de6efb7c19ca9976e1e9c (patch) | |
tree | b9a06e35d1a2831cb0750177daa978314b9be481 /lang/js/src/Signature.js | |
parent | js: clean up test extension (diff) | |
download | gpgme-94ee0988d4eaac27785de6efb7c19ca9976e1e9c.tar.gz gpgme-94ee0988d4eaac27785de6efb7c19ca9976e1e9c.zip |
js: change the write access for js class methods
--
* src/ [Connection, Error, Key, Keyring, MEssage, Signature, gpgmejs]:
Functions and values that are not meant to be overwritten are now
moved into their constructors, thus eliminating the possibility of
overwrites after initialization.
* Key: The mode of use (synchronous cached, or async promises) ivs now
determined at initialization of that Key. The property Key.isAsync
reflects this state.
* unittests: fixed old Key syntax for testing.
* Message.js isComplete is now a method and not a getter anymore.
* Added some startup tests.
Diffstat (limited to 'lang/js/src/Signature.js')
-rw-r--r-- | lang/js/src/Signature.js | 74 |
1 files changed, 56 insertions, 18 deletions
diff --git a/lang/js/src/Signature.js b/lang/js/src/Signature.js index 191e00ab..ff4278ad 100644 --- a/lang/js/src/Signature.js +++ b/lang/js/src/Signature.js @@ -82,44 +82,47 @@ export function createSignature(sigObject){ class GPGME_Signature { constructor(sigObject){ - this._rawSigObject = sigObject; - } + let _rawSigObject = sigObject; - get fingerprint(){ - return this._rawSigObject.fingerprint; - } + this.getFingerprint = function(){ + if (!_rawSigObject.fingerprint){ + return gpgme_error('SIG_WRONG'); + } else { + return _rawSigObject.fingerprint; + } + }; /** * The expiration of this Signature as Javascript date, or null if * signature does not expire * @returns {Date | null} */ - get expiration(){ - if (!this._rawSigObject.exp_timestamp){ + this.getExpiration = function(){ + if (!_rawSigObject.exp_timestamp){ return null; } - return new Date(this._rawSigObject.exp_timestamp* 1000); - } + return new Date(_rawSigObject.exp_timestamp* 1000); + }; /** * The creation date of this Signature in Javascript Date * @returns {Date} */ - get timestamp(){ - return new Date(this._rawSigObject.timestamp * 1000); - } + this.getTimestamp= function (){ + return new Date(_rawSigObject.timestamp * 1000); + }; /** * The overall validity of the key. If false, errorDetails may contain * additional information */ - get valid() { - if (this._rawSigObject.summary.valid === true){ + this.getValid= function() { + if (_rawSigObject.summary.valid === true){ return true; } else { return false; } - } + }; /** * gives more information on non-valid signatures. Refer to the gpgme docs @@ -127,19 +130,54 @@ class GPGME_Signature { * details on the values * @returns {Object} Object with boolean properties */ - get errorDetails(){ + this.getErrorDetails = function (){ let properties = ['revoked', 'key-expired', 'sig-expired', 'key-missing', 'crl-missing', 'crl-too-old', 'bad-policy', 'sys-error']; let result = {}; for (let i=0; i< properties.length; i++){ - if ( this._rawSigObject.hasOwnProperty(properties[i]) ){ - result[properties[i]] = this._rawSigObject[properties[i]]; + if ( _rawSigObject.hasOwnProperty(properties[i]) ){ + result[properties[i]] = _rawSigObject[properties[i]]; } } return result; + }; +} + + /** + * Convenience getter for {@link getFingerprint} + */ + get fingerprint(){ + return this.getFingerprint(); } + /** + * Convenience getter for {@link getExpiration} + */ + get expiration(){ + return this.getExpiration(); + } + + /** + * Convenience getter for {@link getTimeStamp} + */ + get timestamp(){ + return this.getTimestamp(); + } + + /** + * Convenience getter for {@link getValid} + */ + get valid(){ + return this.getValid(); + } + + /** + * Convenience getter for {@link getErrorDetails} + */ + get errorDetails(){ + return this.getErrorDetails(); + } } /** |