Skip to content

Commit

Permalink
refactor: rm src/runtime/node/secret_key.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Nov 16, 2021
1 parent cd0a5c7 commit 444cc3f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
5 changes: 2 additions & 3 deletions src/runtime/node/aeskw.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Buffer } from 'buffer'
import { KeyObject, createDecipheriv, createCipheriv } from 'crypto'
import { KeyObject, createDecipheriv, createCipheriv, createSecretKey } from 'crypto'
import { JOSENotSupported } from '../../util/errors.js'
import type { AesKwUnwrapFunction, AesKwWrapFunction } from '../interfaces.d'
import { concat } from '../../lib/buffer_utils.js'
import getSecretKey from './secret_key.js'
import { isCryptoKey } from './webcrypto.js'
import { checkEncCryptoKey } from '../../lib/crypto_key.js'
import isKeyObject from './is_key_object.js'
Expand All @@ -22,7 +21,7 @@ function ensureKeyObject(key: unknown, alg: string, usage: KeyUsage) {
return key
}
if (key instanceof Uint8Array) {
return getSecretKey(key)
return createSecretKey(key)
}
if (isCryptoKey(key)) {
checkEncCryptoKey(key, alg, usage)
Expand Down
5 changes: 2 additions & 3 deletions src/runtime/node/get_sign_verify_key.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { KeyObject } from 'crypto'
import { KeyObject, createSecretKey } from 'crypto'
import { isCryptoKey } from './webcrypto.js'
import { checkSigCryptoKey } from '../../lib/crypto_key.js'
import getSecretKey from './secret_key.js'
import invalidKeyInput from '../../lib/invalid_key_input.js'
import { types } from './is_key_like.js'

Expand All @@ -10,7 +9,7 @@ export default function getSignVerifyKey(alg: string, key: unknown, usage: KeyUs
if (!alg.startsWith('HS')) {
throw new TypeError(invalidKeyInput(key, ...types))
}
return getSecretKey(key)
return createSecretKey(key)
}
if (key instanceof KeyObject) {
return key
Expand Down
13 changes: 0 additions & 13 deletions src/runtime/node/secret_key.ts

This file was deleted.

0 comments on commit 444cc3f

Please sign in to comment.