]> git.kaiwu.me - njs.git/commitdiff
Types: added definitions for Hash.copy() method.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 27 Apr 2023 02:38:13 +0000 (19:38 -0700)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 27 Apr 2023 02:38:13 +0000 (19:38 -0700)
test/ts/test.ts
ts/njs_modules/crypto.d.ts

index 5522f4a1f8c8cc06900e7883dc08bbad04ec3a0e..127fb089bfb252d00f288fb09df8a33a3b7a40e6 100644 (file)
@@ -188,6 +188,7 @@ function crypto_module(str: NjsByteString) {
 
     h = cr.createHash("sha1");
     h = h.update(str).update(Buffer.from([0]));
+    h = h.copy();
     b = h.digest();
 
     s = cr.createHash("sha256").digest("hex");
index ea554f34767b4138574fdd249f722777d2193375..70801144f793fa4f0d0e2e1c017545260d4895b6 100644 (file)
@@ -7,6 +7,12 @@ declare module "crypto" {
     export type DigestEncoding = Exclude<BufferEncoding, "utf8">;
 
     export interface Hash {
+        /**
+         * Returns a new Hash object that contains a deep copy of
+         * the internal state of the current Hash object.
+         */
+        copy(): Hash;
+
         /**
          * Updates the hash content with the given `data` and returns self.
          */