@salesforce/core 6.0.1-crdt.0 → 6.1.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/README.md +3 -3
- package/lib/config/authInfoConfig.d.ts +1 -1
- package/lib/config/config.d.ts +6 -29
- package/lib/config/config.js +91 -113
- package/lib/config/configAggregator.js +1 -0
- package/lib/config/configFile.d.ts +3 -1
- package/lib/config/configFile.js +44 -67
- package/lib/config/configStore.d.ts +20 -29
- package/lib/config/configStore.js +50 -53
- package/lib/config/envVars.js +3 -2
- package/lib/config/lwwMap.d.ts +4 -5
- package/lib/config/lwwMap.js +19 -16
- package/lib/config/lwwRegister.d.ts +2 -3
- package/lib/config/lwwRegister.js +6 -7
- package/lib/config/sandboxOrgConfig.js +1 -1
- package/lib/config/sandboxProcessCache.d.ts +1 -1
- package/lib/crypto/crypto.js +4 -3
- package/lib/crypto/keyChain.js +1 -0
- package/lib/crypto/keyChainImpl.d.ts +2 -2
- package/lib/crypto/keyChainImpl.js +9 -8
- package/lib/crypto/secureBuffer.js +1 -1
- package/lib/deviceOauthService.d.ts +1 -1
- package/lib/deviceOauthService.js +8 -6
- package/lib/exported.d.ts +3 -4
- package/lib/exported.js +6 -6
- package/lib/global.js +4 -4
- package/lib/logger/logger.js +6 -5
- package/lib/logger/memoryLogger.d.ts +1 -1
- package/lib/logger/memoryLogger.js +2 -2
- package/lib/logger/transformStream.d.ts +1 -1
- package/lib/logger/transformStream.js +3 -3
- package/lib/messageTransformer.js +2 -2
- package/lib/messages.js +5 -5
- package/lib/org/authInfo.js +11 -10
- package/lib/org/authRemover.d.ts +1 -2
- package/lib/org/authRemover.js +2 -12
- package/lib/org/connection.js +3 -2
- package/lib/org/org.js +9 -8
- package/lib/org/orgConfigProperties.js +3 -2
- package/lib/org/permissionSetAssignment.js +15 -13
- package/lib/org/scratchOrgCreate.js +2 -1
- package/lib/org/scratchOrgErrorCodes.js +1 -0
- package/lib/org/scratchOrgFeatureDeprecation.js +1 -0
- package/lib/org/scratchOrgInfoApi.js +1 -0
- package/lib/org/scratchOrgInfoGenerator.js +3 -2
- package/lib/org/scratchOrgSettingsGenerator.js +3 -3
- package/lib/org/user.js +4 -3
- package/lib/schema/validator.js +2 -2
- package/lib/sfError.d.ts +1 -1
- package/lib/sfProject.d.ts +6 -6
- package/lib/sfProject.js +18 -21
- package/lib/stateAggregator/accessors/aliasAccessor.d.ts +1 -2
- package/lib/stateAggregator/accessors/aliasAccessor.js +3 -2
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +2 -2
- package/lib/stateAggregator/accessors/orgAccessor.js +8 -6
- package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +1 -1
- package/lib/stateAggregator/stateAggregator.d.ts +0 -2
- package/lib/stateAggregator/stateAggregator.js +0 -2
- package/lib/status/myDomainResolver.d.ts +1 -1
- package/lib/status/myDomainResolver.js +6 -6
- package/lib/status/pollingClient.js +1 -1
- package/lib/status/streamingClient.js +4 -3
- package/lib/status/types.d.ts +1 -1
- package/lib/status/types.js +2 -2
- package/lib/testSetup.d.ts +3 -7
- package/lib/testSetup.js +47 -39
- package/lib/util/cache.js +14 -14
- package/lib/util/checkLightningDomain.js +2 -2
- package/lib/util/directoryWriter.d.ts +1 -1
- package/lib/util/directoryWriter.js +7 -7
- package/lib/util/fileLocking.d.ts +24 -0
- package/lib/util/fileLocking.js +91 -0
- package/lib/util/findUppercaseKeys.d.ts +2 -0
- package/lib/util/findUppercaseKeys.js +29 -0
- package/lib/util/internal.js +7 -6
- package/lib/util/sfdc.d.ts +0 -18
- package/lib/util/sfdc.js +1 -42
- package/lib/util/sfdcUrl.d.ts +2 -2
- package/lib/util/sfdcUrl.js +9 -8
- package/lib/util/structuredWriter.d.ts +1 -1
- package/lib/util/time.d.ts +1 -0
- package/lib/util/time.js +13 -0
- package/lib/util/uniqid.js +3 -3
- package/lib/util/zipWriter.d.ts +1 -1
- package/lib/util/zipWriter.js +2 -2
- package/lib/webOAuthServer.d.ts +2 -2
- package/lib/webOAuthServer.js +16 -15
- package/package.json +14 -38
- package/lib/config/tokensConfig.d.ts +0 -10
- package/lib/config/tokensConfig.js +0 -29
- package/lib/org/index.d.ts +0 -6
- package/lib/org/index.js +0 -29
- package/lib/schema/printer.d.ts +0 -81
- package/lib/schema/printer.js +0 -263
- package/lib/stateAggregator/accessors/tokenAccessor.d.ts +0 -63
- package/lib/stateAggregator/accessors/tokenAccessor.js +0 -80
- package/lib/stateAggregator/index.d.ts +0 -4
- package/lib/stateAggregator/index.js +0 -27
- package/lib/util/jsonXmlTools.d.ts +0 -14
- package/lib/util/jsonXmlTools.js +0 -39
package/lib/webOAuthServer.js
CHANGED
|
@@ -9,19 +9,20 @@
|
|
|
9
9
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.WebServer = exports.WebOAuthServer = void 0;
|
|
12
|
-
const http = require("http");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
12
|
+
const http = require("node:http");
|
|
13
|
+
const node_querystring_1 = require("node:querystring");
|
|
14
|
+
const node_url_1 = require("node:url");
|
|
15
|
+
const node_net_1 = require("node:net");
|
|
16
|
+
const node_events_1 = require("node:events");
|
|
17
17
|
const jsforce_1 = require("jsforce");
|
|
18
18
|
const kit_1 = require("@salesforce/kit");
|
|
19
19
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
20
20
|
const logger_1 = require("./logger/logger");
|
|
21
|
-
const
|
|
21
|
+
const authInfo_1 = require("./org/authInfo");
|
|
22
22
|
const sfError_1 = require("./sfError");
|
|
23
23
|
const messages_1 = require("./messages");
|
|
24
24
|
const sfProject_1 = require("./sfProject");
|
|
25
|
+
;
|
|
25
26
|
const messages = new messages_1.Messages('@salesforce/core', 'auth', new Map([["targetOrgNotSet", "A default user is not set."], ["targetOrgNotSet.actions", ["Run the \"sfdx auth\" commands with --setdefaultusername to connect to an org and set it as your default org.", "Run \"force:org:create\" with --setdefaultusername to create a scratch org and set it as your default org.", "Run \"sfdx config:set defaultusername=<username>\" to set your default username."]], ["portInUse", "Cannot start the OAuth redirect server on port %s."], ["portInUse.actions", ["Kill the process running on port %s or use a custom connected app and update OauthLocalPort in the sfdx-project.json file."]], ["invalidRequestMethod", "Invalid request method: %s"], ["invalidRequestUri", "Invalid request uri: %s"], ["pollingTimeout", "The device authorization request timed out. After executing force:auth:device:login, you must approve access to the device within 10 minutes. This can happen if the URL wasn\u2019t copied into the browser, login was not attempted, or the 2FA process was not completed within 10 minutes. Request authorization again."], ["serverErrorHTMLResponse", "<html><head><style>body {background-color:#F4F6F9; font-family: Arial, sans-serif; font-size: 0.8125rem; line-height: 1.5rem; color: #16325c;} #center {margin: auto; width: 370px; padding: 100px 0px 20px;} #logo-container {margin-left: auto; margin-right: auto; text-align: center;} #logo {max-width: 180px; max-height: 113px; margin-bottom: 2rem; border: 0;} #header {font-size: 1.5rem; text-align: center; margin-bottom: 1rem;} #message {background-color: #FFFFFF; margin: 0px auto; padding: 1.25rem; border-radius: 0.25rem; border: 1px solid #D8DDE6;} #footer {height: 24px; width: 370px; text-align: center; font-size: .75rem; position: absolute; bottom: 10;}</style></head><body><div id=\"center\"><div id=\"logo-container\"><img id=\"logo\" aria-hidden=\"true\" name=\"logo\" alt=\"Salesforce\" src=\"data:image/svg+xml;base64,%s\"></div><div id=\"header\">%s</div><div id=\"message\">%s<br/><br/>This is most likely <b>not</b> an error with the Salesforce CLI. Please ensure all information is accurate and try again.</div><div id=\"footer\">© %s Salesforce, Inc. All rights reserved.</div></div></body></html>"], ["missingAuthCode", "No authentication code found on login response."], ["serverSuccessHTMLResponse", "<html><head><style>body {background-color:#F4F6F9; font-family: Arial, sans-serif; font-size: 0.8125rem; line-height: 1.5rem; color: #16325c;} #center {margin: auto; width: 300px; padding: 100px 0px 20px;} #logo-container {margin-left: auto; margin-right: auto; text-align: center;} #logo {max-width: 180px; max-height: 113px; margin-bottom: 2rem; border: 0;} #header {font-size: 1.5rem; text-align: center; margin-bottom: 1rem;} #message {background-color: #FFFFFF; margin: 0px auto; padding: 1.25rem; border-radius: 0.25rem; border: 1px solid #D8DDE6;} #footer {height: 24px; width: 300px; text-align: center; font-size: .75rem; position: absolute; bottom: 10;}</style></head><body><div id=\"center\"><div id=\"logo-container\"><img id=\"logo\" aria-hidden=\"true\" name=\"logo\" alt=\"Salesforce\" src=\"data:image/svg+xml;base64,%s\"></div><div id=\"header\">Authentication Successful</div><div id=\"message\">You've successfully logged in. You can now close this browser tab or window.</div><div id=\"footer\">© %s Salesforce, Inc. All rights reserved.</div></div></body></html>"], ["serverSfdcImage", "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIxLjEuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAyNjIgMTg0IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNjIgMTg0OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+Cgkuc3Qwe2ZpbGw6IzAwQTFFMDt9Cgkuc3Qxe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU+Cjx0aXRsZT5sb2dvLXNhbGVzZm9yY2U8L3RpdGxlPgo8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KPGcgaWQ9IlRlc3QtQiI+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0wLjYKCQkJCQljMC4xLTAuMywxLTIuNywxLjEtMy4xYzAuMi0wLjQsMC41LTAuMiwwLjUtMC4yYzAuMywwLjEsMC41LDAuMiwwLjgsMC4zYzAuNCwwLjEsMC44LDAuMSwxLjIsMC4xYzAuNywwLDEuMy0wLjEsMS44LTAuMwoJCQkJCWMwLjYtMC4yLDEtMC42LDEuNC0xLjFjMC40LTAuNSwwLjctMS4yLDEuMS0yLjFjMC4zLTAuOSwwLjYtMi4yLDAuOS0zLjdsMy40LTE4LjloLTMuM2MtMC40LDAtMC41LTAuMi0wLjUtMC41bDAuNi0zLjEKCQkJCQljMC4xLTAuNSwwLjUtMC40LDAuNS0wLjRoMy40bDAuMi0xYzAuNS0zLDEuNS01LjMsMy02LjhjMS41LTEuNSwzLjctMi4zLDYuNC0yLjNjMC44LDAsMS41LDAuMSwyLjEsMC4yCgkJCQkJQzE1NSw2NC44LDE1NS41LDY0LjksMTU2LDY1LjF6IE04OC42LDk3LjZjMCwwLjMtMC4yLDAuNS0wLjQsMC41aC00Yy0wLjMsMC0wLjQtMC4yLTAuNC0wLjVWNjUuNWMwLTAuMiwwLjItMC41LDAuNC0wLjVoNAoJCQkJCWMwLjMsMCwwLjQsMC4yLDAuNCwwLjVWOTcuNnoiLz4KCQkJPC9nPgoJCTwvZz4KCTwvZz4KPC9nPgo8L3N2Zz4K"]]));
|
|
26
27
|
/**
|
|
27
28
|
* Handles the creation of a web server for web based login flows.
|
|
@@ -81,7 +82,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
81
82
|
this.executeOauthRequest()
|
|
82
83
|
.then(async (response) => {
|
|
83
84
|
try {
|
|
84
|
-
const authInfo = await
|
|
85
|
+
const authInfo = await authInfo_1.AuthInfo.create({
|
|
85
86
|
oauth2Options: this.oauthConfig,
|
|
86
87
|
oauth2: this.oauth2,
|
|
87
88
|
});
|
|
@@ -124,14 +125,14 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
124
125
|
this.logger = await logger_1.Logger.child(this.constructor.name);
|
|
125
126
|
const port = await WebOAuthServer.determineOauthPort();
|
|
126
127
|
if (!this.oauthConfig.clientId)
|
|
127
|
-
this.oauthConfig.clientId =
|
|
128
|
+
this.oauthConfig.clientId = authInfo_1.DEFAULT_CONNECTED_APP_INFO.clientId;
|
|
128
129
|
if (!this.oauthConfig.loginUrl)
|
|
129
|
-
this.oauthConfig.loginUrl =
|
|
130
|
+
this.oauthConfig.loginUrl = authInfo_1.AuthInfo.getDefaultInstanceUrl();
|
|
130
131
|
if (!this.oauthConfig.redirectUri)
|
|
131
132
|
this.oauthConfig.redirectUri = `http://localhost:${port}/OauthRedirect`;
|
|
132
133
|
this.webServer = await WebServer.create({ port });
|
|
133
134
|
this.oauth2 = new jsforce_1.OAuth2(this.oauthConfig);
|
|
134
|
-
this.authUrl =
|
|
135
|
+
this.authUrl = authInfo_1.AuthInfo.getAuthorizationUrl(this.oauthConfig, this.oauth2);
|
|
135
136
|
}
|
|
136
137
|
/**
|
|
137
138
|
* Executes the oauth request
|
|
@@ -145,11 +146,11 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
145
146
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
146
147
|
this.webServer.server.on('request', async (request, response) => {
|
|
147
148
|
if (request.url) {
|
|
148
|
-
const url = (0,
|
|
149
|
+
const url = (0, node_url_1.parse)(request.url);
|
|
149
150
|
this.logger.debug(`processing request for uri: ${url.pathname}`);
|
|
150
151
|
if (request.method === 'GET') {
|
|
151
152
|
if (url.pathname?.startsWith('/OauthRedirect') && url.query) {
|
|
152
|
-
request.query = (0,
|
|
153
|
+
request.query = (0, node_querystring_1.parse)(url.query);
|
|
153
154
|
if (request.query.error) {
|
|
154
155
|
const errorName = typeof request.query.error_description === 'string'
|
|
155
156
|
? request.query.error_description
|
|
@@ -242,7 +243,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
242
243
|
*/
|
|
243
244
|
validateState(request) {
|
|
244
245
|
const state = request.query.state;
|
|
245
|
-
const query = (0,
|
|
246
|
+
const query = (0, node_url_1.parse)(this.authUrl, true).query;
|
|
246
247
|
return !!(state && state === query.state);
|
|
247
248
|
}
|
|
248
249
|
}
|
|
@@ -257,7 +258,7 @@ class WebServer extends kit_1.AsyncCreatable {
|
|
|
257
258
|
this.port = WebOAuthServer.DEFAULT_PORT;
|
|
258
259
|
this.host = 'localhost';
|
|
259
260
|
this.sockets = [];
|
|
260
|
-
this.redirectStatus = new
|
|
261
|
+
this.redirectStatus = new node_events_1.EventEmitter();
|
|
261
262
|
if (options.port)
|
|
262
263
|
this.port = options.port;
|
|
263
264
|
if (options.host)
|
|
@@ -386,7 +387,7 @@ class WebServer extends kit_1.AsyncCreatable {
|
|
|
386
387
|
async checkOsPort() {
|
|
387
388
|
return new Promise((resolve, reject) => {
|
|
388
389
|
const clientConfig = { port: this.port, host: this.host };
|
|
389
|
-
const socket = new
|
|
390
|
+
const socket = new node_net_1.Socket();
|
|
390
391
|
socket.setTimeout(this.getSocketTimeout(), () => {
|
|
391
392
|
socket.destroy();
|
|
392
393
|
const error = new sfError_1.SfError('timeout', 'SOCKET_TIMEOUT');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
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",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"messageTransformer/messageTransformer.ts"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@salesforce/kit": "^3.0.
|
|
43
|
-
"@salesforce/schemas": "^1.6.
|
|
44
|
-
"@salesforce/ts-types": "^2.0.
|
|
45
|
-
"@types/semver": "^7.5.
|
|
42
|
+
"@salesforce/kit": "^3.0.15",
|
|
43
|
+
"@salesforce/schemas": "^1.6.1",
|
|
44
|
+
"@salesforce/ts-types": "^2.0.9",
|
|
45
|
+
"@types/semver": "^7.5.4",
|
|
46
46
|
"ajv": "^8.12.0",
|
|
47
47
|
"change-case": "^4.1.2",
|
|
48
48
|
"faye": "^1.4.0",
|
|
@@ -51,49 +51,25 @@
|
|
|
51
51
|
"jsforce": "^2.0.0-beta.28",
|
|
52
52
|
"jsonwebtoken": "9.0.2",
|
|
53
53
|
"jszip": "3.10.1",
|
|
54
|
-
"pino": "^8.
|
|
55
|
-
"pino-abstract-transport": "^1.
|
|
54
|
+
"pino": "^8.16.1",
|
|
55
|
+
"pino-abstract-transport": "^1.1.0",
|
|
56
56
|
"pino-pretty": "^10.2.3",
|
|
57
57
|
"proper-lockfile": "^4.1.2",
|
|
58
58
|
"semver": "^7.5.4",
|
|
59
59
|
"ts-retry-promise": "^0.7.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@salesforce/dev-
|
|
63
|
-
"@salesforce/
|
|
64
|
-
"@salesforce/prettier-config": "^0.0.3",
|
|
65
|
-
"@salesforce/ts-sinon": "^1.4.16",
|
|
62
|
+
"@salesforce/dev-scripts": "^6.0.4",
|
|
63
|
+
"@salesforce/ts-sinon": "^1.4.19",
|
|
66
64
|
"@types/benchmark": "^2.1.3",
|
|
67
|
-
"@types/chai-string": "^1.4.
|
|
65
|
+
"@types/chai-string": "^1.4.5",
|
|
68
66
|
"@types/jsonwebtoken": "9.0.3",
|
|
69
|
-
"@types/lodash": "^4.14.199",
|
|
70
67
|
"@types/proper-lockfile": "^4.1.2",
|
|
71
|
-
"@types/shelljs": "0.8.13",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
73
|
-
"@typescript-eslint/parser": "^5.62.0",
|
|
74
68
|
"benchmark": "^2.1.4",
|
|
75
|
-
"chai": "^4.3.10",
|
|
76
69
|
"chai-string": "^1.5.0",
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"eslint-config-salesforce-license": "^0.2.0",
|
|
81
|
-
"eslint-config-salesforce-typescript": "^1.1.2",
|
|
82
|
-
"eslint-plugin-header": "^3.1.1",
|
|
83
|
-
"eslint-plugin-import": "^2.28.1",
|
|
84
|
-
"eslint-plugin-jsdoc": "^43.2.0",
|
|
85
|
-
"husky": "^7.0.4",
|
|
86
|
-
"lodash": "^4.17.21",
|
|
87
|
-
"mocha": "^9.1.3",
|
|
88
|
-
"nyc": "^15.1.0",
|
|
89
|
-
"prettier": "^2.8.7",
|
|
90
|
-
"pretty-quick": "^3.1.3",
|
|
91
|
-
"shelljs": "0.8.5",
|
|
92
|
-
"sinon": "^14.0.2",
|
|
93
|
-
"ts-node": "^10.4.0",
|
|
94
|
-
"ttypescript": "^1.5.15",
|
|
95
|
-
"typescript": "^4.9.5",
|
|
96
|
-
"wireit": "^0.14.0"
|
|
70
|
+
"ts-node": "^10.9.1",
|
|
71
|
+
"ts-patch": "^3.0.2",
|
|
72
|
+
"typescript": "^5.2.2"
|
|
97
73
|
},
|
|
98
74
|
"repository": {
|
|
99
75
|
"type": "git",
|
|
@@ -110,7 +86,7 @@
|
|
|
110
86
|
]
|
|
111
87
|
},
|
|
112
88
|
"compile": {
|
|
113
|
-
"command": "
|
|
89
|
+
"command": "tspc -p . --pretty --incremental",
|
|
114
90
|
"files": [
|
|
115
91
|
"src/**/*.ts",
|
|
116
92
|
"tsconfig.json",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Optional } from '@salesforce/ts-types';
|
|
2
|
-
import { SfTokens } from '../stateAggregator';
|
|
3
|
-
import { ConfigFile } from './configFile';
|
|
4
|
-
import { ConfigContents, ConfigValue } from './configStackTypes';
|
|
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
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
package/lib/org/index.d.ts
DELETED
package/lib/org/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2020, 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
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
__exportStar(require("./authInfo"), exports);
|
|
24
|
-
__exportStar(require("./authRemover"), exports);
|
|
25
|
-
__exportStar(require("./connection"), exports);
|
|
26
|
-
__exportStar(require("./org"), exports);
|
|
27
|
-
__exportStar(require("./permissionSetAssignment"), exports);
|
|
28
|
-
__exportStar(require("./user"), exports);
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
package/lib/schema/printer.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { JsonMap } from '@salesforce/ts-types';
|
|
2
|
-
import { Logger } from '../logger/logger';
|
|
3
|
-
/**
|
|
4
|
-
* Renders schema properties. By default, this is simply an identity transform. Subclasses may provide more
|
|
5
|
-
* interesting decorations of each values, such as ANSI coloring.
|
|
6
|
-
*
|
|
7
|
-
* @deprecated
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
export declare class SchemaPropertyRenderer {
|
|
11
|
-
/**
|
|
12
|
-
* Renders a name.
|
|
13
|
-
*
|
|
14
|
-
* @param name The name value to render.
|
|
15
|
-
*/
|
|
16
|
-
renderName(name: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Renders a title.
|
|
19
|
-
*
|
|
20
|
-
* @param title The title value to render.
|
|
21
|
-
*/
|
|
22
|
-
renderTitle(title: string): string;
|
|
23
|
-
/**
|
|
24
|
-
* Renders a description.
|
|
25
|
-
*
|
|
26
|
-
* @param description The description value to render.
|
|
27
|
-
*/
|
|
28
|
-
renderDescription(description: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* Renders a type.
|
|
31
|
-
*
|
|
32
|
-
* @param propertyType The type value to render.
|
|
33
|
-
*/
|
|
34
|
-
renderType(propertyType: string): string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Prints a JSON schema in a human-friendly format.
|
|
38
|
-
*
|
|
39
|
-
* @deprecated
|
|
40
|
-
* remaining reference: https://github.com/salesforcecli/plugin-data/blob/cc1bdfa2c707f93a6da96beea8117b25f9612d4a/src/commands/data/import/tree.ts#L75
|
|
41
|
-
*
|
|
42
|
-
* ```
|
|
43
|
-
* import chalk from 'chalk';
|
|
44
|
-
* class MyPropertyRenderer extends SchemaPropertyRenderer {
|
|
45
|
-
* renderName(name) { return chalk.bold.blue(name); }
|
|
46
|
-
* }
|
|
47
|
-
*
|
|
48
|
-
* const printer = new SchemaPrinter(logger, schema, new MyPropertyRenderer());
|
|
49
|
-
* printer.getLines().forEach(console.log);
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare class SchemaPrinter {
|
|
53
|
-
private schema;
|
|
54
|
-
private propertyRenderer;
|
|
55
|
-
private logger;
|
|
56
|
-
private lines;
|
|
57
|
-
/**
|
|
58
|
-
* Constructs a new `SchemaPrinter`.
|
|
59
|
-
*
|
|
60
|
-
* @param logger The logger to use when emitting the printed schema.
|
|
61
|
-
* @param schema The schema to print.
|
|
62
|
-
* @param propertyRenderer The property renderer.
|
|
63
|
-
*/
|
|
64
|
-
constructor(logger: Logger, schema: JsonMap, propertyRenderer?: SchemaPropertyRenderer);
|
|
65
|
-
/**
|
|
66
|
-
* Gets a read-only array of ready-to-display lines.
|
|
67
|
-
*/
|
|
68
|
-
getLines(): readonly string[];
|
|
69
|
-
/**
|
|
70
|
-
* Gets a ready-to-display line by index.
|
|
71
|
-
*
|
|
72
|
-
* @param index The line index to get.
|
|
73
|
-
*/
|
|
74
|
-
getLine(index: number): string;
|
|
75
|
-
/**
|
|
76
|
-
* Prints the accumulated set of schema lines as info log lines to the logger.
|
|
77
|
-
*/
|
|
78
|
-
print(): void;
|
|
79
|
-
private addFn;
|
|
80
|
-
private parseProperty;
|
|
81
|
-
}
|
package/lib/schema/printer.js
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2020, 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.SchemaPrinter = exports.SchemaPropertyRenderer = void 0;
|
|
11
|
-
const ts_types_1 = require("@salesforce/ts-types");
|
|
12
|
-
const sfError_1 = require("../sfError");
|
|
13
|
-
/**
|
|
14
|
-
* Renders schema properties. By default, this is simply an identity transform. Subclasses may provide more
|
|
15
|
-
* interesting decorations of each values, such as ANSI coloring.
|
|
16
|
-
*
|
|
17
|
-
* @deprecated
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
class SchemaPropertyRenderer {
|
|
21
|
-
/**
|
|
22
|
-
* Renders a name.
|
|
23
|
-
*
|
|
24
|
-
* @param name The name value to render.
|
|
25
|
-
*/
|
|
26
|
-
renderName(name) {
|
|
27
|
-
return name;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Renders a title.
|
|
31
|
-
*
|
|
32
|
-
* @param title The title value to render.
|
|
33
|
-
*/
|
|
34
|
-
renderTitle(title) {
|
|
35
|
-
return title;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Renders a description.
|
|
39
|
-
*
|
|
40
|
-
* @param description The description value to render.
|
|
41
|
-
*/
|
|
42
|
-
renderDescription(description) {
|
|
43
|
-
return description;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Renders a type.
|
|
47
|
-
*
|
|
48
|
-
* @param propertyType The type value to render.
|
|
49
|
-
*/
|
|
50
|
-
renderType(propertyType) {
|
|
51
|
-
return propertyType;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.SchemaPropertyRenderer = SchemaPropertyRenderer;
|
|
55
|
-
/**
|
|
56
|
-
* Prints a JSON schema in a human-friendly format.
|
|
57
|
-
*
|
|
58
|
-
* @deprecated
|
|
59
|
-
* remaining reference: https://github.com/salesforcecli/plugin-data/blob/cc1bdfa2c707f93a6da96beea8117b25f9612d4a/src/commands/data/import/tree.ts#L75
|
|
60
|
-
*
|
|
61
|
-
* ```
|
|
62
|
-
* import chalk from 'chalk';
|
|
63
|
-
* class MyPropertyRenderer extends SchemaPropertyRenderer {
|
|
64
|
-
* renderName(name) { return chalk.bold.blue(name); }
|
|
65
|
-
* }
|
|
66
|
-
*
|
|
67
|
-
* const printer = new SchemaPrinter(logger, schema, new MyPropertyRenderer());
|
|
68
|
-
* printer.getLines().forEach(console.log);
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
class SchemaPrinter {
|
|
72
|
-
/**
|
|
73
|
-
* Constructs a new `SchemaPrinter`.
|
|
74
|
-
*
|
|
75
|
-
* @param logger The logger to use when emitting the printed schema.
|
|
76
|
-
* @param schema The schema to print.
|
|
77
|
-
* @param propertyRenderer The property renderer.
|
|
78
|
-
*/
|
|
79
|
-
constructor(logger, schema, propertyRenderer = new SchemaPropertyRenderer()) {
|
|
80
|
-
this.schema = schema;
|
|
81
|
-
this.propertyRenderer = propertyRenderer;
|
|
82
|
-
this.lines = [];
|
|
83
|
-
this.logger = logger.child('SchemaPrinter');
|
|
84
|
-
if (!this.schema.properties && !this.schema.items) {
|
|
85
|
-
// No need to add to messages, since this should never happen. In fact,
|
|
86
|
-
// this will cause a test failure if there is a command that uses a schema
|
|
87
|
-
// with no properties defined.
|
|
88
|
-
throw new sfError_1.SfError('There is no purpose to print a schema with no properties or items');
|
|
89
|
-
}
|
|
90
|
-
const startLevel = 0;
|
|
91
|
-
const add = this.addFn(startLevel);
|
|
92
|
-
// For object schemas, print out the "header" and first level properties differently
|
|
93
|
-
if (this.schema.properties) {
|
|
94
|
-
if (typeof this.schema.description === 'string') {
|
|
95
|
-
// Output the overall schema description before printing the properties
|
|
96
|
-
add(this.schema.description);
|
|
97
|
-
add('');
|
|
98
|
-
}
|
|
99
|
-
Object.keys(this.schema.properties).forEach((key) => {
|
|
100
|
-
const properties = (0, ts_types_1.asJsonMap)(this.schema.properties);
|
|
101
|
-
if (!properties) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
this.parseProperty(key, (0, ts_types_1.asJsonMap)(properties[key]), startLevel);
|
|
105
|
-
add('');
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
this.parseProperty('schema', this.schema, startLevel);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Gets a read-only array of ready-to-display lines.
|
|
114
|
-
*/
|
|
115
|
-
getLines() {
|
|
116
|
-
return this.lines;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Gets a ready-to-display line by index.
|
|
120
|
-
*
|
|
121
|
-
* @param index The line index to get.
|
|
122
|
-
*/
|
|
123
|
-
getLine(index) {
|
|
124
|
-
return this.lines[index];
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Prints the accumulated set of schema lines as info log lines to the logger.
|
|
128
|
-
*/
|
|
129
|
-
print() {
|
|
130
|
-
this.lines.forEach((line) => this.logger.info(line));
|
|
131
|
-
}
|
|
132
|
-
addFn(level) {
|
|
133
|
-
const indent = ' '.repeat(level * 4);
|
|
134
|
-
return (line) => {
|
|
135
|
-
this.lines.push(`${indent}${line}`);
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
parseProperty(name, rawProperty, level = 0) {
|
|
139
|
-
if (!rawProperty) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const add = this.addFn(level);
|
|
143
|
-
const property = new SchemaProperty(this.logger, this.schema, name, rawProperty, this.propertyRenderer);
|
|
144
|
-
add(property.renderHeader());
|
|
145
|
-
if (property.type === 'object' && property.properties) {
|
|
146
|
-
Object.keys(property.properties).forEach((key) => {
|
|
147
|
-
this.parseProperty(key, property.getProperty(key), level + 1);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
if (property.type === 'array') {
|
|
151
|
-
add(` ${property.renderArrayHeader()}`);
|
|
152
|
-
if (property.items && property.items.type === 'object' && property.items.properties) {
|
|
153
|
-
Object.keys(property.items.properties).forEach((key) => {
|
|
154
|
-
const items = (0, ts_types_1.asJsonMap)(property.items);
|
|
155
|
-
if (!items) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const properties = (0, ts_types_1.asJsonMap)(items.properties);
|
|
159
|
-
if (!properties) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
this.parseProperty(key, (0, ts_types_1.asJsonMap)(properties[key]), level + 2);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (property.required) {
|
|
167
|
-
add(`Required: ${property.required.join(', ')}`);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
exports.SchemaPrinter = SchemaPrinter;
|
|
172
|
-
class SchemaProperty {
|
|
173
|
-
constructor(logger, schema, name, rawProperty, propertyRenderer) {
|
|
174
|
-
this.logger = logger;
|
|
175
|
-
this.schema = schema;
|
|
176
|
-
this.name = name;
|
|
177
|
-
this.rawProperty = rawProperty;
|
|
178
|
-
this.propertyRenderer = propertyRenderer;
|
|
179
|
-
this.name = name;
|
|
180
|
-
// Capture the referenced definition, if specified
|
|
181
|
-
if (typeof this.rawProperty.$ref === 'string') {
|
|
182
|
-
// Copy the referenced property while adding the original property's properties on top of that --
|
|
183
|
-
// if they are defined here, they take precedence over referenced definition properties.
|
|
184
|
-
this.rawProperty = Object.assign({}, resolveRef(this.schema, this.rawProperty), rawProperty);
|
|
185
|
-
}
|
|
186
|
-
const oneOfs = (0, ts_types_1.asJsonArray)(this.rawProperty.oneOf);
|
|
187
|
-
if (oneOfs && !this.rawProperty.type) {
|
|
188
|
-
this.rawProperty.type = oneOfs.map((value) => ((0, ts_types_1.isJsonMap)(value) ? value.type ?? value.$ref : value)).join('|');
|
|
189
|
-
}
|
|
190
|
-
// Handle items references
|
|
191
|
-
if ((0, ts_types_1.isJsonMap)(this.items) && this.items && this.items.$ref) {
|
|
192
|
-
Object.assign(this.items, resolveRef(this.schema, this.items));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
get title() {
|
|
196
|
-
return (0, ts_types_1.asString)(this.rawProperty.title);
|
|
197
|
-
}
|
|
198
|
-
get description() {
|
|
199
|
-
return (0, ts_types_1.asString)(this.rawProperty.description);
|
|
200
|
-
}
|
|
201
|
-
get type() {
|
|
202
|
-
return (0, ts_types_1.asString)(this.rawProperty.type);
|
|
203
|
-
}
|
|
204
|
-
get required() {
|
|
205
|
-
return (0, ts_types_1.asJsonArray)(this.rawProperty.required);
|
|
206
|
-
}
|
|
207
|
-
get properties() {
|
|
208
|
-
return (0, ts_types_1.asJsonMap)(this.rawProperty.properties);
|
|
209
|
-
}
|
|
210
|
-
get items() {
|
|
211
|
-
return (0, ts_types_1.asJsonMap)(this.rawProperty.items);
|
|
212
|
-
}
|
|
213
|
-
get minItems() {
|
|
214
|
-
return (0, ts_types_1.asNumber)(this.rawProperty.minItems);
|
|
215
|
-
}
|
|
216
|
-
getProperty(key) {
|
|
217
|
-
const properties = this.getProperties();
|
|
218
|
-
return (0, ts_types_1.asJsonMap)(properties?.[key]);
|
|
219
|
-
}
|
|
220
|
-
getProperties() {
|
|
221
|
-
return (0, ts_types_1.asJsonMap)(this.rawProperty.properties);
|
|
222
|
-
}
|
|
223
|
-
renderName() {
|
|
224
|
-
return this.propertyRenderer.renderName(this.name);
|
|
225
|
-
}
|
|
226
|
-
renderTitle() {
|
|
227
|
-
return this.propertyRenderer.renderTitle(this.title ?? '');
|
|
228
|
-
}
|
|
229
|
-
renderDescription() {
|
|
230
|
-
return this.propertyRenderer.renderDescription(this.description ?? '');
|
|
231
|
-
}
|
|
232
|
-
renderType() {
|
|
233
|
-
return this.propertyRenderer.renderType(this.type ?? '');
|
|
234
|
-
}
|
|
235
|
-
renderHeader() {
|
|
236
|
-
return `${this.renderName()}(${this.renderType()}) - ${this.renderTitle()}: ${this.renderDescription()}`;
|
|
237
|
-
}
|
|
238
|
-
renderArrayHeader() {
|
|
239
|
-
if (!this.items) {
|
|
240
|
-
return '';
|
|
241
|
-
}
|
|
242
|
-
const minItems = this.minItems ? ` - min ${this.minItems}` : '';
|
|
243
|
-
const prop = new SchemaProperty(this.logger, this.schema, 'items', this.items, this.propertyRenderer);
|
|
244
|
-
return `items(${prop.renderType()}${minItems}) - ${prop.renderTitle()}: ${prop.renderDescription()}`;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Get the referenced definition by following the reference path on the current schema.
|
|
249
|
-
*
|
|
250
|
-
* @param schema The source schema containing the property containing a `$ref` field.
|
|
251
|
-
* @param property The property that contains the `$ref` field.
|
|
252
|
-
*/
|
|
253
|
-
function resolveRef(schema, property) {
|
|
254
|
-
const ref = property.$ref;
|
|
255
|
-
if (!ref || typeof ref !== 'string') {
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
|
-
return ref.split('/').reduce((prev, key) => {
|
|
259
|
-
const next = prev[key];
|
|
260
|
-
return key === '#' ? schema : (0, ts_types_1.isJsonMap)(next) ? next : {};
|
|
261
|
-
}, property);
|
|
262
|
-
}
|
|
263
|
-
//# sourceMappingURL=printer.js.map
|