Merge pull request #33410 from errietta/hkp-types

openpgp.js: Add HKP types
This commit is contained in:
Nathan Shively-Sanders
2019-03-06 10:38:30 -08:00
committed by GitHub
4 changed files with 28 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
export class HKP {
constructor(keyServerUrl?: string);
lookup(options: {keyId?: string, query?: string }): Promise<string>;
upload(publicKeyArmored: string): Promise<Response>;
}
+3 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for openpgp 4.0.1
// Type definitions for openpgp 4.4.8
// Project: http://openpgpjs.org/
// Definitions by: Guillaume Lacasa <https://blog.lacasa.fr>
// Errietta Kostala <https://github.com/errietta>
@@ -10,6 +10,8 @@
export as namespace openpgp;
export * from './common';
export interface UserId {
name?: string,
email?: string,
+17
View File
@@ -135,6 +135,23 @@ openpgp.initWorker({ path:'openpgp.worker.js' });
return verified.signatures[0].valid;
})();
async () => {
let hkp = new openpgp.HKP();
const hkpOptions = {
query: 'alice@example.com'
};
const armoredPubkey = await hkp.lookup(hkpOptions);
await openpgp.key.readArmored(armoredPubkey);
hkp = new openpgp.HKP('https://pgp.mit.edu');
const pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
await hkp.upload(pubkey);
}
// Open PGP Tests
+3 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for openpgp 4.0.1
// Type definitions for openpgp 4.4.8
// Project: http://openpgpjs.org/
// Definitions by: Guillaume Lacasa <https://blog.lacasa.fr>
// Errietta Kostala <https://github.com/errietta>
@@ -9,6 +9,8 @@
export as namespace openpgp;
export * from '../common';
export interface UserId {
name?: string,
email?: string,