├── verdaccio ├── htpasswd ├── npmrc ├── integration │ ├── package.json │ └── Readme.md └── config.yaml ├── .prettierignore ├── packages ├── sha256-js │ ├── src │ │ ├── index.ts │ │ ├── constants.ts │ │ ├── jsSha256.ts │ │ └── RawSha256.ts │ ├── .npmignore │ ├── tsconfig.module.json │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── test │ │ ├── RawSha256.test.ts │ │ └── jsSha256.test.ts │ ├── README.md │ ├── package.json │ └── CHANGELOG.md ├── crc32 │ ├── .npmignore │ ├── tsconfig.module.json │ ├── src │ │ ├── index.ts │ │ ├── aws_crc32.ts │ │ └── crc32.ts │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ ├── test │ │ └── index.test.ts │ └── CHANGELOG.md ├── crc32c │ ├── .npmignore │ ├── tsconfig.module.json │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── README.md │ ├── src │ │ ├── aws_crc32c.ts │ │ └── index.ts │ ├── package.json │ ├── test │ │ └── index.test.ts │ └── CHANGELOG.md ├── supports-web-crypto │ ├── src │ │ ├── index.ts │ │ └── supportsWebCrypto.ts │ ├── .npmignore │ ├── tsconfig.module.json │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ ├── test │ │ └── supportsWebCrypto.test.ts │ └── CHANGELOG.md ├── util │ ├── .npmignore │ ├── tsconfig.module.json │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── README.md │ ├── src │ │ ├── index.ts │ │ ├── numToUint8.ts │ │ ├── isEmptyData.ts │ │ ├── uint32ArrayFrom.ts │ │ └── convertToBuffer.ts │ ├── test │ │ ├── uint32ArrayFrom.test.ts │ │ ├── isEmptyData.test.ts │ │ └── convertToBuffer.test.ts │ ├── package.json │ └── CHANGELOG.md ├── sha1-browser │ ├── .npmignore │ ├── src │ │ ├── index.ts │ │ ├── isEmptyData.ts │ │ ├── constants.ts │ │ ├── crossPlatformSha1.ts │ │ └── webCryptoSha1.ts │ ├── test │ │ ├── testUtils.fixture.ts │ │ ├── index.test.ts │ │ ├── isEmptyData.test.ts │ │ └── webCryptoSha1.test.ts │ ├── tsconfig.module.json │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── CHANGELOG.md ├── random-source-node │ ├── .npmignore │ ├── tsconfig.module.json │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── README.md │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.test.ts │ ├── package.json │ └── CHANGELOG.md ├── sha256-browser │ ├── .npmignore │ ├── src │ │ ├── index.ts │ │ ├── isEmptyData.ts │ │ ├── constants.ts │ │ ├── crossPlatformSha256.ts │ │ └── webCryptoSha256.ts │ ├── test │ │ ├── testUtils.fixture.ts │ │ ├── index.test.ts │ │ ├── isEmptyData.test.ts │ │ └── webCryptoSha256.test.ts │ ├── tsconfig.module.json │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── CHANGELOG.md ├── sha256-universal │ ├── .npmignore │ ├── tsconfig.module.json │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── test │ │ ├── nodeUsage.test.ts │ │ ├── browserUsage.test.ts │ │ └── index.test.ts │ ├── README.md │ ├── src │ │ └── index.ts │ ├── package.json │ └── CHANGELOG.md ├── random-source-browser │ ├── .npmignore │ ├── tsconfig.module.json │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── src │ │ ├── webCryptoRandomValues.ts │ │ └── index.ts │ ├── README.md │ ├── test │ │ ├── webCryptoRandomValues.test.ts │ │ └── index.test.ts │ ├── package.json │ └── CHANGELOG.md ├── random-source-universal │ ├── .npmignore │ ├── tsconfig.module.json │ ├── tsconfig.test.json │ ├── tsconfig.json │ ├── README.md │ ├── src │ │ └── index.ts │ ├── test │ │ ├── nodeUsage.test.ts │ │ └── browserUsage.test.ts │ ├── package.json │ └── CHANGELOG.md └── tsconfig.json ├── lerna.json ├── NOTICE ├── .github ├── workflows │ ├── pull.yaml │ ├── push.yaml │ ├── daily_ci.yaml │ ├── ci-unit-tests.yaml │ └── promote-to-master-pr.yaml ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── codebuild ├── nodejs_latest.yml ├── test_vectors │ └── test_publish.yml └── release │ ├── version.yml │ ├── prod-release.yml │ └── publish.yml ├── .gitignore ├── SUPPORT_POLICY.rst ├── wallaby.conf.js ├── util ├── local_verdaccio_publish └── verify_release ├── package.json ├── README.md ├── CONTRIBUTING.md └── CHANGELOG.md /verdaccio/htpasswd: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/*/CHANGELOG.md 2 | **/*/package-lock.json -------------------------------------------------------------------------------- /packages/sha256-js/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./jsSha256"; 2 | -------------------------------------------------------------------------------- /verdaccio/npmrc: -------------------------------------------------------------------------------- 1 | loglevel=warn 2 | registry=http://localhost:4873/ 3 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": ["packages/*"], 3 | "version": "5.2.0" 4 | } 5 | -------------------------------------------------------------------------------- /packages/crc32/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /packages/crc32c/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /packages/supports-web-crypto/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./supportsWebCrypto"; 2 | -------------------------------------------------------------------------------- /packages/util/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /packages/sha1-browser/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /packages/sha256-js/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /packages/random-source-node/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /packages/sha256-browser/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /packages/sha256-universal/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /packages/random-source-browser/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /packages/random-source-universal/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /packages/supports-web-crypto/.npmignore: -------------------------------------------------------------------------------- 1 | /test/ 2 | /coverage/ 3 | /docs/ 4 | tsconfig.test.json -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | AWS SDK JS Crypto Helpers 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | -------------------------------------------------------------------------------- /verdaccio/integration/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "integration", 3 | "version": "1.0.0", 4 | "license": "Apache-2.0" 5 | } 6 | -------------------------------------------------------------------------------- /packages/sha1-browser/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./crossPlatformSha1"; 2 | export { Sha1 as WebCryptoSha1 } from "./webCryptoSha1"; 3 | -------------------------------------------------------------------------------- /packages/sha256-browser/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./crossPlatformSha256"; 2 | export { Sha256 as WebCryptoSha256 } from "./webCryptoSha256"; 3 | -------------------------------------------------------------------------------- /packages/sha1-browser/test/testUtils.fixture.ts: -------------------------------------------------------------------------------- 1 | export function flushPromises(): Promise { 2 | return new Promise((resolve) => setTimeout(resolve)); 3 | } 4 | -------------------------------------------------------------------------------- /packages/sha256-browser/test/testUtils.fixture.ts: -------------------------------------------------------------------------------- 1 | export function flushPromises(): Promise { 2 | return new Promise(resolve => setTimeout(resolve)); 3 | } 4 | -------------------------------------------------------------------------------- /packages/crc32/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/crc32c/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/util/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/sha1-browser/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/sha256-js/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/random-source-node/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/sha256-browser/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/sha256-universal/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/random-source-browser/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/random-source-universal/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/supports-web-crypto/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "outDir": "build/module", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/sha256-js/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.github/workflows/pull.yaml: -------------------------------------------------------------------------------- 1 | # This workflow runs for every pull request 2 | name: PR CI 3 | 4 | on: 5 | pull_request: 6 | 7 | jobs: 8 | pr-ci-js-helpers-test: 9 | uses: ./.github/workflows/ci-unit-tests.yaml -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | _Issue #, if available:_ 2 | 3 | _Description of changes:_ 4 | 5 | By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. 6 | -------------------------------------------------------------------------------- /packages/crc32/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from "./crc32"; 5 | export { AwsCrc32 } from "./aws_crc32"; 6 | -------------------------------------------------------------------------------- /packages/crc32/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/util/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /verdaccio/integration/Readme.md: -------------------------------------------------------------------------------- 1 | npx v7 will not install a newer version when any version is installed. 2 | This module is a place to run npx on our integration modules. 3 | 4 | see `util/npx-verdaccio` for more details 5 | -------------------------------------------------------------------------------- /packages/crc32c/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/random-source-browser/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/sha1-browser/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/sha256-browser/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/random-source-node/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/sha256-universal/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/supports-web-crypto/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/random-source-universal/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "inlineSourceMap": true, 6 | "inlineSources": true, 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: '13:00' 8 | open-pull-requests-limit: 10 9 | versioning-strategy: increase-if-necessary 10 | -------------------------------------------------------------------------------- /packages/crc32/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./build/main", 6 | }, 7 | "include": ["src/**/*.ts"], 8 | "exclude": ["node_modules/**"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/crc32c/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./build/main", 6 | }, 7 | "include": ["src/**/*.ts"], 8 | "exclude": ["node_modules/**"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/util/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./build/main", 6 | }, 7 | "include": ["src/**/*.ts"], 8 | "exclude": ["node_modules/**"] 9 | } 10 | -------------------------------------------------------------------------------- /.github/workflows/push.yaml: -------------------------------------------------------------------------------- 1 | # This workflow runs for every push to master 2 | name: Push CI 3 | 4 | on: 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | push-ci-js-helpers-test: 11 | uses: ./.github/workflows/ci-unit-tests.yaml -------------------------------------------------------------------------------- /packages/sha256-universal/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./build/main", 6 | }, 7 | "include": ["src/**/*.ts"], 8 | "exclude": ["node_modules/**"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/random-source-node/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./build/main", 6 | }, 7 | "include": ["src/**/*.ts"], 8 | "exclude": ["node_modules/**"] 9 | } 10 | -------------------------------------------------------------------------------- /.github/workflows/daily_ci.yaml: -------------------------------------------------------------------------------- 1 | # This workflow runs every weekday at 15:00 UTC (8AM PDT) 2 | name: Daily CI 3 | 4 | on: 5 | schedule: 6 | - cron: "00 15 * * 1-5" 7 | 8 | jobs: 9 | daily-ci-js-helpers: 10 | uses: ./.github/workflows/ci-unit-tests.yaml -------------------------------------------------------------------------------- /packages/sha1-browser/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./build/main", 6 | "lib": ["dom"], 7 | }, 8 | "include": ["src/**/*.ts"], 9 | "exclude": ["node_modules/**"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/sha256-js/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./build/main", 6 | "lib": ["dom"], 7 | }, 8 | "include": ["src/**/*.ts"], 9 | "exclude": ["node_modules/**"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/sha1-browser/src/isEmptyData.ts: -------------------------------------------------------------------------------- 1 | import { SourceData } from "@aws-sdk/types"; 2 | 3 | export function isEmptyData(data: SourceData): boolean { 4 | if (typeof data === "string") { 5 | return data.length === 0; 6 | } 7 | 8 | return data.byteLength === 0; 9 | } 10 | -------------------------------------------------------------------------------- /packages/sha256-browser/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./build/main", 6 | "lib": ["dom"], 7 | }, 8 | "include": ["src/**/*.ts"], 9 | "exclude": ["node_modules/**"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/random-source-browser/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./build/main", 6 | "lib": ["dom"], 7 | }, 8 | "include": ["src/**/*.ts"], 9 | "exclude": ["node_modules/**"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/sha256-browser/src/isEmptyData.ts: -------------------------------------------------------------------------------- 1 | import { SourceData } from "@aws-sdk/types"; 2 | 3 | export function isEmptyData(data: SourceData): boolean { 4 | if (typeof data === "string") { 5 | return data.length === 0; 6 | } 7 | 8 | return data.byteLength === 0; 9 | } 10 | -------------------------------------------------------------------------------- /packages/supports-web-crypto/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "lib": ["dom"], 5 | "rootDir": "./src", 6 | "outDir": "./build/main", 7 | }, 8 | "include": ["src/**/*.ts"], 9 | "exclude": ["node_modules/**"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/random-source-universal/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./build/main", 6 | "lib": ["dom"], 7 | }, 8 | "include": ["src/**/*.ts"], 9 | "exclude": ["node_modules/**"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/util/README.md: -------------------------------------------------------------------------------- 1 | # @aws-crypto/util 2 | 3 | Helper functions 4 | 5 | ## Usage 6 | 7 | ``` 8 | import { convertToBuffer } from '@aws-crypto/util'; 9 | 10 | const data = "asdf"; 11 | const utf8EncodedUint8Array = convertToBuffer(data); 12 | ``` 13 | 14 | ## Test 15 | 16 | `npm test` 17 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Each line is a file pattern followed by one or more owners. 2 | # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners 3 | 4 | # Default code owner for everything is our aws-crypto-tools group 5 | * @aws/aws-crypto-tools 6 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | 3 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 4 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 5 | opensource-codeofconduct@amazon.com with any additional questions or comments. 6 | -------------------------------------------------------------------------------- /packages/crc32/README.md: -------------------------------------------------------------------------------- 1 | # @aws-crypto/crc32 2 | 3 | Pure JS implementation of CRC32 https://en.wikipedia.org/wiki/Cyclic_redundancy_check 4 | 5 | ## Usage 6 | 7 | ``` 8 | import { Crc32 } from '@aws-crypto/crc32'; 9 | 10 | const crc32Digest = (new Crc32).update(buffer).digest() 11 | 12 | ``` 13 | 14 | ## Test 15 | 16 | `npm test` 17 | -------------------------------------------------------------------------------- /packages/util/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export { convertToBuffer } from "./convertToBuffer"; 5 | export { isEmptyData } from "./isEmptyData"; 6 | export { numToUint8 } from "./numToUint8"; 7 | export {uint32ArrayFrom} from './uint32ArrayFrom'; 8 | -------------------------------------------------------------------------------- /packages/crc32c/README.md: -------------------------------------------------------------------------------- 1 | # @aws-crypto/crc32c 2 | 3 | Pure JS implementation of CRC32-C https://en.wikipedia.org/wiki/Cyclic_redundancy_check 4 | 5 | ## Usage 6 | 7 | ``` 8 | import { Crc32c } from '@aws-crypto/crc32c'; 9 | 10 | const crc32Digest = (new Crc32c).update(buffer).digest() 11 | 12 | ``` 13 | 14 | ## Test 15 | 16 | `npm test` 17 | -------------------------------------------------------------------------------- /codebuild/nodejs_latest.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | env: 4 | variables: 5 | NODE_OPTIONS: "--max-old-space-size=4096" 6 | 7 | phases: 8 | install: 9 | runtime-versions: 10 | nodejs: latest 11 | commands: 12 | - node --version ; npm --version 13 | - npm ci --unsafe-perm 14 | build: 15 | commands: 16 | - npm test 17 | -------------------------------------------------------------------------------- /packages/util/src/numToUint8.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export function numToUint8(num: number) { 5 | return new Uint8Array([ 6 | (num & 0xff000000) >> 24, 7 | (num & 0x00ff0000) >> 16, 8 | (num & 0x0000ff00) >> 8, 9 | num & 0x000000ff, 10 | ]); 11 | } 12 | -------------------------------------------------------------------------------- /packages/sha1-browser/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import * as browser from "../src/"; 4 | 5 | describe("exported symbols", () => { 6 | it("should export each implementation as a stable symbol", () => { 7 | expect(typeof browser.Sha1).to.eql("function"); 8 | expect(typeof browser.WebCryptoSha1).to.eql("function"); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /packages/util/src/isEmptyData.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { SourceData } from "@aws-sdk/types"; 5 | 6 | export function isEmptyData(data: SourceData): boolean { 7 | if (typeof data === "string") { 8 | return data.length === 0; 9 | } 10 | 11 | return data.byteLength === 0; 12 | } 13 | -------------------------------------------------------------------------------- /packages/sha256-browser/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import * as browser from "../src/"; 4 | 5 | describe("exported symbols", () => { 6 | it("should export each implementation as a stable symbol", () => { 7 | expect(typeof browser.Sha256).to.eql("function"); 8 | expect(typeof browser.WebCryptoSha256).to.eql("function"); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Vim swap files 2 | *~ 3 | *.swp 4 | *.swo 5 | 6 | # OS Artifacts 7 | .DS_Store 8 | 9 | # Artifacts 10 | build 11 | node_modules 12 | 13 | # VSCode 14 | .vscode 15 | .history 16 | 17 | # JetBrains 18 | .idea 19 | 20 | # nyc/code coverage 21 | .nyc_output 22 | .karma_output 23 | coverage 24 | 25 | # Lerna 26 | /lerna-debug.log 27 | 28 | # verdaccio 29 | storage 30 | /verdaccio/.npx 31 | -------------------------------------------------------------------------------- /packages/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "declaration": true, 7 | "strict": true, 8 | "sourceMap": true, 9 | "downlevelIteration": true, 10 | "lib": ["es5", "es2015.promise", "es2015.collection", "es2015.iterable"], 11 | "importHelpers": true, 12 | "noEmitHelpers": true 13 | }, 14 | } -------------------------------------------------------------------------------- /packages/random-source-universal/README.md: -------------------------------------------------------------------------------- 1 | # @aws-crypto/random-source-universal 2 | 3 | Access to a secure random source in either a browser or NodeJs. 4 | See @aws-crypto/random-source-browser and @aws-crypto/random-source-node 5 | 6 | ## Usage 7 | 8 | ``` 9 | import {randomValues} from '@aws-crypto/random-source-universal' 10 | 11 | const seedData = await randomValues(16); 12 | 13 | ``` 14 | 15 | ## Test 16 | 17 | `npm test` 18 | -------------------------------------------------------------------------------- /packages/random-source-node/README.md: -------------------------------------------------------------------------------- 1 | # @aws-crypto/random-source-node 2 | 3 | Access to a secure random source in NodeJs. 4 | This package exists provide a consistent interface 5 | with @aws-crypto/random-source-browser. 6 | Especially for @aws-crypto/random-source-universal 7 | 8 | ## Usage 9 | 10 | ``` 11 | import {randomValues} from '@aws-crypto/random-source-node' 12 | 13 | const seedData = await randomValues(16); 14 | 15 | ``` 16 | 17 | ## Test 18 | 19 | `npm test` 20 | -------------------------------------------------------------------------------- /packages/sha1-browser/README.md: -------------------------------------------------------------------------------- 1 | # @aws-crypto/sha1-browser 2 | 3 | SHA1 wrapper for browsers that prefers `window.crypto.subtle`. 4 | 5 | SHA1 is **NOT** a cryptographically secure algorithm. 6 | It should _only_ be used for non cryptographic functions like checksums. 7 | 8 | ## Usage 9 | 10 | ``` 11 | import {Sha1} from '@aws-crypto/sha1-browser' 12 | 13 | const hash = new Sha1(); 14 | hash.update('some data'); 15 | const result = await hash.digest(); 16 | 17 | ``` 18 | 19 | ## Test 20 | 21 | `npm test` 22 | -------------------------------------------------------------------------------- /packages/sha1-browser/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const SHA_1_HASH: { name: "SHA-1" } = { name: "SHA-1" }; 2 | 3 | export const SHA_1_HMAC_ALGO: { name: "HMAC"; hash: { name: "SHA-1" } } = { 4 | name: "HMAC", 5 | hash: SHA_1_HASH, 6 | }; 7 | 8 | export const EMPTY_DATA_SHA_1 = new Uint8Array([ 9 | 218, 10 | 57, 11 | 163, 12 | 238, 13 | 94, 14 | 107, 15 | 75, 16 | 13, 17 | 50, 18 | 85, 19 | 191, 20 | 239, 21 | 149, 22 | 96, 23 | 24, 24 | 144, 25 | 175, 26 | 216, 27 | 7, 28 | 9, 29 | ]); 30 | -------------------------------------------------------------------------------- /packages/random-source-node/src/index.ts: -------------------------------------------------------------------------------- 1 | import { randomBytes } from "crypto"; 2 | import { randomValues as IRandomValues } from "@aws-sdk/types"; 3 | 4 | /** 5 | * @implements {IRandomValues} 6 | */ 7 | export function randomValues(byteLength: number): Promise { 8 | return new Promise((resolve, reject) => { 9 | randomBytes(byteLength, (err: Error | null, buf: Buffer) => { 10 | if (err) { 11 | reject(err); 12 | } else { 13 | resolve(buf); 14 | } 15 | }); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /packages/sha256-js/test/RawSha256.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { hashTestVectors } from "../src/knownHashes.fixture"; 4 | import { RawSha256 } from "../src/RawSha256"; 5 | 6 | describe("Hash", () => { 7 | let idx = 0; 8 | for (const [input, result] of hashTestVectors) { 9 | it("should match known hash calculations: " + idx++, () => { 10 | const hash = new RawSha256(); 11 | hash.update(input); 12 | expect(hash.digest()).to.deep.equal(result); 13 | }); 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /packages/random-source-browser/src/webCryptoRandomValues.ts: -------------------------------------------------------------------------------- 1 | interface IRandomValues { 2 | (byteLength: number): Promise; 3 | } 4 | import { locateWindow } from "@aws-sdk/util-locate-window"; 5 | 6 | /** 7 | * @implements {IRandomValues} 8 | */ 9 | export function randomValues(byteLength: number): Promise { 10 | return new Promise(resolve => { 11 | const randomBytes = new Uint8Array(byteLength); 12 | locateWindow().crypto.getRandomValues(randomBytes); 13 | 14 | resolve(randomBytes); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /codebuild/test_vectors/test_publish.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | env: 4 | variables: 5 | NODE_OPTIONS: "--max-old-space-size=4096" 6 | NPM_CONFIG_UNSAFE_PERM: true 7 | 8 | phases: 9 | install: 10 | runtime-versions: 11 | nodejs: latest 12 | commands: 13 | - npm ci 14 | build: 15 | commands: 16 | - npm test 17 | - |- 18 | if [ "$CI" = "true" ]; then 19 | npm run verdaccio-publish 20 | npm run verdaccio-verify-publish -- ci 21 | else 22 | npm run verdaccio-verify-publish -- public 23 | fi 24 | -------------------------------------------------------------------------------- /packages/sha256-js/README.md: -------------------------------------------------------------------------------- 1 | # crypto-sha256-js 2 | 3 | A pure JS implementation SHA256. 4 | 5 | ## Usage 6 | 7 | - To hash "some data" 8 | ``` 9 | import {Sha256} from '@aws-crypto/sha256-js'; 10 | 11 | const hash = new Sha256(); 12 | hash.update('some data'); 13 | const result = await hash.digest(); 14 | 15 | ``` 16 | 17 | - To hmac "some data" with "a key" 18 | ``` 19 | import {Sha256} from '@aws-crypto/sha256-js'; 20 | 21 | const hash = new Sha256('a key'); 22 | hash.update('some data'); 23 | const result = await hash.digest(); 24 | 25 | ``` 26 | 27 | ## Test 28 | 29 | `npm test` 30 | -------------------------------------------------------------------------------- /packages/sha256-universal/test/nodeUsage.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { Sha256 } from "../src/"; 4 | 5 | import * as sinon from "sinon"; 6 | import * as crypto from "crypto"; 7 | import { Hash } from "@smithy/hash-node"; 8 | 9 | describe("implementation selection", () => { 10 | before(() => sinon.stub(crypto, "createHash")); 11 | after(() => sinon.restore()); 12 | it("should use the node implementation when the crypto module is defined", () => { 13 | const sha256 = new Sha256(); 14 | expect((sha256 as any).hash).to.be.instanceof(Hash); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /.github/workflows/ci-unit-tests.yaml: -------------------------------------------------------------------------------- 1 | name: Unit tests 2 | 3 | on: workflow_call 4 | 5 | jobs: 6 | ci-unit-tests: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | fail-fast: true 10 | matrix: 11 | os: 12 | - ubuntu-latest 13 | - windows-latest 14 | - macos-latest 15 | node: 16 | - 16 17 | - 18 18 | - 20 19 | steps: 20 | - uses: actions/checkout@v2 21 | - uses: actions/setup-node@v1 22 | with: 23 | node-version: ${{ matrix.node }} 24 | - uses: bahmutov/npm-install@v1 25 | - run: npm test 26 | -------------------------------------------------------------------------------- /packages/util/src/uint32ArrayFrom.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // IE 11 does not support Array.from, so we do it manually 5 | export function uint32ArrayFrom(a_lookUpTable: Array): Uint32Array { 6 | if (!Uint32Array.from) { 7 | const return_array = new Uint32Array(a_lookUpTable.length) 8 | let a_index = 0 9 | while (a_index < a_lookUpTable.length) { 10 | return_array[a_index] = a_lookUpTable[a_index] 11 | a_index += 1 12 | } 13 | return return_array 14 | } 15 | return Uint32Array.from(a_lookUpTable) 16 | } 17 | -------------------------------------------------------------------------------- /packages/sha256-universal/README.md: -------------------------------------------------------------------------------- 1 | # @aws-crypto/sha256-universal 2 | 3 | A consistent interface for SHA256 across browsers and NodeJs 4 | 5 | ## Usage 6 | 7 | - To hash "some data" 8 | ``` 9 | import {Sha256} from '@aws-crypto/sha256-universal' 10 | 11 | const hash = new Sha256(); 12 | hash.update('some data'); 13 | const result = await hash.digest(); 14 | 15 | ``` 16 | 17 | - To hmac "some data" with "a key" 18 | ``` 19 | import {Sha256} from '@aws-crypto/sha256-universal' 20 | 21 | const hash = new Sha256('a key'); 22 | hash.update('some data'); 23 | const result = await hash.digest(); 24 | 25 | ``` 26 | 27 | ## Test 28 | 29 | `npm test` 30 | -------------------------------------------------------------------------------- /packages/sha256-universal/test/browserUsage.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { Sha256 } from "../src/"; 4 | import { Sha256 as BrowserSha256 } from "@aws-crypto/sha256-browser"; 5 | 6 | import * as sinon from "sinon"; 7 | import * as crypto from "crypto"; 8 | 9 | describe("implementation selection", () => { 10 | before(() => sinon.stub(crypto, "createHash").value(false)); 11 | after(() => sinon.restore()); 12 | 13 | it("should use the browser implementation when the crypto module is not defined", () => { 14 | const sha256 = new Sha256(); 15 | expect((sha256 as any).hash).to.be.instanceof(BrowserSha256); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /.github/workflows/promote-to-master-pr.yaml: -------------------------------------------------------------------------------- 1 | name: Promote development to master 2 | 3 | on: 4 | push: 5 | branches: 6 | - development 7 | 8 | jobs: 9 | promote-to-master-pr: 10 | name: Promote development to master 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: promote 14 | uses: vsoch/pull-request-action@master 15 | env: 16 | GITHUB_TOKEN: ${{ secrets.MERGE_TOKEN }} 17 | BRANCH_PREFIX: development 18 | PULL_REQUEST_BRANCH: master 19 | PULL_REQUEST_TITLE: Promote development to master 20 | PULL_REQUEST_BODY: | 21 | Automatic promotion from development to master. 22 | -------------------------------------------------------------------------------- /packages/sha256-browser/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const SHA_256_HASH: { name: "SHA-256" } = { name: "SHA-256" }; 2 | 3 | export const SHA_256_HMAC_ALGO: { name: "HMAC"; hash: { name: "SHA-256" } } = { 4 | name: "HMAC", 5 | hash: SHA_256_HASH 6 | }; 7 | 8 | export const EMPTY_DATA_SHA_256 = new Uint8Array([ 9 | 227, 10 | 176, 11 | 196, 12 | 66, 13 | 152, 14 | 252, 15 | 28, 16 | 20, 17 | 154, 18 | 251, 19 | 244, 20 | 200, 21 | 153, 22 | 111, 23 | 185, 24 | 36, 25 | 39, 26 | 174, 27 | 65, 28 | 228, 29 | 100, 30 | 155, 31 | 147, 32 | 76, 33 | 164, 34 | 149, 35 | 153, 36 | 27, 37 | 120, 38 | 82, 39 | 184, 40 | 85 41 | ]); 42 | -------------------------------------------------------------------------------- /packages/crc32/src/aws_crc32.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { SourceData, Checksum } from "@aws-sdk/types"; 5 | import { convertToBuffer, isEmptyData, numToUint8 } from "@aws-crypto/util"; 6 | import { Crc32 } from "./crc32"; 7 | 8 | export class AwsCrc32 implements Checksum { 9 | private crc32 = new Crc32(); 10 | 11 | update(toHash: SourceData) { 12 | if (isEmptyData(toHash)) return; 13 | 14 | this.crc32.update(convertToBuffer(toHash)); 15 | } 16 | 17 | async digest(): Promise { 18 | return numToUint8(this.crc32.digest()); 19 | } 20 | 21 | reset(): void { 22 | this.crc32 = new Crc32(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/util/test/uint32ArrayFrom.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { expect } from "chai"; 5 | import "mocha"; 6 | import { uint32ArrayFrom } from "../src/uint32ArrayFrom"; 7 | 8 | describe("uint32ArrayFrom", () =>{ 9 | it("When given an empty array, should return an empty array", () => { 10 | expect(uint32ArrayFrom(Array.of(0))) 11 | .to 12 | .eql(Uint32Array.of(0)) 13 | }) 14 | 15 | it("Given a populated array, returns a valid Uint32 Array", () => { 16 | expect(uint32ArrayFrom(Array.of(0x00000000, 0xF26B8303, 0xE13B70F7))) 17 | .to 18 | .eql(Uint32Array.of(0, 4067132163, 3778769143)) 19 | }) 20 | }) 21 | -------------------------------------------------------------------------------- /packages/crc32c/src/aws_crc32c.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { Checksum, SourceData } from "@aws-sdk/types"; 5 | import { convertToBuffer, isEmptyData, numToUint8 } from "@aws-crypto/util"; 6 | import { Crc32c } from "./index"; 7 | 8 | export class AwsCrc32c implements Checksum { 9 | private crc32c = new Crc32c(); 10 | 11 | update(toHash: SourceData) { 12 | if (isEmptyData(toHash)) return; 13 | 14 | this.crc32c.update(convertToBuffer(toHash)); 15 | } 16 | 17 | async digest(): Promise { 18 | return numToUint8(this.crc32c.digest()); 19 | } 20 | 21 | reset(): void { 22 | this.crc32c = new Crc32c(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/sha256-browser/README.md: -------------------------------------------------------------------------------- 1 | # @aws-crypto/sha256-browser 2 | 3 | SHA256 wrapper for browsers that prefers `window.crypto.subtle` but will 4 | fall back to a pure JS implementation in @aws-crypto/sha256-js 5 | to provide a consistent interface for SHA256. 6 | 7 | ## Usage 8 | 9 | - To hash "some data" 10 | ``` 11 | import {Sha256} from '@aws-crypto/sha256-browser' 12 | 13 | const hash = new Sha256(); 14 | hash.update('some data'); 15 | const result = await hash.digest(); 16 | 17 | ``` 18 | 19 | - To hmac "some data" with "a key" 20 | ``` 21 | import {Sha256} from '@aws-crypto/sha256-browser' 22 | 23 | const hash = new Sha256('a key'); 24 | hash.update('some data'); 25 | const result = await hash.digest(); 26 | 27 | ``` 28 | 29 | ## Test 30 | 31 | `npm test` 32 | -------------------------------------------------------------------------------- /packages/supports-web-crypto/README.md: -------------------------------------------------------------------------------- 1 | # @aws-crypto/supports-web-crypto 2 | 3 | Functions to check web crypto support for browsers. 4 | 5 | ## Usage 6 | 7 | ``` 8 | import {supportsWebCrypto} from '@aws-crypto/supports-web-crypto'; 9 | 10 | if (supportsWebCrypto(window)) { 11 | // window.crypto.subtle.encrypt will exist 12 | } 13 | 14 | ``` 15 | 16 | ## supportsWebCrypto 17 | 18 | Used to make sure `window.crypto.subtle` exists and implements crypto functions 19 | as well as a cryptographic secure random source exists. 20 | 21 | ## supportsSecureRandom 22 | 23 | Used to make sure that a cryptographic secure random source exists. 24 | Does not check for `window.crypto.subtle`. 25 | 26 | ## supportsSubtleCrypto 27 | 28 | ## supportsZeroByteGCM 29 | 30 | ## Test 31 | 32 | `npm test` 33 | -------------------------------------------------------------------------------- /packages/random-source-browser/README.md: -------------------------------------------------------------------------------- 1 | # @aws-crypto/random-source-browser 2 | 3 | Access to a secure random source in a browser. 4 | `Math.random` is not acceptable for cryptographic operations. 5 | This module exports a consistent interface for modern browsers. 6 | 7 | 8 | ## Usage 9 | 10 | ``` 11 | import {randomValues, randomValuesOnly} from '@aws-crypto/random-source-browser' 12 | 13 | const seedData2 = await randomValues(16); 14 | const seedData1 = await randomValuesOnly(16); 15 | 16 | ``` 17 | 18 | ## randomValues vs randomValuesOnly 19 | 20 | Some browsers only implement `crypto.getRandomValues` and not `crypto.subtle`. 21 | If you need to have access to both, you should use `randomValues`. But if 22 | you want to use some cryptographic fallback like MSRCrypto `randomValuesOnly` 23 | is the preferred function. 24 | 25 | ## Test 26 | 27 | `npm test` 28 | -------------------------------------------------------------------------------- /codebuild/release/version.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | env: 4 | variables: 5 | NODE_OPTIONS: "--max-old-space-size=4096" 6 | BRANCH: "master" 7 | # An explicit version bump 8 | VERSION_BUMP: "" 9 | git-credential-helper: yes 10 | 11 | phases: 12 | install: 13 | commands: 14 | - npm ci --unsafe-perm 15 | runtime-versions: 16 | nodejs: latest 17 | pre_build: 18 | commands: 19 | - git config --global user.name "aws-crypto-tools-ci-bot" 20 | - git config --global user.email "no-reply@noemail.local" 21 | - git checkout $BRANCH 22 | build: 23 | commands: 24 | # Generate new version and CHANGELOG entry and push it 25 | - npx lerna version --conventional-commits --git-remote origin --yes ${VERSION_BUMP:+$VERSION_BUMP --force-publish} 26 | # Log the commit for posterity 27 | - git log -n 1 28 | -------------------------------------------------------------------------------- /packages/random-source-universal/src/index.ts: -------------------------------------------------------------------------------- 1 | import { randomValues as browserRandomValues } from "@aws-crypto/random-source-browser"; 2 | import { randomValues as nodeRandomValues } from "@aws-crypto/random-source-node"; 3 | import { randomValues as IRandomValues } from "@aws-sdk/types"; 4 | 5 | /** 6 | * @implements {IRandomValues} 7 | */ 8 | export function randomValues(byteLength: number): Promise { 9 | if (supportsCryptoModule) { 10 | return nodeRandomValues(byteLength); 11 | } 12 | 13 | return browserRandomValues(byteLength); 14 | } 15 | 16 | /** 17 | * Try to require Node's crypto module and record whether the operation 18 | * succeeded. 19 | * 20 | * @internal 21 | */ 22 | const supportsCryptoModule: boolean = (() => { 23 | try { 24 | return !!require("crypto").randomBytes; 25 | } catch { 26 | return false; 27 | } 28 | })(); 29 | -------------------------------------------------------------------------------- /packages/random-source-universal/test/nodeUsage.test.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | 3 | import * as sinon from "sinon"; 4 | 5 | import * as browserRandom from "@aws-crypto/random-source-browser"; 6 | import * as nodeRandom from "@aws-crypto/random-source-node"; 7 | 8 | try { 9 | // @ts-ignore reset the module 10 | delete require.cache[require.resolve("../src/")]; 11 | } catch {} 12 | import { randomValues } from "../src/"; 13 | 14 | describe("implementation selection", () => { 15 | after(() => sinon.restore()); 16 | 17 | it("should use the node implementation when the crypto module is defined", async () => { 18 | const node = sinon.spy(nodeRandom, "randomValues"); 19 | const browser = sinon.spy(browserRandom, "randomValues"); 20 | 21 | await randomValues(1); 22 | 23 | sinon.assert.calledOnce(node); 24 | sinon.assert.notCalled(browser); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /packages/random-source-browser/src/index.ts: -------------------------------------------------------------------------------- 1 | import { randomValues as webCryptoRandomValues } from "./webCryptoRandomValues"; 2 | import { 3 | supportsWebCrypto, 4 | supportsSecureRandom 5 | } from "@aws-crypto/supports-web-crypto"; 6 | import { locateWindow } from "@aws-sdk/util-locate-window"; 7 | 8 | export function testableRandomValues( 9 | supports: typeof supportsWebCrypto 10 | ) { 11 | return function randomValues(byteLength: number): Promise { 12 | // Find the global scope for this runtime 13 | const globalScope = locateWindow(); 14 | 15 | if (supports(globalScope)) { 16 | return webCryptoRandomValues(byteLength); 17 | } 18 | 19 | return Promise.reject(new Error(`Unable to locate a secure random source.`)); 20 | } 21 | } 22 | 23 | export const randomValues = testableRandomValues(supportsWebCrypto); 24 | export const randomValuesOnly = testableRandomValues(supportsSecureRandom); 25 | -------------------------------------------------------------------------------- /packages/util/src/convertToBuffer.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { SourceData } from "@aws-sdk/types"; 5 | import { fromUtf8 as fromUtf8Browser } from "@smithy/util-utf8"; 6 | 7 | // Quick polyfill 8 | const fromUtf8 = 9 | typeof Buffer !== "undefined" && Buffer.from 10 | ? (input: string) => Buffer.from(input, "utf8") 11 | : fromUtf8Browser; 12 | 13 | export function convertToBuffer(data: SourceData): Uint8Array { 14 | // Already a Uint8, do nothing 15 | if (data instanceof Uint8Array) return data; 16 | 17 | if (typeof data === "string") { 18 | return fromUtf8(data); 19 | } 20 | 21 | if (ArrayBuffer.isView(data)) { 22 | return new Uint8Array( 23 | data.buffer, 24 | data.byteOffset, 25 | data.byteLength / Uint8Array.BYTES_PER_ELEMENT 26 | ); 27 | } 28 | 29 | return new Uint8Array(data); 30 | } 31 | -------------------------------------------------------------------------------- /packages/sha1-browser/src/crossPlatformSha1.ts: -------------------------------------------------------------------------------- 1 | import { Sha1 as WebCryptoSha1 } from "./webCryptoSha1"; 2 | import { Checksum, SourceData } from "@aws-sdk/types"; 3 | import { supportsWebCrypto } from "@aws-crypto/supports-web-crypto"; 4 | import { locateWindow } from "@aws-sdk/util-locate-window"; 5 | import { convertToBuffer } from "@aws-crypto/util"; 6 | 7 | export class Sha1 implements Checksum { 8 | private hash: Checksum; 9 | 10 | constructor(secret?: SourceData) { 11 | if (supportsWebCrypto(locateWindow())) { 12 | this.hash = new WebCryptoSha1(secret); 13 | } else { 14 | throw new Error("SHA1 not supported"); 15 | } 16 | } 17 | 18 | update(data: SourceData, encoding?: "utf8" | "ascii" | "latin1"): void { 19 | this.hash.update(convertToBuffer(data)); 20 | } 21 | 22 | digest(): Promise { 23 | return this.hash.digest(); 24 | } 25 | 26 | reset(): void { 27 | this.hash.reset(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/sha1-browser/test/isEmptyData.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { isEmptyData } from "../src/isEmptyData"; 4 | 5 | describe("isEmptyData", () => { 6 | it("should return true for an empty string", () => { 7 | expect(isEmptyData("")).to.eql(true); 8 | }); 9 | 10 | it("should return false for a non-empty string", () => { 11 | expect(isEmptyData("foo")).to.eql(false); 12 | }); 13 | 14 | it("should return true for an empty ArrayBuffer", () => { 15 | expect(isEmptyData(new ArrayBuffer(0))).to.eql(true); 16 | }); 17 | 18 | it("should return false for a non-empty ArrayBuffer", () => { 19 | expect(isEmptyData(new ArrayBuffer(1))).to.eql(false); 20 | }); 21 | 22 | it("should return true for an empty ArrayBufferView", () => { 23 | expect(isEmptyData(new Uint8Array(0))).to.eql(true); 24 | }); 25 | 26 | it("should return false for a non-empty ArrayBufferView", () => { 27 | expect(isEmptyData(Uint8Array.from([0]))).to.eql(false); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /packages/sha256-browser/test/isEmptyData.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { isEmptyData } from "../src/isEmptyData"; 4 | 5 | describe("isEmptyData", () => { 6 | it("should return true for an empty string", () => { 7 | expect(isEmptyData("")).to.eql(true); 8 | }); 9 | 10 | it("should return false for a non-empty string", () => { 11 | expect(isEmptyData("foo")).to.eql(false); 12 | }); 13 | 14 | it("should return true for an empty ArrayBuffer", () => { 15 | expect(isEmptyData(new ArrayBuffer(0))).to.eql(true); 16 | }); 17 | 18 | it("should return false for a non-empty ArrayBuffer", () => { 19 | expect(isEmptyData(new ArrayBuffer(1))).to.eql(false); 20 | }); 21 | 22 | it("should return true for an empty ArrayBufferView", () => { 23 | expect(isEmptyData(new Uint8Array(0))).to.eql(true); 24 | }); 25 | 26 | it("should return false for a non-empty ArrayBufferView", () => { 27 | expect(isEmptyData(Uint8Array.from([0]))).to.eql(false); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /packages/sha256-browser/src/crossPlatformSha256.ts: -------------------------------------------------------------------------------- 1 | import { Sha256 as WebCryptoSha256 } from "./webCryptoSha256"; 2 | import { Sha256 as JsSha256 } from "@aws-crypto/sha256-js"; 3 | import { Checksum, SourceData } from "@aws-sdk/types"; 4 | import { supportsWebCrypto } from "@aws-crypto/supports-web-crypto"; 5 | import { locateWindow } from "@aws-sdk/util-locate-window"; 6 | import { convertToBuffer } from "@aws-crypto/util"; 7 | 8 | export class Sha256 implements Checksum { 9 | private hash: Checksum; 10 | 11 | constructor(secret?: SourceData) { 12 | if (supportsWebCrypto(locateWindow())) { 13 | this.hash = new WebCryptoSha256(secret); 14 | } else { 15 | this.hash = new JsSha256(secret); 16 | } 17 | } 18 | 19 | update(data: SourceData, encoding?: "utf8" | "ascii" | "latin1"): void { 20 | this.hash.update(convertToBuffer(data)); 21 | } 22 | 23 | digest(): Promise { 24 | return this.hash.digest(); 25 | } 26 | 27 | reset(): void { 28 | this.hash.reset(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/sha256-universal/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Sha256 as BrowserSha256 } from "@aws-crypto/sha256-browser"; 2 | import { Checksum, SourceData } from "@aws-sdk/types"; 3 | import { convertToBuffer } from "@aws-crypto/util"; 4 | import { Hash as NodeHash } from "@smithy/hash-node"; 5 | 6 | export class Sha256 implements Checksum { 7 | private hash: Checksum; 8 | 9 | constructor(secret?: SourceData) { 10 | if (supportsCryptoModule()) { 11 | this.hash = new NodeHash("sha256", secret); 12 | } else { 13 | this.hash = new BrowserSha256(secret); 14 | } 15 | } 16 | 17 | update(data: SourceData, encoding?: "utf8" | "ascii" | "latin1"): void { 18 | this.hash.update(convertToBuffer(data)); 19 | } 20 | 21 | digest(): Promise { 22 | return this.hash.digest(); 23 | } 24 | 25 | reset(): void { 26 | this.hash.reset(); 27 | } 28 | } 29 | 30 | function supportsCryptoModule(): boolean { 31 | try { 32 | return !!require("crypto").createHash; 33 | } catch { 34 | return false; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/random-source-node/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { randomValues } from "../src"; 4 | import * as crypto from "crypto"; 5 | import * as sinon from "sinon"; 6 | 7 | describe("randomValues", () => { 8 | it("should return a promise fulfilled with random bytes", async () => { 9 | const cryptoRandom = sinon.stub(crypto, "randomBytes"); 10 | cryptoRandom.callsArgWith(1, undefined, new Uint8Array(10)); 11 | const rand = await randomValues(10); 12 | expect(rand.byteLength).to.eql(10); 13 | cryptoRandom.restore(); 14 | }); 15 | 16 | it("should reject the promise when the Node crypto source is unavailable", async () => { 17 | const cryptoRandom = sinon.stub(crypto, "randomBytes"); 18 | cryptoRandom.callsArgWith(1, new Error("Not on my watch!")); 19 | 20 | await randomValues(10).then( 21 | () => { 22 | throw new Error("The promise should have been rejected"); 23 | }, 24 | () => { 25 | /* promise rejected, just as expected */ 26 | } 27 | ); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /packages/sha256-universal/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { Sha256 } from "../src/"; 4 | import * as sinon from "sinon"; 5 | import { convertToBuffer } from "@aws-crypto/util"; 6 | 7 | describe("Sha256", () => { 8 | it("should proxy method calls to underlying implementation", () => { 9 | const sha256 = new Sha256(); 10 | const hashMock = { 11 | update: sinon.stub(), 12 | digest: sinon.stub() 13 | }; 14 | (sha256 as any).hash = hashMock; 15 | 16 | sha256.update("foo", "utf8"); 17 | sinon.assert.calledOnce(hashMock.update); 18 | expect(hashMock.update.firstCall.args).to.deep.equal([convertToBuffer("foo")]); 19 | 20 | sha256.digest(); 21 | sinon.assert.calledOnce(hashMock.digest); 22 | }); 23 | 24 | it("hash should be reset when reset is called", () => { 25 | const sha256 = new Sha256(); 26 | const hashMock = { 27 | reset: sinon.fake(), 28 | }; 29 | (sha256 as any).hash = hashMock; 30 | sha256.reset(); 31 | sinon.assert.calledOnce(hashMock.reset); 32 | }) 33 | }); 34 | -------------------------------------------------------------------------------- /packages/random-source-universal/test/browserUsage.test.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import * as sinon from "sinon"; 3 | 4 | import * as browserRandom from "@aws-crypto/random-source-browser"; 5 | import * as nodeRandom from "@aws-crypto/random-source-node"; 6 | import * as crypto from "crypto"; 7 | const cryptoRandom = sinon.stub(crypto, "randomBytes").value(false); 8 | 9 | try { 10 | // @ts-ignore reset the module 11 | delete require.cache[require.resolve("../src/")]; 12 | } catch {} 13 | 14 | import { randomValues } from "../src/"; 15 | 16 | // done with this... 17 | cryptoRandom.restore(); 18 | 19 | describe("implementation selection", () => { 20 | after(() => sinon.restore()); 21 | 22 | it("should use the browser implementation when the crypto module is not defined", async () => { 23 | const node = sinon.spy(nodeRandom, "randomValues"); 24 | const browser = sinon.stub(browserRandom, "randomValues"); 25 | browser.resolves(new Uint8Array(1)); 26 | 27 | await randomValues(1); 28 | 29 | sinon.assert.calledOnce(browser); 30 | sinon.assert.notCalled(node); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /packages/util/test/isEmptyData.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { expect } from "chai"; 5 | import "mocha"; 6 | import { isEmptyData } from "../src/isEmptyData"; 7 | 8 | describe("isEmptyData", () => { 9 | it("should return true for an empty string", () => { 10 | expect(isEmptyData("")).to.eql(true); 11 | }); 12 | 13 | it("should return false for a non-empty string", () => { 14 | expect(isEmptyData("foo")).to.eql(false); 15 | }); 16 | 17 | it("should return true for an empty ArrayBuffer", () => { 18 | expect(isEmptyData(new ArrayBuffer(0))).to.eql(true); 19 | }); 20 | 21 | it("should return false for a non-empty ArrayBuffer", () => { 22 | expect(isEmptyData(new ArrayBuffer(1))).to.eql(false); 23 | }); 24 | 25 | it("should return true for an empty ArrayBufferView", () => { 26 | expect(isEmptyData(new Uint8Array(0))).to.eql(true); 27 | }); 28 | 29 | it("should return false for a non-empty ArrayBufferView", () => { 30 | expect(isEmptyData(Uint8Array.from([0]))).to.eql(false); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /packages/random-source-browser/test/webCryptoRandomValues.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { randomValues } from "../src/webCryptoRandomValues"; 4 | import { locateWindow } from "@aws-sdk/util-locate-window"; 5 | 6 | describe("randomValues", () => { 7 | it("should call the random source built into most browsers", async () => { 8 | (locateWindow() as any).crypto = { 9 | getRandomValues(toFill: Uint8Array) { 10 | const view = new DataView(toFill.buffer); 11 | for (let i = 0; i < toFill.byteLength; i++) { 12 | view.setUint8(i, 0x00); 13 | } 14 | } 15 | }; 16 | 17 | expect(await randomValues(4)).to.deep.equals(Uint8Array.from([0, 0, 0, 0])); 18 | }); 19 | 20 | it("should convert a failed random generation into a promise rejection", async () => { 21 | (locateWindow() as any).crypto = { 22 | getRandomValues(toFill: Uint8Array) { 23 | throw new Error("PANIC PANIC"); 24 | } 25 | }; 26 | 27 | try { 28 | await randomValues(12); 29 | } catch (ex) { 30 | expect(ex).to.be.instanceof(Error); 31 | return; 32 | } 33 | throw new Error("never"); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /packages/crc32/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/crc32", 3 | "version": "5.2.0", 4 | "scripts": { 5 | "prepublishOnly": "npm run build", 6 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 7 | "pretest": "tsc -p tsconfig.test.json", 8 | "test": "mocha --require ts-node/register test/**/*test.ts" 9 | }, 10 | "main": "./build/main/index.js", 11 | "module": "./build/module/index.js", 12 | "exports": { 13 | "import": "./build/module/index.js", 14 | "require": "./build/main/index.js" 15 | }, 16 | "types": "./build/main/index.d.ts", 17 | "repository": { 18 | "type": "git", 19 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 20 | }, 21 | "author": { 22 | "name": "AWS Crypto Tools Team", 23 | "email": "aws-cryptools@amazon.com", 24 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 25 | }, 26 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/crc32", 27 | "license": "Apache-2.0", 28 | "dependencies": { 29 | "@aws-crypto/util": "file:../util", 30 | "@aws-sdk/types": "~3.413.0", 31 | "tslib": "~2.6.2" 32 | }, 33 | "engines": { 34 | "node": ">=16.0.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/util/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/util", 3 | "version": "5.2.0", 4 | "scripts": { 5 | "prepublishOnly": "npm run build", 6 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 7 | "pretest": "tsc -p tsconfig.test.json", 8 | "test": "mocha --require ts-node/register test/**/*test.ts" 9 | }, 10 | "main": "./build/main/index.js", 11 | "module": "./build/module/index.js", 12 | "exports": { 13 | "import": "./build/module/index.js", 14 | "require": "./build/main/index.js" 15 | }, 16 | "types": "./build/main/index.d.ts", 17 | "repository": { 18 | "type": "git", 19 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 20 | }, 21 | "author": { 22 | "name": "AWS Crypto Tools Team", 23 | "email": "aws-cryptools@amazon.com", 24 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 25 | }, 26 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/util", 27 | "license": "Apache-2.0", 28 | "dependencies": { 29 | "@aws-sdk/types": "~3.413.0", 30 | "@smithy/util-utf8": "^2.0.0", 31 | "tslib": "~2.6.2" 32 | }, 33 | "publishConfig": { 34 | "access": "public" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/crc32c/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/crc32c", 3 | "version": "5.2.0", 4 | "scripts": { 5 | "prepublishOnly": "npm run build", 6 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 7 | "pretest": "tsc -p tsconfig.test.json", 8 | "test": "mocha --require ts-node/register test/**/*test.ts" 9 | }, 10 | "main": "./build/main/index.js", 11 | "module": "./build/module/index.js", 12 | "exports": { 13 | "import": "./build/module/index.js", 14 | "require": "./build/main/index.js" 15 | }, 16 | "types": "./build/main/index.d.ts", 17 | "repository": { 18 | "type": "git", 19 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 20 | }, 21 | "author": { 22 | "name": "AWS Crypto Tools Team", 23 | "email": "aws-cryptools@amazon.com", 24 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 25 | }, 26 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/crc32c", 27 | "license": "Apache-2.0", 28 | "dependencies": { 29 | "@aws-crypto/util": "file:../util", 30 | "@aws-sdk/types": "~3.413.0", 31 | "tslib": "~2.6.2" 32 | }, 33 | "publishConfig": { 34 | "access": "public" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/supports-web-crypto/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/supports-web-crypto", 3 | "version": "5.2.0", 4 | "description": "Provides functions for detecting if the host environment supports the WebCrypto API", 5 | "scripts": { 6 | "prepublishOnly": "npm run build", 7 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 8 | "pretest": "tsc -p tsconfig.test.json", 9 | "test": "mocha --require ts-node/register test/**/*test.ts" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 14 | }, 15 | "author": { 16 | "name": "AWS Crypto Tools Team", 17 | "email": "aws-cryptools@amazon.com", 18 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 19 | }, 20 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/supports-web-crypto", 21 | "license": "Apache-2.0", 22 | "main": "./build/main/index.js", 23 | "module": "./build/module/index.js", 24 | "exports": { 25 | "import": "./build/module/index.js", 26 | "require": "./build/main/index.js" 27 | }, 28 | "types": "./build/main/index.d.ts", 29 | "dependencies": { 30 | "tslib": "~2.6.2" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/sha256-js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/sha256-js", 3 | "version": "5.2.0", 4 | "scripts": { 5 | "prepublishOnly": "npm run build", 6 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 7 | "pretest": "tsc -p tsconfig.test.json", 8 | "test": "mocha --require ts-node/register test/**/*test.ts" 9 | }, 10 | "main": "./build/main/index.js", 11 | "module": "./build/module/index.js", 12 | "exports": { 13 | "import": "./build/module/index.js", 14 | "require": "./build/main/index.js" 15 | }, 16 | "types": "./build/main/index.d.ts", 17 | "repository": { 18 | "type": "git", 19 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 20 | }, 21 | "author": { 22 | "name": "AWS Crypto Tools Team", 23 | "email": "aws-cryptools@amazon.com", 24 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 25 | }, 26 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/sha256-js", 27 | "license": "Apache-2.0", 28 | "dependencies": { 29 | "@aws-crypto/util": "file:../util", 30 | "@aws-sdk/types": "~3.413.0", 31 | "tslib": "~2.6.2" 32 | }, 33 | "engines": { 34 | "node": ">=16.0.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/random-source-browser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/random-source-browser", 3 | "version": "5.2.0", 4 | "scripts": { 5 | "prepublishOnly": "npm run build", 6 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 7 | "pretest": "tsc -p tsconfig.test.json", 8 | "test": "mocha --require ts-node/register test/**/*test.ts" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 13 | }, 14 | "author": { 15 | "name": "AWS Crypto Tools Team", 16 | "email": "aws-cryptools@amazon.com", 17 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 18 | }, 19 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/random-source-browser", 20 | "license": "Apache-2.0", 21 | "dependencies": { 22 | "@aws-crypto/supports-web-crypto": "file:../supports-web-crypto", 23 | "@aws-sdk/util-locate-window": "^3.0.0", 24 | "tslib": "~2.6.2" 25 | }, 26 | "main": "./build/main/index.js", 27 | "module": "./build/module/index.js", 28 | "exports": { 29 | "import": "./build/module/index.js", 30 | "require": "./build/main/index.js" 31 | }, 32 | "types": "./build/main/index.d.ts" 33 | } 34 | -------------------------------------------------------------------------------- /packages/random-source-node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/random-source-node", 3 | "version": "5.2.0", 4 | "description": "A Node.JS implementation of the AWS SDK for JavaScript's `randomValues` interface", 5 | "main": "./build/main/index.js", 6 | "module": "./build/module/index.js", 7 | "exports": { 8 | "import": "./build/module/index.js", 9 | "require": "./build/main/index.js" 10 | }, 11 | "types": "./build/main/index.d.ts", 12 | "scripts": { 13 | "prepublishOnly": "npm run build", 14 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 15 | "pretest": "tsc -p tsconfig.test.json", 16 | "test": "mocha --require ts-node/register test/**/*test.ts" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 21 | }, 22 | "author": { 23 | "name": "AWS Crypto Tools Team", 24 | "email": "aws-cryptools@amazon.com", 25 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 26 | }, 27 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/random-source-node", 28 | "license": "Apache-2.0", 29 | "dependencies": { 30 | "@aws-sdk/types": "~3.413.0", 31 | "tslib": "~2.6.2" 32 | }, 33 | "engines": { 34 | "node": ">=16.0.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/supports-web-crypto/test/supportsWebCrypto.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { supportsWebCrypto } from "../src/supportsWebCrypto"; 4 | 5 | const fakeWindow: Window = { 6 | crypto: { 7 | getRandomValues: () => {}, 8 | subtle: { 9 | decrypt(alg: any, key: any) { 10 | return {} as any; 11 | }, 12 | digest(alg: any) { 13 | return {} as any; 14 | }, 15 | encrypt(alg: any, key: any) { 16 | return {} as any; 17 | }, 18 | exportKey(format: any, key: any) { 19 | return {} as any; 20 | }, 21 | generateKey(alg: any) { 22 | return {} as any; 23 | }, 24 | importKey(format: any, keyData: any, alg: any) { 25 | return {} as any; 26 | }, 27 | sign(alg: any, key: any) { 28 | return {} as any; 29 | }, 30 | verify(alg: any, key: any, signature: any) { 31 | return {} as any; 32 | } 33 | } 34 | } 35 | } as any; 36 | 37 | describe("supportsWebCrypto", () => { 38 | it("should return false if an object does not fulfill the WebCrypto interface", () => { 39 | expect(supportsWebCrypto({} as any)).to.eql(false); 40 | }); 41 | 42 | it("should return true if an object fulfills the WebCrypto interface", () => { 43 | expect(supportsWebCrypto(fakeWindow)).to.eql(true); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /packages/sha256-universal/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/sha256-universal", 3 | "version": "5.2.0", 4 | "scripts": { 5 | "prepublishOnly": "npm run build", 6 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 7 | "pretest": "tsc -p tsconfig.test.json", 8 | "test": "mocha --require ts-node/register test/**/*test.ts" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 13 | }, 14 | "author": { 15 | "name": "AWS Crypto Tools Team", 16 | "email": "aws-cryptools@amazon.com", 17 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 18 | }, 19 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/sha256-universal", 20 | "license": "Apache-2.0", 21 | "dependencies": { 22 | "@aws-crypto/sha256-browser": "file:../sha256-browser", 23 | "@aws-sdk/types": "~3.413.0", 24 | "@smithy/hash-node": "^2.2.0", 25 | "tslib": "~2.6.2" 26 | }, 27 | "main": "./build/main/index.js", 28 | "module": "./build/module/index.js", 29 | "exports": { 30 | "import": "./build/module/index.js", 31 | "require": "./build/main/index.js" 32 | }, 33 | "types": "./build/main/index.d.ts", 34 | "browser": { 35 | "@smithy/hash-node": false, 36 | "crypto": false 37 | }, 38 | "engines": { 39 | "node": ">=16.0.0" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/sha256-browser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/sha256-browser", 3 | "version": "5.2.0", 4 | "scripts": { 5 | "prepublishOnly": "npm run build", 6 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 7 | "pretest": "tsc -p tsconfig.test.json", 8 | "test": "mocha --require ts-node/register test/**/*test.ts" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 13 | }, 14 | "author": { 15 | "name": "AWS Crypto Tools Team", 16 | "email": "aws-cryptools@amazon.com", 17 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 18 | }, 19 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/sha256-browser", 20 | "license": "Apache-2.0", 21 | "dependencies": { 22 | "@aws-crypto/sha256-js": "file:../sha256-js", 23 | "@aws-crypto/supports-web-crypto": "file:../supports-web-crypto", 24 | "@aws-crypto/util": "file:../util", 25 | "@aws-sdk/types": "~3.413.0", 26 | "@aws-sdk/util-locate-window": "^3.0.0", 27 | "@smithy/util-utf8": "^2.0.0", 28 | "tslib": "~2.6.2" 29 | }, 30 | "main": "./build/main/index.js", 31 | "module": "./build/module/index.js", 32 | "exports": { 33 | "import": "./build/module/index.js", 34 | "require": "./build/main/index.js" 35 | }, 36 | "types": "./build/main/index.d.ts" 37 | } 38 | -------------------------------------------------------------------------------- /packages/sha1-browser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/sha1-browser", 3 | "version": "5.2.0", 4 | "scripts": { 5 | "prepublishOnly": "npm run build", 6 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 7 | "pretest": "tsc -p tsconfig.test.json", 8 | "test": "mocha --require ts-node/register test/**/*test.ts" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 13 | }, 14 | "author": { 15 | "name": "AWS Crypto Tools Team", 16 | "email": "aws-cryptools@amazon.com", 17 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 18 | }, 19 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/sha1-browser", 20 | "license": "Apache-2.0", 21 | "dependencies": { 22 | "@aws-crypto/supports-web-crypto": "file:../supports-web-crypto", 23 | "@aws-crypto/util": "file:../util", 24 | "@aws-sdk/types": "~3.413.0", 25 | "@aws-sdk/util-locate-window": "^3.0.0", 26 | "@smithy/util-utf8": "^2.0.0", 27 | "tslib": "~2.6.2" 28 | }, 29 | "main": "./build/main/index.js", 30 | "module": "./build/module/index.js", 31 | "exports": { 32 | "import": "./build/module/index.js", 33 | "require": "./build/main/index.js" 34 | }, 35 | "types": "./build/main/index.d.ts", 36 | "publishConfig": { 37 | "access": "public" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /codebuild/release/prod-release.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | batch: 4 | fast-fail: true 5 | build-graph: 6 | # Unit Tests 7 | #NOTE: We need to add browser testing as part of our Unit Tests. Look at the 8 | #js-esdk for insight on how we do this. 9 | - identifier: testNodejsLatest 10 | buildspec: codebuild/nodejs_latest.yml 11 | env: 12 | image: aws/codebuild/standard:6.0 13 | 14 | # Test publishing to local Verdaccio server 15 | - identifier: test_publish 16 | depend-on: 17 | - testNodejsLatest 18 | buildspec: codebuild/test_vectors/test_publish.yml 19 | env: 20 | variables: 21 | CI: "true" 22 | image: aws/codebuild/standard:6.0 23 | 24 | # Version the project and push git commits and tags 25 | - identifier: version 26 | depend-on: 27 | - testNodejsLatest 28 | - test_publish 29 | buildspec: codebuild/release/version.yml 30 | 31 | # Publish the release to npm 32 | - identifier: publish 33 | depend-on: 34 | - version 35 | buildspec: codebuild/release/publish.yml 36 | 37 | # Validate and test that the published versions are available 38 | - identifier: validateNodejs 39 | depend-on: 40 | - publish 41 | buildspec: codebuild/test_vectors/test_publish.yml 42 | env: 43 | variables: 44 | CI: "false" 45 | image: aws/codebuild/standard:6.0 46 | 47 | -------------------------------------------------------------------------------- /packages/random-source-universal/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-crypto/random-source-universal", 3 | "version": "5.2.0", 4 | "scripts": { 5 | "prepublishOnly": "npm run build", 6 | "build": "tsc -p tsconfig.json && tsc -p tsconfig.module.json", 7 | "pretest": "tsc -p tsconfig.test.json", 8 | "test": "mocha --require ts-node/register test/**/*test.ts" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 13 | }, 14 | "author": { 15 | "name": "AWS Crypto Tools Team", 16 | "email": "aws-cryptools@amazon.com", 17 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 18 | }, 19 | "homepage": "https://github.com/aws/aws-sdk-js-crypto-helpers/tree/master/packages/random-source-universal", 20 | "license": "Apache-2.0", 21 | "dependencies": { 22 | "@aws-crypto/random-source-browser": "file:../random-source-browser", 23 | "@aws-crypto/random-source-node": "file:../random-source-node", 24 | "@aws-sdk/types": "~3.413.0", 25 | "tslib": "~2.6.2" 26 | }, 27 | "browser": { 28 | "@aws/crypto-random-source-node": false 29 | }, 30 | "main": "./build/main/index.js", 31 | "module": "./build/module/index.js", 32 | "exports": { 33 | "import": "./build/module/index.js", 34 | "require": "./build/main/index.js" 35 | }, 36 | "types": "./build/main/index.d.ts", 37 | "engines": { 38 | "node": ">=16.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/util/test/convertToBuffer.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { expect } from "chai"; 5 | import "mocha"; 6 | import { convertToBuffer } from "../src/convertToBuffer"; 7 | 8 | describe("convertToBuffer", () => { 9 | it("should return the same Uint8Array", () => { 10 | const data = new Uint8Array(5); 11 | const test = convertToBuffer(data); 12 | 13 | expect(test).to.equal(data); 14 | }); 15 | 16 | it("should return a utf8 encoded Uint8Array", () => { 17 | const data = "asdf"; 18 | const test = convertToBuffer(data); 19 | 20 | expect(test).to.deep.equal(new Uint8Array([97, 115, 100, 102])); 21 | }); 22 | 23 | it("should return an empty ArrayBuffer for an empty string", () => { 24 | const data = ""; 25 | const test = convertToBuffer(data); 26 | 27 | expect(test).to.deep.equal(new Uint8Array(0)); 28 | }); 29 | 30 | it("should return a Uint8Array with the same buffer", () => { 31 | const data = new Uint8Array(5).fill(1); 32 | const test = convertToBuffer(data.buffer); 33 | 34 | expect(test.buffer).to.equal(data.buffer); 35 | }); 36 | 37 | it("", () => { 38 | const data = new Uint8Array(10).fill(2); 39 | const view = new DataView( 40 | new Uint8Array(data.buffer, 3, 5).fill(1).buffer, 41 | 3, 42 | 5 43 | ); 44 | const test = convertToBuffer(view); 45 | 46 | expect(test).to.deep.equal(new Uint8Array([1, 1, 1, 1, 1])); 47 | }); 48 | }); 49 | -------------------------------------------------------------------------------- /packages/sha256-js/src/constants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @internal 3 | */ 4 | export const BLOCK_SIZE: number = 64; 5 | 6 | /** 7 | * @internal 8 | */ 9 | export const DIGEST_LENGTH: number = 32; 10 | 11 | /** 12 | * @internal 13 | */ 14 | export const KEY = new Uint32Array([ 15 | 0x428a2f98, 16 | 0x71374491, 17 | 0xb5c0fbcf, 18 | 0xe9b5dba5, 19 | 0x3956c25b, 20 | 0x59f111f1, 21 | 0x923f82a4, 22 | 0xab1c5ed5, 23 | 0xd807aa98, 24 | 0x12835b01, 25 | 0x243185be, 26 | 0x550c7dc3, 27 | 0x72be5d74, 28 | 0x80deb1fe, 29 | 0x9bdc06a7, 30 | 0xc19bf174, 31 | 0xe49b69c1, 32 | 0xefbe4786, 33 | 0x0fc19dc6, 34 | 0x240ca1cc, 35 | 0x2de92c6f, 36 | 0x4a7484aa, 37 | 0x5cb0a9dc, 38 | 0x76f988da, 39 | 0x983e5152, 40 | 0xa831c66d, 41 | 0xb00327c8, 42 | 0xbf597fc7, 43 | 0xc6e00bf3, 44 | 0xd5a79147, 45 | 0x06ca6351, 46 | 0x14292967, 47 | 0x27b70a85, 48 | 0x2e1b2138, 49 | 0x4d2c6dfc, 50 | 0x53380d13, 51 | 0x650a7354, 52 | 0x766a0abb, 53 | 0x81c2c92e, 54 | 0x92722c85, 55 | 0xa2bfe8a1, 56 | 0xa81a664b, 57 | 0xc24b8b70, 58 | 0xc76c51a3, 59 | 0xd192e819, 60 | 0xd6990624, 61 | 0xf40e3585, 62 | 0x106aa070, 63 | 0x19a4c116, 64 | 0x1e376c08, 65 | 0x2748774c, 66 | 0x34b0bcb5, 67 | 0x391c0cb3, 68 | 0x4ed8aa4a, 69 | 0x5b9cca4f, 70 | 0x682e6ff3, 71 | 0x748f82ee, 72 | 0x78a5636f, 73 | 0x84c87814, 74 | 0x8cc70208, 75 | 0x90befffa, 76 | 0xa4506ceb, 77 | 0xbef9a3f7, 78 | 0xc67178f2 79 | ]); 80 | 81 | /** 82 | * @internal 83 | */ 84 | export const INIT = [ 85 | 0x6a09e667, 86 | 0xbb67ae85, 87 | 0x3c6ef372, 88 | 0xa54ff53a, 89 | 0x510e527f, 90 | 0x9b05688c, 91 | 0x1f83d9ab, 92 | 0x5be0cd19 93 | ]; 94 | 95 | /** 96 | * @internal 97 | */ 98 | export const MAX_HASHABLE_LENGTH = 2 ** 53 - 1; 99 | -------------------------------------------------------------------------------- /SUPPORT_POLICY.rst: -------------------------------------------------------------------------------- 1 | Overview 2 | ======== 3 | This page describes the support policy for the AWS Crypto Helpers. We regularly provide the AWS Crypto Helpers with updates that may contain support for new or updated APIs, new features, enhancements, bug fixes, security patches, or documentation updates. Updates may also address changes with dependencies, language runtimes, and operating systems. 4 | 5 | We recommend users to stay up-to-date with AWS Crypto Helpers releases to keep up with the latest features, security updates, and underlying dependencies. Continued use of an unsupported SDK version is not recommended and is done at the user’s discretion. 6 | 7 | Major Version Lifecycle 8 | ======================== 9 | The AWS Crypto Helpers follows the same major version lifecycle as the AWS SDK. For details on this lifecycle, see `AWS SDKs and Tools Maintenance Policy`_. 10 | 11 | Version Support Matrix 12 | ====================== 13 | This table describes the current support status of each major version of the AWS Crypto Helpers. It also shows the next status each major version will transition to, and the date at which that transition will happen. 14 | 15 | .. list-table:: 16 | :widths: 30 50 50 50 17 | :header-rows: 1 18 | 19 | * - Major version 20 | - Current status 21 | - Next status 22 | - Next status date 23 | * - 1.x 24 | - End of Support 25 | - 26 | - 27 | * - 2.x 28 | - End of Support 29 | - 30 | - 31 | * - 3.x 32 | - Maintenance 33 | - End of Support 34 | - 2023-08-21 35 | * - 4.x 36 | - General Availability 37 | - Maintenance 38 | - 2023-08-20 39 | * - 5.x 40 | - General Availability 41 | - Maintenance 42 | - 2024-01-12 43 | 44 | .. _AWS SDKs and Tools Maintenance Policy: https://docs.aws.amazon.com/sdkref/latest/guide/maint-policy.html#version-life-cycle 45 | 46 | -------------------------------------------------------------------------------- /codebuild/release/publish.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | env: 4 | variables: 5 | NODE_OPTIONS: "--max-old-space-size=4096" 6 | BRANCH: "master" 7 | secrets-manager: 8 | OTP_SECRET_KEY: npm/aws-crypto-tools-ci-bot/2FA:OTP_SECRET_KEY 9 | NPM_TOKEN: npm/aws-crypto-tools-ci-bot/2FA:NPM_TOKEN 10 | 11 | phases: 12 | install: 13 | commands: 14 | - npm ci --unsafe-perm 15 | # Install `otplib` to extract the OTP from the npm 2FA secret 16 | - npm install otplib --no-save 17 | - npm test 18 | runtime-versions: 19 | nodejs: latest 20 | 21 | pre_build: 22 | commands: 23 | - git checkout $BRANCH 24 | 25 | build: 26 | commands: 27 | # Extract the otp using the secrets environment variables from above. 28 | # This will wait for the next token. This is because npm uses 29 | # TOTP and the tokens time out after 30 seconds. If the process just 30 | # extracted the token then the lifetime for this token 31 | # would be very random. This will maximize the amount of time 32 | # available on the OTP to publish. 33 | - >- 34 | OTP=`node -e " 35 | auth=require('otplib').authenticator; 36 | setTimeout(() => 37 | console.log(auth.generate(process.env.OTP_SECRET_KEY)), 38 | auth.timeRemaining() * 1000); 39 | "` 40 | # npm will only expand env vars inside .npmrc 41 | # NOTE the ' this is to keep the env var NPM_TOKEN from expanding! 42 | - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc 43 | # Now we publish to npm. 44 | # This is going to use the OTP generated above and the NPM_TOKEN 45 | # environment variable. This will only publish things that are 46 | # missing from npm. It is therefore safe to run repeatedly. 47 | - npx lerna publish from-package --yes --otp $OTP 48 | # remove after publishing 49 | - rm .npmrc 50 | 51 | -------------------------------------------------------------------------------- /packages/supports-web-crypto/src/supportsWebCrypto.ts: -------------------------------------------------------------------------------- 1 | type SubtleCryptoMethod = 2 | | "decrypt" 3 | | "digest" 4 | | "encrypt" 5 | | "exportKey" 6 | | "generateKey" 7 | | "importKey" 8 | | "sign" 9 | | "verify"; 10 | 11 | const subtleCryptoMethods: Array = [ 12 | "decrypt", 13 | "digest", 14 | "encrypt", 15 | "exportKey", 16 | "generateKey", 17 | "importKey", 18 | "sign", 19 | "verify" 20 | ]; 21 | 22 | export function supportsWebCrypto(window: Window): boolean { 23 | if ( 24 | supportsSecureRandom(window) && 25 | typeof window.crypto.subtle === "object" 26 | ) { 27 | const { subtle } = window.crypto; 28 | 29 | return supportsSubtleCrypto(subtle); 30 | } 31 | 32 | return false; 33 | } 34 | 35 | export function supportsSecureRandom(window: Window): boolean { 36 | if (typeof window === "object" && typeof window.crypto === "object") { 37 | const { getRandomValues } = window.crypto; 38 | 39 | return typeof getRandomValues === "function"; 40 | } 41 | 42 | return false; 43 | } 44 | 45 | export function supportsSubtleCrypto(subtle: SubtleCrypto) { 46 | return ( 47 | subtle && 48 | subtleCryptoMethods.every( 49 | methodName => typeof subtle[methodName] === "function" 50 | ) 51 | ); 52 | } 53 | 54 | export async function supportsZeroByteGCM(subtle: SubtleCrypto) { 55 | if (!supportsSubtleCrypto(subtle)) return false; 56 | try { 57 | const key = await subtle.generateKey( 58 | { name: "AES-GCM", length: 128 }, 59 | false, 60 | ["encrypt"] 61 | ); 62 | const zeroByteAuthTag = await subtle.encrypt( 63 | { 64 | name: "AES-GCM", 65 | iv: new Uint8Array(Array(12)), 66 | additionalData: new Uint8Array(Array(16)), 67 | tagLength: 128 68 | }, 69 | key, 70 | new Uint8Array(0) 71 | ); 72 | return zeroByteAuthTag.byteLength === 16; 73 | } catch { 74 | return false; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /wallaby.conf.js: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | const compilerOptions = Object.assign({ 5 | 'esModuleInterop': true, 6 | 'target': 'esnext', 7 | 'module': 'commonjs' 8 | }) 9 | 10 | module.exports = function (wallaby) { 11 | return { 12 | files: [ 13 | 'packages/**/src/**/*.ts', 14 | 'packages/**/fixtures.ts', 15 | '!packages/**/test/**/*.test.ts', 16 | '!packages/**/node_modules/**', 17 | '!packages/**/build/**', 18 | '!packages/*-+(browser|backend)/**/*.ts' 19 | ], 20 | tests: [ 21 | 'packages/**/test/**/*test.ts', 22 | '!packages/**/node_modules/**', 23 | '!packages/**/build/**', 24 | '!packages/*-+(browser|backend)/**/*.ts' 25 | ], 26 | filesWithNoCoverageCalculated: [ 27 | 'packages/**/src/index.ts' 28 | ], 29 | testFramework: 'mocha', 30 | compilers: { 31 | '**/*.ts': wallaby.compilers.typeScript(compilerOptions) 32 | }, 33 | env: { type: 'node' }, 34 | debug: true, 35 | setup: w => { 36 | const { projectCacheDir } = w 37 | const path = require('path') 38 | const { Module } = require('module') 39 | const fs = require('fs') 40 | if (!Module._originalRequire) { 41 | const modulePrototype = Module.prototype 42 | Module._originalRequire = modulePrototype.require 43 | modulePrototype.require = function (filePath) { 44 | if (!filePath.startsWith('@aws-crypto')) { 45 | return Module._originalRequire.call(this, filePath) 46 | } 47 | const [, _module] = filePath.split('/') 48 | const _filePath = path.join(projectCacheDir, 'modules', _module, 'src', 'index.js') 49 | if (!fs.existsSync(_filePath)) { 50 | return Module._originalRequire.call(this, filePath) 51 | } 52 | return Module._originalRequire.call(this, _filePath) 53 | } 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /packages/crc32/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | import { Crc32, AwsCrc32 } from "../src/index"; 4 | import { fromUtf8 } from "@smithy/util-utf8"; 5 | 6 | type TestVector = [Uint8Array, number]; 7 | 8 | const emptyVector: TestVector = [new Uint8Array(0), 0]; 9 | 10 | const phraseVector: TestVector = [ 11 | fromUtf8("The quick brown fox jumps over the lazy dog"), 12 | 0x414fa339, 13 | ]; 14 | const phraseVectorNew: TestVector = [ 15 | fromUtf8("Sphinx of black quartz, judge my vow."), 16 | 0xa839a3df, 17 | ]; 18 | 19 | const incrementalVectors: Array = [ 20 | [fromUtf8("The "), 746075], 21 | [fromUtf8("quick "), 2750157876], 22 | [fromUtf8("brown "), 3357223548], 23 | [fromUtf8("fox "), 2293265890], 24 | [fromUtf8("jumps "), 330596039], 25 | [fromUtf8("over "), 2281844364], 26 | [fromUtf8("the "), 3828401820], 27 | [fromUtf8("lazy "), 3693501045], 28 | [fromUtf8("dog"), 0x414fa339], 29 | ]; 30 | 31 | const testVectors = new Map([ 32 | emptyVector, 33 | phraseVector, 34 | phraseVectorNew, 35 | ]); 36 | 37 | describe("Crc32", () => { 38 | for (const [buffer, expected] of testVectors) { 39 | it(`should derive a Crc32 of ${expected} for an input of ${buffer.toString()}`, () => { 40 | expect(new Crc32().update(buffer).digest()).to.eql(expected); 41 | }); 42 | } 43 | 44 | it("should allow incremental digest calculation", () => { 45 | const instance = new Crc32(); 46 | expect(instance.digest()).to.eql(0); 47 | 48 | for (const [data, expectedCrc32] of incrementalVectors) { 49 | expect(instance.update(data).digest()).to.eql(expectedCrc32); 50 | } 51 | }); 52 | 53 | it("should create a new crc32 instance when reset is called ", () => { 54 | const awsCrc32 = new AwsCrc32(); 55 | const oldInstance = (awsCrc32 as any).crc32; 56 | awsCrc32.reset(); 57 | const newInstance = (awsCrc32 as any).crc32; 58 | expect(oldInstance).to.not.equal(newInstance); // compare by reference 59 | }) 60 | }); 61 | -------------------------------------------------------------------------------- /packages/sha256-browser/src/webCryptoSha256.ts: -------------------------------------------------------------------------------- 1 | import { Checksum, SourceData } from "@aws-sdk/types"; 2 | import { isEmptyData, convertToBuffer } from "@aws-crypto/util"; 3 | import { 4 | EMPTY_DATA_SHA_256, 5 | SHA_256_HASH, 6 | SHA_256_HMAC_ALGO, 7 | } from "./constants"; 8 | import { locateWindow } from "@aws-sdk/util-locate-window"; 9 | 10 | export class Sha256 implements Checksum { 11 | private readonly secret?: SourceData; 12 | private key: Promise | undefined; 13 | private toHash: Uint8Array = new Uint8Array(0); 14 | 15 | constructor(secret?: SourceData) { 16 | this.secret = secret; 17 | this.reset(); 18 | } 19 | 20 | update(data: SourceData): void { 21 | if (isEmptyData(data)) { 22 | return; 23 | } 24 | 25 | const update = convertToBuffer(data); 26 | const typedArray = new Uint8Array( 27 | this.toHash.byteLength + update.byteLength 28 | ); 29 | typedArray.set(this.toHash, 0); 30 | typedArray.set(update, this.toHash.byteLength); 31 | this.toHash = typedArray; 32 | } 33 | 34 | digest(): Promise { 35 | if (this.key) { 36 | return this.key.then((key) => 37 | locateWindow() 38 | .crypto.subtle.sign(SHA_256_HMAC_ALGO, key, this.toHash) 39 | .then((data) => new Uint8Array(data)) 40 | ); 41 | } 42 | 43 | if (isEmptyData(this.toHash)) { 44 | return Promise.resolve(EMPTY_DATA_SHA_256); 45 | } 46 | 47 | return Promise.resolve() 48 | .then(() => 49 | locateWindow().crypto.subtle.digest(SHA_256_HASH, this.toHash) 50 | ) 51 | .then((data) => Promise.resolve(new Uint8Array(data))); 52 | } 53 | 54 | reset(): void { 55 | this.toHash = new Uint8Array(0); 56 | if (this.secret && this.secret !== void 0) { 57 | this.key = new Promise((resolve, reject) => { 58 | locateWindow() 59 | .crypto.subtle.importKey( 60 | "raw", 61 | convertToBuffer(this.secret as SourceData), 62 | SHA_256_HMAC_ALGO, 63 | false, 64 | ["sign"] 65 | ) 66 | .then(resolve, reject); 67 | }); 68 | this.key.catch(() => {}); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /util/local_verdaccio_publish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | // This is done in a node script for 2 reasons 6 | // 1. Potability: I will need to run this in windows 7 | // 2. Errors. If the main command fails, the script needs to clean up 8 | // but and exit with this error. 9 | // this _can_ be done from bash or shell, 10 | // but now the portability problems loom large. 11 | 12 | const { spawn, execSync } = require('child_process') 13 | const { readFileSync } = require('fs') 14 | const pipeStdIo = { stdio: [process.stdin, process.stdout, process.stderr] } 15 | const { workspaces } = JSON.parse(readFileSync("package.json", 'utf8')) 16 | 17 | // Always clear storage so the latest versions are published 18 | // I am not worried about _what_ version number is published 19 | // Only that it is the latest code 20 | execSync('rm -rf verdaccio/storage/@aws-crypto') 21 | 22 | // Start verdaccio in the background 23 | const verdaccio = spawn('npx', ['verdaccio', '-c', 'verdaccio/config.yaml'], pipeStdIo) 24 | .on('error', e => { 25 | throw e 26 | }) 27 | 28 | // Publish all changed packages the local verdaccio server. 29 | // Anything that has not been changed will match what is in npm 30 | const args = [ 31 | 'lerna', 'publish', 'prepatch', 32 | '--registry', 'http://localhost:4873/', 33 | '--yes', 34 | '--no-changelog', 35 | '--no-git-tag-version', 36 | '--no-push', 37 | '--no-git-reset', 38 | '--preid', 'ci', 39 | '--no-verify-access', 40 | '--force-publish' 41 | ] 42 | spawn('npx', args, pipeStdIo) 43 | .on('close', (code) => { 44 | // Kill the background verdaccio server 45 | verdaccio.kill() 46 | 47 | // The above command will make some modifications, 48 | // Roll them back 49 | // Ideally, we would find a way to not have to do this 50 | workspaces.forEach(workspace => execSync(`git checkout -- ${workspace}/package.json`)) 51 | execSync('git checkout -- lerna.json') 52 | 53 | // If this command had an error, 54 | // we need to forward this. 55 | // Otherwise the entire CI build may think that things succeeded. 56 | if (code !== 0) throw Error(`Exit code: ${code}`) 57 | }) -------------------------------------------------------------------------------- /packages/crc32c/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | import { Crc32c, AwsCrc32c } from "../src"; 4 | import { fromUtf8 } from "@smithy/util-utf8"; 5 | 6 | type TestVector = [Uint8Array, number]; 7 | 8 | const emptyVector: TestVector = [new Uint8Array(0), 0]; 9 | 10 | // @ref https://reveng.sourceforge.io/crc-catalogue/17plus.htm#crc.cat.crc-32c 11 | // @ref https://datatracker.ietf.org/doc/html/rfc7143#appendix-A.4 12 | 13 | const ascendingVector: TestVector = [fromUtf8("123456789"), 0xe3069283]; 14 | const phraseVector: TestVector = [ 15 | fromUtf8("The quick brown fox jumps over the lazy dog"), 16 | 0x22620404, 17 | ]; 18 | const phraseVectorNew: TestVector = [ 19 | fromUtf8("Sphinx of black quartz, judge my vow."), 20 | 0xbcb02b65, 21 | ]; 22 | 23 | const incrementalVectors: Array = [ 24 | [fromUtf8("The "), 0x92fe8395], 25 | [fromUtf8("quick "), 0xfcca5898], 26 | [fromUtf8("brown "), 0x3bf9991e], 27 | [fromUtf8("fox "), 0x46675bb9], 28 | [fromUtf8("jumps "), 0x5d497653], 29 | [fromUtf8("over "), 0x0b5e117a], 30 | [fromUtf8("the "), 0xe17ccce8], 31 | [fromUtf8("lazy "), 0xb62d88c9], 32 | [fromUtf8("dog"), 0x22620404], 33 | ]; 34 | 35 | const testVectors = new Map([ 36 | emptyVector, 37 | ascendingVector, 38 | phraseVector, 39 | phraseVectorNew, 40 | ]); 41 | 42 | describe("Crc32c", () => { 43 | // @ts-ignore 44 | for (const [buffer, expected] of testVectors) { 45 | it(`should derive a CRC-32C of ${expected} for an input of ${buffer.toString()}`, () => { 46 | expect(new Crc32c().update(buffer).digest()).to.eql(expected); 47 | }); 48 | } 49 | 50 | it("should allow incremental digest calculation", () => { 51 | const instance = new Crc32c(); 52 | expect(instance.digest()).to.eql(0); 53 | 54 | for (const [data, expectedCrc32c] of incrementalVectors) { 55 | expect(instance.update(data).digest()).to.eql(expectedCrc32c); 56 | } 57 | }); 58 | 59 | it("should create a new crc32c instance when reset is called ", () => { 60 | const awsCrc32c = new AwsCrc32c(); 61 | const oldInstance = (awsCrc32c as any).crc32c; 62 | awsCrc32c.reset(); 63 | const newInstance = (awsCrc32c as any).crc32c; 64 | expect(oldInstance).to.not.equal(newInstance); // compare by reference 65 | }) 66 | }); 67 | -------------------------------------------------------------------------------- /packages/sha1-browser/src/webCryptoSha1.ts: -------------------------------------------------------------------------------- 1 | import { Checksum, SourceData } from "@aws-sdk/types"; 2 | import { fromUtf8 } from "@smithy/util-utf8"; 3 | import { isEmptyData } from "./isEmptyData"; 4 | import { EMPTY_DATA_SHA_1, SHA_1_HASH, SHA_1_HMAC_ALGO } from "./constants"; 5 | import { locateWindow } from "@aws-sdk/util-locate-window"; 6 | 7 | export class Sha1 implements Checksum { 8 | private readonly key: Promise | undefined; 9 | private toHash: Uint8Array = new Uint8Array(0); 10 | 11 | constructor(secret?: SourceData) { 12 | if (secret !== void 0) { 13 | this.key = new Promise((resolve, reject) => { 14 | locateWindow() 15 | .crypto.subtle.importKey( 16 | "raw", 17 | convertToBuffer(secret), 18 | SHA_1_HMAC_ALGO, 19 | false, 20 | ["sign"] 21 | ) 22 | .then(resolve, reject); 23 | }); 24 | this.key.catch(() => {}); 25 | } 26 | } 27 | 28 | update(data: SourceData): void { 29 | if (isEmptyData(data)) { 30 | return; 31 | } 32 | 33 | const update = convertToBuffer(data); 34 | const typedArray = new Uint8Array( 35 | this.toHash.byteLength + update.byteLength 36 | ); 37 | typedArray.set(this.toHash, 0); 38 | typedArray.set(update, this.toHash.byteLength); 39 | this.toHash = typedArray; 40 | } 41 | 42 | digest(): Promise { 43 | if (this.key) { 44 | return this.key.then((key) => 45 | locateWindow() 46 | .crypto.subtle.sign(SHA_1_HMAC_ALGO, key, this.toHash) 47 | .then((data) => new Uint8Array(data)) 48 | ); 49 | } 50 | 51 | if (isEmptyData(this.toHash)) { 52 | return Promise.resolve(EMPTY_DATA_SHA_1); 53 | } 54 | 55 | return Promise.resolve() 56 | .then(() => locateWindow().crypto.subtle.digest(SHA_1_HASH, this.toHash)) 57 | .then((data) => Promise.resolve(new Uint8Array(data))); 58 | } 59 | 60 | reset(): void { 61 | this.toHash = new Uint8Array(0); 62 | } 63 | } 64 | 65 | function convertToBuffer(data: SourceData): Uint8Array { 66 | if (typeof data === "string") { 67 | return fromUtf8(data); 68 | } 69 | 70 | if (ArrayBuffer.isView(data)) { 71 | return new Uint8Array( 72 | data.buffer, 73 | data.byteOffset, 74 | data.byteLength / Uint8Array.BYTES_PER_ELEMENT 75 | ); 76 | } 77 | 78 | return new Uint8Array(data); 79 | } 80 | -------------------------------------------------------------------------------- /verdaccio/config.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # This is the default config file. It allows all users to do anything, 3 | # so don't use it on production systems. 4 | # 5 | # Look here for more config file examples: 6 | # https://github.com/verdaccio/verdaccio/tree/master/conf 7 | # 8 | 9 | # path to a directory with all packages 10 | storage: ./storage 11 | # path to a directory with plugins to include 12 | plugins: ./plugins 13 | 14 | web: 15 | title: Verdaccio 16 | # comment out to disable gravatar support 17 | # gravatar: false 18 | # by default packages are ordercer ascendant (asc|desc) 19 | # sort_packages: asc 20 | 21 | auth: 22 | htpasswd: 23 | file: ./htpasswd 24 | # Maximum amount of users allowed to register, defaults to "+inf". 25 | # You can set this to -1 to disable registration. 26 | # max_users: 1000 27 | 28 | security: 29 | api: 30 | jwt: 31 | sign: 32 | expiresIn: 60d 33 | notBefore: 1 34 | web: 35 | sign: 36 | expiresIn: 7d 37 | notBefore: 1 38 | 39 | # a list of other known repositories we can talk to 40 | uplinks: 41 | npmjs: 42 | url: https://registry.npmjs.org/ 43 | 44 | packages: 45 | '@aws-crypto/*': 46 | # scoped packages 47 | access: $all 48 | publish: $all 49 | unpublish: $all 50 | proxy: npmjs 51 | '@*/*': 52 | # scoped packages 53 | access: $all 54 | publish: $authenticated 55 | unpublish: $authenticated 56 | proxy: npmjs 57 | 58 | '**': 59 | # allow all users (including non-authenticated users) to read and 60 | # publish all packages 61 | # 62 | # you can specify usernames/groupnames (depending on your auth plugin) 63 | # and three keywords: "$all", "$anonymous", "$authenticated" 64 | access: $all 65 | 66 | # allow all known users to publish/publish packages 67 | # (anyone can register by default, remember?) 68 | publish: $authenticated 69 | unpublish: $authenticated 70 | 71 | # if package is not available locally, proxy requests to 'npmjs' registry 72 | proxy: npmjs 73 | 74 | # You can specify HTTP/1.1 server keep alive timeout in seconds for incomming connections. 75 | # A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout. 76 | # WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enought. 77 | server: 78 | keepAliveTimeout: 60 79 | 80 | middlewares: 81 | audit: 82 | enabled: true 83 | 84 | # log settings 85 | logs: { type: stdout, format: pretty, level: http } 86 | -------------------------------------------------------------------------------- /packages/sha256-js/src/jsSha256.ts: -------------------------------------------------------------------------------- 1 | import { BLOCK_SIZE } from "./constants"; 2 | import { RawSha256 } from "./RawSha256"; 3 | import { Checksum, SourceData } from "@aws-sdk/types"; 4 | import { isEmptyData, convertToBuffer } from "@aws-crypto/util"; 5 | 6 | export class Sha256 implements Checksum { 7 | private readonly secret?: SourceData; 8 | private hash: RawSha256; 9 | private outer?: RawSha256; 10 | private error: any; 11 | 12 | constructor(secret?: SourceData) { 13 | this.secret = secret; 14 | this.hash = new RawSha256(); 15 | this.reset(); 16 | } 17 | 18 | update(toHash: SourceData): void { 19 | if (isEmptyData(toHash) || this.error) { 20 | return; 21 | } 22 | 23 | try { 24 | this.hash.update(convertToBuffer(toHash)); 25 | } catch (e) { 26 | this.error = e; 27 | } 28 | } 29 | 30 | /* This synchronous method keeps compatibility 31 | * with the v2 aws-sdk. 32 | */ 33 | digestSync(): Uint8Array { 34 | if (this.error) { 35 | throw this.error; 36 | } 37 | 38 | if (this.outer) { 39 | if (!this.outer.finished) { 40 | this.outer.update(this.hash.digest()); 41 | } 42 | 43 | return this.outer.digest(); 44 | } 45 | 46 | return this.hash.digest(); 47 | } 48 | 49 | /* The underlying digest method here is synchronous. 50 | * To keep the same interface with the other hash functions 51 | * the default is to expose this as an async method. 52 | * However, it can sometimes be useful to have a sync method. 53 | */ 54 | async digest(): Promise { 55 | return this.digestSync(); 56 | } 57 | 58 | reset(): void { 59 | this.hash = new RawSha256(); 60 | if (this.secret) { 61 | this.outer = new RawSha256(); 62 | const inner = bufferFromSecret(this.secret); 63 | const outer = new Uint8Array(BLOCK_SIZE); 64 | outer.set(inner); 65 | 66 | for (let i = 0; i < BLOCK_SIZE; i++) { 67 | inner[i] ^= 0x36; 68 | outer[i] ^= 0x5c; 69 | } 70 | 71 | this.hash.update(inner); 72 | this.outer.update(outer); 73 | 74 | // overwrite the copied key in memory 75 | for (let i = 0; i < inner.byteLength; i++) { 76 | inner[i] = 0; 77 | } 78 | } 79 | } 80 | } 81 | 82 | function bufferFromSecret(secret: SourceData): Uint8Array { 83 | let input = convertToBuffer(secret); 84 | 85 | if (input.byteLength > BLOCK_SIZE) { 86 | const bufferHash = new RawSha256(); 87 | bufferHash.update(input); 88 | input = bufferHash.digest(); 89 | } 90 | 91 | const buffer = new Uint8Array(BLOCK_SIZE); 92 | buffer.set(input); 93 | return buffer; 94 | } 95 | -------------------------------------------------------------------------------- /packages/random-source-browser/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { testableRandomValues } from "../src/"; 4 | import * as sinon from "sinon"; 5 | 6 | import * as webCryptoRandom from "../src/webCryptoRandomValues"; 7 | declare var global: any; 8 | 9 | describe("implementation selection", () => { 10 | beforeEach(() => { 11 | sinon.stub(webCryptoRandom, "randomValues"); 12 | }); 13 | 14 | afterEach(() => { 15 | (webCryptoRandom.randomValues).restore(); 16 | }); 17 | 18 | it("should use WebCrypto when available", async () => { 19 | const supports = sinon.stub() 20 | supports.returns(true) 21 | 22 | await testableRandomValues(supports)(1); 23 | 24 | sinon.assert.calledOnce(webCryptoRandom.randomValues); 25 | }); 26 | 27 | it("should throw if WebCrypto is not available", async () => { 28 | const doesNotSupport = sinon.stub() 29 | doesNotSupport.returns(false) 30 | 31 | try { 32 | await testableRandomValues(doesNotSupport)(1); 33 | } catch (ex) { 34 | expect(ex).to.be.instanceof(Error); 35 | } 36 | 37 | sinon.assert.notCalled(webCryptoRandom.randomValues); 38 | }); 39 | }); 40 | 41 | describe("global detection", () => { 42 | beforeEach(() => { 43 | sinon.stub(webCryptoRandom, "randomValues"); 44 | }); 45 | 46 | afterEach(() => { 47 | (webCryptoRandom.randomValues).restore(); 48 | }); 49 | 50 | const _window = (global as any).window || {}; 51 | const _self = (global as any).self || {}; 52 | 53 | beforeEach(() => { 54 | (global as any).window = undefined; 55 | (global as any).self = undefined; 56 | }); 57 | 58 | after(() => { 59 | (global as any).window = _window; 60 | (global as any).self = _self; 61 | }); 62 | 63 | it("should throw if neither window nor self is defined", async () => { 64 | const doesNotSupport = sinon.stub() 65 | doesNotSupport.returns(false) 66 | 67 | try { 68 | await testableRandomValues(doesNotSupport)(1); 69 | } catch (ex) { 70 | expect(ex).to.be.instanceof(Error); 71 | sinon.assert.notCalled(webCryptoRandom.randomValues); 72 | return; 73 | } 74 | throw new Error("never"); 75 | }); 76 | 77 | it("should use `self` if window is not defined", async () => { 78 | (global as any).self = _self; 79 | 80 | const supports = sinon.stub() 81 | supports.returns(true) 82 | 83 | try { 84 | await testableRandomValues(supports)(1); 85 | } catch {} 86 | 87 | sinon.assert.calledOnce(supports); 88 | expect( 89 | (supports).firstCall.args[0] 90 | ).to.eql(_self); 91 | }); 92 | }); 93 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-javascript-crypto-helpers", 3 | "private": true, 4 | "version": "0.0.1", 5 | "description": "AWS encryption helpers for javascript", 6 | "main": "index.js", 7 | "scripts": { 8 | "clean": "npm run clear-build-cache && lerna clean", 9 | "clear-build-cache": "rimraf ./packages/*/build/*", 10 | "build": "lerna run build", 11 | "pretest": "lerna run pretest", 12 | "test": "lerna run test", 13 | "verdaccio-publish": "./util/local_verdaccio_publish", 14 | "verdaccio-verify-publish": "lerna exec --concurrency 1 $INIT_CWD/util/verify_release" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git@github.com:aws/aws-sdk-js-crypto-helpers.git" 19 | }, 20 | "author": { 21 | "name": "AWS Crypto Tools Team", 22 | "email": "aws-cryptools@amazon.com", 23 | "url": "https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us" 24 | }, 25 | "license": "Apache-2.0", 26 | "dependencies": { 27 | "@aws-crypto/crc32": "file:packages/crc32", 28 | "@aws-crypto/crc32c": "file:packages/crc32c", 29 | "@aws-crypto/random-source-browser": "file:packages/random-source-browser", 30 | "@aws-crypto/random-source-node": "file:packages/random-source-node", 31 | "@aws-crypto/random-source-universal": "file:packages/random-source-universal", 32 | "@aws-crypto/sha256-browser": "file:packages/sha256-browser", 33 | "@aws-crypto/sha256-js": "file:packages/sha256-js", 34 | "@aws-crypto/sha256-universal": "file:packages/sha256-universal", 35 | "@aws-crypto/supports-web-crypto": "file:packages/supports-web-crypto", 36 | "@aws-crypto/util": "file:packages/util" 37 | }, 38 | "workspaces": [ 39 | "packages/*" 40 | ], 41 | "devDependencies": { 42 | "@aws-sdk/types": "~3.413.0", 43 | "@smithy/util-buffer-from": "^3.0.0", 44 | "@smithy/util-hex-encoding": "^3.0.0", 45 | "@smithy/util-utf8": "^2.0.0", 46 | "@types/chai": "^4.2.12", 47 | "@types/mocha": "^10.0.0", 48 | "@types/node": "^20.11.20", 49 | "@types/sinon": "^10.0.13", 50 | "chai": "^4.2.0", 51 | "dot-prop": "^8.0.2", 52 | "glob": "^10.3.10", 53 | "husky": "^8.0.1", 54 | "lerna": "^8.1.8", 55 | "lint-staged": "^15.2.2", 56 | "mocha": "^10.0.0", 57 | "nyc": "^15.1.0", 58 | "prettier": "^3.2.5", 59 | "rimraf": "^3.0.2", 60 | "sinon": "^17.0.1", 61 | "tmp": "^0.2.1", 62 | "ts-node": "^10.9.1", 63 | "tslib": "~2.6.2", 64 | "typescript": "^5.3.3", 65 | "verdaccio": "^6.0.2" 66 | }, 67 | "husky": { 68 | "hooks": { 69 | "pre-commit": "lint-staged" 70 | } 71 | }, 72 | "lint-staged": { 73 | "*.{ts,json,md}": [ 74 | "prettier --write", 75 | "git add" 76 | ] 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## AWS SDK JS Crypto Helpers 2 | 3 | AWS Cryptographic Helpers for Javascript and Node.js 4 | 5 | [Security issue notifications](./CONTRIBUTING.md#security-issue-notifications) 6 | 7 | ## Scope 8 | 9 | This repository collects cryptographic helper packages. We have designed it to gather packages that implement simple primitives for the browser or Node.js. More information about AWS Crypto Tools can be found [here](https://docs.aws.amazon.com/aws-crypto-tools/index.html?id=docs_gateway#lang/en_us) 10 | 11 | ## Project Status 12 | 13 | This project is still in its early stages. Please send us your feedback. We might make breaking changes in future releases while the SDK is still in developer preview. 14 | 15 | ## Getting started 16 | 17 | Let’s walk through setting up a project that requires a cryptographically secure random value. The following steps use npm as an example. They assume you have node.js and npm already installed. 18 | 19 | 1. Create a new node.js project. 20 | 2. In the project, run: `npm install --save @aws-crypto/random-source-node@preview` 21 | 3. Create a new file called index.js, require the function, and then use it to get a random value. 22 | 23 | ```javascript 24 | const { randomValues } = require("@aws-crypto/random-source-node"); 25 | async function example() { 26 | try { 27 | const rand = await randomValues(32); 28 | console.log(rand.length); 29 | } catch (err) { 30 | console.error(err); 31 | } 32 | } 33 | example(); 34 | ``` 35 | 36 | ## Crypto Helper Package Index 37 | 38 | Each package has readme details. 39 | 40 | - [crc32](packages/crc32) 41 | - [random-source-browser](packages/random-source-browser) 42 | - [random-source-node](packages/random-source-node) 43 | - [random-source-universal](packages/random-source-universal) 44 | - [sha256-browser](packages/sha256-browser) 45 | - [sha256-js](packages/sha256-js) 46 | - [sha256-universal](packages/sha256-universal) 47 | - [supports-web-crypto](packages/supports-web-crypto) 48 | 49 | ## Testing 50 | 51 | To run the tests in every package. 52 | 53 | ``` 54 | npm install 55 | npm test 56 | ``` 57 | 58 | ## Feedback 59 | 60 | We welcome your feedback! If you have comments, questions, or suggestions, open a GitHub issue. 61 | We are actively monitoring issues and will respond to feedback as we prepare for our GA launch. 62 | 63 | ## Contributing 64 | 65 | We welcome your contributions! To fix a problem, or add to an existing package: create a pull request. 66 | You must submit all pull requests under the Apache 2.0 license. They will be reviewed by a team member prior to merging. 67 | We would appreciate, but do not require, unit tests for all significant contributions. See [Contributing](CONTRIBUTING.md) for more information. 68 | 69 | ## License 70 | 71 | This library is licensed under the Apache 2.0 License. 72 | -------------------------------------------------------------------------------- /util/verify_release: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | // A very simple script to verify that a package can be installed and imported. 6 | // Intended primarily as a basic smoke test after publishing. 7 | // TODO-RS: Work out how to run this against verdaccio for pre-release verification too! 8 | 9 | const { execSync, spawn } = require('child_process') 10 | const tmp = require('tmp') 11 | const fs = require('fs'); 12 | const pipeStdIo = { stdio: [process.stdin, process.stdout, process.stderr] } 13 | const localVerdaccioRegistry = 'http://localhost:4873/' 14 | const npmPublicRegistry = 'https://registry.npmjs.org/' 15 | const mode = process.argv[2] 16 | if (!['ci', 'public'].includes(mode)) throw new Error(`Unknown mode ${mode}`) 17 | 18 | const npmRegistry = process.argv[2] === 'ci' ? localVerdaccioRegistry : npmPublicRegistry 19 | const { name } = JSON.parse(fs.readFileSync("package.json", 'utf8')) 20 | 21 | // Create a temporary directory to act as a dummy consuming project. 22 | // It's important not to use the current directory because npm will 23 | // walk the file tree upwards and potentially find unrelated node_modules directories! 24 | const consumingPackageDir = tmp.dirSync(); 25 | 26 | // I am assuming that you used `local_verdaccio_publish` 27 | // This is to facilitate interacting with a local verdaccio server 28 | // So... I need a running server 29 | const verdaccio = spawn('npx', ['verdaccio', '-c', '../../verdaccio/config.yaml'], pipeStdIo) 30 | .on('error', e => { 31 | throw e 32 | }) 33 | // just in case 34 | process.on('exit', () => { 35 | if (!verdaccio.killed) verdaccio.kill() 36 | }) 37 | 38 | // Verify the version information 39 | const version = execSync(`npm info ${name} dist-tags.latest --registry ${npmRegistry}`).toString().trim() 40 | if (localVerdaccioRegistry === npmRegistry && !version.includes('ci')) { 41 | throw new Error('Latest version in Verdaccio is not a ci release.') 42 | } else if (localVerdaccioRegistry !== npmRegistry && version.includes('ci')) { 43 | throw new Error('CI release pushed publicly!') 44 | } 45 | 46 | console.log(`\nVerifying ${name}@${version} release...`) 47 | 48 | //Init dir in order to have package.json in dummy dir 49 | execSync(`npm init --yes`, {cwd: consumingPackageDir.name}) 50 | // Manually install the dependency 51 | execSync(`npm install ${name} --registry ${npmRegistry}`, {cwd: consumingPackageDir.name}) 52 | 53 | // Kill the background verdaccio server 54 | verdaccio.kill() 55 | 56 | // Verify that it can be imported. This also ensures that types are available correctly. 57 | const out = execSync(`node -e "console.log(require('${name}'))"`, {cwd: consumingPackageDir.name}).toString() 58 | 59 | console.log(`SUCCESS: Verified ${name} release: ${out}`) 60 | -------------------------------------------------------------------------------- /packages/sha1-browser/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | ### Features 19 | 20 | - Use @smithy/util-utf8 ([#730](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/730)) ([00fb851](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/00fb851ca3559d5a1f370f9256814de1210826b8)), closes [#699](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/699) 21 | 22 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 23 | 24 | - feat!: drop support for IE 11 (#629) ([6c49fb6](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6c49fb6c1b1f18bbff02dbd77a37a21bdb40c959)), closes [#629](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/629) 25 | 26 | ### BREAKING CHANGES 27 | 28 | - Remove support for IE11 29 | 30 | Co-authored-by: texastony <5892063+texastony@users.noreply.github.com> 31 | 32 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 33 | 34 | **Note:** Version bump only for package @aws-crypto/sha1-browser 35 | 36 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 37 | 38 | - 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) 39 | 40 | ### BREAKING CHANGES 41 | 42 | - All classes that implemented `Hash` now implement `Checksum`. 43 | 44 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 45 | 46 | ### Bug Fixes 47 | 48 | - **#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) 49 | 50 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 51 | 52 | **Note:** Version bump only for package @aws-crypto/sha1-browser 53 | 54 | # [1.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.1.1...v1.2.0) (2021-09-17) 55 | 56 | ### Bug Fixes 57 | 58 | - 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)) 59 | 60 | ### Features 61 | 62 | - 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)) 63 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | ## Reporting Bugs/Feature Requests 10 | 11 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 12 | 13 | When filing an issue, please check [existing open](https://github.com/aws/aws-sdk-js-crypto-helpers/issues), or [recently closed](https://github.com/aws/aws-sdk-js-crypto-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already 14 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 15 | 16 | - A reproducible test case or series of steps 17 | - The version of our code being used 18 | - Any modifications you've made relevant to the bug 19 | - Anything unusual about your environment or deployment 20 | 21 | ## Contributing via Pull Requests 22 | 23 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 24 | 25 | 1. You are working against the latest source on the _master_ branch. 26 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 27 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 28 | 29 | To send us a pull request, please: 30 | 31 | 1. Fork the repository. 32 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 33 | 3. Ensure local tests pass. 34 | 4. Commit to your fork using clear commit messages. 35 | 5. Send us a pull request, answering any default questions in the pull request interface. 36 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 37 | 38 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 39 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 40 | 41 | ## Finding contributions to work on 42 | 43 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws/aws-sdk-js-crypto-helpers/labels/help%20wanted) issues is a great place to start. 44 | 45 | ## Code of Conduct 46 | 47 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 48 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 49 | opensource-codeofconduct@amazon.com with any additional questions or comments. 50 | 51 | ## Security issue notifications 52 | 53 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 54 | 55 | ## Licensing 56 | 57 | See the [LICENSE](https://github.com/aws/aws-sdk-js-crypto-helpers/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 58 | 59 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. 60 | -------------------------------------------------------------------------------- /packages/sha256-js/test/jsSha256.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { Sha256 } from "../src/jsSha256"; 4 | import { RawSha256 } from "../src/RawSha256"; 5 | import { hashTestVectors, hmacTestVectors } from "../src/knownHashes.fixture"; 6 | import * as sinon from "sinon"; 7 | 8 | describe("Sha256", () => { 9 | it("should create an instance of RawSha256 by default", () => { 10 | const sha256 = new Sha256(); 11 | expect((sha256 as any).hash).to.be.instanceof(RawSha256); 12 | }); 13 | 14 | it("should create an outer hash if a secret is present", () => { 15 | const sha256 = new Sha256("foo"); 16 | expect((sha256 as any).hash).to.be.instanceof(RawSha256); 17 | expect((sha256 as any).outer).to.be.instanceof(RawSha256); 18 | }); 19 | 20 | it("should accept ArrayBufferView secrets", () => { 21 | const sha256 = new Sha256(Uint8Array.from([0xde, 0xad])); 22 | }); 23 | 24 | it("should accept ArrayBuffer secrets", () => { 25 | const sha256 = new Sha256(Uint8Array.from([0xde, 0xad]).buffer); 26 | }); 27 | 28 | it("should call update when given data", () => { 29 | const sha256 = new Sha256(); 30 | const spy = sinon.spy((sha256 as any).hash, "update"); 31 | 32 | sha256.update("data"); 33 | sinon.assert.calledOnce(spy); 34 | }); 35 | 36 | it("should not call update when given empty data", () => { 37 | const sha256 = new Sha256(); 38 | const spy = sinon.spy((sha256 as any).hash, "update"); 39 | 40 | sha256.update(new ArrayBuffer(0)); 41 | sinon.assert.notCalled(spy); 42 | }); 43 | 44 | it("should trap update errors", async () => { 45 | const sha256 = new Sha256(); 46 | sinon.stub((sha256 as any).hash, "update").throws(new Error("PANIC")); 47 | 48 | sha256.update("foo"); 49 | 50 | await sha256.digest().then( 51 | () => { 52 | throw new Error("The promise should have been rejected."); 53 | }, 54 | () => { 55 | /* Promise rejected, just as expected */ 56 | } 57 | ); 58 | }); 59 | 60 | it("should trap finalization errors", async () => { 61 | const sha256 = new Sha256(); 62 | sinon.stub((sha256 as any).hash, "digest").throws(new Error("PANIC")); 63 | 64 | await sha256.digest().then( 65 | () => { 66 | throw new Error("The promise should have been rejected."); 67 | }, 68 | () => { 69 | /* Promise rejected, just as expected */ 70 | } 71 | ); 72 | }); 73 | 74 | it("should create a new hash instance when reset is called", () => { 75 | const sha256 = new Sha256(); 76 | const oldInstance = (sha256 as any).hash; 77 | sha256.reset(); 78 | const newInstance = (sha256 as any).hash; 79 | expect(oldInstance).to.not.equal(newInstance); // compare by reference 80 | }) 81 | 82 | it("should create a outer hash instance when reset is called", () => { 83 | const sha256 = new Sha256("foo"); 84 | const oldInstance = (sha256 as any).outer; 85 | sha256.reset(); 86 | const newInstance = (sha256 as any).outer; 87 | expect(oldInstance).to.not.equal(newInstance); // compare by reference 88 | }) 89 | 90 | let idx = 0; 91 | for (const [input, result] of hashTestVectors) { 92 | it("should match known hash calculations: " + idx++, async () => { 93 | const hash = new Sha256(); 94 | hash.update(input); 95 | expect(await hash.digest()).to.deep.equal(result); 96 | }); 97 | } 98 | 99 | idx = 0; 100 | for (const [key, data, result] of hmacTestVectors) { 101 | it("should match known hmac calculations: " + idx++, async () => { 102 | const hash = new Sha256(key); 103 | hash.update(data); 104 | expect(await hash.digest()).to.deep.equal(result); 105 | }); 106 | } 107 | }); 108 | -------------------------------------------------------------------------------- /packages/crc32c/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | ### Features 19 | 20 | - Use @smithy/util-utf8 ([#730](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/730)) ([00fb851](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/00fb851ca3559d5a1f370f9256814de1210826b8)), closes [#699](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/699) 21 | 22 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 23 | 24 | **Note:** Version bump only for package @aws-crypto/crc32c 25 | 26 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 27 | 28 | **Note:** Version bump only for package @aws-crypto/crc32c 29 | 30 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 31 | 32 | - 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) 33 | 34 | ### BREAKING CHANGES 35 | 36 | - All classes that implemented `Hash` now implement `Checksum`. 37 | 38 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 39 | 40 | ### Bug Fixes 41 | 42 | - **#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) 43 | 44 | ## [2.0.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.0...v2.0.1) (2021-12-09) 45 | 46 | **Note:** Version bump only for package @aws-crypto/crc32c 47 | 48 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 49 | 50 | **Note:** Version bump only for package @aws-crypto/crc32c 51 | 52 | ## [1.2.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.1...v1.2.2) (2021-10-12) 53 | 54 | ### Bug Fixes 55 | 56 | - **crc32c:** ie11 does not support Array.from ([#221](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/221)) ([5f49547](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/5f495472ab8988cf203e0f2a70a51f7e1fcd7e60)) 57 | 58 | ## [1.2.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.0...v1.2.1) (2021-09-17) 59 | 60 | **Note:** Version bump only for package @aws-crypto/crc32c 61 | 62 | # [1.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.1.1...v1.2.0) (2021-09-17) 63 | 64 | ### Features 65 | 66 | - Add AwsCrc32C Hash ([4840c83](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/4840c83bdd7c461dded777ebc45a8f99258ba21c)) 67 | 68 | ## [0.2.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/crc32c@0.2.0...@aws-crypto/crc32c@0.2.1) (2021-08-24) 69 | 70 | **Note:** Version bump only for package @aws-crypto/crc32c 71 | 72 | # 0.2.0 (2021-08-11) 73 | 74 | ### Features 75 | 76 | - Create CRC-32C implementation ([#201](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/201)) ([e43c7ec](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e43c7ecd30d6499fa696f5839ecc30502a34b8b6)) 77 | -------------------------------------------------------------------------------- /packages/crc32c/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import {uint32ArrayFrom} from "@aws-crypto/util"; 5 | 6 | export function crc32c(data: Uint8Array): number { 7 | return new Crc32c().update(data).digest(); 8 | } 9 | 10 | export class Crc32c { 11 | private checksum = 0xffffffff; 12 | 13 | update(data: Uint8Array): this { 14 | for (const byte of data) { 15 | this.checksum = 16 | (this.checksum >>> 8) ^ lookupTable[(this.checksum ^ byte) & 0xff]; 17 | } 18 | 19 | return this; 20 | } 21 | 22 | digest(): number { 23 | return (this.checksum ^ 0xffffffff) >>> 0; 24 | } 25 | } 26 | 27 | // prettier-ignore 28 | const a_lookupTable = [ 29 | 0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, 0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB, 30 | 0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B, 0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24, 31 | 0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B, 0xD7C45070, 0x25AFD373, 0x36FF2087, 0xC494A384, 32 | 0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54, 0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B, 33 | 0x20BD8EDE, 0xD2D60DDD, 0xC186FE29, 0x33ED7D2A, 0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35, 34 | 0xAA64D611, 0x580F5512, 0x4B5FA6E6, 0xB93425E5, 0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA, 35 | 0x30E349B1, 0xC288CAB2, 0xD1D83946, 0x23B3BA45, 0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A, 36 | 0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A, 0x7DA08661, 0x8FCB0562, 0x9C9BF696, 0x6EF07595, 37 | 0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48, 0x86E18AA3, 0x748A09A0, 0x67DAFA54, 0x95B17957, 38 | 0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687, 0x0C38D26C, 0xFE53516F, 0xED03A29B, 0x1F682198, 39 | 0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927, 0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38, 40 | 0xDBFC821C, 0x2997011F, 0x3AC7F2EB, 0xC8AC71E8, 0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7, 41 | 0x61C69362, 0x93AD1061, 0x80FDE395, 0x72966096, 0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789, 42 | 0xEB1FCBAD, 0x197448AE, 0x0A24BB5A, 0xF84F3859, 0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46, 43 | 0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9, 0xB602C312, 0x44694011, 0x5739B3E5, 0xA55230E6, 44 | 0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36, 0x3CDB9BDD, 0xCEB018DE, 0xDDE0EB2A, 0x2F8B6829, 45 | 0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C, 0x456CAC67, 0xB7072F64, 0xA457DC90, 0x563C5F93, 46 | 0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043, 0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C, 47 | 0x92A8FC17, 0x60C37F14, 0x73938CE0, 0x81F80FE3, 0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC, 48 | 0x1871A4D8, 0xEA1A27DB, 0xF94AD42F, 0x0B21572C, 0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033, 49 | 0xA24BB5A6, 0x502036A5, 0x4370C551, 0xB11B4652, 0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D, 50 | 0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D, 0xEF087A76, 0x1D63F975, 0x0E330A81, 0xFC588982, 51 | 0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D, 0x758FE5D6, 0x87E466D5, 0x94B49521, 0x66DF1622, 52 | 0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2, 0xFF56BD19, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED, 53 | 0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530, 0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F, 54 | 0x49547E0B, 0xBB3FFD08, 0xA86F0EFC, 0x5A048DFF, 0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0, 55 | 0xD3D3E1AB, 0x21B862A8, 0x32E8915C, 0xC083125F, 0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540, 56 | 0x590AB964, 0xAB613A67, 0xB831C993, 0x4A5A4A90, 0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F, 57 | 0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE, 0x24AA3F05, 0xD6C1BC06, 0xC5914FF2, 0x37FACCF1, 58 | 0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321, 0xAE7367CA, 0x5C18E4C9, 0x4F48173D, 0xBD23943E, 59 | 0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81, 0x34F4F86A, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E, 60 | 0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E, 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351, 61 | ]; 62 | 63 | const lookupTable: Uint32Array = uint32ArrayFrom(a_lookupTable) 64 | export { AwsCrc32c } from "./aws_crc32c"; 65 | -------------------------------------------------------------------------------- /packages/util/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | ### Features 19 | 20 | - Use @smithy/util-utf8 ([#730](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/730)) ([00fb851](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/00fb851ca3559d5a1f370f9256814de1210826b8)), closes [#699](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/699) 21 | 22 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 23 | 24 | **Note:** Version bump only for package @aws-crypto/util 25 | 26 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 27 | 28 | **Note:** Version bump only for package @aws-crypto/util 29 | 30 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 31 | 32 | - 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) 33 | 34 | ### BREAKING CHANGES 35 | 36 | - All classes that implemented `Hash` now implement `Checksum`. 37 | 38 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 39 | 40 | ### Bug Fixes 41 | 42 | - **#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) 43 | - **docs:** update README for packages/util ([#382](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/382)) ([f3e650e](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/f3e650e1b4792ffbea2e8a1a015fd55fb951a3a4)) 44 | 45 | ## [2.0.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.0...v2.0.1) (2021-12-09) 46 | 47 | ### Bug Fixes 48 | 49 | - **uint32ArrayFrom:** increment index & polyfill for Uint32Array ([#270](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/270)) ([a70d603](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/a70d603f3ba7600d3c1213f297d4160a4b3793bd)) 50 | 51 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 52 | 53 | **Note:** Version bump only for package @aws-crypto/util 54 | 55 | ## [1.2.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.1...v1.2.2) (2021-10-12) 56 | 57 | ### Bug Fixes 58 | 59 | - **crc32c:** ie11 does not support Array.from ([#221](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/221)) ([5f49547](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/5f495472ab8988cf203e0f2a70a51f7e1fcd7e60)) 60 | 61 | ## [1.2.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.0...v1.2.1) (2021-09-17) 62 | 63 | ### Bug Fixes 64 | 65 | - better pollyfill check for Buffer ([#217](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/217)) ([bc97da2](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/bc97da29aaf473943e4407c9a29cc30f74f15723)) 66 | 67 | # [1.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.1.1...v1.2.0) (2021-09-17) 68 | 69 | ### Features 70 | 71 | - add @aws-crypto/util ([8f489cb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/8f489cbe4c0e134f826bac66f1bf5172597048b9)) 72 | -------------------------------------------------------------------------------- /packages/crc32/src/crc32.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import {uint32ArrayFrom} from "@aws-crypto/util"; 5 | 6 | export function crc32(data: Uint8Array): number { 7 | return new Crc32().update(data).digest(); 8 | } 9 | 10 | export class Crc32 { 11 | private checksum = 0xffffffff; 12 | 13 | update(data: Uint8Array): this { 14 | for (const byte of data) { 15 | this.checksum = 16 | (this.checksum >>> 8) ^ lookupTable[(this.checksum ^ byte) & 0xff]; 17 | } 18 | 19 | return this; 20 | } 21 | 22 | digest(): number { 23 | return (this.checksum ^ 0xffffffff) >>> 0; 24 | } 25 | } 26 | 27 | // prettier-ignore 28 | const a_lookUpTable = [ 29 | 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 30 | 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 31 | 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 32 | 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 33 | 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 34 | 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 35 | 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 36 | 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 37 | 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 38 | 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 39 | 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 40 | 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 41 | 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 42 | 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 43 | 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 44 | 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 45 | 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 46 | 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 47 | 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 48 | 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 49 | 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 50 | 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 51 | 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 52 | 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 53 | 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 54 | 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 55 | 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 56 | 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 57 | 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 58 | 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 59 | 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 60 | 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 61 | 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 62 | 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 63 | 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 64 | 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 65 | 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 66 | 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 67 | 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 68 | 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 69 | 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 70 | 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 71 | 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 72 | 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 73 | 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 74 | 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 75 | 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 76 | 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 77 | 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 78 | 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 79 | 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 80 | 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 81 | 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 82 | 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 83 | 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 84 | 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 85 | 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 86 | 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 87 | 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 88 | 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 89 | 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 90 | 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 91 | 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 92 | 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D, 93 | ]; 94 | const lookupTable: Uint32Array = uint32ArrayFrom(a_lookUpTable) -------------------------------------------------------------------------------- /packages/supports-web-crypto/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 19 | 20 | **Note:** Version bump only for package @aws-crypto/supports-web-crypto 21 | 22 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 23 | 24 | **Note:** Version bump only for package @aws-crypto/supports-web-crypto 25 | 26 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 27 | 28 | **Note:** Version bump only for package @aws-crypto/supports-web-crypto 29 | 30 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 31 | 32 | **Note:** Version bump only for package @aws-crypto/supports-web-crypto 33 | 34 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 35 | 36 | **Note:** Version bump only for package @aws-crypto/supports-web-crypto 37 | 38 | # [1.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/supports-web-crypto@1.0.0-alpha.0...@aws-crypto/supports-web-crypto@1.0.0) (2020-10-22) 39 | 40 | ### Bug Fixes 41 | 42 | - replace `sourceRoot` -> `rootDir` in tsconfig ([#169](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/169)) ([d437167](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/d437167b51d1c56a4fcc2bb8a446b74a7e3b7e06)) 43 | 44 | # [1.0.0-alpha.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/supports-web-crypto@0.1.0-preview.4...@aws-crypto/supports-web-crypto@1.0.0-alpha.0) (2020-02-07) 45 | 46 | **Note:** Version bump only for package @aws-crypto/supports-web-crypto 47 | 48 | # [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/supports-web-crypto@0.1.0-preview.2...@aws-crypto/supports-web-crypto@0.1.0-preview.4) (2020-01-16) 49 | 50 | ### Bug Fixes 51 | 52 | - 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) 53 | - 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) 54 | 55 | # [0.1.0-preview.3](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/supports-web-crypto@0.1.0-preview.2...@aws-crypto/supports-web-crypto@0.1.0-preview.3) (2019-11-15) 56 | 57 | ### Bug Fixes 58 | 59 | - 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) 60 | - 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) 61 | 62 | # [0.1.0-preview.2](https://github.com/aws/aws-javascript-crypto-helpers/compare/@aws-crypto/supports-web-crypto@0.1.0-preview.1...@aws-crypto/supports-web-crypto@0.1.0-preview.2) (2019-10-30) 63 | 64 | ### Bug Fixes 65 | 66 | - 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)) 67 | -------------------------------------------------------------------------------- /packages/sha256-js/src/RawSha256.ts: -------------------------------------------------------------------------------- 1 | import { 2 | BLOCK_SIZE, 3 | DIGEST_LENGTH, 4 | INIT, 5 | KEY, 6 | MAX_HASHABLE_LENGTH 7 | } from "./constants"; 8 | 9 | /** 10 | * @internal 11 | */ 12 | export class RawSha256 { 13 | private state: Int32Array = Int32Array.from(INIT); 14 | private temp: Int32Array = new Int32Array(64); 15 | private buffer: Uint8Array = new Uint8Array(64); 16 | private bufferLength: number = 0; 17 | private bytesHashed: number = 0; 18 | 19 | /** 20 | * @internal 21 | */ 22 | finished: boolean = false; 23 | 24 | update(data: Uint8Array): void { 25 | if (this.finished) { 26 | throw new Error("Attempted to update an already finished hash."); 27 | } 28 | 29 | let position = 0; 30 | let { byteLength } = data; 31 | this.bytesHashed += byteLength; 32 | 33 | if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) { 34 | throw new Error("Cannot hash more than 2^53 - 1 bits"); 35 | } 36 | 37 | while (byteLength > 0) { 38 | this.buffer[this.bufferLength++] = data[position++]; 39 | byteLength--; 40 | 41 | if (this.bufferLength === BLOCK_SIZE) { 42 | this.hashBuffer(); 43 | this.bufferLength = 0; 44 | } 45 | } 46 | } 47 | 48 | digest(): Uint8Array { 49 | if (!this.finished) { 50 | const bitsHashed = this.bytesHashed * 8; 51 | const bufferView = new DataView( 52 | this.buffer.buffer, 53 | this.buffer.byteOffset, 54 | this.buffer.byteLength 55 | ); 56 | 57 | const undecoratedLength = this.bufferLength; 58 | bufferView.setUint8(this.bufferLength++, 0x80); 59 | 60 | // Ensure the final block has enough room for the hashed length 61 | if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) { 62 | for (let i = this.bufferLength; i < BLOCK_SIZE; i++) { 63 | bufferView.setUint8(i, 0); 64 | } 65 | this.hashBuffer(); 66 | this.bufferLength = 0; 67 | } 68 | 69 | for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) { 70 | bufferView.setUint8(i, 0); 71 | } 72 | bufferView.setUint32( 73 | BLOCK_SIZE - 8, 74 | Math.floor(bitsHashed / 0x100000000), 75 | true 76 | ); 77 | bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed); 78 | 79 | this.hashBuffer(); 80 | 81 | this.finished = true; 82 | } 83 | 84 | // The value in state is little-endian rather than big-endian, so flip 85 | // each word into a new Uint8Array 86 | const out = new Uint8Array(DIGEST_LENGTH); 87 | for (let i = 0; i < 8; i++) { 88 | out[i * 4] = (this.state[i] >>> 24) & 0xff; 89 | out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff; 90 | out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff; 91 | out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff; 92 | } 93 | 94 | return out; 95 | } 96 | 97 | private hashBuffer(): void { 98 | const { buffer, state } = this; 99 | 100 | let state0 = state[0], 101 | state1 = state[1], 102 | state2 = state[2], 103 | state3 = state[3], 104 | state4 = state[4], 105 | state5 = state[5], 106 | state6 = state[6], 107 | state7 = state[7]; 108 | 109 | for (let i = 0; i < BLOCK_SIZE; i++) { 110 | if (i < 16) { 111 | this.temp[i] = 112 | ((buffer[i * 4] & 0xff) << 24) | 113 | ((buffer[i * 4 + 1] & 0xff) << 16) | 114 | ((buffer[i * 4 + 2] & 0xff) << 8) | 115 | (buffer[i * 4 + 3] & 0xff); 116 | } else { 117 | let u = this.temp[i - 2]; 118 | const t1 = 119 | ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10); 120 | 121 | u = this.temp[i - 15]; 122 | const t2 = 123 | ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3); 124 | 125 | this.temp[i] = 126 | ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0); 127 | } 128 | 129 | const t1 = 130 | ((((((state4 >>> 6) | (state4 << 26)) ^ 131 | ((state4 >>> 11) | (state4 << 21)) ^ 132 | ((state4 >>> 25) | (state4 << 7))) + 133 | ((state4 & state5) ^ (~state4 & state6))) | 134 | 0) + 135 | ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) | 136 | 0; 137 | 138 | const t2 = 139 | ((((state0 >>> 2) | (state0 << 30)) ^ 140 | ((state0 >>> 13) | (state0 << 19)) ^ 141 | ((state0 >>> 22) | (state0 << 10))) + 142 | ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) | 143 | 0; 144 | 145 | state7 = state6; 146 | state6 = state5; 147 | state5 = state4; 148 | state4 = (state3 + t1) | 0; 149 | state3 = state2; 150 | state2 = state1; 151 | state1 = state0; 152 | state0 = (t1 + t2) | 0; 153 | } 154 | 155 | state[0] += state0; 156 | state[1] += state1; 157 | state[2] += state2; 158 | state[3] += state3; 159 | state[4] += state4; 160 | state[5] += state5; 161 | state[6] += state6; 162 | state[7] += state7; 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /packages/random-source-browser/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 19 | 20 | - feat!: drop support for IE 11 (#629) ([6c49fb6](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6c49fb6c1b1f18bbff02dbd77a37a21bdb40c959)), closes [#629](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/629) 21 | 22 | ### BREAKING CHANGES 23 | 24 | - Remove support for IE11 25 | 26 | Co-authored-by: texastony <5892063+texastony@users.noreply.github.com> 27 | 28 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 29 | 30 | **Note:** Version bump only for package @aws-crypto/random-source-browser 31 | 32 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 33 | 34 | **Note:** Version bump only for package @aws-crypto/random-source-browser 35 | 36 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 37 | 38 | **Note:** Version bump only for package @aws-crypto/random-source-browser 39 | 40 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 41 | 42 | **Note:** Version bump only for package @aws-crypto/random-source-browser 43 | 44 | # [1.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-browser@1.0.0...@aws-crypto/random-source-browser@1.1.0) (2021-01-13) 45 | 46 | **Note:** Version bump only for package @aws-crypto/random-source-browser 47 | 48 | # [1.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-browser@1.0.0-alpha.0...@aws-crypto/random-source-browser@1.0.0) (2020-10-22) 49 | 50 | ### Bug Fixes 51 | 52 | - replace `sourceRoot` -> `rootDir` in tsconfig ([#169](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/169)) ([d437167](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/d437167b51d1c56a4fcc2bb8a446b74a7e3b7e06)) 53 | 54 | # [1.0.0-alpha.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-browser@0.1.0-preview.4...@aws-crypto/random-source-browser@1.0.0-alpha.0) (2020-02-07) 55 | 56 | **Note:** Version bump only for package @aws-crypto/random-source-browser 57 | 58 | # [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-browser@0.1.0-preview.2...@aws-crypto/random-source-browser@0.1.0-preview.4) (2020-01-16) 59 | 60 | ### Bug Fixes 61 | 62 | - 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) 63 | - 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) 64 | 65 | # [0.1.0-preview.3](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-browser@0.1.0-preview.2...@aws-crypto/random-source-browser@0.1.0-preview.3) (2019-11-15) 66 | 67 | ### Bug Fixes 68 | 69 | - 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) 70 | - 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) 71 | 72 | # [0.1.0-preview.2](https://github.com/aws/aws-javascript-crypto-helpers/compare/@aws-crypto/random-source-browser@0.1.0-preview.1...@aws-crypto/random-source-browser@0.1.0-preview.2) (2019-10-30) 73 | 74 | ### Bug Fixes 75 | 76 | - 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)) 77 | -------------------------------------------------------------------------------- /packages/random-source-node/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 19 | 20 | **Note:** Version bump only for package @aws-crypto/random-source-node 21 | 22 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 23 | 24 | **Note:** Version bump only for package @aws-crypto/random-source-node 25 | 26 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 27 | 28 | - 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) 29 | 30 | ### BREAKING CHANGES 31 | 32 | - All classes that implemented `Hash` now implement `Checksum`. 33 | 34 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 35 | 36 | ### Bug Fixes 37 | 38 | - **#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) 39 | 40 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 41 | 42 | **Note:** Version bump only for package @aws-crypto/random-source-node 43 | 44 | # [1.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-node@1.0.0...@aws-crypto/random-source-node@1.1.0) (2021-01-13) 45 | 46 | ### Bug Fixes 47 | 48 | - remove package lock ([6002a5a](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6002a5ab9218dc8798c19dc205d3eebd3bec5b43)) 49 | - **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)) 50 | 51 | # [1.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-node@1.0.0-alpha.0...@aws-crypto/random-source-node@1.0.0) (2020-10-22) 52 | 53 | ### Bug Fixes 54 | 55 | - replace `sourceRoot` -> `rootDir` in tsconfig ([#169](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/169)) ([d437167](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/d437167b51d1c56a4fcc2bb8a446b74a7e3b7e06)) 56 | 57 | # [1.0.0-alpha.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-node@0.1.0-preview.4...@aws-crypto/random-source-node@1.0.0-alpha.0) (2020-02-07) 58 | 59 | ### Bug Fixes 60 | 61 | - update function definition ([42a6861](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/42a6861bf2ab251fe211f2eb89aebd1e95e648c3)) 62 | 63 | # [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-node@0.1.0-preview.2...@aws-crypto/random-source-node@0.1.0-preview.4) (2020-01-16) 64 | 65 | ### Bug Fixes 66 | 67 | - 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) 68 | - 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) 69 | 70 | # [0.1.0-preview.3](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-node@0.1.0-preview.2...@aws-crypto/random-source-node@0.1.0-preview.3) (2019-11-15) 71 | 72 | ### Bug Fixes 73 | 74 | - 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) 75 | - 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) 76 | 77 | # [0.1.0-preview.2](https://github.com/aws/aws-javascript-crypto-helpers/compare/@aws-crypto/random-source-node@0.1.0-preview.1...@aws-crypto/random-source-node@0.1.0-preview.2) (2019-10-30) 78 | 79 | ### Bug Fixes 80 | 81 | - 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)) 82 | -------------------------------------------------------------------------------- /packages/random-source-universal/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 19 | 20 | **Note:** Version bump only for package @aws-crypto/random-source-universal 21 | 22 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 23 | 24 | **Note:** Version bump only for package @aws-crypto/random-source-universal 25 | 26 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 27 | 28 | - 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) 29 | 30 | ### BREAKING CHANGES 31 | 32 | - All classes that implemented `Hash` now implement `Checksum`. 33 | 34 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 35 | 36 | ### Bug Fixes 37 | 38 | - **#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) 39 | 40 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 41 | 42 | **Note:** Version bump only for package @aws-crypto/random-source-universal 43 | 44 | # [1.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-universal@1.0.0...@aws-crypto/random-source-universal@1.1.0) (2021-01-13) 45 | 46 | ### Bug Fixes 47 | 48 | - remove package lock ([6002a5a](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6002a5ab9218dc8798c19dc205d3eebd3bec5b43)) 49 | - **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)) 50 | - **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)) 51 | 52 | # [1.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-universal@1.0.0-alpha.0...@aws-crypto/random-source-universal@1.0.0) (2020-10-22) 53 | 54 | **Note:** Version bump only for package @aws-crypto/random-source-universal 55 | 56 | # [1.0.0-alpha.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-universal@0.1.0-preview.4...@aws-crypto/random-source-universal@1.0.0-alpha.0) (2020-02-07) 57 | 58 | **Note:** Version bump only for package @aws-crypto/random-source-universal 59 | 60 | # [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-universal@0.1.0-preview.2...@aws-crypto/random-source-universal@0.1.0-preview.4) (2020-01-16) 61 | 62 | ### Bug Fixes 63 | 64 | - 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) 65 | - 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) 66 | 67 | # [0.1.0-preview.3](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/random-source-universal@0.1.0-preview.2...@aws-crypto/random-source-universal@0.1.0-preview.3) (2019-11-15) 68 | 69 | ### Bug Fixes 70 | 71 | - 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) 72 | - 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) 73 | 74 | # [0.1.0-preview.2](https://github.com/aws/aws-javascript-crypto-helpers/compare/@aws-crypto/random-source-universal@0.1.0-preview.1...@aws-crypto/random-source-universal@0.1.0-preview.2) (2019-10-30) 75 | 76 | ### Bug Fixes 77 | 78 | - 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)) 79 | -------------------------------------------------------------------------------- /packages/crc32/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | ### Features 19 | 20 | - Use @smithy/util-utf8 ([#730](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/730)) ([00fb851](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/00fb851ca3559d5a1f370f9256814de1210826b8)), closes [#699](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/699) 21 | 22 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 23 | 24 | **Note:** Version bump only for package @aws-crypto/crc32 25 | 26 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 27 | 28 | **Note:** Version bump only for package @aws-crypto/crc32 29 | 30 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 31 | 32 | - 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) 33 | 34 | ### BREAKING CHANGES 35 | 36 | - All classes that implemented `Hash` now implement `Checksum`. 37 | 38 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 39 | 40 | ### Bug Fixes 41 | 42 | - **#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) 43 | 44 | ## [2.0.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.0...v2.0.1) (2021-12-09) 45 | 46 | **Note:** Version bump only for package @aws-crypto/crc32 47 | 48 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 49 | 50 | **Note:** Version bump only for package @aws-crypto/crc32 51 | 52 | ## [1.2.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.1...v1.2.2) (2021-10-12) 53 | 54 | ### Bug Fixes 55 | 56 | - **crc32c:** ie11 does not support Array.from ([#221](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/221)) ([5f49547](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/5f495472ab8988cf203e0f2a70a51f7e1fcd7e60)) 57 | 58 | ## [1.2.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.0...v1.2.1) (2021-09-17) 59 | 60 | **Note:** Version bump only for package @aws-crypto/crc32 61 | 62 | # [1.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.1.1...v1.2.0) (2021-09-17) 63 | 64 | ### Features 65 | 66 | - Add AwsCrc32 Hash ([f5d7e81](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/f5d7e815fcbe0f8da1edb855fea3bd33eb1edc15)) 67 | 68 | # [1.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/crc32@1.0.0...@aws-crypto/crc32@1.1.0) (2021-08-11) 69 | 70 | ### Features 71 | 72 | - Create CRC-32C implementation ([#201](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/201)) ([e43c7ec](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e43c7ecd30d6499fa696f5839ecc30502a34b8b6)) 73 | 74 | # [1.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/crc32@1.0.0-alpha.0...@aws-crypto/crc32@1.0.0) (2020-10-22) 75 | 76 | **Note:** Version bump only for package @aws-crypto/crc32 77 | 78 | # [1.0.0-alpha.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/crc32@0.1.0-preview.4...@aws-crypto/crc32@1.0.0-alpha.0) (2020-02-07) 79 | 80 | **Note:** Version bump only for package @aws-crypto/crc32 81 | 82 | # [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/crc32@0.1.0-preview.2...@aws-crypto/crc32@0.1.0-preview.4) (2020-01-16) 83 | 84 | ### Bug Fixes 85 | 86 | - 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) 87 | - 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) 88 | 89 | # [0.1.0-preview.3](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/crc32@0.1.0-preview.2...@aws-crypto/crc32@0.1.0-preview.3) (2019-11-15) 90 | 91 | ### Bug Fixes 92 | 93 | - 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) 94 | - 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) 95 | 96 | # [0.1.0-preview.2](https://github.com/aws/aws-javascript-crypto-helpers/compare/@aws-crypto/crc32@0.1.0-preview.1...@aws-crypto/crc32@0.1.0-preview.2) (2019-10-30) 97 | 98 | ### Bug Fixes 99 | 100 | - 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)) 101 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | ### Features 19 | 20 | - Use @smithy/util-utf8 ([#730](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/730)) ([00fb851](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/00fb851ca3559d5a1f370f9256814de1210826b8)), closes [#699](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/699) 21 | 22 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 23 | 24 | - feat!: drop support for IE 11 (#629) ([6c49fb6](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6c49fb6c1b1f18bbff02dbd77a37a21bdb40c959)), closes [#629](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/629) 25 | - chore!: Drop Node 14 Support (#678) ([4bae6e9](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/4bae6e99dd6c622c3359bba95a2a2e89956f4cf1)), closes [#678](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/678) 26 | 27 | ### BREAKING CHANGES 28 | 29 | - Remove support for IE11 30 | 31 | Co-authored-by: texastony <5892063+texastony@users.noreply.github.com> 32 | 33 | - Node 14 is no longer supported nor tested. 34 | 35 | ## [4.0.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.0...v4.0.1) (2023-05-22) 36 | 37 | ### Bug Fixes 38 | 39 | - correct package naming in "browser" fields ([#625](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/625)) ([24d8c2b](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/24d8c2b4b740fe2c8faa136384fe3ae8fb1ff60b)) 40 | 41 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 42 | 43 | - feat!: deprecate node12. ([d85ca33](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/d85ca33d1b98e2acdeb5dd8981a369630f69addf)) 44 | 45 | ### BREAKING CHANGES 46 | 47 | - Remove node12 from CI (#543) 48 | 49 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 50 | 51 | ### Bug Fixes 52 | 53 | - **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)) 54 | 55 | - 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) 56 | 57 | ### BREAKING CHANGES 58 | 59 | - All classes that implemented `Hash` now implement `Checksum`. 60 | 61 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 62 | 63 | ### Bug Fixes 64 | 65 | - **#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) 66 | - **docs:** update README for packages/util ([#382](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/382)) ([f3e650e](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/f3e650e1b4792ffbea2e8a1a015fd55fb951a3a4)) 67 | 68 | ## [2.0.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.0...v2.0.1) (2021-12-09) 69 | 70 | ### Bug Fixes 71 | 72 | - **uint32ArrayFrom:** increment index & polyfill for Uint32Array ([#270](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/270)) ([a70d603](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/a70d603f3ba7600d3c1213f297d4160a4b3793bd)) 73 | 74 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 75 | 76 | - feat!: update support policy for node8 and node10 notice (#249) ([723e6d2](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/723e6d2c386a0bc395b32accd85c3544f03c1d18)), closes [#249](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/249) 77 | 78 | ### BREAKING CHANGES 79 | 80 | - Deprecate Node8 and Node10 81 | 82 | ## [1.2.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.1...v1.2.2) (2021-10-12) 83 | 84 | ### Bug Fixes 85 | 86 | - **crc32c:** ie11 does not support Array.from ([#221](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/221)) ([5f49547](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/5f495472ab8988cf203e0f2a70a51f7e1fcd7e60)) 87 | 88 | ## [1.2.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.0...v1.2.1) (2021-09-17) 89 | 90 | ### Bug Fixes 91 | 92 | - better pollyfill check for Buffer ([#217](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/217)) ([bc97da2](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/bc97da29aaf473943e4407c9a29cc30f74f15723)) 93 | 94 | # [1.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.1.1...v1.2.0) (2021-09-17) 95 | 96 | ### Bug Fixes 97 | 98 | - 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)) 99 | 100 | - feat!: Remove support for old version of Node.js (#210) ([eb9100d](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/eb9100d296d2fbc27a922cbfcde80535db3e8940)), closes [#210](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/210) 101 | 102 | ### Features 103 | 104 | - add @aws-crypto/util ([8f489cb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/8f489cbe4c0e134f826bac66f1bf5172597048b9)) 105 | - Add AwsCrc32 Hash ([f5d7e81](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/f5d7e815fcbe0f8da1edb855fea3bd33eb1edc15)) 106 | - Add AwsCrc32C Hash ([4840c83](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/4840c83bdd7c461dded777ebc45a8f99258ba21c)) 107 | - 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)) 108 | 109 | ### BREAKING CHANGES 110 | 111 | - Removing Node.Js 8 and 10 from CI 112 | -------------------------------------------------------------------------------- /packages/sha256-browser/test/webCryptoSha256.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { Sha256 } from "../src/webCryptoSha256"; 4 | import { 5 | EMPTY_DATA_SHA_256, 6 | SHA_256_HASH, 7 | SHA_256_HMAC_ALGO, 8 | } from "../src/constants"; 9 | import { flushPromises } from "./testUtils.fixture"; 10 | import * as sinon from "sinon"; 11 | 12 | import { locateWindow } from "@aws-sdk/util-locate-window"; 13 | 14 | describe("Sha256", () => { 15 | beforeEach(() => { 16 | (locateWindow() as any).crypto = { 17 | subtle: { 18 | digest: sinon.stub().resolves(new ArrayBuffer(32)), 19 | importKey: sinon.stub(), 20 | sign: sinon.stub().resolves(new ArrayBuffer(32)), 21 | }, 22 | }; 23 | 24 | }); 25 | 26 | afterEach(() => sinon.restore()); 27 | 28 | it("should create a hash object by default", async () => { 29 | const sha256 = new Sha256(); 30 | sha256.update(new ArrayBuffer(1)); 31 | await sha256.digest(); 32 | 33 | const { digest } = locateWindow().crypto.subtle; 34 | sinon.assert.calledOnce(digest as sinon.SinonStub); 35 | const [method, data] = (digest as sinon.SinonStub).firstCall.args; 36 | expect(method).to.deep.equal(SHA_256_HASH); 37 | expect(data).to.deep.equal(new Uint8Array(1)); 38 | }); 39 | 40 | it("should immediately import a secret as a SubtleCrypto key when supplied", async () => { 41 | const secret = Uint8Array.from([0xde, 0xad, 0xbe, 0xef]); 42 | const { importKey } = locateWindow().crypto.subtle; 43 | 44 | const sha256 = new Sha256(secret); 45 | await flushPromises(); 46 | 47 | sinon.assert.calledOnce(importKey as sinon.SinonStub); 48 | const [ 49 | type, 50 | key, 51 | algorithm, 52 | exportable, 53 | permittedUses, 54 | ] = (importKey as sinon.SinonStub).firstCall.args; 55 | 56 | expect(type).to.eql("raw"); 57 | expect(key).to.deep.equal(secret); 58 | expect(algorithm).to.deep.equal(SHA_256_HMAC_ALGO); 59 | expect(exportable).to.eql(false); 60 | expect(permittedUses).to.deep.equal(["sign"]); 61 | }); 62 | 63 | it("should import ArrayBufferView secrets", async () => { 64 | const secret = Uint8Array.from([0xde, 0xad, 0xbe, 0xef]); 65 | const { importKey } = locateWindow().crypto.subtle; 66 | 67 | const sha256 = new Sha256(secret); 68 | await flushPromises(); 69 | 70 | sinon.assert.calledOnce(importKey as sinon.SinonStub); 71 | const [_, key] = (importKey as sinon.SinonStub).firstCall.args; 72 | 73 | expect(key).to.deep.equal(secret); 74 | }); 75 | 76 | it("should trap UTF-8 errors", async () => { 77 | const sha256 = new Sha256("secret"); 78 | await flushPromises(); 79 | 80 | await sha256.digest().then( 81 | () => { 82 | throw new Error("The promise should have been rejected."); 83 | }, 84 | () => { 85 | /* Promise rejected, just as expected */ 86 | } 87 | ); 88 | }); 89 | 90 | it("should trap key import errors", async () => { 91 | const secret = Uint8Array.from([0xde, 0xad, 0xbe, 0xef]); 92 | const { importKey } = locateWindow().crypto.subtle; 93 | (importKey as sinon.SinonStub).rejects("No can do, sir."); 94 | 95 | const sha256 = new Sha256(secret); 96 | await flushPromises(); 97 | 98 | sinon.assert.calledOnce(importKey as sinon.SinonStub); 99 | 100 | await sha256.digest().then( 101 | () => { 102 | throw new Error("The promise should have been rejected."); 103 | }, 104 | () => { 105 | /* Promise rejected, just as expected */ 106 | } 107 | ); 108 | }); 109 | 110 | it("should not call process if empty data is received", async () => { 111 | const sha256 = new Sha256(); 112 | 113 | const { digest } = locateWindow().crypto.subtle; 114 | 115 | await flushPromises(); 116 | sinon.assert.notCalled(digest as sinon.SinonStub); 117 | 118 | sha256.update(new ArrayBuffer(0)); 119 | await flushPromises(); 120 | sinon.assert.notCalled(digest as sinon.SinonStub); 121 | }); 122 | 123 | it("should trap processing errors for vanilla hashes", async () => { 124 | const sha256 = new Sha256(); 125 | 126 | const { digest } = locateWindow().crypto.subtle; 127 | (digest as sinon.SinonStub).rejects("failure, failure"); 128 | 129 | sha256.update(new ArrayBuffer(4)); 130 | await sha256.digest().then( 131 | () => { 132 | throw new Error("The promise should have been rejected."); 133 | }, 134 | () => { 135 | /* Promise rejected, just as expected */ 136 | } 137 | ); 138 | }); 139 | 140 | it("should trap processing errors for hmacs", async () => { 141 | const { importKey, sign } = locateWindow().crypto.subtle; 142 | (importKey as sinon.SinonStub).resolves( 143 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 144 | ); 145 | (sign as sinon.SinonStub).rejects("failure, failure"); 146 | 147 | const sha256 = new Sha256(new ArrayBuffer(1)); 148 | 149 | sha256.update(new ArrayBuffer(4)); 150 | await sha256.digest().then( 151 | () => { 152 | throw new Error("The promise should have been rejected."); 153 | }, 154 | () => { 155 | /* Promise rejected, just as expected */ 156 | } 157 | ); 158 | }); 159 | 160 | it("should resolve the promise with the value returned by WebCrypto for vanilla hashes", async () => { 161 | const sha256 = new Sha256(); 162 | 163 | const { digest } = locateWindow().crypto.subtle; 164 | (digest as sinon.SinonStub).resolves( 165 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 166 | ); 167 | 168 | sha256.update(new ArrayBuffer(4)); 169 | 170 | expect(await sha256.digest()).to.deep.equal( 171 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 172 | ); 173 | }); 174 | 175 | it("should resolve the promise with the value returned by WebCrypto for hmacs", async () => { 176 | const { importKey, sign } = locateWindow().crypto.subtle; 177 | (importKey as sinon.SinonStub).resolves( 178 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 179 | ); 180 | (sign as sinon.SinonStub).resolves( 181 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 182 | ); 183 | 184 | const sha256 = new Sha256(new ArrayBuffer(1)); 185 | 186 | sha256.update(new ArrayBuffer(4)); 187 | 188 | expect(await sha256.digest()).to.deep.equal( 189 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 190 | ); 191 | }); 192 | 193 | it("should skip calling WebCrypto if no data was supplied", async () => { 194 | const sha256 = new Sha256(); 195 | 196 | const { digest } = locateWindow().crypto.subtle; 197 | (digest as sinon.SinonStub).throws(new Error("PANIC")); 198 | 199 | sha256.update(new ArrayBuffer(0)); 200 | 201 | expect(await sha256.digest()).to.deep.equal(EMPTY_DATA_SHA_256); 202 | }); 203 | }); 204 | -------------------------------------------------------------------------------- /packages/sha256-universal/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 19 | 20 | **Note:** Version bump only for package @aws-crypto/sha256-universal 21 | 22 | ## [4.0.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.0...v4.0.1) (2023-05-22) 23 | 24 | ### Bug Fixes 25 | 26 | - correct package naming in "browser" fields ([#625](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/625)) ([24d8c2b](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/24d8c2b4b740fe2c8faa136384fe3ae8fb1ff60b)) 27 | 28 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 29 | 30 | **Note:** Version bump only for package @aws-crypto/sha256-universal 31 | 32 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 33 | 34 | ### Bug Fixes 35 | 36 | - **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)) 37 | 38 | - 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) 39 | 40 | ### BREAKING CHANGES 41 | 42 | - All classes that implemented `Hash` now implement `Checksum`. 43 | 44 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 45 | 46 | ### Bug Fixes 47 | 48 | - **#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) 49 | 50 | ## [2.0.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.0...v2.0.1) (2021-12-09) 51 | 52 | **Note:** Version bump only for package @aws-crypto/sha256-universal 53 | 54 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 55 | 56 | **Note:** Version bump only for package @aws-crypto/sha256-universal 57 | 58 | ## [1.2.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.1...v1.2.2) (2021-10-12) 59 | 60 | **Note:** Version bump only for package @aws-crypto/sha256-universal 61 | 62 | ## [1.2.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.0...v1.2.1) (2021-09-17) 63 | 64 | **Note:** Version bump only for package @aws-crypto/sha256-universal 65 | 66 | # [1.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.1.1...v1.2.0) (2021-09-17) 67 | 68 | **Note:** Version bump only for package @aws-crypto/sha256-universal 69 | 70 | ## [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) 71 | 72 | **Note:** Version bump only for package @aws-crypto/sha256-universal 73 | 74 | # [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) 75 | 76 | ### Bug Fixes 77 | 78 | - remove package lock ([6002a5a](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6002a5ab9218dc8798c19dc205d3eebd3bec5b43)) 79 | - **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)) 80 | - **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)) 81 | 82 | # [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) 83 | 84 | **Note:** Version bump only for package @aws-crypto/sha256-universal 85 | 86 | # [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) 87 | 88 | **Note:** Version bump only for package @aws-crypto/sha256-universal 89 | 90 | # [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) 91 | 92 | ### Bug Fixes 93 | 94 | - 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) 95 | - 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) 96 | 97 | # [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) 98 | 99 | ### Bug Fixes 100 | 101 | - 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) 102 | - 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) 103 | 104 | # [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) 105 | 106 | ### Bug Fixes 107 | 108 | - 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)) 109 | -------------------------------------------------------------------------------- /packages/sha256-js/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 19 | 20 | **Note:** Version bump only for package @aws-crypto/sha256-js 21 | 22 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 23 | 24 | **Note:** Version bump only for package @aws-crypto/sha256-js 25 | 26 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 27 | 28 | ### Bug Fixes 29 | 30 | - **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)) 31 | 32 | - 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) 33 | 34 | ### BREAKING CHANGES 35 | 36 | - All classes that implemented `Hash` now implement `Checksum`. 37 | 38 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 39 | 40 | ### Bug Fixes 41 | 42 | - **#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) 43 | 44 | ## [2.0.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.0...v2.0.1) (2021-12-09) 45 | 46 | **Note:** Version bump only for package @aws-crypto/sha256-js 47 | 48 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 49 | 50 | **Note:** Version bump only for package @aws-crypto/sha256-js 51 | 52 | ## [1.2.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.1...v1.2.2) (2021-10-12) 53 | 54 | **Note:** Version bump only for package @aws-crypto/sha256-js 55 | 56 | ## [1.2.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.0...v1.2.1) (2021-09-17) 57 | 58 | **Note:** Version bump only for package @aws-crypto/sha256-js 59 | 60 | # [1.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.1.1...v1.2.0) (2021-09-17) 61 | 62 | ### Features 63 | 64 | - add @aws-crypto/util ([8f489cb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/8f489cbe4c0e134f826bac66f1bf5172597048b9)) 65 | 66 | # [1.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-js@1.0.0...@aws-crypto/sha256-js@1.1.0) (2021-01-13) 67 | 68 | ### Bug Fixes 69 | 70 | - remove package lock ([6002a5a](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6002a5ab9218dc8798c19dc205d3eebd3bec5b43)) 71 | - **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)) 72 | - **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)) 73 | 74 | # [1.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-js@1.0.0-alpha.0...@aws-crypto/sha256-js@1.0.0) (2020-10-22) 75 | 76 | **Note:** Version bump only for package @aws-crypto/sha256-js 77 | 78 | # [1.0.0-alpha.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-js@0.1.0-preview.4...@aws-crypto/sha256-js@1.0.0-alpha.0) (2020-02-07) 79 | 80 | **Note:** Version bump only for package @aws-crypto/sha256-js 81 | 82 | # [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-js@0.1.0-preview.2...@aws-crypto/sha256-js@0.1.0-preview.4) (2020-01-16) 83 | 84 | ### Bug Fixes 85 | 86 | - 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) 87 | - es2015.iterable required ([#10](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/10)) ([6e08d83](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6e08d83c33667ad8cbeeaaa7cedf1bbe05f79ed8)) 88 | - 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) 89 | 90 | # [0.1.0-preview.3](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-js@0.1.0-preview.2...@aws-crypto/sha256-js@0.1.0-preview.3) (2019-11-15) 91 | 92 | ### Bug Fixes 93 | 94 | - 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) 95 | - es2015.iterable required ([#10](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/10)) ([6e08d83](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6e08d83c33667ad8cbeeaaa7cedf1bbe05f79ed8)) 96 | - 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) 97 | 98 | # [0.1.0-preview.2](https://github.com/aws/aws-javascript-crypto-helpers/compare/@aws-crypto/sha256-js@0.1.0-preview.1...@aws-crypto/sha256-js@0.1.0-preview.2) (2019-10-30) 99 | 100 | ### Bug Fixes 101 | 102 | - 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)) 103 | 104 | ### Features 105 | 106 | - **sha256-js:** expose synchronous digest ([#7](https://github.com/aws/aws-javascript-crypto-helpers/issues/7)) ([9edaef7](https://github.com/aws/aws-javascript-crypto-helpers/commit/9edaef7)), closes [#6](https://github.com/aws/aws-javascript-crypto-helpers/issues/6) 107 | -------------------------------------------------------------------------------- /packages/sha1-browser/test/webCryptoSha1.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import "mocha"; 3 | import { Sha1 } from "../src/webCryptoSha1"; 4 | import { 5 | EMPTY_DATA_SHA_1, 6 | SHA_1_HASH, 7 | SHA_1_HMAC_ALGO, 8 | } from "../src/constants"; 9 | import { flushPromises } from "./testUtils.fixture"; 10 | import * as sinon from "sinon"; 11 | import { locateWindow } from "@aws-sdk/util-locate-window"; 12 | 13 | describe("Sha1", () => { 14 | beforeEach(() => { 15 | (locateWindow() as any).crypto = { 16 | subtle: { 17 | digest: sinon.stub().resolves(new ArrayBuffer(32)), 18 | importKey: sinon.stub(), 19 | sign: sinon.stub().resolves(new ArrayBuffer(32)), 20 | }, 21 | }; 22 | 23 | }); 24 | 25 | afterEach(() => sinon.restore()); 26 | 27 | it("should create a hash object by default", async () => { 28 | const sha1 = new Sha1(); 29 | sha1.update(new ArrayBuffer(1)); 30 | await sha1.digest(); 31 | 32 | const { digest } = locateWindow().crypto.subtle; 33 | sinon.assert.calledOnce(digest as sinon.SinonStub); 34 | const [method, data] = (digest as sinon.SinonStub).firstCall.args; 35 | expect(method).to.deep.equal(SHA_1_HASH); 36 | expect(data).to.deep.equal(new Uint8Array(1)); 37 | }); 38 | 39 | it("should immediately import a secret as a SubtleCrypto key when supplied", async () => { 40 | const secret = Uint8Array.from([0xde, 0xad, 0xbe, 0xef]); 41 | const { importKey } = locateWindow().crypto.subtle; 42 | 43 | const sha1 = new Sha1(secret); 44 | await flushPromises(); 45 | 46 | sinon.assert.calledOnce(importKey as sinon.SinonStub); 47 | const [ 48 | type, 49 | key, 50 | algorithm, 51 | exportable, 52 | permittedUses, 53 | ] = (importKey as sinon.SinonStub).firstCall.args; 54 | 55 | expect(type).to.eql("raw"); 56 | expect(key).to.deep.equal(secret); 57 | expect(algorithm).to.deep.equal(SHA_1_HMAC_ALGO); 58 | expect(exportable).to.eql(false); 59 | expect(permittedUses).to.deep.equal(["sign"]); 60 | }); 61 | 62 | it("should import ArrayBufferView secrets", async () => { 63 | const secret = Uint8Array.from([0xde, 0xad, 0xbe, 0xef]); 64 | const { importKey } = locateWindow().crypto.subtle; 65 | 66 | const sha1 = new Sha1(secret); 67 | await flushPromises(); 68 | 69 | sinon.assert.calledOnce(importKey as sinon.SinonStub); 70 | const [_, key] = (importKey as sinon.SinonStub).firstCall.args; 71 | 72 | expect(key).to.deep.equal(secret); 73 | }); 74 | 75 | it("should convert empty string secrets to empty ArrayBuffers", async () => { 76 | const { importKey } = locateWindow().crypto.subtle; 77 | 78 | const sha1 = new Sha1(""); 79 | await flushPromises(); 80 | 81 | const [_, key] = (importKey as sinon.SinonStub).firstCall.args; 82 | 83 | expect(key).to.deep.equal(new Uint8Array(0)); 84 | }); 85 | 86 | it("should import string secrets via the browser UTF-8 decoder", async () => { 87 | const { importKey } = locateWindow().crypto.subtle; 88 | 89 | const sha1 = new Sha1("secret"); 90 | await flushPromises(); 91 | 92 | const [_, key] = (importKey as sinon.SinonStub).firstCall.args; 93 | 94 | expect(key).to.deep.equal(new Uint8Array([ 115, 101, 99, 114, 101, 116 ])); 95 | }); 96 | 97 | it("should trap UTF-8 errors", async () => { 98 | const sha1 = new Sha1("secret"); 99 | await flushPromises(); 100 | 101 | await sha1.digest().then( 102 | () => { 103 | throw new Error("The promise should have been rejected."); 104 | }, 105 | () => { 106 | /* Promise rejected, just as expected */ 107 | } 108 | ); 109 | }); 110 | 111 | it("should trap key import errors", async () => { 112 | const secret = Uint8Array.from([0xde, 0xad, 0xbe, 0xef]); 113 | const { importKey } = locateWindow().crypto.subtle; 114 | (importKey as sinon.SinonStub).rejects("No can do, sir."); 115 | 116 | const sha1 = new Sha1(secret); 117 | await flushPromises(); 118 | 119 | sinon.assert.calledOnce(importKey as sinon.SinonStub); 120 | 121 | await sha1.digest().then( 122 | () => { 123 | throw new Error("The promise should have been rejected."); 124 | }, 125 | () => { 126 | /* Promise rejected, just as expected */ 127 | } 128 | ); 129 | }); 130 | 131 | it("should not call process if empty data is received", async () => { 132 | const sha1 = new Sha1(); 133 | 134 | const { digest } = locateWindow().crypto.subtle; 135 | 136 | await flushPromises(); 137 | sinon.assert.notCalled(digest as sinon.SinonStub); 138 | 139 | sha1.update(new ArrayBuffer(0)); 140 | await flushPromises(); 141 | sinon.assert.notCalled(digest as sinon.SinonStub); 142 | }); 143 | 144 | it("should trap processing errors for vanilla hashes", async () => { 145 | const sha1 = new Sha1(); 146 | 147 | const { digest } = locateWindow().crypto.subtle; 148 | (digest as sinon.SinonStub).rejects("failure, failure"); 149 | 150 | sha1.update(new ArrayBuffer(4)); 151 | await sha1.digest().then( 152 | () => { 153 | throw new Error("The promise should have been rejected."); 154 | }, 155 | () => { 156 | /* Promise rejected, just as expected */ 157 | } 158 | ); 159 | }); 160 | 161 | it("should trap processing errors for hmacs", async () => { 162 | const { importKey, sign } = locateWindow().crypto.subtle; 163 | (importKey as sinon.SinonStub).resolves( 164 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 165 | ); 166 | (sign as sinon.SinonStub).rejects("failure, failure"); 167 | 168 | const sha1 = new Sha1(new ArrayBuffer(1)); 169 | 170 | sha1.update(new ArrayBuffer(4)); 171 | await sha1.digest().then( 172 | () => { 173 | throw new Error("The promise should have been rejected."); 174 | }, 175 | () => { 176 | /* Promise rejected, just as expected */ 177 | } 178 | ); 179 | }); 180 | 181 | it("should resolve the promise with the value returned by WebCrypto for vanilla hashes", async () => { 182 | const sha1 = new Sha1(); 183 | 184 | const { digest } = locateWindow().crypto.subtle; 185 | (digest as sinon.SinonStub).resolves( 186 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 187 | ); 188 | 189 | sha1.update(new ArrayBuffer(4)); 190 | 191 | expect(await sha1.digest()).to.deep.equal( 192 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 193 | ); 194 | }); 195 | 196 | it("should resolve the promise with the value returned by WebCrypto for hmacs", async () => { 197 | const { importKey, sign } = locateWindow().crypto.subtle; 198 | (importKey as sinon.SinonStub).resolves( 199 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 200 | ); 201 | (sign as sinon.SinonStub).resolves( 202 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 203 | ); 204 | 205 | const sha1 = new Sha1(new ArrayBuffer(1)); 206 | 207 | sha1.update(new ArrayBuffer(4)); 208 | 209 | expect(await sha1.digest()).to.deep.equal( 210 | Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) 211 | ); 212 | }); 213 | 214 | it("should skip calling WebCrypto if no data was supplied", async () => { 215 | const sha1 = new Sha1(); 216 | 217 | const { digest } = locateWindow().crypto.subtle; 218 | (digest as sinon.SinonStub).throws(new Error("PANIC")); 219 | 220 | sha1.update(new ArrayBuffer(0)); 221 | 222 | expect(await sha1.digest()).to.deep.equal(EMPTY_DATA_SHA_1); 223 | }); 224 | 225 | it("should create a new toHash instance when reset is called", () => { 226 | const sha1 = new Sha1(); 227 | const oldInstance = (sha1 as any).toHash; 228 | sha1.reset(); 229 | const newInstance = (sha1 as any).toHash; 230 | expect(oldInstance).to.not.equal(newInstance); // compare by reference 231 | }) 232 | }); 233 | -------------------------------------------------------------------------------- /packages/sha256-browser/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [5.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.1.0...v5.2.0) (2023-10-16) 7 | 8 | ### Features 9 | 10 | - support ESM artifacts in all packages ([#752](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/752)) ([e930ffb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/e930ffba5cfef66dd242049e7d514ced232c1e3b)) 11 | 12 | # [5.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v5.0.0...v5.1.0) (2023-09-22) 13 | 14 | ### Bug Fixes 15 | 16 | - Update tsc to 2.x ([#735](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/735)) ([782e0de](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/782e0de9f5fef41f694130580a69d940894b6b8c)) 17 | 18 | ### Features 19 | 20 | - Use @smithy/util-utf8 ([#730](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/730)) ([00fb851](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/00fb851ca3559d5a1f370f9256814de1210826b8)), closes [#699](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/699) 21 | 22 | # [5.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v4.0.1...v5.0.0) (2023-07-13) 23 | 24 | - feat!: drop support for IE 11 (#629) ([6c49fb6](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6c49fb6c1b1f18bbff02dbd77a37a21bdb40c959)), closes [#629](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/629) 25 | 26 | ### BREAKING CHANGES 27 | 28 | - Remove support for IE11 29 | 30 | Co-authored-by: texastony <5892063+texastony@users.noreply.github.com> 31 | 32 | # [4.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v3.0.0...v4.0.0) (2023-02-20) 33 | 34 | **Note:** Version bump only for package @aws-crypto/sha256-browser 35 | 36 | # [3.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.2...v3.0.0) (2023-01-12) 37 | 38 | ### Bug Fixes 39 | 40 | - **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)) 41 | 42 | - 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) 43 | 44 | ### BREAKING CHANGES 45 | 46 | - All classes that implemented `Hash` now implement `Checksum`. 47 | 48 | ## [2.0.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.1...v2.0.2) (2022-09-07) 49 | 50 | ### Bug Fixes 51 | 52 | - **#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) 53 | 54 | ## [2.0.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v2.0.0...v2.0.1) (2021-12-09) 55 | 56 | **Note:** Version bump only for package @aws-crypto/sha256-browser 57 | 58 | # [2.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.2...v2.0.0) (2021-10-25) 59 | 60 | **Note:** Version bump only for package @aws-crypto/sha256-browser 61 | 62 | ## [1.2.2](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.1...v1.2.2) (2021-10-12) 63 | 64 | **Note:** Version bump only for package @aws-crypto/sha256-browser 65 | 66 | ## [1.2.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.2.0...v1.2.1) (2021-09-17) 67 | 68 | **Note:** Version bump only for package @aws-crypto/sha256-browser 69 | 70 | # [1.2.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/v1.1.1...v1.2.0) (2021-09-17) 71 | 72 | ### Features 73 | 74 | - add @aws-crypto/util ([8f489cb](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/8f489cbe4c0e134f826bac66f1bf5172597048b9)) 75 | 76 | ## [1.1.1](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-browser@1.1.0...@aws-crypto/sha256-browser@1.1.1) (2021-07-13) 77 | 78 | ### Bug Fixes 79 | 80 | - **sha256-browser:** throw errors not string ([#194](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/194)) ([7fa7ac4](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/7fa7ac445ef7a04dfb1ff479e7114aba045b2b2c)) 81 | 82 | # [1.1.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-browser@1.0.0...@aws-crypto/sha256-browser@1.1.0) (2021-01-13) 83 | 84 | ### Bug Fixes 85 | 86 | - remove package lock ([6002a5a](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6002a5ab9218dc8798c19dc205d3eebd3bec5b43)) 87 | - **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)) 88 | - **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)) 89 | 90 | # [1.0.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-browser@1.0.0-alpha.0...@aws-crypto/sha256-browser@1.0.0) (2020-10-22) 91 | 92 | **Note:** Version bump only for package @aws-crypto/sha256-browser 93 | 94 | # [1.0.0-alpha.0](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-browser@0.1.0-preview.4...@aws-crypto/sha256-browser@1.0.0-alpha.0) (2020-02-07) 95 | 96 | **Note:** Version bump only for package @aws-crypto/sha256-browser 97 | 98 | # [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-browser@0.1.0-preview.2...@aws-crypto/sha256-browser@0.1.0-preview.4) (2020-01-16) 99 | 100 | ### Bug Fixes 101 | 102 | - 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) 103 | - es2015.iterable required ([#10](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/10)) ([6e08d83](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6e08d83c33667ad8cbeeaaa7cedf1bbe05f79ed8)) 104 | - 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) 105 | 106 | # [0.1.0-preview.3](https://github.com/aws/aws-sdk-js-crypto-helpers/compare/@aws-crypto/sha256-browser@0.1.0-preview.2...@aws-crypto/sha256-browser@0.1.0-preview.3) (2019-11-15) 107 | 108 | ### Bug Fixes 109 | 110 | - 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) 111 | - es2015.iterable required ([#10](https://github.com/aws/aws-sdk-js-crypto-helpers/issues/10)) ([6e08d83](https://github.com/aws/aws-sdk-js-crypto-helpers/commit/6e08d83c33667ad8cbeeaaa7cedf1bbe05f79ed8)) 112 | - 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) 113 | 114 | # [0.1.0-preview.2](https://github.com/aws/aws-javascript-crypto-helpers/compare/@aws-crypto/sha256-browser@0.1.0-preview.1...@aws-crypto/sha256-browser@0.1.0-preview.2) (2019-10-30) 115 | 116 | ### Bug Fixes 117 | 118 | - 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)) 119 | --------------------------------------------------------------------------------