@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/util/sfdcUrl.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { URL } from 'url';
|
|
3
|
+
export declare function getLoginAudienceCombos(audienceUrl: string, loginUrl: string): Array<[string, string]>;
|
|
3
4
|
export declare class SfdcUrl extends URL {
|
|
4
5
|
/**
|
|
5
6
|
* Salesforce URLs
|
|
@@ -27,7 +28,7 @@ export declare class SfdcUrl extends URL {
|
|
|
27
28
|
/**
|
|
28
29
|
* Tests whether this url is an internal Salesforce domain
|
|
29
30
|
*
|
|
30
|
-
* @returns {boolean} true if this is
|
|
31
|
+
* @returns {boolean} true if this is an internal domain
|
|
31
32
|
*/
|
|
32
33
|
isInternalUrl(): boolean;
|
|
33
34
|
/**
|
|
@@ -43,36 +44,21 @@ export declare class SfdcUrl extends URL {
|
|
|
43
44
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
44
45
|
*
|
|
45
46
|
* @returns {Promise<true | never>} The resolved ip address or never
|
|
46
|
-
* @throws {@link
|
|
47
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
47
48
|
*/
|
|
48
49
|
checkLightningDomain(): Promise<true | never>;
|
|
49
50
|
/**
|
|
50
|
-
* Method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again
|
|
51
|
+
* Method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again until timeout
|
|
51
52
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
52
53
|
*
|
|
53
54
|
* @returns the resolved ip address.
|
|
54
|
-
* @throws {@link
|
|
55
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
55
56
|
*/
|
|
56
57
|
lookup(): Promise<string>;
|
|
57
|
-
/**
|
|
58
|
-
* Tests whether this url is a sandbox url
|
|
59
|
-
*
|
|
60
|
-
* @param createdOrgInstance The Salesforce instance the org was created on. e.g. `cs42`
|
|
61
|
-
* @returns {boolean}
|
|
62
|
-
*/
|
|
63
|
-
isSandboxUrl(createdOrgInstance?: string): boolean;
|
|
64
58
|
/**
|
|
65
59
|
* Test whether this url represents a lightning domain
|
|
66
60
|
*
|
|
67
61
|
* @returns {boolean} true if this domain is a lightning domain
|
|
68
62
|
*/
|
|
69
63
|
isLightningDomain(): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Tests whether this url is a sandbox url
|
|
72
|
-
* otherwise tries to resolve dns cnames and then look if any is sandbox url
|
|
73
|
-
*
|
|
74
|
-
* @param createdOrgInstance The Salesforce instance the org was created on. e.g. `cs42`
|
|
75
|
-
* @returns {Promise<boolean>} true if this domain resolves to sanbox url
|
|
76
|
-
*/
|
|
77
|
-
private resolvesToSandbox;
|
|
78
64
|
}
|
package/lib/util/sfdcUrl.js
CHANGED
|
@@ -6,13 +6,37 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.SfdcUrl = void 0;
|
|
9
|
+
exports.SfdcUrl = exports.getLoginAudienceCombos = void 0;
|
|
10
10
|
const url_1 = require("url");
|
|
11
11
|
const kit_1 = require("@salesforce/kit");
|
|
12
12
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
13
|
const myDomainResolver_1 = require("../status/myDomainResolver");
|
|
14
14
|
const logger_1 = require("../logger");
|
|
15
15
|
const lifecycleEvents_1 = require("../lifecycleEvents");
|
|
16
|
+
function getLoginAudienceCombos(audienceUrl, loginUrl) {
|
|
17
|
+
const filtered = [
|
|
18
|
+
[loginUrl, loginUrl],
|
|
19
|
+
[SfdcUrl.SANDBOX, SfdcUrl.SANDBOX],
|
|
20
|
+
[SfdcUrl.PRODUCTION, SfdcUrl.PRODUCTION],
|
|
21
|
+
[audienceUrl, audienceUrl],
|
|
22
|
+
[audienceUrl, SfdcUrl.PRODUCTION],
|
|
23
|
+
[audienceUrl, SfdcUrl.SANDBOX],
|
|
24
|
+
[loginUrl, audienceUrl],
|
|
25
|
+
[loginUrl, SfdcUrl.PRODUCTION],
|
|
26
|
+
[loginUrl, SfdcUrl.SANDBOX],
|
|
27
|
+
[SfdcUrl.PRODUCTION, audienceUrl],
|
|
28
|
+
[SfdcUrl.SANDBOX, audienceUrl],
|
|
29
|
+
].filter(([login, audience]) => !((login === SfdcUrl.PRODUCTION && audience === SfdcUrl.SANDBOX) ||
|
|
30
|
+
(login === SfdcUrl.SANDBOX && audience === SfdcUrl.PRODUCTION)));
|
|
31
|
+
const reduced = filtered.reduce((acc, [login, audience]) => {
|
|
32
|
+
const l = new url_1.URL(login);
|
|
33
|
+
const a = new url_1.URL(audience);
|
|
34
|
+
acc.set(`${l.origin}:${a.origin}`, [login, audience]);
|
|
35
|
+
return acc;
|
|
36
|
+
}, new Map());
|
|
37
|
+
return [...reduced.values()];
|
|
38
|
+
}
|
|
39
|
+
exports.getLoginAudienceCombos = getLoginAudienceCombos;
|
|
16
40
|
class SfdcUrl extends url_1.URL {
|
|
17
41
|
constructor(input, base) {
|
|
18
42
|
super(input.toString(), base);
|
|
@@ -45,13 +69,6 @@ class SfdcUrl extends url_1.URL {
|
|
|
45
69
|
this.logger.debug(`Audience URL overridden by env var SFDX_AUDIENCE_URL=${envVarVal}`);
|
|
46
70
|
return envVarVal;
|
|
47
71
|
}
|
|
48
|
-
if (this.isInternalUrl()) {
|
|
49
|
-
// This is for internal developers when just doing authorize
|
|
50
|
-
return this.origin;
|
|
51
|
-
}
|
|
52
|
-
if (await this.resolvesToSandbox(createdOrgInstance)) {
|
|
53
|
-
return SfdcUrl.SANDBOX;
|
|
54
|
-
}
|
|
55
72
|
if ((createdOrgInstance && /^gs1/gi.test(createdOrgInstance)) || /(gs1.my.salesforce.com)/gi.test(this.origin)) {
|
|
56
73
|
return 'https://gs1.salesforce.com';
|
|
57
74
|
}
|
|
@@ -74,14 +91,12 @@ class SfdcUrl extends url_1.URL {
|
|
|
74
91
|
'crmforce.mil',
|
|
75
92
|
];
|
|
76
93
|
const allowlistOfSalesforceHosts = ['developer.salesforce.com', 'trailhead.salesforce.com'];
|
|
77
|
-
return allowlistOfSalesforceDomainPatterns.some((pattern) =>
|
|
78
|
-
return this.hostname.endsWith(pattern) || allowlistOfSalesforceHosts.includes(this.hostname);
|
|
79
|
-
});
|
|
94
|
+
return allowlistOfSalesforceDomainPatterns.some((pattern) => this.hostname.endsWith(pattern) || allowlistOfSalesforceHosts.includes(this.hostname));
|
|
80
95
|
}
|
|
81
96
|
/**
|
|
82
97
|
* Tests whether this url is an internal Salesforce domain
|
|
83
98
|
*
|
|
84
|
-
* @returns {boolean} true if this is
|
|
99
|
+
* @returns {boolean} true if this is an internal domain
|
|
85
100
|
*/
|
|
86
101
|
isInternalUrl() {
|
|
87
102
|
const INTERNAL_URL_PARTS = [
|
|
@@ -110,6 +125,15 @@ class SfdcUrl extends url_1.URL {
|
|
|
110
125
|
if (this.origin.endsWith('.my.salesforce.mil')) {
|
|
111
126
|
return this.origin.replace('.my.salesforce.mil', '.lightning.crmforce.mil');
|
|
112
127
|
}
|
|
128
|
+
// enhanced domains
|
|
129
|
+
// ex: sandbox.my.salesforce.com, scratch.my.salesforce.com, etc
|
|
130
|
+
if (this.origin.endsWith('.my.salesforce.com')) {
|
|
131
|
+
return this.origin.replace('.my.salesforce.com', '.lightning.force.com');
|
|
132
|
+
}
|
|
133
|
+
// alternative domains
|
|
134
|
+
if (this.origin.endsWith('.my-salesforce.com')) {
|
|
135
|
+
return this.origin.replace('.my-salesforce.com', '.my-lightning.com');
|
|
136
|
+
}
|
|
113
137
|
// all non-mil domains
|
|
114
138
|
return `https://${(0, ts_types_1.ensureArray)(/https?:\/\/([^.]*)/.exec(this.origin))
|
|
115
139
|
.slice(1, 2)
|
|
@@ -121,7 +145,7 @@ class SfdcUrl extends url_1.URL {
|
|
|
121
145
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
122
146
|
*
|
|
123
147
|
* @returns {Promise<true | never>} The resolved ip address or never
|
|
124
|
-
* @throws {@link
|
|
148
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
125
149
|
*/
|
|
126
150
|
async checkLightningDomain() {
|
|
127
151
|
const quantity = (0, ts_types_1.ensureNumber)(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
|
@@ -138,11 +162,11 @@ class SfdcUrl extends url_1.URL {
|
|
|
138
162
|
return true;
|
|
139
163
|
}
|
|
140
164
|
/**
|
|
141
|
-
* Method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again
|
|
165
|
+
* Method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again until timeout
|
|
142
166
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
143
167
|
*
|
|
144
168
|
* @returns the resolved ip address.
|
|
145
|
-
* @throws {@link
|
|
169
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
146
170
|
*/
|
|
147
171
|
async lookup() {
|
|
148
172
|
const quantity = (0, ts_types_1.ensureNumber)(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
|
@@ -154,46 +178,13 @@ class SfdcUrl extends url_1.URL {
|
|
|
154
178
|
});
|
|
155
179
|
return resolver.resolve();
|
|
156
180
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Tests whether this url is a sandbox url
|
|
159
|
-
*
|
|
160
|
-
* @param createdOrgInstance The Salesforce instance the org was created on. e.g. `cs42`
|
|
161
|
-
* @returns {boolean}
|
|
162
|
-
*/
|
|
163
|
-
isSandboxUrl(createdOrgInstance) {
|
|
164
|
-
return ((createdOrgInstance && /^cs|s$/gi.test(createdOrgInstance)) ||
|
|
165
|
-
this.origin.endsWith('sandbox.my.salesforce.mil') ||
|
|
166
|
-
/sandbox\.my\.salesforce\.com/gi.test(this.origin) || // enhanced domains >= 230
|
|
167
|
-
/(cs[0-9]+(\.my|)\.salesforce\.com)/gi.test(this.origin) || // my domains on CS instance OR CS instance without my domain
|
|
168
|
-
/([a-z]{3}[0-9]+s\.sfdc-.+\.salesforce\.com)/gi.test(this.origin) || // falcon sandbox ex: usa2s.sfdc-whatever.salesforce.com
|
|
169
|
-
/([a-z]{3}[0-9]+s\.sfdc-.+\.force\.com)/gi.test(this.origin) || // falcon sandbox ex: usa2s.sfdc-whatever.force.com
|
|
170
|
-
this.hostname === 'test.salesforce.com');
|
|
171
|
-
}
|
|
172
181
|
/**
|
|
173
182
|
* Test whether this url represents a lightning domain
|
|
174
183
|
*
|
|
175
184
|
* @returns {boolean} true if this domain is a lightning domain
|
|
176
185
|
*/
|
|
177
186
|
isLightningDomain() {
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Tests whether this url is a sandbox url
|
|
182
|
-
* otherwise tries to resolve dns cnames and then look if any is sandbox url
|
|
183
|
-
*
|
|
184
|
-
* @param createdOrgInstance The Salesforce instance the org was created on. e.g. `cs42`
|
|
185
|
-
* @returns {Promise<boolean>} true if this domain resolves to sanbox url
|
|
186
|
-
*/
|
|
187
|
-
async resolvesToSandbox(createdOrgInstance) {
|
|
188
|
-
if (this.isSandboxUrl(createdOrgInstance)) {
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
const myDomainResolver = await myDomainResolver_1.MyDomainResolver.create({ url: this });
|
|
192
|
-
const cnames = await myDomainResolver.getCnames();
|
|
193
|
-
return cnames.some((cname) => {
|
|
194
|
-
const url = new SfdcUrl(`https://${cname}`);
|
|
195
|
-
return url.isSandboxUrl();
|
|
196
|
-
});
|
|
187
|
+
return this.origin.includes('.lightning.force.com') || this.origin.includes('.lightning.crmforce.mil');
|
|
197
188
|
}
|
|
198
189
|
}
|
|
199
190
|
exports.SfdcUrl = SfdcUrl;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
export interface StructuredWriter {
|
|
5
|
+
addToStore(contents: string | Readable | Buffer, path: string): Promise<void>;
|
|
6
|
+
finalize(): Promise<void>;
|
|
7
|
+
getDestinationPath(): string | undefined;
|
|
8
|
+
get buffer(): Buffer;
|
|
9
|
+
}
|
package/lib/util/zipWriter.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Readable, Writable } from 'stream';
|
|
4
|
+
import { StructuredWriter } from './structuredWriter';
|
|
5
|
+
export declare class ZipWriter extends Writable implements StructuredWriter {
|
|
6
|
+
private readonly rootDestination?;
|
|
6
7
|
private zip;
|
|
7
8
|
private buffers;
|
|
8
9
|
constructor(rootDestination?: string | undefined);
|
|
9
|
-
|
|
10
|
+
get buffer(): Buffer;
|
|
11
|
+
addToStore(contents: string | Readable | Buffer, path: string): Promise<void>;
|
|
10
12
|
finalize(): Promise<void>;
|
|
13
|
+
getDestinationPath(): string | undefined;
|
|
11
14
|
private getOutputStream;
|
|
12
15
|
private getInputBuffer;
|
|
13
|
-
get buffer(): Buffer;
|
|
14
16
|
}
|
package/lib/util/zipWriter.js
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ZipWriter =
|
|
9
|
+
exports.ZipWriter = void 0;
|
|
10
10
|
const fs_1 = require("fs");
|
|
11
11
|
const stream_1 = require("stream");
|
|
12
12
|
const util_1 = require("util");
|
|
13
13
|
const archiver_1 = require("archiver");
|
|
14
|
-
|
|
14
|
+
const pipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
15
15
|
class ZipWriter extends stream_1.Writable {
|
|
16
16
|
constructor(rootDestination) {
|
|
17
17
|
super({ objectMode: true });
|
|
@@ -21,15 +21,22 @@ class ZipWriter extends stream_1.Writable {
|
|
|
21
21
|
// higher values = diminishing returns on compression and made conversion slower
|
|
22
22
|
this.zip = (0, archiver_1.create)('zip', { zlib: { level: 3 } });
|
|
23
23
|
this.buffers = [];
|
|
24
|
-
void
|
|
24
|
+
void pipeline(this.zip, this.getOutputStream());
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
get buffer() {
|
|
27
|
+
return Buffer.concat(this.buffers);
|
|
28
|
+
}
|
|
29
|
+
async addToStore(contents, path) {
|
|
27
30
|
this.zip.append(contents, { name: path });
|
|
31
|
+
return Promise.resolve();
|
|
28
32
|
}
|
|
29
33
|
async finalize() {
|
|
30
34
|
await this.zip.finalize();
|
|
31
35
|
await this.getInputBuffer();
|
|
32
36
|
}
|
|
37
|
+
getDestinationPath() {
|
|
38
|
+
return this.rootDestination;
|
|
39
|
+
}
|
|
33
40
|
getOutputStream() {
|
|
34
41
|
if (this.rootDestination) {
|
|
35
42
|
return (0, fs_1.createWriteStream)(this.rootDestination);
|
|
@@ -51,18 +58,11 @@ class ZipWriter extends stream_1.Writable {
|
|
|
51
58
|
inputStream.on('data', (chunk) => {
|
|
52
59
|
this.buffers.push(chunk);
|
|
53
60
|
});
|
|
54
|
-
inputStream.once('end', () =>
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
inputStream.once('error', (error) => {
|
|
58
|
-
return reject(error);
|
|
59
|
-
});
|
|
61
|
+
inputStream.once('end', () => resolve());
|
|
62
|
+
inputStream.once('error', (error) => reject(error));
|
|
60
63
|
});
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
|
-
get buffer() {
|
|
64
|
-
return Buffer.concat(this.buffers);
|
|
65
|
-
}
|
|
66
66
|
}
|
|
67
67
|
exports.ZipWriter = ZipWriter;
|
|
68
68
|
//# sourceMappingURL=zipWriter.js.map
|
package/lib/webOAuthServer.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as http from 'http';
|
|
3
|
+
import { JwtOAuth2Config } from 'jsforce';
|
|
3
4
|
import { AsyncCreatable } from '@salesforce/kit';
|
|
4
|
-
import { AuthInfo
|
|
5
|
+
import { AuthInfo } from './org';
|
|
5
6
|
/**
|
|
6
7
|
* Handles the creation of a web server for web based login flows.
|
|
7
8
|
*
|
|
@@ -25,6 +26,7 @@ export declare class WebOAuthServer extends AsyncCreatable<WebOAuthServer.Option
|
|
|
25
26
|
private webServer;
|
|
26
27
|
private oauth2;
|
|
27
28
|
private oauthConfig;
|
|
29
|
+
private oauthError;
|
|
28
30
|
constructor(options: WebOAuthServer.Options);
|
|
29
31
|
/**
|
|
30
32
|
* Returns the configured oauthLocalPort or the WebOAuthServer.DEFAULT_PORT
|
|
@@ -79,12 +81,14 @@ export declare class WebOAuthServer extends AsyncCreatable<WebOAuthServer.Option
|
|
|
79
81
|
}
|
|
80
82
|
export declare namespace WebOAuthServer {
|
|
81
83
|
interface Options {
|
|
82
|
-
oauthConfig:
|
|
84
|
+
oauthConfig: JwtOAuth2Config;
|
|
83
85
|
}
|
|
84
86
|
type Request = http.IncomingMessage & {
|
|
85
87
|
query: {
|
|
86
88
|
code: string;
|
|
87
89
|
state: string;
|
|
90
|
+
error?: string;
|
|
91
|
+
error_description?: string;
|
|
88
92
|
};
|
|
89
93
|
};
|
|
90
94
|
}
|
|
@@ -98,6 +102,7 @@ export declare class WebServer extends AsyncCreatable<WebServer.Options> {
|
|
|
98
102
|
host: string;
|
|
99
103
|
private logger;
|
|
100
104
|
private sockets;
|
|
105
|
+
private redirectStatus;
|
|
101
106
|
constructor(options: WebServer.Options);
|
|
102
107
|
/**
|
|
103
108
|
* Starts the http server after checking that the port is open
|
|
@@ -110,7 +115,7 @@ export declare class WebServer extends AsyncCreatable<WebServer.Options> {
|
|
|
110
115
|
/**
|
|
111
116
|
* sends a response error.
|
|
112
117
|
*
|
|
113
|
-
* @param
|
|
118
|
+
* @param status the statusCode for the response.
|
|
114
119
|
* @param message the message for the http body.
|
|
115
120
|
* @param response the response to write the error to.
|
|
116
121
|
*/
|
|
@@ -118,7 +123,7 @@ export declare class WebServer extends AsyncCreatable<WebServer.Options> {
|
|
|
118
123
|
/**
|
|
119
124
|
* sends a response redirect.
|
|
120
125
|
*
|
|
121
|
-
* @param
|
|
126
|
+
* @param status the statusCode for the response.
|
|
122
127
|
* @param url the url to redirect to.
|
|
123
128
|
* @param response the response to write the redirect to.
|
|
124
129
|
*/
|
|
@@ -126,11 +131,20 @@ export declare class WebServer extends AsyncCreatable<WebServer.Options> {
|
|
|
126
131
|
/**
|
|
127
132
|
* sends a response to the browser reporting an error.
|
|
128
133
|
*
|
|
129
|
-
* @param error the error
|
|
130
|
-
* @param response the response
|
|
134
|
+
* @param error the oauth error
|
|
135
|
+
* @param response the HTTP response.
|
|
131
136
|
*/
|
|
132
137
|
reportError(error: Error, response: http.ServerResponse): void;
|
|
138
|
+
/**
|
|
139
|
+
* sends a response to the browser reporting the success.
|
|
140
|
+
*
|
|
141
|
+
* @param response the HTTP response.
|
|
142
|
+
*/
|
|
143
|
+
reportSuccess(response: http.ServerResponse): void;
|
|
144
|
+
handleSuccess(response: http.ServerResponse): Promise<void>;
|
|
145
|
+
handleError(response: http.ServerResponse): Promise<void>;
|
|
133
146
|
protected init(): Promise<void>;
|
|
147
|
+
private handleRedirect;
|
|
134
148
|
/**
|
|
135
149
|
* Make sure we can't open a socket on the localhost/host port. It's important because we don't want to send
|
|
136
150
|
* auth tokens to a random strange port listener. We want to make sure we can startup our server first.
|