TS: generateKey: fix options.type definitions to accept 'curve25519' and 'curve448'

This commit is contained in:
larabr 2024-11-11 13:28:05 +01:00
parent 01b62399af
commit 2d65d1d553
2 changed files with 8 additions and 9 deletions

10
openpgp.d.ts vendored
View File

@ -702,7 +702,7 @@ export type EllipticCurveName = 'ed25519Legacy' | 'curve25519Legacy' | 'nistP256
interface GenerateKeyOptions {
userIDs: MaybeArray<UserID>;
passphrase?: string;
type?: 'ecc' | 'rsa';
type?: 'ecc' | 'rsa' | 'curve25519' | 'curve448';
curve?: EllipticCurveName;
rsaBits?: number;
keyExpirationTime?: number;
@ -713,14 +713,8 @@ interface GenerateKeyOptions {
}
export type KeyOptions = GenerateKeyOptions;
export interface SubkeyOptions {
type?: 'ecc' | 'rsa';
curve?: EllipticCurveName;
rsaBits?: number;
keyExpirationTime?: number;
date?: Date;
export interface SubkeyOptions extends Pick<GenerateKeyOptions, 'type' | 'curve' | 'rsaBits' | 'keyExpirationTime' | 'date' | 'config'> {
sign?: boolean;
config?: PartialConfig;
}
export declare class KeyID {

View File

@ -22,7 +22,12 @@ import {
(async () => {
// Generate keys
const keyOptions = { userIDs: [{ email: 'user@corp.co' }], config: { v6Keys: true } };
const keyOptions = {
type: 'curve25519' as const,
userIDs: [{ email: 'user@corp.co' }],
subkeys: [{ type: 'rsa' as const, sign: false }],
config: { v6Keys: true }
};
const { privateKey: privateKeyArmored, publicKey: publicKeyArmored } = await generateKey(keyOptions);
const { privateKey: privateKeyBinary } = await generateKey({ ...keyOptions, format: 'binary' });
const { privateKey, publicKey, revocationCertificate } = await generateKey({ ...keyOptions, format: 'object' });