@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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2024, Salesforce.com, Inc.
1
+ Copyright (c) 2025, Salesforce.com, Inc.
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -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(conn, callback) {
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
- return await callback(null, fields.accessToken);
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;
@@ -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 get request on the baseUrl to force an auth refresh
152
- * Useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes
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;
@@ -334,14 +334,18 @@ class Connection extends jsforce_node_1.Connection {
334
334
  return result.records[0];
335
335
  }
336
336
  /**
337
- * Executes a get request on the baseUrl to force an auth refresh
338
- * Useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes
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: 'GET',
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
- * Refreshes the auth for this org's instance by calling HTTP GET on the baseUrl of the connection object.
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
- * Refreshes the auth for this org's instance by calling HTTP GET on the baseUrl of the connection object.
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: 'GET',
636
+ method: 'HEAD',
632
637
  };
633
638
  await this.getConnection().request(requestInfo);
634
639
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "8.8.0",
3
+ "version": "8.8.1",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",