Skip to content

Commit c4abaa2

Browse files
committed
refactor: always use infered CryptoKey
1 parent e00f273 commit c4abaa2

14 files changed

+16
-3
lines changed

src/lib/crypto_key.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { CryptoKey } from '../types.d.ts'
2+
13
function unusable(name: string | number, prop = 'algorithm.name') {
24
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`)
35
}

src/runtime/aeskw.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CryptoKey } from '../types.d.ts'
12
import { checkEncCryptoKey } from '../lib/crypto_key.js'
23

34
function checkKeySize(key: CryptoKey, alg: string) {

src/runtime/check_key_length.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { CryptoKey } from '../types.d.ts'
2+
13
export default (alg: string, key: CryptoKey) => {
24
if (alg.startsWith('RS') || alg.startsWith('PS')) {
35
const { modulusLength } = key.algorithm as RsaKeyAlgorithm

src/runtime/decrypt.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { concat, uint64be } from '../lib/buffer_utils.js'
22

3+
import type { CryptoKey } from '../types.d.ts'
34
import type { DecryptFunction } from './interfaces.d.ts'
45
import checkIvLength from '../lib/check_iv_length.js'
56
import checkCekLength from './check_cek_length.js'

src/runtime/ecdhes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { CryptoKey } from '../types.d.ts'
12
import { encoder, concat, uint32be, lengthAndInput, concatKdf } from '../lib/buffer_utils.js'
23
import { checkEncCryptoKey } from '../lib/crypto_key.js'
3-
import type { CryptoKey } from '../types.d.ts'
44

55
export async function deriveKey(
66
publicKey: CryptoKey,

src/runtime/encrypt.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CryptoKey } from '../types.d.ts'
12
import { concat, uint64be } from '../lib/buffer_utils.js'
23
import type { EncryptFunction } from './interfaces.d.ts'
34
import checkIvLength from '../lib/check_iv_length.js'

src/runtime/generate.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CryptoKey } from '../types.d.ts'
12
import { JOSENotSupported } from '../util/errors.js'
23
import random from './random.js'
34
import type { GenerateKeyPairOptions } from '../key/generate_key_pair.js'

src/runtime/get_sign_verify_key.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CryptoKey } from '../types.d.ts'
12
import { checkSigCryptoKey } from '../lib/crypto_key.js'
23
import invalidKeyInput from '../lib/invalid_key_input.js'
34

src/runtime/is_key_like.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { KeyObject } from '../types.d.ts'
1+
import type { CryptoKey, KeyObject } from '../types.d.ts'
22

33
export function assertCryptoKey(key: unknown): asserts key is CryptoKey {
44
if (!isCryptoKey(key)) {

src/runtime/jwk_to_key.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { JOSENotSupported } from '../util/errors.js'
2-
import type { JWK } from '../types.d.ts'
2+
import type { CryptoKey, JWK } from '../types.d.ts'
33

44
function subtleMapping(jwk: JWK): {
55
algorithm: RsaHashedImportParams | EcKeyAlgorithm | Algorithm

src/runtime/pbes2kw.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CryptoKey } from '../types.d.ts'
12
import random from './random.js'
23
import { p2s as concatSalt } from '../lib/buffer_utils.js'
34
import { encode as base64url } from './base64url.js'

src/runtime/rsaes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CryptoKey } from '../types.d.ts'
12
import subtleAlgorithm from './subtle_rsaes.js'
23
import { checkEncCryptoKey } from '../lib/crypto_key.js'
34
import checkKeyLength from './check_key_length.js'

src/runtime/sign.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CryptoKey } from '../types.d.ts'
12
import subtleAlgorithm from './subtle_dsa.js'
23

34
import checkKeyLength from './check_key_length.js'

src/runtime/verify.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CryptoKey } from '../types.d.ts'
12
import subtleAlgorithm from './subtle_dsa.js'
23

34
import checkKeyLength from './check_key_length.js'

0 commit comments

Comments
 (0)