@aws-crypto/sha256-universal
Advanced tools
Comparing version 2.0.2 to 3.0.0
@@ -1,7 +0,8 @@ | ||
import { Hash, SourceData } from "@aws-sdk/types"; | ||
export declare class Sha256 implements Hash { | ||
private readonly hash; | ||
import { Checksum, SourceData } from "@aws-sdk/types"; | ||
export declare class Sha256 implements Checksum { | ||
private hash; | ||
constructor(secret?: SourceData); | ||
update(data: SourceData, encoding?: "utf8" | "ascii" | "latin1"): void; | ||
digest(): Promise<Uint8Array>; | ||
reset(): void; | ||
} |
@@ -5,7 +5,8 @@ "use strict"; | ||
var sha256_browser_1 = require("@aws-crypto/sha256-browser"); | ||
var hash_node_1 = require("@aws-sdk/hash-node"); | ||
var util_1 = require("@aws-crypto/util"); | ||
var node_hash_1 = require("./node_hash"); | ||
var Sha256 = /** @class */ (function () { | ||
function Sha256(secret) { | ||
if (supportsCryptoModule()) { | ||
this.hash = new hash_node_1.Hash("sha256", secret); | ||
this.hash = new node_hash_1.NodeHash("sha256", secret); | ||
} | ||
@@ -17,3 +18,3 @@ else { | ||
Sha256.prototype.update = function (data, encoding) { | ||
this.hash.update(data, encoding); | ||
this.hash.update((0, util_1.convertToBuffer)(data)); | ||
}; | ||
@@ -23,2 +24,5 @@ Sha256.prototype.digest = function () { | ||
}; | ||
Sha256.prototype.reset = function () { | ||
this.hash.reset(); | ||
}; | ||
return Sha256; | ||
@@ -25,0 +29,0 @@ }()); |
@@ -6,13 +6,20 @@ # 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) | ||
### 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) | ||
- **docs:** sha256 packages, clarify hmac support ([#455](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/455)) ([1be5043](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/1be5043325991f3f5ccb52a8dd928f004b4d442e)) | ||
- 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) | ||
### BREAKING CHANGES | ||
- 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.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.0...v2.0.1) (2021-12-09) | ||
@@ -22,6 +29,2 @@ | ||
# [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) | ||
@@ -31,6 +34,2 @@ | ||
## [1.2.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.1...v1.2.2) (2021-10-12) | ||
@@ -40,6 +39,2 @@ | ||
## [1.2.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.0...v1.2.1) (2021-09-17) | ||
@@ -49,6 +44,2 @@ | ||
# [1.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.1.1...v1.2.0) (2021-09-17) | ||
@@ -58,6 +49,2 @@ | ||
## [1.1.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-universal@1.1.0...@aws-crypto/sha256-universal@1.1.1) (2021-07-13) | ||
@@ -67,19 +54,10 @@ | ||
# [1.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-universal@1.0.0...@aws-crypto/sha256-universal@1.1.0) (2021-01-13) | ||
### Bug Fixes | ||
* remove package lock ([6002a5a](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6002a5ab9218dc8798c19dc205d3eebd3bec5b43)) | ||
* **aws-crypto:** export explicit dependencies on [@aws-types](https://github.com/aws-types) ([6a1873a](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6a1873a4dcc2aaa4a1338595703cfa7099f17b8c)) | ||
* **deps-dev:** move @aws-sdk/types to devDependencies ([#188](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/188)) ([08efdf4](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/08efdf46dcc612d88c441e29945d787f253ee77d)) | ||
- remove package lock ([6002a5a](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6002a5ab9218dc8798c19dc205d3eebd3bec5b43)) | ||
- **aws-crypto:** export explicit dependencies on [@aws-types](https://github.com/aws-types) ([6a1873a](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6a1873a4dcc2aaa4a1338595703cfa7099f17b8c)) | ||
- **deps-dev:** move @aws-sdk/types to devDependencies ([#188](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/188)) ([08efdf4](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/08efdf46dcc612d88c441e29945d787f253ee77d)) | ||
# [1.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-universal@1.0.0-alpha.0...@aws-crypto/sha256-universal@1.0.0) (2020-10-22) | ||
@@ -89,6 +67,2 @@ | ||
# [1.0.0-alpha.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-universal@0.1.0-preview.4...@aws-crypto/sha256-universal@1.0.0-alpha.0) (2020-02-07) | ||
@@ -98,35 +72,20 @@ | ||
# [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-universal@0.1.0-preview.2...@aws-crypto/sha256-universal@0.1.0-preview.4) (2020-01-16) | ||
### Bug Fixes | ||
* Changed package.json files to point to the right Git repo ([#9](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/9)) ([028245d](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/028245d72e642ca98d82226afb300eb154503c4a)), closes [#8](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/8) | ||
* lerna version maintains package-lock ([#14](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/14)) ([2ef29e1](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/2ef29e13779703a5c9b32e93d18918fcb33b7272)), closes [#13](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/13) | ||
- Changed package.json files to point to the right Git repo ([#9](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/9)) ([028245d](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/028245d72e642ca98d82226afb300eb154503c4a)), closes [#8](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/8) | ||
- lerna version maintains package-lock ([#14](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/14)) ([2ef29e1](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/2ef29e13779703a5c9b32e93d18918fcb33b7272)), closes [#13](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/13) | ||
# [0.1.0-preview.3](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-universal@0.1.0-preview.2...@aws-crypto/sha256-universal@0.1.0-preview.3) (2019-11-15) | ||
### Bug Fixes | ||
* Changed package.json files to point to the right Git repo ([#9](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/9)) ([028245d](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/028245d72e642ca98d82226afb300eb154503c4a)), closes [#8](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/8) | ||
* lerna version maintains package-lock ([#14](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/14)) ([2ef29e1](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/2ef29e13779703a5c9b32e93d18918fcb33b7272)), closes [#13](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/13) | ||
- Changed package.json files to point to the right Git repo ([#9](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/9)) ([028245d](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/028245d72e642ca98d82226afb300eb154503c4a)), closes [#8](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/8) | ||
- lerna version maintains package-lock ([#14](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/14)) ([2ef29e1](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/2ef29e13779703a5c9b32e93d18918fcb33b7272)), closes [#13](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/13) | ||
# [0.1.0-preview.2](https://github.com/aws/aws-javascript-crypto-helpers/compare/@aws-crypto/sha256-universal@0.1.0-preview.1...@aws-crypto/sha256-universal@0.1.0-preview.2) (2019-10-30) | ||
### Bug Fixes | ||
* remove /src/ from .npmignore (for sourcemaps) ([#5](https://github.com/aws/aws-javascript-crypto-helpers/issues/5)) ([ec52056](https://github.com/aws/aws-javascript-crypto-helpers/commit/ec52056)) | ||
- remove /src/ from .npmignore (for sourcemaps) ([#5](https://github.com/aws/aws-javascript-crypto-helpers/issues/5)) ([ec52056](https://github.com/aws/aws-javascript-crypto-helpers/commit/ec52056)) |
{ | ||
"name": "@aws-crypto/sha256-universal", | ||
"version": "2.0.2", | ||
"version": "3.0.0", | ||
"scripts": { | ||
@@ -21,5 +21,5 @@ "prepublishOnly": "tsc", | ||
"dependencies": { | ||
"@aws-crypto/sha256-browser": "^2.0.2", | ||
"@aws-crypto/sha256-browser": "^3.0.0", | ||
"@aws-sdk/hash-node": "^3.110.0", | ||
"@aws-sdk/types": "^3.110.0", | ||
"@aws-sdk/types": "^3.222.0", | ||
"tslib": "^1.11.1" | ||
@@ -33,3 +33,3 @@ }, | ||
}, | ||
"gitHead": "5d1db32bb75010cbe38ff8dda9c560cdbb7ec578" | ||
"gitHead": "7f56cee8f62bd65cd397eeec29c3c997215bd80c" | ||
} |
@@ -7,2 +7,3 @@ # @aws-crypto/sha256-universal | ||
- To hash "some data" | ||
``` | ||
@@ -17,4 +18,14 @@ import {Sha256} from '@aws-crypto/sha256-universal' | ||
- To hmac "some data" with "a key" | ||
``` | ||
import {Sha256} from '@aws-crypto/sha256-universal' | ||
const hash = new Sha256('a key'); | ||
hash.update('some data'); | ||
const result = await hash.digest(); | ||
``` | ||
## Test | ||
`npm test` |
import { Sha256 as BrowserSha256 } from "@aws-crypto/sha256-browser"; | ||
import { Hash as NodeHash } from "@aws-sdk/hash-node"; | ||
import { Hash, SourceData } from "@aws-sdk/types"; | ||
import { Checksum, SourceData } from "@aws-sdk/types"; | ||
import { convertToBuffer } from "@aws-crypto/util"; | ||
import { NodeHash } from './node_hash' | ||
export class Sha256 implements Hash { | ||
private readonly hash: Hash; | ||
export class Sha256 implements Checksum { | ||
private hash: Checksum; | ||
@@ -17,3 +18,3 @@ constructor(secret?: SourceData) { | ||
update(data: SourceData, encoding?: "utf8" | "ascii" | "latin1"): void { | ||
this.hash.update(data, encoding); | ||
this.hash.update(convertToBuffer(data)); | ||
} | ||
@@ -24,2 +25,6 @@ | ||
} | ||
reset(): void { | ||
this.hash.reset(); | ||
} | ||
} | ||
@@ -26,0 +31,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24267
13
139
30
+ Added@aws-crypto/ie11-detection@3.0.0(transitive)
+ Added@aws-crypto/sha256-browser@3.0.0(transitive)
+ Added@aws-crypto/sha256-js@3.0.0(transitive)
+ Added@aws-crypto/supports-web-crypto@3.0.0(transitive)
+ Added@aws-crypto/util@3.0.0(transitive)
- Removed@aws-crypto/ie11-detection@2.0.2(transitive)
- Removed@aws-crypto/sha256-browser@2.0.2(transitive)
- Removed@aws-crypto/sha256-js@2.0.2(transitive)
- Removed@aws-crypto/supports-web-crypto@2.0.2(transitive)
- Removed@aws-crypto/util@2.0.2(transitive)
Updated@aws-sdk/types@^3.222.0