Skip to content

Commit 1cc3092

Browse files
committed
remove CipherType
1 parent da2cdb6 commit 1cc3092

3 files changed

Lines changed: 6 additions & 19 deletions

File tree

example/src/tests/cipher/cipher_tests.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
createCipheriv,
55
createDecipheriv,
66
randomFillSync,
7-
type CipherType,
87
type BinaryLikeNode,
98
type BinaryLike,
109
type Cipher,
@@ -30,7 +29,6 @@ test(SUITE, 'cipher - valid algorithm', async () => {
3029

3130
test(SUITE, 'cipher - invalid algorithm', async () => {
3231
expect(() => {
33-
// @ts-expect-error - testing bad algorithm
3432
createCipheriv('aes-128-boorad', key, iv, {});
3533
}).to.throw(/Invalid Cipher Algorithm: aes-128-boorad/);
3634
});
@@ -57,12 +55,12 @@ test(SUITE, 'cipher - buffers', async () => {
5755
// update/final
5856
ciphers.forEach(cipherName => {
5957
test(SUITE, `cipher - non-stream - ${cipherName}`, async () => {
60-
roundtrip(cipherName as CipherType, key, iv, plaintext);
58+
roundtrip(cipherName, key, iv, plaintext);
6159
});
6260
});
6361

6462
function roundtrip(
65-
cipherName: CipherType,
63+
cipherName: string,
6664
lKey: BinaryLikeNode,
6765
lIv: BinaryLike,
6866
payload: string,

packages/react-native-quick-crypto/src/cipher.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
} from 'crypto'; // @types/node
1414
import type { Cipher as NativeCipher } from './specs/cipher.nitro';
1515
import { binaryLikeToArrayBuffer } from './utils';
16-
import type { BinaryLike, BinaryLikeNode, CipherType, Encoding } from './utils';
16+
import type { BinaryLike, BinaryLikeNode, Encoding } from './utils';
1717
import {
1818
getDecoder,
1919
getDefaultEncoding,
@@ -218,7 +218,7 @@ export function createDecipheriv(
218218
options?: CipherGCMOptions,
219219
): Decipher;
220220
export function createDecipheriv(
221-
algorithm: CipherType,
221+
algorithm: string,
222222
key: BinaryLikeNode,
223223
iv: BinaryLike,
224224
options?: Stream.TransformOptions,
@@ -260,7 +260,7 @@ export function createCipheriv(
260260
options?: CipherGCMOptions,
261261
): Cipher;
262262
export function createCipheriv(
263-
algorithm: CipherType,
263+
algorithm: string,
264264
key: BinaryLikeNode,
265265
iv: BinaryLike,
266266
options?: Stream.TransformOptions,

packages/react-native-quick-crypto/src/utils/types.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,7 @@ export type Encoding =
285285

286286
// These are for shortcomings in @types/node
287287
// Here we use "*Type" instead of "*Types" like node does.
288-
export type CipherType =
289-
| 'aes128'
290-
| 'aes192'
291-
| 'aes256'
292-
| CipherCBCType
293-
| CipherCFBType
294-
| CipherCTRType
295-
| CipherDESType
296-
| CipherECBType
297-
| CipherGCMType
298-
| CipherOFBType;
299-
export type CipherCBCType = 'aes-128-cbc' | 'aes-192-cbc' | 'aes-256-cbc';
288+
// export type CipherCBCType = 'aes-128-cbc' | 'aes-192-cbc' | 'aes-256-cbc';
300289
export type CipherCFBType =
301290
| 'aes-128-cfb'
302291
| 'aes-192-cfb'

0 commit comments

Comments
 (0)