@@ -29,7 +29,8 @@ import {
2929} from './utils/cipher' ;
3030
3131class CipherUtils {
32- private static native = NitroModules . createHybridObject < NativeCipher > ( 'Cipher' ) ;
32+ private static native =
33+ NitroModules . createHybridObject < NativeCipher > ( 'Cipher' ) ;
3334 public static getSupportedCiphers ( ) : string [ ] {
3435 return this . native . getSupportedCiphers ( ) ;
3536 }
@@ -40,23 +41,23 @@ export function getCiphers(): string[] {
4041}
4142
4243interface CipherArgs {
44+ isCipher : boolean ;
4345 cipherType : string ;
4446 cipherKey : BinaryLikeNode ;
45- isCipher : boolean ;
46- options : Record < string , TransformOptions > ;
4747 iv : BinaryLike ;
48- } ;
48+ options : Record < string , TransformOptions > ;
49+ }
4950
5051class CipherCommon extends Stream . Transform {
5152 private native : NativeCipher ;
5253 private decoder : StringDecoder | undefined ;
5354
5455 constructor ( {
56+ isCipher,
5557 cipherType,
5658 cipherKey,
57- isCipher,
58- options = { } ,
5959 iv,
60+ options = { } ,
6061 } : CipherArgs ) {
6162 super ( options ) ;
6263 this . native = NitroModules . createHybridObject < NativeCipher > ( 'Cipher' ) ;
@@ -166,35 +167,35 @@ class CipherCommon extends Stream.Transform {
166167 }
167168}
168169
169- export class Cipher extends CipherCommon {
170+ class Cipheriv extends CipherCommon {
170171 constructor (
171172 cipherType : string ,
172173 cipherKey : BinaryLikeNode ,
173- options : Record < string , TransformOptions > = { } ,
174174 iv : BinaryLike ,
175+ options : Record < string , TransformOptions > = { } ,
175176 ) {
176177 super ( {
178+ isCipher : true ,
177179 cipherType,
178180 cipherKey : binaryLikeToArrayBuffer ( cipherKey ) ,
179181 iv : binaryLikeToArrayBuffer ( iv ) ,
180- isCipher : true ,
181182 options,
182183 } ) ;
183184 }
184185}
185186
186- export class Decipher extends CipherCommon {
187+ class Decipheriv extends CipherCommon {
187188 constructor (
188189 cipherType : string ,
189190 cipherKey : BinaryLikeNode ,
190- options : Record < string , TransformOptions > = { } ,
191191 iv : BinaryLike ,
192+ options : Record < string , TransformOptions > = { } ,
192193 ) {
193194 super ( {
195+ isCipher : false ,
194196 cipherType,
195197 cipherKey : binaryLikeToArrayBuffer ( cipherKey ) ,
196198 iv : binaryLikeToArrayBuffer ( iv ) ,
197- isCipher : false ,
198199 options,
199200 } ) ;
200201 }
@@ -223,7 +224,7 @@ export function createDecipheriv(
223224 key : BinaryLikeNode ,
224225 iv : BinaryLike ,
225226 options ?: Stream . TransformOptions ,
226- ) : DecipherCCM | DecipherOCB | DecipherGCM | Decipher ;
227+ ) : DecipherCCM | DecipherOCB | DecipherGCM | Decipheriv ;
227228export function createDecipheriv (
228229 algorithm : string ,
229230 key : BinaryLikeNode ,
@@ -233,12 +234,12 @@ export function createDecipheriv(
233234 | CipherOCBOptions
234235 | CipherGCMOptions
235236 | Stream . TransformOptions ,
236- ) : DecipherCCM | DecipherOCB | DecipherGCM | Decipher {
237- return new Decipher (
237+ ) : DecipherCCM | DecipherOCB | DecipherGCM | Decipheriv {
238+ return new Decipheriv (
238239 algorithm ,
239240 key ,
240- options as Record < string , TransformOptions > ,
241241 iv ,
242+ options as Record < string , TransformOptions > ,
242243 ) ;
243244}
244245
@@ -265,7 +266,7 @@ export function createCipheriv(
265266 key : BinaryLikeNode ,
266267 iv : BinaryLike ,
267268 options ?: Stream . TransformOptions ,
268- ) : CipherCCM | CipherOCB | CipherGCM | Cipher ;
269+ ) : CipherCCM | CipherOCB | CipherGCM | Cipheriv ;
269270export function createCipheriv (
270271 algorithm : string ,
271272 key : BinaryLikeNode ,
@@ -275,11 +276,11 @@ export function createCipheriv(
275276 | CipherOCBOptions
276277 | CipherGCMOptions
277278 | Stream . TransformOptions ,
278- ) : CipherCCM | CipherOCB | CipherGCM | Cipher {
279- return new Cipher (
279+ ) : CipherCCM | CipherOCB | CipherGCM | Cipheriv {
280+ return new Cipheriv (
280281 algorithm ,
281282 key ,
282- options as Record < string , TransformOptions > ,
283283 iv ,
284+ options as Record < string , TransformOptions > ,
284285 ) ;
285286}
0 commit comments