mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-06-07 14:46:42 +00:00
TS: generateKey
: fix options.type
definitions to accept 'curve25519'
and 'curve448'
This commit is contained in:
parent
01b62399af
commit
2d65d1d553
10
openpgp.d.ts
vendored
10
openpgp.d.ts
vendored
@ -702,7 +702,7 @@ export type EllipticCurveName = 'ed25519Legacy' | 'curve25519Legacy' | 'nistP256
|
|||||||
interface GenerateKeyOptions {
|
interface GenerateKeyOptions {
|
||||||
userIDs: MaybeArray<UserID>;
|
userIDs: MaybeArray<UserID>;
|
||||||
passphrase?: string;
|
passphrase?: string;
|
||||||
type?: 'ecc' | 'rsa';
|
type?: 'ecc' | 'rsa' | 'curve25519' | 'curve448';
|
||||||
curve?: EllipticCurveName;
|
curve?: EllipticCurveName;
|
||||||
rsaBits?: number;
|
rsaBits?: number;
|
||||||
keyExpirationTime?: number;
|
keyExpirationTime?: number;
|
||||||
@ -713,14 +713,8 @@ interface GenerateKeyOptions {
|
|||||||
}
|
}
|
||||||
export type KeyOptions = GenerateKeyOptions;
|
export type KeyOptions = GenerateKeyOptions;
|
||||||
|
|
||||||
export interface SubkeyOptions {
|
export interface SubkeyOptions extends Pick<GenerateKeyOptions, 'type' | 'curve' | 'rsaBits' | 'keyExpirationTime' | 'date' | 'config'> {
|
||||||
type?: 'ecc' | 'rsa';
|
|
||||||
curve?: EllipticCurveName;
|
|
||||||
rsaBits?: number;
|
|
||||||
keyExpirationTime?: number;
|
|
||||||
date?: Date;
|
|
||||||
sign?: boolean;
|
sign?: boolean;
|
||||||
config?: PartialConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class KeyID {
|
export declare class KeyID {
|
||||||
|
@ -22,7 +22,12 @@ import {
|
|||||||
(async () => {
|
(async () => {
|
||||||
|
|
||||||
// Generate keys
|
// 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: privateKeyArmored, publicKey: publicKeyArmored } = await generateKey(keyOptions);
|
||||||
const { privateKey: privateKeyBinary } = await generateKey({ ...keyOptions, format: 'binary' });
|
const { privateKey: privateKeyBinary } = await generateKey({ ...keyOptions, format: 'binary' });
|
||||||
const { privateKey, publicKey, revocationCertificate } = await generateKey({ ...keyOptions, format: 'object' });
|
const { privateKey, publicKey, revocationCertificate } = await generateKey({ ...keyOptions, format: 'object' });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user