@salesforce/core 3.7.6 → 3.7.7
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 +2 -0
- package/README.md +4 -4
- package/lib/config/config.d.ts +5 -5
- package/lib/config/config.js +5 -5
- package/lib/config/configAggregator.d.ts +2 -2
- package/lib/config/configAggregator.js +2 -2
- package/lib/config/configFile.d.ts +2 -2
- package/lib/config/configFile.js +7 -7
- package/lib/config/configStore.js +5 -5
- package/lib/crypto/keyChainImpl.js +2 -2
- package/lib/deviceOauthService.js +2 -2
- package/lib/exported.d.ts +2 -2
- package/lib/exported.js +9 -6
- package/lib/globalInfo/accessors/aliasAccessor.js +2 -2
- package/lib/logger.d.ts +3 -3
- package/lib/logger.js +9 -9
- package/lib/messages.d.ts +2 -2
- package/lib/messages.js +4 -4
- package/lib/org/authInfo.d.ts +1 -1
- package/lib/org/authInfo.js +4 -4
- package/lib/org/authRemover.d.ts +2 -2
- package/lib/org/authRemover.js +2 -2
- package/lib/org/connection.d.ts +1 -1
- package/lib/org/connection.js +4 -4
- package/lib/org/org.d.ts +4 -4
- package/lib/org/org.js +13 -13
- package/lib/org/permissionSetAssignment.js +2 -2
- package/lib/org/scratchOrgCreate.js +4 -4
- package/lib/org/scratchOrgErrorCodes.js +6 -6
- package/lib/org/scratchOrgInfoApi.js +16 -16
- package/lib/org/scratchOrgInfoGenerator.d.ts +3 -3
- package/lib/org/scratchOrgInfoGenerator.js +17 -17
- package/lib/org/scratchOrgSettingsGenerator.js +2 -2
- package/lib/org/user.js +4 -4
- package/lib/schema/printer.js +2 -2
- package/lib/schema/validator.d.ts +4 -4
- package/lib/schema/validator.js +9 -9
- package/lib/{sfdxError.d.ts → sfError.d.ts} +14 -9
- package/lib/{sfdxError.js → sfError.js} +20 -14
- package/lib/{sfdxProject.d.ts → sfProject.d.ts} +37 -27
- package/lib/{sfdxProject.js → sfProject.js} +75 -63
- package/lib/status/pollingClient.js +3 -3
- package/lib/status/streamingClient.d.ts +2 -2
- package/lib/status/streamingClient.js +6 -6
- package/lib/testSetup.d.ts +4 -4
- package/lib/testSetup.js +8 -8
- package/lib/util/fs.js +7 -7
- package/lib/util/internal.d.ts +2 -2
- package/lib/util/internal.js +2 -2
- package/lib/util/sfdcUrl.d.ts +2 -2
- package/lib/util/sfdcUrl.js +2 -2
- package/lib/webOAuthServer.js +10 -10
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncOptionalCreatable, Duration, Env } from '@salesforce/kit/lib';
|
|
2
2
|
import { AnyJson } from '@salesforce/ts-types/lib';
|
|
3
|
-
import { Org } from '../org';
|
|
3
|
+
import { Org } from '../org/org';
|
|
4
4
|
import { CometClient, CometSubscription, Message, StatusResult, StreamingExtension, StreamProcessor } from './types';
|
|
5
5
|
export { CometClient, CometSubscription, Message, StatusResult, StreamingExtension, StreamProcessor };
|
|
6
6
|
/**
|
|
@@ -113,7 +113,7 @@ export declare class StreamingClient extends AsyncOptionalCreatable<StreamingCli
|
|
|
113
113
|
* Subscribe to streaming events. When the streaming processor that's set in the options completes execution it
|
|
114
114
|
* returns a payload in the StatusResult object. The payload is just echoed here for convenience.
|
|
115
115
|
*
|
|
116
|
-
* **Throws** *{@link
|
|
116
|
+
* **Throws** *{@link SfError}{ name: '{@link StreamingClient.TimeoutErrorType.SUBSCRIBE}'}* When the subscribe timeout occurs.
|
|
117
117
|
*
|
|
118
118
|
* @param streamInit This function should call the platform apis that result in streaming updates on push topics.
|
|
119
119
|
* {@link StatusResult}
|
|
@@ -13,7 +13,7 @@ const lib_1 = require("@salesforce/kit/lib");
|
|
|
13
13
|
const lib_2 = require("@salesforce/ts-types/lib");
|
|
14
14
|
const Faye = require("faye");
|
|
15
15
|
const logger_1 = require("../logger");
|
|
16
|
-
const
|
|
16
|
+
const sfError_1 = require("../sfError");
|
|
17
17
|
const messages_1 = require("../messages");
|
|
18
18
|
const types_1 = require("./types");
|
|
19
19
|
Object.defineProperty(exports, "CometClient", { enumerable: true, get: function () { return types_1.CometClient; } });
|
|
@@ -151,7 +151,7 @@ class StreamingClient extends lib_1.AsyncOptionalCreatable {
|
|
|
151
151
|
this.cometClient.setHeader('Authorization', `OAuth ${accessToken}`);
|
|
152
152
|
}
|
|
153
153
|
else {
|
|
154
|
-
throw new
|
|
154
|
+
throw new sfError_1.SfError('Missing or invalid access token', 'MissingOrInvalidAccessToken');
|
|
155
155
|
}
|
|
156
156
|
this.log(`Streaming client target url: ${this.targetUrl}`);
|
|
157
157
|
this.log(`options.subscribeTimeout (ms): ${this.options.subscribeTimeout.milliseconds}`);
|
|
@@ -201,7 +201,7 @@ class StreamingClient extends lib_1.AsyncOptionalCreatable {
|
|
|
201
201
|
* Subscribe to streaming events. When the streaming processor that's set in the options completes execution it
|
|
202
202
|
* returns a payload in the StatusResult object. The payload is just echoed here for convenience.
|
|
203
203
|
*
|
|
204
|
-
* **Throws** *{@link
|
|
204
|
+
* **Throws** *{@link SfError}{ name: '{@link StreamingClient.TimeoutErrorType.SUBSCRIBE}'}* When the subscribe timeout occurs.
|
|
205
205
|
*
|
|
206
206
|
* @param streamInit This function should call the platform apis that result in streaming updates on push topics.
|
|
207
207
|
* {@link StatusResult}
|
|
@@ -342,13 +342,13 @@ exports.StreamingClient = StreamingClient;
|
|
|
342
342
|
logger.warn('envDep is deprecated');
|
|
343
343
|
}
|
|
344
344
|
if (!streamProcessor) {
|
|
345
|
-
throw new
|
|
345
|
+
throw new sfError_1.SfError('Missing stream processor', 'MissingArg');
|
|
346
346
|
}
|
|
347
347
|
if (!org) {
|
|
348
|
-
throw new
|
|
348
|
+
throw new sfError_1.SfError('Missing org', 'MissingArg');
|
|
349
349
|
}
|
|
350
350
|
if (!channel) {
|
|
351
|
-
throw new
|
|
351
|
+
throw new sfError_1.SfError('Missing streaming channel', 'MissingArg');
|
|
352
352
|
}
|
|
353
353
|
this.org = org;
|
|
354
354
|
this.apiVersion = org.getConnection().getApiVersion();
|
package/lib/testSetup.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as sinonType from 'sinon';
|
|
|
4
4
|
import { AnyJson, JsonMap, Optional } from '@salesforce/ts-types';
|
|
5
5
|
import { ConfigContents } from './config/configStore';
|
|
6
6
|
import { Logger } from './logger';
|
|
7
|
-
import {
|
|
7
|
+
import { SfError } from './sfError';
|
|
8
8
|
import { CometClient, CometSubscription, Message, StreamingExtension } from './status/streamingClient';
|
|
9
9
|
import { SfOrg } from './globalInfo';
|
|
10
10
|
/**
|
|
@@ -85,7 +85,7 @@ export interface TestContext {
|
|
|
85
85
|
[configName: string]: Optional<ConfigStub>;
|
|
86
86
|
GlobalInfo?: ConfigStub;
|
|
87
87
|
Aliases?: ConfigStub;
|
|
88
|
-
|
|
88
|
+
SfProjectJson?: ConfigStub;
|
|
89
89
|
SfdxConfig?: ConfigStub;
|
|
90
90
|
};
|
|
91
91
|
/**
|
|
@@ -252,7 +252,7 @@ export declare const testSetup: (sinon?: any) => TestContext;
|
|
|
252
252
|
*
|
|
253
253
|
* **See** {@link shouldThrow}
|
|
254
254
|
*/
|
|
255
|
-
export declare const unexpectedResult:
|
|
255
|
+
export declare const unexpectedResult: SfError;
|
|
256
256
|
/**
|
|
257
257
|
* Use for this testing pattern:
|
|
258
258
|
* ```
|
|
@@ -302,7 +302,7 @@ export interface StreamingMockCometSubscriptionOptions {
|
|
|
302
302
|
/**
|
|
303
303
|
* If it's an error that states what that error should be.
|
|
304
304
|
*/
|
|
305
|
-
subscriptionErrbackError?:
|
|
305
|
+
subscriptionErrbackError?: SfError;
|
|
306
306
|
/**
|
|
307
307
|
* A list of messages to playback for the client. One message per process tick.
|
|
308
308
|
*/
|
package/lib/testSetup.js
CHANGED
|
@@ -21,8 +21,8 @@ const connection_1 = require("./org/connection");
|
|
|
21
21
|
const crypto_2 = require("./crypto/crypto");
|
|
22
22
|
const logger_1 = require("./logger");
|
|
23
23
|
const messages_1 = require("./messages");
|
|
24
|
-
const
|
|
25
|
-
const
|
|
24
|
+
const sfError_1 = require("./sfError");
|
|
25
|
+
const sfProject_1 = require("./sfProject");
|
|
26
26
|
const streamingClient_1 = require("./status/streamingClient");
|
|
27
27
|
const globalInfo_1 = require("./globalInfo");
|
|
28
28
|
const global_1 = require("./global");
|
|
@@ -126,12 +126,12 @@ const instantiateContext = (sinon) => {
|
|
|
126
126
|
inProject(inProject = true) {
|
|
127
127
|
testContext.SANDBOXES.PROJECT.restore();
|
|
128
128
|
if (inProject) {
|
|
129
|
-
testContext.SANDBOXES.PROJECT.stub(
|
|
130
|
-
testContext.SANDBOXES.PROJECT.stub(
|
|
129
|
+
testContext.SANDBOXES.PROJECT.stub(sfProject_1.SfProject, 'resolveProjectPath').callsFake(() => testContext.localPathRetriever(testContext.id));
|
|
130
|
+
testContext.SANDBOXES.PROJECT.stub(sfProject_1.SfProject, 'resolveProjectPathSync').callsFake(() => testContext.localPathRetrieverSync(testContext.id));
|
|
131
131
|
}
|
|
132
132
|
else {
|
|
133
|
-
testContext.SANDBOXES.PROJECT.stub(
|
|
134
|
-
testContext.SANDBOXES.PROJECT.stub(
|
|
133
|
+
testContext.SANDBOXES.PROJECT.stub(sfProject_1.SfProject, 'resolveProjectPath').rejects(new sfError_1.SfError('', 'InvalidProjectWorkspaceError'));
|
|
134
|
+
testContext.SANDBOXES.PROJECT.stub(sfProject_1.SfProject, 'resolveProjectPathSync').throws(new sfError_1.SfError('', 'InvalidProjectWorkspaceError'));
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
};
|
|
@@ -174,7 +174,7 @@ const stubContext = (testContext) => {
|
|
|
174
174
|
testContext.inProject(true);
|
|
175
175
|
testContext.SANDBOXES.CONFIG.stub(configFile_1.ConfigFile, 'resolveRootFolder').callsFake((isGlobal) => testContext.rootPathRetriever(isGlobal, testContext.id));
|
|
176
176
|
testContext.SANDBOXES.CONFIG.stub(configFile_1.ConfigFile, 'resolveRootFolderSync').callsFake((isGlobal) => testContext.rootPathRetrieverSync(isGlobal, testContext.id));
|
|
177
|
-
(0, ts_sinon_1.stubMethod)(testContext.SANDBOXES.PROJECT,
|
|
177
|
+
(0, ts_sinon_1.stubMethod)(testContext.SANDBOXES.PROJECT, sfProject_1.SfProjectJson.prototype, 'doesPackageExist').callsFake(() => true);
|
|
178
178
|
const initStubForRead = (configFile) => {
|
|
179
179
|
const stub = testContext.configStubs[configFile.constructor.name] || {};
|
|
180
180
|
// init calls read calls getPath which sets the path on the config file the first time.
|
|
@@ -324,7 +324,7 @@ exports.testSetup = (0, kit_1.once)(_testSetup);
|
|
|
324
324
|
*
|
|
325
325
|
* **See** {@link shouldThrow}
|
|
326
326
|
*/
|
|
327
|
-
exports.unexpectedResult = new
|
|
327
|
+
exports.unexpectedResult = new sfError_1.SfError('This code was expected to fail', 'UnexpectedResult');
|
|
328
328
|
/**
|
|
329
329
|
* Use for this testing pattern:
|
|
330
330
|
* ```
|
package/lib/util/fs.js
CHANGED
|
@@ -13,7 +13,7 @@ const util_1 = require("util");
|
|
|
13
13
|
const kit_1 = require("@salesforce/kit");
|
|
14
14
|
const fsLib = require("graceful-fs");
|
|
15
15
|
const mkdirpLib = require("mkdirp");
|
|
16
|
-
const
|
|
16
|
+
const sfError_1 = require("../sfError");
|
|
17
17
|
/**
|
|
18
18
|
* @deprecated Use fs/promises instead
|
|
19
19
|
*/
|
|
@@ -79,13 +79,13 @@ exports.fs = Object.assign({}, fsLib, {
|
|
|
79
79
|
*/
|
|
80
80
|
remove: async (dirPath) => {
|
|
81
81
|
if (!dirPath) {
|
|
82
|
-
throw new
|
|
82
|
+
throw new sfError_1.SfError('Path is null or undefined.', 'PathIsNullOrUndefined');
|
|
83
83
|
}
|
|
84
84
|
try {
|
|
85
85
|
await exports.fs.access(dirPath, fsLib.constants.R_OK);
|
|
86
86
|
}
|
|
87
87
|
catch (err) {
|
|
88
|
-
throw new
|
|
88
|
+
throw new sfError_1.SfError(`The path: ${dirPath} doesn't exist or access is denied.`, 'DirMissingOrNoAccess');
|
|
89
89
|
}
|
|
90
90
|
const files = await exports.fs.readdir(dirPath);
|
|
91
91
|
const stats = await Promise.all(files.map((file) => exports.fs.stat(path.join(dirPath, file))));
|
|
@@ -105,13 +105,13 @@ exports.fs = Object.assign({}, fsLib, {
|
|
|
105
105
|
*/
|
|
106
106
|
removeSync: (dirPath) => {
|
|
107
107
|
if (!dirPath) {
|
|
108
|
-
throw new
|
|
108
|
+
throw new sfError_1.SfError('Path is null or undefined.', 'PathIsNullOrUndefined');
|
|
109
109
|
}
|
|
110
110
|
try {
|
|
111
111
|
exports.fs.accessSync(dirPath, fsLib.constants.R_OK);
|
|
112
112
|
}
|
|
113
113
|
catch (err) {
|
|
114
|
-
throw new
|
|
114
|
+
throw new sfError_1.SfError(`The path: ${dirPath} doesn't exist or access is denied.`, 'DirMissingOrNoAccess');
|
|
115
115
|
}
|
|
116
116
|
exports.fs.actOnSync(dirPath, (fullPath, file) => {
|
|
117
117
|
if (file) {
|
|
@@ -340,7 +340,7 @@ exports.fs = Object.assign({}, fsLib, {
|
|
|
340
340
|
return exports.fs.getContentHash(contentA) === exports.fs.getContentHash(contentB);
|
|
341
341
|
}
|
|
342
342
|
catch (err) {
|
|
343
|
-
throw new
|
|
343
|
+
throw new sfError_1.SfError(`The path: ${err.path} doesn't exist or access is denied.`, 'DirMissingOrNoAccess');
|
|
344
344
|
}
|
|
345
345
|
},
|
|
346
346
|
/**
|
|
@@ -362,7 +362,7 @@ exports.fs = Object.assign({}, fsLib, {
|
|
|
362
362
|
return exports.fs.getContentHash(contentA) === exports.fs.getContentHash(contentB);
|
|
363
363
|
}
|
|
364
364
|
catch (err) {
|
|
365
|
-
throw new
|
|
365
|
+
throw new sfError_1.SfError(`The path: ${err.path} doesn't exist or access is denied.`, 'DirMissingOrNoAccess');
|
|
366
366
|
}
|
|
367
367
|
},
|
|
368
368
|
/**
|
package/lib/util/internal.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const SFDX_PROJECT_JSON = "sfdx-project.json";
|
|
|
11
11
|
*
|
|
12
12
|
* **See** {@link traverseForFile}
|
|
13
13
|
*
|
|
14
|
-
* **Throws** *{@link
|
|
14
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
15
15
|
*
|
|
16
16
|
* @param dir The directory path to start traversing from.
|
|
17
17
|
* @ignore
|
|
@@ -24,7 +24,7 @@ export declare function resolveProjectPath(dir?: string): Promise<string>;
|
|
|
24
24
|
*
|
|
25
25
|
* **See** {@link traverseForFile}
|
|
26
26
|
*
|
|
27
|
-
* **Throws** *{@link
|
|
27
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
28
28
|
*
|
|
29
29
|
* @param dir The directory path to start traversing from.
|
|
30
30
|
* @ignore
|
package/lib/util/internal.js
CHANGED
|
@@ -25,7 +25,7 @@ exports.SFDX_PROJECT_JSON = 'sfdx-project.json';
|
|
|
25
25
|
*
|
|
26
26
|
* **See** {@link traverseForFile}
|
|
27
27
|
*
|
|
28
|
-
* **Throws** *{@link
|
|
28
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
29
29
|
*
|
|
30
30
|
* @param dir The directory path to start traversing from.
|
|
31
31
|
* @ignore
|
|
@@ -45,7 +45,7 @@ exports.resolveProjectPath = resolveProjectPath;
|
|
|
45
45
|
*
|
|
46
46
|
* **See** {@link traverseForFile}
|
|
47
47
|
*
|
|
48
|
-
* **Throws** *{@link
|
|
48
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
49
49
|
*
|
|
50
50
|
* @param dir The directory path to start traversing from.
|
|
51
51
|
* @ignore
|
package/lib/util/sfdcUrl.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare class SfdcUrl extends URL {
|
|
|
43
43
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
44
44
|
*
|
|
45
45
|
* @returns {Promise<true | never>} The resolved ip address or never
|
|
46
|
-
* @throws {@link
|
|
46
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
47
47
|
*/
|
|
48
48
|
checkLightningDomain(): Promise<true | never>;
|
|
49
49
|
/**
|
|
@@ -51,7 +51,7 @@ export declare class SfdcUrl extends URL {
|
|
|
51
51
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
52
52
|
*
|
|
53
53
|
* @returns the resolved ip address.
|
|
54
|
-
* @throws {@link
|
|
54
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
55
55
|
*/
|
|
56
56
|
lookup(): Promise<string>;
|
|
57
57
|
/**
|
package/lib/util/sfdcUrl.js
CHANGED
|
@@ -121,7 +121,7 @@ class SfdcUrl extends url_1.URL {
|
|
|
121
121
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
122
122
|
*
|
|
123
123
|
* @returns {Promise<true | never>} The resolved ip address or never
|
|
124
|
-
* @throws {@link
|
|
124
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
125
125
|
*/
|
|
126
126
|
async checkLightningDomain() {
|
|
127
127
|
const quantity = (0, ts_types_1.ensureNumber)(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
|
@@ -142,7 +142,7 @@ class SfdcUrl extends url_1.URL {
|
|
|
142
142
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
143
143
|
*
|
|
144
144
|
* @returns the resolved ip address.
|
|
145
|
-
* @throws {@link
|
|
145
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
146
146
|
*/
|
|
147
147
|
async lookup() {
|
|
148
148
|
const quantity = (0, ts_types_1.ensureNumber)(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
package/lib/webOAuthServer.js
CHANGED
|
@@ -16,9 +16,9 @@ const ts_types_1 = require("@salesforce/ts-types");
|
|
|
16
16
|
const jsforce_1 = require("jsforce");
|
|
17
17
|
const logger_1 = require("./logger");
|
|
18
18
|
const authInfo_1 = require("./org/authInfo");
|
|
19
|
-
const
|
|
19
|
+
const sfError_1 = require("./sfError");
|
|
20
20
|
const messages_1 = require("./messages");
|
|
21
|
-
const
|
|
21
|
+
const sfProject_1 = require("./sfProject");
|
|
22
22
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
23
23
|
const messages = messages_1.Messages.load('@salesforce/core', 'auth', [
|
|
24
24
|
'invalidRequestUri',
|
|
@@ -56,8 +56,8 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
56
56
|
*/
|
|
57
57
|
static async determineOauthPort() {
|
|
58
58
|
try {
|
|
59
|
-
const
|
|
60
|
-
return
|
|
59
|
+
const sfProject = await sfProject_1.SfProjectJson.create();
|
|
60
|
+
return sfProject.get('oauthLocalPort') || WebOAuthServer.DEFAULT_PORT;
|
|
61
61
|
}
|
|
62
62
|
catch {
|
|
63
63
|
return WebOAuthServer.DEFAULT_PORT;
|
|
@@ -152,7 +152,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
152
152
|
if (url.pathname && url.pathname.startsWith('/OauthRedirect')) {
|
|
153
153
|
request.query = (0, querystring_1.parse)(url.query);
|
|
154
154
|
if (request.query.error) {
|
|
155
|
-
const err = new
|
|
155
|
+
const err = new sfError_1.SfError(request.query.error_description || request.query.error, request.query.error);
|
|
156
156
|
this.webServer.reportError(err, response);
|
|
157
157
|
return reject(err);
|
|
158
158
|
}
|
|
@@ -169,14 +169,14 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
169
169
|
this.webServer.sendError(404, 'Resource not found', response);
|
|
170
170
|
const errName = 'invalidRequestUri';
|
|
171
171
|
const errMessage = messages.getMessage(errName, [url.pathname]);
|
|
172
|
-
reject(new
|
|
172
|
+
reject(new sfError_1.SfError(errMessage, errName));
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
else {
|
|
176
176
|
this.webServer.sendError(405, 'Unsupported http methods', response);
|
|
177
177
|
const errName = 'invalidRequestMethod';
|
|
178
178
|
const errMessage = messages.getMessage(errName, [request.method]);
|
|
179
|
-
reject(new
|
|
179
|
+
reject(new sfError_1.SfError(errMessage, errName));
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
});
|
|
@@ -190,7 +190,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
190
190
|
*/
|
|
191
191
|
parseAuthCodeFromRequest(response, request) {
|
|
192
192
|
if (!this.validateState(request)) {
|
|
193
|
-
const error = new
|
|
193
|
+
const error = new sfError_1.SfError('urlStateMismatch');
|
|
194
194
|
this.webServer.sendError(400, `${error.message}\n`, response);
|
|
195
195
|
this.closeRequest(request);
|
|
196
196
|
this.logger.warn('urlStateMismatchAttempt detected.');
|
|
@@ -343,13 +343,13 @@ class WebServer extends kit_1.AsyncCreatable {
|
|
|
343
343
|
const socket = new net_1.Socket();
|
|
344
344
|
socket.setTimeout(this.getSocketTimeout(), () => {
|
|
345
345
|
socket.destroy();
|
|
346
|
-
const error = new
|
|
346
|
+
const error = new sfError_1.SfError('timeout', 'SOCKET_TIMEOUT');
|
|
347
347
|
reject(error);
|
|
348
348
|
});
|
|
349
349
|
// An existing connection, means that the port is occupied
|
|
350
350
|
socket.connect(clientConfig, () => {
|
|
351
351
|
socket.destroy();
|
|
352
|
-
const error = new
|
|
352
|
+
const error = new sfError_1.SfError('Address in use', 'EADDRINUSE');
|
|
353
353
|
error.data = {
|
|
354
354
|
port: clientConfig.port,
|
|
355
355
|
address: clientConfig.host,
|