Skip to content

Commit ccf0cda

Browse files
committed
refactor(types): remove index signatures from JWK interfaces
1 parent bcf2de2 commit ccf0cda

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

src/runtime/node/jwk_to_key.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { createPrivateKey, createPublicKey } from 'node:crypto'
2-
import type { KeyObject } from 'node:crypto'
2+
import type { KeyObject, JsonWebKeyInput } from 'node:crypto'
33

44
import type { JWK } from '../../types.d'
55

6-
const parse = (jwk: JWK): KeyObject => {
7-
return (jwk.d ? createPrivateKey : createPublicKey)({ format: 'jwk', key: jwk })
6+
const parse = (key: JWK): KeyObject => {
7+
if (key.d) {
8+
return createPrivateKey(<JsonWebKeyInput>{ format: 'jwk', key })
9+
}
10+
return createPublicKey(<JsonWebKeyInput>{ format: 'jwk', key })
811
}
912
export default parse

src/types.d.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ export interface JWKParameters {
121121
x5u?: string
122122
/** JWK "kid" (Key ID) Parameter. */
123123
kid?: string
124-
125-
[propName: string]: unknown
126124
}
127125

128126
/** Convenience interface for Public OKP JSON Web Keys */
@@ -131,16 +129,12 @@ export interface JWK_OKP_Public extends JWKParameters {
131129
crv: string
132130
/** The public key */
133131
x: string
134-
135-
[propName: string]: unknown
136132
}
137133

138134
/** Convenience interface for Private OKP JSON Web Keys */
139135
export interface JWK_OKP_Private extends JWK_OKP_Public, JWKParameters {
140136
/** The Private Key */
141137
d: string
142-
143-
[propName: string]: unknown
144138
}
145139

146140
/** Convenience interface for Public EC JSON Web Keys */
@@ -151,16 +145,12 @@ export interface JWK_EC_Public extends JWKParameters {
151145
x: string
152146
/** Y Coordinate */
153147
y: string
154-
155-
[propName: string]: unknown
156148
}
157149

158150
/** Convenience interface for Private EC JSON Web Keys */
159151
export interface JWK_EC_Private extends JWK_EC_Public, JWKParameters {
160152
/** ECC Private Key */
161153
d: string
162-
163-
[propName: string]: unknown
164154
}
165155

166156
/** Convenience interface for Public RSA JSON Web Keys */
@@ -169,8 +159,6 @@ export interface JWK_RSA_Public extends JWKParameters {
169159
e: string
170160
/** Modulus */
171161
n: string
172-
173-
[propName: string]: unknown
174162
}
175163

176164
/** Convenience interface for Private RSA JSON Web Keys */
@@ -193,16 +181,12 @@ export interface JWK_RSA_Private extends JWK_RSA_Public, JWKParameters {
193181
q: string
194182
/** First CRT Coefficient */
195183
qi: string
196-
197-
[propName: string]: unknown
198184
}
199185

200186
/** Convenience interface for oct JSON Web Keys */
201187
export interface JWK_oct extends JWKParameters {
202188
/** Key Value */
203189
k: string
204-
205-
[propName: string]: unknown
206190
}
207191

208192
/**
@@ -258,8 +242,6 @@ export interface JWK extends JWKParameters {
258242
x?: string
259243
/** (EC) Y Coordinate */
260244
y?: string
261-
262-
[propName: string]: unknown
263245
}
264246

265247
/**

0 commit comments

Comments
 (0)