@api-client/core 0.6.30 → 0.7.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/build/browser.d.ts +6 -14
- package/build/browser.js +11 -16
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +8 -20
- package/build/index.js +13 -25
- package/build/index.js.map +1 -1
- package/build/src/amf/ApiSchemaValues.d.ts +2 -0
- package/build/src/amf/ApiSchemaValues.js +29 -23
- package/build/src/amf/ApiSchemaValues.js.map +1 -1
- package/build/src/authorization/lib/Utils.d.ts +1 -1
- package/build/src/cookies/CookieJar.d.ts +23 -0
- package/build/src/cookies/CookieJar.js +3 -0
- package/build/src/cookies/CookieJar.js.map +1 -0
- package/build/src/cookies/CookieParser.d.ts +67 -0
- package/build/src/cookies/CookieParser.js +316 -0
- package/build/src/cookies/CookieParser.js.map +1 -0
- package/build/src/cookies/InMemoryCookieJar.d.ts +12 -0
- package/build/src/cookies/InMemoryCookieJar.js +68 -0
- package/build/src/cookies/InMemoryCookieJar.js.map +1 -0
- package/build/src/cookies/Punycode.d.ts +12 -0
- package/build/src/cookies/Punycode.js +124 -0
- package/build/src/cookies/Punycode.js.map +1 -0
- package/build/src/data/RequestDataExtractor.d.ts +8 -7
- package/build/src/data/RequestDataExtractor.js +8 -10
- package/build/src/data/RequestDataExtractor.js.map +1 -1
- package/build/src/events/CustomEvent.js +5 -0
- package/build/src/events/CustomEvent.js.map +1 -1
- package/build/src/events/EventTypes.d.ts +43 -43
- package/build/src/events/amf/AmfEventTypes.d.ts +4 -4
- package/build/src/events/authorization/AuthorizationEventTypes.d.ts +4 -4
- package/build/src/events/cookies/CookieEventTypes.d.ts +9 -9
- package/build/src/events/encryption/EncryptionEventTypes.d.ts +2 -2
- package/build/src/events/environment/EnvironmentEventTypes.d.ts +1 -1
- package/build/src/events/models/ModelEventTypes.d.ts +7 -7
- package/build/src/events/process/ProcessEventTypes.d.ts +3 -3
- package/build/src/events/reporting/ReportingEventTypes.d.ts +1 -1
- package/build/src/events/telemetry/TelemetryEventTypes.d.ts +6 -6
- package/build/src/events/transport/TransportEventTypes.d.ts +6 -6
- package/build/src/events/transport/TransportEvents.d.ts +2 -2
- package/build/src/mocking/ProjectMock.d.ts +3 -2
- package/build/src/mocking/ProjectMock.js +3 -3
- package/build/src/mocking/ProjectMock.js.map +1 -1
- package/build/src/mocking/lib/App.d.ts +36 -0
- package/build/src/mocking/lib/App.js +70 -0
- package/build/src/mocking/lib/App.js.map +1 -0
- package/build/src/models/{arc/ArcProject.d.ts → AppProject.d.ts} +296 -134
- package/build/src/models/{arc/ArcProject.js → AppProject.js} +436 -79
- package/build/src/models/AppProject.js.map +1 -0
- package/build/src/models/AppRequest.d.ts +69 -0
- package/build/src/models/{arc/ArcHttpRequest.js → AppRequest.js} +53 -17
- package/build/src/models/AppRequest.js.map +1 -0
- package/build/src/models/ClientCertificate.d.ts +2 -2
- package/build/src/models/Environment.d.ts +8 -1
- package/build/src/models/Environment.js +21 -0
- package/build/src/models/Environment.js.map +1 -1
- package/build/src/models/HostRule.d.ts +2 -2
- package/build/src/models/HttpCookie.d.ts +63 -12
- package/build/src/models/HttpCookie.js +178 -44
- package/build/src/models/HttpCookie.js.map +1 -1
- package/build/src/models/HttpHistory.d.ts +8 -3
- package/build/src/models/HttpHistory.js +3 -3
- package/build/src/models/HttpHistory.js.map +1 -1
- package/build/src/models/HttpProject.d.ts +34 -1
- package/build/src/models/HttpProject.js +104 -8
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/ProjectFolder.d.ts +2 -0
- package/build/src/models/ProjectFolder.js +14 -0
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/ProjectItem.d.ts +2 -0
- package/build/src/models/ProjectItem.js +20 -0
- package/build/src/models/ProjectItem.js.map +1 -1
- package/build/src/models/ProjectParent.js.map +1 -1
- package/build/src/models/ProjectRequest.d.ts +3 -2
- package/build/src/models/ProjectRequest.js.map +1 -1
- package/build/src/models/Property.d.ts +2 -2
- package/build/src/models/Property.js +2 -2
- package/build/src/models/Property.js.map +1 -1
- package/build/src/models/Request.d.ts +16 -8
- package/build/src/models/Request.js +20 -15
- package/build/src/models/Request.js.map +1 -1
- package/build/src/models/RequestAuthorization.js.map +1 -1
- package/build/src/models/RequestUiMeta.d.ts +0 -14
- package/build/src/models/RequestUiMeta.js +1 -10
- package/build/src/models/RequestUiMeta.js.map +1 -1
- package/build/src/models/Server.d.ts +1 -2
- package/build/src/models/Server.js.map +1 -1
- package/build/src/models/http-actions/HttpActions.d.ts +256 -0
- package/build/src/models/http-actions/HttpActions.js +46 -0
- package/build/src/models/http-actions/HttpActions.js.map +1 -0
- package/build/src/models/http-actions/LegacyTranslator.d.ts +17 -0
- package/build/src/models/http-actions/LegacyTranslator.js +222 -0
- package/build/src/models/http-actions/LegacyTranslator.js.map +1 -0
- package/build/src/models/store/Backend.d.ts +136 -1
- package/build/src/models/store/File.d.ts +1 -1
- package/build/src/models/store/File.js +2 -0
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/User.d.ts +3 -3
- package/build/src/runtime/http-engine/CoreEngine.d.ts +2 -0
- package/build/src/runtime/http-engine/CoreEngine.js +1 -0
- package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
- package/build/src/runtime/http-engine/HttpEngine.d.ts +13 -0
- package/build/src/runtime/http-engine/HttpEngine.js +39 -31
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/build/src/runtime/{actions/ConditionRunner.d.ts → http-runner/ConditionCheck.d.ts} +2 -2
- package/build/src/runtime/{actions/ConditionRunner.js → http-runner/ConditionCheck.js} +2 -2
- package/build/src/runtime/http-runner/ConditionCheck.js.map +1 -0
- package/build/src/runtime/http-runner/HttpFlowRunner.d.ts +62 -0
- package/build/src/runtime/http-runner/HttpFlowRunner.js +217 -0
- package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -0
- package/build/src/runtime/{node/RequestFactory.d.ts → http-runner/HttpRequestRunner.d.ts} +40 -54
- package/build/src/runtime/http-runner/HttpRequestRunner.js +316 -0
- package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -0
- package/build/src/runtime/http-runner/HttpRuntimeEnvironment.d.ts +25 -0
- package/build/src/runtime/http-runner/HttpRuntimeEnvironment.js +2 -0
- package/build/src/runtime/http-runner/HttpRuntimeEnvironment.js.map +1 -0
- package/build/src/runtime/http-runner/RequestAuthorizationProcessor.d.ts +56 -0
- package/build/src/runtime/http-runner/RequestAuthorizationProcessor.js +143 -0
- package/build/src/runtime/http-runner/RequestAuthorizationProcessor.js.map +1 -0
- package/build/src/runtime/http-runner/RequestCookiesProcessor.d.ts +24 -0
- package/build/src/runtime/http-runner/RequestCookiesProcessor.js +65 -0
- package/build/src/runtime/http-runner/RequestCookiesProcessor.js.map +1 -0
- package/build/src/runtime/node/InteropInterfaces.d.ts +21 -6
- package/build/src/runtime/node/ProjectParallelRunner.js +3 -1
- package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.d.ts +24 -10
- package/build/src/runtime/node/ProjectRequestRunner.js +116 -45
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.d.ts +5 -7
- package/build/src/runtime/node/ProjectRunner.js +30 -14
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunnerWorker.js +3 -0
- package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
- package/build/src/runtime/reporters/Reporter.d.ts +5 -0
- package/build/src/runtime/reporters/Reporter.js.map +1 -1
- package/build/src/runtime/store/AppSdk.d.ts +185 -0
- package/build/src/runtime/store/AppSdk.js +704 -0
- package/build/src/runtime/store/AppSdk.js.map +1 -0
- package/build/src/runtime/store/FilesSdk.js +4 -4
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/build/src/runtime/store/HistorySdk.js +2 -2
- package/build/src/runtime/store/HistorySdk.js.map +1 -1
- package/build/src/runtime/store/RouteBuilder.d.ts +17 -2
- package/build/src/runtime/store/RouteBuilder.js +60 -3
- package/build/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/src/runtime/store/Sdk.d.ts +5 -0
- package/build/src/runtime/store/Sdk.js +5 -0
- package/build/src/runtime/store/Sdk.js.map +1 -1
- package/build/src/runtime/store/SharedSdk.js +1 -1
- package/build/src/runtime/store/SharedSdk.js.map +1 -1
- package/build/src/runtime/store/UsersSdk.js +1 -1
- package/build/src/runtime/store/UsersSdk.js.map +1 -1
- package/package.json +2 -2
- package/src/amf/ApiSchemaValues.ts +41 -33
- package/src/cookies/CookieJar.ts +26 -0
- package/src/cookies/CookieParser.ts +327 -0
- package/src/cookies/InMemoryCookieJar.ts +70 -0
- package/src/cookies/Punycode.ts +133 -0
- package/src/data/RequestDataExtractor.ts +14 -15
- package/src/events/CustomEvent.ts +4 -0
- package/src/mocking/ProjectMock.ts +4 -3
- package/src/mocking/lib/App.ts +101 -0
- package/src/models/{arc/ArcProject.ts → AppProject.ts} +671 -225
- package/src/models/AppRequest.ts +176 -0
- package/src/models/ClientCertificate.ts +2 -2
- package/src/models/Environment.ts +24 -2
- package/src/models/HostRule.ts +2 -2
- package/src/models/HttpCookie.ts +210 -48
- package/src/models/HttpHistory.ts +12 -5
- package/src/models/HttpProject.ts +113 -10
- package/src/models/ProjectFolder.ts +16 -0
- package/src/models/ProjectItem.ts +18 -0
- package/src/models/ProjectParent.ts +4 -1
- package/src/models/ProjectRequest.ts +4 -3
- package/src/models/Property.ts +4 -4
- package/src/models/Request.ts +29 -19
- package/src/models/RequestAuthorization.ts +4 -4
- package/src/models/RequestUiMeta.ts +1 -21
- package/src/models/Server.ts +1 -2
- package/src/models/http-actions/HttpActions.ts +270 -0
- package/src/models/http-actions/LegacyTranslator.ts +223 -0
- package/src/models/store/Backend.ts +148 -2
- package/src/models/store/File.ts +3 -1
- package/src/models/store/User.ts +3 -3
- package/src/runtime/http-engine/CoreEngine.ts +3 -2
- package/src/runtime/http-engine/HttpEngine.ts +48 -30
- package/src/runtime/{actions/ConditionRunner.ts → http-runner/ConditionCheck.ts} +3 -3
- package/src/runtime/http-runner/HttpFlowRunner.ts +232 -0
- package/src/runtime/http-runner/HttpRequestRunner.ts +353 -0
- package/src/runtime/http-runner/HttpRuntimeEnvironment.ts +27 -0
- package/src/runtime/http-runner/RequestAuthorizationProcessor.ts +144 -0
- package/src/runtime/http-runner/RequestCookiesProcessor.ts +74 -0
- package/src/runtime/node/InteropInterfaces.ts +24 -6
- package/src/runtime/node/ProjectParallelRunner.ts +4 -2
- package/src/runtime/node/ProjectRequestRunner.ts +130 -60
- package/src/runtime/node/ProjectRunner.ts +37 -22
- package/src/runtime/node/ProjectRunnerWorker.ts +3 -0
- package/src/runtime/reporters/Reporter.ts +5 -0
- package/src/runtime/store/AppSdk.ts +709 -0
- package/src/runtime/store/FilesSdk.ts +4 -4
- package/src/runtime/store/HistorySdk.ts +2 -2
- package/src/runtime/store/RouteBuilder.ts +75 -3
- package/src/runtime/store/Sdk.ts +6 -0
- package/src/runtime/store/SharedSdk.ts +1 -1
- package/src/runtime/store/UsersSdk.ts +1 -1
- package/build/src/lib/cookies/Cookie.d.ts +0 -123
- package/build/src/lib/cookies/Cookie.js +0 -257
- package/build/src/lib/cookies/Cookie.js.map +0 -1
- package/build/src/lib/cookies/Cookies.d.ts +0 -90
- package/build/src/lib/cookies/Cookies.js +0 -310
- package/build/src/lib/cookies/Cookies.js.map +0 -1
- package/build/src/lib/cookies/Utils.d.ts +0 -47
- package/build/src/lib/cookies/Utils.js +0 -163
- package/build/src/lib/cookies/Utils.js.map +0 -1
- package/build/src/mocking/lib/Arc.d.ts +0 -10
- package/build/src/mocking/lib/Arc.js +0 -31
- package/build/src/mocking/lib/Arc.js.map +0 -1
- package/build/src/models/RequestActions.d.ts +0 -65
- package/build/src/models/RequestActions.js +0 -114
- package/build/src/models/RequestActions.js.map +0 -1
- package/build/src/models/actions/Action.d.ts +0 -75
- package/build/src/models/actions/Action.js +0 -188
- package/build/src/models/actions/Action.js.map +0 -1
- package/build/src/models/actions/ActionView.d.ts +0 -15
- package/build/src/models/actions/ActionView.js +0 -33
- package/build/src/models/actions/ActionView.js.map +0 -1
- package/build/src/models/actions/Condition.d.ts +0 -81
- package/build/src/models/actions/Condition.js +0 -185
- package/build/src/models/actions/Condition.js.map +0 -1
- package/build/src/models/actions/ConditionView.d.ts +0 -17
- package/build/src/models/actions/ConditionView.js +0 -34
- package/build/src/models/actions/ConditionView.js.map +0 -1
- package/build/src/models/actions/Enums.d.ts +0 -26
- package/build/src/models/actions/Enums.js +0 -31
- package/build/src/models/actions/Enums.js.map +0 -1
- package/build/src/models/actions/RunnableAction.d.ts +0 -59
- package/build/src/models/actions/RunnableAction.js +0 -106
- package/build/src/models/actions/RunnableAction.js.map +0 -1
- package/build/src/models/actions/runnable/DeleteCookieAction.d.ts +0 -44
- package/build/src/models/actions/runnable/DeleteCookieAction.js +0 -92
- package/build/src/models/actions/runnable/DeleteCookieAction.js.map +0 -1
- package/build/src/models/actions/runnable/Runnable.d.ts +0 -8
- package/build/src/models/actions/runnable/Runnable.js +0 -4
- package/build/src/models/actions/runnable/Runnable.js.map +0 -1
- package/build/src/models/actions/runnable/SetCookieAction.d.ts +0 -87
- package/build/src/models/actions/runnable/SetCookieAction.js +0 -176
- package/build/src/models/actions/runnable/SetCookieAction.js.map +0 -1
- package/build/src/models/actions/runnable/SetVariableAction.d.ts +0 -31
- package/build/src/models/actions/runnable/SetVariableAction.js +0 -63
- package/build/src/models/actions/runnable/SetVariableAction.js.map +0 -1
- package/build/src/models/actions/runnable/index.d.ts +0 -7
- package/build/src/models/actions/runnable/index.js +0 -2
- package/build/src/models/actions/runnable/index.js.map +0 -1
- package/build/src/models/arc/ArcHttpRequest.d.ts +0 -40
- package/build/src/models/arc/ArcHttpRequest.js.map +0 -1
- package/build/src/models/arc/ArcProject.js.map +0 -1
- package/build/src/runtime/actions/ActionRunner.d.ts +0 -17
- package/build/src/runtime/actions/ActionRunner.js +0 -74
- package/build/src/runtime/actions/ActionRunner.js.map +0 -1
- package/build/src/runtime/actions/ConditionRunner.js.map +0 -1
- package/build/src/runtime/actions/RunnableCondition.d.ts +0 -27
- package/build/src/runtime/actions/RunnableCondition.js +0 -50
- package/build/src/runtime/actions/RunnableCondition.js.map +0 -1
- package/build/src/runtime/actions/runnable/ActionRunnable.d.ts +0 -13
- package/build/src/runtime/actions/runnable/ActionRunnable.js +0 -13
- package/build/src/runtime/actions/runnable/ActionRunnable.js.map +0 -1
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.d.ts +0 -7
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js +0 -36
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js.map +0 -1
- package/build/src/runtime/actions/runnable/SetCookieRunnable.d.ts +0 -10
- package/build/src/runtime/actions/runnable/SetCookieRunnable.js +0 -89
- package/build/src/runtime/actions/runnable/SetCookieRunnable.js.map +0 -1
- package/build/src/runtime/actions/runnable/SetVariableRunnable.d.ts +0 -10
- package/build/src/runtime/actions/runnable/SetVariableRunnable.js +0 -49
- package/build/src/runtime/actions/runnable/SetVariableRunnable.js.map +0 -1
- package/build/src/runtime/modules/BasicAuthCache.d.ts +0 -39
- package/build/src/runtime/modules/BasicAuthCache.js +0 -122
- package/build/src/runtime/modules/BasicAuthCache.js.map +0 -1
- package/build/src/runtime/modules/ExecutionResponse.d.ts +0 -4
- package/build/src/runtime/modules/ExecutionResponse.js +0 -6
- package/build/src/runtime/modules/ExecutionResponse.js.map +0 -1
- package/build/src/runtime/modules/ModulesRegistry.d.ts +0 -93
- package/build/src/runtime/modules/ModulesRegistry.js +0 -69
- package/build/src/runtime/modules/ModulesRegistry.js.map +0 -1
- package/build/src/runtime/modules/RequestAuthorization.d.ts +0 -6
- package/build/src/runtime/modules/RequestAuthorization.js +0 -110
- package/build/src/runtime/modules/RequestAuthorization.js.map +0 -1
- package/build/src/runtime/modules/RequestCookies.d.ts +0 -17
- package/build/src/runtime/modules/RequestCookies.js +0 -134
- package/build/src/runtime/modules/RequestCookies.js.map +0 -1
- package/build/src/runtime/node/RequestFactory.js +0 -406
- package/build/src/runtime/node/RequestFactory.js.map +0 -1
- package/build/src/runtime/node/VariablesStore.d.ts +0 -9
- package/build/src/runtime/node/VariablesStore.js +0 -19
- package/build/src/runtime/node/VariablesStore.js.map +0 -1
- package/src/lib/cookies/Cookie.ts +0 -312
- package/src/lib/cookies/Cookies.ts +0 -326
- package/src/lib/cookies/Utils.ts +0 -168
- package/src/mocking/lib/Arc.ts +0 -34
- package/src/models/RequestActions.ts +0 -161
- package/src/models/actions/Action.ts +0 -213
- package/src/models/actions/ActionView.ts +0 -40
- package/src/models/actions/Condition.ts +0 -207
- package/src/models/actions/ConditionView.ts +0 -42
- package/src/models/actions/Enums.ts +0 -29
- package/src/models/actions/RunnableAction.ts +0 -144
- package/src/models/actions/runnable/DeleteCookieAction.ts +0 -113
- package/src/models/actions/runnable/Runnable.ts +0 -9
- package/src/models/actions/runnable/SetCookieAction.ts +0 -216
- package/src/models/actions/runnable/SetVariableAction.ts +0 -81
- package/src/models/arc/ArcHttpRequest.ts +0 -129
- package/src/models/arc/readme.md +0 -3
- package/src/runtime/actions/ActionRunner.ts +0 -83
- package/src/runtime/actions/RunnableCondition.ts +0 -56
- package/src/runtime/actions/runnable/ActionRunnable.ts +0 -19
- package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +0 -39
- package/src/runtime/actions/runnable/SetCookieRunnable.ts +0 -92
- package/src/runtime/actions/runnable/SetVariableRunnable.ts +0 -53
- package/src/runtime/modules/BasicAuthCache.ts +0 -129
- package/src/runtime/modules/ExecutionResponse.ts +0 -4
- package/src/runtime/modules/ModulesRegistry.ts +0 -136
- package/src/runtime/modules/RequestAuthorization.ts +0 -106
- package/src/runtime/modules/RequestCookies.ts +0 -146
- package/src/runtime/node/RequestFactory.ts +0 -432
- package/src/runtime/node/VariablesStore.ts +0 -25
|
@@ -762,7 +762,7 @@ export class CoreEngine extends HttpEngine {
|
|
|
762
762
|
if (buffer) {
|
|
763
763
|
raw = buffer.toString();
|
|
764
764
|
}
|
|
765
|
-
this.currentResponse
|
|
765
|
+
(this.currentResponse as Response).headers = raw;
|
|
766
766
|
this.logger.info('Received headers list', raw);
|
|
767
767
|
const headers = new Headers(raw);
|
|
768
768
|
this.currentHeaders = headers;
|
|
@@ -974,13 +974,14 @@ export class CoreEngine extends HttpEngine {
|
|
|
974
974
|
};
|
|
975
975
|
if (proxyIsSsl) {
|
|
976
976
|
connectOptions.rejectUnauthorized = false;
|
|
977
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
977
978
|
// @ts-ignore
|
|
978
979
|
connectOptions.requestOCSP = false;
|
|
979
980
|
}
|
|
980
981
|
const auth = this._proxyAuthHeader();
|
|
981
982
|
if (auth) {
|
|
982
983
|
this.logger.debug(`Adding proxy authorization.`);
|
|
983
|
-
connectOptions.headers
|
|
984
|
+
(connectOptions.headers as http.OutgoingHttpHeaders)['proxy-authorization'] = auth;
|
|
984
985
|
}
|
|
985
986
|
const lib = proxyIsSsl ? https : http;
|
|
986
987
|
return new Promise((resolve, reject) => {
|
|
@@ -25,9 +25,18 @@ import { DefaultLogger } from '../../lib/logging/DefaultLogger.js';
|
|
|
25
25
|
import { ILogger, Logger } from '../../lib/logging/Logger.js';
|
|
26
26
|
import { Headers } from '../../lib/headers/Headers.js';
|
|
27
27
|
import * as RequestUtils from './RequestUtils.js';
|
|
28
|
-
import { Cookies } from '../../lib/cookies/Cookies.js';
|
|
28
|
+
// import { Cookies } from '../../lib/cookies/Cookies.js';
|
|
29
29
|
import { HttpErrorCodes } from './HttpErrorCodes.js';
|
|
30
|
+
import { CookieParser } from '../../cookies/CookieParser.js';
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* A note on cookies and redirects.
|
|
34
|
+
* The architecture here assumes running requests is a test environment.
|
|
35
|
+
* This means cookies are not processed by this class. This includes processing cookies during a redirect.
|
|
36
|
+
* The class does parse response cookies before a redirect and sets new cookies in the redirected request only
|
|
37
|
+
* if they match the domain + path. However, this class doesn't know anything about other cookies
|
|
38
|
+
* that the application may have for the domain after redirection.
|
|
39
|
+
*/
|
|
31
40
|
export interface HttpEngineOptions extends IRequestBaseConfig {
|
|
32
41
|
/**
|
|
33
42
|
* The authorization configuration to apply to the request.
|
|
@@ -473,11 +482,8 @@ export abstract class HttpEngine extends EventEmitter {
|
|
|
473
482
|
this._publishResponse();
|
|
474
483
|
return;
|
|
475
484
|
}
|
|
476
|
-
let responseCookies;
|
|
477
|
-
if (this.currentHeaders.has('set-cookie')) {
|
|
478
|
-
responseCookies = this.currentHeaders.get('set-cookie');
|
|
479
|
-
}
|
|
480
485
|
try {
|
|
486
|
+
const responseCookies = this.currentHeaders.get('set-cookie');
|
|
481
487
|
const response = await this._createRedirectResponse(location);
|
|
482
488
|
this.redirects.push(response);
|
|
483
489
|
this._cleanUpRedirect();
|
|
@@ -712,35 +718,47 @@ Check your request parameters.`);
|
|
|
712
718
|
* @param location Redirect destination
|
|
713
719
|
*/
|
|
714
720
|
_processRedirectCookies(responseCookies: string, location: string): void {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
const expired = newParser.clearExpired();
|
|
721
|
+
const received = CookieParser.parse(this.request.url, responseCookies);
|
|
722
|
+
const forwardCookies = CookieParser.filterCookies(received, location);
|
|
718
723
|
const headers = new Headers(this.request.headers);
|
|
719
|
-
|
|
720
|
-
if (
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
oldParser.clearExpired();
|
|
725
|
-
oldParser.merge(newParser);
|
|
726
|
-
newParser = oldParser;
|
|
727
|
-
// remove expired from the new response.
|
|
728
|
-
newParser.cookies = newParser.cookies.filter((c) => {
|
|
729
|
-
for (let i = 0, len = expired.length; i < len; i++) {
|
|
730
|
-
if (expired[i].name === c.name) {
|
|
731
|
-
return false;
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
return true;
|
|
724
|
+
headers.delete('cookie');
|
|
725
|
+
if (forwardCookies.length) {
|
|
726
|
+
const parts: string[] = [];
|
|
727
|
+
forwardCookies.forEach((cookie) => {
|
|
728
|
+
parts.push(cookie.toString());
|
|
735
729
|
});
|
|
736
|
-
|
|
737
|
-
const str = newParser.toString(true);
|
|
738
|
-
if (str) {
|
|
739
|
-
headers.set('cookie', str);
|
|
740
|
-
} else if (hasCookie) {
|
|
741
|
-
headers.delete('cookie');
|
|
730
|
+
headers.set('cookie', parts.join('; '));
|
|
742
731
|
}
|
|
743
732
|
this.request.headers = headers.toString();
|
|
733
|
+
|
|
734
|
+
// let newParser = new Cookies(responseCookies, location);
|
|
735
|
+
// newParser.filter();
|
|
736
|
+
// const expired = newParser.clearExpired();
|
|
737
|
+
// const hasCookie = headers.has('cookie');
|
|
738
|
+
// if (hasCookie) {
|
|
739
|
+
// const oldCookies = headers.get('cookie');
|
|
740
|
+
// const oldParser = new Cookies(oldCookies, location);
|
|
741
|
+
// oldParser.filter();
|
|
742
|
+
// oldParser.clearExpired();
|
|
743
|
+
// oldParser.merge(newParser);
|
|
744
|
+
// newParser = oldParser;
|
|
745
|
+
// // remove expired from the new response.
|
|
746
|
+
// newParser.cookies = newParser.cookies.filter((c) => {
|
|
747
|
+
// for (let i = 0, len = expired.length; i < len; i++) {
|
|
748
|
+
// if (expired[i].name === c.name) {
|
|
749
|
+
// return false;
|
|
750
|
+
// }
|
|
751
|
+
// }
|
|
752
|
+
// return true;
|
|
753
|
+
// });
|
|
754
|
+
// }
|
|
755
|
+
// const str = newParser.toString(true);
|
|
756
|
+
// if (str) {
|
|
757
|
+
// headers.set('cookie', str);
|
|
758
|
+
// } else if (hasCookie) {
|
|
759
|
+
// headers.delete('cookie');
|
|
760
|
+
// }
|
|
761
|
+
// this.request.headers = headers.toString();
|
|
744
762
|
}
|
|
745
763
|
|
|
746
764
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {
|
|
2
|
+
import { ActionOperatorEnum } from '../../models/http-actions/HttpActions.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Checks if values equal.
|
|
@@ -8,7 +8,7 @@ import { OperatorEnum } from '../../models/actions/Enums.js';
|
|
|
8
8
|
* @returns True if objects matches.
|
|
9
9
|
*/
|
|
10
10
|
export function isEqual(value: any, condition: any): boolean {
|
|
11
|
-
if (value === condition) {
|
|
11
|
+
if (value === condition || String(value) === String(condition)) {
|
|
12
12
|
return true;
|
|
13
13
|
}
|
|
14
14
|
let valueTyped = value;
|
|
@@ -170,7 +170,7 @@ export function isRegex(value: any, condition: any): boolean {
|
|
|
170
170
|
* @param condition Value to compare.
|
|
171
171
|
* @returns True if the condition is satisfied and false otherwise.
|
|
172
172
|
*/
|
|
173
|
-
export function checkCondition(value: any, operator:
|
|
173
|
+
export function checkCondition(value: any, operator: ActionOperatorEnum, condition: string | undefined): boolean {
|
|
174
174
|
switch (operator) {
|
|
175
175
|
case 'equal':
|
|
176
176
|
return isEqual(value, condition);
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { CookieJar } from "../../cookies/CookieJar.js";
|
|
2
|
+
import { IHttpRequest } from "../../models/HttpRequest.js";
|
|
3
|
+
import { ISentRequest } from "../../models/SentRequest.js";
|
|
4
|
+
import { IResponse } from "../../models/Response.js";
|
|
5
|
+
import { IErrorResponse } from "../../models/ErrorResponse.js";
|
|
6
|
+
import { HttpCookie } from "../../models/HttpCookie.js";
|
|
7
|
+
import { ActionSourceEnum, DeleteCookieStepKind, IActionStep, IDeleteCookieStep, IHttpAction, IHttpActionFlow, IHttpCondition, IReadDataStep, ISetCookieStep, ISetDataStep, ISetVariableStep, ReadDataStepKind, SetCookieStepKind, SetDataStepKind, SetVariableStepKind } from '../../models/http-actions/HttpActions.js';
|
|
8
|
+
import { RequestDataExtractor } from "../../data/RequestDataExtractor.js";
|
|
9
|
+
import { checkCondition } from "./ConditionCheck.js";
|
|
10
|
+
import { ApiSchemaValues } from "../../amf/ApiSchemaValues.js";
|
|
11
|
+
import { SameSiteValue } from "../../cookies/CookieParser.js";
|
|
12
|
+
|
|
13
|
+
type FlowValue = string | number | boolean | null | undefined;
|
|
14
|
+
|
|
15
|
+
export class HttpFlowRunner {
|
|
16
|
+
/**
|
|
17
|
+
* The cumulative list of all variables to be applied to the request and other properties.
|
|
18
|
+
* The variables must be already processed for variables in values (evaluated).
|
|
19
|
+
*
|
|
20
|
+
* These variables are passed by reference. Changes made anywhere to the variables will result
|
|
21
|
+
* with updating this list.
|
|
22
|
+
*/
|
|
23
|
+
variables?: Record<string, string>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An instance of a cookie jar (store) to put/read cookies.
|
|
27
|
+
*/
|
|
28
|
+
cookies?: CookieJar;
|
|
29
|
+
|
|
30
|
+
async request(request: IHttpRequest, flows?: IHttpActionFlow[]): Promise<void> {
|
|
31
|
+
if (!flows || !flows.length) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
for (const flow of flows) {
|
|
35
|
+
for (const action of flow.actions) {
|
|
36
|
+
await this._runAction(action, request);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async response(request: IHttpRequest | ISentRequest, response: IResponse | IErrorResponse, flows?: IHttpActionFlow[]): Promise<void> {
|
|
42
|
+
if (!flows || !flows.length) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const flow of flows) {
|
|
46
|
+
for (const action of flow.actions) {
|
|
47
|
+
await this._runAction(action, request, response);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async _runAction(action: IHttpAction, request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<void> {
|
|
53
|
+
const { steps, condition } = action;
|
|
54
|
+
if (!Array.isArray(steps) || !steps.length) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (condition) {
|
|
58
|
+
const meet = await this._satisfied(condition, request, response);
|
|
59
|
+
if (!meet) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// this keeps a value from the last step to be passed to the next step.
|
|
65
|
+
let lastResult: FlowValue;
|
|
66
|
+
for (const step of steps) {
|
|
67
|
+
lastResult = await this._runStep(step, lastResult, request, response);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async _satisfied(condition: IHttpCondition, request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<boolean> {
|
|
72
|
+
const { source, data, path, operator, value } = condition;
|
|
73
|
+
if (!source || !operator) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const extractor = new RequestDataExtractor(request, response);
|
|
77
|
+
const readValue = await extractor.extract(source, data, path);
|
|
78
|
+
return checkCondition(readValue, operator, value);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async _runStep(step: IActionStep, input: FlowValue, request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<FlowValue> {
|
|
82
|
+
switch (step.kind) {
|
|
83
|
+
case ReadDataStepKind: return this._runReadDataStep(step as IReadDataStep, request, response);
|
|
84
|
+
case SetDataStepKind: return this._runSetDataStep(step as ISetDataStep);
|
|
85
|
+
case SetVariableStepKind: return this._runSetVariableStep(step as ISetVariableStep, input);
|
|
86
|
+
case SetCookieStepKind: return this._runSetCookieStep(step as ISetCookieStep, input, request);
|
|
87
|
+
case DeleteCookieStepKind: return this._runDeleteCookieStep(step as IDeleteCookieStep, request);
|
|
88
|
+
default: return undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A step that reads data from the request, response, or variables.
|
|
94
|
+
*
|
|
95
|
+
* @param step The step configuration.
|
|
96
|
+
* @param request The HttpRequest or the SentRequest (for responses)
|
|
97
|
+
* @param response When available, the response data
|
|
98
|
+
* @returns The read value or undefined.
|
|
99
|
+
*/
|
|
100
|
+
async _runReadDataStep(step: IReadDataStep, request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<string | number | undefined> {
|
|
101
|
+
const { source, data, enabled, path } = step;
|
|
102
|
+
if (enabled === false) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
if (source === ActionSourceEnum.request) {
|
|
106
|
+
const extractor = new RequestDataExtractor(request);
|
|
107
|
+
return extractor.extract(source, data, path);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (source === ActionSourceEnum.response) {
|
|
111
|
+
const extractor = new RequestDataExtractor(request, response);
|
|
112
|
+
return extractor.extract(source, data, path);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (source === ActionSourceEnum.variable && path && this.variables) {
|
|
116
|
+
return this.variables[path];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* A step that returns a pre-configured value.
|
|
124
|
+
*
|
|
125
|
+
* @param step The step configuration.
|
|
126
|
+
* @returns The read value with applied data type.
|
|
127
|
+
*/
|
|
128
|
+
_runSetDataStep(step: ISetDataStep): FlowValue {
|
|
129
|
+
const { value, dataType, enabled } = step;
|
|
130
|
+
if (enabled === false) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
if (value === null || value === undefined) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
return ApiSchemaValues.parseScalar(value, dataType);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A step that sets a variable in the current environment.
|
|
141
|
+
*
|
|
142
|
+
* @param step The step configuration.
|
|
143
|
+
* @param value The value to set. A value that is `null` or `undefined` deletes the variable.
|
|
144
|
+
*/
|
|
145
|
+
_runSetVariableStep(step: ISetVariableStep, value: FlowValue): FlowValue {
|
|
146
|
+
const { name, enabled } = step;
|
|
147
|
+
if (enabled === false || !name || !this.variables) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
if (value === null || typeof value === undefined) {
|
|
151
|
+
delete this.variables[name];
|
|
152
|
+
} else {
|
|
153
|
+
this.variables[name] = String(value);
|
|
154
|
+
}
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* A step that sets a cookie.
|
|
160
|
+
*
|
|
161
|
+
* @param step The step configuration.
|
|
162
|
+
* @param value The value to sent on the cookie.
|
|
163
|
+
* @param request The request object.
|
|
164
|
+
*/
|
|
165
|
+
async _runSetCookieStep(step: ISetCookieStep, value: FlowValue, request: IHttpRequest | ISentRequest): Promise<FlowValue> {
|
|
166
|
+
const { name, enabled, expires, hostOnly, httpOnly, sameSite, secure, session } = step;
|
|
167
|
+
const { cookies } = this;
|
|
168
|
+
if (enabled === false || !name || !cookies ) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
if (value === null || typeof value === undefined) {
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
const typedValue = String(value);
|
|
175
|
+
let url: string;
|
|
176
|
+
if (step.url) {
|
|
177
|
+
url = step.url;
|
|
178
|
+
} else {
|
|
179
|
+
url = request.url;
|
|
180
|
+
}
|
|
181
|
+
const cookie = new HttpCookie({
|
|
182
|
+
name: name,
|
|
183
|
+
value: typedValue,
|
|
184
|
+
sameSite: 'unspecified',
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
if (sameSite) {
|
|
188
|
+
const typed = sameSite as SameSiteValue;
|
|
189
|
+
switch (typed.toLowerCase()) {
|
|
190
|
+
case 'lax': cookie.sameSite = 'lax'; break;
|
|
191
|
+
case 'strict': cookie.sameSite = 'strict'; break;
|
|
192
|
+
case 'none': cookie.sameSite = 'no_restriction'; break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (expires) {
|
|
196
|
+
cookie.expirationDate = expires;
|
|
197
|
+
}
|
|
198
|
+
if (typeof hostOnly === 'boolean') {
|
|
199
|
+
cookie.hostOnly = hostOnly;
|
|
200
|
+
}
|
|
201
|
+
if (typeof httpOnly === 'boolean') {
|
|
202
|
+
cookie.httpOnly = httpOnly;
|
|
203
|
+
}
|
|
204
|
+
if (typeof secure === 'boolean') {
|
|
205
|
+
cookie.secure = secure;
|
|
206
|
+
}
|
|
207
|
+
if (typeof session === 'boolean') {
|
|
208
|
+
cookie.session = session;
|
|
209
|
+
}
|
|
210
|
+
await cookies.setCookies(url, [cookie]);
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* A step to delete cookies from the cookie jar.
|
|
216
|
+
*/
|
|
217
|
+
async _runDeleteCookieStep(step: IDeleteCookieStep, request: IHttpRequest | ISentRequest): Promise<FlowValue> {
|
|
218
|
+
const { name, enabled } = step;
|
|
219
|
+
const { cookies } = this;
|
|
220
|
+
if (enabled === false || !cookies ) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
let url: string;
|
|
224
|
+
if (step.url) {
|
|
225
|
+
url = step.url;
|
|
226
|
+
} else {
|
|
227
|
+
url = request.url;
|
|
228
|
+
}
|
|
229
|
+
await cookies.deleteCookies(url, name);
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
}
|