@salesforce/core 4.0.0 → 4.1.0

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.
Files changed (151) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +93 -44
  3. package/lib/config/authInfoConfig.d.ts +19 -0
  4. package/lib/config/authInfoConfig.js +35 -0
  5. package/lib/config/config.d.ts +87 -22
  6. package/lib/config/config.js +117 -65
  7. package/lib/config/configAggregator.d.ts +41 -35
  8. package/lib/config/configAggregator.js +102 -73
  9. package/lib/config/configFile.d.ts +2 -2
  10. package/lib/config/configFile.js +38 -29
  11. package/lib/config/configStore.d.ts +9 -9
  12. package/lib/config/configStore.js +17 -15
  13. package/lib/config/envVars.d.ts +15 -9
  14. package/lib/config/envVars.js +71 -47
  15. package/lib/config/orgUsersConfig.js +2 -0
  16. package/lib/config/sandboxOrgConfig.js +2 -0
  17. package/lib/config/sandboxProcessCache.d.ts +16 -0
  18. package/lib/config/sandboxProcessCache.js +38 -0
  19. package/lib/config/tokensConfig.d.ts +10 -0
  20. package/lib/config/tokensConfig.js +29 -0
  21. package/lib/config/ttlConfig.d.ts +34 -0
  22. package/lib/config/ttlConfig.js +50 -0
  23. package/lib/crypto/crypto.js +15 -22
  24. package/lib/crypto/keyChain.js +2 -3
  25. package/lib/crypto/keyChainImpl.d.ts +5 -3
  26. package/lib/crypto/keyChainImpl.js +58 -61
  27. package/lib/crypto/secureBuffer.d.ts +1 -1
  28. package/lib/deviceOauthService.d.ts +3 -3
  29. package/lib/deviceOauthService.js +27 -25
  30. package/lib/exported.d.ts +15 -12
  31. package/lib/exported.js +28 -16
  32. package/lib/global.d.ts +11 -3
  33. package/lib/global.js +39 -12
  34. package/lib/lifecycleEvents.d.ts +1 -1
  35. package/lib/lifecycleEvents.js +3 -0
  36. package/lib/logger.d.ts +19 -9
  37. package/lib/logger.js +112 -86
  38. package/lib/messages.d.ts +53 -36
  39. package/lib/messages.js +81 -91
  40. package/lib/org/authInfo.d.ts +56 -20
  41. package/lib/org/authInfo.js +232 -131
  42. package/lib/org/authRemover.d.ts +8 -7
  43. package/lib/org/authRemover.js +32 -28
  44. package/lib/org/connection.d.ts +13 -37
  45. package/lib/org/connection.js +78 -124
  46. package/lib/org/index.js +5 -1
  47. package/lib/org/org.d.ts +151 -48
  48. package/lib/org/org.js +468 -225
  49. package/lib/org/orgConfigProperties.d.ts +64 -3
  50. package/lib/org/orgConfigProperties.js +96 -4
  51. package/lib/org/permissionSetAssignment.js +4 -13
  52. package/lib/org/scratchOrgCache.d.ts +20 -0
  53. package/lib/org/scratchOrgCache.js +33 -0
  54. package/lib/org/scratchOrgCreate.d.ts +28 -17
  55. package/lib/org/scratchOrgCreate.js +125 -53
  56. package/lib/org/scratchOrgErrorCodes.d.ts +9 -3
  57. package/lib/org/scratchOrgErrorCodes.js +34 -17
  58. package/lib/org/scratchOrgFeatureDeprecation.js +1 -6
  59. package/lib/org/scratchOrgInfoApi.d.ts +21 -47
  60. package/lib/org/scratchOrgInfoApi.js +129 -63
  61. package/lib/org/scratchOrgInfoGenerator.d.ts +6 -5
  62. package/lib/org/scratchOrgInfoGenerator.js +76 -62
  63. package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -0
  64. package/lib/org/scratchOrgLifecycleEvents.js +41 -0
  65. package/lib/org/scratchOrgSettingsGenerator.d.ts +44 -21
  66. package/lib/org/scratchOrgSettingsGenerator.js +165 -98
  67. package/lib/org/scratchOrgTypes.d.ts +43 -0
  68. package/lib/org/scratchOrgTypes.js +9 -0
  69. package/lib/org/user.d.ts +1 -1
  70. package/lib/org/user.js +25 -34
  71. package/lib/schema/printer.d.ts +6 -0
  72. package/lib/schema/printer.js +34 -31
  73. package/lib/schema/validator.d.ts +12 -10
  74. package/lib/schema/validator.js +56 -76
  75. package/lib/{sfdxError.d.ts → sfError.d.ts} +12 -20
  76. package/lib/{sfdxError.js → sfError.js} +40 -30
  77. package/lib/{sfdxProject.d.ts → sfProject.d.ts} +75 -35
  78. package/lib/sfProject.js +651 -0
  79. package/lib/stateAggregator/accessors/aliasAccessor.d.ts +129 -0
  80. package/lib/stateAggregator/accessors/aliasAccessor.js +263 -0
  81. package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -0
  82. package/lib/stateAggregator/accessors/orgAccessor.js +240 -0
  83. package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -0
  84. package/lib/stateAggregator/accessors/sandboxAccessor.js +28 -0
  85. package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -0
  86. package/lib/stateAggregator/accessors/tokenAccessor.js +80 -0
  87. package/lib/stateAggregator/index.d.ts +4 -0
  88. package/lib/stateAggregator/index.js +27 -0
  89. package/lib/stateAggregator/stateAggregator.d.ts +25 -0
  90. package/lib/stateAggregator/stateAggregator.js +46 -0
  91. package/lib/status/myDomainResolver.d.ts +1 -1
  92. package/lib/status/myDomainResolver.js +4 -4
  93. package/lib/status/pollingClient.js +4 -4
  94. package/lib/status/streamingClient.d.ts +2 -2
  95. package/lib/status/streamingClient.js +58 -63
  96. package/lib/status/types.d.ts +2 -2
  97. package/lib/testSetup.d.ts +204 -75
  98. package/lib/testSetup.js +468 -164
  99. package/lib/util/cache.d.ts +2 -2
  100. package/lib/util/cache.js +6 -6
  101. package/lib/util/checkLightningDomain.js +3 -4
  102. package/lib/util/directoryWriter.d.ts +12 -0
  103. package/lib/util/directoryWriter.js +54 -0
  104. package/lib/util/getJwtAudienceUrl.js +1 -1
  105. package/lib/util/internal.d.ts +28 -2
  106. package/lib/util/internal.js +65 -8
  107. package/lib/util/jsonXmlTools.js +2 -4
  108. package/lib/util/mapKeys.d.ts +9 -9
  109. package/lib/util/mapKeys.js +13 -9
  110. package/lib/util/sfdc.d.ts +51 -51
  111. package/lib/util/sfdc.js +74 -79
  112. package/lib/util/sfdcUrl.d.ts +5 -19
  113. package/lib/util/sfdcUrl.js +40 -49
  114. package/lib/util/structuredWriter.d.ts +9 -0
  115. package/lib/util/structuredWriter.js +3 -0
  116. package/lib/util/zipWriter.d.ts +8 -6
  117. package/lib/util/zipWriter.js +13 -13
  118. package/lib/webOAuthServer.d.ts +20 -6
  119. package/lib/webOAuthServer.js +102 -56
  120. package/messageTransformer/messageTransformer.ts +93 -0
  121. package/messages/auth.md +9 -1
  122. package/messages/config.md +42 -6
  123. package/messages/connection.md +8 -0
  124. package/messages/core.md +10 -0
  125. package/messages/envVars.md +37 -3
  126. package/messages/org.md +21 -1
  127. package/messages/scratchOrgCreate.md +2 -6
  128. package/messages/scratchOrgErrorCodes.md +17 -1
  129. package/messages/scratchOrgInfoApi.md +9 -0
  130. package/messages/scratchOrgInfoGenerator.md +9 -1
  131. package/package.json +123 -46
  132. package/CHANGELOG.md +0 -1244
  133. package/lib/config/keychainConfig.d.ts +0 -19
  134. package/lib/config/keychainConfig.js +0 -43
  135. package/lib/globalInfo/accessors/aliasAccessor.d.ts +0 -83
  136. package/lib/globalInfo/accessors/aliasAccessor.js +0 -130
  137. package/lib/globalInfo/accessors/orgAccessor.d.ts +0 -13
  138. package/lib/globalInfo/accessors/orgAccessor.js +0 -45
  139. package/lib/globalInfo/accessors/tokenAccessor.d.ts +0 -13
  140. package/lib/globalInfo/accessors/tokenAccessor.js +0 -35
  141. package/lib/globalInfo/globalInfoConfig.d.ts +0 -36
  142. package/lib/globalInfo/globalInfoConfig.js +0 -105
  143. package/lib/globalInfo/index.d.ts +0 -6
  144. package/lib/globalInfo/index.js +0 -29
  145. package/lib/globalInfo/sfdxDataHandler.d.ts +0 -43
  146. package/lib/globalInfo/sfdxDataHandler.js +0 -217
  147. package/lib/globalInfo/types.d.ts +0 -39
  148. package/lib/globalInfo/types.js +0 -10
  149. package/lib/sfdxProject.js +0 -557
  150. package/lib/util/fs.d.ts +0 -201
  151. package/lib/util/fs.js +0 -378
