@salesforce/core 2.34.2 → 2.34.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/CHANGELOG.md +6 -0
- package/lib/connection.d.ts +5 -0
- package/lib/connection.js +15 -0
- package/lib/org.js +1 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
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.34.3](https://github.com/forcedotcom/sfdx-core/compare/v2.34.2...v2.34.3) (2022-01-25)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- refresh auth on a connection, too ([ff32a70](https://github.com/forcedotcom/sfdx-core/commit/ff32a705d87d6e410d06597eefa407b54eeb215d))
|
|
10
|
+
|
|
5
11
|
### [2.34.2](https://github.com/forcedotcom/sfdx-core/compare/v2.33.2...v2.34.2) (2022-01-25)
|
|
6
12
|
|
|
7
13
|
### [2.33.2](https://github.com/forcedotcom/sfdx-core/compare/v2.33.1...v2.33.2) (2022-01-25)
|
package/lib/connection.d.ts
CHANGED
|
@@ -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.
|
|
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.
|