@@ -78,7 +78,7 @@ class CipherCommon extends Stream.Transform {
7878 data : BinaryLike ,
7979 inputEncoding ?: Encoding ,
8080 outputEncoding ?: Encoding ,
81- ) : ArrayBuffer | string {
81+ ) : Buffer | string {
8282 const defaultEncoding = getDefaultEncoding ( ) ;
8383 inputEncoding = inputEncoding ?? defaultEncoding ;
8484 outputEncoding = outputEncoding ?? defaultEncoding ;
@@ -98,12 +98,12 @@ class CipherCommon extends Stream.Transform {
9898 return this . decoder ! . write ( SBuffer . from ( ret ) as any ) ;
9999 }
100100
101- return ret ;
101+ return Buffer . from ( ret ) ;
102102 }
103103
104- final ( ) : ArrayBuffer ;
104+ final ( ) : Buffer ;
105105 final ( outputEncoding : BufferEncoding | 'buffer' ) : string ;
106- final ( outputEncoding ?: BufferEncoding | 'buffer' ) : ArrayBuffer | string {
106+ final ( outputEncoding ?: BufferEncoding | 'buffer' ) : Buffer | string {
107107 const ret = this . native . final ( ) ;
108108
109109 if ( outputEncoding && outputEncoding !== 'buffer' ) {
@@ -112,7 +112,7 @@ class CipherCommon extends Stream.Transform {
112112 return this . decoder ! . end ( SBuffer . from ( ret ) as any ) ;
113113 }
114114
115- return ret ;
115+ return Buffer . from ( ret ) ;
116116 }
117117
118118 _transform (
@@ -184,6 +184,8 @@ class Cipheriv extends CipherCommon {
184184 }
185185}
186186
187+ type Cipher = CipherCCM | CipherOCB | CipherGCM | Cipheriv ;
188+
187189class Decipheriv extends CipherCommon {
188190 constructor (
189191 cipherType : string ,
@@ -201,6 +203,8 @@ class Decipheriv extends CipherCommon {
201203 }
202204}
203205
206+ type Decipher = DecipherCCM | DecipherOCB | DecipherGCM | Decipheriv ;
207+
204208export function createDecipheriv (
205209 algorithm : CipherCCMTypes ,
206210 key : BinaryLikeNode ,
@@ -224,7 +228,7 @@ export function createDecipheriv(
224228 key : BinaryLikeNode ,
225229 iv : BinaryLike ,
226230 options ?: Stream . TransformOptions ,
227- ) : DecipherCCM | DecipherOCB | DecipherGCM | Decipheriv ;
231+ ) : Decipher ;
228232export function createDecipheriv (
229233 algorithm : string ,
230234 key : BinaryLikeNode ,
@@ -234,7 +238,7 @@ export function createDecipheriv(
234238 | CipherOCBOptions
235239 | CipherGCMOptions
236240 | Stream . TransformOptions ,
237- ) : DecipherCCM | DecipherOCB | DecipherGCM | Decipheriv {
241+ ) : Decipher {
238242 return new Decipheriv (
239243 algorithm ,
240244 key ,
@@ -266,7 +270,7 @@ export function createCipheriv(
266270 key : BinaryLikeNode ,
267271 iv : BinaryLike ,
268272 options ?: Stream . TransformOptions ,
269- ) : CipherCCM | CipherOCB | CipherGCM | Cipheriv ;
273+ ) : Cipher ;
270274export function createCipheriv (
271275 algorithm : string ,
272276 key : BinaryLikeNode ,
@@ -276,7 +280,7 @@ export function createCipheriv(
276280 | CipherOCBOptions
277281 | CipherGCMOptions
278282 | Stream . TransformOptions ,
279- ) : CipherCCM | CipherOCB | CipherGCM | Cipheriv {
283+ ) : Cipher {
280284 return new Cipheriv (
281285 algorithm ,
282286 key ,
@@ -290,3 +294,5 @@ export const cipherExports = {
290294 createDecipheriv,
291295 getCiphers,
292296} ;
297+
298+ export type { Cipher , Decipher } ;
0 commit comments