@@ -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 a internal domain
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 SfdxError} If can't resolve DNS.
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 untill timeout
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 SfdxError} If can't resolve DNS.
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
  }
@@ -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 a internal domain
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 SfdxError} If can't resolve DNS.
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 untill timeout
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 SfdxError} If can't resolve DNS.
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 /\.lightning\.force\.com/.test(this.origin);
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
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=structuredWriter.js.map
@@ -1,14 +1,16 @@
1
1
  /// <reference types="node" />
2
- import { pipeline as cbPipeline, Readable, Writable } from 'stream';
3
- export declare const pipeline: typeof cbPipeline.__promisify__;
4
- export declare class ZipWriter extends Writable {
5
- private rootDestination?;
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
- addToZip(contents: string | Readable | Buffer, path: string): void;
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
  }
@@ -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 = exports.pipeline = void 0;
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
- exports.pipeline = (0, util_1.promisify)(stream_1.pipeline);
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 (0, exports.pipeline)(this.zip, this.getOutputStream());
24
+ void pipeline(this.zip, this.getOutputStream());
25
25
  }
26
- addToZip(contents, path) {
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
- return resolve();
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
@@ -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, OAuth2Config } from './org/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: OAuth2Config;
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 statusCode he statusCode for the response.
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 statusCode the statusCode for the response.
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 to write the redirect to.
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.