@salesforce/core 2.33.2 → 2.35.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [2.35.1](https://github.com/forcedotcom/sfdx-core/compare/v2.35.0...v2.35.1) (2022-02-10)
6
+
7
+ ### Bug Fixes
8
+
9
+ - add error message on failed settings deploy ([e218b1e](https://github.com/forcedotcom/sfdx-core/commit/e218b1e40414ea9e4fec256b74224626d96eff4a))
10
+ - prefer instanceUrl for loginUrl on user:create ([#518](https://github.com/forcedotcom/sfdx-core/issues/518)) ([c070a87](https://github.com/forcedotcom/sfdx-core/commit/c070a871861409dea722e85845eeb91f262ab66f))
11
+
12
+ ## [2.35.0](https://github.com/forcedotcom/sfdx-core/compare/v2.34.2...v2.35.0) (2022-01-25)
13
+
14
+ ### Bug Fixes
15
+
16
+ - jsforce dep and pjson version realign ([#516](https://github.com/forcedotcom/sfdx-core/issues/516)) ([9f35f2f](https://github.com/forcedotcom/sfdx-core/commit/9f35f2f0ce30e996a0b4c88461c2babb536c33f7))
17
+ - refresh auth on a connection, too ([ff32a70](https://github.com/forcedotcom/sfdx-core/commit/ff32a705d87d6e410d06597eefa407b54eeb215d))
18
+
19
+ ### [2.34.2](https://github.com/forcedotcom/sfdx-core/compare/v2.33.2...v2.34.2) (2022-01-25)
20
+
5
21
  ### [2.33.2](https://github.com/forcedotcom/sfdx-core/compare/v2.33.1...v2.33.2) (2022-01-25)
6
22
 
7
23
  ### Bug Fixes
@@ -173,6 +173,11 @@ export declare class Connection extends JSForceConnection {
173
173
  * @param options The query options.
174
174
  */
175
175
  singleRecordQuery<T>(soql: string, options?: SingleRecordQueryOptions): Promise<T>;
176
+ /**
177
+ * Executes a get request on the baseUrl to force an auth refresh
178
+ * Useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes
179
+ */
180
+ refreshAuth(): Promise<void>;
176
181
  private loadInstanceApiVersion;
177
182
  }
178
183
  export declare const SingleRecordQueryErrors: {
package/lib/connection.js CHANGED
@@ -127,6 +127,8 @@ class Connection extends jsforce_1.Connection {
127
127
  delete options.rest;
128
128
  if (rest) {
129
129
  this.logger.debug('deploy with REST');
130
+ // do a quick auth refresh because the raw transport used doesn't handle expired AccessTokens
131
+ await this.refreshAuth();
130
132
  const headers = {
131
133
  Authorization: this && `OAuth ${this.accessToken}`,
132
134
  clientId: this.oauth2 && this.oauth2.clientId,
@@ -182,6 +184,7 @@ class Connection extends jsforce_1.Connection {
182
184
  * @param request HTTP request object or URL to GET request.
183
185
  */
184
186
  async requestRaw(request) {
187
+ await this.refreshAuth();
185
188
  const headers = this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {};
186
189
  kit_1.merge(headers, exports.SFDX_HTTP_HEADERS, request.headers);
187
190
  return this._transport.httpRequest({
@@ -389,6 +392,18 @@ class Connection extends jsforce_1.Connection {
389
392
  }
390
393
  return result.records[0];
391
394
  }
395
+ /**
396
+ * Executes a get request on the baseUrl to force an auth refresh
397
+ * Useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes
398
+ */
399
+ async refreshAuth() {
400
+ this.logger.debug('Refreshing auth for org.');
401
+ const requestInfo = {
402
+ url: this.baseUrl(),
403
+ method: 'GET',
404
+ };
405
+ await this.request(requestInfo);
406
+ }
392
407
  async loadInstanceApiVersion() {
393
408
  const authFileFields = this.options.authInfo.getFields();
394
409
  const lastCheckedDateString = authFileFields.instanceApiVersionLastRetrieved;
package/lib/org.js CHANGED
@@ -306,13 +306,8 @@ class Org extends kit_1.AsyncCreatable {
306
306
  * Refreshes the auth for this org's instance by calling HTTP GET on the baseUrl of the connection object.
307
307
  */
308
308
  async refreshAuth() {
309
- this.logger.debug('Refreshing auth for org.');
310
- const requestInfo = {
311
- url: this.getConnection().baseUrl(),
312
- method: 'GET',
313
- };
314
309
  const conn = this.getConnection();
315
- await conn.request(requestInfo);
310
+ await conn.refreshAuth();
316
311
  }
317
312
  /**
318
313
  * Reads and returns the content of all user auth files for this org as an array.
@@ -7,9 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.RequestStatus = void 0;
10
- // Node
11
10
  const path = require("path");
12
- // @salesforce
13
11
  const kit_1 = require("@salesforce/kit");
14
12
  const ts_types_1 = require("@salesforce/ts-types");
15
13
  const js2xmlparser = require("js2xmlparser");
@@ -77,7 +75,7 @@ class SettingsGenerator {
77
75
  const pollingOptions = {
78
76
  async poll() {
79
77
  try {
80
- result = await connection.metadata.checkDeployStatus(id);
78
+ result = await connection.metadata.checkDeployStatus(id, true);
81
79
  logger.debug(`Deploy id: ${id} status: ${result.status}`);
82
80
  if (breakPolling.includes(result.status)) {
83
81
  return {
@@ -105,7 +103,11 @@ class SettingsGenerator {
105
103
  const client = await pollingClient_1.PollingClient.create(pollingOptions);
106
104
  const status = (await client.subscribe());
107
105
  if (status !== RequestStatus.Succeeded) {
108
- const error = new sfdxError_1.SfdxError(`A scratch org was created with username ${username}, but the settings failed to deploy`, 'ProblemDeployingSettings');
106
+ const componentFailures = ts_types_1.ensureObject(result.details).componentFailures;
107
+ const failures = (Array.isArray(componentFailures) ? componentFailures : [componentFailures])
108
+ .map((failure) => failure.problem)
109
+ .join('\n');
110
+ const error = new sfdxError_1.SfdxError(`A scratch org was created with username ${username}, but the settings failed to deploy due to: \n${failures}`, 'ProblemDeployingSettings');
109
111
  error.setData(result);
110
112
  throw error;
111
113
  }
package/lib/user.js CHANGED
@@ -280,6 +280,7 @@ class User extends kit_1.AsyncCreatable {
280
280
  * ```
281
281
  */
282
282
  async createUser(fields) {
283
+ var _a;
283
284
  // Create a user and get a refresh token
284
285
  const refreshTokenSecret = await this.createUserInternal(fields);
285
286
  // Create the initial auth info
@@ -287,7 +288,8 @@ class User extends kit_1.AsyncCreatable {
287
288
  const adminUserAuthFields = authInfo.getFields(true);
288
289
  // Setup oauth options for the new user
289
290
  const oauthOptions = {
290
- loginUrl: adminUserAuthFields.loginUrl,
291
+ // Communities users require the instance for auth
292
+ loginUrl: (_a = adminUserAuthFields.instanceUrl) !== null && _a !== void 0 ? _a : adminUserAuthFields.loginUrl,
291
293
  refreshToken: refreshTokenSecret.buffer.value((buffer) => buffer.toString('utf8')),
292
294
  clientId: adminUserAuthFields.clientId,
293
295
  clientSecret: adminUserAuthFields.clientSecret,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "2.33.2",
3
+ "version": "2.35.1",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",
@@ -39,6 +39,7 @@
39
39
  "@salesforce/schemas": "^1.0.1",
40
40
  "@salesforce/ts-types": "^1.5.20",
41
41
  "@types/graceful-fs": "^4.1.5",
42
+ "@types/jsforce": "^1.9.38",
42
43
  "@types/mkdirp": "^1.0.1",
43
44
  "archiver": "^5.3.0",
44
45
  "debug": "^3.1.0",
@@ -60,7 +61,6 @@
60
61
  "@types/archiver": "^5.1.1",
61
62
  "@types/debug": "0.0.30",
62
63
  "@types/jsen": "0.0.19",
63
- "@types/jsforce": "^1.9.38",
64
64
  "@types/jsonwebtoken": "8.3.2",
65
65
  "@types/semver": "^7.3.9",
66
66
  "@types/shelljs": "0.7.8",
@@ -82,7 +82,7 @@
82
82
  "nyc": "^15.1.0",
83
83
  "prettier": "^2.0.5",
84
84
  "pretty-quick": "^3.1.0",
85
- "shelljs": "0.8.1",
85
+ "shelljs": "0.8.5",
86
86
  "sinon": "10.0.0",
87
87
  "ts-node": "^10.0.0",
88
88
  "typescript": "^4.1.3"