Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-crypto/sha1-browser

Package Overview
Dependencies
Maintainers
8
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-crypto/sha1-browser - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0

7

build/crossPlatformSha1.d.ts

@@ -1,7 +0,8 @@

import { Hash, SourceData } from "@aws-sdk/types";
export declare class Sha1 implements Hash {
private readonly hash;
import { Checksum, SourceData } from "@aws-sdk/types";
export declare class Sha1 implements Checksum {
private hash;
constructor(secret?: SourceData);
update(data: SourceData, encoding?: "utf8" | "ascii" | "latin1"): void;
digest(): Promise<Uint8Array>;
reset(): void;
}

@@ -9,2 +9,3 @@ "use strict";

var util_locate_window_1 = require("@aws-sdk/util-locate-window");
var util_1 = require("@aws-crypto/util");
var Sha1 = /** @class */ (function () {

@@ -23,3 +24,3 @@ function Sha1(secret) {

Sha1.prototype.update = function (data, encoding) {
this.hash.update(data, encoding);
this.hash.update((0, util_1.convertToBuffer)(data));
};

@@ -29,2 +30,5 @@ Sha1.prototype.digest = function () {

};
Sha1.prototype.reset = function () {
this.hash.reset();
};
return Sha1;

@@ -31,0 +35,0 @@ }());

@@ -1,3 +0,4 @@

import { Hash, SourceData } from "@aws-sdk/types";
export declare class Sha1 implements Hash {
import { Checksum, SourceData } from "@aws-sdk/types";
export declare class Sha1 implements Checksum {
private readonly secret?;
private operation;

@@ -7,2 +8,3 @@ constructor(secret?: SourceData);

digest(): Promise<Uint8Array>;
reset(): void;
}

@@ -10,11 +10,4 @@ "use strict";

function Sha1(secret) {
if (secret) {
this.operation = getKeyPromise(secret).then(function (keyData) {
return (0, util_locate_window_1.locateWindow)().msCrypto.subtle.sign(constants_1.SHA_1_HMAC_ALGO, keyData);
});
this.operation.catch(function () { });
}
else {
this.operation = Promise.resolve((0, util_locate_window_1.locateWindow)().msCrypto.subtle.digest("SHA-1"));
}
this.secret = secret;
this.reset();
}

@@ -51,2 +44,13 @@ Sha1.prototype.update = function (toHash) {

};
Sha1.prototype.reset = function () {
if (this.secret) {
this.operation = getKeyPromise(this.secret).then(function (keyData) {
return (0, util_locate_window_1.locateWindow)().msCrypto.subtle.sign(constants_1.SHA_1_HMAC_ALGO, keyData);
});
this.operation.catch(function () { });
}
else {
this.operation = Promise.resolve((0, util_locate_window_1.locateWindow)().msCrypto.subtle.digest("SHA-1"));
}
};
return Sha1;

@@ -53,0 +57,0 @@ }());

@@ -1,3 +0,3 @@

import { Hash, SourceData } from "@aws-sdk/types";
export declare class Sha1 implements Hash {
import { Checksum, SourceData } from "@aws-sdk/types";
export declare class Sha1 implements Checksum {
private readonly key;

@@ -8,2 +8,3 @@ private toHash;

digest(): Promise<Uint8Array>;
reset(): void;
}

@@ -46,2 +46,5 @@ "use strict";

};
Sha1.prototype.reset = function () {
this.toHash = new Uint8Array(0);
};
return Sha1;

@@ -48,0 +51,0 @@ }());

@@ -6,13 +6,16 @@ # Change Log

## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07)
# [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12)
- feat!: replace Hash implementations with Checksum interface (#492) ([da43dc0](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/da43dc0fdf669d9ebb5bfb1b1f7c79e46c4aaae1)), closes [#492](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/492)
### Bug Fixes
### BREAKING CHANGES
* **#337:** update @aws-sdk/types ([#373](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/373)) ([b26a811](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/b26a811a392f5209c7ec7e57251500d4d78f97ff)), closes [#337](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/337)
- All classes that implemented `Hash` now implement `Checksum`.
## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07)
### Bug Fixes
- **#337:** update @aws-sdk/types ([#373](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/373)) ([b26a811](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/b26a811a392f5209c7ec7e57251500d4d78f97ff)), closes [#337](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/337)
# [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25)

@@ -22,16 +25,10 @@

# [1.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.1.1...v1.2.0) (2021-09-17)
### Bug Fixes
* Adding ie11-detection dependency to sha1-browser ([#213](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/213)) ([138750d](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/138750d96385b8cc479b6f54c500ee1b5380648c))
- Adding ie11-detection dependency to sha1-browser ([#213](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/213)) ([138750d](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/138750d96385b8cc479b6f54c500ee1b5380648c))
### Features
* Add SHA1 ([#208](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/208)) ([45c50ff](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/45c50ffa3acc9e3bf4039ab59a0102e4d40455ec))
- Add SHA1 ([#208](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/208)) ([45c50ff](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/45c50ffa3acc9e3bf4039ab59a0102e4d40455ec))
{
"name": "@aws-crypto/sha1-browser",
"version": "2.0.2",
"version": "3.0.0",
"scripts": {

@@ -21,5 +21,6 @@ "prepublishOnly": "tsc",

"dependencies": {
"@aws-crypto/ie11-detection": "^2.0.2",
"@aws-crypto/supports-web-crypto": "^2.0.2",
"@aws-sdk/types": "^3.110.0",
"@aws-crypto/ie11-detection": "^3.0.0",
"@aws-crypto/supports-web-crypto": "^3.0.0",
"@aws-crypto/util": "^3.0.0",
"@aws-sdk/types": "^3.222.0",
"@aws-sdk/util-locate-window": "^3.0.0",

@@ -34,3 +35,3 @@ "@aws-sdk/util-utf8-browser": "^3.0.0",

},
"gitHead": "5d1db32bb75010cbe38ff8dda9c560cdbb7ec578"
"gitHead": "7f56cee8f62bd65cd397eeec29c3c997215bd80c"
}
import { Sha1 as Ie11Sha1 } from "./ie11Sha1";
import { Sha1 as WebCryptoSha1 } from "./webCryptoSha1";
import { Hash, SourceData } from "@aws-sdk/types";
import { Checksum, SourceData } from "@aws-sdk/types";
import { supportsWebCrypto } from "@aws-crypto/supports-web-crypto";
import { isMsWindow } from "@aws-crypto/ie11-detection";
import { locateWindow } from "@aws-sdk/util-locate-window";
import { convertToBuffer } from "@aws-crypto/util";
export class Sha1 implements Hash {
private readonly hash: Hash;
export class Sha1 implements Checksum {
private hash: Checksum;

@@ -22,3 +23,3 @@ constructor(secret?: SourceData) {

update(data: SourceData, encoding?: "utf8" | "ascii" | "latin1"): void {
this.hash.update(data, encoding);
this.hash.update(convertToBuffer(data));
}

@@ -29,2 +30,6 @@

}
reset(): void {
this.hash.reset();
}
}
import { isEmptyData } from "./isEmptyData";
import { SHA_1_HMAC_ALGO } from "./constants";
import { Hash, SourceData } from "@aws-sdk/types";
import { Checksum, SourceData } from "@aws-sdk/types";
import { fromUtf8 } from "@aws-sdk/util-utf8-browser";

@@ -8,19 +8,9 @@ import { CryptoOperation, Key, MsWindow } from "@aws-crypto/ie11-detection";

export class Sha1 implements Hash {
private operation: Promise<CryptoOperation>;
export class Sha1 implements Checksum {
private readonly secret?: SourceData;
private operation!: Promise<CryptoOperation>;
constructor(secret?: SourceData) {
if (secret) {
this.operation = getKeyPromise(secret).then((keyData) =>
(locateWindow() as MsWindow).msCrypto.subtle.sign(
SHA_1_HMAC_ALGO,
keyData
)
);
this.operation.catch(() => {});
} else {
this.operation = Promise.resolve(
(locateWindow() as MsWindow).msCrypto.subtle.digest("SHA-1")
);
}
this.secret = secret;
this.reset();
}

@@ -64,2 +54,18 @@

}
reset(): void {
if (this.secret) {
this.operation = getKeyPromise(this.secret).then((keyData) =>
(locateWindow() as MsWindow).msCrypto.subtle.sign(
SHA_1_HMAC_ALGO,
keyData
)
);
this.operation.catch(() => {});
} else {
this.operation = Promise.resolve(
(locateWindow() as MsWindow).msCrypto.subtle.digest("SHA-1")
);
}
}
}

@@ -66,0 +72,0 @@

@@ -1,2 +0,2 @@

import { Hash, SourceData } from "@aws-sdk/types";
import { Checksum, SourceData } from "@aws-sdk/types";
import { fromUtf8 } from "@aws-sdk/util-utf8-browser";

@@ -7,3 +7,3 @@ import { isEmptyData } from "./isEmptyData";

export class Sha1 implements Hash {
export class Sha1 implements Checksum {
private readonly key: Promise<CryptoKey> | undefined;

@@ -60,2 +60,6 @@ private toHash: Uint8Array = new Uint8Array(0);

}
reset(): void {
this.toHash = new Uint8Array(0);
}
}

@@ -62,0 +66,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc