@jsforce/jsforce-node 3.2.1 → 3.2.3

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.
package/README.md CHANGED
@@ -60,6 +60,6 @@ See [DEVELOPING.md](./DEVELOPING.md)
60
60
 
61
61
  Your contributions are welcome: both by reporting issues on [GitHub issues](https://github.com/jsforce/jsforce/issues) or pull-requesting patches.
62
62
 
63
- If you want to implement any additional features, to be added to JSforce to our master branch, which may or may not be merged please first check current [opening issues](https://github.com/jsforce/jsforce/issues?q=is%3Aopen) with milestones and confirm whether the feature is on road map or not.
63
+ If you want to implement any additional features, to be added to JSforce to our main branch, which may or may not be merged please first check current [opening issues](https://github.com/jsforce/jsforce/issues?q=is%3Aopen) with milestones and confirm whether the feature is on road map or not.
64
64
 
65
65
  If your feature implementation is brand-new or fixing unsupposed bugs in the library's test cases, please include additional test codes in the `test/` directory.
package/lib/VERSION.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "3.2.1";
1
+ declare const _default: "3.2.3";
2
2
  export default _default;
package/lib/VERSION.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '3.2.1';
3
+ exports.default = '3.2.3';
package/lib/http-api.js CHANGED
@@ -247,7 +247,7 @@ class HttpApi extends events_1.EventEmitter {
247
247
  if (errors.Errors) {
248
248
  return errors.Errors.Error;
249
249
  }
250
- return Array.isArray(errors) ? errors[0] : errors;
250
+ return errors;
251
251
  }
252
252
  /**
253
253
  * Get error message in response
@@ -261,6 +261,15 @@ class HttpApi extends events_1.EventEmitter {
261
261
  catch (e) {
262
262
  // eslint-disable no-empty
263
263
  }
264
+ if (Array.isArray(error)) {
265
+ if (error.length === 1) {
266
+ error = error[0];
267
+ }
268
+ else {
269
+ return new HttpApiError(`Multiple errors returned.
270
+ Check \`error.data\` for the error details`, 'MULTIPLE_API_ERRORS', error);
271
+ }
272
+ }
264
273
  error =
265
274
  typeof error === 'object' &&
266
275
  error !== null &&
@@ -274,9 +283,9 @@ class HttpApi extends events_1.EventEmitter {
274
283
  this._logger.debug(`html response.body: ${response.body}`);
275
284
  return new HttpApiError(`HTTP response contains html content.
276
285
  Check that the org exists and can be reached.
277
- See error.content for the full html response.`, error.errorCode, error.message);
286
+ See \`error.data\` for the full html response.`, error.errorCode, error.message);
278
287
  }
279
- return new HttpApiError(error.message, error.errorCode);
288
+ return error instanceof HttpApiError ? error : new HttpApiError(error.message, error.errorCode, error);
280
289
  }
281
290
  }
282
291
  exports.HttpApi = HttpApi;
@@ -284,13 +293,24 @@ exports.HttpApi = HttpApi;
284
293
  *
285
294
  */
286
295
  class HttpApiError extends Error {
296
+ /**
297
+ * This contains error-specific details, usually returned from the API.
298
+ */
299
+ data;
287
300
  errorCode;
288
- content;
289
- constructor(message, errorCode, content) {
301
+ constructor(message, errorCode, data) {
290
302
  super(message);
291
303
  this.name = errorCode || this.name;
292
304
  this.errorCode = this.name;
293
- this.content = content;
305
+ this.data = data;
306
+ }
307
+ /**
308
+ * This will be removed in the next major (v4)
309
+ *
310
+ * @deprecated use `error.data` instead
311
+ */
312
+ get content() {
313
+ return this.data;
294
314
  }
295
315
  }
296
316
  exports.default = HttpApi;
package/lib/oauth2.js CHANGED
@@ -72,10 +72,11 @@ class OAuth2 {
72
72
  revokeServiceUrl || `${this.loginUrl}/services/oauth2/revoke`;
73
73
  }
74
74
  else {
75
- this.loginUrl = loginUrl || defaultOAuth2Config.loginUrl;
76
- this.authzServiceUrl = `${this.loginUrl}/services/oauth2/authorize`;
77
- this.tokenServiceUrl = `${this.loginUrl}/services/oauth2/token`;
78
- this.revokeServiceUrl = `${this.loginUrl}/services/oauth2/revoke`;
75
+ const loginUrlObject = new URL(loginUrl || defaultOAuth2Config.loginUrl);
76
+ this.loginUrl = loginUrlObject.href;
77
+ this.authzServiceUrl = `${loginUrlObject.origin}/services/oauth2/authorize`;
78
+ this.tokenServiceUrl = `${loginUrlObject.origin}/services/oauth2/token`;
79
+ this.revokeServiceUrl = `${loginUrlObject.origin}/services/oauth2/revoke`;
79
80
  }
80
81
  this.clientId = clientId;
81
82
  this.clientSecret = clientSecret;
@@ -163,7 +164,7 @@ class OAuth2 {
163
164
  * OAuth2 Username-Password Flow (Resource Owner Password Credentials)
164
165
  */
165
166
  async authenticate(username, password) {
166
- if (!this.clientId || !this.clientSecret || !this.redirectUri) {
167
+ if (!this.clientId || !this.clientSecret) {
167
168
  throw new Error('No valid OAuth2 client configuration set');
168
169
  }
169
170
  const ret = await this._postParams({
@@ -172,7 +173,6 @@ class OAuth2 {
172
173
  password,
173
174
  client_id: this.clientId,
174
175
  client_secret: this.clientSecret,
175
- redirect_uri: this.redirectUri,
176
176
  });
177
177
  return ret;
178
178
  }
package/lib/request.js CHANGED
@@ -56,7 +56,7 @@ async function startFetchRequest(request, options, input, output, emitter, count
56
56
  const controller = new abort_controller_1.default();
57
57
  let retryCount = 0;
58
58
  const retryOpts = {
59
- statusCodes: options.retry?.statusCodes ?? [429, 500, 502, 503, 504],
59
+ statusCodes: options.retry?.statusCodes ?? [420, 429, 500, 502, 503, 504],
60
60
  maxRetries: options.retry?.maxRetries ?? 5,
61
61
  minTimeout: options.retry?.minTimeout ?? 500,
62
62
  timeoutFactor: options.retry?.timeoutFactor ?? 2,
@@ -53,6 +53,9 @@ class SessionRefreshDelegate {
53
53
  await this._refreshPromise;
54
54
  this._logger.info('<refresh complete>');
55
55
  }
56
+ catch (err) {
57
+ throw new Error(`Unable to refresh session due to: ${err.message}`);
58
+ }
56
59
  finally {
57
60
  this._refreshPromise = undefined;
58
61
  this._lastRefreshedAt = Date.now();
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "database.com"
11
11
  ],
12
12
  "homepage": "http://github.com/jsforce/jsforce",
13
- "version": "3.2.1",
13
+ "version": "3.2.3",
14
14
  "repository": {
15
15
  "type": "git",
16
16
  "url": "git://github.com/jsforce/jsforce.git"
@@ -19,7 +19,7 @@
19
19
  "licenses": [
20
20
  {
21
21
  "type": "MIT",
22
- "url": "http://github.com/jsforce/jsforce/raw/master/LICENSE"
22
+ "url": "http://github.com/jsforce/jsforce/raw/main/LICENSE"
23
23
  }
24
24
  ],
25
25
  "main": "./index",