From c7a8606e4dc43bcb0829f6e17f4b627473abcfea Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Mon, 13 May 2019 10:34:46 +0200 Subject: [PATCH] fix: add missing keystore.toJWKS() .d.ts definition fixes #25 --- lib/index.d.ts | 72 ++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index 474b0fa4cc..72b4e18f21 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -16,6 +16,44 @@ type keyType = 'RSA' | 'EC' | 'OKP' | 'oct' type asymmetricKeyObjectTypes = 'private' | 'public' type keyObjectTypes = asymmetricKeyObjectTypes | 'secret' +interface JWKOctKey extends KeyParameters { + kty: 'oct', + k?: string +} + +interface JWKECKey extends KeyParameters { + kty: 'EC' + crv: ECCurve + x: string + y: string + d?: string +} + +interface JWKOKPKey extends KeyParameters { + kty: 'OKP' + crv: OKPCurve + x: string + d?: string +} + +interface JWKRSAKey extends KeyParameters { + kty: 'RSA' + e: string + n: string + d?: string + p?: string + q?: string + dp?: string + dq?: string + qi?: string +} + +type JSONWebKey = JWKRSAKey | JWKOKPKey | JWKECKey | JWKOctKey + +interface JSONWebKeySet { + keys: JSONWebKey[] +} + export namespace JWK { interface pemEncodingOptions { @@ -41,38 +79,6 @@ export namespace JWK { algorithms(operation?: keyOperation): Set } - interface JWKOctKey extends KeyParameters { - kty: 'oct', - k?: string - } - - interface JWKECKey extends KeyParameters { - kty: 'EC' - crv: ECCurve - x: string - y: string - d?: string - } - - interface JWKOKPKey extends KeyParameters { - kty: 'OKP' - crv: OKPCurve - x: string - d?: string - } - - interface JWKRSAKey extends KeyParameters { - kty: 'RSA' - e: string - n: string - d?: string - p?: string - q?: string - dp?: string - dq?: string - qi?: string - } - class RSAKey extends Key { kty: 'RSA' type: asymmetricKeyObjectTypes @@ -158,6 +164,8 @@ export namespace JWKS { all(parameters?: KeyQuery): JWK.Key[] get(parameters?: KeyQuery): JWK.Key + toJWKS(private?: boolean): JSONWebKeySet + generate(kty: 'EC', crv?: ECCurve, parameters?: KeyParameters, private?: boolean): void generate(kty: 'OKP', crv?: OKPCurve, parameters?: KeyParameters, private?: boolean): void generate(kty: 'RSA', bitlength?: number, parameters?: KeyParameters, private?: boolean): void