@salesforce/core 3.30.9 → 3.30.11
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/README.md +3 -3
- package/lib/config/aliasesConfig.js +1 -0
- package/lib/config/config.js +6 -9
- package/lib/config/configAggregator.d.ts +3 -3
- package/lib/config/configAggregator.js +14 -14
- package/lib/config/configFile.js +7 -9
- package/lib/config/configGroup.js +8 -7
- package/lib/config/configStore.d.ts +4 -4
- package/lib/config/configStore.js +12 -9
- package/lib/config/envVars.js +1 -1
- package/lib/config/tokensConfig.js +1 -0
- package/lib/config/ttlConfig.d.ts +2 -0
- package/lib/config/ttlConfig.js +5 -4
- package/lib/crypto/crypto.js +9 -12
- package/lib/crypto/keyChainImpl.d.ts +2 -0
- package/lib/crypto/keyChainImpl.js +41 -34
- package/lib/deviceOauthService.js +5 -2
- package/lib/exported.js +5 -1
- package/lib/global.js +2 -0
- package/lib/lifecycleEvents.js +3 -0
- package/lib/logger.d.ts +2 -3
- package/lib/logger.js +57 -53
- package/lib/messages.js +2 -3
- package/lib/org/authInfo.js +40 -29
- package/lib/org/authRemover.js +11 -7
- package/lib/org/connection.d.ts +4 -4
- package/lib/org/connection.js +14 -6
- package/lib/org/index.js +5 -1
- package/lib/org/org.js +23 -15
- package/lib/org/scratchOrgCreate.js +2 -1
- package/lib/org/scratchOrgInfoApi.js +4 -6
- package/lib/org/scratchOrgInfoGenerator.d.ts +1 -0
- package/lib/org/scratchOrgInfoGenerator.js +28 -27
- package/lib/org/scratchOrgLifecycleEvents.js +2 -6
- package/lib/org/scratchOrgSettingsGenerator.js +9 -9
- package/lib/org/scratchOrgTypes.d.ts +1 -1
- package/lib/org/user.js +7 -6
- package/lib/schema/printer.d.ts +4 -0
- package/lib/schema/printer.js +30 -29
- package/lib/schema/validator.d.ts +1 -1
- package/lib/schema/validator.js +2 -1
- package/lib/sfError.d.ts +3 -6
- package/lib/sfError.js +26 -9
- package/lib/sfProject.js +14 -6
- package/lib/stateAggregator/accessors/aliasAccessor.js +2 -1
- package/lib/stateAggregator/accessors/orgAccessor.js +11 -6
- package/lib/stateAggregator/accessors/sandboxAccessor.js +1 -0
- package/lib/stateAggregator/index.js +5 -1
- package/lib/status/myDomainResolver.d.ts +1 -1
- package/lib/status/myDomainResolver.js +4 -4
- package/lib/status/streamingClient.js +51 -49
- package/lib/testSetup.d.ts +5 -1
- package/lib/testSetup.js +32 -21
- package/lib/util/cache.d.ts +2 -2
- package/lib/util/cache.js +6 -6
- package/lib/util/directoryWriter.d.ts +2 -1
- package/lib/util/directoryWriter.js +5 -3
- package/lib/util/jsonXmlTools.js +2 -4
- package/lib/util/mapKeys.d.ts +9 -9
- package/lib/util/mapKeys.js +13 -9
- package/lib/util/sfdc.d.ts +2 -2
- package/lib/util/sfdc.js +8 -17
- package/lib/util/sfdcUrl.d.ts +1 -1
- package/lib/util/sfdcUrl.js +2 -4
- package/lib/util/structuredWriter.d.ts +1 -0
- package/lib/util/zipWriter.d.ts +2 -1
- package/lib/util/zipWriter.js +5 -9
- package/lib/webOAuthServer.js +9 -3
- package/messages/connection.md +8 -0
- package/package.json +16 -17
package/lib/org/authInfo.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthInfo = exports.DEFAULT_CONNECTED_APP_INFO = void 0;
|
|
4
2
|
/*
|
|
5
3
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
4
|
* All rights reserved.
|
|
7
5
|
* Licensed under the BSD 3-Clause license.
|
|
8
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
7
|
*/
|
|
8
|
+
/* eslint-disable class-methods-use-this */
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AuthInfo = exports.DEFAULT_CONNECTED_APP_INFO = void 0;
|
|
10
11
|
const crypto_1 = require("crypto");
|
|
11
12
|
const path_1 = require("path");
|
|
12
13
|
const os = require("os");
|
|
@@ -109,7 +110,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
109
110
|
super(options);
|
|
110
111
|
// Possibly overridden in create
|
|
111
112
|
this.usingAccessToken = false;
|
|
112
|
-
this.options = options
|
|
113
|
+
this.options = options ?? {};
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
115
116
|
* Returns the default instance url
|
|
@@ -118,7 +119,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
118
119
|
*/
|
|
119
120
|
static getDefaultInstanceUrl() {
|
|
120
121
|
const configuredInstanceUrl = configAggregator_1.ConfigAggregator.getValue(orgConfigProperties_1.OrgConfigProperties.ORG_INSTANCE_URL).value;
|
|
121
|
-
return configuredInstanceUrl
|
|
122
|
+
return configuredInstanceUrl ?? sfdcUrl_1.SfdcUrl.PRODUCTION;
|
|
122
123
|
}
|
|
123
124
|
/**
|
|
124
125
|
* Get a list of all authorizations based on auth files stored in the global directory.
|
|
@@ -143,6 +144,8 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
143
144
|
.filter((c) => aliases.includes(c.value) || c.value === username)
|
|
144
145
|
.map((c) => c.key);
|
|
145
146
|
try {
|
|
147
|
+
// prevent ConfigFile collision bug
|
|
148
|
+
// eslint-disable-next-line no-await-in-loop
|
|
146
149
|
const authInfo = await AuthInfo.create({ username });
|
|
147
150
|
const { orgId, instanceUrl, devHubUsername, expirationDate, isDevHub } = authInfo.getFields();
|
|
148
151
|
final.push({
|
|
@@ -151,7 +154,8 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
151
154
|
username,
|
|
152
155
|
instanceUrl,
|
|
153
156
|
isScratchOrg: Boolean(devHubUsername),
|
|
154
|
-
isDevHub: isDevHub
|
|
157
|
+
isDevHub: isDevHub ?? false,
|
|
158
|
+
// eslint-disable-next-line no-await-in-loop
|
|
155
159
|
isSandbox: await stateAggregator.sandboxes.hasFile(orgId),
|
|
156
160
|
orgId: orgId,
|
|
157
161
|
accessToken: authInfo.getConnectionOptions().accessToken,
|
|
@@ -201,14 +205,14 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
201
205
|
static getAuthorizationUrl(options, oauth2) {
|
|
202
206
|
// Always use a verifier for enhanced security
|
|
203
207
|
options.useVerifier = true;
|
|
204
|
-
const oauth2Verifier = oauth2
|
|
208
|
+
const oauth2Verifier = oauth2 ?? new jsforce_1.OAuth2(options);
|
|
205
209
|
// The state parameter allows the redirectUri callback listener to ignore request
|
|
206
210
|
// that don't contain the state value.
|
|
207
211
|
const params = {
|
|
208
212
|
state: (0, crypto_1.randomBytes)(Math.ceil(6)).toString('hex'),
|
|
209
213
|
prompt: 'login',
|
|
210
214
|
// Default connected app is 'refresh_token api web'
|
|
211
|
-
scope: options.scope
|
|
215
|
+
scope: options.scope ?? kit_1.env.getString('SFDX_AUTH_SCOPES', 'refresh_token api web'),
|
|
212
216
|
};
|
|
213
217
|
return oauth2Verifier.getAuthorizationUrl(params);
|
|
214
218
|
}
|
|
@@ -281,7 +285,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
281
285
|
* Find all dev hubs available in the local environment.
|
|
282
286
|
*/
|
|
283
287
|
static async getDevHubAuthInfos() {
|
|
284
|
-
return
|
|
288
|
+
return AuthInfo.listAllAuthorizations((possibleHub) => possibleHub?.isDevHub ?? false);
|
|
285
289
|
}
|
|
286
290
|
static async queryScratchOrg(devHubUsername, scratchOrgId) {
|
|
287
291
|
const devHubOrg = await org_1.Org.create({ aliasOrUsername: devHubUsername });
|
|
@@ -346,7 +350,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
346
350
|
*/
|
|
347
351
|
update(authData) {
|
|
348
352
|
if (authData && (0, ts_types_1.isPlainObject)(authData)) {
|
|
349
|
-
this.username = authData.username
|
|
353
|
+
this.username = authData.username ?? this.username;
|
|
350
354
|
this.stateAggregator.orgs.update(this.username, authData);
|
|
351
355
|
this.logger.info(`Updated auth info for username: ${this.username}`);
|
|
352
356
|
}
|
|
@@ -381,7 +385,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
381
385
|
// Decrypt a user provided client secret or use the default.
|
|
382
386
|
opts = {
|
|
383
387
|
oauth2: {
|
|
384
|
-
loginUrl: instanceUrl
|
|
388
|
+
loginUrl: instanceUrl ?? sfdcUrl_1.SfdcUrl.PRODUCTION,
|
|
385
389
|
clientId: this.getClientId(),
|
|
386
390
|
redirectUri: this.getRedirectUri(),
|
|
387
391
|
},
|
|
@@ -394,7 +398,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
394
398
|
return opts;
|
|
395
399
|
}
|
|
396
400
|
getClientId() {
|
|
397
|
-
return this.getFields()?.clientId
|
|
401
|
+
return this.getFields()?.clientId ?? exports.DEFAULT_CONNECTED_APP_INFO.legacyClientId;
|
|
398
402
|
}
|
|
399
403
|
getRedirectUri() {
|
|
400
404
|
return 'http://localhost:1717/OauthRedirect';
|
|
@@ -432,7 +436,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
432
436
|
const instanceUrl = (0, ts_types_1.ensure)(decryptedFields.instanceUrl, 'undefined instanceUrl').replace(/^https?:\/\//, '');
|
|
433
437
|
let sfdxAuthUrl = 'force://';
|
|
434
438
|
if (decryptedFields.clientId) {
|
|
435
|
-
sfdxAuthUrl += `${decryptedFields.clientId}:${decryptedFields.clientSecret
|
|
439
|
+
sfdxAuthUrl += `${decryptedFields.clientId}:${decryptedFields.clientSecret ?? ''}:`;
|
|
436
440
|
}
|
|
437
441
|
sfdxAuthUrl += `${(0, ts_types_1.ensure)(decryptedFields.refreshToken, 'undefined refreshToken')}@${instanceUrl}`;
|
|
438
442
|
return sfdxAuthUrl;
|
|
@@ -505,7 +509,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
505
509
|
async init() {
|
|
506
510
|
this.stateAggregator = await stateAggregator_1.StateAggregator.getInstance();
|
|
507
511
|
const username = this.options.username;
|
|
508
|
-
const authOptions = this.options.oauth2Options
|
|
512
|
+
const authOptions = this.options.oauth2Options ?? this.options.accessTokenOptions;
|
|
509
513
|
// Must specify either username and/or options
|
|
510
514
|
if (!username && !authOptions) {
|
|
511
515
|
throw messages.createError('authInfoCreationError');
|
|
@@ -517,7 +521,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
517
521
|
throw messages.createError('authInfoOverwriteError');
|
|
518
522
|
}
|
|
519
523
|
}
|
|
520
|
-
const oauthUsername = username
|
|
524
|
+
const oauthUsername = username ?? authOptions?.username;
|
|
521
525
|
if (oauthUsername) {
|
|
522
526
|
this.username = oauthUsername;
|
|
523
527
|
await this.stateAggregator.orgs.read(oauthUsername, false, false);
|
|
@@ -527,7 +531,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
527
531
|
// Need to initAuthOptions the logger and authInfoCrypto since we don't call init()
|
|
528
532
|
this.logger = await logger_1.Logger.child('AuthInfo');
|
|
529
533
|
const aggregator = await configAggregator_1.ConfigAggregator.create();
|
|
530
|
-
const instanceUrl = this.getInstanceUrl(
|
|
534
|
+
const instanceUrl = this.getInstanceUrl(aggregator, authOptions);
|
|
531
535
|
this.update({
|
|
532
536
|
accessToken: oauthUsername,
|
|
533
537
|
instanceUrl,
|
|
@@ -544,7 +548,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
544
548
|
await this.initAuthOptions(authOptions);
|
|
545
549
|
}
|
|
546
550
|
}
|
|
547
|
-
getInstanceUrl(
|
|
551
|
+
getInstanceUrl(aggregator, options) {
|
|
548
552
|
const instanceUrl = options?.instanceUrl ?? aggregator.getPropertyValue(orgConfigProperties_1.OrgConfigProperties.ORG_INSTANCE_URL);
|
|
549
553
|
return instanceUrl ?? sfdcUrl_1.SfdcUrl.PRODUCTION;
|
|
550
554
|
}
|
|
@@ -595,14 +599,12 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
595
599
|
// refresh token flow (from sfdxUrl or OAuth refreshFn)
|
|
596
600
|
authConfig = await this.buildRefreshTokenConfig(options);
|
|
597
601
|
}
|
|
602
|
+
else if (this.options.oauth2 instanceof jsforce_1.OAuth2) {
|
|
603
|
+
// authcode exchange / web auth flow
|
|
604
|
+
authConfig = await this.exchangeToken(options, this.options.oauth2);
|
|
605
|
+
}
|
|
598
606
|
else {
|
|
599
|
-
|
|
600
|
-
// authcode exchange / web auth flow
|
|
601
|
-
authConfig = await this.exchangeToken(options, this.options.oauth2);
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
authConfig = await this.exchangeToken(options);
|
|
605
|
-
}
|
|
607
|
+
authConfig = await this.exchangeToken(options);
|
|
606
608
|
}
|
|
607
609
|
}
|
|
608
610
|
authConfig.isDevHub = await this.determineIfDevHub((0, ts_types_1.ensureString)(authConfig.instanceUrl), (0, ts_types_1.ensureString)(authConfig.accessToken));
|
|
@@ -613,6 +615,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
613
615
|
}
|
|
614
616
|
return this;
|
|
615
617
|
}
|
|
618
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
616
619
|
async loadDecryptedAuthFromConfig(username) {
|
|
617
620
|
// Fetch from the persisted auth file
|
|
618
621
|
const authInfo = this.stateAggregator.orgs.get(username, true);
|
|
@@ -668,6 +671,8 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
668
671
|
const loginAndAudienceUrls = (0, sfdcUrl_1.getLoginAudienceCombos)(audienceUrl, loginUrl);
|
|
669
672
|
for (const [login, audience] of loginAndAudienceUrls) {
|
|
670
673
|
try {
|
|
674
|
+
// sequentially, in probabilistic order
|
|
675
|
+
// eslint-disable-next-line no-await-in-loop
|
|
671
676
|
authFieldsBuilder = await this.tryJwtAuth(options.clientId, login, audience, privateKeyContents);
|
|
672
677
|
break;
|
|
673
678
|
}
|
|
@@ -698,7 +703,9 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
698
703
|
authFields.instanceUrl = instanceUrl;
|
|
699
704
|
}
|
|
700
705
|
catch (err) {
|
|
701
|
-
this.logger.debug(
|
|
706
|
+
this.logger.debug(
|
|
707
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
708
|
+
`Instance URL [${authFieldsBuilder.instance_url}] is not available. DNS lookup failed. Using loginUrl [${options.loginUrl}] instead. This may result in a "Destination URL not reset" error.`);
|
|
702
709
|
authFields.instanceUrl = options.loginUrl;
|
|
703
710
|
}
|
|
704
711
|
return authFields;
|
|
@@ -713,6 +720,8 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
713
720
|
algorithm: 'RS256',
|
|
714
721
|
});
|
|
715
722
|
const oauth2 = new jsforce_1.JwtOAuth2({ loginUrl });
|
|
723
|
+
// jsforce has it types as any
|
|
724
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
716
725
|
return (0, ts_types_1.ensureJsonMap)(await oauth2.jwtAuthorize(jwtToken));
|
|
717
726
|
}
|
|
718
727
|
// Build OAuth config for a refresh token auth flow
|
|
@@ -734,6 +743,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
734
743
|
catch (err) {
|
|
735
744
|
throw messages.createError('refreshTokenAuthError', [err.message]);
|
|
736
745
|
}
|
|
746
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
737
747
|
// @ts-ignore
|
|
738
748
|
const { orgId } = parseIdUrl(authFieldsBuilder.id);
|
|
739
749
|
let username = this.getUsername();
|
|
@@ -746,7 +756,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
746
756
|
username,
|
|
747
757
|
accessToken: authFieldsBuilder.access_token,
|
|
748
758
|
instanceUrl: authFieldsBuilder.instance_url,
|
|
749
|
-
loginUrl: options.loginUrl
|
|
759
|
+
loginUrl: options.loginUrl ?? authFieldsBuilder.instance_url,
|
|
750
760
|
refreshToken: options.refreshToken,
|
|
751
761
|
clientId: options.clientId,
|
|
752
762
|
clientSecret: options.clientSecret,
|
|
@@ -779,6 +789,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
779
789
|
// Only need to query for the username if it isn't known. For example, a new auth code exchange
|
|
780
790
|
// rather than refreshing a token on an existing connection.
|
|
781
791
|
if (!username) {
|
|
792
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
782
793
|
// @ts-ignore
|
|
783
794
|
const userInfo = await this.retrieveUserInfo(authFields.instance_url, authFields.access_token);
|
|
784
795
|
username = userInfo?.username;
|
|
@@ -788,7 +799,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
788
799
|
instanceUrl: authFields.instance_url,
|
|
789
800
|
orgId,
|
|
790
801
|
username,
|
|
791
|
-
loginUrl: options.loginUrl
|
|
802
|
+
loginUrl: options.loginUrl ?? authFields.instance_url,
|
|
792
803
|
refreshToken: authFields.refresh_token,
|
|
793
804
|
clientId: options.clientId,
|
|
794
805
|
clientSecret: options.clientSecret,
|
|
@@ -801,7 +812,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
801
812
|
const apiVersion = 'v51.0'; // hardcoding to v51.0 just for this call is okay.
|
|
802
813
|
const instance = (0, ts_types_1.ensure)(instanceUrl);
|
|
803
814
|
const baseUrl = new sfdcUrl_1.SfdcUrl(instance);
|
|
804
|
-
const userInfoUrl = `${baseUrl}services/oauth2/userinfo`;
|
|
815
|
+
const userInfoUrl = `${baseUrl.toString()}services/oauth2/userinfo`;
|
|
805
816
|
const headers = Object.assign({ Authorization: `Bearer ${accessToken}` }, connection_1.SFDX_HTTP_HEADERS);
|
|
806
817
|
try {
|
|
807
818
|
this.logger.info(`Sending request for Username after successful auth code exchange to URL: ${userInfoUrl}`);
|
|
@@ -811,7 +822,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
811
822
|
}
|
|
812
823
|
else {
|
|
813
824
|
const userInfoJson = (0, kit_1.parseJsonMap)(response.body);
|
|
814
|
-
const url = `${baseUrl}/services/data/${apiVersion}/sobjects/User/${userInfoJson.user_id}`;
|
|
825
|
+
const url = `${baseUrl.toString()}/services/data/${apiVersion}/sobjects/User/${userInfoJson.user_id}`;
|
|
815
826
|
this.logger.info(`Sending request for User SObject after successful auth code exchange to URL: ${url}`);
|
|
816
827
|
response = await new transport_1.default().httpRequest({ url, method: 'GET', headers });
|
|
817
828
|
if (response.statusCode >= 400) {
|
|
@@ -863,7 +874,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
863
874
|
const apiVersion = 'v51.0'; // hardcoding to v51.0 just for this call is okay.
|
|
864
875
|
const instance = (0, ts_types_1.ensure)(instanceUrl);
|
|
865
876
|
const baseUrl = new sfdcUrl_1.SfdcUrl(instance);
|
|
866
|
-
const scratchOrgInfoUrl = `${baseUrl}/services/data/${apiVersion}/query?q=SELECT%20Id%20FROM%20ScratchOrgInfo%20limit%201`;
|
|
877
|
+
const scratchOrgInfoUrl = `${baseUrl.toString()}/services/data/${apiVersion}/query?q=SELECT%20Id%20FROM%20ScratchOrgInfo%20limit%201`;
|
|
867
878
|
const headers = Object.assign({ Authorization: `Bearer ${accessToken}` }, connection_1.SFDX_HTTP_HEADERS);
|
|
868
879
|
try {
|
|
869
880
|
const res = await new transport_1.default().httpRequest({ url: scratchOrgInfoUrl, method: 'GET', headers });
|
package/lib/org/authRemover.js
CHANGED
|
@@ -59,6 +59,8 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
59
59
|
const auths = this.findAllAuths();
|
|
60
60
|
const usernames = Object.keys(auths);
|
|
61
61
|
for (const username of usernames) {
|
|
62
|
+
// prevent ConfigFile collision bug
|
|
63
|
+
// eslint-disable-next-line no-await-in-loop
|
|
62
64
|
await this.removeAuth(username);
|
|
63
65
|
}
|
|
64
66
|
}
|
|
@@ -81,10 +83,9 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
81
83
|
*/
|
|
82
84
|
findAllAuths() {
|
|
83
85
|
const orgs = this.stateAggregator.orgs.getAll();
|
|
84
|
-
return orgs.reduce((x, y) =>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}, {});
|
|
86
|
+
return orgs.reduce((x, y) =>
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
88
|
+
({ ...x, [y.username]: y }), {});
|
|
88
89
|
}
|
|
89
90
|
async init() {
|
|
90
91
|
this.logger = await logger_1.Logger.child(this.constructor.name);
|
|
@@ -98,6 +99,7 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
98
99
|
* @param usernameOrAlias username or alias
|
|
99
100
|
* @returns {Promise<string>}
|
|
100
101
|
*/
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
101
103
|
async resolveUsername(usernameOrAlias) {
|
|
102
104
|
return this.stateAggregator.aliases.resolveUsername(usernameOrAlias);
|
|
103
105
|
}
|
|
@@ -127,7 +129,7 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
127
129
|
*/
|
|
128
130
|
async unsetConfigValues(username) {
|
|
129
131
|
const aliases = this.getAliases(username);
|
|
130
|
-
this.logger.debug(`Clearing config keys for username ${username} and aliases: ${aliases}`);
|
|
132
|
+
this.logger.debug(`Clearing config keys for username ${username} and aliases: ${aliases.join(',')}`);
|
|
131
133
|
const configs = [this.config.getGlobalConfig(), this.config.getLocalConfig()];
|
|
132
134
|
for (const config of configs) {
|
|
133
135
|
if (config) {
|
|
@@ -137,7 +139,7 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
137
139
|
.filter((k) => !!k)
|
|
138
140
|
.reduce((x, y) => x.concat(y), []);
|
|
139
141
|
const allKeys = keysWithUsername.concat(keysWithAlias);
|
|
140
|
-
this.logger.debug(`Found these config keys to remove: ${allKeys}`);
|
|
142
|
+
this.logger.debug(`Found these config keys to remove: ${allKeys.join(',')}`);
|
|
141
143
|
allKeys.forEach((key) => {
|
|
142
144
|
try {
|
|
143
145
|
config.unset(key);
|
|
@@ -146,6 +148,8 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
146
148
|
this.logger.debug(`Failed to remove ${key}`);
|
|
147
149
|
}
|
|
148
150
|
});
|
|
151
|
+
// prevent ConfigFile collision bug
|
|
152
|
+
// eslint-disable-next-line no-await-in-loop
|
|
149
153
|
await config.write();
|
|
150
154
|
}
|
|
151
155
|
}
|
|
@@ -160,7 +164,7 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
160
164
|
const existingAliases = this.stateAggregator.aliases.getAll(username);
|
|
161
165
|
if (existingAliases.length === 0)
|
|
162
166
|
return;
|
|
163
|
-
this.logger.debug(`Found these aliases to remove: ${existingAliases}`);
|
|
167
|
+
this.logger.debug(`Found these aliases to remove: ${existingAliases.join(',')}`);
|
|
164
168
|
existingAliases.forEach((alias) => this.stateAggregator.aliases.unset(alias));
|
|
165
169
|
await this.stateAggregator.aliases.write();
|
|
166
170
|
}
|
package/lib/org/connection.d.ts
CHANGED
|
@@ -37,10 +37,6 @@ export interface Tooling<S extends Schema = Schema> extends JSForceTooling<S> {
|
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
export declare class Connection<S extends Schema = Schema> extends JSForceConnection<S> {
|
|
40
|
-
/**
|
|
41
|
-
* Tooling api reference.
|
|
42
|
-
*/
|
|
43
|
-
get tooling(): Tooling<S>;
|
|
44
40
|
private logger;
|
|
45
41
|
private options;
|
|
46
42
|
private username;
|
|
@@ -52,6 +48,10 @@ export declare class Connection<S extends Schema = Schema> extends JSForceConnec
|
|
|
52
48
|
* @ignore
|
|
53
49
|
*/
|
|
54
50
|
constructor(options: Connection.Options<S>);
|
|
51
|
+
/**
|
|
52
|
+
* Tooling api reference.
|
|
53
|
+
*/
|
|
54
|
+
get tooling(): Tooling<S>;
|
|
55
55
|
/**
|
|
56
56
|
* Creates an instance of a Connection. Performs additional async initializations.
|
|
57
57
|
*
|
package/lib/org/connection.js
CHANGED
|
@@ -26,8 +26,9 @@ const messages = messages_1.Messages.load('@salesforce/core', 'connection', [
|
|
|
26
26
|
'incorrectAPIVersionError',
|
|
27
27
|
'domainNotFoundError',
|
|
28
28
|
'noInstanceUrlError',
|
|
29
|
+
'noApiVersionsError',
|
|
29
30
|
]);
|
|
30
|
-
const clientId = `sfdx toolbelt:${process.env.SFDX_SET_CLIENT_IDS
|
|
31
|
+
const clientId = `sfdx toolbelt:${process.env.SFDX_SET_CLIENT_IDS ?? ''}`;
|
|
31
32
|
exports.SFDX_HTTP_HEADERS = {
|
|
32
33
|
'content-type': 'application/json',
|
|
33
34
|
'user-agent': clientId,
|
|
@@ -57,11 +58,10 @@ class Connection extends jsforce_1.Connection {
|
|
|
57
58
|
* @ignore
|
|
58
59
|
*/
|
|
59
60
|
constructor(options) {
|
|
60
|
-
super(options.connectionOptions
|
|
61
|
+
super(options.connectionOptions ?? {});
|
|
61
62
|
this.options = options;
|
|
62
63
|
this.username = options.authInfo.getUsername();
|
|
63
64
|
}
|
|
64
|
-
// The following are all initialized in either this constructor or the super constructor, sometimes conditionally...
|
|
65
65
|
/**
|
|
66
66
|
* Tooling api reference.
|
|
67
67
|
*/
|
|
@@ -82,7 +82,7 @@ class Connection extends jsforce_1.Connection {
|
|
|
82
82
|
};
|
|
83
83
|
if (!baseOptions.version) {
|
|
84
84
|
// Set the API version obtained from the config aggregator.
|
|
85
|
-
const configAggregator = options.configAggregator
|
|
85
|
+
const configAggregator = options.configAggregator ?? (await configAggregator_1.ConfigAggregator.create());
|
|
86
86
|
baseOptions.version = (0, ts_types_1.asString)(configAggregator.getInfo('org-api-version').value);
|
|
87
87
|
}
|
|
88
88
|
const providedOptions = options.authInfo.getConnectionOptions();
|
|
@@ -157,6 +157,7 @@ class Connection extends jsforce_1.Connection {
|
|
|
157
157
|
*/
|
|
158
158
|
baseUrl() {
|
|
159
159
|
// essentially the same as pathJoin(super.instanceUrl, 'services', 'data', `v${super.version}`);
|
|
160
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
160
161
|
return super._baseUrl();
|
|
161
162
|
}
|
|
162
163
|
/**
|
|
@@ -178,6 +179,11 @@ class Connection extends jsforce_1.Connection {
|
|
|
178
179
|
async retrieveMaxApiVersion() {
|
|
179
180
|
await this.isResolvable();
|
|
180
181
|
const versions = await this.request(`${this.instanceUrl}/services/data`);
|
|
182
|
+
// if the server doesn't return a list of versions, it's possibly a instanceUrl issue where the local file is out of date.
|
|
183
|
+
if (!Array.isArray(versions)) {
|
|
184
|
+
this.logger.debug(`server response for retrieveMaxApiVersion: ${versions}`);
|
|
185
|
+
throw messages.createError('noApiVersionsError');
|
|
186
|
+
}
|
|
181
187
|
this.logger.debug(`response for org versions: ${versions.map((item) => item.version).join(',')}`);
|
|
182
188
|
const max = (0, ts_types_1.ensure)((0, kit_1.maxBy)(versions, (version) => version.version));
|
|
183
189
|
return max.version;
|
|
@@ -272,6 +278,7 @@ class Connection extends jsforce_1.Connection {
|
|
|
272
278
|
* @param url Partial url.
|
|
273
279
|
*/
|
|
274
280
|
normalizeUrl(url) {
|
|
281
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
275
282
|
return this._normalizeUrl(url);
|
|
276
283
|
}
|
|
277
284
|
/**
|
|
@@ -285,7 +292,7 @@ class Connection extends jsforce_1.Connection {
|
|
|
285
292
|
async autoFetchQuery(soql, queryOptions = {}) {
|
|
286
293
|
const config = await configAggregator_1.ConfigAggregator.create();
|
|
287
294
|
// take the limit from the calling function, then the config, then default 10,000
|
|
288
|
-
const maxFetch = config.getInfo(orgConfigProperties_1.OrgConfigProperties.ORG_MAX_QUERY_LIMIT).value || queryOptions.maxFetch
|
|
295
|
+
const maxFetch = (config.getInfo(orgConfigProperties_1.OrgConfigProperties.ORG_MAX_QUERY_LIMIT).value || queryOptions.maxFetch) ?? 10000;
|
|
289
296
|
const options = Object.assign(queryOptions, {
|
|
290
297
|
autoFetch: true,
|
|
291
298
|
maxFetch,
|
|
@@ -312,7 +319,8 @@ class Connection extends jsforce_1.Connection {
|
|
|
312
319
|
}
|
|
313
320
|
if (result.totalSize > 1) {
|
|
314
321
|
throw new sfError_1.SfError(options.returnChoicesOnMultiple
|
|
315
|
-
?
|
|
322
|
+
? // eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
323
|
+
`Multiple records found. ${result.records.map((item) => item[options.choiceField]).join(',')}`
|
|
316
324
|
: 'The query returned more than 1 record', exports.SingleRecordQueryErrors.MultipleRecords);
|
|
317
325
|
}
|
|
318
326
|
return result.records[0];
|
package/lib/org/index.js
CHANGED
|
@@ -7,7 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
9
|
if (k2 === undefined) k2 = k;
|
|
10
|
-
Object.
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
11
15
|
}) : (function(o, m, k, k2) {
|
|
12
16
|
if (k2 === undefined) k2 = k;
|
|
13
17
|
o[k2] = m[k];
|
package/lib/org/org.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Licensed under the BSD 3-Clause license.
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
|
+
/* eslint-disable class-methods-use-this */
|
|
8
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
10
|
exports.Org = exports.SandboxEvents = exports.OrgTypes = void 0;
|
|
10
11
|
const path_1 = require("path");
|
|
@@ -104,14 +105,14 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
104
105
|
async: false,
|
|
105
106
|
interval: kit_1.Duration.seconds(30),
|
|
106
107
|
}) {
|
|
107
|
-
this.logger.debug(`CreateSandbox called with SandboxRequest: ${sandboxReq}`);
|
|
108
|
+
this.logger.debug(`CreateSandbox called with SandboxRequest: ${JSON.stringify(sandboxReq, undefined, 2)}`);
|
|
108
109
|
const createResult = await this.connection.tooling.create('SandboxInfo', sandboxReq);
|
|
109
|
-
this.logger.debug(`Return from calling tooling.create: ${createResult}`);
|
|
110
|
+
this.logger.debug(`Return from calling tooling.create: ${JSON.stringify(createResult, undefined, 2)}`);
|
|
110
111
|
if (Array.isArray(createResult) || !createResult.success) {
|
|
111
112
|
throw messages.createError('sandboxInfoCreateFailed', [JSON.stringify(createResult)]);
|
|
112
113
|
}
|
|
113
114
|
const sandboxCreationProgress = await this.querySandboxProcessBySandboxInfoId(createResult.id);
|
|
114
|
-
this.logger.debug(`Return from calling singleRecordQuery with tooling: ${sandboxCreationProgress}`);
|
|
115
|
+
this.logger.debug(`Return from calling singleRecordQuery with tooling: ${JSON.stringify(sandboxCreationProgress, undefined, 2)}`);
|
|
115
116
|
const isAsync = !!options.async;
|
|
116
117
|
if (isAsync) {
|
|
117
118
|
// The user didn't want us to poll, so simply return the status
|
|
@@ -119,7 +120,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
119
120
|
return sandboxCreationProgress;
|
|
120
121
|
}
|
|
121
122
|
const [wait, pollInterval] = this.validateWaitOptions(options);
|
|
122
|
-
this.logger.debug(`create - pollStatusAndAuth sandboxProcessObj ${sandboxCreationProgress}, max wait time of ${wait.minutes} minutes`);
|
|
123
|
+
this.logger.debug(`create - pollStatusAndAuth sandboxProcessObj ${JSON.stringify(sandboxCreationProgress, undefined, 2)}, max wait time of ${wait.minutes} minutes`);
|
|
123
124
|
return this.pollStatusAndAuth({
|
|
124
125
|
sandboxProcessObj: sandboxCreationProgress,
|
|
125
126
|
wait,
|
|
@@ -151,7 +152,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
151
152
|
async: false,
|
|
152
153
|
interval: kit_1.Duration.seconds(30),
|
|
153
154
|
}) {
|
|
154
|
-
this.logger.debug(`ResumeSandbox called with ResumeSandboxRequest: ${resumeSandboxRequest}`);
|
|
155
|
+
this.logger.debug(`ResumeSandbox called with ResumeSandboxRequest: ${JSON.stringify(resumeSandboxRequest, undefined, 2)}`);
|
|
155
156
|
let sandboxCreationProgress;
|
|
156
157
|
// seed the sandboxCreationProgress via the resumeSandboxRequest options
|
|
157
158
|
if (resumeSandboxRequest.SandboxName) {
|
|
@@ -165,7 +166,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
165
166
|
resumeSandboxRequest.SandboxName ?? resumeSandboxRequest.SandboxProcessObjId,
|
|
166
167
|
]);
|
|
167
168
|
}
|
|
168
|
-
this.logger.debug(`Return from calling singleRecordQuery with tooling: ${sandboxCreationProgress}`);
|
|
169
|
+
this.logger.debug(`Return from calling singleRecordQuery with tooling: ${JSON.stringify(sandboxCreationProgress, undefined, 2)}`);
|
|
169
170
|
await lifecycleEvents_1.Lifecycle.getInstance().emit(SandboxEvents.EVENT_RESUME, sandboxCreationProgress);
|
|
170
171
|
const [wait, pollInterval] = this.validateWaitOptions(options);
|
|
171
172
|
// if wait is 0, return the sandboxCreationProgress immediately
|
|
@@ -176,7 +177,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
176
177
|
if (sandboxInfo) {
|
|
177
178
|
await lifecycleEvents_1.Lifecycle.getInstance().emit(SandboxEvents.EVENT_AUTH, sandboxInfo);
|
|
178
179
|
try {
|
|
179
|
-
this.logger.debug(`sandbox signup complete with ${sandboxInfo}`);
|
|
180
|
+
this.logger.debug(`sandbox signup complete with ${JSON.stringify(sandboxInfo, undefined, 2)}`);
|
|
180
181
|
await this.writeSandboxAuthFile(sandboxCreationProgress, sandboxInfo);
|
|
181
182
|
return sandboxCreationProgress;
|
|
182
183
|
}
|
|
@@ -188,7 +189,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
188
189
|
await lifecycleEvents_1.Lifecycle.getInstance().emit(SandboxEvents.EVENT_ASYNC_RESULT, sandboxCreationProgress);
|
|
189
190
|
throw messages.createError('sandboxCreateNotComplete');
|
|
190
191
|
}
|
|
191
|
-
this.logger.debug(`resume - pollStatusAndAuth sandboxProcessObj ${sandboxCreationProgress}, max wait time of ${wait.minutes} minutes`);
|
|
192
|
+
this.logger.debug(`resume - pollStatusAndAuth sandboxProcessObj ${JSON.stringify(sandboxCreationProgress, undefined, 2)}, max wait time of ${wait.minutes} minutes`);
|
|
192
193
|
return this.pollStatusAndAuth({
|
|
193
194
|
sandboxProcessObj: sandboxCreationProgress,
|
|
194
195
|
wait,
|
|
@@ -236,7 +237,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
236
237
|
}
|
|
237
238
|
throw err;
|
|
238
239
|
}
|
|
239
|
-
return this.manageDelete(async () =>
|
|
240
|
+
return this.manageDelete(async () => fs.promises.rmdir(dataPath), dataPath, throwWhenRemoveFails);
|
|
240
241
|
}
|
|
241
242
|
/**
|
|
242
243
|
* @ignore
|
|
@@ -449,7 +450,11 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
449
450
|
*/
|
|
450
451
|
async setTracksSource(value) {
|
|
451
452
|
const originalAuth = await authInfo_1.AuthInfo.create({ username: this.getUsername() });
|
|
452
|
-
originalAuth.handleAliasAndDefaultSettings({
|
|
453
|
+
return originalAuth.handleAliasAndDefaultSettings({
|
|
454
|
+
setDefault: false,
|
|
455
|
+
setDefaultDevHub: false,
|
|
456
|
+
setTracksSource: value,
|
|
457
|
+
});
|
|
453
458
|
}
|
|
454
459
|
/**
|
|
455
460
|
* Returns `true` if the org is a scratch org.
|
|
@@ -660,14 +665,14 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
660
665
|
* Returns an org field. Returns undefined if the field is not set or invalid.
|
|
661
666
|
*/
|
|
662
667
|
getField(key) {
|
|
663
|
-
|
|
668
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */
|
|
664
669
|
// @ts-ignore Legacy. We really shouldn't be doing this.
|
|
665
670
|
const ownProp = this[key];
|
|
666
671
|
if (ownProp && typeof ownProp !== 'function')
|
|
667
672
|
return ownProp;
|
|
668
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
669
673
|
// @ts-ignore
|
|
670
674
|
return this.getConnection().getAuthInfoFields()[key];
|
|
675
|
+
/* eslint-enable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */
|
|
671
676
|
}
|
|
672
677
|
/**
|
|
673
678
|
* Returns a map of requested fields.
|
|
@@ -740,7 +745,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
740
745
|
const aliasOrUsername = this.options.isDevHub
|
|
741
746
|
? this.configAggregator.getPropertyValue(orgConfigProperties_1.OrgConfigProperties.TARGET_DEV_HUB)
|
|
742
747
|
: this.configAggregator.getPropertyValue(orgConfigProperties_1.OrgConfigProperties.TARGET_ORG);
|
|
743
|
-
this.options.aliasOrUsername = aliasOrUsername
|
|
748
|
+
this.options.aliasOrUsername = aliasOrUsername ?? undefined;
|
|
744
749
|
}
|
|
745
750
|
const username = stateAggregator.aliases.resolveUsername(this.options.aliasOrUsername);
|
|
746
751
|
if (!username) {
|
|
@@ -759,6 +764,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
759
764
|
/**
|
|
760
765
|
* **Throws** *{@link SfError}{ name: 'NotSupportedError' }* Throws an unsupported error.
|
|
761
766
|
*/
|
|
767
|
+
// eslint-disable-next-line class-methods-use-this
|
|
762
768
|
getDefaultOptions() {
|
|
763
769
|
throw new sfError_1.SfError('Not Supported', 'NotSupportedError');
|
|
764
770
|
}
|
|
@@ -788,7 +794,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
788
794
|
interval: kit_1.Duration.seconds(30),
|
|
789
795
|
}) {
|
|
790
796
|
const [wait, pollInterval] = this.validateWaitOptions(options);
|
|
791
|
-
this.logger.debug(`AuthWithRetries sandboxProcessObj ${sandboxProcessObj}, max wait time of ${wait.minutes} minutes`);
|
|
797
|
+
this.logger.debug(`AuthWithRetries sandboxProcessObj ${JSON.stringify(sandboxProcessObj, undefined, 2)}, max wait time of ${wait.minutes} minutes`);
|
|
792
798
|
return this.pollStatusAndAuth({
|
|
793
799
|
sandboxProcessObj,
|
|
794
800
|
wait,
|
|
@@ -817,6 +823,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
817
823
|
throw messages.createError('SandboxProcessNotFoundBySandboxName', [sandboxNameIn]);
|
|
818
824
|
}
|
|
819
825
|
}
|
|
826
|
+
// eslint-disable-next-line class-methods-use-this
|
|
820
827
|
async queryProduction(org, field, value) {
|
|
821
828
|
return org.connection.singleRecordQuery(`SELECT SandboxInfoId FROM SandboxProcess WHERE ${field} ='${value}' AND Status NOT IN ('D', 'E')`, { tooling: true });
|
|
822
829
|
}
|
|
@@ -1038,7 +1045,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
1038
1045
|
timestamp: new Date().toISOString(),
|
|
1039
1046
|
};
|
|
1040
1047
|
await this.setSandboxConfig(sandboxOrgId, sfSandbox);
|
|
1041
|
-
(await stateAggregator_1.StateAggregator.getInstance()).sandboxes.write(sandboxOrgId);
|
|
1048
|
+
await (await stateAggregator_1.StateAggregator.getInstance()).sandboxes.write(sandboxOrgId);
|
|
1042
1049
|
await lifecycleEvents_1.Lifecycle.getInstance().emit(SandboxEvents.EVENT_RESULT, {
|
|
1043
1050
|
sandboxProcessObj,
|
|
1044
1051
|
sandboxRes,
|
|
@@ -1124,6 +1131,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
1124
1131
|
callbackUrl,
|
|
1125
1132
|
};
|
|
1126
1133
|
this.logger.debug('Calling sandboxAuth with SandboxUserAuthRequest', sandboxReq);
|
|
1134
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
1127
1135
|
const url = `${this.connection.tooling._baseUrl()}/sandboxAuth`;
|
|
1128
1136
|
const params = {
|
|
1129
1137
|
method: 'POST',
|
|
@@ -83,7 +83,7 @@ const scratchOrgResume = async (jobId) => {
|
|
|
83
83
|
const configAggregator = await configAggregator_1.ConfigAggregator.create();
|
|
84
84
|
await (0, scratchOrgLifecycleEvents_1.emit)({ stage: 'deploy settings', scratchOrgInfo: soi });
|
|
85
85
|
const settingsGenerator = new scratchOrgSettingsGenerator_1.default();
|
|
86
|
-
settingsGenerator.extract({ ...soi, ...definitionjson });
|
|
86
|
+
await settingsGenerator.extract({ ...soi, ...definitionjson });
|
|
87
87
|
const [authInfo] = await Promise.all([
|
|
88
88
|
(0, scratchOrgInfoApi_1.resolveUrl)(scratchOrgAuthInfo),
|
|
89
89
|
(0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, apiVersion ??
|
|
@@ -144,6 +144,7 @@ const scratchOrgCreate = async (options) => {
|
|
|
144
144
|
cache.set(scratchOrgInfoId, {
|
|
145
145
|
hubUsername: hubOrg.getUsername(),
|
|
146
146
|
hubBaseUrl: hubOrg.getField(org_1.Org.Fields.INSTANCE_URL)?.toString(),
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
147
148
|
definitionjson: { ...(definitionjson ? JSON.parse(definitionjson) : {}), ...orgConfig, ...settings },
|
|
148
149
|
clientSecret,
|
|
149
150
|
alias,
|
|
@@ -63,8 +63,8 @@ const buildOAuth2Options = async (options) => {
|
|
|
63
63
|
logger.debug(`isJwtFlow: ${isJwtFlow}`);
|
|
64
64
|
if (isJwtFlow && !process.env.SFDX_CLIENT_SECRET) {
|
|
65
65
|
oauth2Options.privateKeyFile = options.hubOrg.getConnection().getAuthInfoFields().privateKey;
|
|
66
|
-
const retries = options?.retry
|
|
67
|
-
const timeoutInSeconds = kit_1.env.getNumber('SFDX_JWT_AUTH_RETRY_TIMEOUT')
|
|
66
|
+
const retries = options?.retry ?? kit_1.env.getNumber('SFDX_JWT_AUTH_RETRY_ATTEMPTS') ?? 0;
|
|
67
|
+
const timeoutInSeconds = kit_1.env.getNumber('SFDX_JWT_AUTH_RETRY_TIMEOUT') ?? 300;
|
|
68
68
|
const timeout = kit_1.Duration.seconds(timeoutInSeconds).milliseconds;
|
|
69
69
|
const delay = retries ? timeout / retries : 1000;
|
|
70
70
|
return {
|
|
@@ -137,9 +137,7 @@ const getAuthInfo = async (options) => {
|
|
|
137
137
|
* @param id Record ID for the ScratchOrgInfoObject
|
|
138
138
|
* @returns Promise<ScratchOrgInfo>
|
|
139
139
|
*/
|
|
140
|
-
const queryScratchOrgInfo = async (hubOrg, id) =>
|
|
141
|
-
return (await hubOrg.getConnection().sobject('ScratchOrgInfo').retrieve(id));
|
|
142
|
-
};
|
|
140
|
+
const queryScratchOrgInfo = async (hubOrg, id) => (await hubOrg.getConnection().sobject('ScratchOrgInfo').retrieve(id));
|
|
143
141
|
exports.queryScratchOrgInfo = queryScratchOrgInfo;
|
|
144
142
|
/**
|
|
145
143
|
* after we successfully signup an org we need to trade the auth token for access and refresh token.
|
|
@@ -300,7 +298,7 @@ timeout = kit_1.Duration.minutes(15)) => {
|
|
|
300
298
|
const client = await pollingClient_1.PollingClient.create(pollingOptions);
|
|
301
299
|
try {
|
|
302
300
|
const resultInProgress = await client.subscribe();
|
|
303
|
-
return (0, scratchOrgErrorCodes_1.checkScratchOrgInfoForErrors)(resultInProgress, hubOrg.getUsername());
|
|
301
|
+
return await (0, scratchOrgErrorCodes_1.checkScratchOrgInfoForErrors)(resultInProgress, hubOrg.getUsername());
|
|
304
302
|
}
|
|
305
303
|
catch (error) {
|
|
306
304
|
if (error instanceof Error) {
|