From acfa712faea52f2cf10479a297a996c33daf6299 Mon Sep 17 00:00:00 2001 From: Gus Narea Date: Tue, 22 Aug 2023 11:36:04 +0100 Subject: [PATCH] fix(deps): Upgrade `@relaycorp/cloudevents-transport` to 1.3.9 (#218) --- docs/install.md | 4 +- package-lock.json | 379 ++++++++++++++++++++----- package.json | 2 +- src/utilities/eventing/Emitter.spec.ts | 24 +- src/utilities/eventing/Emitter.ts | 3 +- 5 files changed, 328 insertions(+), 84 deletions(-) diff --git a/docs/install.md b/docs/install.md index be7cf9a5..068a768d 100644 --- a/docs/install.md +++ b/docs/install.md @@ -52,8 +52,10 @@ All processes require the following variables: ## CloudEvents environment variables -- `CE_TRANSPORT` (default: `ce-http-binary`): The [`@relaycorp/cloudevents-transport`](https://www.npmjs.com/package/@relaycorp/cloudevents-transport) transport to use. Each transport has its own set of environment variables. +[`@relaycorp/cloudevents-transport`](https://www.npmjs.com/package/@relaycorp/cloudevents-transport) configuration: +- `CE_TRANSPORT` (default: `ce-http-binary`): The transport to use. +- `K_SINK` (required): The transport channel to use. It can be a URL to a CloudEvents server or the name of a Google PubSub topic, for example. (This is called `K_SINK` for compatibility with Knative Eventing, which doesn't allow overriding the `K_SINK` variable name as of this writing.) ## Example with Knative We use Knative to run the app in development and CI, so you can refer to [the Kubernetes resources in the repository](https://github.com/relaycorp/veraid-authority/tree/main/k8s) to see a fully-operation example. diff --git a/package-lock.json b/package-lock.json index 46069369..d1b5f153 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@fastify/routes": "^5.1.0", "@fastify/type-provider-json-schema-to-ts": "^2.2.2", "@peculiar/webcrypto": "^1.4.3", - "@relaycorp/cloudevents-transport": "^1.3.0", + "@relaycorp/cloudevents-transport": "^1.3.9", "@relaycorp/dnssec": "^1.11.4", "@relaycorp/pino-cloud": "^1.0.28", "@relaycorp/veraid": "^1.14.2", @@ -2214,15 +2214,15 @@ } }, "node_modules/@google-cloud/paginator": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@google-cloud/paginator/-/paginator-4.0.1.tgz", - "integrity": "sha512-6G1ui6bWhNyHjmbYwavdN7mpVPRBtyDg/bfqBTAlwr413On2TnFNfDxc9UhTJctkgoCDgQXEKiRPLPR9USlkbQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@google-cloud/paginator/-/paginator-5.0.0.tgz", + "integrity": "sha512-87aeg6QQcEPxGCOthnpUjvw4xAZ57G7pL8FS0C4e/81fr3FjkpUpibf1s2v5XGyGhUVGF4Jfg7yEcxqn2iUw1w==", "dependencies": { "arrify": "^2.0.0", "extend": "^3.0.2" }, "engines": { - "node": ">=12.0.0" + "node": ">=14.0.0" } }, "node_modules/@google-cloud/paginator/node_modules/arrify": { @@ -2234,53 +2234,64 @@ } }, "node_modules/@google-cloud/precise-date": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@google-cloud/precise-date/-/precise-date-3.0.1.tgz", - "integrity": "sha512-crK2rgNFfvLoSgcKJY7ZBOLW91IimVNmPfi1CL+kMTf78pTJYd29XqEVedAeBu4DwCJc0EDIp1MpctLgoPq+Uw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@google-cloud/precise-date/-/precise-date-4.0.0.tgz", + "integrity": "sha512-1TUx3KdaU3cN7nfCdNf+UVqA/PSX29Cjcox3fZZBtINlRrXVTmUkQnCKv2MbBUbCopbK4olAT1IHl76uZyCiVA==", "engines": { - "node": ">=12.0.0" + "node": ">=14.0.0" } }, "node_modules/@google-cloud/projectify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@google-cloud/projectify/-/projectify-3.0.0.tgz", - "integrity": "sha512-HRkZsNmjScY6Li8/kb70wjGlDDyLkVk3KvoEo9uIoxSjYLJasGiCch9+PqRVDOCGUFvEIqyogl+BeqILL4OJHA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@google-cloud/projectify/-/projectify-4.0.0.tgz", + "integrity": "sha512-MmaX6HeSvyPbWGwFq7mXdo0uQZLGBYCwziiLIGq5JVX+/bdI3SAq6bP98trV5eTWfLuvsMcIC1YJOF2vfteLFA==", "engines": { - "node": ">=12.0.0" + "node": ">=14.0.0" } }, "node_modules/@google-cloud/promisify": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@google-cloud/promisify/-/promisify-2.0.4.tgz", - "integrity": "sha512-j8yRSSqswWi1QqUGKVEKOG03Q7qOoZP6/h2zN2YO+F5h2+DHU0bSrHCK9Y7lo2DI9fBd8qGAw795sf+3Jva4yA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@google-cloud/promisify/-/promisify-4.0.0.tgz", + "integrity": "sha512-Orxzlfb9c67A15cq2JQEyVc7wEsmFBmHjZWZYQMUyJ1qivXyMwdyNOs9odi79hze+2zqdTtu1E19IM/FtqZ10g==", "engines": { - "node": ">=10" + "node": ">=14" } }, "node_modules/@google-cloud/pubsub": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@google-cloud/pubsub/-/pubsub-3.7.1.tgz", - "integrity": "sha512-J6jzgIubq1sAMafnSF2wGnOn1qkNd0l0Y5ChG33rU27/iDXmxKabaiY/dvFndX3v57TE/QcB9uQt5A6Pek+WrA==", - "dependencies": { - "@google-cloud/paginator": "^4.0.0", - "@google-cloud/precise-date": "^3.0.0", - "@google-cloud/projectify": "^3.0.0", - "@google-cloud/promisify": "^2.0.0", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@google-cloud/pubsub/-/pubsub-4.0.1.tgz", + "integrity": "sha512-tpL4uKs3dfE23Rb+WXI76BFZQ6ryKAHEQRXh0+LZ365WZ05RPVNUOCvHKFh4my+xrDuXEjlKEb0KWjaeGq7QnQ==", + "dependencies": { + "@google-cloud/paginator": "^5.0.0", + "@google-cloud/precise-date": "^4.0.0", + "@google-cloud/projectify": "^4.0.0", + "@google-cloud/promisify": "^4.0.0", "@opentelemetry/api": "^1.0.0", "@opentelemetry/semantic-conventions": "~1.3.0", "@types/duplexify": "^3.6.0", "@types/long": "^4.0.0", "arrify": "^2.0.0", "extend": "^3.0.2", - "google-auth-library": "^8.0.2", - "google-gax": "^3.5.6", + "google-auth-library": "^9.0.0", + "google-gax": "^4.0.2", "heap-js": "^2.2.0", "is-stream-ended": "^0.1.4", "lodash.snakecase": "^4.1.1", "p-defer": "^3.0.0" }, "engines": { - "node": ">=12.0.0" + "node": ">=14.0.0" + } + }, + "node_modules/@google-cloud/pubsub/node_modules/agent-base": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", + "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" } }, "node_modules/@google-cloud/pubsub/node_modules/arrify": { @@ -2291,6 +2302,122 @@ "node": ">=8" } }, + "node_modules/@google-cloud/pubsub/node_modules/gaxios": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-6.1.0.tgz", + "integrity": "sha512-EIHuesZxNyIkUGcTQKQPMICyOpDD/bi+LJIJx+NLsSGmnS7N+xCLRX5bi4e9yAu9AlSZdVq+qlyWWVuTh/483w==", + "dependencies": { + "extend": "^3.0.2", + "https-proxy-agent": "^7.0.1", + "is-stream": "^2.0.0", + "node-fetch": "^2.6.9" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@google-cloud/pubsub/node_modules/gcp-metadata": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-6.0.0.tgz", + "integrity": "sha512-Ozxyi23/1Ar51wjUT2RDklK+3HxqDr8TLBNK8rBBFQ7T85iIGnXnVusauj06QyqCXRFZig8LZC+TUddWbndlpQ==", + "dependencies": { + "gaxios": "^6.0.0", + "json-bigint": "^1.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@google-cloud/pubsub/node_modules/google-auth-library": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.0.0.tgz", + "integrity": "sha512-IQGjgQoVUAfOk6khqTVMLvWx26R+yPw9uLyb1MNyMQpdKiKt0Fd9sp4NWoINjyGHR8S3iw12hMTYK7O8J07c6Q==", + "dependencies": { + "base64-js": "^1.3.0", + "ecdsa-sig-formatter": "^1.0.11", + "gaxios": "^6.0.0", + "gcp-metadata": "^6.0.0", + "gtoken": "^7.0.0", + "jws": "^4.0.0", + "lru-cache": "^6.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@google-cloud/pubsub/node_modules/google-gax": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/google-gax/-/google-gax-4.0.3.tgz", + "integrity": "sha512-gllHYRhZvpz0LcVN+xtyzBeUa/ZYiLGF4JNBECrvL/LxDkaJc09hHoQ+KzRBI2Ewqgrjj7V3QrOC2pGno5ropw==", + "dependencies": { + "@grpc/grpc-js": "~1.8.0", + "@grpc/proto-loader": "^0.7.0", + "@types/long": "^4.0.0", + "abort-controller": "^3.0.0", + "duplexify": "^4.0.0", + "google-auth-library": "^9.0.0", + "node-fetch": "^2.6.1", + "object-hash": "^3.0.0", + "proto3-json-serializer": "^1.1.1", + "protobufjs": "7.2.4", + "retry-request": "^6.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@google-cloud/pubsub/node_modules/gtoken": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.0.1.tgz", + "integrity": "sha512-KcFVtoP1CVFtQu0aSk3AyAt2og66PFhZAlkUOuWKwzMLoulHXG5W5wE5xAnHb+yl3/wEFoqGW7/cDGMU8igDZQ==", + "dependencies": { + "gaxios": "^6.0.0", + "jws": "^4.0.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@google-cloud/pubsub/node_modules/https-proxy-agent": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.1.tgz", + "integrity": "sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==", + "dependencies": { + "agent-base": "^7.0.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/@google-cloud/pubsub/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@google-cloud/pubsub/node_modules/retry-request": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/retry-request/-/retry-request-6.0.0.tgz", + "integrity": "sha512-24kaFMd3wCnT3n4uPnsQh90ZSV8OISpfTFXJ00Wi+/oD2OPrp63EQ8hznk6rhxdlpwx2QBhQSDz2Fg46ki852g==", + "dependencies": { + "debug": "^4.1.1", + "extend": "^3.0.2" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@google-cloud/pubsub/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "node_modules/@grpc/grpc-js": { "version": "1.8.14", "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.8.14.tgz", @@ -5035,22 +5162,21 @@ } }, "node_modules/@relaycorp/cloudevents-transport": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@relaycorp/cloudevents-transport/-/cloudevents-transport-1.3.0.tgz", - "integrity": "sha512-/hfcZo8GZIS9lAK1bnnSKR45Lmf48aZxtz8r/9205reZPke7cWHjAjcZgyzjAKcUVrnNnnDHzPQbRrZKzR/BzA==", + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/@relaycorp/cloudevents-transport/-/cloudevents-transport-1.3.9.tgz", + "integrity": "sha512-uVW5h6R1pBT9eo7l7S6Q61oso9I4ghrlYMUykZTEpB4kJ1LJFrvehXeK55rIgjFQGGW7119foTHz1lkmrttQ6g==", "dependencies": { - "@google-cloud/pubsub": "^3.7.1", + "@google-cloud/pubsub": "^4.0.1", "ajv": "^8.12.0", - "cloudevents": "< 8", + "cloudevents": "< 9", "date-fns": "^2.30.0", - "env-var": "^7.3.1", - "json-schema-to-ts": "^2.9.1" + "json-schema-to-ts": "^2.9.2" }, "engines": { "node": ">=18" }, "peerDependencies": { - "cloudevents": "< 8" + "cloudevents": "< 9" } }, "node_modules/@relaycorp/dnssec": { @@ -13164,9 +13290,9 @@ "dev": true }, "node_modules/json-schema-to-ts": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-2.9.1.tgz", - "integrity": "sha512-8MNpRGERlCUWYeJwsWkMrJ0MWzBz49dfqpG+n9viiIlP4othaahbiaNQZuBzmPxRLUhOv1QJMCzW5WE8nHFGIQ==", + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-2.9.2.tgz", + "integrity": "sha512-h9WqLkTVpBbiaPb5OmeUpz/FBLS/kvIJw4oRCPiEisIu2WjMh+aai0QIY2LoOhRFx5r92taGLcerIrzxKBAP6g==", "dependencies": { "@babel/runtime": "^7.18.3", "@types/json-schema": "^7.0.9", @@ -15779,9 +15905,9 @@ } }, "node_modules/proto3-json-serializer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proto3-json-serializer/-/proto3-json-serializer-1.1.0.tgz", - "integrity": "sha512-SjXwUWe/vANGs/mJJTbw5++7U67nwsymg7qsoPtw6GiXqw3kUy8ByojrlEdVE2efxAdKreX8WkDafxvYW95ZQg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/proto3-json-serializer/-/proto3-json-serializer-1.1.1.tgz", + "integrity": "sha512-AwAuY4g9nxx0u52DnSMkqqgyLHaW/XaPLtaAo3y/ZCfeaQB/g4YDH4kb8Wc/mWzWvu0YjOznVnfn373MVZZrgw==", "dependencies": { "protobufjs": "^7.0.0" }, @@ -21190,9 +21316,9 @@ } }, "@google-cloud/paginator": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@google-cloud/paginator/-/paginator-4.0.1.tgz", - "integrity": "sha512-6G1ui6bWhNyHjmbYwavdN7mpVPRBtyDg/bfqBTAlwr413On2TnFNfDxc9UhTJctkgoCDgQXEKiRPLPR9USlkbQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@google-cloud/paginator/-/paginator-5.0.0.tgz", + "integrity": "sha512-87aeg6QQcEPxGCOthnpUjvw4xAZ57G7pL8FS0C4e/81fr3FjkpUpibf1s2v5XGyGhUVGF4Jfg7yEcxqn2iUw1w==", "requires": { "arrify": "^2.0.0", "extend": "^3.0.2" @@ -21206,47 +21332,147 @@ } }, "@google-cloud/precise-date": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@google-cloud/precise-date/-/precise-date-3.0.1.tgz", - "integrity": "sha512-crK2rgNFfvLoSgcKJY7ZBOLW91IimVNmPfi1CL+kMTf78pTJYd29XqEVedAeBu4DwCJc0EDIp1MpctLgoPq+Uw==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@google-cloud/precise-date/-/precise-date-4.0.0.tgz", + "integrity": "sha512-1TUx3KdaU3cN7nfCdNf+UVqA/PSX29Cjcox3fZZBtINlRrXVTmUkQnCKv2MbBUbCopbK4olAT1IHl76uZyCiVA==" }, "@google-cloud/projectify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@google-cloud/projectify/-/projectify-3.0.0.tgz", - "integrity": "sha512-HRkZsNmjScY6Li8/kb70wjGlDDyLkVk3KvoEo9uIoxSjYLJasGiCch9+PqRVDOCGUFvEIqyogl+BeqILL4OJHA==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@google-cloud/projectify/-/projectify-4.0.0.tgz", + "integrity": "sha512-MmaX6HeSvyPbWGwFq7mXdo0uQZLGBYCwziiLIGq5JVX+/bdI3SAq6bP98trV5eTWfLuvsMcIC1YJOF2vfteLFA==" }, "@google-cloud/promisify": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@google-cloud/promisify/-/promisify-2.0.4.tgz", - "integrity": "sha512-j8yRSSqswWi1QqUGKVEKOG03Q7qOoZP6/h2zN2YO+F5h2+DHU0bSrHCK9Y7lo2DI9fBd8qGAw795sf+3Jva4yA==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@google-cloud/promisify/-/promisify-4.0.0.tgz", + "integrity": "sha512-Orxzlfb9c67A15cq2JQEyVc7wEsmFBmHjZWZYQMUyJ1qivXyMwdyNOs9odi79hze+2zqdTtu1E19IM/FtqZ10g==" }, "@google-cloud/pubsub": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@google-cloud/pubsub/-/pubsub-3.7.1.tgz", - "integrity": "sha512-J6jzgIubq1sAMafnSF2wGnOn1qkNd0l0Y5ChG33rU27/iDXmxKabaiY/dvFndX3v57TE/QcB9uQt5A6Pek+WrA==", - "requires": { - "@google-cloud/paginator": "^4.0.0", - "@google-cloud/precise-date": "^3.0.0", - "@google-cloud/projectify": "^3.0.0", - "@google-cloud/promisify": "^2.0.0", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@google-cloud/pubsub/-/pubsub-4.0.1.tgz", + "integrity": "sha512-tpL4uKs3dfE23Rb+WXI76BFZQ6ryKAHEQRXh0+LZ365WZ05RPVNUOCvHKFh4my+xrDuXEjlKEb0KWjaeGq7QnQ==", + "requires": { + "@google-cloud/paginator": "^5.0.0", + "@google-cloud/precise-date": "^4.0.0", + "@google-cloud/projectify": "^4.0.0", + "@google-cloud/promisify": "^4.0.0", "@opentelemetry/api": "^1.0.0", "@opentelemetry/semantic-conventions": "~1.3.0", "@types/duplexify": "^3.6.0", "@types/long": "^4.0.0", "arrify": "^2.0.0", "extend": "^3.0.2", - "google-auth-library": "^8.0.2", - "google-gax": "^3.5.6", + "google-auth-library": "^9.0.0", + "google-gax": "^4.0.2", "heap-js": "^2.2.0", "is-stream-ended": "^0.1.4", "lodash.snakecase": "^4.1.1", "p-defer": "^3.0.0" }, "dependencies": { + "agent-base": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", + "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", + "requires": { + "debug": "^4.3.4" + } + }, "arrify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==" + }, + "gaxios": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-6.1.0.tgz", + "integrity": "sha512-EIHuesZxNyIkUGcTQKQPMICyOpDD/bi+LJIJx+NLsSGmnS7N+xCLRX5bi4e9yAu9AlSZdVq+qlyWWVuTh/483w==", + "requires": { + "extend": "^3.0.2", + "https-proxy-agent": "^7.0.1", + "is-stream": "^2.0.0", + "node-fetch": "^2.6.9" + } + }, + "gcp-metadata": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-6.0.0.tgz", + "integrity": "sha512-Ozxyi23/1Ar51wjUT2RDklK+3HxqDr8TLBNK8rBBFQ7T85iIGnXnVusauj06QyqCXRFZig8LZC+TUddWbndlpQ==", + "requires": { + "gaxios": "^6.0.0", + "json-bigint": "^1.0.0" + } + }, + "google-auth-library": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.0.0.tgz", + "integrity": "sha512-IQGjgQoVUAfOk6khqTVMLvWx26R+yPw9uLyb1MNyMQpdKiKt0Fd9sp4NWoINjyGHR8S3iw12hMTYK7O8J07c6Q==", + "requires": { + "base64-js": "^1.3.0", + "ecdsa-sig-formatter": "^1.0.11", + "gaxios": "^6.0.0", + "gcp-metadata": "^6.0.0", + "gtoken": "^7.0.0", + "jws": "^4.0.0", + "lru-cache": "^6.0.0" + } + }, + "google-gax": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/google-gax/-/google-gax-4.0.3.tgz", + "integrity": "sha512-gllHYRhZvpz0LcVN+xtyzBeUa/ZYiLGF4JNBECrvL/LxDkaJc09hHoQ+KzRBI2Ewqgrjj7V3QrOC2pGno5ropw==", + "requires": { + "@grpc/grpc-js": "~1.8.0", + "@grpc/proto-loader": "^0.7.0", + "@types/long": "^4.0.0", + "abort-controller": "^3.0.0", + "duplexify": "^4.0.0", + "google-auth-library": "^9.0.0", + "node-fetch": "^2.6.1", + "object-hash": "^3.0.0", + "proto3-json-serializer": "^1.1.1", + "protobufjs": "7.2.4", + "retry-request": "^6.0.0" + } + }, + "gtoken": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.0.1.tgz", + "integrity": "sha512-KcFVtoP1CVFtQu0aSk3AyAt2og66PFhZAlkUOuWKwzMLoulHXG5W5wE5xAnHb+yl3/wEFoqGW7/cDGMU8igDZQ==", + "requires": { + "gaxios": "^6.0.0", + "jws": "^4.0.0" + } + }, + "https-proxy-agent": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.1.tgz", + "integrity": "sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==", + "requires": { + "agent-base": "^7.0.2", + "debug": "4" + } + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "retry-request": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/retry-request/-/retry-request-6.0.0.tgz", + "integrity": "sha512-24kaFMd3wCnT3n4uPnsQh90ZSV8OISpfTFXJ00Wi+/oD2OPrp63EQ8hznk6rhxdlpwx2QBhQSDz2Fg46ki852g==", + "requires": { + "debug": "^4.1.1", + "extend": "^3.0.2" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" } } }, @@ -23139,16 +23365,15 @@ } }, "@relaycorp/cloudevents-transport": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@relaycorp/cloudevents-transport/-/cloudevents-transport-1.3.0.tgz", - "integrity": "sha512-/hfcZo8GZIS9lAK1bnnSKR45Lmf48aZxtz8r/9205reZPke7cWHjAjcZgyzjAKcUVrnNnnDHzPQbRrZKzR/BzA==", + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/@relaycorp/cloudevents-transport/-/cloudevents-transport-1.3.9.tgz", + "integrity": "sha512-uVW5h6R1pBT9eo7l7S6Q61oso9I4ghrlYMUykZTEpB4kJ1LJFrvehXeK55rIgjFQGGW7119foTHz1lkmrttQ6g==", "requires": { - "@google-cloud/pubsub": "^3.7.1", + "@google-cloud/pubsub": "^4.0.1", "ajv": "^8.12.0", - "cloudevents": "< 8", + "cloudevents": "< 9", "date-fns": "^2.30.0", - "env-var": "^7.3.1", - "json-schema-to-ts": "^2.9.1" + "json-schema-to-ts": "^2.9.2" } }, "@relaycorp/dnssec": { @@ -29068,9 +29293,9 @@ "dev": true }, "json-schema-to-ts": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-2.9.1.tgz", - "integrity": "sha512-8MNpRGERlCUWYeJwsWkMrJ0MWzBz49dfqpG+n9viiIlP4othaahbiaNQZuBzmPxRLUhOv1QJMCzW5WE8nHFGIQ==", + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-2.9.2.tgz", + "integrity": "sha512-h9WqLkTVpBbiaPb5OmeUpz/FBLS/kvIJw4oRCPiEisIu2WjMh+aai0QIY2LoOhRFx5r92taGLcerIrzxKBAP6g==", "requires": { "@babel/runtime": "^7.18.3", "@types/json-schema": "^7.0.9", @@ -30909,9 +31134,9 @@ "dev": true }, "proto3-json-serializer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proto3-json-serializer/-/proto3-json-serializer-1.1.0.tgz", - "integrity": "sha512-SjXwUWe/vANGs/mJJTbw5++7U67nwsymg7qsoPtw6GiXqw3kUy8ByojrlEdVE2efxAdKreX8WkDafxvYW95ZQg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/proto3-json-serializer/-/proto3-json-serializer-1.1.1.tgz", + "integrity": "sha512-AwAuY4g9nxx0u52DnSMkqqgyLHaW/XaPLtaAo3y/ZCfeaQB/g4YDH4kb8Wc/mWzWvu0YjOznVnfn373MVZZrgw==", "requires": { "protobufjs": "^7.0.0" } diff --git a/package.json b/package.json index 78f61741..ac286d85 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@fastify/routes": "^5.1.0", "@fastify/type-provider-json-schema-to-ts": "^2.2.2", "@peculiar/webcrypto": "^1.4.3", - "@relaycorp/cloudevents-transport": "^1.3.0", + "@relaycorp/cloudevents-transport": "^1.3.9", "@relaycorp/dnssec": "^1.11.4", "@relaycorp/pino-cloud": "^1.0.28", "@relaycorp/veraid": "^1.14.2", diff --git a/src/utilities/eventing/Emitter.spec.ts b/src/utilities/eventing/Emitter.spec.ts index d05042b8..83a56ab1 100644 --- a/src/utilities/eventing/Emitter.spec.ts +++ b/src/utilities/eventing/Emitter.spec.ts @@ -1,8 +1,9 @@ import { jest } from '@jest/globals'; import { CloudEvent } from 'cloudevents'; +import envVar from 'env-var'; import { mockSpy } from '../../testUtils/jest.js'; -import { CE_ID, CE_SOURCE, CE_TRANSPORT } from '../../testUtils/eventing/stubs.js'; +import { CE_ID, CE_SOURCE, CE_TRANSPORT, K_SINK } from '../../testUtils/eventing/stubs.js'; import { configureMockEnvVars } from '../../testUtils/envVars.js'; const mockEmitterFunction = mockSpy(jest.fn()); @@ -14,9 +15,9 @@ const { Emitter } = await import('./Emitter.js'); const { makeEmitter } = await import('@relaycorp/cloudevents-transport'); describe('Emitter', () => { - describe('init', () => { - const mockEnvVars = configureMockEnvVars({ CE_TRANSPORT }); + const mockEnvVars = configureMockEnvVars({ CE_TRANSPORT, K_SINK }); + describe('init', () => { test('Emitter function should not be initialised', () => { Emitter.init(); @@ -61,7 +62,22 @@ describe('Emitter', () => { await emitter.emit(event); - expect(makeEmitter).toHaveBeenCalledWith(CE_TRANSPORT); + expect(makeEmitter).toHaveBeenCalledWith(CE_TRANSPORT, expect.anything()); + }); + + test('Channel specified in K_SINK should be used', async () => { + const emitter = new Emitter(CE_TRANSPORT); + + await emitter.emit(event); + + expect(makeEmitter).toHaveBeenCalledWith(expect.anything(), K_SINK); + }); + + test('Environment variable K_SINK should be defined', async () => { + mockEnvVars({ K_SINK: undefined }); + const emitter = new Emitter(CE_TRANSPORT); + + await expect(emitter.emit(event)).rejects.toThrowWithMessage(envVar.EnvVarError, /K_SINK/u); }); }); }); diff --git a/src/utilities/eventing/Emitter.ts b/src/utilities/eventing/Emitter.ts index 6134b56b..44bd1fda 100644 --- a/src/utilities/eventing/Emitter.ts +++ b/src/utilities/eventing/Emitter.ts @@ -22,7 +22,8 @@ export class Emitter { public async emit(event: CloudEvent): Promise { if (this.emitterFunction === undefined) { - this.emitterFunction = await makeEmitter(this.transport); + const channel = envVar.get('K_SINK').required().asString(); + this.emitterFunction = await makeEmitter(this.transport, channel); } await this.emitterFunction(event); }