Skip to content

Commit

Permalink
fix(typescript): PEM import functions always resolve a KeyLike, never…
Browse files Browse the repository at this point in the history
… a Uint8Array
  • Loading branch information
panva committed Oct 6, 2021
1 parent 1a3d31c commit 8ef3a8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/key/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export async function importSPKI(
spki: string,
alg: string,
options?: PEMImportOptions,
): Promise<Exclude<KeyLike, Uint8Array>> {
): Promise<KeyLike> {
if (typeof spki !== 'string' || spki.indexOf('-----BEGIN PUBLIC KEY-----') !== 0) {
throw new TypeError('"spki" must be SPKI formatted string')
}
Expand Down Expand Up @@ -180,7 +180,7 @@ export async function importX509(
x509: string,
alg: string,
options?: PEMImportOptions,
): Promise<Exclude<KeyLike, Uint8Array>> {
): Promise<KeyLike> {
if (typeof x509 !== 'string' || x509.indexOf('-----BEGIN CERTIFICATE-----') !== 0) {
throw new TypeError('"x509" must be X.509 formatted string')
}
Expand Down Expand Up @@ -226,7 +226,7 @@ export async function importPKCS8(
pkcs8: string,
alg: string,
options?: PEMImportOptions,
): Promise<Exclude<KeyLike, Uint8Array>> {
): Promise<KeyLike> {
if (typeof pkcs8 !== 'string' || pkcs8.indexOf('-----BEGIN PRIVATE KEY-----') !== 0) {
throw new TypeError('"pkcs8" must be PCKS8 formatted string')
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export interface JWKImportFunction {
(jwk: JWK): AsyncOrSync<KeyLike>
}
export interface PEMImportFunction {
(pem: string, alg: string, options?: PEMImportOptions): AsyncOrSync<Exclude<KeyLike, Uint8Array>>
(pem: string, alg: string, options?: PEMImportOptions): AsyncOrSync<KeyLike>
}
interface ExportFunction<T> {
(key: unknown): AsyncOrSync<T>
Expand Down

0 comments on commit 8ef3a8e

Please sign in to comment.