UNPKG

age-encryption

Version:

<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://github.com/FiloSottile/age/blob/main/logo/logo_white.svg"> <source media="(prefers-color-scheme: light)" srcset="https://github.com/FiloSottile/a

90 lines (89 loc) 3.4 kB
import { Stanza } from "./format.js"; import { type Identity, type Recipient } from "./index.js"; /** * Generate a new native age identity. * * Currently, this returns an X25519 identity. In the future, this may return a * post-quantum hybrid identity like {@link generateHybridIdentity}. To * explicitly generate an X25519 identity, use {@link generateX25519Identity}. * * @returns A promise that resolves to the new identity, a string starting with * `AGE-SECRET-KEY-1...`. Use {@link identityToRecipient} to produce the * corresponding recipient. */ export declare function generateIdentity(): Promise<string>; /** * Generate a new X25519 native age identity. * * @returns A promise that resolves to the new identity, a string starting with * `AGE-SECRET-KEY-1...`. Use {@link identityToRecipient} to produce the * corresponding recipient. */ export declare function generateX25519Identity(): Promise<string>; /** * Generate a new post-quantum hybrid native age identity. * * @returns A promise that resolves to the new identity, a string starting with * `AGE-SECRET-KEY-PQ-1...`. Use {@link identityToRecipient} to produce the * corresponding recipient. */ export declare function generateHybridIdentity(): Promise<string>; /** * Convert an age identity to a recipient. * * @param identity - An age identity, a string starting with * `AGE-SECRET-KEY-PQ-1...` or `AGE-SECRET-KEY-1...` or an X25519 private * {@link https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey | CryptoKey} * object. * * @returns A promise that resolves to the corresponding recipient, a string * starting with `age1...`. * * @see {@link generateIdentity} * @see {@link Decrypter.addIdentity} */ export declare function identityToRecipient(identity: string | CryptoKey): Promise<string>; export declare class HybridRecipient implements Recipient { private recipient; constructor(s: string); wrapFileKey(fileKey: Uint8Array): Stanza[]; } export declare class HybridIdentity implements Identity { private identity; constructor(s: string); unwrapFileKey(stanzas: Stanza[]): Uint8Array | null; } export declare class TagRecipient implements Recipient { private recipient; constructor(s: string); wrapFileKey(fileKey: Uint8Array): Stanza[]; } export declare class HybridTagRecipient implements Recipient { private recipient; constructor(s: string); wrapFileKey(fileKey: Uint8Array): Stanza[]; } export declare class X25519Recipient implements Recipient { private recipient; constructor(s: string); wrapFileKey(fileKey: Uint8Array): Promise<Stanza[]>; } export declare class X25519Identity implements Identity { private identity; private recipient; constructor(s: string | CryptoKey); unwrapFileKey(stanzas: Stanza[]): Promise<Uint8Array | null>; } export declare class ScryptRecipient implements Recipient { private passphrase; private logN; constructor(passphrase: string, logN: number); wrapFileKey(fileKey: Uint8Array): Stanza[]; } export declare class ScryptIdentity implements Identity { private passphrase; constructor(passphrase: string); unwrapFileKey(stanzas: Stanza[]): Uint8Array | null; } export declare function encryptFileKey(fileKey: Uint8Array, key: Uint8Array): Uint8Array; export declare function decryptFileKey(body: Uint8Array, key: Uint8Array): Uint8Array | null;