diff --git a/.kokoro/populate-secrets.sh b/.kokoro/populate-secrets.sh new file mode 100755 index 0000000..e6ce820 --- /dev/null +++ b/.kokoro/populate-secrets.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# 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 +# +# http://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. + +set -eo pipefail + +function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;} +function msg { println "$*" >&2 ;} +function println { printf '%s\n' "$(now) $*" ;} + + +# Populates requested secrets set in SECRET_MANAGER_KEYS from service account: +# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com +SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" +msg "Creating folder on disk for secrets: ${SECRET_LOCATION}" +mkdir -p ${SECRET_LOCATION} +for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g") +do + msg "Retrieving secret ${key}" + docker run --entrypoint=gcloud \ + --volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \ + gcr.io/google.com/cloudsdktool/cloud-sdk \ + secrets versions access latest \ + --credential-file-override=${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json \ + --project cloud-devrel-kokoro-resources \ + --secret $key > \ + "$SECRET_LOCATION/$key" + if [[ $? == 0 ]]; then + msg "Secret written to ${SECRET_LOCATION}/${key}" + else + msg "Error retrieving secret ${key}" + fi +done diff --git a/.kokoro/publish.sh b/.kokoro/publish.sh index 59aac46..24957d7 100755 --- a/.kokoro/publish.sh +++ b/.kokoro/publish.sh @@ -24,7 +24,7 @@ python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source / cd $(dirname $0)/.. -NPM_TOKEN=$(cat $KOKORO_KEYSTORE_DIR/73713_google-cloud-recaptcha-enterprise-npm-token) +NPM_TOKEN=$(cat $KOKORO_GFILE_DIR/secret_manager/npm_publish_token echo "//wombat-dressing-room.appspot.com/:_authToken=${NPM_TOKEN}" > ~/.npmrc npm install diff --git a/.kokoro/release/publish.cfg b/.kokoro/release/publish.cfg index e3d3ecb..e30e0fb 100644 --- a/.kokoro/release/publish.cfg +++ b/.kokoro/release/publish.cfg @@ -47,13 +47,9 @@ before_action { } } -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "google-cloud-recaptcha-enterprise-npm-token" - } - } +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "npm_publish_token" } # Download trampoline resources. diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh index 9bd4905..a4241db 100755 --- a/.kokoro/trampoline.sh +++ b/.kokoro/trampoline.sh @@ -24,4 +24,5 @@ function cleanup() { } trap cleanup EXIT +$(dirname $0)/populate-secrets.sh # Secret Manager secrets. python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 9b6337d..a4696f1 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -5083,6 +5083,9 @@ export namespace google { /** FieldDescriptorProto options */ options?: (google.protobuf.IFieldOptions|null); + + /** FieldDescriptorProto proto3Optional */ + proto3Optional?: (boolean|null); } /** Represents a FieldDescriptorProto. */ @@ -5124,6 +5127,9 @@ export namespace google { /** FieldDescriptorProto options. */ public options?: (google.protobuf.IFieldOptions|null); + /** FieldDescriptorProto proto3Optional. */ + public proto3Optional: boolean; + /** * Creates a new FieldDescriptorProto instance using the specified properties. * @param [properties] Properties to set diff --git a/protos/protos.js b/protos/protos.js index 6ab2d1c..d3cb0c5 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -28,7 +28,7 @@ var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; // Exported root namespace - var $root = $protobuf.roots._google_cloud_recaptcha_enterprise_1_8_0_protos || ($protobuf.roots._google_cloud_recaptcha_enterprise_1_8_0_protos = {}); + var $root = $protobuf.roots._google_cloud_recaptcha_enterprise_protos || ($protobuf.roots._google_cloud_recaptcha_enterprise_protos = {}); $root.google = (function() { @@ -12382,6 +12382,7 @@ * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex * @property {string|null} [jsonName] FieldDescriptorProto jsonName * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options + * @property {boolean|null} [proto3Optional] FieldDescriptorProto proto3Optional */ /** @@ -12479,6 +12480,14 @@ */ FieldDescriptorProto.prototype.options = null; + /** + * FieldDescriptorProto proto3Optional. + * @member {boolean} proto3Optional + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.proto3Optional = false; + /** * Creates a new FieldDescriptorProto instance using the specified properties. * @function create @@ -12523,6 +12532,8 @@ writer.uint32(/* id 9, wireType 0 =*/72).int32(message.oneofIndex); if (message.jsonName != null && Object.hasOwnProperty.call(message, "jsonName")) writer.uint32(/* id 10, wireType 2 =*/82).string(message.jsonName); + if (message.proto3Optional != null && Object.hasOwnProperty.call(message, "proto3Optional")) + writer.uint32(/* id 17, wireType 0 =*/136).bool(message.proto3Optional); return writer; }; @@ -12587,6 +12598,9 @@ case 8: message.options = $root.google.protobuf.FieldOptions.decode(reader, reader.uint32()); break; + case 17: + message.proto3Optional = reader.bool(); + break; default: reader.skipType(tag & 7); break; @@ -12681,6 +12695,9 @@ if (error) return "options." + error; } + if (message.proto3Optional != null && message.hasOwnProperty("proto3Optional")) + if (typeof message.proto3Optional !== "boolean") + return "proto3Optional: boolean expected"; return null; }; @@ -12803,6 +12820,8 @@ throw TypeError(".google.protobuf.FieldDescriptorProto.options: object expected"); message.options = $root.google.protobuf.FieldOptions.fromObject(object.options); } + if (object.proto3Optional != null) + message.proto3Optional = Boolean(object.proto3Optional); return message; }; @@ -12830,6 +12849,7 @@ object.options = null; object.oneofIndex = 0; object.jsonName = ""; + object.proto3Optional = false; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -12851,6 +12871,8 @@ object.oneofIndex = message.oneofIndex; if (message.jsonName != null && message.hasOwnProperty("jsonName")) object.jsonName = message.jsonName; + if (message.proto3Optional != null && message.hasOwnProperty("proto3Optional")) + object.proto3Optional = message.proto3Optional; return object; }; @@ -14644,7 +14666,7 @@ * @memberof google.protobuf.FileOptions * @instance */ - FileOptions.prototype.ccEnableArenas = false; + FileOptions.prototype.ccEnableArenas = true; /** * FileOptions objcClassPrefix. @@ -15130,7 +15152,7 @@ object.javaGenerateEqualsAndHash = false; object.deprecated = false; object.javaStringCheckUtf8 = false; - object.ccEnableArenas = false; + object.ccEnableArenas = true; object.objcClassPrefix = ""; object.csharpNamespace = ""; object.swiftPrefix = ""; diff --git a/protos/protos.json b/protos/protos.json index 3700f43..199ef85 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -1365,6 +1365,10 @@ "options": { "type": "FieldOptions", "id": 8 + }, + "proto3Optional": { + "type": "bool", + "id": 17 } }, "nested": { @@ -1600,7 +1604,7 @@ "type": "bool", "id": 31, "options": { - "default": false + "default": true } }, "objcClassPrefix": { diff --git a/src/index.ts b/src/index.ts index f093420..005c69d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,12 +16,12 @@ // ** https://github.com/googleapis/synthtool ** // ** All changes to this file may be overwritten. ** -import * as v1 from './v1'; import * as v1beta1 from './v1beta1'; +import * as v1 from './v1'; const RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient; -export {v1, v1beta1, RecaptchaEnterpriseServiceClient}; -export default {v1, v1beta1, RecaptchaEnterpriseServiceClient}; +export {v1beta1, v1, RecaptchaEnterpriseServiceClient}; +export default {v1beta1, v1, RecaptchaEnterpriseServiceClient}; import * as protos from '../protos/protos'; export {protos}; diff --git a/src/v1/recaptcha_enterprise_service_client.ts b/src/v1/recaptcha_enterprise_service_client.ts index 57d5366..1ad38c3 100644 --- a/src/v1/recaptcha_enterprise_service_client.ts +++ b/src/v1/recaptcha_enterprise_service_client.ts @@ -100,16 +100,20 @@ export class RecaptchaEnterpriseServiceClient { } opts.servicePath = opts.servicePath || servicePath; opts.port = opts.port || port; + + // users can override the config from client side, like retry codes name. + // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546 + // The way to override client config for Showcase API: + // + // const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}} + // const showcaseClient = new showcaseClient({ projectId, customConfig }); opts.clientConfig = opts.clientConfig || {}; - const isBrowser = typeof window !== 'undefined'; - if (isBrowser) { - opts.fallback = true; - } - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + // If we're running in browser, it's OK to omit `fallback` since + // google-gax has `browser` field in its `package.json`. + // For Electron (which does not respect `browser` field), + // pass `{fallback: true}` to the RecaptchaEnterpriseServiceClient constructor. + this._gaxModule = opts.fallback ? gax.fallback : gax; // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. diff --git a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts index fbbfc22..ec1ce52 100644 --- a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts +++ b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts @@ -100,16 +100,20 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { } opts.servicePath = opts.servicePath || servicePath; opts.port = opts.port || port; + + // users can override the config from client side, like retry codes name. + // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546 + // The way to override client config for Showcase API: + // + // const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}} + // const showcaseClient = new showcaseClient({ projectId, customConfig }); opts.clientConfig = opts.clientConfig || {}; - const isBrowser = typeof window !== 'undefined'; - if (isBrowser) { - opts.fallback = true; - } - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + // If we're running in browser, it's OK to omit `fallback` since + // google-gax has `browser` field in its `package.json`. + // For Electron (which does not respect `browser` field), + // pass `{fallback: true}` to the RecaptchaEnterpriseServiceV1Beta1Client constructor. + this._gaxModule = opts.fallback ? gax.fallback : gax; // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. diff --git a/synth.metadata b/synth.metadata index 80fefb6..1818584 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,42 +4,15 @@ "git": { "name": ".", "remote": "git@github.com:googleapis/nodejs-recaptcha-enterprise.git", - "sha": "05f1acabb9834dd291475598f343ecf7ae62b128" + "sha": "f548f0270d13a5195c345e209ffeb75a1d038344" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "aed11c01e52921613b9ee469c2d85f5f33175fb7", - "internalRef": "310660461" - } - }, - { - "git": { - "name": "synthtool", - "remote": "https://github.com/googleapis/synthtool.git", - "sha": "98c50772ec23295c64cf0d2ddf199ea52961fd4c" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "recaptchaenterprise", - "apiVersion": "v1", - "language": "typescript", - "generator": "gapic-generator-typescript" - } - }, - { - "client": { - "source": "googleapis", - "apiName": "recaptchaenterprise", - "apiVersion": "v1beta1", - "language": "typescript", - "generator": "gapic-generator-typescript" + "sha": "c1ba5ba3f24307ca5a6df350d0137c29d69983d5", + "internalRef": "316715576" } } ] diff --git a/synth.py b/synth.py index d425c12..9b135f8 100644 --- a/synth.py +++ b/synth.py @@ -25,7 +25,7 @@ # run the gapic generator gapic = gcp.GAPICMicrogenerator() -versions = ['v1', 'v1beta1'] +versions = ['v1beta1', 'v1'] for version in versions: library = gapic.typescript_library( 'recaptchaenterprise', version, diff --git a/system-test/fixtures/sample/src/index.js b/system-test/fixtures/sample/src/index.js index 3299314..d8d9e2c 100644 --- a/system-test/fixtures/sample/src/index.js +++ b/system-test/fixtures/sample/src/index.js @@ -20,7 +20,7 @@ const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); function main() { - const recaptchaEnterpriseServiceV1Beta1Client = new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); + const recaptchaEnterpriseServiceClient = new recaptchaenterprise.RecaptchaEnterpriseServiceClient(); } main(); diff --git a/system-test/fixtures/sample/src/index.ts b/system-test/fixtures/sample/src/index.ts index dd718e4..cc5f3b1 100644 --- a/system-test/fixtures/sample/src/index.ts +++ b/system-test/fixtures/sample/src/index.ts @@ -16,10 +16,10 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import * as recaptchaenterprise from '@google-cloud/recaptcha-enterprise'; +import {RecaptchaEnterpriseServiceClient} from '@google-cloud/recaptcha-enterprise'; function main() { - new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); + new RecaptchaEnterpriseServiceClient(); } main(); diff --git a/tsconfig.json b/tsconfig.json index 613d355..c78f1c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "outDir": "build", "resolveJsonModule": true, "lib": [ - "es2016", + "es2018", "dom" ] }, diff --git a/webpack.config.js b/webpack.config.js index 04831b7..4c93b13 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -17,8 +17,8 @@ const path = require('path'); module.exports = { entry: './src/index.ts', output: { - library: 'RecaptchaEnterpriseServiceV1Beta1', - filename: './recaptcha-enterprise-service-v1-beta1.js', + library: 'RecaptchaEnterpriseService', + filename: './recaptcha-enterprise-service.js', }, node: { child_process: 'empty',