@salesforce/core 3.6.6 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -0
- package/LICENSE.txt +1 -1
- package/lib/config/configStore.js +0 -1
- package/lib/deviceOauthService.d.ts +3 -3
- package/lib/deviceOauthService.js +17 -18
- package/lib/exported.d.ts +4 -5
- package/lib/exported.js +4 -3
- package/lib/lifecycleEvents.d.ts +38 -1
- package/lib/lifecycleEvents.js +73 -2
- package/lib/logger.js +1 -0
- package/lib/org/authInfo.d.ts +17 -46
- package/lib/org/authInfo.js +31 -72
- package/lib/org/connection.d.ts +18 -25
- package/lib/org/connection.js +53 -79
- package/lib/org/org.d.ts +121 -9
- package/lib/org/org.js +360 -27
- package/lib/org/user.d.ts +1 -0
- package/lib/org/user.js +11 -2
- package/lib/sfdxError.d.ts +1 -1
- package/lib/sfdxError.js +1 -0
- package/lib/status/pollingClient.d.ts +1 -1
- package/lib/status/streamingClient.d.ts +3 -78
- package/lib/status/streamingClient.js +11 -23
- package/lib/status/types.d.ts +89 -0
- package/lib/status/types.js +18 -0
- package/lib/testSetup.d.ts +6 -4
- package/lib/testSetup.js +3 -3
- package/lib/util/getJwtAudienceUrl.d.ts +2 -2
- package/lib/util/sfdcUrl.d.ts +2 -1
- package/lib/util/sfdcUrl.js +14 -6
- package/lib/webOAuthServer.d.ts +2 -3
- package/lib/webOAuthServer.js +2 -1
- package/messages/core.json +3 -3
- package/messages/core.md +1 -1
- package/messages/org.md +36 -0
- package/package.json +17 -22
- package/lib/status/client.d.ts +0 -15
- package/lib/status/client.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [3.7.3](https://github.com/forcedotcom/sfdx-core/compare/v3.7.2...v3.7.3) (2021-12-16)
|
|
6
|
+
|
|
7
|
+
### [3.7.2](https://github.com/forcedotcom/sfdx-core/compare/v3.7.1...v3.7.2) (2021-10-28)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- make @types/sfdx-faye a dependendcy ([683680b](https://github.com/forcedotcom/sfdx-core/commit/683680b8133048f71d25ef4df7aa24d9700dc5e8))
|
|
12
|
+
|
|
13
|
+
### [3.7.1](https://github.com/forcedotcom/sfdx-core/compare/v3.7.0...v3.7.1) (2021-10-28)
|
|
14
|
+
|
|
15
|
+
## [3.7.0](https://github.com/forcedotcom/sfdx-core/compare/v3.6.6...v3.7.0) (2021-10-12)
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
- use jsforce v2 ([#457](https://github.com/forcedotcom/sfdx-core/issues/457)) ([4a9094e](https://github.com/forcedotcom/sfdx-core/commit/4a9094e958288cdcc6c69f5d87b10a70a437d8e9))
|
|
20
|
+
|
|
5
21
|
### [3.6.6](https://github.com/forcedotcom/sfdx-core/compare/v3.6.5...v3.6.6) (2021-10-08)
|
|
6
22
|
|
|
7
23
|
### [3.6.5](https://github.com/forcedotcom/sfdx-core/compare/v3.6.4...v3.6.5) (2021-09-29)
|
|
@@ -206,6 +222,81 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
206
222
|
- add GlobalInfo config file ([#397](https://github.com/forcedotcom/sfdx-core/issues/397)) ([579998b](https://github.com/forcedotcom/sfdx-core/commit/579998b6ee70dbb9772e65896bbabf6d812aae23))
|
|
207
223
|
- default to reading files from cache ([12b5930](https://github.com/forcedotcom/sfdx-core/commit/12b59301df96395c4edcbfb0816dbddd45af95db))
|
|
208
224
|
|
|
225
|
+
### [2.33.1](https://github.com/forcedotcom/sfdx-core/compare/v2.33.0...v2.33.1) (2021-12-15)
|
|
226
|
+
|
|
227
|
+
### Bug Fixes
|
|
228
|
+
|
|
229
|
+
- faye doesn't use custom stuff passed it ([b1cefc7](https://github.com/forcedotcom/sfdx-core/commit/b1cefc76afde7f0dd56ed72b5539a47c118eef63))
|
|
230
|
+
|
|
231
|
+
## [2.33.0](https://github.com/forcedotcom/sfdx-core/compare/v2.32.0...v2.33.0) (2021-12-14)
|
|
232
|
+
|
|
233
|
+
### Features
|
|
234
|
+
|
|
235
|
+
- sandbox creation ([314dcf1](https://github.com/forcedotcom/sfdx-core/commit/314dcf164d93bd0e3a5f4763a4dfcdde7d0cb14a))
|
|
236
|
+
|
|
237
|
+
## [2.32.0](https://github.com/forcedotcom/sfdx-core/compare/v2.31.1...v2.32.0) (2021-12-14)
|
|
238
|
+
|
|
239
|
+
### Features
|
|
240
|
+
|
|
241
|
+
- switch sfdx-faye with faye ([a0545e5](https://github.com/forcedotcom/sfdx-core/commit/a0545e57d5041c97e499f284afbd7fcb16cf2247))
|
|
242
|
+
|
|
243
|
+
### Bug Fixes
|
|
244
|
+
|
|
245
|
+
- no maxquery warning when records.length is 0 ([758f912](https://github.com/forcedotcom/sfdx-core/commit/758f912a23bd3e9f8d4f854f3e07682dd4d4c4aa))
|
|
246
|
+
|
|
247
|
+
### [2.31.1](https://github.com/forcedotcom/sfdx-core/compare/v2.31.0...v2.31.1) (2021-12-06)
|
|
248
|
+
|
|
249
|
+
## [2.31.0](https://github.com/forcedotcom/sfdx-core/compare/v2.30.1...v2.31.0) (2021-11-30)
|
|
250
|
+
|
|
251
|
+
### Features
|
|
252
|
+
|
|
253
|
+
- bump version of jsforce ([7d89024](https://github.com/forcedotcom/sfdx-core/commit/7d89024f593968c031af22ac817efc26d00fcd54))
|
|
254
|
+
|
|
255
|
+
### [2.30.1](https://github.com/forcedotcom/sfdx-core/compare/v2.30.0...v2.30.1) (2021-11-30)
|
|
256
|
+
|
|
257
|
+
### Bug Fixes
|
|
258
|
+
|
|
259
|
+
- better output for authUrl errors ([f3ec729](https://github.com/forcedotcom/sfdx-core/commit/f3ec7298bdbd3194d3d14bfea09f47f413669376))
|
|
260
|
+
|
|
261
|
+
## [2.30.0](https://github.com/forcedotcom/sfdx-core/compare/v2.29.0...v2.30.0) (2021-11-25)
|
|
262
|
+
|
|
263
|
+
### Features
|
|
264
|
+
|
|
265
|
+
- delete scratch orgs and sandboxes ([#491](https://github.com/forcedotcom/sfdx-core/issues/491)) ([468c348](https://github.com/forcedotcom/sfdx-core/commit/468c348f0ecc69ddeea02927bf7a26ca660a86ca))
|
|
266
|
+
|
|
267
|
+
## [2.29.0](https://github.com/forcedotcom/sfdx-core/compare/v2.28.4...v2.29.0) (2021-11-17)
|
|
268
|
+
|
|
269
|
+
### Features
|
|
270
|
+
|
|
271
|
+
- cleans up old listeners from upgraded instance ([e3f2d69](https://github.com/forcedotcom/sfdx-core/commit/e3f2d69ccd5c096d37addb1b982e19354175f11a))
|
|
272
|
+
- use warnings instead of process in sfdx-core ([c1f7e98](https://github.com/forcedotcom/sfdx-core/commit/c1f7e98f6b19d57da1a2ee0cdf58e449079f0ee7))
|
|
273
|
+
- warning and telemetry events ([80a8039](https://github.com/forcedotcom/sfdx-core/commit/80a8039e2f686d973ddbc24c9a2980fb93928d13))
|
|
274
|
+
- warning and telemetry events ([a04b293](https://github.com/forcedotcom/sfdx-core/commit/a04b29355c8ca6c7e37e071ccc159aff5e5e9ca0))
|
|
275
|
+
|
|
276
|
+
### Bug Fixes
|
|
277
|
+
|
|
278
|
+
- transfer listeners when upgrading the global instance to newer version ([0a40831](https://github.com/forcedotcom/sfdx-core/commit/0a408317c132548771ced0fe196178d2e9c76232))
|
|
279
|
+
|
|
280
|
+
### [2.28.4](https://github.com/forcedotcom/sfdx-core/compare/v2.28.3...v2.28.4) (2021-11-10)
|
|
281
|
+
|
|
282
|
+
### Bug Fixes
|
|
283
|
+
|
|
284
|
+
- bump jsforce types and run unit tests on Windows ([#485](https://github.com/forcedotcom/sfdx-core/issues/485)) ([3952c8f](https://github.com/forcedotcom/sfdx-core/commit/3952c8fe248531a0597477ed12240f611048caba))
|
|
285
|
+
|
|
286
|
+
### [2.28.3](https://github.com/forcedotcom/sfdx-core/compare/v2.28.2...v2.28.3) (2021-11-08)
|
|
287
|
+
|
|
288
|
+
### Bug Fixes
|
|
289
|
+
|
|
290
|
+
- fix unit test ([d903c04](https://github.com/forcedotcom/sfdx-core/commit/d903c04e5f3e4f01fccb3f00b91560c443013ddf))
|
|
291
|
+
- force new release ([124bb74](https://github.com/forcedotcom/sfdx-core/commit/124bb744c5ecc28cb8babf285c6d8c3032eb7ef6))
|
|
292
|
+
- improve error message when providing an invalid username ([2ab4bbd](https://github.com/forcedotcom/sfdx-core/commit/2ab4bbdefd962283d88ccb735de88c88fe189d39))
|
|
293
|
+
|
|
294
|
+
### [2.28.2](https://github.com/forcedotcom/sfdx-core/compare/v2.28.1...v2.28.2) (2021-10-13)
|
|
295
|
+
|
|
296
|
+
### Bug Fixes
|
|
297
|
+
|
|
298
|
+
- support for .mil sandboxes ([9ef35c7](https://github.com/forcedotcom/sfdx-core/commit/9ef35c7b1ef0fe974c3bd3b89b862a436e00f7d9))
|
|
299
|
+
|
|
209
300
|
### [2.28.1](https://github.com/forcedotcom/sfdx-core/compare/v2.28.0...v2.28.1) (2021-10-06)
|
|
210
301
|
|
|
211
302
|
### Bug Fixes
|
package/LICENSE.txt
CHANGED
|
@@ -218,7 +218,6 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
|
|
|
218
218
|
}
|
|
219
219
|
// Allows extended classes the ability to override the set method. i.e. maybe they want
|
|
220
220
|
// nested object set from kit.
|
|
221
|
-
// NOTE: Key and value must stay string and value to be reliably overwritten.
|
|
222
221
|
setMethod(contents, key, value) {
|
|
223
222
|
kit_1.set(contents, key, value);
|
|
224
223
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncCreatable } from '@salesforce/kit';
|
|
2
|
-
import {
|
|
2
|
+
import { OAuth2Config } from 'jsforce/lib/oauth2';
|
|
3
3
|
import { Nullable, JsonMap } from '@salesforce/ts-types';
|
|
4
4
|
import { AuthInfo } from './org/authInfo';
|
|
5
5
|
export interface DeviceCodeResponse extends JsonMap {
|
|
@@ -34,7 +34,7 @@ export interface DeviceCodePollingResponse extends JsonMap {
|
|
|
34
34
|
* const authInfo = await deviceOauthService.authorizeAndSave(approval);
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
export declare class DeviceOauthService extends AsyncCreatable<
|
|
37
|
+
export declare class DeviceOauthService extends AsyncCreatable<OAuth2Config> {
|
|
38
38
|
static RESPONSE_TYPE: string;
|
|
39
39
|
static GRANT_TYPE: string;
|
|
40
40
|
static SCOPE: string;
|
|
@@ -42,7 +42,7 @@ export declare class DeviceOauthService extends AsyncCreatable<OAuth2Options> {
|
|
|
42
42
|
private logger;
|
|
43
43
|
private options;
|
|
44
44
|
private pollingCount;
|
|
45
|
-
constructor(options:
|
|
45
|
+
constructor(options: OAuth2Config);
|
|
46
46
|
/**
|
|
47
47
|
* Begin the authorization flow by requesting the login
|
|
48
48
|
*
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.DeviceOauthService = void 0;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const Transport = require("jsforce/lib/transport");
|
|
12
|
+
const url_1 = require("url");
|
|
13
|
+
const transport_1 = require("jsforce/lib/transport");
|
|
15
14
|
const kit_1 = require("@salesforce/kit");
|
|
16
15
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
17
16
|
const logger_1 = require("./logger");
|
|
@@ -27,7 +26,7 @@ async function wait(ms = 1000) {
|
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
async function makeRequest(options) {
|
|
30
|
-
const rawResponse = await new
|
|
29
|
+
const rawResponse = await new transport_1.default().httpRequest(options);
|
|
31
30
|
const response = kit_1.parseJsonMap(rawResponse.body);
|
|
32
31
|
if (response.error) {
|
|
33
32
|
const err = new sfdxError_1.SfdxError('Request Failed.');
|
|
@@ -109,36 +108,36 @@ class DeviceOauthService extends kit_1.AsyncCreatable {
|
|
|
109
108
|
this.logger.debug(`this.options.loginUrl: ${this.options.loginUrl}`);
|
|
110
109
|
}
|
|
111
110
|
getLoginOptions(url) {
|
|
111
|
+
const body = new url_1.URLSearchParams();
|
|
112
|
+
body.append('client_id', ts_types_1.ensureString(this.options.clientId));
|
|
113
|
+
body.append('response_type', DeviceOauthService.RESPONSE_TYPE);
|
|
114
|
+
body.append('scope', DeviceOauthService.SCOPE);
|
|
112
115
|
return {
|
|
113
116
|
url,
|
|
114
117
|
headers: connection_1.SFDX_HTTP_HEADERS,
|
|
115
118
|
method: 'POST',
|
|
116
|
-
|
|
117
|
-
client_id: ts_types_1.ensureString(this.options.clientId),
|
|
118
|
-
response_type: DeviceOauthService.RESPONSE_TYPE,
|
|
119
|
-
scope: DeviceOauthService.SCOPE,
|
|
120
|
-
},
|
|
119
|
+
body,
|
|
121
120
|
};
|
|
122
121
|
}
|
|
123
122
|
getPollingOptions(url, code) {
|
|
123
|
+
const body = new url_1.URLSearchParams();
|
|
124
|
+
body.append('client_id', ts_types_1.ensureString(this.options.clientId));
|
|
125
|
+
body.append('grant_type', DeviceOauthService.GRANT_TYPE);
|
|
126
|
+
body.append('code', code);
|
|
124
127
|
return {
|
|
125
128
|
url,
|
|
126
129
|
headers: connection_1.SFDX_HTTP_HEADERS,
|
|
127
130
|
method: 'POST',
|
|
128
|
-
|
|
129
|
-
code,
|
|
130
|
-
grant_type: DeviceOauthService.GRANT_TYPE,
|
|
131
|
-
client_id: ts_types_1.ensureString(this.options.clientId),
|
|
132
|
-
},
|
|
131
|
+
body,
|
|
133
132
|
};
|
|
134
133
|
}
|
|
135
134
|
getDeviceFlowRequestUrl() {
|
|
136
135
|
return `${ts_types_1.ensureString(this.options.loginUrl)}/services/oauth2/token`;
|
|
137
136
|
}
|
|
138
|
-
async poll(
|
|
137
|
+
async poll(httpRequest) {
|
|
139
138
|
this.logger.debug(`polling for device approval (attempt ${this.pollingCount} of ${DeviceOauthService.POLLING_COUNT_MAX})`);
|
|
140
139
|
try {
|
|
141
|
-
return await makeRequest(
|
|
140
|
+
return await makeRequest(httpRequest);
|
|
142
141
|
}
|
|
143
142
|
catch (e) {
|
|
144
143
|
const err = e.data;
|
|
@@ -160,11 +159,11 @@ class DeviceOauthService extends kit_1.AsyncCreatable {
|
|
|
160
159
|
shouldContinuePolling() {
|
|
161
160
|
return this.pollingCount < DeviceOauthService.POLLING_COUNT_MAX;
|
|
162
161
|
}
|
|
163
|
-
async pollForDeviceApproval(
|
|
162
|
+
async pollForDeviceApproval(httpRequest, interval) {
|
|
164
163
|
this.logger.debug('BEGIN POLLING FOR DEVICE APPROVAL');
|
|
165
164
|
let result;
|
|
166
165
|
while (this.shouldContinuePolling()) {
|
|
167
|
-
result = await this.poll(
|
|
166
|
+
result = await this.poll(httpRequest);
|
|
168
167
|
if (result) {
|
|
169
168
|
this.logger.debug('POLLING FOR DEVICE APPROVAL SUCCESS');
|
|
170
169
|
break;
|
package/lib/exported.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { OAuth2Config } from 'jsforce';
|
|
2
2
|
export { ConfigFile } from './config/configFile';
|
|
3
3
|
export { EnvironmentVariable, SUPPORTED_ENV_VARS } from './config/envVars';
|
|
4
4
|
export { BaseConfigStore, ConfigContents, ConfigEntry, ConfigStore, ConfigValue } from './config/configStore';
|
|
@@ -7,7 +7,7 @@ export { DeviceOauthService, DeviceCodeResponse, DeviceCodePollingResponse } fro
|
|
|
7
7
|
export { OrgUsersConfig } from './config/orgUsersConfig';
|
|
8
8
|
export { ConfigPropertyMeta, ConfigPropertyMetaInput, Config, SfdxPropertyKeys, SFDX_ALLOWED_PROPERTIES, } from './config/config';
|
|
9
9
|
export { ConfigInfo, ConfigAggregator } from './config/configAggregator';
|
|
10
|
-
export { AuthFields, AuthInfo,
|
|
10
|
+
export { AuthFields, AuthInfo, OrgAuthorization } from './org/authInfo';
|
|
11
11
|
export { AuthRemover } from './org/authRemover';
|
|
12
12
|
export { Connection, SFDX_HTTP_HEADERS } from './org/connection';
|
|
13
13
|
export { Mode, Global } from './global';
|
|
@@ -17,15 +17,14 @@ export { SfdcUrl } from './util/sfdcUrl';
|
|
|
17
17
|
export { getJwtAudienceUrl } from './util/getJwtAudienceUrl';
|
|
18
18
|
export { Fields, FieldValue, LoggerLevel, LoggerLevelValue, LogLine, LoggerOptions, LoggerStream, Logger, } from './logger';
|
|
19
19
|
export { Messages } from './messages';
|
|
20
|
-
export { Org } from './org
|
|
20
|
+
export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, OrgTypes, ResultEvent, } from './org';
|
|
21
21
|
export { OrgConfigProperties, ORG_CONFIG_ALLOWED_PROPERTIES } from './org/orgConfigProperties';
|
|
22
22
|
export { PackageDir, NamedPackageDir, PackageDirDependency, SfdxProject, SfdxProjectJson } from './sfdxProject';
|
|
23
23
|
export { SchemaPrinter } from './schema/printer';
|
|
24
24
|
export { SchemaValidator } from './schema/validator';
|
|
25
25
|
export { SfdxError } from './sfdxError';
|
|
26
|
-
export { StatusResult } from './status/client';
|
|
27
26
|
export { PollingClient } from './status/pollingClient';
|
|
28
|
-
export { CometClient, CometSubscription, StreamingClient } from './status/streamingClient';
|
|
27
|
+
export { CometClient, CometSubscription, StreamingClient, StatusResult } from './status/streamingClient';
|
|
29
28
|
export { MyDomainResolver } from './status/myDomainResolver';
|
|
30
29
|
export { DefaultUserFields, REQUIRED_FIELDS, User, UserFields } from './org/user';
|
|
31
30
|
export { PermissionSetAssignment, PermissionSetAssignmentFields } from './org/permissionSetAssignment';
|
package/lib/exported.js
CHANGED
|
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.
|
|
19
|
+
exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.ConfigAggregator = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.SfInfoKeys = exports.GlobalInfo = exports.BaseConfigStore = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.ConfigFile = void 0;
|
|
20
20
|
const messages_1 = require("./messages");
|
|
21
21
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
22
22
|
var configFile_1 = require("./config/configFile");
|
|
@@ -41,7 +41,6 @@ var configAggregator_1 = require("./config/configAggregator");
|
|
|
41
41
|
Object.defineProperty(exports, "ConfigAggregator", { enumerable: true, get: function () { return configAggregator_1.ConfigAggregator; } });
|
|
42
42
|
var authInfo_1 = require("./org/authInfo");
|
|
43
43
|
Object.defineProperty(exports, "AuthInfo", { enumerable: true, get: function () { return authInfo_1.AuthInfo; } });
|
|
44
|
-
Object.defineProperty(exports, "OAuth2WithVerifier", { enumerable: true, get: function () { return authInfo_1.OAuth2WithVerifier; } });
|
|
45
44
|
var authRemover_1 = require("./org/authRemover");
|
|
46
45
|
Object.defineProperty(exports, "AuthRemover", { enumerable: true, get: function () { return authRemover_1.AuthRemover; } });
|
|
47
46
|
var connection_1 = require("./org/connection");
|
|
@@ -63,8 +62,10 @@ Object.defineProperty(exports, "LoggerLevel", { enumerable: true, get: function
|
|
|
63
62
|
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
|
|
64
63
|
var messages_2 = require("./messages");
|
|
65
64
|
Object.defineProperty(exports, "Messages", { enumerable: true, get: function () { return messages_2.Messages; } });
|
|
66
|
-
var org_1 = require("./org
|
|
65
|
+
var org_1 = require("./org");
|
|
67
66
|
Object.defineProperty(exports, "Org", { enumerable: true, get: function () { return org_1.Org; } });
|
|
67
|
+
Object.defineProperty(exports, "SandboxEvents", { enumerable: true, get: function () { return org_1.SandboxEvents; } });
|
|
68
|
+
Object.defineProperty(exports, "OrgTypes", { enumerable: true, get: function () { return org_1.OrgTypes; } });
|
|
68
69
|
var orgConfigProperties_1 = require("./org/orgConfigProperties");
|
|
69
70
|
Object.defineProperty(exports, "OrgConfigProperties", { enumerable: true, get: function () { return orgConfigProperties_1.OrgConfigProperties; } });
|
|
70
71
|
Object.defineProperty(exports, "ORG_CONFIG_ALLOWED_PROPERTIES", { enumerable: true, get: function () { return orgConfigProperties_1.ORG_CONFIG_ALLOWED_PROPERTIES; } });
|
package/lib/lifecycleEvents.d.ts
CHANGED
|
@@ -16,16 +16,29 @@ declare type callback = (data: any) => Promise<void>;
|
|
|
16
16
|
*
|
|
17
17
|
* // Deep in the deploy code, fire the event for all libraries and plugins to hear.
|
|
18
18
|
* Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed);
|
|
19
|
+
*
|
|
20
|
+
* // if you don't need to await anything
|
|
21
|
+
* use `void Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed)` ;
|
|
19
22
|
* ```
|
|
20
23
|
*/
|
|
21
24
|
export declare class Lifecycle {
|
|
22
|
-
private debug;
|
|
23
25
|
private readonly listeners;
|
|
26
|
+
static readonly telemetryEventName = "telemetry";
|
|
27
|
+
static readonly warningEventName = "warning";
|
|
28
|
+
private debug;
|
|
24
29
|
private constructor();
|
|
30
|
+
/**
|
|
31
|
+
* return the package.json version of the sfdx-core library.
|
|
32
|
+
*/
|
|
33
|
+
static staticVersion(): string;
|
|
25
34
|
/**
|
|
26
35
|
* Retrieve the singleton instance of this class so that all listeners and emitters can interact from any library or tool
|
|
27
36
|
*/
|
|
28
37
|
static getInstance(): Lifecycle;
|
|
38
|
+
/**
|
|
39
|
+
* return the package.json version of the sfdx-core library.
|
|
40
|
+
*/
|
|
41
|
+
version(): string;
|
|
29
42
|
/**
|
|
30
43
|
* Remove all listeners for a given event
|
|
31
44
|
*
|
|
@@ -38,6 +51,18 @@ export declare class Lifecycle {
|
|
|
38
51
|
* @param eventName The name of the event to get listeners of
|
|
39
52
|
*/
|
|
40
53
|
getListeners(eventName: string): callback[];
|
|
54
|
+
/**
|
|
55
|
+
* Create a listener for the `telemetry` event
|
|
56
|
+
*
|
|
57
|
+
* @param cb The callback function to run when the event is emitted
|
|
58
|
+
*/
|
|
59
|
+
onTelemetry(cb: (data: Record<string, unknown>) => Promise<void>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Create a listener for the `warning` event
|
|
62
|
+
*
|
|
63
|
+
* @param cb The callback function to run when the event is emitted
|
|
64
|
+
*/
|
|
65
|
+
onWarning(cb: (warning: string) => Promise<void>): void;
|
|
41
66
|
/**
|
|
42
67
|
* Create a new listener for a given event
|
|
43
68
|
*
|
|
@@ -45,6 +70,18 @@ export declare class Lifecycle {
|
|
|
45
70
|
* @param cb The callback function to run when the event is emitted
|
|
46
71
|
*/
|
|
47
72
|
on<T = AnyJson>(eventName: string, cb: (data: T) => Promise<void>): void;
|
|
73
|
+
/**
|
|
74
|
+
* Emit a `telemetry` event, causing all callback functions to be run in the order they were registered
|
|
75
|
+
*
|
|
76
|
+
* @param data The data to emit
|
|
77
|
+
*/
|
|
78
|
+
emitTelemetry(data: AnyJson): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Emit a `warning` event, causing all callback functions to be run in the order they were registered
|
|
81
|
+
*
|
|
82
|
+
* @param data The warning (string) to emit
|
|
83
|
+
*/
|
|
84
|
+
emitWarning(warning: string): Promise<void>;
|
|
48
85
|
/**
|
|
49
86
|
* Emit a given event, causing all callback functions to be run in the order they were registered
|
|
50
87
|
*
|
package/lib/lifecycleEvents.js
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Lifecycle = void 0;
|
|
10
10
|
const Debug = require("debug");
|
|
11
|
+
const semver_1 = require("semver");
|
|
12
|
+
// needed for TS to not put everything inside /lib/src
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
const pjson = require("../package.json");
|
|
11
15
|
/**
|
|
12
16
|
* An asynchronous event listener and emitter that follows the singleton pattern. The singleton pattern allows lifecycle
|
|
13
17
|
* events to be emitted from deep within a library and still be consumed by any other library or tool. It allows other
|
|
@@ -24,12 +28,21 @@ const Debug = require("debug");
|
|
|
24
28
|
*
|
|
25
29
|
* // Deep in the deploy code, fire the event for all libraries and plugins to hear.
|
|
26
30
|
* Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed);
|
|
31
|
+
*
|
|
32
|
+
* // if you don't need to await anything
|
|
33
|
+
* use `void Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed)` ;
|
|
27
34
|
* ```
|
|
28
35
|
*/
|
|
29
36
|
class Lifecycle {
|
|
30
|
-
constructor() {
|
|
37
|
+
constructor(listeners = {}) {
|
|
38
|
+
this.listeners = listeners;
|
|
31
39
|
this.debug = Debug(`sfdx:${this.constructor.name}`);
|
|
32
|
-
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* return the package.json version of the sfdx-core library.
|
|
43
|
+
*/
|
|
44
|
+
static staticVersion() {
|
|
45
|
+
return pjson.version;
|
|
33
46
|
}
|
|
34
47
|
/**
|
|
35
48
|
* Retrieve the singleton instance of this class so that all listeners and emitters can interact from any library or tool
|
|
@@ -52,10 +65,29 @@ class Lifecycle {
|
|
|
52
65
|
//
|
|
53
66
|
// Nothing should EVER be removed, even across major versions.
|
|
54
67
|
if (!global.salesforceCoreLifecycle) {
|
|
68
|
+
// it's not been loaded yet (basic singleton pattern)
|
|
55
69
|
global.salesforceCoreLifecycle = new Lifecycle();
|
|
56
70
|
}
|
|
71
|
+
else if (
|
|
72
|
+
// an older version was loaded that should be replaced
|
|
73
|
+
semver_1.compare(global.salesforceCoreLifecycle.version(), Lifecycle.staticVersion()) === -1) {
|
|
74
|
+
const oldInstance = global.salesforceCoreLifecycle;
|
|
75
|
+
// use the newer version and transfer any listeners from the old version
|
|
76
|
+
// object spread keeps them from being references
|
|
77
|
+
global.salesforceCoreLifecycle = new Lifecycle({ ...oldInstance.listeners });
|
|
78
|
+
// clean up any listeners on the old version
|
|
79
|
+
Object.keys(oldInstance.listeners).map((eventName) => {
|
|
80
|
+
oldInstance.removeAllListeners(eventName);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
57
83
|
return global.salesforceCoreLifecycle;
|
|
58
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* return the package.json version of the sfdx-core library.
|
|
87
|
+
*/
|
|
88
|
+
version() {
|
|
89
|
+
return pjson.version;
|
|
90
|
+
}
|
|
59
91
|
/**
|
|
60
92
|
* Remove all listeners for a given event
|
|
61
93
|
*
|
|
@@ -79,6 +111,22 @@ class Lifecycle {
|
|
|
79
111
|
return [];
|
|
80
112
|
}
|
|
81
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a listener for the `telemetry` event
|
|
116
|
+
*
|
|
117
|
+
* @param cb The callback function to run when the event is emitted
|
|
118
|
+
*/
|
|
119
|
+
onTelemetry(cb) {
|
|
120
|
+
this.on(Lifecycle.telemetryEventName, cb);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Create a listener for the `warning` event
|
|
124
|
+
*
|
|
125
|
+
* @param cb The callback function to run when the event is emitted
|
|
126
|
+
*/
|
|
127
|
+
onWarning(cb) {
|
|
128
|
+
this.on(Lifecycle.warningEventName, cb);
|
|
129
|
+
}
|
|
82
130
|
/**
|
|
83
131
|
* Create a new listener for a given event
|
|
84
132
|
*
|
|
@@ -93,6 +141,27 @@ class Lifecycle {
|
|
|
93
141
|
listeners.push(cb);
|
|
94
142
|
this.listeners[eventName] = listeners;
|
|
95
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Emit a `telemetry` event, causing all callback functions to be run in the order they were registered
|
|
146
|
+
*
|
|
147
|
+
* @param data The data to emit
|
|
148
|
+
*/
|
|
149
|
+
async emitTelemetry(data) {
|
|
150
|
+
return this.emit(Lifecycle.telemetryEventName, data);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Emit a `warning` event, causing all callback functions to be run in the order they were registered
|
|
154
|
+
*
|
|
155
|
+
* @param data The warning (string) to emit
|
|
156
|
+
*/
|
|
157
|
+
async emitWarning(warning) {
|
|
158
|
+
// if there are no listeners, warnings should go to the node process so they're not lost
|
|
159
|
+
// this also preserves behavior in UT where there's a spy on process.emitWarning
|
|
160
|
+
if (this.getListeners(Lifecycle.warningEventName).length === 0) {
|
|
161
|
+
process.emitWarning(warning);
|
|
162
|
+
}
|
|
163
|
+
return this.emit(Lifecycle.warningEventName, warning);
|
|
164
|
+
}
|
|
96
165
|
/**
|
|
97
166
|
* Emit a given event, causing all callback functions to be run in the order they were registered
|
|
98
167
|
*
|
|
@@ -112,4 +181,6 @@ class Lifecycle {
|
|
|
112
181
|
}
|
|
113
182
|
}
|
|
114
183
|
exports.Lifecycle = Lifecycle;
|
|
184
|
+
Lifecycle.telemetryEventName = 'telemetry';
|
|
185
|
+
Lifecycle.warningEventName = 'warning';
|
|
115
186
|
//# sourceMappingURL=lifecycleEvents.js.map
|
package/lib/logger.js
CHANGED
package/lib/org/authInfo.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { AsyncOptionalCreatable } from '@salesforce/kit';
|
|
2
|
-
import {
|
|
3
|
-
import { OAuth2,
|
|
2
|
+
import { Nullable } from '@salesforce/ts-types';
|
|
3
|
+
import { OAuth2, OAuth2Config as JsforceOAuth2Config } from 'jsforce';
|
|
4
4
|
import { Connection } from './connection';
|
|
5
|
+
export declare type OAuth2Config = JsforceOAuth2Config & {
|
|
6
|
+
privateKey?: string;
|
|
7
|
+
privateKeyFile?: string;
|
|
8
|
+
authCode?: string;
|
|
9
|
+
refreshToken?: string;
|
|
10
|
+
loginUrl?: string;
|
|
11
|
+
};
|
|
5
12
|
/**
|
|
6
13
|
* Fields for authorization, org, and local information.
|
|
7
14
|
*/
|
|
@@ -63,46 +70,12 @@ export declare type ConnectionOptions = AuthFields & {
|
|
|
63
70
|
/**
|
|
64
71
|
* OAuth options.
|
|
65
72
|
*/
|
|
66
|
-
oauth2?: Partial<
|
|
73
|
+
oauth2?: Partial<OAuth2Config>;
|
|
67
74
|
/**
|
|
68
75
|
* Refresh token callback.
|
|
69
76
|
*/
|
|
70
77
|
refreshFn?: RefreshFn;
|
|
71
78
|
};
|
|
72
|
-
/**
|
|
73
|
-
* Extend OAuth2 to add code verifier support for the auth code (web auth) flow
|
|
74
|
-
* const oauth2 = new OAuth2WithVerifier({ loginUrl, clientSecret, clientId, redirectUri });
|
|
75
|
-
*
|
|
76
|
-
* const authUrl = oauth2.getAuthorizationUrl({
|
|
77
|
-
* state: 'foo',
|
|
78
|
-
* prompt: 'login',
|
|
79
|
-
* scope: 'api web'
|
|
80
|
-
* });
|
|
81
|
-
* console.log(authUrl);
|
|
82
|
-
* const authCode = await retrieveCode();
|
|
83
|
-
* const authInfo = await AuthInfo.create({ oauth2Options: { clientId, clientSecret, loginUrl, authCode }, oauth2});
|
|
84
|
-
* console.log(`access token: ${authInfo.getFields(true).accessToken}`);
|
|
85
|
-
*/
|
|
86
|
-
export declare class OAuth2WithVerifier extends OAuth2 {
|
|
87
|
-
readonly codeVerifier: string;
|
|
88
|
-
constructor(options: OAuth2Options);
|
|
89
|
-
/**
|
|
90
|
-
* Overrides jsforce.OAuth2.getAuthorizationUrl. Get Salesforce OAuth2 authorization page
|
|
91
|
-
* URL to redirect user agent, adding a verification code for added security.
|
|
92
|
-
*
|
|
93
|
-
* @param params
|
|
94
|
-
*/
|
|
95
|
-
getAuthorizationUrl(params: Record<string, unknown>): string;
|
|
96
|
-
requestToken(code: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise<TokenResponse>;
|
|
97
|
-
/**
|
|
98
|
-
* Overrides jsforce.OAuth2._postParams because jsforce's oauth impl doesn't support
|
|
99
|
-
* coder_verifier and code_challenge. This enables the server to disallow trading a one-time auth code
|
|
100
|
-
* for an access/refresh token when the verifier and challenge are out of alignment.
|
|
101
|
-
*
|
|
102
|
-
* See https://github.com/jsforce/jsforce/issues/665
|
|
103
|
-
*/
|
|
104
|
-
protected _postParams(params: Record<string, unknown>, callback: AnyFunction): Promise<any>;
|
|
105
|
-
}
|
|
106
79
|
export declare const DEFAULT_CONNECTED_APP_INFO: {
|
|
107
80
|
clientId: string;
|
|
108
81
|
legacyClientId: string;
|
|
@@ -180,9 +153,9 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
|
|
|
180
153
|
*
|
|
181
154
|
* @param options The options to generate the URL.
|
|
182
155
|
*/
|
|
183
|
-
static getAuthorizationUrl(options:
|
|
156
|
+
static getAuthorizationUrl(options: OAuth2Config & {
|
|
184
157
|
scope?: string;
|
|
185
|
-
}, oauth2?:
|
|
158
|
+
}, oauth2?: OAuth2): string;
|
|
186
159
|
/**
|
|
187
160
|
* Parse a sfdx auth url, usually obtained by `authInfo.getSfdxAuthUrl`.
|
|
188
161
|
*
|
|
@@ -192,12 +165,7 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
|
|
|
192
165
|
* ```
|
|
193
166
|
* @param sfdxAuthUrl
|
|
194
167
|
*/
|
|
195
|
-
static parseSfdxAuthUrl(sfdxAuthUrl: string):
|
|
196
|
-
clientId: string;
|
|
197
|
-
clientSecret: string;
|
|
198
|
-
refreshToken: string;
|
|
199
|
-
loginUrl: string;
|
|
200
|
-
};
|
|
168
|
+
static parseSfdxAuthUrl(sfdxAuthUrl: string): Pick<AuthFields, 'clientId' | 'clientSecret' | 'refreshToken' | 'loginUrl'>;
|
|
201
169
|
/**
|
|
202
170
|
* Get the username.
|
|
203
171
|
*/
|
|
@@ -235,6 +203,8 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
|
|
|
235
203
|
* Get the auth fields (decrypted) needed to make a connection.
|
|
236
204
|
*/
|
|
237
205
|
getConnectionOptions(): ConnectionOptions;
|
|
206
|
+
getClientId(): string;
|
|
207
|
+
getRedirectUri(): string;
|
|
238
208
|
/**
|
|
239
209
|
* Get the authorization fields.
|
|
240
210
|
*
|
|
@@ -320,7 +290,7 @@ export declare namespace AuthInfo {
|
|
|
320
290
|
/**
|
|
321
291
|
* OAuth options.
|
|
322
292
|
*/
|
|
323
|
-
oauth2Options?:
|
|
293
|
+
oauth2Options?: OAuth2Config;
|
|
324
294
|
/**
|
|
325
295
|
* Options for the access token auth.
|
|
326
296
|
*/
|
|
@@ -332,5 +302,6 @@ export declare namespace AuthInfo {
|
|
|
332
302
|
* creation.
|
|
333
303
|
*/
|
|
334
304
|
parentUsername?: string;
|
|
305
|
+
isDevHub?: boolean;
|
|
335
306
|
}
|
|
336
307
|
}
|