@hatchet-dev/typescript-sdk 0.1.27 → 0.1.28
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.
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { ChannelCredentials } from 'nice-grpc';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
declare const ClientTLSConfigSchema: z.ZodObject<{
|
|
4
|
-
tls_strategy: z.ZodOptional<z.ZodEnum<["tls", "mtls"]>>;
|
|
4
|
+
tls_strategy: z.ZodOptional<z.ZodEnum<["tls", "mtls", "none"]>>;
|
|
5
5
|
cert_file: z.ZodOptional<z.ZodString>;
|
|
6
6
|
ca_file: z.ZodOptional<z.ZodString>;
|
|
7
7
|
key_file: z.ZodOptional<z.ZodString>;
|
|
8
8
|
server_name: z.ZodOptional<z.ZodString>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
tls_strategy?: "tls" | "mtls" | undefined;
|
|
10
|
+
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
11
11
|
cert_file?: string | undefined;
|
|
12
12
|
ca_file?: string | undefined;
|
|
13
13
|
key_file?: string | undefined;
|
|
14
14
|
server_name?: string | undefined;
|
|
15
15
|
}, {
|
|
16
|
-
tls_strategy?: "tls" | "mtls" | undefined;
|
|
16
|
+
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
17
17
|
cert_file?: string | undefined;
|
|
18
18
|
ca_file?: string | undefined;
|
|
19
19
|
key_file?: string | undefined;
|
|
@@ -22,19 +22,19 @@ declare const ClientTLSConfigSchema: z.ZodObject<{
|
|
|
22
22
|
export declare const ClientConfigSchema: z.ZodObject<{
|
|
23
23
|
token: z.ZodString;
|
|
24
24
|
tls_config: z.ZodObject<{
|
|
25
|
-
tls_strategy: z.ZodOptional<z.ZodEnum<["tls", "mtls"]>>;
|
|
25
|
+
tls_strategy: z.ZodOptional<z.ZodEnum<["tls", "mtls", "none"]>>;
|
|
26
26
|
cert_file: z.ZodOptional<z.ZodString>;
|
|
27
27
|
ca_file: z.ZodOptional<z.ZodString>;
|
|
28
28
|
key_file: z.ZodOptional<z.ZodString>;
|
|
29
29
|
server_name: z.ZodOptional<z.ZodString>;
|
|
30
30
|
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
tls_strategy?: "tls" | "mtls" | undefined;
|
|
31
|
+
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
32
32
|
cert_file?: string | undefined;
|
|
33
33
|
ca_file?: string | undefined;
|
|
34
34
|
key_file?: string | undefined;
|
|
35
35
|
server_name?: string | undefined;
|
|
36
36
|
}, {
|
|
37
|
-
tls_strategy?: "tls" | "mtls" | undefined;
|
|
37
|
+
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
38
38
|
cert_file?: string | undefined;
|
|
39
39
|
ca_file?: string | undefined;
|
|
40
40
|
key_file?: string | undefined;
|
|
@@ -47,7 +47,7 @@ export declare const ClientConfigSchema: z.ZodObject<{
|
|
|
47
47
|
}, "strip", z.ZodTypeAny, {
|
|
48
48
|
token: string;
|
|
49
49
|
tls_config: {
|
|
50
|
-
tls_strategy?: "tls" | "mtls" | undefined;
|
|
50
|
+
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
51
51
|
cert_file?: string | undefined;
|
|
52
52
|
ca_file?: string | undefined;
|
|
53
53
|
key_file?: string | undefined;
|
|
@@ -60,7 +60,7 @@ export declare const ClientConfigSchema: z.ZodObject<{
|
|
|
60
60
|
}, {
|
|
61
61
|
token: string;
|
|
62
62
|
tls_config: {
|
|
63
|
-
tls_strategy?: "tls" | "mtls" | undefined;
|
|
63
|
+
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
64
64
|
cert_file?: string | undefined;
|
|
65
65
|
ca_file?: string | undefined;
|
|
66
66
|
key_file?: string | undefined;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ClientConfigSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const ClientTLSConfigSchema = zod_1.z.object({
|
|
6
|
-
tls_strategy: zod_1.z.enum(['tls', 'mtls']).optional(),
|
|
6
|
+
tls_strategy: zod_1.z.enum(['tls', 'mtls', 'none']).optional(),
|
|
7
7
|
cert_file: zod_1.z.string().optional(),
|
|
8
8
|
ca_file: zod_1.z.string().optional(),
|
|
9
9
|
key_file: zod_1.z.string().optional(),
|
package/package.json
CHANGED
|
@@ -44,6 +44,9 @@ class ConfigLoader {
|
|
|
44
44
|
server_name: (_m = (_l = yaml === null || yaml === void 0 ? void 0 : yaml.tls_config) === null || _l === void 0 ? void 0 : _l.server_name) !== null && _m !== void 0 ? _m : this.env('HATCHET_CLIENT_TLS_SERVER_NAME'),
|
|
45
45
|
};
|
|
46
46
|
const token = (_p = (_o = override === null || override === void 0 ? void 0 : override.token) !== null && _o !== void 0 ? _o : yaml === null || yaml === void 0 ? void 0 : yaml.token) !== null && _p !== void 0 ? _p : this.env('HATCHET_CLIENT_TOKEN');
|
|
47
|
+
if (!token) {
|
|
48
|
+
throw new Error('No token provided. Provide it by setting the HATCHET_CLIENT_TOKEN environment variable.');
|
|
49
|
+
}
|
|
47
50
|
let grpcBroadcastAddress;
|
|
48
51
|
let apiUrl;
|
|
49
52
|
const tenantId = (0, token_1.getTenantIdFromJWT)(token);
|
|
@@ -74,6 +77,10 @@ class ConfigLoader {
|
|
|
74
77
|
return p.join(process.cwd(), DEFAULT_CONFIG_FILE);
|
|
75
78
|
}
|
|
76
79
|
static createCredentials(config) {
|
|
80
|
+
// if none, create insecure credentials
|
|
81
|
+
if (config.tls_strategy === 'none') {
|
|
82
|
+
return nice_grpc_1.ChannelCredentials.createInsecure();
|
|
83
|
+
}
|
|
77
84
|
if (config.tls_strategy === 'tls') {
|
|
78
85
|
const rootCerts = config.ca_file ? (0, fs_1.readFileSync)(config.ca_file) : undefined;
|
|
79
86
|
return nice_grpc_1.ChannelCredentials.createSsl(rootCerts);
|