@salesforce/core 8.31.5 → 8.32.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/lib/org/authInfo.js +4 -0
- package/lib/org/authRemover.d.ts +21 -1
- package/lib/org/authRemover.js +22 -1
- package/lib/org/connection.js +5 -3
- package/package.json +1 -1
package/lib/org/authInfo.js
CHANGED
|
@@ -443,6 +443,10 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
443
443
|
*/
|
|
444
444
|
update(authData) {
|
|
445
445
|
if (authData && (0, ts_types_1.isPlainObject)(authData)) {
|
|
446
|
+
if (authData.instanceApiVersion && !(0, sfdc_1.validateApiVersion)(authData.instanceApiVersion)) {
|
|
447
|
+
this.logger.warn(`Ignoring invalid instanceApiVersion "${authData.instanceApiVersion}" (expected format: "XX.0")`);
|
|
448
|
+
authData.instanceApiVersion = undefined;
|
|
449
|
+
}
|
|
446
450
|
this.username = authData.username ?? this.username;
|
|
447
451
|
this.stateAggregator.orgs.update(this.username, authData);
|
|
448
452
|
this.logger.info(`Updated auth info for username: ${this.username}`);
|
package/lib/org/authRemover.d.ts
CHANGED
|
@@ -23,11 +23,22 @@ import { AuthFields } from './authInfo';
|
|
|
23
23
|
* );
|
|
24
24
|
* await remover.removeAuth(auth.username);
|
|
25
25
|
* ```
|
|
26
|
+
*
|
|
27
|
+
* Pass a `projectPath` to resolve local config from a specific project instead of `process.cwd()`,
|
|
28
|
+
* and `skipCache` to re-read config from disk when the process-cached aggregator can't be trusted:
|
|
29
|
+
*
|
|
30
|
+
* ```
|
|
31
|
+
* const remover = await AuthRemover.create({ projectPath: '/path/to/project', skipCache: true });
|
|
32
|
+
* await remover.removeAuth('example@mycompany.com');
|
|
33
|
+
* ```
|
|
26
34
|
*/
|
|
27
|
-
export declare class AuthRemover extends AsyncOptionalCreatable {
|
|
35
|
+
export declare class AuthRemover extends AsyncOptionalCreatable<AuthRemoverOptions> {
|
|
28
36
|
private config;
|
|
29
37
|
private stateAggregator;
|
|
30
38
|
private logger;
|
|
39
|
+
private readonly projectPath?;
|
|
40
|
+
private readonly skipCache?;
|
|
41
|
+
constructor(options?: AuthRemoverOptions);
|
|
31
42
|
/**
|
|
32
43
|
* Removes the authentication and any configs or aliases associated with it
|
|
33
44
|
*
|
|
@@ -85,3 +96,12 @@ export declare class AuthRemover extends AsyncOptionalCreatable {
|
|
|
85
96
|
*/
|
|
86
97
|
private unsetAliases;
|
|
87
98
|
}
|
|
99
|
+
export type AuthRemoverOptions = {
|
|
100
|
+
/** an absolute path to the project root, used to resolve local config; defaults to `process.cwd()` */
|
|
101
|
+
projectPath?: string;
|
|
102
|
+
/**
|
|
103
|
+
* re-read config from disk instead of trusting the process-cached ConfigAggregator. Set `true`
|
|
104
|
+
* when the config may have changed out of process or before this call. Defaults to `false`.
|
|
105
|
+
*/
|
|
106
|
+
skipCache?: boolean;
|
|
107
|
+
};
|
package/lib/org/authRemover.js
CHANGED
|
@@ -37,11 +37,26 @@ const messages = new messages_1.Messages('@salesforce/core', 'auth', new Map([["
|
|
|
37
37
|
* );
|
|
38
38
|
* await remover.removeAuth(auth.username);
|
|
39
39
|
* ```
|
|
40
|
+
*
|
|
41
|
+
* Pass a `projectPath` to resolve local config from a specific project instead of `process.cwd()`,
|
|
42
|
+
* and `skipCache` to re-read config from disk when the process-cached aggregator can't be trusted:
|
|
43
|
+
*
|
|
44
|
+
* ```
|
|
45
|
+
* const remover = await AuthRemover.create({ projectPath: '/path/to/project', skipCache: true });
|
|
46
|
+
* await remover.removeAuth('example@mycompany.com');
|
|
47
|
+
* ```
|
|
40
48
|
*/
|
|
41
49
|
class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
42
50
|
config;
|
|
43
51
|
stateAggregator;
|
|
44
52
|
logger;
|
|
53
|
+
projectPath;
|
|
54
|
+
skipCache;
|
|
55
|
+
constructor(options) {
|
|
56
|
+
super(options);
|
|
57
|
+
this.projectPath = options?.projectPath;
|
|
58
|
+
this.skipCache = options?.skipCache;
|
|
59
|
+
}
|
|
45
60
|
/**
|
|
46
61
|
* Removes the authentication and any configs or aliases associated with it
|
|
47
62
|
*
|
|
@@ -91,7 +106,13 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
91
106
|
}
|
|
92
107
|
async init() {
|
|
93
108
|
this.logger = await logger_1.Logger.child(this.constructor.name);
|
|
94
|
-
this.config = await configAggregator_1.ConfigAggregator.create();
|
|
109
|
+
this.config = await configAggregator_1.ConfigAggregator.create(this.projectPath ? { projectPath: this.projectPath } : undefined);
|
|
110
|
+
// ConfigAggregator.create returns a process-cached instance keyed by projectPath, so its
|
|
111
|
+
// in-memory config may be stale (set out of process, or before this call). When the caller
|
|
112
|
+
// can't trust the cache, skipCache re-reads from disk so unsetConfigValues sees current values.
|
|
113
|
+
if (this.skipCache) {
|
|
114
|
+
await this.config.reload();
|
|
115
|
+
}
|
|
95
116
|
this.stateAggregator = await stateAggregator_1.StateAggregator.getInstance();
|
|
96
117
|
await this.stateAggregator.orgs.readAll();
|
|
97
118
|
}
|
package/lib/org/connection.js
CHANGED
|
@@ -205,8 +205,7 @@ class Connection extends jsforce_node_1.Connection {
|
|
|
205
205
|
if (error.name === exports.DNS_ERROR_NAME) {
|
|
206
206
|
throw error; // throws on DNS connection errors
|
|
207
207
|
}
|
|
208
|
-
|
|
209
|
-
this.logger.warn('Failed to set the latest API version:', error);
|
|
208
|
+
this.logger.warn(`Failed to set the latest API version (${error.name}: ${error.message}). Using default: v${this.version}`);
|
|
210
209
|
}
|
|
211
210
|
}
|
|
212
211
|
/**
|
|
@@ -382,7 +381,10 @@ class Connection extends jsforce_node_1.Connection {
|
|
|
382
381
|
const has24HoursPastSinceLastCheck = now.getTime() - lastChecked > kit_1.Duration.hours(24).milliseconds;
|
|
383
382
|
this.logger.debug(`API version cache last checked on ${lastCheckedDateString ?? '<undefined>'} (now is ${now.toLocaleString()})`);
|
|
384
383
|
if (!has24HoursPastSinceLastCheck && version) {
|
|
385
|
-
|
|
384
|
+
if (!(0, sfdc_1.validateApiVersion)(version)) {
|
|
385
|
+
this.logger.warn(`Cached instanceApiVersion "${version}" is invalid (expected format: "XX.0"). Ignoring cache and re-fetching.`);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
386
388
|
this.logger.debug(`Using cached API version: ${version}`);
|
|
387
389
|
return version;
|
|
388
390
|
}
|