Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openpgp.js: Add HKP types #33410

Merged
merged 4 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions types/openpgp/common/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class HKP {
constructor(keyServerUrl?: string);
lookup(options: {keyId?: string, query?: string }): Promise<string>;
upload(publicKeyArmored: string): Promise<Response>;
}
4 changes: 3 additions & 1 deletion types/openpgp/index.d.ts
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -10,6 +10,8 @@

export as namespace openpgp;

export * from './common';

export interface UserId {
name?: string,
email?: string,
Expand Down
17 changes: 17 additions & 0 deletions types/openpgp/openpgp-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 3 additions & 1 deletion types/openpgp/ts3.2/index.d.ts
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -9,6 +9,8 @@

export as namespace openpgp;

export * from '../common';

export interface UserId {
name?: string,
email?: string,
Expand Down