@contract-case/case-connector 0.29.1 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +19 -0
  3. package/dist/cjs/src/connectors/case-boundary/internals/BoundaryPluginLoader.cjs +16 -4
  4. package/dist/cjs/src/connectors/case-boundary/internals/BoundaryPluginLoader.d.ts.map +1 -1
  5. package/dist/cjs/src/connectors/case-boundary/internals/BoundaryPluginLoader.js.map +1 -1
  6. package/dist/cjs/src/connectors/grpc/authTokenInterceptor.cjs +41 -0
  7. package/dist/cjs/src/connectors/grpc/authTokenInterceptor.d.cts +14 -0
  8. package/dist/cjs/src/connectors/grpc/authTokenInterceptor.d.ts.map +1 -0
  9. package/dist/cjs/src/connectors/grpc/authTokenInterceptor.js.map +1 -0
  10. package/dist/cjs/src/connectors/grpc/contract-case-stream.d.mts +7 -1
  11. package/dist/cjs/src/connectors/grpc/contract-case-stream.d.mts.map +1 -1
  12. package/dist/cjs/src/connectors/grpc/contract-case-stream.mjs +18 -3
  13. package/dist/cjs/src/connectors/grpc/contract-case-stream.mjs.map +1 -1
  14. package/dist/cjs/src/entities/versionString.cjs +1 -1
  15. package/dist/cjs/src/entities/versionString.d.cts +1 -1
  16. package/dist/cjs/tsconfig.56c70853.tsbuildinfo +1 -0
  17. package/dist/src/connectors/case-boundary/internals/BoundaryPluginLoader.d.ts.map +1 -1
  18. package/dist/src/connectors/case-boundary/internals/BoundaryPluginLoader.js +16 -4
  19. package/dist/src/connectors/case-boundary/internals/BoundaryPluginLoader.js.map +1 -1
  20. package/dist/src/connectors/grpc/authTokenInterceptor.d.ts +14 -0
  21. package/dist/src/connectors/grpc/authTokenInterceptor.d.ts.map +1 -0
  22. package/dist/src/connectors/grpc/authTokenInterceptor.js +37 -0
  23. package/dist/src/connectors/grpc/authTokenInterceptor.js.map +1 -0
  24. package/dist/src/connectors/grpc/contract-case-stream.d.mts +7 -1
  25. package/dist/src/connectors/grpc/contract-case-stream.d.mts.map +1 -1
  26. package/dist/src/connectors/grpc/contract-case-stream.mjs +18 -3
  27. package/dist/src/connectors/grpc/contract-case-stream.mjs.map +1 -1
  28. package/dist/src/entities/versionString.d.ts +1 -1
  29. package/dist/src/entities/versionString.js +1 -1
  30. package/dist/tsconfig.build.tsbuildinfo +1 -1
  31. package/package/case-connector.js +2 -2
  32. package/package/case-connector.js.LICENSE.txt +6 -0
  33. package/package/case-connector.js.map +1 -1
  34. package/package.json +10 -10
  35. package/src/connectors/grpc/contract-case-stream.mts +22 -4
  36. package/dist/cjs/tsconfig.557bacae.tsbuildinfo +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.30.0](https://github.com/case-contract-testing/contract-case/compare/@contract-case/case-connector-v0.29.1...@contract-case/case-connector-v0.30.0) (2026-07-05)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **@contract-case/case-connector:** Synchronize ContractCase versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @contract-case/case-connector-proto bumped from 0.29.1 to 0.30.0
16
+ * @contract-case/case-core bumped from 0.29.1 to 0.30.0
17
+ * @contract-case/case-entities-internal bumped from 0.29.1 to 0.30.0
18
+ * devDependencies
19
+ * @contract-case/case-maintainer-config bumped from 0.29.1 to 0.30.0
20
+ * @contract-case/eslint-config-case-maintainer bumped from 0.29.1 to 0.30.0
21
+
3
22
  ## [0.29.1](https://github.com/case-contract-testing/contract-case/compare/@contract-case/case-connector-v0.29.0...@contract-case/case-connector-v0.29.1) (2026-06-04)
4
23
 
5
24
 
package/README.md CHANGED
@@ -15,3 +15,22 @@ bug, by exposing the communication layer as a gRPC service.
15
15
  Additionally, it exposes the boundary layer as `@contract-case/case-connector` for ESM imports, and `@contract-case/case-connector/cjs` for CJS imports.
16
16
 
17
17
  For details of the protocol schema, see the case-connector-proto package.
18
+
19
+ ## Authentication
20
+
21
+ The connector binds to the loopback interface only, on a free port that it
22
+ announces on stdout in the form:
23
+
24
+ ```
25
+ [SERVER] Started on port: <PORT>
26
+ ```
27
+
28
+ To prevent other local processes from connecting to it, wrappers must
29
+ generate an unguessable random token and pass it to the connector process via
30
+ the `CASE_CONNECTOR_TOKEN` environment variable. The connector rejects (with
31
+ `UNAUTHENTICATED`) any call that doesn't present the same token in the
32
+ `authorization` metadata of the gRPC call.
33
+
34
+ If `CASE_CONNECTOR_TOKEN` is not set, the connector refuses to start. This
35
+ means the connector always requires a compatible wrapper (any wrapper released
36
+ after the token was introduced).
@@ -48,10 +48,22 @@ class BoundaryPluginLoader {
48
48
  }
49
49
  async loadPlugins(moduleNames) {
50
50
  this.initialiseLoader();
51
- return Promise.all(moduleNames.map(
52
- // webpack ignore is needed here so that the final bundle for host
53
- // languages is able to import arbitrary libs, without webpack failing
54
- (moduleName) => import(/* webpackIgnore: true */ moduleName)))
51
+ return Promise.all(moduleNames.map((moduleName) => {
52
+ if (
53
+ // Forbid URIs
54
+ moduleName.includes(':') ||
55
+ // Forbid strings that start with '.', as they may be hidden files or path traversal
56
+ moduleName.startsWith('.') ||
57
+ // Forbid strings that start with / , as only local packages are supported
58
+ moduleName.startsWith('/') ||
59
+ // Forbid strings that don't look like node module names
60
+ !/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(?:\/[a-z0-9][a-z0-9._-]*)*$/i.test(moduleName)) {
61
+ throw new case_core_1.CaseConfigurationError(`Unsafe plugin module specifier. Plugin names must be a valid local nodejs package name, and may not be remote or inline URIs. Provided name was: '${moduleName}'`, 'DONT_ADD_LOCATION', 'INVALID_PLUGIN_NAME');
62
+ }
63
+ // webpack ignore is needed here so that the final bundle for host
64
+ // languages is able to import arbitrary libs, without webpack failing
65
+ return import(/* webpackIgnore: true */ moduleName);
66
+ }))
55
67
  .then((plugins) => {
56
68
  if (this.loader == null) {
57
69
  throw new case_core_1.CaseCoreError('this.loader was not initialised during loadPlugins. This should never happen, as initialiseLoader() is meant to be called first');
@@ -1 +1 @@
1
- {"version":3,"file":"BoundaryPluginLoader.d.ts","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/BoundaryPluginLoader.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,0BAA0B,EAC1B,WAAW,EACX,cAAc,EACd,cAAc,EACf,MAAM,qBAAqB,CAAC;AAS7B;;;;GAIG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAA2B;IAEzC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6B;IAE/D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAc;IAEzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAE/C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAW;IAE1C;;;;;;;;;;OAUG;gBAED,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,WAAW,EACvB,aAAa,EAAE,cAAc,EAC7B,cAAc,EAAE,MAAM,EAAE;IAc1B,OAAO,CAAC,gBAAgB;IAYlB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;CA6BlE"}
1
+ {"version":3,"file":"BoundaryPluginLoader.d.ts","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/BoundaryPluginLoader.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,0BAA0B,EAC1B,WAAW,EACX,cAAc,EACd,cAAc,EACf,MAAM,qBAAqB,CAAC;AAS7B;;;;GAIG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAA2B;IAEzC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6B;IAE/D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAc;IAEzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAE/C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAW;IAE1C;;;;;;;;;;OAUG;gBAED,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,WAAW,EACvB,aAAa,EAAE,cAAc,EAC7B,cAAc,EAAE,MAAM,EAAE;IAc1B,OAAO,CAAC,gBAAgB;IAYlB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;CA+ClE"}
@@ -1 +1 @@
1
- {"version":3,"file":"BoundaryPluginLoader.js","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/BoundaryPluginLoader.ts"],"names":[],"mappings":";;;AAAA,wDAIkC;AAQlC,yEAAmE;AACnE,iDAI4B;AAC5B,yCAA6C;AAE7C;;;;GAIG;AACH,MAAa,oBAAoB;IACvB,MAAM,CAA2B;IAExB,iBAAiB,CAA6B;IAE9C,UAAU,CAAc;IAExB,aAAa,CAAiB;IAE9B,cAAc,CAAW;IAE1C;;;;;;;;;;OAUG;IACH,YACE,MAAkC,EAClC,UAAuB,EACvB,aAA6B,EAC7B,cAAwB;QAExB,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,sDAAsD;QACtD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,gCAAa,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,cAAc,EAAE,gCAAa,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACvC,CAAC;IACH,CAAC;IAEO,gBAAgB;QACtB,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,wBAAa,EAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAEzD,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAY,CAC5B,MAAM,EACN,IAAA,yBAAc,EAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,EACnD,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,WAAqB;QACrC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC,GAAG,CAChB,WAAW,CAAC,GAAG;QACb,kEAAkE;QAClE,sEAAsE;QACtE,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAC7D,CACF;aACE,IAAI,CACH,CAAC,OAAO,EAAE,EAAE;YACV,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;gBACxB,MAAM,IAAI,yBAAa,CACrB,iIAAiI,CAClI,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC,EACD,CAAC,CAAC,EAAE,EAAE;YACJ,MAAM,IAAI,kCAAsB,CAC9B,0BAA0B,CAAC,CAAC,OAAO,EAAE,EACrC,mBAAmB,EACnB,cAAc,CACf,CAAC;QACJ,CAAC,CACF;aACA,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,0BAAe,EAAE,CAAC;aACjC,KAAK,CAAC,2BAAgB,CAAC,CAAC;IAC7B,CAAC;CACF;AAjFD,oDAiFC"}
1
+ {"version":3,"file":"BoundaryPluginLoader.js","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/BoundaryPluginLoader.ts"],"names":[],"mappings":";;;AAAA,wDAIkC;AAQlC,yEAAmE;AACnE,iDAI4B;AAC5B,yCAA6C;AAE7C;;;;GAIG;AACH,MAAa,oBAAoB;IACvB,MAAM,CAA2B;IAExB,iBAAiB,CAA6B;IAE9C,UAAU,CAAc;IAExB,aAAa,CAAiB;IAE9B,cAAc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xD,CAAC,gFAAgF,CAAC,IAAI,CACpF,UAAU,CACX,EACD,CAAC;gBACD,MAAM,IAAI,kCAAsB,CAC9B,qJAAqJ,UAAU,GAAG,EAClK,mBAAmB,EACnB,qBAAqB,CACtB,CAAC;YACJ,CAAC;YACD,kEAAkE;YAClE,sEAAsE;YACtE,OAAO,MAAM,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC;QACtD,CAAC,CAAC,CACH;aACE,IAAI,CACH,CAAC,OAAO,EAAE,EAAE;YACV,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;gBACxB,MAAM,IAAI,yBAAa,CACrB,iIAAiI,CAClI,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC,EACD,CAAC,CAAC,EAAE,EAAE;YACJ,MAAM,IAAI,kCAAsB,CAC9B,0BAA0B,CAAC,CAAC,OAAO,EAAE,EACrC,mBAAmB,EACnB,cAAc,CACf,CAAC;QACJ,CAAC,CACF;aACA,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,0BAAe,EAAE,CAAC;aACjC,KAAK,CAAC,2BAAgB,CAAC,CAAC;IAC7B,CAAC;CACF;AAnGD,oDAmGC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeAuthTokenInterceptor = void 0;
4
+ const grpc_js_1 = require("@grpc/grpc-js");
5
+ const node_crypto_1 = require("node:crypto");
6
+ // Comparing hashes rather than the raw values keeps the comparison
7
+ // constant-time even when the provided token has a different length
8
+ const hashToken = (token) => (0, node_crypto_1.createHash)('sha256').update(token, 'utf8').digest();
9
+ /**
10
+ * Creates a server interceptor that rejects any call which doesn't present
11
+ * the expected token in its `authorization` metadata.
12
+ *
13
+ * The token is shared with the client that spawned this connector via the
14
+ * `CASE_CONNECTOR_TOKEN` environment variable, so only that client (or
15
+ * processes it chooses to share the token with) can invoke the connector.
16
+ *
17
+ * @param expectedToken - the token that callers must present
18
+ * @returns a {@link ServerInterceptor} enforcing the token
19
+ */
20
+ const makeAuthTokenInterceptor = (expectedToken) => (_methodDescriptor, call) => new grpc_js_1.ServerInterceptingCall(call, {
21
+ start: (next) => {
22
+ next({
23
+ onReceiveMetadata: (metadata, mdNext) => {
24
+ const provided = metadata.get('authorization');
25
+ if (provided.length === 1 &&
26
+ typeof provided[0] === 'string' &&
27
+ (0, node_crypto_1.timingSafeEqual)(hashToken(provided[0]), hashToken(expectedToken))) {
28
+ mdNext(metadata);
29
+ }
30
+ else {
31
+ call.sendStatus({
32
+ code: grpc_js_1.status.UNAUTHENTICATED,
33
+ details: "This ContractCase connector requires callers to present the token from the CASE_CONNECTOR_TOKEN environment variable in the 'authorization' metadata of each call",
34
+ });
35
+ }
36
+ },
37
+ });
38
+ },
39
+ });
40
+ exports.makeAuthTokenInterceptor = makeAuthTokenInterceptor;
41
+ //# sourceMappingURL=authTokenInterceptor.js.map
@@ -0,0 +1,14 @@
1
+ import { ServerInterceptor } from '@grpc/grpc-js';
2
+ /**
3
+ * Creates a server interceptor that rejects any call which doesn't present
4
+ * the expected token in its `authorization` metadata.
5
+ *
6
+ * The token is shared with the client that spawned this connector via the
7
+ * `CASE_CONNECTOR_TOKEN` environment variable, so only that client (or
8
+ * processes it chooses to share the token with) can invoke the connector.
9
+ *
10
+ * @param expectedToken - the token that callers must present
11
+ * @returns a {@link ServerInterceptor} enforcing the token
12
+ */
13
+ export declare const makeAuthTokenInterceptor: (expectedToken: string) => ServerInterceptor;
14
+ //# sourceMappingURL=authTokenInterceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authTokenInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/grpc/authTokenInterceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAElB,MAAM,eAAe,CAAC;AAQvB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GAClC,eAAe,MAAM,KAAG,iBAuBrB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authTokenInterceptor.js","sourceRoot":"","sources":["../../../../../src/connectors/grpc/authTokenInterceptor.ts"],"names":[],"mappings":";;;AAAA,2CAIuB;AACvB,6CAA0D;AAE1D,mEAAmE;AACnE,oEAAoE;AACpE,MAAM,SAAS,GAAG,CAAC,KAAa,EAAU,EAAE,CAC1C,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;AAEtD;;;;;;;;;;GAUG;AACI,MAAM,wBAAwB,GACnC,CAAC,aAAqB,EAAqB,EAAE,CAC7C,CAAC,iBAAiB,EAAE,IAAI,EAAE,EAAE,CAC1B,IAAI,gCAAsB,CAAC,IAAI,EAAE;IAC/B,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;QACd,IAAI,CAAC;YACH,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;gBACtC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBAC/C,IACE,QAAQ,CAAC,MAAM,KAAK,CAAC;oBACrB,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ;oBAC/B,IAAA,6BAAe,EAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,EACjE,CAAC;oBACD,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACnB,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,UAAU,CAAC;wBACd,IAAI,EAAE,gBAAM,CAAC,eAAe;wBAC5B,OAAO,EACL,mKAAmK;qBACtK,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC;AAxBM,QAAA,wBAAwB,4BAwB9B"}
@@ -1,5 +1,11 @@
1
+ import { Server } from '@grpc/grpc-js';
1
2
  /**
2
3
  * Starts a gRPC server for defining and verifying ContractCase contracts
4
+ *
5
+ * @returns the running server and the port it is listening on
3
6
  */
4
- export declare function main(): void;
7
+ export declare function main(): Promise<{
8
+ server: Server;
9
+ port: string;
10
+ }>;
5
11
  //# sourceMappingURL=contract-case-stream.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-case-stream.d.mts","sourceRoot":"","sources":["../../../../../src/connectors/grpc/contract-case-stream.mts"],"names":[],"mappings":"AAgCA;;GAEG;AACH,wBAAgB,IAAI,IAAI,IAAI,CAkC3B"}
1
+ {"version":3,"file":"contract-case-stream.d.mts","sourceRoot":"","sources":["../../../../../src/connectors/grpc/contract-case-stream.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,eAAe,CAAC;AAiC1D;;;;GAIG;AACH,wBAAgB,IAAI,IAAI,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAiDhE"}
@@ -3,6 +3,7 @@ import { ContractCaseService } from '@contract-case/case-connector-proto';
3
3
  import getPort from 'get-port';
4
4
  import { contractDefinition } from './contractDefinition.js';
5
5
  import { contractVerification } from './contractVerification.js';
6
+ import { makeAuthTokenInterceptor } from './authTokenInterceptor.js';
6
7
  import { versionString } from '../../entities/versionString.js';
7
8
  import { maintainerLog } from '../../domain/maintainerLog.js';
8
9
  const bind = (server, host, freePort) => new Promise((resolve, reject) => {
@@ -19,11 +20,24 @@ const bind = (server, host, freePort) => new Promise((resolve, reject) => {
19
20
  });
20
21
  /**
21
22
  * Starts a gRPC server for defining and verifying ContractCase contracts
23
+ *
24
+ * @returns the running server and the port it is listening on
22
25
  */
23
26
  export function main() {
24
27
  maintainerLog(`Starting ContractCase ${versionString}`);
25
- const server = new Server();
26
- getPort().then((freePort) => {
28
+ // Only calls that present this token are accepted
29
+ // - see authTokenInterceptor for details
30
+ const authToken = process.env['CASE_CONNECTOR_TOKEN'];
31
+ if (authToken == null || authToken === '') {
32
+ // Console used here because there's nothing sensible we can do with this error
33
+ // eslint-disable-next-line no-console
34
+ console.error(`[${versionString}]`, "ContractCase's internal server requires the CASE_CONNECTOR_TOKEN environment variable to be set to an unguessable random secret, so that only the client that started the server can connect to it");
35
+ process.exit(1);
36
+ }
37
+ const server = new Server({
38
+ interceptors: [makeAuthTokenInterceptor(authToken)],
39
+ });
40
+ return getPort().then((freePort) => {
27
41
  server.addService(ContractCaseService, {
28
42
  contractDefinition,
29
43
  contractVerification,
@@ -39,11 +53,12 @@ export function main() {
39
53
  // Must have the port number after the `:`
40
54
  // eslint-disable-next-line no-console
41
55
  console.log('[SERVER]', `Started on port: ${port}`);
56
+ return { server, port };
42
57
  }, (error) => {
43
58
  // Console used here because there's nothing sensible we can do with this error
44
59
  // eslint-disable-next-line no-console
45
60
  console.error(`[${versionString}]`, `ContractCase's internal server was unable to start: ${error}`);
46
- process.exit(1);
61
+ return process.exit(1);
47
62
  });
48
63
  });
49
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"contract-case-stream.mjs","sourceRoot":"","sources":["../../../../../src/connectors/grpc/contract-case-stream.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAI9D,MAAM,IAAI,GAAG,CACX,MAAc,EACd,IAAY,EACZ,QAAgB,EACK,EAAE,CACvB,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM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AC,CAAC;QACtD,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;YACR,+EAA+E;YAC/E,sCAAsC;YACtC,OAAO,CAAC,KAAK,CACX,IAAI,aAAa,GAAG,EACpB,uDAAuD,KAAK,EAAE,CAC/D,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CACF,CAAC;IACN,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"contract-case-stream.mjs","sourceRoot":"","sources":["../../../../../src/connectors/grpc/contract-case-stream.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAI9D,MAAM,IAAI,GAAG,CACX,MAAc,EACd,IAAY,EACZ,QAAgB,EACK,EAAE,CACvB,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9B,MAAM,OAAO,GAAG,GAAG,IAAI,IAAI,QAAQ,EAAE,CAAC;IACtC,aAAa,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,SAAS,CACd,OAAO,EACP,iBAAiB,CAAC,cAAc,EAAE,EAClC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACd,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC;aAAM,CAA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C;YACtC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,oBAAoB,IAAI,EAAE,CAAC,CAAC;YACpD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAC1B,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;YACR,+EAA+E;YAC/E,sCAAsC;YACtC,OAAO,CAAC,KAAK,CACX,IAAI,aAAa,GAAG,EACpB,uDAAuD,KAAK,EAAE,CAC/D,CAAC;YACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC,CACF,CAAC;IACN,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.versionString = void 0;
4
4
  const packageName = 'case-connector';
5
- const version = '0.29.1'; // x-release-please-version
5
+ const version = '0.30.0'; // x-release-please-version
6
6
  exports.versionString = `${packageName}@${version}`;
7
7
  //# sourceMappingURL=versionString.js.map
@@ -1,2 +1,2 @@
1
- export declare const versionString = "case-connector@0.29.1";
1
+ export declare const versionString = "case-connector@0.30.0";
2
2
  //# sourceMappingURL=versionString.d.ts.map