diff options
| author | Maximilian Krambach <[email protected]> | 2018-08-21 09:42:11 +0000 | 
|---|---|---|
| committer | Maximilian Krambach <[email protected]> | 2018-08-21 09:42:11 +0000 | 
| commit | 8b8c009dee8ae5493e7f888ee518468dbfcf5375 (patch) | |
| tree | 778783cac863197291f7efa389ae4ff27b75d845 /lang/js/src | |
| parent | js: add option "subkey-algo" to generateKey (diff) | |
| download | gpgme-8b8c009dee8ae5493e7f888ee518468dbfcf5375.tar.gz gpgme-8b8c009dee8ae5493e7f888ee518468dbfcf5375.zip | |
js: set expiry of generatedKey to seconds from now
--
* src/Keyring.js: Changed key ecpiration from Date to seconds from
  creation, as in gpgme. The Date parameter used before was due to a
  misunderstanding in documentation and requests from potential users.
Diffstat (limited to '')
| -rw-r--r-- | lang/js/src/Keyring.js | 10 | 
1 files changed, 4 insertions, 6 deletions
| diff --git a/lang/js/src/Keyring.js b/lang/js/src/Keyring.js index 81a047ca..ab0144ef 100644 --- a/lang/js/src/Keyring.js +++ b/lang/js/src/Keyring.js @@ -367,8 +367,8 @@ export class GPGME_Keyring {       * @param {String} algo (optional) algorithm (and optionally key size)       * to be used. See {@link supportedKeyAlgos} below for supported       * values. If ommitted, 'default' is used. -     * @param {Date} expires (optional) Expiration date. If not set, -     * expiration will be set to 'never' +     * @param {Number} expires (optional) Expiration time in seconds from now. +     * If not set or set to 0, expiration will be 'never'       * @param {String} subkey_algo (optional) algorithm of the encryption       * subkey. If ommited the same as algo is used.       * @@ -380,7 +380,7 @@ export class GPGME_Keyring {              typeof (userId) !== 'string' ||              // eslint-disable-next-line no-use-before-define              supportedKeyAlgos.indexOf(algo) < 0 || -            (expires && !(expires instanceof Date)) +            (expires && !( Number.isInteger(expires) || expires < 0 ))          ){              return Promise.reject(gpgme_error('PARAM_WRONG'));          } @@ -397,9 +397,7 @@ export class GPGME_Keyring {                  msg.setParameter('subkey-algo', subkey_algo );              }              if (expires){ -                const now = new Date(); -                msg.setParameter('expires', -                    Math.floor((expires - now) /1000)); +                msg.setParameter('expires', expires);              } else {                  msg.setParameter('expires', 0);              } | 
