@salesforce/core 3.23.7 → 3.24.0
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 +20 -0
- package/lib/config/authInfoConfig.js +1 -1
- 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.d.ts +1 -1
- package/lib/org/org.js +18 -28
- package/lib/org/permissionSetAssignment.js +1 -2
- package/lib/org/scratchOrgCreate.d.ts +1 -1
- package/lib/org/scratchOrgCreate.js +13 -16
- package/lib/org/scratchOrgErrorCodes.js +7 -3
- 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/messages/scratchOrgCreate.md +0 -20
- package/messages/scratchOrgErrorCodes.md +16 -0
- package/package.json +2 -2
|
@@ -36,8 +36,7 @@ class GlobalInfoAliasAccessor {
|
|
|
36
36
|
* @param entity the aliasable entity that you want to get the alias of
|
|
37
37
|
*/
|
|
38
38
|
get(entity) {
|
|
39
|
-
|
|
40
|
-
return (_a = this.getAll(entity).find((alias) => alias)) !== null && _a !== void 0 ? _a : null;
|
|
39
|
+
return this.getAll(entity).find((alias) => alias) ?? null;
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
43
42
|
* Returns the value that corresponds to the given alias if it exists
|
|
@@ -45,8 +44,7 @@ class GlobalInfoAliasAccessor {
|
|
|
45
44
|
* @param alias the alias that corresponds to a value
|
|
46
45
|
*/
|
|
47
46
|
getValue(alias) {
|
|
48
|
-
|
|
49
|
-
return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
|
|
47
|
+
return this.getAll()[alias] ?? null;
|
|
50
48
|
}
|
|
51
49
|
/**
|
|
52
50
|
* Returns the username that corresponds to the given alias if it exists
|
|
@@ -54,8 +52,7 @@ class GlobalInfoAliasAccessor {
|
|
|
54
52
|
* @param alias the alias that corresponds to a username
|
|
55
53
|
*/
|
|
56
54
|
getUsername(alias) {
|
|
57
|
-
|
|
58
|
-
return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
|
|
55
|
+
return this.getAll()[alias] ?? null;
|
|
59
56
|
}
|
|
60
57
|
/**
|
|
61
58
|
* If the provided string is an alias, it returns the corresponding value.
|
|
@@ -68,8 +65,7 @@ class GlobalInfoAliasAccessor {
|
|
|
68
65
|
* @param valueOrAlias a string that might be a value or might be an alias
|
|
69
66
|
*/
|
|
70
67
|
resolveValue(valueOrAlias) {
|
|
71
|
-
|
|
72
|
-
return (_a = this.getValue(valueOrAlias)) !== null && _a !== void 0 ? _a : valueOrAlias;
|
|
68
|
+
return this.getValue(valueOrAlias) ?? valueOrAlias;
|
|
73
69
|
}
|
|
74
70
|
/**
|
|
75
71
|
* If the provided string is an alias, it returns the corresponding username.
|
|
@@ -82,8 +78,7 @@ class GlobalInfoAliasAccessor {
|
|
|
82
78
|
* @param usernameOrAlias a string that might be a username or might be an alias
|
|
83
79
|
*/
|
|
84
80
|
resolveUsername(usernameOrAlias) {
|
|
85
|
-
|
|
86
|
-
return (_a = this.getUsername(usernameOrAlias)) !== null && _a !== void 0 ? _a : usernameOrAlias;
|
|
81
|
+
return this.getUsername(usernameOrAlias) ?? usernameOrAlias;
|
|
87
82
|
}
|
|
88
83
|
/**
|
|
89
84
|
* Set an alias for the given aliasable entity
|
|
@@ -121,10 +116,9 @@ class GlobalInfoAliasAccessor {
|
|
|
121
116
|
* Returns the username of given aliasable entity
|
|
122
117
|
*/
|
|
123
118
|
getNameOf(entity) {
|
|
124
|
-
var _a;
|
|
125
119
|
if (typeof entity === 'string')
|
|
126
120
|
return entity;
|
|
127
|
-
const aliaseeName =
|
|
121
|
+
const aliaseeName = entity.username ?? entity.user;
|
|
128
122
|
if (!aliaseeName) {
|
|
129
123
|
throw new sfError_1.SfError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
|
|
130
124
|
}
|
|
@@ -153,8 +147,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
153
147
|
* @param entity the aliasable entity that you want to get the alias of
|
|
154
148
|
*/
|
|
155
149
|
get(entity) {
|
|
156
|
-
|
|
157
|
-
return (_a = this.getAll(entity).find((alias) => alias)) !== null && _a !== void 0 ? _a : null;
|
|
150
|
+
return this.getAll(entity).find((alias) => alias) ?? null;
|
|
158
151
|
}
|
|
159
152
|
/**
|
|
160
153
|
* Returns the value that corresponds to the given alias if it exists
|
|
@@ -162,8 +155,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
162
155
|
* @param alias the alias that corresponds to a value
|
|
163
156
|
*/
|
|
164
157
|
getValue(alias) {
|
|
165
|
-
|
|
166
|
-
return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
|
|
158
|
+
return this.getAll()[alias] ?? null;
|
|
167
159
|
}
|
|
168
160
|
/**
|
|
169
161
|
* Returns the username that corresponds to the given alias if it exists
|
|
@@ -171,8 +163,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
171
163
|
* @param alias the alias that corresponds to a username
|
|
172
164
|
*/
|
|
173
165
|
getUsername(alias) {
|
|
174
|
-
|
|
175
|
-
return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
|
|
166
|
+
return this.getAll()[alias] ?? null;
|
|
176
167
|
}
|
|
177
168
|
/**
|
|
178
169
|
* If the provided string is an alias, it returns the corresponding value.
|
|
@@ -185,8 +176,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
185
176
|
* @param valueOrAlias a string that might be a value or might be an alias
|
|
186
177
|
*/
|
|
187
178
|
resolveValue(valueOrAlias) {
|
|
188
|
-
|
|
189
|
-
return (_a = this.getValue(valueOrAlias)) !== null && _a !== void 0 ? _a : valueOrAlias;
|
|
179
|
+
return this.getValue(valueOrAlias) ?? valueOrAlias;
|
|
190
180
|
}
|
|
191
181
|
/**
|
|
192
182
|
* If the provided string is an alias, it returns the corresponding username.
|
|
@@ -199,8 +189,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
199
189
|
* @param usernameOrAlias a string that might be a username or might be an alias
|
|
200
190
|
*/
|
|
201
191
|
resolveUsername(usernameOrAlias) {
|
|
202
|
-
|
|
203
|
-
return (_a = this.getUsername(usernameOrAlias)) !== null && _a !== void 0 ? _a : usernameOrAlias;
|
|
192
|
+
return this.getUsername(usernameOrAlias) ?? usernameOrAlias;
|
|
204
193
|
}
|
|
205
194
|
/**
|
|
206
195
|
* If the provided string is an alias, return it.
|
|
@@ -212,10 +201,9 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
212
201
|
* @param usernameOrAlias a string that might be a username or might be an alias
|
|
213
202
|
*/
|
|
214
203
|
resolveAlias(usernameOrAlias) {
|
|
215
|
-
var _a;
|
|
216
204
|
if (this.has(usernameOrAlias))
|
|
217
205
|
return usernameOrAlias;
|
|
218
|
-
return
|
|
206
|
+
return Object.entries(this.getAll()).find(([, username]) => username === usernameOrAlias)?.[0];
|
|
219
207
|
}
|
|
220
208
|
/**
|
|
221
209
|
* Set an alias for the given aliasable entity
|
|
@@ -260,10 +248,9 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
260
248
|
* Returns the username of given aliasable entity
|
|
261
249
|
*/
|
|
262
250
|
getNameOf(entity) {
|
|
263
|
-
var _a;
|
|
264
251
|
if (typeof entity === 'string')
|
|
265
252
|
return entity;
|
|
266
|
-
const aliaseeName =
|
|
253
|
+
const aliaseeName = entity.username ?? entity.user;
|
|
267
254
|
if (!aliaseeName) {
|
|
268
255
|
throw new sfError_1.SfError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
|
|
269
256
|
}
|
|
@@ -35,15 +35,13 @@ class GlobalInfoOrgAccessor {
|
|
|
35
35
|
return !!this.getAll()[username];
|
|
36
36
|
}
|
|
37
37
|
set(username, org) {
|
|
38
|
-
var _a;
|
|
39
38
|
// For legacy, and to keep things standard, some things wants the username in auth info.
|
|
40
|
-
|
|
39
|
+
org.username ?? (org.username = username);
|
|
41
40
|
this.globalInfo.set(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
|
|
42
41
|
}
|
|
43
42
|
update(username, org) {
|
|
44
|
-
var _a;
|
|
45
43
|
// For legacy, and to keep things standard, some things wants the username in auth info.
|
|
46
|
-
|
|
44
|
+
org.username ?? (org.username = username);
|
|
47
45
|
this.globalInfo.update(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
|
|
48
46
|
}
|
|
49
47
|
unset(username) {
|
|
@@ -176,17 +174,16 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
176
174
|
* @param org
|
|
177
175
|
*/
|
|
178
176
|
set(username, org) {
|
|
179
|
-
var _a, _b;
|
|
180
177
|
const config = this.configs.get(username);
|
|
181
178
|
if (config) {
|
|
182
179
|
config.setContentsFromObject(org);
|
|
183
180
|
const contents = config.getContents();
|
|
184
|
-
|
|
181
|
+
contents.username ?? (contents.username = username);
|
|
185
182
|
this.contents.set(username, contents);
|
|
186
183
|
}
|
|
187
184
|
else {
|
|
188
185
|
// @ts-ignore
|
|
189
|
-
|
|
186
|
+
org.username ?? (org.username = username);
|
|
190
187
|
this.contents.set(username, org);
|
|
191
188
|
}
|
|
192
189
|
}
|
|
@@ -207,8 +204,7 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
207
204
|
* @param username
|
|
208
205
|
*/
|
|
209
206
|
async remove(username) {
|
|
210
|
-
|
|
211
|
-
await ((_a = this.configs.get(username)) === null || _a === void 0 ? void 0 : _a.unlink());
|
|
207
|
+
await this.configs.get(username)?.unlink();
|
|
212
208
|
this.configs.delete(username);
|
|
213
209
|
this.contents.delete(username);
|
|
214
210
|
}
|
|
@@ -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
|
|
@@ -18,26 +18,6 @@ Expected 'durationDays' to be an integer number.
|
|
|
18
18
|
|
|
19
19
|
Expected 'retry' to be an integer number.
|
|
20
20
|
|
|
21
|
-
# WaitValidationMaxError
|
|
22
|
-
|
|
23
|
-
Expected 'wait' greater than or equal to %s but received %s.
|
|
24
|
-
|
|
25
|
-
# NoScratchOrgInfoError
|
|
26
|
-
|
|
27
|
-
No ScratchOrgInfo object found in the Dev Hub you specified. Check that the ID and the Dev Hub are correct.
|
|
28
|
-
|
|
29
|
-
# ScratchOrgDeletedError
|
|
30
|
-
|
|
31
|
-
That scratch org has been deleted, so you can't connect to it anymore.
|
|
32
|
-
|
|
33
21
|
# CacheMissError
|
|
34
22
|
|
|
35
23
|
The ScratchOrgInfoId %s was not found in the cache.
|
|
36
|
-
|
|
37
|
-
# StillInProgressError
|
|
38
|
-
|
|
39
|
-
The scratch org is not ready yet (Status = %).
|
|
40
|
-
|
|
41
|
-
# action.StillInProgress
|
|
42
|
-
|
|
43
|
-
Wait for a few minutes, and then try the <%= config.bin %> <%= command.id %> command again
|
|
@@ -14,6 +14,22 @@ See https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_ob
|
|
|
14
14
|
|
|
15
15
|
The request to create a scratch org returned an unexpected status
|
|
16
16
|
|
|
17
|
+
# StillInProgressError
|
|
18
|
+
|
|
19
|
+
The scratch org is not ready yet (Status = %).
|
|
20
|
+
|
|
21
|
+
# action.StillInProgress
|
|
22
|
+
|
|
23
|
+
Wait for a few minutes, and then try the <%= config.bin %> <%= command.id %> command again
|
|
24
|
+
|
|
25
|
+
# NoScratchOrgInfoError
|
|
26
|
+
|
|
27
|
+
No ScratchOrgInfo object found in the Dev Hub you specified. Check that the ID and the Dev Hub are correct.
|
|
28
|
+
|
|
29
|
+
# ScratchOrgDeletedError
|
|
30
|
+
|
|
31
|
+
That scratch org has been deleted, so you can't connect to it anymore.
|
|
32
|
+
|
|
17
33
|
# INVALID_ID_FIELD
|
|
18
34
|
|
|
19
35
|
Provide a valid template ID, in the format 0TTxxxxxxxxxxxx.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.24.0",
|
|
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"
|