Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@google-cloud/kms

googleapis689kApache-2.05.0.1TypeScript support: included

Google Cloud Key Management Service (KMS) API client for Node.js

google apis client, google api client, google apis, google api, google, google cloud platform, google cloud, cloud, google kms, kms, Google Cloud Key Management Service (KMS) API

readme

Google Cloud Platform logo

Google Cloud Key Management Service: Node.js Client

release level npm version

Google Cloud Key Management Service (KMS) API client for Node.js

A comprehensive list of changes in each version may be found in the CHANGELOG.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Google Cloud Key Management Service API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/kms

Using the client library

//
// TODO(developer): Uncomment these variables before running the sample.
//
// const projectId = 'my-project';
// const locationId = 'us-east1';

// Imports the Cloud KMS library
const {KeyManagementServiceClient} = require('@google-cloud/kms');

// Instantiates a client
const client = new KeyManagementServiceClient();

// Build the location name
const locationName = client.locationPath(projectId, locationId);

async function listKeyRings() {
  const [keyRings] = await client.listKeyRings({
    parent: locationName,
  });

  for (const keyRing of keyRings) {
    console.log(keyRing.name);
  }

  return keyRings;
}

return listKeyRings();

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

Sample Source Code Try it
Autokey.create_key_handle source code Open in Cloud Shell
Autokey.get_key_handle source code Open in Cloud Shell
Autokey.list_key_handles source code Open in Cloud Shell
Autokey_admin.get_autokey_config source code Open in Cloud Shell
Autokey_admin.show_effective_autokey_config source code Open in Cloud Shell
Autokey_admin.update_autokey_config source code Open in Cloud Shell
Ekm_service.create_ekm_connection source code Open in Cloud Shell
Ekm_service.get_ekm_config source code Open in Cloud Shell
Ekm_service.get_ekm_connection source code Open in Cloud Shell
Ekm_service.list_ekm_connections source code Open in Cloud Shell
Ekm_service.update_ekm_config source code Open in Cloud Shell
Ekm_service.update_ekm_connection source code Open in Cloud Shell
Ekm_service.verify_connectivity source code Open in Cloud Shell
Key_management_service.asymmetric_decrypt source code Open in Cloud Shell
Key_management_service.asymmetric_sign source code Open in Cloud Shell
Key_management_service.create_crypto_key source code Open in Cloud Shell
Key_management_service.create_crypto_key_version source code Open in Cloud Shell
Key_management_service.create_import_job source code Open in Cloud Shell
Key_management_service.create_key_ring source code Open in Cloud Shell
Key_management_service.decrypt source code Open in Cloud Shell
Key_management_service.destroy_crypto_key_version source code Open in Cloud Shell
Key_management_service.encrypt source code Open in Cloud Shell
Key_management_service.generate_random_bytes source code Open in Cloud Shell
Key_management_service.get_crypto_key source code Open in Cloud Shell
Key_management_service.get_crypto_key_version source code Open in Cloud Shell
Key_management_service.get_import_job source code Open in Cloud Shell
Key_management_service.get_key_ring source code Open in Cloud Shell
Key_management_service.get_public_key source code Open in Cloud Shell
Key_management_service.import_crypto_key_version source code Open in Cloud Shell
Key_management_service.list_crypto_key_versions source code Open in Cloud Shell
Key_management_service.list_crypto_keys source code Open in Cloud Shell
Key_management_service.list_import_jobs source code Open in Cloud Shell
Key_management_service.list_key_rings source code Open in Cloud Shell
Key_management_service.mac_sign source code Open in Cloud Shell
Key_management_service.mac_verify source code Open in Cloud Shell
Key_management_service.raw_decrypt source code Open in Cloud Shell
Key_management_service.raw_encrypt source code Open in Cloud Shell
Key_management_service.restore_crypto_key_version source code Open in Cloud Shell
Key_management_service.update_crypto_key source code Open in Cloud Shell
Key_management_service.update_crypto_key_primary_version source code Open in Cloud Shell
Key_management_service.update_crypto_key_version source code Open in Cloud Shell
Quickstart source code Open in Cloud Shell

The Google Cloud Key Management Service Node.js Client API Reference documentation also contains samples.

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js. If you are using an end-of-life version of Node.js, we recommend that you update as soon as possible to an actively supported LTS version.

Google's client libraries support legacy versions of Node.js runtimes on a best-efforts basis with the following warnings:

  • Legacy versions are not tested in continuous integration.
  • Some security patches and features cannot be backported.
  • Dependencies cannot be kept up-to-date.

