/** * @typedef {'EC' | 'RSA' | 'OKP' | 'oct'} Kty * @typedef {'P-256' | 'P-384' | 'P-521' | 'secp256k1'} EcCurve * @typedef {'Ed25519' | 'Ed448' | 'X25519' | 'X448'} OkpCurve */ /** * @typedef {Object} GenerateOptionsCommon * @property {string} [kid] * @property {'sig' | 'enc'} [use] * @property {string} [alg] * @property {string[]} [key_ops] */ /** * @typedef {GenerateOptionsCommon & { curve?: EcCurve }} GenerateOptionsEC * @typedef {GenerateOptionsCommon & { modulusLength?: number, publicExponent?: number }} GenerateOptionsRSA * @typedef {GenerateOptionsCommon & { curve?: OkpCurve }} GenerateOptionsOKP * @typedef {GenerateOptionsCommon & { bits?: number }} GenerateOptionsOct */ /** * @typedef {Object} GeneratedKeyPair * @property {object} publicJwk public projection (asymmetric); equals `privateJwk` for `oct` * @property {object} privateJwk private JWK (contains `d`, or `k` for `oct`) */ /** * Generate a JWK for the requested `kty`. * * @param {Kty} kty * @param {GenerateOptionsEC | GenerateOptionsRSA | GenerateOptionsOKP | GenerateOptionsOct} [options] * @returns {Promise} */ declare function generate(kty: Kty, options?: GenerateOptionsEC | GenerateOptionsRSA | GenerateOptionsOKP | GenerateOptionsOct): Promise; type Kty = "EC" | "RSA" | "OKP" | "oct"; type EcCurve = "P-256" | "P-384" | "P-521" | "secp256k1"; type OkpCurve = "Ed25519" | "Ed448" | "X25519" | "X448"; type GenerateOptionsCommon = { kid?: string | undefined; use?: "sig" | "enc" | undefined; alg?: string | undefined; key_ops?: string[] | undefined; }; type GenerateOptionsEC = GenerateOptionsCommon & { curve?: EcCurve; }; type GenerateOptionsRSA = GenerateOptionsCommon & { modulusLength?: number; publicExponent?: number; }; type GenerateOptionsOKP = GenerateOptionsCommon & { curve?: OkpCurve; }; type GenerateOptionsOct = GenerateOptionsCommon & { bits?: number; }; type GeneratedKeyPair = { /** * public projection (asymmetric); equals `privateJwk` for `oct` */ publicJwk: object; /** * private JWK (contains `d`, or `k` for `oct`) */ privateJwk: object; }; export { generate }; export type { EcCurve, GenerateOptionsCommon, GenerateOptionsEC, GenerateOptionsOKP, GenerateOptionsOct, GenerateOptionsRSA, GeneratedKeyPair, Kty, OkpCurve };