How to use @aws-sdk/util-locate-window - 7 common examples

To help you get started, we’ve selected a few @aws-sdk/util-locate-window examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-sdk-js-v3 / packages / crypto-random-source-browser / src / index.ts View on Github external
export function randomValues(byteLength: number): Promise {
    // Find the global scope for this runtime
    const globalScope = locateWindow();

    if (supportsWebCrypto(globalScope)) {
        return webCryptoRandomValues(byteLength);
    } else if (isMsWindow(globalScope)) {
        return ie11RandomValues(byteLength);
    }

    return Promise.reject(
        new Error(`Unable to locate a secure random source.`)
    );
}
github aws / aws-sdk-js-v3 / packages / crypto-sha256-browser / src / webCryptoSha256.ts View on Github external
            return this.key.then(key => locateWindow().crypto.subtle
                .sign(SHA_256_HMAC_ALGO, key, this.toHash)
                .then(data => new Uint8Array(data))
            );
github aws / aws-sdk-js-v3 / packages / crypto-sha256-browser / src / ie11Sha256.ts View on Github external
constructor(secret?: SourceData) {
        if (secret) {
            this.operation = getKeyPromise(secret).then(keyData => (
                (locateWindow() as MsWindow).msCrypto.subtle
                    .sign(SHA_256_HMAC_ALGO, keyData)
            ));
            this.operation.catch(() => {});
        } else {
            this.operation = Promise.resolve(
                (locateWindow() as MsWindow).msCrypto.subtle
                    .digest('SHA-256')
            );
        }
    }
github aws / aws-sdk-js-v3 / packages / crypto-random-source-browser / src / webCryptoRandomValues.ts View on Github external
return new Promise(resolve => {
        const randomBytes = new Uint8Array(byteLength);
        locateWindow().crypto.getRandomValues(randomBytes);

        resolve(randomBytes);
    });
}
github aws / aws-sdk-js-v3 / packages / crypto-sha256-browser / src / crossPlatformSha256.ts View on Github external
constructor(secret?: SourceData) {
        if (supportsWebCrypto(locateWindow())) {
            this.hash = new WebCryptoSha256(secret);
        } else if (isMsWindow(locateWindow())) {
            this.hash = new Ie11Sha256(secret);
        } else {
            this.hash = new JsSha256(secret);
        }
    }
github aws / aws-sdk-js-v3 / packages / crypto-sha256-browser / src / crossPlatformSha256.ts View on Github external
constructor(secret?: SourceData) {
        if (supportsWebCrypto(locateWindow())) {
            this.hash = new WebCryptoSha256(secret);
        } else if (isMsWindow(locateWindow())) {
            this.hash = new Ie11Sha256(secret);
        } else {
            this.hash = new JsSha256(secret);
        }
    }
github aws / aws-encryption-sdk-javascript / modules / web-crypto-backend / src / index.ts View on Github external
*
 *     http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { locateWindow } from '@aws-sdk/util-locate-window'
import { webCryptoBackendFactory } from './backend-factory'

const {
  getWebCryptoBackend,
  configureFallback
} = webCryptoBackendFactory(locateWindow())
export { getWebCryptoBackend, configureFallback }

export {
  getNonZeroByteBackend,
  getZeroByteSubtle,
  isFullSupportWebCryptoBackend,
  WebCryptoBackend,
  FullSupportWebCryptoBackend,
  MixedSupportWebCryptoBackend
} from './backend-factory'

export { synchronousRandomValues } from './synchronous_random_values'

@aws-sdk/util-locate-window

[![NPM version](https://img.shields.io/npm/v/@aws-sdk/util-locate-window/latest.svg)](https://www.npmjs.com/package/@aws-sdk/util-locate-window) [![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/util-locate-window.svg)](https://www.npmjs.com/packag

Apache-2.0
Latest version published 3 months ago

Package Health Score

100 / 100
Full package analysis

Popular @aws-sdk/util-locate-window functions

Similar packages