@salesforce/core 8.8.0 → 8.8.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/LICENSE.txt +1 -1
- package/lib/org/authInfo.js +7 -2
- package/lib/org/connection.d.ts +6 -2
- package/lib/org/connection.js +7 -3
- package/lib/org/org.d.ts +6 -1
- package/lib/org/org.js +7 -2
- package/package.json +1 -1
package/LICENSE.txt
CHANGED
package/lib/org/authInfo.js
CHANGED
|
@@ -730,13 +730,18 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
730
730
|
}
|
|
731
731
|
// A callback function for a connection to refresh an access token. This is used
|
|
732
732
|
// both for a JWT connection and an OAuth connection.
|
|
733
|
-
async refreshFn(
|
|
733
|
+
async refreshFn(_conn, callback) {
|
|
734
734
|
this.logger.info('Access token has expired. Updating...');
|
|
735
735
|
try {
|
|
736
736
|
const fields = this.getFields(true);
|
|
737
|
+
// This method will request the new access token and save to the current AuthInfo instance (but don't persist them!).
|
|
737
738
|
await this.initAuthOptions(fields);
|
|
739
|
+
// Persist fields with refreshed access token to auth file.
|
|
738
740
|
await this.save();
|
|
739
|
-
|
|
741
|
+
// Pass new access token to the jsforce's session-refresh callback for proper propagation:
|
|
742
|
+
// https://jsforce.github.io/jsforce/types/session_refresh_delegate.SessionRefreshFunc.html
|
|
743
|
+
const { accessToken } = this.getFields(true);
|
|
744
|
+
return await callback(null, accessToken);
|
|
740
745
|
}
|
|
741
746
|
catch (err) {
|
|
742
747
|
const error = err;
|
package/lib/org/connection.d.ts
CHANGED
|
@@ -148,8 +148,12 @@ export declare class Connection<S extends Schema = Schema> extends JSForceConnec
|
|
|
148
148
|
*/
|
|
149
149
|
singleRecordQuery<T extends Record>(soql: string, options?: SingleRecordQueryOptions): Promise<T>;
|
|
150
150
|
/**
|
|
151
|
-
* Executes a
|
|
152
|
-
*
|
|
151
|
+
* Executes a HEAD request on the baseUrl to force an auth refresh.
|
|
152
|
+
* This is useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes.
|
|
153
|
+
*
|
|
154
|
+
* This method issues a request using the current access token to check if it is still valid.
|
|
155
|
+
* If the request returns 200, no refresh happens, and we keep the token.
|
|
156
|
+
* If it returns 401, jsforce will request a new token and set it in the connection instance.
|
|
153
157
|
*/
|
|
154
158
|
refreshAuth(): Promise<void>;
|
|
155
159
|
private getCachedApiVersion;
|
package/lib/org/connection.js
CHANGED
|
@@ -334,14 +334,18 @@ class Connection extends jsforce_node_1.Connection {
|
|
|
334
334
|
return result.records[0];
|
|
335
335
|
}
|
|
336
336
|
/**
|
|
337
|
-
* Executes a
|
|
338
|
-
*
|
|
337
|
+
* Executes a HEAD request on the baseUrl to force an auth refresh.
|
|
338
|
+
* This is useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes.
|
|
339
|
+
*
|
|
340
|
+
* This method issues a request using the current access token to check if it is still valid.
|
|
341
|
+
* If the request returns 200, no refresh happens, and we keep the token.
|
|
342
|
+
* If it returns 401, jsforce will request a new token and set it in the connection instance.
|
|
339
343
|
*/
|
|
340
344
|
async refreshAuth() {
|
|
341
345
|
this.logger.debug('Refreshing auth for org.');
|
|
342
346
|
const requestInfo = {
|
|
343
347
|
url: this.baseUrl(),
|
|
344
|
-
method: '
|
|
348
|
+
method: 'HEAD',
|
|
345
349
|
};
|
|
346
350
|
await this.request(requestInfo);
|
|
347
351
|
}
|
package/lib/org/org.d.ts
CHANGED
|
@@ -319,7 +319,12 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
|
|
|
319
319
|
*/
|
|
320
320
|
updateLocalInformation(): Promise<Pick<AuthFields, Org.Fields.NAME | Org.Fields.INSTANCE_NAME | Org.Fields.NAMESPACE_PREFIX | Org.Fields.IS_SANDBOX | Org.Fields.IS_SCRATCH | Org.Fields.TRIAL_EXPIRATION_DATE> | undefined>;
|
|
321
321
|
/**
|
|
322
|
-
*
|
|
322
|
+
* Executes a HEAD request on the baseUrl to force an auth refresh.
|
|
323
|
+
* This is useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes.
|
|
324
|
+
*
|
|
325
|
+
* This method issues a request using the current access token to check if it is still valid.
|
|
326
|
+
* If the request returns 200, no refresh happens, and we keep the token.
|
|
327
|
+
* If it returns 401, jsforce will request a new token and set it in the connection instance.
|
|
323
328
|
*/
|
|
324
329
|
refreshAuth(): Promise<void>;
|
|
325
330
|
/**
|
package/lib/org/org.js
CHANGED
|
@@ -622,13 +622,18 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
624
|
/**
|
|
625
|
-
*
|
|
625
|
+
* Executes a HEAD request on the baseUrl to force an auth refresh.
|
|
626
|
+
* This is useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes.
|
|
627
|
+
*
|
|
628
|
+
* This method issues a request using the current access token to check if it is still valid.
|
|
629
|
+
* If the request returns 200, no refresh happens, and we keep the token.
|
|
630
|
+
* If it returns 401, jsforce will request a new token and set it in the connection instance.
|
|
626
631
|
*/
|
|
627
632
|
async refreshAuth() {
|
|
628
633
|
this.logger.debug('Refreshing auth for org.');
|
|
629
634
|
const requestInfo = {
|
|
630
635
|
url: this.getConnection().baseUrl(),
|
|
631
|
-
method: '
|
|
636
|
+
method: 'HEAD',
|
|
632
637
|
};
|
|
633
638
|
await this.getConnection().request(requestInfo);
|
|
634
639
|
}
|