Skip to content

Commit

Permalink
fix: add missing keystore.toJWKS() .d.ts definition
Browse files Browse the repository at this point in the history
fixes #25
  • Loading branch information
panva committed May 13, 2019
1 parent 46eb7ed commit c7a8606
Showing 1 changed file with 40 additions and 32 deletions.
72 changes: 40 additions & 32 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -41,38 +79,6 @@ export namespace JWK {
algorithms(operation?: keyOperation): Set<string>
}

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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c7a8606

Please sign in to comment.