Skip to content

Commit d5e799f

Browse files
committed
build: release v5.3.0
1 parent 07568b6 commit d5e799f

File tree

8 files changed

+115
-16
lines changed

8 files changed

+115
-16
lines changed

dist/client.cjs

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ var CustomLongAvroType = import_avro_js.default.types.LongType.using({
146146

147147
// src/utils/configurationLoader.js
148148
var DEFAULT_PUB_SUB_ENDPOINT = "api.pubsub.salesforce.com:7443";
149+
var DEFAULT_REJECT_UNAUTHORIZED_SSL = true;
149150
var ConfigurationLoader = class _ConfigurationLoader {
150151
/**
151152
* @param {Configuration} config the client configuration
@@ -186,8 +187,53 @@ var ConfigurationLoader = class _ConfigurationLoader {
186187
`Unsupported authType value: ${config.authType}`
187188
);
188189
}
190+
_ConfigurationLoader.#loadBooleanValue(
191+
config,
192+
"rejectUnauthorizedSsl",
193+
DEFAULT_REJECT_UNAUTHORIZED_SSL
194+
);
189195
return config;
190196
}
197+
/**
198+
* Loads a boolean value from a config key.
199+
* Falls back to the provided default value if no value is specified.
200+
* Errors out if the config value can't be converted to a boolean value.
201+
* @param {Configuration} config
202+
* @param {string} key
203+
* @param {boolean} defaultValue
204+
*/
205+
static #loadBooleanValue(config, key, defaultValue) {
206+
if (!Object.hasOwn(config, key) || config[key] === void 0 || config[key] === null) {
207+
config[key] = defaultValue;
208+
return;
209+
}
210+
const value = config[key];
211+
const type = typeof value;
212+
switch (type) {
213+
case "boolean":
214+
break;
215+
case "string":
216+
{
217+
switch (value.toUppercase()) {
218+
case "TRUE":
219+
config[key] = true;
220+
break;
221+
case "FALSE":
222+
config[key] = false;
223+
break;
224+
default:
225+
throw new Error(
226+
`Expected boolean value for ${key}, found ${type} with value ${value}`
227+
);
228+
}
229+
}
230+
break;
231+
default:
232+
throw new Error(
233+
`Expected boolean value for ${key}, found ${type} with value ${value}`
234+
);
235+
}
236+
}
191237
/**
192238
* @param {Configuration} config the client configuration
193239
* @returns {Configuration} sanitized configuration
@@ -482,11 +528,6 @@ var SalesforceAuth = class {
482528
*/
483529
async #authWithJwtBearer() {
484530
const { clientId, username, loginUrl, privateKey } = this.#config;
485-
if (!privateKey.toString().trim().startsWith("-----BEGIN RSA PRIVATE KEY-----")) {
486-
throw new Error(
487-
`Private key is missing -----BEGIN RSA PRIVATE KEY----- header`
488-
);
489-
}
490531
const header = JSON.stringify({ alg: "RS256" });
491532
const claims = JSON.stringify({
492533
iss: clientId,
@@ -646,7 +687,9 @@ var PubSubApiClient = class {
646687
};
647688
const callCreds = import_grpc_js.default.credentials.createFromMetadataGenerator(metaCallback);
648689
const combCreds = import_grpc_js.default.credentials.combineChannelCredentials(
649-
import_grpc_js.default.credentials.createSsl(rootCert),
690+
import_grpc_js.default.credentials.createSsl(rootCert, null, null, {
691+
rejectUnauthorized: this.#config.rejectUnauthorizedSsl
692+
}),
650693
callCreds
651694
);
652695
this.#client = new sfdcPackage.PubSub(

dist/client.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/client.js

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ var CustomLongAvroType = avro.types.LongType.using({
113113

114114
// src/utils/configurationLoader.js
115115
var DEFAULT_PUB_SUB_ENDPOINT = "api.pubsub.salesforce.com:7443";
116+
var DEFAULT_REJECT_UNAUTHORIZED_SSL = true;
116117
var ConfigurationLoader = class _ConfigurationLoader {
117118
/**
118119
* @param {Configuration} config the client configuration
@@ -153,8 +154,53 @@ var ConfigurationLoader = class _ConfigurationLoader {
153154
`Unsupported authType value: ${config.authType}`
154155
);
155156
}
157+
_ConfigurationLoader.#loadBooleanValue(
158+
config,
159+
"rejectUnauthorizedSsl",
160+
DEFAULT_REJECT_UNAUTHORIZED_SSL
161+
);
156162
return config;
157163
}
164+
/**
165+
* Loads a boolean value from a config key.
166+
* Falls back to the provided default value if no value is specified.
167+
* Errors out if the config value can't be converted to a boolean value.
168+
* @param {Configuration} config
169+
* @param {string} key
170+
* @param {boolean} defaultValue
171+
*/
172+
static #loadBooleanValue(config, key, defaultValue) {
173+
if (!Object.hasOwn(config, key) || config[key] === void 0 || config[key] === null) {
174+
config[key] = defaultValue;
175+
return;
176+
}
177+
const value = config[key];
178+
const type = typeof value;
179+
switch (type) {
180+
case "boolean":
181+
break;
182+
case "string":
183+
{
184+
switch (value.toUppercase()) {
185+
case "TRUE":
186+
config[key] = true;
187+
break;
188+
case "FALSE":
189+
config[key] = false;
190+
break;
191+
default:
192+
throw new Error(
193+
`Expected boolean value for ${key}, found ${type} with value ${value}`
194+
);
195+
}
196+
}
197+
break;
198+
default:
199+
throw new Error(
200+
`Expected boolean value for ${key}, found ${type} with value ${value}`
201+
);
202+
}
203+
}
158204
/**
159205
* @param {Configuration} config the client configuration
160206
* @returns {Configuration} sanitized configuration
@@ -449,11 +495,6 @@ var SalesforceAuth = class {
449495
*/
450496
async #authWithJwtBearer() {
451497
const { clientId, username, loginUrl, privateKey } = this.#config;
452-
if (!privateKey.toString().trim().startsWith("-----BEGIN RSA PRIVATE KEY-----")) {
453-
throw new Error(
454-
`Private key is missing -----BEGIN RSA PRIVATE KEY----- header`
455-
);
456-
}
457498
const header = JSON.stringify({ alg: "RS256" });
458499
const claims = JSON.stringify({
459500
iss: clientId,
@@ -613,7 +654,9 @@ var PubSubApiClient = class {
613654
};
614655
const callCreds = grpc.credentials.createFromMetadataGenerator(metaCallback);
615656
const combCreds = grpc.credentials.combineChannelCredentials(
616-
grpc.credentials.createSsl(rootCert),
657+
grpc.credentials.createSsl(rootCert, null, null, {
658+
rejectUnauthorized: this.#config.rejectUnauthorizedSsl
659+
}),
617660
callCreds
618661
);
619662
this.#client = new sfdcPackage.PubSub(

dist/utils/auth.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/utils/configurationLoader.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ export default class ConfigurationLoader {
44
* @returns {Configuration} the sanitized client configuration
55
*/
66
static load(config: Configuration): Configuration;
7+
/**
8+
* Loads a boolean value from a config key.
9+
* Falls back to the provided default value if no value is specified.
10+
* Errors out if the config value can't be converted to a boolean value.
11+
* @param {Configuration} config
12+
* @param {string} key
13+
* @param {boolean} defaultValue
14+
*/
15+
static "__#1@#loadBooleanValue"(config: Configuration, key: string, defaultValue: boolean): void;
716
/**
817
* @param {Configuration} config the client configuration
918
* @returns {Configuration} sanitized configuration

dist/utils/configurationLoader.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/utils/types.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ export type Configuration = {
131131
* Optional organization ID. If you don't provide one, we'll attempt to parse it from the accessToken.
132132
*/
133133
organizationId?: string;
134+
/**
135+
* Optional flag used to accept self-signed SSL certificates for testing purposes when set to `false`. Default is `true` (client rejects self-signed SSL certificates).
136+
*/
137+
rejectUnauthorizedSsl?: boolean;
134138
};
135139
export type Logger = {
136140
debug: Function;

dist/utils/types.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)