Skip to content
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

migrate code from googleapis/nodejs-kms #2839

Merged
merged 88 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
48f217e
gen: generate v1 of KMS library
jkwlui Jul 11, 2018
a626f6e
build: add a package.json to samples so eslint runs properly (#6)
jkwlui Jul 18, 2018
af233bf
chore(deps): lock file maintenance (#8)
renovate[bot] Jul 24, 2018
c28fe1f
chore(deps): update dependency eslint-plugin-node to v7 (#7)
renovate[bot] Jul 25, 2018
67c29f7
chore: require node 8 for samples (#11)
JustinBeckwith Jul 30, 2018
d5482d0
chore(deps): lock file maintenance (#12)
renovate[bot] Jul 31, 2018
b61e866
chore(deps): lock file maintenance (#16)
renovate[bot] Aug 7, 2018
1a2856f
chore: ignore package-lock.json (#18)
JustinBeckwith Aug 7, 2018
0aabfdd
Release v0.2.0 (#36)
jkwlui Sep 18, 2018
e7c0017
chore: update lint rules (#69)
JustinBeckwith Nov 9, 2018
15809bc
docs: add samples (#88)
JustinBeckwith Dec 6, 2018
8f06f06
docs: Changes 'dencrypt' to 'decrypt' (#97)
WalterHub Dec 12, 2018
92a4836
Release v0.3.0 (#106)
jkwlui Jan 15, 2019
ff430e0
chore(deps): update dependency yargs to v13 (#122)
renovate[bot] Feb 12, 2019
2f6a80d
chore(deps): update dependency mocha to v6
renovate[bot] Feb 19, 2019
37ec3a3
Release v0.4.0 (#135)
JustinBeckwith Mar 14, 2019
95ac5bd
refactor: use execSync for tests (#143)
JustinBeckwith Apr 4, 2019
fbea514
refactor: wrap execSync with encoding: utf-8 (#144)
jkwlui Apr 5, 2019
3c7713e
refactor: update metadata, synth, and deps (#160)
JustinBeckwith May 14, 2019
6232ce6
chore: release 1.0.0 (#166)
yoshi-automation May 20, 2019
ae7d640
chore: release 1.1.0 (#174)
yoshi-automation Jun 5, 2019
d8ffa33
chore: release 1.1.1 (#178)
yoshi-automation Jun 14, 2019
a75954d
feat: introduces CreateImportJob, ListImportJob, GetImportJob (#180)
yoshi-automation Jun 24, 2019
fab28ee
chore: release 1.2.0 (#182)
yoshi-automation Jun 24, 2019
712982b
chore: release 1.2.1 (#184)
yoshi-automation Jun 27, 2019
63f5d71
chore: release 1.3.0 (#187)
yoshi-automation Jul 2, 2019
5869a25
chore: release 1.3.1 (#195)
yoshi-automation Aug 5, 2019
21068c9
chore(deps): update dependency yargs to v14
renovate-bot Aug 20, 2019
365ccbd
chore: release 1.3.2 (#200)
yoshi-automation Aug 28, 2019
912ca3a
chore: release 1.4.0 (#204)
yoshi-automation Sep 16, 2019
2e6744a
chore: release 1.5.1 (#222)
release-please[bot] Oct 22, 2019
a169be2
chore: release 1.5.2 (#232)
release-please[bot] Nov 15, 2019
bdd4880
chore(deps): update dependency yargs to v15 (#238)
renovate-bot Nov 18, 2019
ce27837
chore: release 1.5.3 (#237)
release-please[bot] Nov 18, 2019
0a43a06
fix: remove superfluous base64-encoding/decoding (#242)
bdhess Nov 27, 2019
fa6928a
feat(samples): add asymmetric samples (#241)
sethvargo Dec 4, 2019
e1cab4a
refactor: use explicit mocha imports
JustinBeckwith Dec 30, 2019
8a2b651
chore: release 1.6.0 (#245)
release-please[bot] Jan 2, 2020
9db7c3c
fix: updated proto annotations (#258)
yoshi-automation Jan 5, 2020
25da3f1
chore: release 1.6.1
release-please[bot] Jan 6, 2020
c08914f
chore(deps): update dependency mocha to v7 (#260)
renovate-bot Jan 6, 2020
e035c38
chore: release 1.6.2 (#262)
release-please[bot] Jan 9, 2020
f0b95d5
chore: release 1.6.3 (#274)
release-please[bot] Feb 10, 2020
689a78f
feat!: move to typescript code generation (#264)
xiaozhenliu-gg5 Mar 5, 2020
5dbf7ff
chore: update UUID to latest (#293)
bcoe Mar 19, 2020
63dfc1f
feat!: drop node8 support, support for async iterators (#300)
alexander-fenster Mar 31, 2020
b886f3e
chore: release 2.0.0 (#285)
release-please[bot] Apr 8, 2020
0e31cd4
chore: update lint rules and synth (#316)
JustinBeckwith Apr 14, 2020
02c63a2
docs: address typo in comment (#325)
sofisl Apr 28, 2020
02c8dfe
feat(samples): add new samples (#324)
sethvargo Apr 28, 2020
bb4f6b5
chore: update UUID to latest (#328)
bcoe May 4, 2020
3d82ed0
chore: release 2.1.0 (#313)
release-please[bot] Jun 4, 2020
3faa549
chore: release 2.1.1 (#340)
release-please[bot] Jun 8, 2020
ae9a73c
chore(deps): update dependency mocha to v8 (#344)
renovate-bot Jun 11, 2020
e2ad481
chore: release 2.1.2 (#347)
release-please[bot] Jun 16, 2020
17e1c19
chore: release 2.1.3 (#400)
release-please[bot] Nov 11, 2020
1cc8123
chore: release 2.1.4 (#405)
release-please[bot] Dec 2, 2020
ace21f7
chore: release 2.2.0 (#413)
release-please[bot] Jan 7, 2021
d04defb
feat(samples): add integrity verification to Cloud KMS crypto samples…
iamtamjam Jan 8, 2021
7345945
chore: release 2.3.0 (#414)
release-please[bot] Jan 12, 2021
e0d5d00
chore: release 2.3.1 (#419)
release-please[bot] Mar 2, 2021
600f15d
docs: update samples to reflect proper typings (#443)
sofisl Apr 20, 2021
4f11510
chore: release 2.3.2 (#448)
release-please[bot] May 13, 2021
dc8d92f
chore: release 2.3.3 (#457)
release-please[bot] May 25, 2021
cdf30e3
chore: release 2.4.0 (#465)
release-please[bot] Jun 14, 2021
0c4f1bf
chore: release 2.4.1 (#468)
release-please[bot] Jun 28, 2021
09f34af
chore: release 2.4.2 (#472)
release-please[bot] Jun 29, 2021
f5e8129
chore: release 2.4.3 (#475)
release-please[bot] Jul 12, 2021
ec6e519
chore: release 2.4.4 (#477)
release-please[bot] Jul 16, 2021
8f8f5c4
chore: release 2.5.0 (#485)
release-please[bot] Aug 5, 2021
35b4610
feat(kms): add samples for new rng and hmac kms apis (#487)
sethvargo Aug 16, 2021
d220ddf
chore: release 2.6.0 (#488)
release-please[bot] Aug 17, 2021
4f7c9f5
chore: release 2.7.0 (#491)
release-please[bot] Aug 23, 2021
942800f
chore: release 2.8.0 (#494)
release-please[bot] Aug 30, 2021
7498e71
chore: release 2.8.1 (#497)
release-please[bot] Sep 3, 2021
90f0352
docs(samples): add auto-generated Node samples (#501)
gcf-owl-bot[bot] Sep 24, 2021
f672942
chore: release 2.9.0 (#507)
release-please[bot] Oct 14, 2021
2b94392
chore: release 2.10.0 (#510)
release-please[bot] Oct 19, 2021
c705fe4
chore(main): release 2.11.0 (#535)
release-please[bot] Feb 8, 2022
4d77a2f
fix(docs): document that fast-crc32c must be installed (#546)
bcoe Apr 8, 2022
5a8bc79
chore(main): release 2.11.1 (#547)
release-please[bot] Apr 8, 2022
30444bd
build!: update library to use Node 12 (#556)
sofisl May 20, 2022
85aa2b6
chore(main): release 3.0.0 (#557)
release-please[bot] Jun 7, 2022
db007b3
chore(main): release 3.0.1 (#562)
release-please[bot] Jul 4, 2022
ead55c2
chore(deps): update dependency uuid to v9 (#572)
renovate-bot Sep 9, 2022
886852a
chore(main): release 3.1.0 (#567)
release-please[bot] Nov 11, 2022
422fdb1
Merge remote-tracking branch 'migration/main' into nodejs-kms-migrati…
NimJay Nov 11, 2022
cc81398
Generate .github/workflows/kms.yaml
NimJay Nov 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/kms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: kms
on:
push:
branches:
- main
paths:
- 'kms/**'
pull_request:
paths:
- 'kms/**'
pull_request_target:
types: [labeled]
paths:
- 'kms/**'
schedule:
- cron: '0 0 * * 0'
jobs:
test:
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: 'write'
pull-requests: 'write'
id-token: 'write'
steps:
- uses: actions/checkout@v3.1.0
with:
ref: ${{github.event.pull_request.head.sha}}
- uses: 'google-github-actions/auth@v1.0.0'
with:
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com'
create_credentials_file: 'true'
access_token_lifetime: 600s
- uses: actions/setup-node@v3.5.1
with:
node-version: 16
- run: npm install
working-directory: kms
- run: npm test
working-directory: kms
env:
MOCHA_REPORTER_SUITENAME: kms
MOCHA_REPORTER_OUTPUT: kms_sponge_log.xml
MOCHA_REPORTER: xunit
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.removeLabel({
name: 'actions:force-run',
owner: 'GoogleCloudPlatform',
repo: 'nodejs-docs-samples',
issue_number: context.payload.pull_request.number
});
} catch (e) {
if (!e.message.includes('Label does not exist')) {
throw e;
}
}
- if: ${{ github.event_name == 'schedule'}}
run: |
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
chmod +x ./flakybot
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
1 change: 1 addition & 0 deletions .github/workflows/workflows.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"healthcare/dicom",
"healthcare/fhir",
"healthcare/hl7v2",
"kms",
"game-servers/snippets",
"mediatranslation",
"monitoring/opencensus",
Expand Down
76 changes: 76 additions & 0 deletions kms/createKeyAsymmetricDecrypt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License 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.

'use strict';

async function main(
projectId = 'my-project',
locationId = 'us-east1',
keyRingId = 'my-key-ring',
id = 'my-asymmetric-decrypt-key'
) {
// [START kms_create_key_asymmetric_decrypt]
//
// TODO(developer): Uncomment these variables before running the sample.
//
// const projectId = 'my-project';
// const locationId = 'us-east1';
// const keyRingId = 'my-key-ring';
// const id = 'my-asymmetric-decrypt-key';

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

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

// Build the parent key ring name
const keyRingName = client.keyRingPath(projectId, locationId, keyRingId);

async function createKeyAsymmetricDecrypt() {
const [key] = await client.createCryptoKey({
parent: keyRingName,
cryptoKeyId: id,
cryptoKey: {
purpose: 'ASYMMETRIC_DECRYPT',
versionTemplate: {
algorithm: 'RSA_DECRYPT_OAEP_2048_SHA256',
},

// Optional: customize how long key versions should be kept before
// destroying.
destroyScheduledDuration: {seconds: 60 * 60 * 24},
},
});

console.log(`Created asymmetric key: ${key.name}`);
return key;
}

return createKeyAsymmetricDecrypt();
// [END kms_create_key_asymmetric_decrypt]
}
module.exports.main = main;

/* c8 ignore next 10 */
if (require.main === module) {
main(...process.argv.slice(2)).catch(err => {
console.error(err.message);
process.exitCode = 1;
});
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
}
76 changes: 76 additions & 0 deletions kms/createKeyAsymmetricSign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License 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.

'use strict';

async function main(
projectId = 'my-project',
locationId = 'us-east1',
keyRingId = 'my-key-ring',
id = 'my-asymmetric-sign-key'
) {
// [START kms_create_key_asymmetric_sign]
//
// TODO(developer): Uncomment these variables before running the sample.
//
// const projectId = 'my-project';
// const locationId = 'us-east1';
// const keyRingId = 'my-key-ring';
// const id = 'my-asymmetric-sign-key';

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

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

// Build the parent key ring name
const keyRingName = client.keyRingPath(projectId, locationId, keyRingId);

async function createKeyAsymmetricSign() {
const [key] = await client.createCryptoKey({
parent: keyRingName,
cryptoKeyId: id,
cryptoKey: {
purpose: 'ASYMMETRIC_SIGN',
versionTemplate: {
algorithm: 'RSA_SIGN_PKCS1_2048_SHA256',
},

// Optional: customize how long key versions should be kept before
// destroying.
destroyScheduledDuration: {seconds: 60 * 60 * 24},
},
});

console.log(`Created asymmetric key: ${key.name}`);
return key;
}

return createKeyAsymmetricSign();
// [END kms_create_key_asymmetric_sign]
}
module.exports.main = main;

/* c8 ignore next 10 */
if (require.main === module) {
main(...process.argv.slice(2)).catch(err => {
console.error(err.message);
process.exitCode = 1;
});
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
}
77 changes: 77 additions & 0 deletions kms/createKeyHsm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License 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.

'use strict';

async function main(
projectId = 'my-project',
locationId = 'us-east1',
keyRingId = 'my-key-ring',
id = 'my-hsm-encryption-key'
) {
// [START kms_create_key_hsm]
//
// TODO(developer): Uncomment these variables before running the sample.
//
// const projectId = 'my-project';
// const locationId = 'us-east1';
// const keyRingId = 'my-key-ring';
// const id = 'my-hsm-encryption-key';

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

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

// Build the parent key ring name
const keyRingName = client.keyRingPath(projectId, locationId, keyRingId);

async function createKeyHsm() {
const [key] = await client.createCryptoKey({
parent: keyRingName,
cryptoKeyId: id,
cryptoKey: {
purpose: 'ENCRYPT_DECRYPT',
versionTemplate: {
algorithm: 'GOOGLE_SYMMETRIC_ENCRYPTION',
protectionLevel: 'HSM',
},

// Optional: customize how long key versions should be kept before
// destroying.
destroyScheduledDuration: {seconds: 60 * 60 * 24},
},
});

console.log(`Created hsm key: ${key.name}`);
return key;
}

return createKeyHsm();
// [END kms_create_key_hsm]
}
module.exports.main = main;

/* c8 ignore next 10 */
if (require.main === module) {
main(...process.argv.slice(2)).catch(err => {
console.error(err.message);
process.exitCode = 1;
});
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
}
76 changes: 76 additions & 0 deletions kms/createKeyLabels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License 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.

'use strict';

async function main(
projectId = 'my-project',
locationId = 'us-east1',
keyRingId = 'my-key-ring',
id = 'my-labeled-key'
) {
// [START kms_create_key_labels]
//
// TODO(developer): Uncomment these variables before running the sample.
//
// const projectId = 'my-project';
// const locationId = 'us-east1';
// const keyRingId = 'my-key-ring';
// const id = 'my-labeled-key';

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

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

// Build the parent key ring name
const keyRingName = client.keyRingPath(projectId, locationId, keyRingId);

async function createKeyLabels() {
const [key] = await client.createCryptoKey({
parent: keyRingName,
cryptoKeyId: id,
cryptoKey: {
purpose: 'ENCRYPT_DECRYPT',
versionTemplate: {
algorithm: 'GOOGLE_SYMMETRIC_ENCRYPTION',
},
labels: {
team: 'alpha',
cost_center: 'cc1234',
},
},
});

console.log(`Created labeled key: ${key.name}`);
return key;
}

return createKeyLabels();
// [END kms_create_key_labels]
}
module.exports.main = main;

/* c8 ignore next 10 */
if (require.main === module) {
main(...process.argv.slice(2)).catch(err => {
console.error(err.message);
process.exitCode = 1;
});
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
}
Loading