@salesforce/core 4.0.0 → 4.0.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 +1 -1
- package/README.md +93 -44
- package/lib/config/aliasesConfig.d.ts +12 -0
- package/lib/config/aliasesConfig.js +28 -0
- package/lib/config/authInfoConfig.d.ts +19 -0
- package/lib/config/authInfoConfig.js +35 -0
- package/lib/config/config.d.ts +87 -22
- package/lib/config/config.js +117 -65
- package/lib/config/configAggregator.d.ts +41 -35
- package/lib/config/configAggregator.js +102 -73
- package/lib/config/configFile.d.ts +2 -2
- package/lib/config/configFile.js +38 -29
- package/lib/config/configGroup.d.ts +141 -0
- package/lib/config/configGroup.js +225 -0
- package/lib/config/configStore.d.ts +9 -9
- package/lib/config/configStore.js +17 -15
- package/lib/config/envVars.d.ts +15 -9
- package/lib/config/envVars.js +71 -47
- package/lib/config/orgUsersConfig.js +2 -0
- package/lib/config/sandboxOrgConfig.js +2 -0
- package/lib/config/sandboxProcessCache.d.ts +16 -0
- package/lib/config/sandboxProcessCache.js +38 -0
- package/lib/config/tokensConfig.d.ts +10 -0
- package/lib/config/tokensConfig.js +29 -0
- package/lib/config/ttlConfig.d.ts +34 -0
- package/lib/config/ttlConfig.js +50 -0
- package/lib/crypto/crypto.js +15 -22
- package/lib/crypto/keyChain.js +2 -3
- package/lib/crypto/keyChainImpl.d.ts +5 -3
- package/lib/crypto/keyChainImpl.js +58 -61
- package/lib/crypto/secureBuffer.d.ts +1 -1
- package/lib/deviceOauthService.d.ts +3 -3
- package/lib/deviceOauthService.js +27 -25
- package/lib/exported.d.ts +15 -12
- package/lib/exported.js +28 -16
- package/lib/global.d.ts +11 -3
- package/lib/global.js +39 -12
- package/lib/lifecycleEvents.d.ts +1 -1
- package/lib/lifecycleEvents.js +3 -0
- package/lib/logger.d.ts +19 -9
- package/lib/logger.js +112 -86
- package/lib/messages.d.ts +53 -36
- package/lib/messages.js +81 -91
- package/lib/org/authInfo.d.ts +56 -20
- package/lib/org/authInfo.js +232 -131
- package/lib/org/authRemover.d.ts +8 -7
- package/lib/org/authRemover.js +32 -28
- package/lib/org/connection.d.ts +13 -37
- package/lib/org/connection.js +78 -124
- package/lib/org/index.js +5 -1
- package/lib/org/org.d.ts +151 -48
- package/lib/org/org.js +466 -220
- package/lib/org/orgConfigProperties.d.ts +64 -3
- package/lib/org/orgConfigProperties.js +96 -4
- package/lib/org/permissionSetAssignment.js +4 -13
- package/lib/org/scratchOrgCache.d.ts +20 -0
- package/lib/org/scratchOrgCache.js +33 -0
- package/lib/org/scratchOrgCreate.d.ts +28 -17
- package/lib/org/scratchOrgCreate.js +125 -53
- package/lib/org/scratchOrgErrorCodes.d.ts +9 -3
- package/lib/org/scratchOrgErrorCodes.js +34 -17
- package/lib/org/scratchOrgFeatureDeprecation.js +1 -6
- package/lib/org/scratchOrgInfoApi.d.ts +21 -47
- package/lib/org/scratchOrgInfoApi.js +129 -63
- package/lib/org/scratchOrgInfoGenerator.d.ts +6 -5
- package/lib/org/scratchOrgInfoGenerator.js +76 -62
- package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -0
- package/lib/org/scratchOrgLifecycleEvents.js +41 -0
- package/lib/org/scratchOrgSettingsGenerator.d.ts +44 -21
- package/lib/org/scratchOrgSettingsGenerator.js +165 -98
- package/lib/org/scratchOrgTypes.d.ts +43 -0
- package/lib/org/scratchOrgTypes.js +9 -0
- package/lib/org/user.d.ts +1 -1
- package/lib/org/user.js +25 -34
- package/lib/schema/printer.d.ts +6 -0
- package/lib/schema/printer.js +34 -31
- package/lib/schema/validator.d.ts +12 -10
- package/lib/schema/validator.js +56 -76
- package/lib/{sfdxError.d.ts → sfError.d.ts} +12 -20
- package/lib/{sfdxError.js → sfError.js} +40 -30
- package/lib/{sfdxProject.d.ts → sfProject.d.ts} +75 -35
- package/lib/sfProject.js +651 -0
- package/lib/{globalInfo → stateAggregator}/accessors/aliasAccessor.d.ts +27 -12
- package/lib/{globalInfo → stateAggregator}/accessors/aliasAccessor.js +47 -31
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -0
- package/lib/stateAggregator/accessors/orgAccessor.js +240 -0
- package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -0
- package/lib/stateAggregator/accessors/sandboxAccessor.js +28 -0
- package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -0
- package/lib/stateAggregator/accessors/tokenAccessor.js +80 -0
- package/lib/stateAggregator/index.d.ts +4 -0
- package/lib/stateAggregator/index.js +27 -0
- package/lib/stateAggregator/stateAggregator.d.ts +25 -0
- package/lib/stateAggregator/stateAggregator.js +46 -0
- package/lib/status/myDomainResolver.d.ts +1 -1
- package/lib/status/myDomainResolver.js +4 -4
- package/lib/status/pollingClient.js +4 -4
- package/lib/status/streamingClient.d.ts +2 -2
- package/lib/status/streamingClient.js +58 -63
- package/lib/status/types.d.ts +2 -2
- package/lib/testSetup.d.ts +206 -75
- package/lib/testSetup.js +463 -165
- package/lib/util/cache.d.ts +2 -2
- package/lib/util/cache.js +6 -6
- package/lib/util/checkLightningDomain.js +3 -4
- package/lib/util/directoryWriter.d.ts +12 -0
- package/lib/util/directoryWriter.js +54 -0
- package/lib/util/getJwtAudienceUrl.js +1 -1
- package/lib/util/internal.d.ts +28 -2
- package/lib/util/internal.js +65 -8
- 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 +51 -51
- package/lib/util/sfdc.js +74 -79
- package/lib/util/sfdcUrl.d.ts +5 -19
- package/lib/util/sfdcUrl.js +40 -49
- package/lib/util/structuredWriter.d.ts +9 -0
- package/lib/util/structuredWriter.js +3 -0
- package/lib/util/zipWriter.d.ts +8 -6
- package/lib/util/zipWriter.js +13 -13
- package/lib/webOAuthServer.d.ts +20 -6
- package/lib/webOAuthServer.js +102 -56
- package/messageTransformer/messageTransformer.ts +93 -0
- package/messages/auth.md +9 -1
- package/messages/config.md +42 -6
- package/messages/connection.md +8 -0
- package/messages/core.md +10 -0
- package/messages/envVars.md +37 -3
- package/messages/org.md +21 -1
- package/messages/scratchOrgCreate.md +2 -6
- package/messages/scratchOrgErrorCodes.md +17 -1
- package/messages/scratchOrgInfoApi.md +9 -0
- package/messages/scratchOrgInfoGenerator.md +9 -1
- package/package.json +121 -46
- package/CHANGELOG.md +0 -1244
- package/lib/config/keychainConfig.d.ts +0 -19
- package/lib/config/keychainConfig.js +0 -43
- package/lib/globalInfo/accessors/orgAccessor.d.ts +0 -13
- package/lib/globalInfo/accessors/orgAccessor.js +0 -45
- package/lib/globalInfo/accessors/tokenAccessor.d.ts +0 -13
- package/lib/globalInfo/accessors/tokenAccessor.js +0 -35
- package/lib/globalInfo/globalInfoConfig.d.ts +0 -36
- package/lib/globalInfo/globalInfoConfig.js +0 -105
- package/lib/globalInfo/index.d.ts +0 -6
- package/lib/globalInfo/index.js +0 -29
- package/lib/globalInfo/sfdxDataHandler.d.ts +0 -43
- package/lib/globalInfo/sfdxDataHandler.js +0 -217
- package/lib/globalInfo/types.d.ts +0 -39
- package/lib/globalInfo/types.js +0 -10
- package/lib/sfdxProject.js +0 -557
- package/lib/util/fs.d.ts +0 -201
- package/lib/util/fs.js +0 -378
package/lib/config/envVars.js
CHANGED
|
@@ -11,9 +11,8 @@ const path_1 = require("path");
|
|
|
11
11
|
const change_case_1 = require("change-case");
|
|
12
12
|
const kit_1 = require("@salesforce/kit");
|
|
13
13
|
const messages_1 = require("../messages");
|
|
14
|
-
const
|
|
15
|
-
messages_1.Messages.importMessagesDirectory((0, path_1.join)(__dirname));
|
|
16
|
-
const messages = messages_1.Messages.loadMessages('@salesforce/core', 'envVars');
|
|
14
|
+
const lifecycleEvents_1 = require("../lifecycleEvents");
|
|
15
|
+
const messages = new messages_1.Messages('@salesforce/core', 'envVars', new Map([["forceOpenUrl", "Web page that opens in your browser when you connect to an org. For example, to open Lightning Experience, set to \"lightning\"."], ["forceShowSpinner", "Set to true to show a spinner animation on the command line when running asynchronous CLI commands. Default is false."], ["forceSpinnerDelay", "Speed of the spinner in milliseconds. Default is 60."], ["httpProxy", "HTTP URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy."], ["httpsProxy", "HTTPS URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy."], ["nodeExtraCaCerts", "Fully qualified path to your self-signed certificate. Will be installed after you run \"sfdx update\"."], ["nodeTlsRejectUnauthorized", "Set to 0 to allow Node.js to use the self-signed certificate in the certificate chain."], ["sfdxAccessToken", "Specifies an access token when using the auth:accesstoken:store command."], ["sfdxApiVersion", "The API version for a specific project or all projects. Default value is the API version of your Dev Hub. Overrides the apiVersion config value."], ["sfdxAudienceUrl", "URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you\u2019re logging into."], ["sfdxCodeCoverageRequirement", "Code coverage percentages that are displayed in green when you run force:apex:test:\\* with the --codecoverage parameter."], ["sfdxContentType", "Set to JSON so that all CLI commands output results in JSON format."], ["sfdxDefaultdevhubusername", "Username or alias of your default Dev Hub org. Overrides the defaultdevhubusername configuration value."], ["sfdxDefaultusername", "Username or alias of your default org. Overrides the defaultusername configuration value."], ["sfdxDisableAutoupdate", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfdxAutoupdateDisable", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfdxDisableSourceMemberPolling", "Set to true to disable polling of your org\u2019s SourceMember object when you run the force:source:push|pull commands. Default value is false."], ["sfdxDisableTelemetry", "Set to true to disable Salesforce CLI from collecting usage information, user environment information, and crash reports. Default value is false. Overrides the disableTelemetry configration variable."], ["sfdxDnsTimeout", "Number of seconds that the force:org:\\* commands wait for a response when checking whether an org is connected. Default value is 3."], ["sfdxDomainRetry", "Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom domain to resolve and become available in a scratch org. Default value is 240."], ["sfdxImprovedCodeCoverage", "Set to true to scope Apex test results to the classes entered during a test run when running force:apex:test:\\*."], ["sfdxInstanceUrl", "URL of the Salesforce instance that is hosting your org. Default value is https://login.salesforce.com. Overrides the instanceUrl configuration value."], ["sfdxJsonToStdout", "Set to true to send messages resulting from failed Salesforce CLI commands to stdout instead of stderr."], ["sfdxDisableLogFile", "Set to true to disable log file writing"], ["sfdxLogLevel", "Level of messages that the CLI writes to the log file. Valid values are trace, debug, info, warn, error, fatal. Default value is warn."], ["sfdxLogRotationCount", "The default rotation period for logs. Example '1d' will rotate logs daily (at midnight)."], ["sfdxLogRotationPeriod", "The number of backup rotated log files to keep. Example: '3' will have the base sf.log file, and the past 3 (period) log files."], ["sfdxMaxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default value is 10,000. Overrides the maxQueryLimit configuration value."], ["sfdxMdapiTempDir", "Directory that contains files (in metadata format) when running certain Salesforce CLI commands, such as force:source:\\*."], ["sfdxNpmRegistry", "URL to a private npm server, where all packages that you publish are private."], ["sfdxPrecompileEnable", "Set to true to enable Apex pre-compile before the tests are run with the force:apex:test:run command. Default is false."], ["sfdxProjectAutoupdateDisableForPackageCreate", "Set to true to disable automatic updates to sfdx-project.json when running force:package:create."], ["sfdxProjectAutoupdateDisableForPackageVersionCreate", "Set to true to disable automatic updates to sfdx-project.json when running force:package:version:create."], ["sfdxRestDeploy", "Set to true to make Salesforce CLI use the Metadata REST API for deployments. By default, the CLI uses SOAP."], ["sfdxSourceMemberPollingTimeout", "Number of seconds you want the force:source:push command to keep polling the SourceMember object before the command times out."], ["sfdxUseGenericUnixKeychain", "(Linux and macOS only) Set to true if you want to use the generic UNIX keychain instead of the Linux libsecret library or macOS keychain."], ["sfdxUseProgressBar", "Set to false to disable the progress bar when running force:mdapi:deploy, force:source:deploy, or force:source:push."], ["sfdxLazyLoadModules", "Set to true to enable lazy loading of sfdx modules"], ["sfdxS3Host", "URL to S3 host"], ["sfdxUpdateInstructions", "Text that describes how to update sfdx"], ["sfdxInstaller", "Boolean indicating that the installer is running"], ["sfdxEnv", "Describes if sfdx is in \"demo\" mode"], ["sfTargetOrg", "Username or alias of your default org. Overrides the target-org configuration variable."], ["sfTargetDevHub", "Username or alias of your default Dev Hub org. Overrides the target-dev-hub configuration variable."], ["sfAccessToken", "Specifies an access token when using a login command that uses access tokens."], ["sfOrgApiVersion", "API version for a specific project or all projects. Default value is the API version of your Dev Hub. Overrides the apiVersion configuration variable."], ["sfAudienceUrl", "URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you\u2019re logging into."], ["sfCodeCoverageRequirement", "Code coverage percentages that are displayed in green when you run the Apex test CLIcommands with the --code-coverage flag."], ["sfContentType", "Set to JSON so that all CLI commands output results in JSON format."], ["sfDisableAutoupdate", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfAutoupdateDisable", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfDisableSourceMemberPolling", "Set to true to disable polling of your org\u2019s SourceMember object when you run the commands to push and pull source. Default value is false."], ["sfDisableTelemetry", "Set to true to disable Salesforce CLI from collecting usage information, user environment information, and crash reports. Default value is false. Overrides the disableTelemetry configration variable."], ["sfDnsTimeout", "Number of seconds that the env commands wait for a response when checking whether an org is connected. Default value is 3."], ["sfDomainRetry", "Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom domain to resolve and become available in a scratch org. Default value is 240."], ["sfImprovedCodeCoverage", "Set to true to scope Apex test results to the classes entered during a test run when running the Apex test commands."], ["sfOrgInstanceUrl", "URL of the Salesforce instance that is hosting your org. Default value is https://login.salesforce.com. Overrides the instanceUrl configuration variable."], ["sfJsonToStdout", "Set to true to send messages resulting from failed Salesforce CLI commands to stdout instead of stderr."], ["sfDisableLogFile", "Set to true to disable log file writing"], ["sfLogLevel", "Level of messages that the CLI writes to the log file. Valid values are trace, debug, info, warn, error, fatal. Default value is warn."], ["sfLogRotationCount", "The default rotation period for logs. Example '1d' will rotate logs daily (at midnight)."], ["sfLogRotationPeriod", "The number of backup rotated log files to keep. Example: '3' will have the base sf.log file, and the past 3 (period) log files."], ["sfOrgMaxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default value is 10,000. Overrides the maxQueryLimit configuration variable."], ["sfMdapiTempDir", "Directory that contains files (in metadata format) when running certain Salesforce CLI commands."], ["sfNpmRegistry", "URL to a private npm server, where all packages that you publish are private."], ["sfPrecompileEnable", "Set to true to enable Apex pre-compile before the tests are run with the Apex test run command. Default is false."], ["sfProjectAutoupdateDisableForPackageCreate", "Set to true to disable automatic updates to sfdx-project.json when running the package create command."], ["sfProjectAutoupdateDisableForPackageVersionCreate", "Set to true to disable automatic updates to sfdx-project.json when running the package version create command."], ["sfSourceMemberPollingTimeout", "Number of seconds you want the source push command to keep polling the SourceMember object before the command times out."], ["sfUseGenericUnixKeychain", "(Linux and macOS only) Set to true if you want to use the generic UNIX keychain instead of the Linux libsecret library or macOS keychain."], ["sfUseProgressBar", "Set to false to disable the progress bar when running the metadata deploy command."], ["sfLazyLoadModules", "Set to true to enable lazy loading of sf modules"], ["sfS3Host", "URL to S3 host"], ["sfUpdateInstructions", "Text that describes how to update sf"], ["sfInstaller", "Boolean indicating that the installer is running"], ["sfEnv", "Describes if sf is in \"demo\" mode"], ["deprecatedEnv", "Deprecated environment variable: %s. Please use %s instead."], ["deprecatedEnvDisagreement", "Deprecated environment variable: %s. Please use %s instead.\n\nYour environment has both variables populated, and with different values. The value from %s will be used."]]));
|
|
17
16
|
var EnvironmentVariable;
|
|
18
17
|
(function (EnvironmentVariable) {
|
|
19
18
|
EnvironmentVariable["FORCE_OPEN_URL"] = "FORCE_OPEN_URL";
|
|
@@ -39,7 +38,10 @@ var EnvironmentVariable;
|
|
|
39
38
|
EnvironmentVariable["SFDX_IMPROVED_CODE_COVERAGE"] = "SFDX_IMPROVED_CODE_COVERAGE";
|
|
40
39
|
EnvironmentVariable["SFDX_INSTANCE_URL"] = "SFDX_INSTANCE_URL";
|
|
41
40
|
EnvironmentVariable["SFDX_JSON_TO_STDOUT"] = "SFDX_JSON_TO_STDOUT";
|
|
41
|
+
EnvironmentVariable["SFDX_DISABLE_LOG_FILE"] = "SFDX_DISABLE_LOG_FILE";
|
|
42
42
|
EnvironmentVariable["SFDX_LOG_LEVEL"] = "SFDX_LOG_LEVEL";
|
|
43
|
+
EnvironmentVariable["SFDX_LOG_ROTATION_COUNT"] = "SFDX_LOG_ROTATION_COUNT";
|
|
44
|
+
EnvironmentVariable["SFDX_LOG_ROTATION_PERIOD"] = "SFDX_LOG_ROTATION_PERIOD";
|
|
43
45
|
EnvironmentVariable["SFDX_MAX_QUERY_LIMIT"] = "SFDX_MAX_QUERY_LIMIT";
|
|
44
46
|
EnvironmentVariable["SFDX_MDAPI_TEMP_DIR"] = "SFDX_MDAPI_TEMP_DIR";
|
|
45
47
|
EnvironmentVariable["SFDX_NPM_REGISTRY"] = "SFDX_NPM_REGISTRY";
|
|
@@ -58,7 +60,7 @@ var EnvironmentVariable;
|
|
|
58
60
|
EnvironmentVariable["SF_TARGET_ORG"] = "SF_TARGET_ORG";
|
|
59
61
|
EnvironmentVariable["SF_TARGET_DEV_HUB"] = "SF_TARGET_DEV_HUB";
|
|
60
62
|
EnvironmentVariable["SF_ACCESS_TOKEN"] = "SF_ACCESS_TOKEN";
|
|
61
|
-
EnvironmentVariable["
|
|
63
|
+
EnvironmentVariable["SF_ORG_API_VERSION"] = "SF_ORG_API_VERSION";
|
|
62
64
|
EnvironmentVariable["SF_AUDIENCE_URL"] = "SF_AUDIENCE_URL";
|
|
63
65
|
EnvironmentVariable["SF_CODE_COVERAGE_REQUIREMENT"] = "SF_CODE_COVERAGE_REQUIREMENT";
|
|
64
66
|
EnvironmentVariable["SF_CONTENT_TYPE"] = "SF_CONTENT_TYPE";
|
|
@@ -69,10 +71,13 @@ var EnvironmentVariable;
|
|
|
69
71
|
EnvironmentVariable["SF_DNS_TIMEOUT"] = "SF_DNS_TIMEOUT";
|
|
70
72
|
EnvironmentVariable["SF_DOMAIN_RETRY"] = "SF_DOMAIN_RETRY";
|
|
71
73
|
EnvironmentVariable["SF_IMPROVED_CODE_COVERAGE"] = "SF_IMPROVED_CODE_COVERAGE";
|
|
72
|
-
EnvironmentVariable["
|
|
74
|
+
EnvironmentVariable["SF_ORG_INSTANCE_URL"] = "SF_ORG_INSTANCE_URL";
|
|
73
75
|
EnvironmentVariable["SF_JSON_TO_STDOUT"] = "SF_JSON_TO_STDOUT";
|
|
76
|
+
EnvironmentVariable["SF_DISABLE_LOG_FILE"] = "SF_DISABLE_LOG_FILE";
|
|
74
77
|
EnvironmentVariable["SF_LOG_LEVEL"] = "SF_LOG_LEVEL";
|
|
75
|
-
EnvironmentVariable["
|
|
78
|
+
EnvironmentVariable["SF_LOG_ROTATION_COUNT"] = "SF_LOG_ROTATION_COUNT";
|
|
79
|
+
EnvironmentVariable["SF_LOG_ROTATION_PERIOD"] = "SF_LOG_ROTATION_PERIOD";
|
|
80
|
+
EnvironmentVariable["SF_ORG_MAX_QUERY_LIMIT"] = "SF_ORG_MAX_QUERY_LIMIT";
|
|
76
81
|
EnvironmentVariable["SF_MDAPI_TEMP_DIR"] = "SF_MDAPI_TEMP_DIR";
|
|
77
82
|
EnvironmentVariable["SF_NPM_REGISTRY"] = "SF_NPM_REGISTRY";
|
|
78
83
|
EnvironmentVariable["SF_PRECOMPILE_ENABLE"] = "SF_PRECOMPILE_ENABLE";
|
|
@@ -124,7 +129,7 @@ exports.SUPPORTED_ENV_VARS = {
|
|
|
124
129
|
},
|
|
125
130
|
[EnvironmentVariable.SFDX_API_VERSION]: {
|
|
126
131
|
description: getMessage(EnvironmentVariable.SFDX_API_VERSION),
|
|
127
|
-
synonymOf: EnvironmentVariable.
|
|
132
|
+
synonymOf: EnvironmentVariable.SF_ORG_API_VERSION,
|
|
128
133
|
},
|
|
129
134
|
[EnvironmentVariable.SFDX_AUDIENCE_URL]: {
|
|
130
135
|
description: getMessage(EnvironmentVariable.SFDX_AUDIENCE_URL),
|
|
@@ -176,19 +181,31 @@ exports.SUPPORTED_ENV_VARS = {
|
|
|
176
181
|
},
|
|
177
182
|
[EnvironmentVariable.SFDX_INSTANCE_URL]: {
|
|
178
183
|
description: getMessage(EnvironmentVariable.SFDX_INSTANCE_URL),
|
|
179
|
-
synonymOf: EnvironmentVariable.
|
|
184
|
+
synonymOf: EnvironmentVariable.SF_ORG_INSTANCE_URL,
|
|
180
185
|
},
|
|
181
186
|
[EnvironmentVariable.SFDX_JSON_TO_STDOUT]: {
|
|
182
187
|
description: getMessage(EnvironmentVariable.SFDX_JSON_TO_STDOUT),
|
|
183
188
|
synonymOf: EnvironmentVariable.SF_JSON_TO_STDOUT,
|
|
184
189
|
},
|
|
190
|
+
[EnvironmentVariable.SFDX_DISABLE_LOG_FILE]: {
|
|
191
|
+
description: getMessage(EnvironmentVariable.SFDX_DISABLE_LOG_FILE),
|
|
192
|
+
synonymOf: EnvironmentVariable.SF_DISABLE_LOG_FILE,
|
|
193
|
+
},
|
|
185
194
|
[EnvironmentVariable.SFDX_LOG_LEVEL]: {
|
|
186
195
|
description: getMessage(EnvironmentVariable.SFDX_LOG_LEVEL),
|
|
187
196
|
synonymOf: EnvironmentVariable.SF_LOG_LEVEL,
|
|
188
197
|
},
|
|
198
|
+
[EnvironmentVariable.SFDX_LOG_ROTATION_COUNT]: {
|
|
199
|
+
description: getMessage(EnvironmentVariable.SFDX_LOG_ROTATION_COUNT),
|
|
200
|
+
synonymOf: EnvironmentVariable.SF_LOG_ROTATION_COUNT,
|
|
201
|
+
},
|
|
202
|
+
[EnvironmentVariable.SFDX_LOG_ROTATION_PERIOD]: {
|
|
203
|
+
description: getMessage(EnvironmentVariable.SFDX_LOG_ROTATION_PERIOD),
|
|
204
|
+
synonymOf: EnvironmentVariable.SF_LOG_ROTATION_PERIOD,
|
|
205
|
+
},
|
|
189
206
|
[EnvironmentVariable.SFDX_MAX_QUERY_LIMIT]: {
|
|
190
207
|
description: getMessage(EnvironmentVariable.SFDX_MAX_QUERY_LIMIT),
|
|
191
|
-
synonymOf: EnvironmentVariable.
|
|
208
|
+
synonymOf: EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT,
|
|
192
209
|
},
|
|
193
210
|
[EnvironmentVariable.SFDX_MDAPI_TEMP_DIR]: {
|
|
194
211
|
description: getMessage(EnvironmentVariable.SFDX_MDAPI_TEMP_DIR),
|
|
@@ -212,7 +229,8 @@ exports.SUPPORTED_ENV_VARS = {
|
|
|
212
229
|
},
|
|
213
230
|
[EnvironmentVariable.SFDX_REST_DEPLOY]: {
|
|
214
231
|
description: getMessage(EnvironmentVariable.SFDX_REST_DEPLOY),
|
|
215
|
-
|
|
232
|
+
// this is not an "official" env var, but it supports the env=>config naming convention for the config that lives in plugin-deploy-retrieve
|
|
233
|
+
synonymOf: 'SF_ORG_METADATA_REST_DEPLOY',
|
|
216
234
|
},
|
|
217
235
|
[EnvironmentVariable.SFDX_SOURCE_MEMBER_POLLING_TIMEOUT]: {
|
|
218
236
|
description: getMessage(EnvironmentVariable.SFDX_SOURCE_MEMBER_POLLING_TIMEOUT),
|
|
@@ -259,8 +277,8 @@ exports.SUPPORTED_ENV_VARS = {
|
|
|
259
277
|
description: getMessage(EnvironmentVariable.SF_ACCESS_TOKEN),
|
|
260
278
|
synonymOf: null,
|
|
261
279
|
},
|
|
262
|
-
[EnvironmentVariable.
|
|
263
|
-
description: getMessage(EnvironmentVariable.
|
|
280
|
+
[EnvironmentVariable.SF_ORG_API_VERSION]: {
|
|
281
|
+
description: getMessage(EnvironmentVariable.SF_ORG_API_VERSION),
|
|
264
282
|
synonymOf: null,
|
|
265
283
|
},
|
|
266
284
|
[EnvironmentVariable.SF_AUDIENCE_URL]: {
|
|
@@ -303,20 +321,32 @@ exports.SUPPORTED_ENV_VARS = {
|
|
|
303
321
|
description: getMessage(EnvironmentVariable.SF_IMPROVED_CODE_COVERAGE),
|
|
304
322
|
synonymOf: null,
|
|
305
323
|
},
|
|
306
|
-
[EnvironmentVariable.
|
|
307
|
-
description: getMessage(EnvironmentVariable.
|
|
324
|
+
[EnvironmentVariable.SF_ORG_INSTANCE_URL]: {
|
|
325
|
+
description: getMessage(EnvironmentVariable.SF_ORG_INSTANCE_URL),
|
|
308
326
|
synonymOf: null,
|
|
309
327
|
},
|
|
310
328
|
[EnvironmentVariable.SF_JSON_TO_STDOUT]: {
|
|
311
329
|
description: getMessage(EnvironmentVariable.SF_JSON_TO_STDOUT),
|
|
312
330
|
synonymOf: null,
|
|
313
331
|
},
|
|
332
|
+
[EnvironmentVariable.SF_DISABLE_LOG_FILE]: {
|
|
333
|
+
description: getMessage(EnvironmentVariable.SF_DISABLE_LOG_FILE),
|
|
334
|
+
synonymOf: null,
|
|
335
|
+
},
|
|
314
336
|
[EnvironmentVariable.SF_LOG_LEVEL]: {
|
|
315
337
|
description: getMessage(EnvironmentVariable.SF_LOG_LEVEL),
|
|
316
338
|
synonymOf: null,
|
|
317
339
|
},
|
|
318
|
-
[EnvironmentVariable.
|
|
319
|
-
description: getMessage(EnvironmentVariable.
|
|
340
|
+
[EnvironmentVariable.SF_LOG_ROTATION_COUNT]: {
|
|
341
|
+
description: getMessage(EnvironmentVariable.SF_LOG_ROTATION_COUNT),
|
|
342
|
+
synonymOf: null,
|
|
343
|
+
},
|
|
344
|
+
[EnvironmentVariable.SF_LOG_ROTATION_PERIOD]: {
|
|
345
|
+
description: getMessage(EnvironmentVariable.SF_LOG_ROTATION_PERIOD),
|
|
346
|
+
synonymOf: null,
|
|
347
|
+
},
|
|
348
|
+
[EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT]: {
|
|
349
|
+
description: getMessage(EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT),
|
|
320
350
|
synonymOf: null,
|
|
321
351
|
},
|
|
322
352
|
[EnvironmentVariable.SF_MDAPI_TEMP_DIR]: {
|
|
@@ -377,55 +407,49 @@ class EnvVars extends kit_1.Env {
|
|
|
377
407
|
super(env);
|
|
378
408
|
this.resolve();
|
|
379
409
|
}
|
|
380
|
-
static defaultPrefix() {
|
|
381
|
-
if (process.argv[0].startsWith('sfdx'))
|
|
382
|
-
return 'SFDX_';
|
|
383
|
-
if (process.argv[0].startsWith('sf'))
|
|
384
|
-
return 'SF_';
|
|
385
|
-
return 'SFDX_';
|
|
386
|
-
}
|
|
387
|
-
propertyToEnvName(property, prefix = EnvVars.defaultPrefix()) {
|
|
410
|
+
static propertyToEnvName(property, prefix = EnvVars.defaultPrefix()) {
|
|
388
411
|
return `${prefix || ''}${(0, change_case_1.snakeCase)(property).toUpperCase()}`;
|
|
389
412
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
const value = this.getString(envName);
|
|
393
|
-
if (value) {
|
|
394
|
-
this.setString(property, value);
|
|
395
|
-
}
|
|
413
|
+
static defaultPrefix() {
|
|
414
|
+
return 'SF_';
|
|
396
415
|
}
|
|
397
416
|
getPropertyFromEnv(property, prefix = EnvVars.defaultPrefix()) {
|
|
398
|
-
const envName =
|
|
417
|
+
const envName = EnvVars.propertyToEnvName(property, prefix);
|
|
399
418
|
return this.get(envName);
|
|
400
419
|
}
|
|
401
420
|
asDictionary() {
|
|
402
|
-
return this.entries()
|
|
403
|
-
accumulator[key] = value;
|
|
404
|
-
return accumulator;
|
|
405
|
-
}, {});
|
|
421
|
+
return Object.fromEntries(this.entries());
|
|
406
422
|
}
|
|
407
423
|
asMap() {
|
|
408
|
-
return this.entries()
|
|
409
|
-
accumulator.set(key, value);
|
|
410
|
-
return accumulator;
|
|
411
|
-
}, new Map());
|
|
424
|
+
return new Map(this.entries());
|
|
412
425
|
}
|
|
413
426
|
resolve() {
|
|
427
|
+
// iterate everything in the real environment
|
|
428
|
+
const corrections = new Map();
|
|
414
429
|
this.entries().forEach(([key, value]) => {
|
|
415
|
-
if (exports.SUPPORTED_ENV_VARS[key]) {
|
|
416
|
-
//
|
|
417
|
-
if
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
430
|
+
if (exports.SUPPORTED_ENV_VARS[key]?.synonymOf) {
|
|
431
|
+
// we are looking at an "old" key that has a new name
|
|
432
|
+
// if the new key has a value set, use that for the old key, too
|
|
433
|
+
const newEnvName = exports.SUPPORTED_ENV_VARS[key].synonymOf;
|
|
434
|
+
if (newEnvName) {
|
|
435
|
+
const valueOfNewName = this.getString(newEnvName);
|
|
436
|
+
if (!valueOfNewName) {
|
|
437
|
+
void lifecycleEvents_1.Lifecycle.getInstance().emitWarning(messages.getMessage('deprecatedEnv', [key, newEnvName]));
|
|
438
|
+
corrections.set(newEnvName, value);
|
|
439
|
+
}
|
|
440
|
+
else if (valueOfNewName !== value) {
|
|
441
|
+
void lifecycleEvents_1.Lifecycle.getInstance().emitWarning(messages.getMessage('deprecatedEnvDisagreement', [key, newEnvName, newEnvName]));
|
|
442
|
+
corrections.set(key, valueOfNewName ?? value);
|
|
422
443
|
}
|
|
423
444
|
}
|
|
424
445
|
}
|
|
425
446
|
});
|
|
447
|
+
corrections.forEach((v, k) => {
|
|
448
|
+
this.setString(k, v);
|
|
449
|
+
});
|
|
426
450
|
}
|
|
427
451
|
get(envName) {
|
|
428
|
-
return this.
|
|
452
|
+
return this.asMap().get(envName);
|
|
429
453
|
}
|
|
430
454
|
}
|
|
431
455
|
exports.EnvVars = EnvVars;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.OrgUsersConfig = void 0;
|
|
10
|
+
const global_1 = require("../global");
|
|
10
11
|
const configFile_1 = require("./configFile");
|
|
11
12
|
/**
|
|
12
13
|
* A config file that stores usernames for an org.
|
|
@@ -33,6 +34,7 @@ class OrgUsersConfig extends configFile_1.ConfigFile {
|
|
|
33
34
|
isState: true,
|
|
34
35
|
filename: `${orgId}.json`,
|
|
35
36
|
orgId,
|
|
37
|
+
stateFolder: global_1.Global.SFDX_STATE_FOLDER,
|
|
36
38
|
};
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.SandboxOrgConfig = void 0;
|
|
10
|
+
const global_1 = require("../global");
|
|
10
11
|
const configFile_1 = require("./configFile");
|
|
11
12
|
/**
|
|
12
13
|
* A config file that stores usernames for an org.
|
|
@@ -33,6 +34,7 @@ class SandboxOrgConfig extends configFile_1.ConfigFile {
|
|
|
33
34
|
isState: true,
|
|
34
35
|
filename: `${orgId}.sandbox.json`,
|
|
35
36
|
orgId,
|
|
37
|
+
stateFolder: global_1.Global.SFDX_STATE_FOLDER,
|
|
36
38
|
};
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SandboxProcessObject, SandboxRequest } from '../org';
|
|
2
|
+
import { TTLConfig } from './ttlConfig';
|
|
3
|
+
export type SandboxRequestCacheEntry = {
|
|
4
|
+
alias?: string;
|
|
5
|
+
setDefault: boolean;
|
|
6
|
+
prodOrgUsername: string;
|
|
7
|
+
sandboxProcessObject: Partial<SandboxProcessObject>;
|
|
8
|
+
sandboxRequest: Partial<SandboxRequest>;
|
|
9
|
+
tracksSource?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare class SandboxRequestCache extends TTLConfig<TTLConfig.Options, SandboxRequestCacheEntry> {
|
|
12
|
+
static getDefaultOptions(): TTLConfig.Options;
|
|
13
|
+
static unset(key: string): Promise<void>;
|
|
14
|
+
static set(key: string, sandboxProcessObject: SandboxRequestCacheEntry): Promise<void>;
|
|
15
|
+
static getFileName(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxRequestCache = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
const kit_1 = require("@salesforce/kit");
|
|
11
|
+
const global_1 = require("../global");
|
|
12
|
+
const ttlConfig_1 = require("./ttlConfig");
|
|
13
|
+
class SandboxRequestCache extends ttlConfig_1.TTLConfig {
|
|
14
|
+
static getDefaultOptions() {
|
|
15
|
+
return {
|
|
16
|
+
isGlobal: true,
|
|
17
|
+
isState: true,
|
|
18
|
+
filename: SandboxRequestCache.getFileName(),
|
|
19
|
+
stateFolder: global_1.Global.SF_STATE_FOLDER,
|
|
20
|
+
ttl: kit_1.Duration.days(14),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static async unset(key) {
|
|
24
|
+
const cache = await SandboxRequestCache.create();
|
|
25
|
+
cache.unset(key);
|
|
26
|
+
await cache.write();
|
|
27
|
+
}
|
|
28
|
+
static async set(key, sandboxProcessObject) {
|
|
29
|
+
const cache = await SandboxRequestCache.create();
|
|
30
|
+
cache.set(key, sandboxProcessObject);
|
|
31
|
+
await cache.write();
|
|
32
|
+
}
|
|
33
|
+
static getFileName() {
|
|
34
|
+
return 'sandbox-create-cache.json';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.SandboxRequestCache = SandboxRequestCache;
|
|
38
|
+
//# sourceMappingURL=sandboxProcessCache.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Optional } from '@salesforce/ts-types';
|
|
2
|
+
import { SfTokens } from '../stateAggregator';
|
|
3
|
+
import { ConfigFile } from './configFile';
|
|
4
|
+
import { ConfigContents, ConfigValue } from './configStore';
|
|
5
|
+
export declare class TokensConfig extends ConfigFile<ConfigFile.Options, SfTokens> {
|
|
6
|
+
protected static encryptedKeys: RegExp[];
|
|
7
|
+
static getDefaultOptions(): ConfigFile.Options;
|
|
8
|
+
protected getMethod(contents: ConfigContents, key: string): Optional<ConfigValue>;
|
|
9
|
+
protected setMethod(contents: ConfigContents, key: string, value?: ConfigValue): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
/* eslint-disable class-methods-use-this */
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.TokensConfig = void 0;
|
|
11
|
+
const configFile_1 = require("./configFile");
|
|
12
|
+
class TokensConfig extends configFile_1.ConfigFile {
|
|
13
|
+
static getDefaultOptions() {
|
|
14
|
+
return {
|
|
15
|
+
isGlobal: true,
|
|
16
|
+
isState: true,
|
|
17
|
+
filename: 'tokens.json',
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
getMethod(contents, key) {
|
|
21
|
+
return contents[key];
|
|
22
|
+
}
|
|
23
|
+
setMethod(contents, key, value) {
|
|
24
|
+
contents[key] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.TokensConfig = TokensConfig;
|
|
28
|
+
TokensConfig.encryptedKeys = [/token/i, /password/i, /secret/i];
|
|
29
|
+
//# sourceMappingURL=tokensConfig.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Duration } from '@salesforce/kit';
|
|
2
|
+
import { JsonMap, Nullable } from '@salesforce/ts-types';
|
|
3
|
+
import { ConfigFile } from './configFile';
|
|
4
|
+
/**
|
|
5
|
+
* A Time To Live configuration file where each entry is timestamped and removed once the TTL has expired.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```
|
|
9
|
+
* import { Duration } from '@salesforce/kit';
|
|
10
|
+
* const config = await TTLConfig.create({
|
|
11
|
+
* isGlobal: false,
|
|
12
|
+
* ttl: Duration.days(1)
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class TTLConfig<T extends TTLConfig.Options, P extends JsonMap> extends ConfigFile<T, TTLConfig.Contents<P>> {
|
|
17
|
+
set(key: string, value: Partial<TTLConfig.Entry<P>>): void;
|
|
18
|
+
getLatestEntry(): Nullable<[string, TTLConfig.Entry<P>]>;
|
|
19
|
+
getLatestKey(): Nullable<string>;
|
|
20
|
+
isExpired(dateTime: number, value: P & {
|
|
21
|
+
timestamp: string;
|
|
22
|
+
}): boolean;
|
|
23
|
+
protected init(): Promise<void>;
|
|
24
|
+
private timestamp;
|
|
25
|
+
}
|
|
26
|
+
export declare namespace TTLConfig {
|
|
27
|
+
type Options = ConfigFile.Options & {
|
|
28
|
+
ttl: Duration;
|
|
29
|
+
};
|
|
30
|
+
type Entry<T extends JsonMap> = T & {
|
|
31
|
+
timestamp: string;
|
|
32
|
+
};
|
|
33
|
+
type Contents<T extends JsonMap> = Record<string, Entry<T>>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TTLConfig = void 0;
|
|
10
|
+
const configFile_1 = require("./configFile");
|
|
11
|
+
/**
|
|
12
|
+
* A Time To Live configuration file where each entry is timestamped and removed once the TTL has expired.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```
|
|
16
|
+
* import { Duration } from '@salesforce/kit';
|
|
17
|
+
* const config = await TTLConfig.create({
|
|
18
|
+
* isGlobal: false,
|
|
19
|
+
* ttl: Duration.days(1)
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
class TTLConfig extends configFile_1.ConfigFile {
|
|
24
|
+
set(key, value) {
|
|
25
|
+
super.set(key, this.timestamp(value));
|
|
26
|
+
}
|
|
27
|
+
getLatestEntry() {
|
|
28
|
+
const entries = this.entries();
|
|
29
|
+
const sorted = entries.sort(([, valueA], [, valueB]) => new Date(valueB.timestamp).getTime() - new Date(valueA.timestamp).getTime());
|
|
30
|
+
return sorted.length > 0 ? sorted[0] : null;
|
|
31
|
+
}
|
|
32
|
+
getLatestKey() {
|
|
33
|
+
const [key] = this.getLatestEntry() ?? [null];
|
|
34
|
+
return key;
|
|
35
|
+
}
|
|
36
|
+
isExpired(dateTime, value) {
|
|
37
|
+
return dateTime - new Date(value.timestamp).getTime() > this.options.ttl.milliseconds;
|
|
38
|
+
}
|
|
39
|
+
async init() {
|
|
40
|
+
const contents = await this.read(this.options.throwOnNotFound);
|
|
41
|
+
const date = new Date().getTime();
|
|
42
|
+
this.setContents(Object.fromEntries(Object.entries(contents).filter(([, value]) => !this.isExpired(date, value))));
|
|
43
|
+
}
|
|
44
|
+
// eslint-disable-next-line class-methods-use-this
|
|
45
|
+
timestamp(value) {
|
|
46
|
+
return { ...value, timestamp: new Date().toISOString() };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.TTLConfig = TTLConfig;
|
|
50
|
+
//# sourceMappingURL=ttlConfig.js.map
|
package/lib/crypto/crypto.js
CHANGED
|
@@ -16,6 +16,7 @@ const kit_1 = require("@salesforce/kit");
|
|
|
16
16
|
const logger_1 = require("../logger");
|
|
17
17
|
const messages_1 = require("../messages");
|
|
18
18
|
const cache_1 = require("../util/cache");
|
|
19
|
+
const global_1 = require("../global");
|
|
19
20
|
const keyChain_1 = require("./keyChain");
|
|
20
21
|
const secureBuffer_1 = require("./secureBuffer");
|
|
21
22
|
const TAG_DELIMITER = ':';
|
|
@@ -25,13 +26,7 @@ const AUTH_TAG_LENGTH = 32;
|
|
|
25
26
|
const ENCRYPTED_CHARS = /[a-f0-9]/;
|
|
26
27
|
const KEY_NAME = 'sfdx';
|
|
27
28
|
const ACCOUNT = 'local';
|
|
28
|
-
messages_1.Messages
|
|
29
|
-
const messages = messages_1.Messages.load('@salesforce/core', 'encryption', [
|
|
30
|
-
'keychainPasswordCreationError',
|
|
31
|
-
'invalidEncryptedFormatError',
|
|
32
|
-
'authDecryptError',
|
|
33
|
-
'macKeychainOutOfSync',
|
|
34
|
-
]);
|
|
29
|
+
const messages = new messages_1.Messages('@salesforce/core', 'encryption', new Map([["invalidEncryptedFormatError", "The encrypted data is not properly formatted."], ["invalidEncryptedFormatError.actions", ["If attempting to create a scratch org then re-authorize. Otherwise create a new scratch org."]], ["authDecryptError", "Failed to decipher auth data. reason: %s."], ["unsupportedOperatingSystemError", "Unsupported Operating System: %s"], ["missingCredentialProgramError", "Unable to find required security software: %s"], ["credentialProgramAccessError", "Unable to execute security software: %s"], ["passwordRetryError", "Failed to get the password after %i retries."], ["passwordRequiredError", "A password is required."], ["keyChainServiceRequiredError", "Unable to get or set a keychain value without a service name."], ["keyChainAccountRequiredError", "Unable to get or set a keychain value without an account name."], ["keyChainUserCanceledError", "User canceled authentication."], ["keychainPasswordCreationError", "Failed to create a password in the keychain."], ["genericKeychainServiceError", "The service and account specified in %s do not match the version of the toolbelt."], ["genericKeychainServiceError.actions", ["Check your toolbelt version and re-auth."]], ["genericKeychainInvalidPermsError", "Invalid file permissions for secret file"], ["genericKeychainInvalidPermsError.actions", ["Ensure the file %s has the file permission octal value of %s."]], ["passwordNotFoundError", "Could not find password.\n%s"], ["passwordNotFoundError.actions", ["Ensure a valid password is returned with the following command: [%s]"]], ["setCredentialError", "Command failed with response:\n%s"], ["setCredentialError.actions", ["Determine why this command failed to set an encryption key for user %s: [%s]."]], ["macKeychainOutOfSync", "We\u2019ve encountered an error with the Mac keychain being out of sync with your `sfdx` credentials. To fix the problem, sync your credentials by authenticating into your org again using the auth commands."]]));
|
|
35
30
|
const makeSecureBuffer = (password) => {
|
|
36
31
|
const newSb = new secureBuffer_1.SecureBuffer();
|
|
37
32
|
newSb.consume(Buffer.from((0, ts_types_1.ensure)(password), 'utf8'));
|
|
@@ -49,23 +44,20 @@ const keychainPromises = {
|
|
|
49
44
|
* @param account The keychain account name.
|
|
50
45
|
*/
|
|
51
46
|
getPassword(_keychain, service, account) {
|
|
52
|
-
const
|
|
47
|
+
const cacheKey = `${global_1.Global.DIR}:${service}:${account}`;
|
|
48
|
+
const sb = cache_1.Cache.get(cacheKey);
|
|
53
49
|
if (!sb) {
|
|
54
|
-
return new Promise((resolve, reject) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
61
|
-
});
|
|
50
|
+
return new Promise((resolve, reject) => _keychain.getPassword({ service, account }, (err, password) => {
|
|
51
|
+
if (err)
|
|
52
|
+
return reject(err);
|
|
53
|
+
cache_1.Cache.set(cacheKey, makeSecureBuffer(password));
|
|
54
|
+
return resolve({ username: account, password: (0, ts_types_1.ensure)(password) });
|
|
55
|
+
}));
|
|
62
56
|
}
|
|
63
57
|
else {
|
|
64
58
|
const pw = sb.value((buffer) => buffer.toString('utf8'));
|
|
65
|
-
cache_1.Cache.set(
|
|
66
|
-
return new Promise((resolve) => {
|
|
67
|
-
return resolve({ username: account, password: (0, ts_types_1.ensure)(pw) });
|
|
68
|
-
});
|
|
59
|
+
cache_1.Cache.set(cacheKey, makeSecureBuffer(pw));
|
|
60
|
+
return new Promise((resolve) => resolve({ username: account, password: (0, ts_types_1.ensure)(pw) }));
|
|
69
61
|
}
|
|
70
62
|
},
|
|
71
63
|
/**
|
|
@@ -98,7 +90,7 @@ class Crypto extends kit_1.AsyncOptionalCreatable {
|
|
|
98
90
|
constructor(options) {
|
|
99
91
|
super(options);
|
|
100
92
|
this.key = new secureBuffer_1.SecureBuffer();
|
|
101
|
-
this.options = options
|
|
93
|
+
this.options = options ?? {};
|
|
102
94
|
}
|
|
103
95
|
encrypt(text) {
|
|
104
96
|
if (text == null) {
|
|
@@ -137,7 +129,7 @@ class Crypto extends kit_1.AsyncOptionalCreatable {
|
|
|
137
129
|
}
|
|
138
130
|
catch (err) {
|
|
139
131
|
const error = messages.createError('authDecryptError', [err.message], [], err);
|
|
140
|
-
const useGenericUnixKeychain = kit_1.env.getBoolean('
|
|
132
|
+
const useGenericUnixKeychain = kit_1.env.getBoolean('SF_USE_GENERIC_UNIX_KEYCHAIN') || kit_1.env.getBoolean('USE_GENERIC_UNIX_KEYCHAIN');
|
|
141
133
|
if (os.platform() === 'darwin' && !useGenericUnixKeychain) {
|
|
142
134
|
error.actions = [messages.getMessage('macKeychainOutOfSync')];
|
|
143
135
|
}
|
|
@@ -153,6 +145,7 @@ class Crypto extends kit_1.AsyncOptionalCreatable {
|
|
|
153
145
|
* @param text The text
|
|
154
146
|
* @returns true if the text is encrypted, false otherwise.
|
|
155
147
|
*/
|
|
148
|
+
// eslint-disable-next-line class-methods-use-this
|
|
156
149
|
isEncrypted(text) {
|
|
157
150
|
if (text == null) {
|
|
158
151
|
return false;
|
package/lib/crypto/keyChain.js
CHANGED
|
@@ -11,8 +11,7 @@ const kit_1 = require("@salesforce/kit");
|
|
|
11
11
|
const logger_1 = require("../logger");
|
|
12
12
|
const messages_1 = require("../messages");
|
|
13
13
|
const keyChainImpl_1 = require("./keyChainImpl");
|
|
14
|
-
messages_1.Messages.
|
|
15
|
-
const messages = messages_1.Messages.load('@salesforce/core', 'encryption', ['unsupportedOperatingSystemError']);
|
|
14
|
+
const messages = new messages_1.Messages('@salesforce/core', 'encryption', new Map([["invalidEncryptedFormatError", "The encrypted data is not properly formatted."], ["invalidEncryptedFormatError.actions", ["If attempting to create a scratch org then re-authorize. Otherwise create a new scratch org."]], ["authDecryptError", "Failed to decipher auth data. reason: %s."], ["unsupportedOperatingSystemError", "Unsupported Operating System: %s"], ["missingCredentialProgramError", "Unable to find required security software: %s"], ["credentialProgramAccessError", "Unable to execute security software: %s"], ["passwordRetryError", "Failed to get the password after %i retries."], ["passwordRequiredError", "A password is required."], ["keyChainServiceRequiredError", "Unable to get or set a keychain value without a service name."], ["keyChainAccountRequiredError", "Unable to get or set a keychain value without an account name."], ["keyChainUserCanceledError", "User canceled authentication."], ["keychainPasswordCreationError", "Failed to create a password in the keychain."], ["genericKeychainServiceError", "The service and account specified in %s do not match the version of the toolbelt."], ["genericKeychainServiceError.actions", ["Check your toolbelt version and re-auth."]], ["genericKeychainInvalidPermsError", "Invalid file permissions for secret file"], ["genericKeychainInvalidPermsError.actions", ["Ensure the file %s has the file permission octal value of %s."]], ["passwordNotFoundError", "Could not find password.\n%s"], ["passwordNotFoundError.actions", ["Ensure a valid password is returned with the following command: [%s]"]], ["setCredentialError", "Command failed with response:\n%s"], ["setCredentialError.actions", ["Determine why this command failed to set an encryption key for user %s: [%s]."]], ["macKeychainOutOfSync", "We\u2019ve encountered an error with the Mac keychain being out of sync with your `sfdx` credentials. To fix the problem, sync your credentials by authenticating into your org again using the auth commands."]]));
|
|
16
15
|
/**
|
|
17
16
|
* Gets the os level keychain impl.
|
|
18
17
|
*
|
|
@@ -22,7 +21,7 @@ const messages = messages_1.Messages.load('@salesforce/core', 'encryption', ['un
|
|
|
22
21
|
const retrieveKeychain = async (platform) => {
|
|
23
22
|
const logger = await logger_1.Logger.child('keyChain');
|
|
24
23
|
logger.debug(`platform: ${platform}`);
|
|
25
|
-
const useGenericUnixKeychainVar = kit_1.env.getBoolean('
|
|
24
|
+
const useGenericUnixKeychainVar = kit_1.env.getBoolean('SF_USE_GENERIC_UNIX_KEYCHAIN');
|
|
26
25
|
const shouldUseGenericUnixKeychain = useGenericUnixKeychainVar && useGenericUnixKeychainVar;
|
|
27
26
|
if (platform.startsWith('win')) {
|
|
28
27
|
return keyChainImpl_1.keyChainImpl.generic_windows;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
2
4
|
import * as childProcess from 'child_process';
|
|
3
5
|
import * as nodeFs from 'fs';
|
|
4
6
|
import { Nullable } from '@salesforce/ts-types';
|
|
5
|
-
export
|
|
7
|
+
export type FsIfc = Pick<typeof nodeFs, 'statSync'>;
|
|
6
8
|
/**
|
|
7
9
|
* Basic keychain interface.
|
|
8
10
|
*/
|
|
@@ -75,7 +77,7 @@ declare enum SecretField {
|
|
|
75
77
|
ACCOUNT = "account",
|
|
76
78
|
KEY = "key"
|
|
77
79
|
}
|
|
78
|
-
|
|
80
|
+
type SecretContents = {
|
|
79
81
|
[SecretField.ACCOUNT]: string;
|
|
80
82
|
[SecretField.KEY]?: string;
|
|
81
83
|
[SecretField.SERVICE]: string;
|
|
@@ -110,5 +112,5 @@ export declare const keyChainImpl: {
|
|
|
110
112
|
linux: KeychainAccess;
|
|
111
113
|
validateProgram: (programPath: string, fsIfc: FsIfc, isExeIfc: (mode: number, gid: number, uid: number) => boolean) => Promise<void>;
|
|
112
114
|
};
|
|
113
|
-
export
|
|
115
|
+
export type KeyChain = GenericUnixKeychainAccess | GenericWindowsKeychainAccess | KeychainAccess;
|
|
114
116
|
export {};
|