|
@@ -25,12 +25,10 @@ export class PgpKeyServerProvider {
|
|
|
|
|
|
public async publishPubKey(pubkey) {
|
|
public async publishPubKey(pubkey) {
|
|
this.hkp.upload(pubkey).then(function(result) {
|
|
this.hkp.upload(pubkey).then(function(result) {
|
|
- // console.log('public key successfully uploaded', result);
|
|
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
public async lookupKeys(email: string) {
|
|
public async lookupKeys(email: string) {
|
|
- // console.log('looking up keys for',email);
|
|
|
|
let pubkey;
|
|
let pubkey;
|
|
let myEmail = await this.storage.get("email");
|
|
let myEmail = await this.storage.get("email");
|
|
if(email === myEmail){
|
|
if(email === myEmail){
|
|
@@ -46,7 +44,6 @@ export class PgpKeyServerProvider {
|
|
try {
|
|
try {
|
|
let armoredPubkey = await this.hkp.lookup(options);
|
|
let armoredPubkey = await this.hkp.lookup(options);
|
|
pubkey = (await openpgp.key.readArmored(armoredPubkey)).keys[0];
|
|
pubkey = (await openpgp.key.readArmored(armoredPubkey)).keys[0];
|
|
- // console.log("pubkey from server:",pubkey);
|
|
|
|
this.pk.push(pubkey);
|
|
this.pk.push(pubkey);
|
|
return pubkey;
|
|
return pubkey;
|
|
} catch (err) {
|
|
} catch (err) {
|
|
@@ -70,7 +67,6 @@ export class PgpKeyServerProvider {
|
|
const options = {
|
|
const options = {
|
|
message: openpgp.message.fromText(plainText), // input as Message object
|
|
message: openpgp.message.fromText(plainText), // input as Message object
|
|
publicKeys: await Promise.all(this.pk), // for encryption
|
|
publicKeys: await Promise.all(this.pk), // for encryption
|
|
- // privateKey s: [privKeyObj] // for signing (optional)
|
|
|
|
}
|
|
}
|
|
const ciphertext = await openpgp.encrypt(options);
|
|
const ciphertext = await openpgp.encrypt(options);
|
|
return ciphertext.data;
|
|
return ciphertext.data;
|
|
@@ -84,7 +80,7 @@ export class PgpKeyServerProvider {
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
let plaintext = await openpgp.decrypt(options2);
|
|
let plaintext = await openpgp.decrypt(options2);
|
|
- return plaintext.data // 'Hello, World!'
|
|
|
|
|
|
+ return plaintext.data
|
|
} catch (err) {
|
|
} catch (err) {
|
|
console.log('Error thrown:', err);
|
|
console.log('Error thrown:', err);
|
|
}
|
|
}
|
|
@@ -107,18 +103,16 @@ export class PgpKeyServerProvider {
|
|
});
|
|
});
|
|
|
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- console.log('revoke failed1', e);
|
|
|
|
|
|
+ console.log('revoke failed', e);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
async getArmoredPrivateKey(key:string){
|
|
async getArmoredPrivateKey(key:string){
|
|
const privKeyObj = (await openpgp.key.readArmored(key)).keys[0];
|
|
const privKeyObj = (await openpgp.key.readArmored(key)).keys[0];
|
|
- // console.log("key is:",key,'amd',privKeyObj);
|
|
|
|
|
|
|
|
if(privKeyObj){
|
|
if(privKeyObj){
|
|
await privKeyObj.decrypt(this.passphrase);
|
|
await privKeyObj.decrypt(this.passphrase);
|
|
- // console.log("Key:",key , "Armored key ",privKeyObj);
|
|
|
|
return privKeyObj;
|
|
return privKeyObj;
|
|
}
|
|
}
|
|
else
|
|
else
|