@salesforce/core 3.23.8 → 3.23.9
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 +2 -0
- package/lib/config/config.js +5 -7
- package/lib/config/configAggregator.js +5 -7
- package/lib/config/configStore.js +1 -2
- package/lib/config/envVars.js +1 -2
- package/lib/deviceOauthService.d.ts +2 -2
- package/lib/deviceOauthService.js +6 -7
- package/lib/org/authInfo.d.ts +4 -12
- package/lib/org/authInfo.js +18 -44
- package/lib/org/connection.d.ts +3 -8
- package/lib/org/connection.js +10 -58
- package/lib/org/org.js +18 -28
- package/lib/org/permissionSetAssignment.js +1 -2
- package/lib/org/scratchOrgCreate.js +13 -11
- package/lib/org/scratchOrgInfoApi.js +3 -4
- package/lib/org/scratchOrgInfoGenerator.js +9 -12
- package/lib/org/scratchOrgSettingsGenerator.js +3 -3
- package/lib/org/user.js +2 -3
- package/lib/sfProject.js +1 -2
- package/lib/stateAggregator/accessors/aliasAccessor.js +13 -26
- package/lib/stateAggregator/accessors/orgAccessor.js +5 -9
- package/lib/stateAggregator/accessors/sandboxAccessor.js +2 -4
- package/lib/stateAggregator/sfdxDataHandler.js +6 -10
- package/lib/status/pollingClient.js +1 -2
- package/lib/testSetup.js +9 -12
- package/lib/util/checkLightningDomain.js +2 -3
- package/lib/webOAuthServer.d.ts +3 -2
- package/lib/webOAuthServer.js +6 -6
- package/package.json +2 -2
|
@@ -39,8 +39,7 @@ class GlobalInfoSandboxAccessor {
|
|
|
39
39
|
* @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
|
|
40
40
|
*/
|
|
41
41
|
get(sandboxOrgId) {
|
|
42
|
-
|
|
43
|
-
return sandboxOrgId ? (_a = this.getAll()[sandboxOrgId]) !== null && _a !== void 0 ? _a : null : null;
|
|
42
|
+
return sandboxOrgId ? this.getAll()[sandboxOrgId] ?? null : null;
|
|
44
43
|
}
|
|
45
44
|
/**
|
|
46
45
|
* Returns true if the given sandbox org id exists
|
|
@@ -48,8 +47,7 @@ class GlobalInfoSandboxAccessor {
|
|
|
48
47
|
* @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
|
|
49
48
|
*/
|
|
50
49
|
has(sandboxOrgId) {
|
|
51
|
-
|
|
52
|
-
return !!(sandboxOrgId ? (_a = this.getAll()[sandboxOrgId]) !== null && _a !== void 0 ? _a : null : null);
|
|
50
|
+
return !!(sandboxOrgId ? this.getAll()[sandboxOrgId] ?? null : null);
|
|
53
51
|
}
|
|
54
52
|
/**
|
|
55
53
|
* Set an sandboxOrgId for the given sandbox entity
|
|
@@ -50,13 +50,12 @@ class SfdxDataHandler {
|
|
|
50
50
|
exports.SfdxDataHandler = SfdxDataHandler;
|
|
51
51
|
class BaseHandler {
|
|
52
52
|
async merge(sfData = globalInfoConfig_1.GlobalInfo.emptyDataModel) {
|
|
53
|
-
var _a, _b;
|
|
54
53
|
const sfdxData = await this.migrate();
|
|
55
54
|
const merged = (0, globalInfoConfig_1.deepCopy)(sfData);
|
|
56
55
|
// Only merge the key this handler is responsible for.
|
|
57
56
|
const key = this.sfKey;
|
|
58
|
-
const sfKeys = Object.keys(
|
|
59
|
-
const sfdxKeys = Object.keys(
|
|
57
|
+
const sfKeys = Object.keys(sfData[key] ?? {});
|
|
58
|
+
const sfdxKeys = Object.keys(sfdxData[key] ?? {});
|
|
60
59
|
const commonKeys = sfKeys.filter((k) => sfdxKeys.includes(k));
|
|
61
60
|
for (const k of commonKeys) {
|
|
62
61
|
const [newer, older] = [sfData[key][k], sfdxData[key][k]].sort((a, b) => {
|
|
@@ -115,12 +114,11 @@ class AuthHandler extends BaseHandler {
|
|
|
115
114
|
}));
|
|
116
115
|
}
|
|
117
116
|
async findChanges(latest, original) {
|
|
118
|
-
var _a;
|
|
119
117
|
const latestAuths = latest.orgs;
|
|
120
118
|
const originalAuths = original.orgs;
|
|
121
119
|
const changed = {};
|
|
122
120
|
for (const [username, auth] of Object.entries(latestAuths)) {
|
|
123
|
-
const originalAuth =
|
|
121
|
+
const originalAuth = originalAuths[username] ?? {};
|
|
124
122
|
if (!isEqual(auth, originalAuth)) {
|
|
125
123
|
changed[username] = auth;
|
|
126
124
|
}
|
|
@@ -218,13 +216,12 @@ class SandboxesHandler extends BaseHandler {
|
|
|
218
216
|
this.sfKey = types_1.SfInfoKeys.SANDBOXES;
|
|
219
217
|
}
|
|
220
218
|
async merge(sfData = globalInfoConfig_1.GlobalInfo.emptyDataModel) {
|
|
221
|
-
var _a, _b;
|
|
222
219
|
const sfdxData = await this.migrate();
|
|
223
220
|
const merged = (0, globalInfoConfig_1.deepCopy)(sfData);
|
|
224
221
|
// Only merge the key this handler is responsible for.
|
|
225
222
|
const key = this.sfKey;
|
|
226
|
-
const sfKeys = Object.keys(
|
|
227
|
-
const sfdxKeys = Object.keys(
|
|
223
|
+
const sfKeys = Object.keys(sfData[key] ?? {});
|
|
224
|
+
const sfdxKeys = Object.keys(sfdxData[key] ?? {});
|
|
228
225
|
// sandbox entries for .sf and .sfdx contain static data. Given there
|
|
229
226
|
// can be no mutation during the life of the sandbox, having to merge common keys
|
|
230
227
|
// is unnecessary.
|
|
@@ -289,12 +286,11 @@ class SandboxesHandler extends BaseHandler {
|
|
|
289
286
|
}));
|
|
290
287
|
}
|
|
291
288
|
async findChanges(latest, original) {
|
|
292
|
-
var _a;
|
|
293
289
|
const latestSandboxes = latest.sandboxes;
|
|
294
290
|
const originalSandboxes = original.sandboxes;
|
|
295
291
|
const changed = {};
|
|
296
292
|
for (const [sandboxOrgId, sandbox] of Object.entries(latestSandboxes)) {
|
|
297
|
-
const originalSandbox =
|
|
293
|
+
const originalSandbox = originalSandboxes[sandboxOrgId] ?? {};
|
|
298
294
|
if (!isEqual(sandbox, originalSandbox)) {
|
|
299
295
|
changed[sandboxOrgId] = sandbox;
|
|
300
296
|
}
|
|
@@ -53,7 +53,6 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
|
|
|
53
53
|
* in the polling options.
|
|
54
54
|
*/
|
|
55
55
|
async subscribe() {
|
|
56
|
-
var _a;
|
|
57
56
|
let errorInPollingFunction; // keep this around for returning in the catch block
|
|
58
57
|
const doPoll = async () => {
|
|
59
58
|
let result;
|
|
@@ -89,7 +88,7 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
|
|
|
89
88
|
}
|
|
90
89
|
await lifecycleEvents_1.Lifecycle.getInstance().emit('POLLING_TIME_OUT', error);
|
|
91
90
|
this.logger.debug('Polling timed out');
|
|
92
|
-
throw new sfError_1.SfError('The client has timed out.',
|
|
91
|
+
throw new sfError_1.SfError('The client has timed out.', this.options.timeoutErrorName ?? 'PollingClientTimeout');
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
}
|
package/lib/testSetup.js
CHANGED
|
@@ -41,11 +41,10 @@ const global_1 = require("./global");
|
|
|
41
41
|
* - length: the length of the unique id as presented in hexadecimal.
|
|
42
42
|
*/
|
|
43
43
|
function uniqid(options) {
|
|
44
|
-
|
|
45
|
-
const uniqueString = (0, crypto_1.randomBytes)(Math.ceil(((_a = options === null || options === void 0 ? void 0 : options.length) !== null && _a !== void 0 ? _a : 32) / 2.0))
|
|
44
|
+
const uniqueString = (0, crypto_1.randomBytes)(Math.ceil((options?.length ?? 32) / 2.0))
|
|
46
45
|
.toString('hex')
|
|
47
|
-
.slice(0,
|
|
48
|
-
if (!
|
|
46
|
+
.slice(0, options?.length ?? 32);
|
|
47
|
+
if (!options?.template) {
|
|
49
48
|
return uniqueString;
|
|
50
49
|
}
|
|
51
50
|
return options.template.includes('%s')
|
|
@@ -168,9 +167,8 @@ const instantiateContext = (sinon) => {
|
|
|
168
167
|
return orgMap.has(username);
|
|
169
168
|
});
|
|
170
169
|
const retrieveContents = async function () {
|
|
171
|
-
var _a;
|
|
172
170
|
const username = (0, path_1.basename)(this.path.replace('.json', ''));
|
|
173
|
-
return Promise.resolve(
|
|
171
|
+
return Promise.resolve(orgMap.get(username) ?? {});
|
|
174
172
|
};
|
|
175
173
|
this.configStubs.AuthInfoConfig = { retrieveContents };
|
|
176
174
|
},
|
|
@@ -179,9 +177,8 @@ const instantiateContext = (sinon) => {
|
|
|
179
177
|
const sandboxMap = new Map(entries);
|
|
180
178
|
(0, ts_sinon_1.stubMethod)(testContext.SANDBOX, sandboxAccessor_1.SandboxAccessor.prototype, 'getAllFiles').returns([...sandboxMap.keys()].map((o) => `${o}.sandbox.json`));
|
|
181
179
|
const retrieveContents = async function () {
|
|
182
|
-
var _a;
|
|
183
180
|
const username = (0, path_1.basename)(this.path.replace('.sandbox.json', ''));
|
|
184
|
-
return Promise.resolve(
|
|
181
|
+
return Promise.resolve(sandboxMap.get(username) ?? {});
|
|
185
182
|
};
|
|
186
183
|
this.configStubs.SandboxOrgConfig = { retrieveContents };
|
|
187
184
|
},
|
|
@@ -595,7 +592,7 @@ class MockTestOrgData {
|
|
|
595
592
|
this.testId = id;
|
|
596
593
|
this.userId = `user_id_${this.testId}`;
|
|
597
594
|
this.orgId = `${this.testId}`;
|
|
598
|
-
this.username =
|
|
595
|
+
this.username = options?.username || `admin_${this.testId}@gb.org`;
|
|
599
596
|
this.loginUrl = `https://login.${this.testId}.salesforce.com`;
|
|
600
597
|
this.instanceUrl = `https://instance.${this.testId}.salesforce.com`;
|
|
601
598
|
this.clientId = `${this.testId}/client_id`;
|
|
@@ -702,9 +699,9 @@ class MockTestSandboxData {
|
|
|
702
699
|
constructor(id = uniqid(), options) {
|
|
703
700
|
this.id = id;
|
|
704
701
|
this.sandboxOrgId = id;
|
|
705
|
-
this.prodOrgUsername =
|
|
706
|
-
this.sandboxName =
|
|
707
|
-
this.username =
|
|
702
|
+
this.prodOrgUsername = options?.prodOrgUsername || `admin_${id}@gb.org`;
|
|
703
|
+
this.sandboxName = options?.name || `sandbox_${id}`;
|
|
704
|
+
this.username = options?.username || `${this.prodOrgUsername}.sandbox`;
|
|
708
705
|
}
|
|
709
706
|
/**
|
|
710
707
|
* Return the auth config file contents.
|
|
@@ -11,9 +11,8 @@ const kit_1 = require("@salesforce/kit");
|
|
|
11
11
|
const myDomainResolver_1 = require("../status/myDomainResolver");
|
|
12
12
|
const sfdc_1 = require("./sfdc");
|
|
13
13
|
async function checkLightningDomain(url) {
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const quantity = (_b = new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240)) !== null && _b !== void 0 ? _b : 0;
|
|
14
|
+
const domain = `https://${/https?:\/\/([^.]*)/.exec(url)?.slice(1, 2).pop()}.lightning.force.com`;
|
|
15
|
+
const quantity = new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240) ?? 0;
|
|
17
16
|
const timeout = new kit_1.Duration(quantity, kit_1.Duration.Unit.SECONDS);
|
|
18
17
|
if (sfdc_1.sfdc.isInternalUrl(url) || timeout.seconds === 0) {
|
|
19
18
|
return true;
|
package/lib/webOAuthServer.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as http from 'http';
|
|
3
|
+
import { JwtOAuth2Config } from 'jsforce';
|
|
3
4
|
import { AsyncCreatable } from '@salesforce/kit';
|
|
4
|
-
import { AuthInfo
|
|
5
|
+
import { AuthInfo } from './org';
|
|
5
6
|
/**
|
|
6
7
|
* Handles the creation of a web server for web based login flows.
|
|
7
8
|
*
|
|
@@ -79,7 +80,7 @@ export declare class WebOAuthServer extends AsyncCreatable<WebOAuthServer.Option
|
|
|
79
80
|
}
|
|
80
81
|
export declare namespace WebOAuthServer {
|
|
81
82
|
interface Options {
|
|
82
|
-
oauthConfig:
|
|
83
|
+
oauthConfig: JwtOAuth2Config;
|
|
83
84
|
}
|
|
84
85
|
type Request = http.IncomingMessage & {
|
|
85
86
|
query: {
|
package/lib/webOAuthServer.js
CHANGED
|
@@ -11,11 +11,11 @@ const http = require("http");
|
|
|
11
11
|
const querystring_1 = require("querystring");
|
|
12
12
|
const url_1 = require("url");
|
|
13
13
|
const net_1 = require("net");
|
|
14
|
+
const jsforce_1 = require("jsforce");
|
|
14
15
|
const kit_1 = require("@salesforce/kit");
|
|
15
16
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
16
|
-
const jsforce_1 = require("jsforce");
|
|
17
17
|
const logger_1 = require("./logger");
|
|
18
|
-
const
|
|
18
|
+
const org_1 = require("./org");
|
|
19
19
|
const sfError_1 = require("./sfError");
|
|
20
20
|
const messages_1 = require("./messages");
|
|
21
21
|
const sfProject_1 = require("./sfProject");
|
|
@@ -85,7 +85,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
85
85
|
this.executeOauthRequest()
|
|
86
86
|
.then(async (response) => {
|
|
87
87
|
try {
|
|
88
|
-
const authInfo = await
|
|
88
|
+
const authInfo = await org_1.AuthInfo.create({
|
|
89
89
|
oauth2Options: this.oauthConfig,
|
|
90
90
|
oauth2: this.oauth2,
|
|
91
91
|
});
|
|
@@ -127,14 +127,14 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
127
127
|
this.logger = await logger_1.Logger.child(this.constructor.name);
|
|
128
128
|
const port = await WebOAuthServer.determineOauthPort();
|
|
129
129
|
if (!this.oauthConfig.clientId)
|
|
130
|
-
this.oauthConfig.clientId =
|
|
130
|
+
this.oauthConfig.clientId = org_1.DEFAULT_CONNECTED_APP_INFO.clientId;
|
|
131
131
|
if (!this.oauthConfig.loginUrl)
|
|
132
|
-
this.oauthConfig.loginUrl =
|
|
132
|
+
this.oauthConfig.loginUrl = org_1.AuthInfo.getDefaultInstanceUrl();
|
|
133
133
|
if (!this.oauthConfig.redirectUri)
|
|
134
134
|
this.oauthConfig.redirectUri = `http://localhost:${port}/OauthRedirect`;
|
|
135
135
|
this.webServer = await WebServer.create({ port });
|
|
136
136
|
this.oauth2 = new jsforce_1.OAuth2(this.oauthConfig);
|
|
137
|
-
this.authUrl =
|
|
137
|
+
this.authUrl = org_1.AuthInfo.getAuthorizationUrl(this.oauthConfig, this.oauth2);
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* Executes the oauth request
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "3.23.
|
|
3
|
+
"version": "3.23.9",
|
|
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",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"form-data": "^4.0.0",
|
|
50
50
|
"graceful-fs": "^4.2.9",
|
|
51
51
|
"js2xmlparser": "^4.0.1",
|
|
52
|
-
"jsforce": "
|
|
52
|
+
"jsforce": "beta",
|
|
53
53
|
"jsonwebtoken": "8.5.1",
|
|
54
54
|
"mkdirp": "1.0.4",
|
|
55
55
|
"ts-retry-promise": "^0.6.0"
|