Keys, trust, and signatures
Exact declarations for 58 package-root exports. Private and protected class members are omitted.
AllowedSignerPrincipalLookupOptions
Interface. Declared in src/AllowedSigners.ts.
export interface AllowedSignerPrincipalLookupOptions {
/** Lookup instant. Numbers and bigints are Unix seconds; Dates are converted to seconds. */
at?: Date | number | bigint;
/** Optional revocation policy applied before returning principals. */
revocations?: KeyRevocationList;
}AllowedSigners
Class. Declared in src/AllowedSigners.ts.
/** OpenSSH allowed-signers policy with integrated detached-signature verification. */
export default class AllowedSigners {
static parse(content: string | Buffer): AllowedSigners;
static load(path: string): Promise<AllowedSigners>;
/** Returns the policy principal fields whose pattern lists positively match this value. */
matchPrincipals(principal: string): readonly string[];
/** Finds the first entry's principals authorized for an embedded signature key. */
findPrincipals(signature: SSHSignature | string | Buffer, options?: AllowedSignerPrincipalLookupOptions): readonly string[];
verify(message: Buffer, signature: SSHSignature | string | Buffer, options: AllowedSignerVerificationOptions): boolean;
}AllowedSignerVerificationOptions
Interface. Declared in src/AllowedSigners.ts.
export interface AllowedSignerVerificationOptions {
/** Expected signer identity matched against the entry and any user certificate principals. */
principal: string;
/** Expected SSHSIG namespace and allowed-signers namespace pattern input. */
namespace: string;
/** Verification instant. Numbers and bigints are Unix seconds; Dates are converted to seconds. */
at?: Date | number | bigint;
/** Optional revocation policy applied to the embedded signing key or certificate. */
revocations?: KeyRevocationList;
}EncodedSecurityKeySignatureData
Interface. Declared in src/utils/Signature.ts.
export interface EncodedSecurityKeySignatureData {
flags: number;
counter: number;
webAuthn?: EncodedWebAuthnSignatureData;
}EncodedSignature
Class. Declared in src/utils/Signature.ts.
export default class EncodedSignature {
data: EncodedSignatureData;
constructor(data: EncodedSignatureData);
serialize(): Buffer;
static parse(raw: Buffer): EncodedSignature;
}EncodedSignatureData
Interface. Declared in src/utils/Signature.ts.
export interface EncodedSignatureData {
alg: string;
data: Buffer;
securityKey?: EncodedSecurityKeySignatureData;
}EncodedWebAuthnSignatureData
Interface. Declared in src/utils/Signature.ts.
export interface EncodedWebAuthnSignatureData {
origin: string;
clientData: Buffer;
extensions: Buffer;
}GeneratedKeyPair
Interface. Declared in src/KeyGeneration.ts.
export interface GeneratedKeyPair {
readonly privateKey: PrivateKey;
readonly publicKey: PublicKey;
}generateKeyPair
Function. Declared in src/KeyGeneration.ts.
/** Generate a supported SSH key pair using Node's cryptographic random source. */
export declare function generateKeyPair(type: KeyPairType, options?: GenerateKeyPairOptions): Promise<GeneratedKeyPair>;GenerateKeyPairOptions
Interface. Declared in src/KeyGeneration.ts.
export interface GenerateKeyPairOptions {
/** RSA modulus or ECDSA curve size. RSA defaults to 3072; ECDSA defaults to 256; fixed-size keys reject it. */
bits?: number;
/** Optional comment embedded in both OpenSSH serializations. */
comment?: string;
}generateKeyPairSync
Function. Declared in src/KeyGeneration.ts.
/** Generate a supported SSH key pair synchronously using Node's cryptographic random source. */
export declare function generateKeyPairSync(type: KeyPairType, options?: GenerateKeyPairOptions): GeneratedKeyPair;KeyPairType
Type. Declared in src/KeyGeneration.ts.
export type KeyPairType = "ed25519" | "ed448" | "rsa" | "ecdsa" | "dsa";KeyRevocationList
Class. Declared in src/KeyRevocationList.ts.
export default class KeyRevocationList {
/** Monotonic version recorded in the KRL header. Rollback enforcement is application policy. */
readonly version: bigint;
/** KRL generation time as unsigned Unix seconds. */
readonly generatedAt: bigint;
/** Human-readable KRL header comment. */
readonly comment: string;
static parse(content: Buffer): KeyRevocationList;
static load(path: string): Promise<KeyRevocationList>;
/** Tests plain keys and all applicable certificate, embedded-key, and authority records. */
isRevoked(key: PublicKey | Buffer): boolean;
/** Returns whether an embedded, cryptographically verified signature uses this exact key. */
isSignedBy(key: PublicKey | Buffer): boolean;
}KnownHostCheckResult
Interface. Declared in src/KnownHosts.ts.
export interface KnownHostCheckResult {
readonly status: KnownHostStatus;
readonly line?: number;
readonly key?: PublicKey;
}KnownHostMarker
Type. Declared in src/KnownHosts.ts.
export type KnownHostMarker = "cert-authority" | "revoked";KnownHosts
Class. Declared in src/KnownHosts.ts.
export default class KnownHosts {
static parse(content: string | Buffer): KnownHosts;
static load(path: string): Promise<KnownHosts>;
check(hostname: string, key: PublicKey | Buffer, port?: number): KnownHostCheckResult;
assertTrusted(hostname: string, key: PublicKey | Buffer, port?: number): void;
hostKeyHook(hostname: string, port?: number): Hook<ClientHooker["hostKey"]>;
replaceHostKeys(hostname: string, keys: readonly (PublicKey | string | Buffer)[], options?: KnownHostsReplaceOptions): Promise<void>;
toString(): string;
}KnownHostsError
Class. Declared in src/KnownHosts.ts.
export declare class KnownHostsError extends Error {
readonly status: Exclude<KnownHostStatus, "trusted">;
readonly line?: number;
constructor(result: KnownHostCheckResult, host: string);
}KnownHostsReplaceOptions
Interface. Declared in src/KnownHosts.ts.
export interface KnownHostsReplaceOptions {
/** SSH port. Port 22 uses the bare hostname; other ports use `[hostname]:port`. */
port?: number;
/** Store one independently salted HMAC-SHA1 hostname for each key. */
hashHostname?: boolean;
}KnownHostStatus
Type. Declared in src/KnownHosts.ts.
export type KnownHostStatus = "trusted" | "unknown" | "changed" | "revoked";ParsedKey
Type. Declared in src/KeyParsing.ts.
export type ParsedKey = PrivateKey | PublicKey;parseKey
Function. Declared in src/KeyParsing.ts.
export declare function parseKey(data: string | Buffer, passphrase?: string | Buffer): ParsedKey;parseKeys
Function. Declared in src/KeyParsing.ts.
export declare function parseKeys(data: string | Buffer, passphrase?: string | Buffer): ParsedKey[];parseRFC4716PublicKey
Function. Declared in src/utils/RFC4716.ts.
export declare function parseRFC4716PublicKey(data: string | Buffer): PublicKey;parseRFC4716PublicKeyFile
Function. Declared in src/utils/RFC4716.ts.
export declare function parseRFC4716PublicKeyFile(data: string | Buffer): RFC4716PublicKeyFile;PrivateKey
Class. Declared in src/utils/PrivateKey.ts.
export default class PrivateKey {
static algorithms: Map<string, typeof PrivateKeyAlgorithm>;
data: PrivateKeyData;
constructor(data: PrivateKeyData);
sign(data: Buffer, algorithm?: string): EncodedSignature;
equals(other: PrivateKey): boolean;
withCertificate(certificate: PublicKey): PrivateKey;
serialize(options?: OpenSSHPrivateKeyEncryptionOptions): Buffer;
static serializeMany(keys: readonly PrivateKey[], options?: OpenSSHPrivateKeyEncryptionOptions): Buffer;
static parse(raw: Buffer, passphrase?: string | Buffer): PrivateKey;
static parseAll(raw: Buffer, passphrase?: string | Buffer): PrivateKey[];
toString(options?: OpenSSHPrivateKeyEncryptionOptions): string;
/** Export the locally held private scalar as unencrypted PKCS#8 PEM. */
toPEM(): string;
static toStringMany(keys: readonly PrivateKey[], options?: OpenSSHPrivateKeyEncryptionOptions): string;
static fromString(data: string, passphrase?: string | Buffer): PrivateKey;
static fromStringAll(data: string, passphrase?: string | Buffer): PrivateKey[];
static fromPuTTY(data: string | Buffer, passphrase?: string | Buffer): PrivateKey;
static fromPEM(data: string, passphrase?: string | Buffer): PrivateKey;
static generate(alg: string): Promise<PrivateKey>;
static generateSync(alg: string): PrivateKey;
}PrivateKeyAlgorithm
Class. Declared in src/utils/PrivateKey.ts.
export declare abstract class PrivateKeyAlgorithm {
static alg_name: string;
constructor(data: unknown);
sign(data: Buffer, algorithm?: string): EncodedSignature;
getPublicKey(): PublicKey;
serialize(): Buffer;
static parse(raw: Buffer): [
PrivateKeyAlgorithm,
Buffer
];
static generate(): Promise<PrivateKey>;
static generateSync(): PrivateKey;
}PrivateKeyData
Interface. Declared in src/utils/PrivateKey.ts.
export interface PrivateKeyData {
publicKey: PublicKey;
alg: string;
algorithm: PrivateKeyAlgorithm;
comment?: string;
}PublicKey
Class. Declared in src/utils/PublicKey.ts.
export default class PublicKey {
static algorithms: Map<string, typeof PublicKeyAlgorithm>;
data: PublicKeyData;
constructor(data: PublicKeyData);
get signatureAlgorithms(): readonly string[];
supportsSignatureAlgorithm(algorithm: string): boolean;
signatureAlgorithmFor(algorithm: string): string;
verifySignature(data: Buffer, signature: EncodedSignature): boolean;
toString(): string;
/** Export the underlying cryptographic public key as SubjectPublicKeyInfo PEM. */
toPEM(): string;
hash(algorithm: "md5" | "sha256" | "sha512"): string;
serialize(): Buffer;
equals(other: PublicKey): boolean;
static parse(raw: Buffer): PublicKey;
static parseString(content: string): PublicKey;
static fromPEM(data: string | Buffer): PublicKey;
static parseAuthorizedKeysFile(content: string): PublicKey[];
}PublicKeyAlgorithm
Class. Declared in src/utils/PublicKey.ts.
export declare abstract class PublicKeyAlgorithm {
static alg_name: string;
static has_encryption: boolean;
static has_signature: boolean;
constructor(data: unknown);
verifySignature(data: Buffer, signature: Buffer, algorithm?: string, securityKey?: EncodedSecurityKeySignatureData): boolean;
serialize(): Buffer;
equals(other: PublicKeyAlgorithm): boolean;
static parse(raw: Buffer): PublicKeyAlgorithm;
}PublicKeyData
Interface. Declared in src/utils/PublicKey.ts.
export interface PublicKeyData {
alg: string;
algorithm: PublicKeyAlgorithm;
comment?: string;
}RFC4716Header
Interface. Declared in src/utils/RFC4716.ts.
export interface RFC4716Header {
readonly tag: string;
readonly value: string;
}RFC4716PublicKeyFile
Interface. Declared in src/utils/RFC4716.ts.
export interface RFC4716PublicKeyFile {
readonly publicKey: PublicKey;
readonly headers: readonly Readonly<RFC4716Header>[];
}SecurityKeyAttestation
Class. Declared in src/SecurityKeyAttestation.ts.
/** Opaque enrollment evidence stored in the published security-key attestation format. */
export default class SecurityKeyAttestation {
readonly format: SecurityKeyAttestationFormat;
readonly flags: number;
get certificate(): Buffer;
get enrollmentSignature(): Buffer;
get authenticatorData(): Buffer | undefined;
get reserved(): Buffer;
static parse(content: Buffer): SecurityKeyAttestation;
static load(path: string): Promise<SecurityKeyAttestation>;
serialize(): Buffer;
}SecurityKeyAttestationFormat
Type. Declared in src/SecurityKeyAttestation.ts.
export type SecurityKeyAttestationFormat = "ssh-sk-attest-v00" | "ssh-sk-attest-v01";serializeRFC4716PublicKey
Function. Declared in src/utils/RFC4716.ts.
export declare function serializeRFC4716PublicKey(publicKey: PublicKey, headers?: readonly RFC4716Header[]): string;SSH_ECDSA_SECURITY_KEY_ALGORITHM
Constant. Declared in src/utils/Signature.ts.
export declare const SSH_ECDSA_SECURITY_KEY_ALGORITHM = "sk-ecdsa-sha2-nistp256@openssh.com";SSH_ED25519_SECURITY_KEY_ALGORITHM
Constant. Declared in src/utils/Signature.ts.
export declare const SSH_ED25519_SECURITY_KEY_ALGORITHM = "sk-ssh-ed25519@openssh.com";SSH_WEBAUTHN_ECDSA_SECURITY_KEY_ALGORITHM
Constant. Declared in src/utils/Signature.ts.
export declare const SSH_WEBAUTHN_ECDSA_SECURITY_KEY_ALGORITHM = "webauthn-sk-ecdsa-sha2-nistp256@openssh.com";SSHCertificateData
Interface. Declared in src/utils/PublicKey.ts.
export interface SSHCertificateData {
readonly nonce: Buffer;
readonly publicKey: PublicKey;
readonly serial: bigint;
readonly role: SSHCertificateRole;
readonly identifier: string;
readonly principals: readonly string[];
readonly validAfter: bigint;
readonly validBefore: bigint;
readonly criticalOptions: readonly SSHCertificateOption[];
readonly extensions: readonly SSHCertificateOption[];
readonly reserved: Buffer;
readonly signatureKey: PublicKey;
readonly signature: EncodedSignature;
}SSHCertificateOption
Interface. Declared in src/utils/PublicKey.ts.
export interface SSHCertificateOption {
readonly name: string;
readonly data: Buffer;
}SSHCertificatePublicKey
Class. Declared in src/utils/PublicKey.ts.
export declare class SSHCertificatePublicKey implements PublicKeyAlgorithm {
static has_encryption: boolean;
static has_signature: boolean;
readonly algorithmName: string;
readonly data: SSHCertificateData;
get publicKey(): PublicKey;
verifyCertificateSignature(): boolean;
verifyHostCertificate(hostname: string, at?: bigint): boolean;
verifySignature(data: Buffer, signature: Buffer, algorithm?: string, securityKey?: EncodedSecurityKeySignatureData): boolean;
serialize(): Buffer;
equals(other: PublicKeyAlgorithm): boolean;
static parse(algorithmName: string, keyAlgorithm: string, payload: Buffer): SSHCertificatePublicKey;
}SSHCertificateRole
Type. Declared in src/utils/PublicKey.ts.
export type SSHCertificateRole = "user" | "host";SSHECDSASecurityKeyPrivateKey
Class. Declared in src/utils/PrivateKey.ts.
export declare class SSHECDSASecurityKeyPrivateKey implements PrivateKeyAlgorithm {
static alg_name: string;
readonly data: SSHECDSASecurityKeyPrivateKeyData;
constructor(data: SSHECDSASecurityKeyPrivateKeyData);
sign(): EncodedSignature;
getPublicKey(): PublicKey;
serialize(): Buffer;
static parse(raw: Buffer): [
PrivateKeyAlgorithm,
Buffer
];
static generate(): Promise<PrivateKey>;
static generateSync(): PrivateKey;
}SSHECDSASecurityKeyPrivateKeyData
Interface. Declared in src/utils/PrivateKey.ts.
export interface SSHECDSASecurityKeyPrivateKeyData {
publicKey: Buffer;
application: string;
flags: number;
keyHandle: Buffer;
reserved: Buffer;
}SSHECDSASecurityKeyPublicKey
Class. Declared in src/utils/PublicKey.ts.
export declare class SSHECDSASecurityKeyPublicKey implements PublicKeyAlgorithm {
static alg_name: string;
static has_encryption: boolean;
static has_signature: boolean;
readonly data: SSHECDSASecurityKeyPublicKeyData;
constructor(data: SSHECDSASecurityKeyPublicKeyData);
verifySignature(data: Buffer, signature: Buffer, algorithm?: string, securityKey?: EncodedSecurityKeySignatureData): boolean;
serialize(): Buffer;
equals(other: PublicKeyAlgorithm): boolean;
static parse(raw: Buffer): SSHECDSASecurityKeyPublicKey;
}SSHECDSASecurityKeyPublicKeyData
Interface. Declared in src/utils/PublicKey.ts.
export interface SSHECDSASecurityKeyPublicKeyData {
publicKey: Buffer;
application: string;
}SSHED25519SecurityKeyPrivateKey
Class. Declared in src/utils/PrivateKey.ts.
export declare class SSHED25519SecurityKeyPrivateKey implements PrivateKeyAlgorithm {
static alg_name: string;
readonly data: SSHED25519SecurityKeyPrivateKeyData;
constructor(data: SSHED25519SecurityKeyPrivateKeyData);
sign(): EncodedSignature;
getPublicKey(): PublicKey;
serialize(): Buffer;
static parse(raw: Buffer): [
PrivateKeyAlgorithm,
Buffer
];
static generate(): Promise<PrivateKey>;
static generateSync(): PrivateKey;
}SSHED25519SecurityKeyPrivateKeyData
Interface. Declared in src/utils/PrivateKey.ts.
export interface SSHED25519SecurityKeyPrivateKeyData {
publicKey: Buffer;
application: string;
flags: number;
keyHandle: Buffer;
reserved: Buffer;
}SSHED25519SecurityKeyPublicKey
Class. Declared in src/utils/PublicKey.ts.
export declare class SSHED25519SecurityKeyPublicKey implements PublicKeyAlgorithm {
static alg_name: string;
static has_encryption: boolean;
static has_signature: boolean;
readonly data: SSHED25519SecurityKeyPublicKeyData;
constructor(data: SSHED25519SecurityKeyPublicKeyData);
verifySignature(data: Buffer, signature: Buffer, algorithm?: string, securityKey?: EncodedSecurityKeySignatureData): boolean;
serialize(): Buffer;
equals(other: PublicKeyAlgorithm): boolean;
static parse(raw: Buffer): SSHED25519SecurityKeyPublicKey;
}SSHED25519SecurityKeyPublicKeyData
Interface. Declared in src/utils/PublicKey.ts.
export interface SSHED25519SecurityKeyPublicKeyData {
publicKey: Buffer;
application: string;
}SSHFPAlgorithm
Enum. Declared in src/SSHFP.ts.
/** DNS SSHFP public-key algorithm numbers assigned by the IANA registry. */
export declare enum SSHFPAlgorithm {
RSA = 1,
DSA = 2,
ECDSA = 3,
Ed25519 = 4,
Ed448 = 6
}SSHFPFingerprintType
Enum. Declared in src/SSHFP.ts.
/** DNS SSHFP fingerprint-type numbers assigned by the IANA registry. */
export declare enum SSHFPFingerprintType {
SHA1 = 1,
SHA256 = 2
}SSHFPRecord
Class. Declared in src/SSHFP.ts.
/**
* One SSHFP RDATA value. DNS owner names, TTLs, and DNSSEC validation state are deliberately not
* part of this value object.
*/
export default class SSHFPRecord {
readonly algorithm: number;
readonly fingerprintType: number;
constructor(algorithm: number, fingerprintType: number, fingerprint: Buffer);
/** A defensive copy of the opaque fingerprint bytes. */
get fingerprint(): Buffer;
/** Parses the complete binary RDATA of one SSHFP resource record. */
static parse(rdata: Buffer): SSHFPRecord;
/**
* Parses the presentation-format RDATA fields, without a DNS owner name, class, TTL, or `SSHFP`
* mnemonic.
*/
static parseText(rdata: string): SSHFPRecord;
/** Generates a fingerprint over the exact SSH public-key blob. SHA-256 is the default. */
static fromPublicKey(publicKey: PublicKey, fingerprintType?: SSHFPFingerprintType): SSHFPRecord;
serialize(): Buffer;
/** Returns the three presentation-format RDATA fields accepted by DNS zone-file tools. */
toString(): string;
}SSHFPVerificationResult
Type. Declared in src/SSHFP.ts.
export type SSHFPVerificationResult = "match" | "mismatch" | "no-supported-records";SSHSignature
Class. Declared in src/SSHSignature.ts.
/** OpenSSH-compatible detached signatures with mandatory namespace-bound verification. */
export default class SSHSignature {
readonly version: number;
readonly publicKey: PublicKey;
readonly hashAlgorithm: SSHSignatureHashAlgorithm;
readonly signature: EncodedSignature;
/** Namespace bytes retained by the detached signature. */
get namespace(): Buffer;
/** Reserved format bytes. Version 1 signers emit an empty value. */
get reserved(): Buffer;
static sign(message: Buffer, privateKey: PrivateKey, options: SSHSignatureOptions): SSHSignature;
static signWithAgent<Id>(message: Buffer, agent: Agent<Id>, id: Id, options: SSHSignatureOptions): Promise<SSHSignature>;
static parse(content: string | Buffer): SSHSignature;
verify(message: Buffer, expectedNamespace: string | Buffer): boolean;
serialize(): Buffer;
toString(): string;
}SSHSignatureHashAlgorithm
Type. Declared in src/SSHSignature.ts.
export type SSHSignatureHashAlgorithm = "sha256" | "sha512";SSHSignatureOptions
Interface. Declared in src/SSHSignature.ts.
export interface SSHSignatureOptions {
/** Application domain that prevents a signature from being reused by another protocol. */
namespace: string | Buffer;
/** Message digest placed in the signed preimage. Defaults to `sha512`. */
hashAlgorithm?: SSHSignatureHashAlgorithm;
}verifySSHFP
Function. Declared in src/SSHFP.ts.
/**
* Verifies one public key against an authenticated SSHFP RRset.
*
* The caller must establish the owner name and DNSSEC authenticity before treating `match` as
* trust. SHA-256 records take precedence over SHA-1 records as required by RFC 6594.
*/
export declare function verifySSHFP(publicKey: PublicKey, records: readonly SSHFPRecord[]): SSHFPVerificationResult;