Skip to content

Commit f024a84

Browse files
authored
Introduce envconfig package (#1795)
1 parent 4c84fc8 commit f024a84

File tree

19 files changed

+1890
-7
lines changed

19 files changed

+1890
-7
lines changed

package-lock.json

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@temporalio/cloud": "file:packages/cloud",
4343
"@temporalio/common": "file:packages/common",
4444
"@temporalio/create": "file:packages/create-project",
45+
"@temporalio/envconfig": "file:packages/envconfig",
4546
"@temporalio/interceptors-opentelemetry": "file:packages/interceptors-opentelemetry",
4647
"@temporalio/nexus": "file:packages/nexus",
4748
"@temporalio/nyc-test-coverage": "file:packages/nyc-test-coverage",
@@ -87,6 +88,7 @@
8788
"packages/common",
8889
"packages/core-bridge",
8990
"packages/create-project",
91+
"packages/envconfig",
9092
"packages/interceptors-opentelemetry",
9193
"packages/nexus",
9294
"packages/nyc-test-coverage",

packages/client/src/connection.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,13 @@ function normalizeGRPCConfig(options?: ConnectionOptions): ConnectionOptions {
204204
if (credentials) {
205205
throw new TypeError('Both `tls` and `credentials` ConnectionOptions were provided');
206206
}
207+
const serverRootCert = tls.serverRootCACertificate && Buffer.from(tls.serverRootCACertificate);
208+
const clientCertKey = tls.clientCertPair?.key && Buffer.from(tls.clientCertPair?.key);
209+
const clientCertCrt = tls.clientCertPair?.crt && Buffer.from(tls.clientCertPair?.crt);
207210
return {
208211
...rest,
209212
credentials: grpc.credentials.combineChannelCredentials(
210-
grpc.credentials.createSsl(tls.serverRootCACertificate, tls.clientCertPair?.key, tls.clientCertPair?.crt),
213+
grpc.credentials.createSsl(serverRootCert, clientCertKey, clientCertCrt),
211214
...(callCredentials ?? [])
212215
),
213216
channelArgs: {

packages/common/src/internal-non-workflow/tls-config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export interface TLSConfig {
1212
* Root CA certificate used by the server. If not set, and the server's
1313
* cert is issued by someone the operating system trusts, verification will still work (ex: Cloud offering).
1414
*/
15-
serverRootCACertificate?: Buffer;
15+
serverRootCACertificate?: Uint8Array;
1616
/** Sets the client certificate and key for connecting with mTLS */
1717
clientCertPair?: {
1818
/** The certificate for this client */
19-
crt: Buffer;
19+
crt: Uint8Array;
2020
/** The private key for this client */
21-
key: Buffer;
21+
key: Uint8Array;
2222
};
2323
}
2424

packages/envconfig/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# `@temporalio/envconfig`
2+
3+
[![NPM](https://img.shields.io/npm/v/@temporalio/envconfig?style=for-the-badge)](https://www.npmjs.com/package/@temporalio/envconfig)
4+
5+
Part of [Temporal](https://temporal.io)'s [TypeScript SDK](https://docs.temporal.io/typescript/introduction/).

packages/envconfig/package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "@temporalio/envconfig",
3+
"version": "0.0.1",
4+
"description": "Temporal.io SDK Environment Configuration sub-package",
5+
"main": "lib/index.js",
6+
"types": "./lib/index.d.ts",
7+
"scripts": {},
8+
"keywords": [
9+
"temporal",
10+
"environment",
11+
"configuration",
12+
"client"
13+
],
14+
"author": "Temporal Technologies Inc. <sdk@temporal.io>",
15+
"license": "MIT",
16+
"dependencies": {
17+
"@temporalio/common": "file:../common",
18+
"smol-toml": "1.4.2"
19+
},
20+
"devDependencies": {
21+
"@temporalio/worker": "file:../worker"
22+
},
23+
"engines": {
24+
"node": ">= 18.0.0"
25+
},
26+
"bugs": {
27+
"url": "https://github.com/temporalio/sdk-typescript/issues"
28+
},
29+
"repository": {
30+
"type": "git",
31+
"url": "git+https://github.com/temporalio/sdk-typescript.git",
32+
"directory": "packages/envconfig"
33+
},
34+
"homepage": "https://github.com/temporalio/sdk-typescript/tree/main/packages/envconfig",
35+
"publishConfig": {
36+
"access": "public"
37+
},
38+
"files": [
39+
"src",
40+
"lib"
41+
]
42+
}

0 commit comments

Comments
 (0)