aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/gpgmejs_openpgpjs.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-04-24 16:44:30 +0000
committerMaximilian Krambach <[email protected]>2018-04-24 16:44:30 +0000
commit461dd0c8b41683a91073b362d100ee5217ec53f6 (patch)
tree15ab814b70a583db52f7f9e664aaa016057d98d0 /lang/js/src/gpgmejs_openpgpjs.js
parentjs: don't allow message operation changes (diff)
downloadgpgme-461dd0c8b41683a91073b362d100ee5217ec53f6.tar.gz
gpgme-461dd0c8b41683a91073b362d100ee5217ec53f6.zip
js: change in initialization ancd connection handling
-- * The Connection will now be started before an object is created, to better account for failures. * index.js: now exposes an init(), which returns a Promise of configurable <GpgME | gpgmeGpgME_openPGPCompatibility> with an established connection. * TODO: There is currently no way to recover from a "connection lost" * Connection.js offers Connection.isConnected, which toggles on port closing.
Diffstat (limited to 'lang/js/src/gpgmejs_openpgpjs.js')
-rw-r--r--lang/js/src/gpgmejs_openpgpjs.js33
1 files changed, 23 insertions, 10 deletions
diff --git a/lang/js/src/gpgmejs_openpgpjs.js b/lang/js/src/gpgmejs_openpgpjs.js
index 54b9dd45..f1ddb5d6 100644
--- a/lang/js/src/gpgmejs_openpgpjs.js
+++ b/lang/js/src/gpgmejs_openpgpjs.js
@@ -30,13 +30,29 @@
import { isFingerprint } from "./Helpers"
import { GPGMEJS_Error } from './Errors'
+
export class GpgME_openPGPCompatibility {
- constructor(){
- this._gpgme = new GpgME({
- null_expire_is_never: false
- });
- this.Keyring = this.initKeyring();
+ constructor(connection){
+ this.initGpgME(connection);
+ }
+
+ get Keyring(){
+ if (this._keyring){
+ return this._keyring;
+ }
+ return undefined;
+ }
+
+ initGpgME(connection){
+ this._GpgME = new GpgME(connection);
+ this._Keyring = new GPGME_Keyring_openPGPCompatibility(connection);
+ }
+
+ get GpgME(){
+ if (this._GpGME){
+ return this._GpGME;
+ }
}
/**
@@ -128,9 +144,6 @@ export class GpgME_openPGPCompatibility {
// mime: A Boolean indicating whether the data is a MIME object.
// info: An optional object with extra information.
}
- initKeyring(){
- return new GPGME_Keyring_openPGPCompatibility;
- }
}
/**
@@ -138,8 +151,8 @@ export class GpgME_openPGPCompatibility {
* It may still be changed/expanded/merged with GPGME_Keyring
*/
class GPGME_Keyring_openPGPCompatibility {
- constructor(){
- this._gpgme_keyring = new GPGME_Keyring;
+ constructor(connection){
+ this._gpgme_keyring = new GPGME_Keyring(connection);
}
/**