Skip to content

example-node Readme.md update #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 18, 2019
32 changes: 16 additions & 16 deletions modules/example-node/Readme.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# AWS Encryption SDK for Javascript Node.js examples

This repository holds examples for encrypt and decrypt in Node.js.
These examples are intended to work so you can experiment with functional code.
These examples are intended to work in such a way that you can experiment with functional code. These are not for production use.

# NOTE
The CMK's in these examples *are only* for example. They *are public*.
Replace these CMK's with your own.
> The CMK's in these examples *are only* for example. They *are public*. *Replace these CMK's with your own*.

## KMS Simple

This is the simples example.
It encrypts and decrypts a simple string with KMS.
This is an example of using KMS to encrypt and decrypt a simple string. See `kms_simple.ts` for a more detailed explanation.

## KMS Stream

An example of encrypting a file stream with KMS.
This is an example of using KMS to encrypt and decrypt a file stream. See `kms_stream.ts` for a more detailed explanation.

## KMS Regional Discovery

KMS Keyrings can be put in `discovery` mode.
This means that it will attempt to connect to any region.
This is not always what you want.
Perhapses for performance you want to limit attempts to a set of "close" regions.
Perhapses for policy reason you want to exclude some regions.
KMS Keyrings can be put in `discovery` mode, which means that, on decrypt, it will attempt to connect to any region represented in the KMS Keyring by using the `clientProvider`. However, perhaps for performance, you may want to limit attempts to a set of "close" regions, or, for policy reasons, you want to exclude some regions, which can be done with the `limitRegions` and `excludeRegions` functions, respectively. See `kms_regional_discovery.ts` for a more detailed explanation.

## RSA Simple

Sometimes you may want to use an RSA key to exchange secrets.
This has some advantages, but comes with a heaved key management cost.
If you can use KMS, the context guaranties are generally worth it.
However, I still want to provide an example incase this fits your use case.
This is an example of using RSA to encrypt and decrypt a simple string. This has some advantages for certain use-cases, but the key management costs are higher than using KMS, which means KMS is generally the best option. See `rsa_simple.ts` for a more detailed explanation.

## How to Use

Run `npm test` to see these examples in action.

## License

This SDK is distributed under the
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0),
see LICENSE.txt and NOTICE.txt for more information.
15 changes: 0 additions & 15 deletions modules/example-node/src/kms_regional_discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,6 @@
* limitations under the License.
*/

/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is
* located at
*
* 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 { KmsKeyringNode, limitRegions, excludeRegions, getKmsClient, decrypt } from '@aws-crypto/client-node'

export async function kmsRegionalDiscoveryLimitTest (ciphertext: string|Buffer) {
Expand Down
15 changes: 0 additions & 15 deletions modules/example-node/src/kms_simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,6 @@
* limitations under the License.
*/

/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is
* located at
*
* 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 { KmsKeyringNode, encrypt, decrypt } from '@aws-crypto/client-node'

export async function kmsSimpleTest () {
Expand Down
15 changes: 0 additions & 15 deletions modules/example-node/src/rsa_simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,6 @@
* limitations under the License.
*/

/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is
* located at
*
* 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 { RawRsaKeyringNode, encrypt, decrypt } from '@aws-crypto/client-node'

import { generateKeyPair } from 'crypto'
Expand Down