Client libraries targeting some end-of-life versions of Node.js are available, and can be installed through npm dist-tags. The dist-tags follow the naming convention legacy-(version). For example, npm install @google-cloud/kms@legacy-8 installs client libraries for versions compatible with Node.js 8.

Versioning

This library follows Semantic Versioning.

This library is considered to be stable. The code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against stable libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

Please note that this README.md, the samples/README.md, and a variety of configuration files in this repository (including .nycrc and tsconfig.json) are generated from a central template. To edit one of these files, make an edit to its templates in directory.

License

Apache Version 2.0

See LICENSE

changelog

Changelog

npm history

5.0.1 (2025-03-19)

Bug Fixes

  • [Many APIs] await/catch promises, and update listOperationsAsync return type (#6186) (dcfc7b4)

5.0.0 (2025-03-18)

⚠ BREAKING CHANGES

  • upgrade to Node 18 (#6096)

Features

  • [Many APIs] add request/response debug logging to gapics (#6140) (2f96b1f)
  • Adding a state field for AutokeyConfig (c8dd40a)

Miscellaneous Chores

4.5.0 (2024-06-21)

Features

  • [kms] support Key Access Justifications policy configuration (#5479) (a6a77c9)

4.4.0 (2024-05-21)

Features

  • [Many APIs] update Nodejs generator to send API versions in headers for GAPICs (#5351) (01f48fc)
  • [Many APIs] update Nodejs generator to send API versions in headers for GAPICs (#5354) (a9784ed)

4.3.0 (2024-05-08)

Features

  • [kms] add client library for KMS Autokey service, which enables automated KMS key provision and management (#5313) (0f199db)

4.2.0 (2024-03-29)

Features

  • [Many APIs] add several fields to manage state of database encryption update (#5189) (64b5a75)

4.1.0 (2024-02-09)

Features

  • Trusted Private Cloud support, use the universeDomain parameter (#5025) (7244cab)

4.0.1 (2023-09-06)

Bug Fixes

  • [Many APIs] simplify logic for HTTP/1.1 REST fallback option (#4586) (4b18686)

4.0.0 (2023-08-06)

⚠ BREAKING CHANGES

  • migrate to Node 14 (#4443)
  • [kms] migrate to Node 14

Bug Fixes

Miscellaneous Chores

3.8.0 (2023-07-24)

Features

  • [kms] add interoperable symmetric encryption system (#4431) (28b5dca)

3.7.0 (2023-07-11)

Features

  • [kms] add interoperable symmetric encryption system (#4389) (685b1ad)

3.6.0 (2023-05-20)

Features

3.5.1 (2023-04-13)

Bug Fixes

3.5.0 (2023-03-13)

Features

  • Add support for Coordinated External Keys (cb0ae8f)

3.4.0 (2023-03-02)

Features

  • Add initial files for google.cloud.kms.inventory.v1 (#4011) (44756d7)

3.3.1 (2023-02-15)

Bug Fixes

  • [Many APIs] changing format of the jsdoc links (#3988) (f2134ed)

3.3.0 (2023-01-28)

Features

3.2.0 (2022-12-16)

Features

3.1.0 (2022-11-11)

Features

  • kms: Enable generation of Locations mixin (#578) (5205ddc)

Bug Fixes

3.0.1 (2022-06-30)

Bug Fixes

3.0.0 (2022-05-20)

⚠ BREAKING CHANGES

  • update library to use Node 12 (#556)

Build System

2.11.1 (2022-04-08)

Bug Fixes

  • docs: document that fast-crc32c must be installed (#546) (57253bb)

2.11.0 (2022-02-03)

Features

2.10.0 (2021-10-19)

Features

2.9.0 (2021-10-14)

Features

  • add OAEP+SHA1 to the list of supported algorithms (#503) (00cc42e)
  • add RPC retry information for MacSign, MacVerify, and GenerateRandomBytes Committer: @bdhess (#506) (08cd155)

2.8.1 (2021-09-03)

Bug Fixes

2.8.0 (2021-08-30)

Features

2.7.0 (2021-08-23)

Features

  • turns on self-signed JWT feature flag (#490) (3db7ee5)

2.6.0 (2021-08-17)

Features

  • kms: add samples for new rng and hmac kms apis (#487) (5278a8e)

Bug Fixes

2.5.0 (2021-08-05)

Features

  • add support for HMAC, Variable Key Destruction, and GenerateRandom (#484) (c207423)

2.4.4 (2021-07-16)

Bug Fixes

  • Updating WORKSPACE files to use the newest version of the Typescript generator. (#476) (5332b9f)

2.4.3 (2021-07-12)

Bug Fixes

2.4.2 (2021-06-29)

Bug Fixes

2.4.1 (2021-06-25)

Bug Fixes

2.4.0 (2021-06-14)

Features

  • add ECDSA secp256k1 to the list of supported algorithms (#464) (a27f95d)

2.3.3 (2021-05-25)

Bug Fixes

  • GoogleAdsError missing using generator version after 1.3.0 (#456) (6f9ceae)

2.3.2 (2021-05-12)

Bug Fixes

2.3.1 (2021-02-12)

Bug Fixes

2.3.0 (2021-01-08)

Features

  • samples: add integrity verification to Cloud KMS crypto samples (#409) (d2897f6)

2.2.0 (2021-01-06)

Features

2.1.4 (2020-11-25)

Bug Fixes

2.1.3 (2020-11-07)

Bug Fixes

  • do not modify options object, use defaultScopes (#399) (288b417)

2.1.2 (2020-06-12)

Bug Fixes

  • handle fallback option properly (753a5b5)

2.1.1 (2020-06-08)

Bug Fixes

2.1.0 (2020-06-04)

Features

  • clean up synth.py by using IAM service option from generator (#305) (797ee55)
  • samples: add new samples (#324) (eb1c213)

Bug Fixes

  • regen protos and tests, fix formatting (#329) (e6083a9)
  • remove eslint, update gax, fix generated protos, run the generator (#309) (54fccb6)
  • synth.py clean up for multiple version (#330) (50de8d0)
  • update common protos and fix synth (#336) (3ed7e67)

2.0.0 (2020-04-07)

⚠ BREAKING CHANGES

  • The library now supports Node.js v10+. The last version to support Node.js v8 is tagged legacy-8 on NPM.

New feature: methods with pagination now support async iteration.

  • move to typescript code generation (#264)

Features

  • add support for Cloud EKM to the Cloud KMS service and resource protos (#306) (f6e28c7)
  • deferred client initialization (#286) (e116119)
  • drop node8 support, support for async iterators (#300) (c2ca42e)
  • move to typescript code generation (#264) (ad02c1c)

Bug Fixes

  • export explicit version in protos.js (#303) (90e1b52)

1.6.3 (2020-02-10)

Bug Fixes

  • proto messages now accept strings for enums (b5241d9)

1.6.2 (2020-01-09)

Bug Fixes

  • protos: removed extra resource annotations, no code changes (b3d99be)

1.6.1 (2020-01-05)

Bug Fixes

1.6.0 (2019-12-31)

Features

Bug Fixes

  • remove superfluous base64-encoding/decoding (#242) (aad6cc4)
  • deps: TypeScript 3.7.0 causes breaking change in typings (#246) (d274c2a)

1.5.3 (2019-11-18)

Bug Fixes

1.5.2 (2019-11-14)

Bug Fixes

  • docs: snippets are now replaced in jsdoc comments (#230) (ed142f3)
  • import long into proto ts declaration file (#231) (bc21cff)

1.5.1 (2019-10-22)

Bug Fixes

1.5.0 (2019-10-09)

Bug Fixes

  • use compatible version of google-gax (b674eee)

Features

1.4.0 (2019-09-16)

Features

  • load protos from JSON, grpc-fallback support (628f665)

1.3.2 (2019-08-28)

Bug Fixes

  • update retry code settings per API call (#196) (3ce2076)
  • use process versions object for client header (#199) (900eb1b)
  • docs: stop redirecting reference docs to anchor link (9edd953)

1.3.1 (2019-08-05)

Bug Fixes

  • allow calls with no request, add JSON proto (e50e0ef)

1.3.0 (2019-07-02)

Features

1.2.1 (2019-06-27)

Bug Fixes

  • docs: link to reference docs section on googleapis.dev (#183) (7c40adf)

1.2.0 (2019-06-24)

Features

  • introduces CreateImportJob, ListImportJob, GetImportJob (#180) (9fb4efb)

1.1.1 (2019-06-14)

Bug Fixes

1.1.0 (2019-06-05)

Features

  • support apiEndpoint override in client constructor (#173) (0e67019)

1.0.0 (2019-05-20)

⚠ BREAKING CHANGES

  • upgrade engines field to >=8.10.0 (#151)

Bug Fixes

  • deps: update dependency google-gax to ^0.26.0 (#149) (b92c822)
  • DEADLINE_EXCEEDED is no longer retried (5f4f9ff)
  • DEADLINE_EXCEEDED retry code is idempotent (#159) (a7e511a)
  • indicate that Encrypt, Decrypt, AsymmetricDecrypt, AsymmetricSign are idempotent, such that they're retried (122b3f8)
  • deps: update dependency google-gax to v1 (#158) (91fe078)

Build System

v0.4.0

03-13-2019 16:16 PDT

New Features

  • feat: add support for the CAVIUM_V2_COMPRESSED type (#126)

Bug Fixes

  • fix: throw on invalid credentials
  • fix(deps): update dependency google-gax to ^0.25.0 (#113)

Documentation

  • docs: update links in contrib guide (#125)
  • docs: update contributing path in README (#119)
  • docs: move CONTRIBUTING.md to root (#118)
  • docs: add lint/fix example to contributing guide (#116)
  • docs: fix example comments (#115)

Internal / Testing Changes

  • refactor: update json import paths (#134)
  • build: Add docuploader credentials to node publish jobs (#132)
  • build: use node10 to run samples-test, system-test etc (#131)
  • build: update release configuration
  • chore: sync latest proto docs
  • chore(deps): update dependency mocha to v6
  • build: use linkinator for docs test (#124)
  • chore(deps): update dependency yargs to v13 (#122)
  • build: create docs test npm scripts (#121)
  • build: test using @grpc/grpc-js in CI (#120)
  • refactor: improve generated code style. (#114)
  • chore(deps): update dependency eslint-config-prettier to v4 (#112)
  • test: add a system test to list global keys (#111)
  • build: ignore googleapis.com in doc link check (#108)
  • chore: sync gapic files

v0.3.0

01-15-2019 10:50 PST

Implementation Changes

  • Add iam_policy proto (#101)

Dependencies

  • fix(deps): update dependency google-gax to ^0.23.0 (#105)
  • fix(deps): update dependency google-gax to ^0.22.0 (#73)
  • chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 (#71)
  • chore(deps): update dependency through2 to v3 (#67)
  • chore(deps): update dependency eslint-plugin-node to v8 (#59)
  • chore(deps): update dependency eslint-plugin-prettier to v3 (#44)

Documentation

  • build: check broken links in generated docs (#102)
  • fix(docs): remove unused IAM message types (#103)
  • docs: Changes 'dencrypt' to 'decrypt' (#97)
  • docs: add samples (#88)
  • docs: update readme badges (#81)

Internal / Testing Changes

  • chore(build): inject yoshi automation key (#96)
  • chore: update nyc and eslint configs (#95)
  • chore: fix publish.sh permission +x (#93)
  • fix(build): fix Kokoro release script (#92)
  • build: add Kokoro configs for autorelease (#91)
  • chore: always nyc report before calling codecov (#87)
  • chore: nyc ignore build/test by default (#86)
  • chore: update the renovate config (#84)
  • chore: update license file (#83)
  • fix(build): fix system key decryption (#79)
  • chore: add a synth.metadata
  • chore: update eslintignore config (#72)
  • chore: update lint rules (#69)
  • chore: drop contributors from multiple places (#70)
  • chore: use latest npm on Windows (#68)
  • chore: update CircleCI config (#66)
  • chore: include build in eslintignore (#63)
  • chore: update issue templates (#58)
  • chore: remove old issue template (#56)
  • build: run tests on node11 (#55)
  • chores(build): do not collect sponge.xml from windows builds (#54)
  • chores(build): run codecov on continuous builds (#53)
  • chore: update new issue template (#52)
  • build: fix codecov uploading on Kokoro (#48)
  • Update kokoro config (#45)
  • test: remove appveyor config (#41)
  • Enable prefer-const in the eslint config (#38)

v0.2.0

New Features

  • Add new features to the library (#33)
    • CryptoKeyPurpose: ASSYMETRIC_SIGN, ASSYMETRIC_DECRYPT
    • CryptoKeyVersion
    • KeyOperationAttestation
    • various improved code documentation

Dependencies

  • fix(deps): update dependency google-gax to ^0.20.0 (#34)
  • chore(deps): update dependency nyc to v13 (#25)
  • fix(deps): update dependency google-gax to ^0.19.0 (#22)

Internal / Testing Changes

  • Enable no-var in eslint (#35)
  • Update CI config (#32)
  • Retry npm install in CI (#30)
  • Update CI config (#27)