@api-client/core 0.6.29 → 0.7.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.
- 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/AppRequest.js +150 -0
- 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/FilesSdk.js +4 -4
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/build/src/runtime/store/HistorySdk.js +1 -1
- package/build/src/runtime/store/HistorySdk.js.map +1 -1
- package/build/src/runtime/store/HttpClientSdk.d.ts +167 -0
- package/build/src/runtime/store/HttpClientSdk.js +624 -0
- package/build/src/runtime/store/HttpClientSdk.js.map +1 -0
- 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/FilesSdk.ts +4 -4
- package/src/runtime/store/HistorySdk.ts +1 -1
- package/src/runtime/store/HttpClientSdk.ts +629 -0
- 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 -39
- package/build/src/models/arc/ArcHttpRequest.js +0 -106
- 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 -121
- 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
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
2
|
-
import { EnvironmentEvents } from '../../events/environment/EnvironmentEvents.js';
|
|
3
|
-
import { CookieEvents } from '../../events/cookies/CookieEvents.js';
|
|
4
|
-
import { EncryptionEvents } from '../../events/encryption/EncryptionEvents.js';
|
|
5
|
-
import { ProcessEvents } from '../../events/process/ProcessEvents.js';
|
|
6
|
-
import { AuthorizationEvents } from '../../events/authorization/AuthorizationEvents.js';
|
|
7
|
-
import { ClientCertificateEvents } from '../../events/models/ClientCertificateEvents.js';
|
|
8
|
-
import { IRequestAuthorization } from '../../models/RequestAuthorization.js';
|
|
9
|
-
import { IRequestConfig } from '../../models/RequestConfig.js';
|
|
10
|
-
import { IRequestLog } from '../../models/RequestLog.js';
|
|
11
|
-
import { HttpCertificate } from '../../models/ClientCertificate.js';
|
|
12
|
-
export interface RegisteredRequestModule {
|
|
13
|
-
fn: (request: IHttpRequest, context: ExecutionContext) => Promise<number>;
|
|
14
|
-
permissions: RegistryPermission[];
|
|
15
|
-
}
|
|
16
|
-
export interface RegisteredResponseModule {
|
|
17
|
-
fn: (log: IRequestLog, context: ExecutionContext) => Promise<number>;
|
|
18
|
-
permissions: RegistryPermission[];
|
|
19
|
-
}
|
|
20
|
-
export declare enum RegistryPermission {
|
|
21
|
-
environment = "environment",
|
|
22
|
-
events = "events"
|
|
23
|
-
}
|
|
24
|
-
export interface ExecutionContext {
|
|
25
|
-
/**
|
|
26
|
-
* The event target for events
|
|
27
|
-
*/
|
|
28
|
-
eventsTarget: EventTarget;
|
|
29
|
-
/**
|
|
30
|
-
* The events to use to communicate with the context store(s)
|
|
31
|
-
*/
|
|
32
|
-
Events?: ExecutionEvents;
|
|
33
|
-
/**
|
|
34
|
-
* The environment variables to use when executing the module.
|
|
35
|
-
*/
|
|
36
|
-
variables?: Record<string, string>;
|
|
37
|
-
/**
|
|
38
|
-
* Request authorization configuration
|
|
39
|
-
*/
|
|
40
|
-
authorization?: IRequestAuthorization[];
|
|
41
|
-
/**
|
|
42
|
-
* Optional request configuration.
|
|
43
|
-
*/
|
|
44
|
-
config?: IRequestConfig;
|
|
45
|
-
/**
|
|
46
|
-
* Can be altered by the actions.
|
|
47
|
-
*/
|
|
48
|
-
certificates?: HttpCertificate[];
|
|
49
|
-
}
|
|
50
|
-
export interface ExecutionEvents {
|
|
51
|
-
Authorization: typeof AuthorizationEvents;
|
|
52
|
-
Environment: typeof EnvironmentEvents;
|
|
53
|
-
Cookie: typeof CookieEvents;
|
|
54
|
-
Encryption: typeof EncryptionEvents;
|
|
55
|
-
Process: typeof ProcessEvents;
|
|
56
|
-
ClientCertificate: typeof ClientCertificateEvents;
|
|
57
|
-
}
|
|
58
|
-
export declare type RequestModule = 'request';
|
|
59
|
-
export declare type ResponseModule = 'response';
|
|
60
|
-
/**
|
|
61
|
-
* A registry for modules.
|
|
62
|
-
*/
|
|
63
|
-
export declare class ModulesRegistry {
|
|
64
|
-
static get request(): RequestModule;
|
|
65
|
-
static get response(): ResponseModule;
|
|
66
|
-
/**
|
|
67
|
-
* Registers a new request or response module in the registry.
|
|
68
|
-
* @param context The name of the execution context
|
|
69
|
-
* @param id The identifier of the module
|
|
70
|
-
* @param fn The function to execute
|
|
71
|
-
* @param permissions The list of permissions for the module
|
|
72
|
-
* @throws {Error} When the module is already registered
|
|
73
|
-
*/
|
|
74
|
-
static register(context: ResponseModule | RequestModule, id: string, fn: Function, permissions?: string[]): void;
|
|
75
|
-
/**
|
|
76
|
-
* Checks whether a module is already registered for the given context.
|
|
77
|
-
* @param {ModulesRegistry.request|ModulesRegistry.response} context The name of the execution context
|
|
78
|
-
* @param id The identifier of the module
|
|
79
|
-
*/
|
|
80
|
-
static has(context: ResponseModule | RequestModule, id: string): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Removes a registered module
|
|
83
|
-
* @param {ModulesRegistry.request|ModulesRegistry.response} context The name of the execution context
|
|
84
|
-
* @param {string} id The identifier of the module
|
|
85
|
-
*/
|
|
86
|
-
static unregister(context: ResponseModule | RequestModule, id: string): void;
|
|
87
|
-
/**
|
|
88
|
-
* Reads the list of registered modules
|
|
89
|
-
* @param context The name of the execution context
|
|
90
|
-
* @returns The copy of the map of actions.
|
|
91
|
-
*/
|
|
92
|
-
static get(context: ResponseModule | RequestModule): Map<string, RegisteredRequestModule | RegisteredResponseModule>;
|
|
93
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
export var RegistryPermission;
|
|
2
|
-
(function (RegistryPermission) {
|
|
3
|
-
RegistryPermission["environment"] = "environment";
|
|
4
|
-
RegistryPermission["events"] = "events";
|
|
5
|
-
})(RegistryPermission || (RegistryPermission = {}));
|
|
6
|
-
/**
|
|
7
|
-
* The list of registered request processing modules.
|
|
8
|
-
*/
|
|
9
|
-
const requestModules = new Map();
|
|
10
|
-
/**
|
|
11
|
-
* The list of registered response processing modules.
|
|
12
|
-
*/
|
|
13
|
-
const responseModules = new Map();
|
|
14
|
-
/**
|
|
15
|
-
* A registry for modules.
|
|
16
|
-
*/
|
|
17
|
-
export class ModulesRegistry {
|
|
18
|
-
static get request() { return 'request'; }
|
|
19
|
-
static get response() { return 'response'; }
|
|
20
|
-
/**
|
|
21
|
-
* Registers a new request or response module in the registry.
|
|
22
|
-
* @param context The name of the execution context
|
|
23
|
-
* @param id The identifier of the module
|
|
24
|
-
* @param fn The function to execute
|
|
25
|
-
* @param permissions The list of permissions for the module
|
|
26
|
-
* @throws {Error} When the module is already registered
|
|
27
|
-
*/
|
|
28
|
-
static register(context, id, fn, permissions) {
|
|
29
|
-
const data = {
|
|
30
|
-
fn,
|
|
31
|
-
permissions: Array.isArray(permissions) ? permissions : [],
|
|
32
|
-
};
|
|
33
|
-
const map = context === ModulesRegistry.request ? requestModules : responseModules;
|
|
34
|
-
if (map.has(id)) {
|
|
35
|
-
throw new Error(`Module ${id} already exists`);
|
|
36
|
-
}
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
map.set(id, data);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Checks whether a module is already registered for the given context.
|
|
42
|
-
* @param {ModulesRegistry.request|ModulesRegistry.response} context The name of the execution context
|
|
43
|
-
* @param id The identifier of the module
|
|
44
|
-
*/
|
|
45
|
-
static has(context, id) {
|
|
46
|
-
const map = context === ModulesRegistry.request ? requestModules : responseModules;
|
|
47
|
-
return map.has(id);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Removes a registered module
|
|
51
|
-
* @param {ModulesRegistry.request|ModulesRegistry.response} context The name of the execution context
|
|
52
|
-
* @param {string} id The identifier of the module
|
|
53
|
-
*/
|
|
54
|
-
static unregister(context, id) {
|
|
55
|
-
const map = context === ModulesRegistry.request ? requestModules : responseModules;
|
|
56
|
-
map.delete(id);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Reads the list of registered modules
|
|
60
|
-
* @param context The name of the execution context
|
|
61
|
-
* @returns The copy of the map of actions.
|
|
62
|
-
*/
|
|
63
|
-
static get(context) {
|
|
64
|
-
const map = context === ModulesRegistry.request ? requestModules : responseModules;
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
return new Map(map);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=ModulesRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModulesRegistry.js","sourceRoot":"","sources":["../../../../src/runtime/modules/ModulesRegistry.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,iDAA2B,CAAA;IAC3B,uCAAiB,CAAA;AACnB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAsCD;;GAEG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,EAAmC,CAAC;AAElE;;GAEG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,EAAoC,CAAC;AAKpE;;GAEG;AACH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GAAG,GAAG,OAAO,KAAK,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC;QACnF,aAAa;QACb,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
2
|
-
import { ExecutionContext } from './ModulesRegistry.js';
|
|
3
|
-
/**
|
|
4
|
-
* Processes authorization data from the authorization configuration and injects data into the request object when necessary.
|
|
5
|
-
*/
|
|
6
|
-
export default function processAuth(request: IHttpRequest, context: ExecutionContext): Promise<number>;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Headers } from '../../lib/headers/Headers.js';
|
|
2
|
-
import { ExecutionResponse } from './ExecutionResponse.js';
|
|
3
|
-
import applyCachedBasicAuthData, { applyRequestBasicAuthData } from './BasicAuthCache.js';
|
|
4
|
-
/**
|
|
5
|
-
* Injects client certificate object into the request object
|
|
6
|
-
*/
|
|
7
|
-
async function processClientCertificate(config, context) {
|
|
8
|
-
const { certificate } = config;
|
|
9
|
-
if (!certificate) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (!Array.isArray(context.certificates)) {
|
|
13
|
-
context.certificates = [];
|
|
14
|
-
}
|
|
15
|
-
context.certificates.push(certificate);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Injects basic auth header into the request headers.
|
|
19
|
-
*/
|
|
20
|
-
function processBasicAuth(request, config) {
|
|
21
|
-
const { username } = config;
|
|
22
|
-
if (!username) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
applyRequestBasicAuthData(request, config);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Injects oauth 2 auth header into the request headers.
|
|
29
|
-
*/
|
|
30
|
-
function processOAuth2(request, config) {
|
|
31
|
-
const { accessToken, tokenType = 'Bearer', deliveryMethod = 'header', deliveryName = 'authorization' } = config;
|
|
32
|
-
if (!accessToken) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const value = `${tokenType} ${accessToken}`;
|
|
36
|
-
if (deliveryMethod === 'header') {
|
|
37
|
-
const headers = new Headers(request.headers || '');
|
|
38
|
-
headers.append(deliveryName, value);
|
|
39
|
-
request.headers = headers.toString();
|
|
40
|
-
}
|
|
41
|
-
else if (deliveryMethod === 'query') {
|
|
42
|
-
const { url } = request;
|
|
43
|
-
try {
|
|
44
|
-
const parsed = new URL(url);
|
|
45
|
-
parsed.searchParams.append(deliveryName, value);
|
|
46
|
-
request.url = parsed.toString();
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
// ...
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Injects OpenID Connect auth header into the request headers.
|
|
55
|
-
*/
|
|
56
|
-
function processOpenId(request, config) {
|
|
57
|
-
const { accessToken } = config;
|
|
58
|
-
if (accessToken) {
|
|
59
|
-
processOAuth2(request, config);
|
|
60
|
-
}
|
|
61
|
-
// todo - if AT is missing find the current token from the tokens list in the passed configuration.
|
|
62
|
-
// Currently the authorization method UI sets the token when the requests is generated so it's not as much important.
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Injects bearer auth header into the request headers.
|
|
66
|
-
*/
|
|
67
|
-
function processBearer(request, config) {
|
|
68
|
-
const { token } = config;
|
|
69
|
-
const value = `Bearer ${token}`;
|
|
70
|
-
const headers = new Headers(request.headers || '');
|
|
71
|
-
headers.append('authorization', value);
|
|
72
|
-
request.headers = headers.toString();
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Processes authorization data from the authorization configuration and injects data into the request object when necessary.
|
|
76
|
-
*/
|
|
77
|
-
export default async function processAuth(request, context) {
|
|
78
|
-
if (!Array.isArray(context.authorization) || !context.authorization.length) {
|
|
79
|
-
return ExecutionResponse.OK;
|
|
80
|
-
}
|
|
81
|
-
for (const auth of context.authorization) {
|
|
82
|
-
if (!auth.enabled || !auth.config) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
switch (auth.type) {
|
|
86
|
-
case 'client certificate':
|
|
87
|
-
await processClientCertificate(auth.config, context);
|
|
88
|
-
break;
|
|
89
|
-
case 'basic':
|
|
90
|
-
processBasicAuth(request, auth.config);
|
|
91
|
-
break;
|
|
92
|
-
case 'oauth 2':
|
|
93
|
-
processOAuth2(request, auth.config);
|
|
94
|
-
break;
|
|
95
|
-
case 'open id':
|
|
96
|
-
processOpenId(request, auth.config);
|
|
97
|
-
break;
|
|
98
|
-
case 'bearer':
|
|
99
|
-
processBearer(request, auth.config);
|
|
100
|
-
break;
|
|
101
|
-
default:
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (request.url && !/^authorization:\s?.+$/gim.test(request.headers || '')) {
|
|
105
|
-
// Try to apply basic auth from the cached during this session values.
|
|
106
|
-
applyCachedBasicAuthData(request, context);
|
|
107
|
-
}
|
|
108
|
-
return ExecutionResponse.OK;
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=RequestAuthorization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RequestAuthorization.js","sourceRoot":"","sources":["../../../../src/runtime/modules/RequestAuthorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,wBAAwB,EAAE,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAK1F;;GAEG;AACH,KAAK,UAAU,wBAAwB,CAAC,MAAwB,EAAE,OAAyB;IACzF,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAC/B,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO;KACR;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAA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;YACnF,KAAK,SAAS;gBAAE,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,MAA8B,CAAC,CAAC;gBAAC,MAAM;YACnF,KAAK,SAAS;gBAAE,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,MAA4B,CAAC,CAAC;gBAAC,MAAM;YACjF,KAAK,QAAQ;gBAAE,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,MAA8B,CAAC,CAAC;gBAAC,MAAM;YAClF,QAAQ;SACT;KACF;IACD,IAAI,OAAO,CAAC,GAAG,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE;QAC1E,sEAAsE;QACtE,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KAC5C;IACD,OAAO,iBAAiB,CAAC,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
2
|
-
import { ExecutionContext } from './ModulesRegistry.js';
|
|
3
|
-
import { IRequestLog } from '../../models/RequestLog.js';
|
|
4
|
-
/**
|
|
5
|
-
* A request engine request module to apply session cookies to a request.
|
|
6
|
-
* It adds stored session cookies when application configuration applies for it (or request configuration, when apply)
|
|
7
|
-
*
|
|
8
|
-
* Unregister this module when the application settings change to not to use session storage.
|
|
9
|
-
*
|
|
10
|
-
* In electron the session storage is a chrome persistent partition with a session shared with the "log in to a web service".
|
|
11
|
-
* This way cookies can be acquired in through the browser login and store in the application to use them with the request.
|
|
12
|
-
*/
|
|
13
|
-
export declare function processRequestCookies(request: IHttpRequest, context: ExecutionContext): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Processes cookies data from the response and inserts them into the session storage
|
|
16
|
-
*/
|
|
17
|
-
export declare function processResponseCookies(log: IRequestLog, context: ExecutionContext): Promise<void>;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { CookieEvents } from '../../events/cookies/CookieEvents.js';
|
|
2
|
-
import { Cookies } from '../../lib/cookies/Cookies.js';
|
|
3
|
-
import { Headers } from '../../lib/headers/Headers.js';
|
|
4
|
-
import { HttpCookie } from '../../models/HttpCookie.js';
|
|
5
|
-
import { Kind as RequestConfigKind } from '../../models/RequestConfig.js';
|
|
6
|
-
/**
|
|
7
|
-
* Get cookies header value for given URL.
|
|
8
|
-
*
|
|
9
|
-
* @param eventsTarget
|
|
10
|
-
* @param url An URL for cookies.
|
|
11
|
-
* @returns A promise that resolves to header value string.
|
|
12
|
-
*/
|
|
13
|
-
async function getCookiesHeaderValue(eventsTarget, url) {
|
|
14
|
-
const cookies = await CookieEvents.listUrl(url, eventsTarget);
|
|
15
|
-
if (!cookies || !cookies.length) {
|
|
16
|
-
return '';
|
|
17
|
-
}
|
|
18
|
-
return cookies.map((c) => `${c.name}=${c.value}`).join('; ');
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Applies cookie header value to current request headers.
|
|
22
|
-
* If header to be applied is computed then it will alter headers string.
|
|
23
|
-
*
|
|
24
|
-
* Note, this element do not sends `request-headers-changed` event.
|
|
25
|
-
*
|
|
26
|
-
* @param header Computed headers string
|
|
27
|
-
* @param request The request object from the event.
|
|
28
|
-
*/
|
|
29
|
-
function applyCookieHeader(header, request) {
|
|
30
|
-
const trimmed = header.trim();
|
|
31
|
-
if (!trimmed) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const headers = new Headers(request.headers);
|
|
35
|
-
headers.append('cookie', trimmed);
|
|
36
|
-
request.headers = headers.toString();
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Extracts cookies from the `response` object and returns an object with `cookies` and `expired` properties containing array of cookies, each.
|
|
40
|
-
*
|
|
41
|
-
* @param url The request URL.
|
|
42
|
-
* @param redirects List of redirect responses
|
|
43
|
-
* @returns An object with `cookies` and `expired` arrays of cookies.
|
|
44
|
-
*/
|
|
45
|
-
function extract(response, url, redirects) {
|
|
46
|
-
let expired = [];
|
|
47
|
-
let parser;
|
|
48
|
-
let exp;
|
|
49
|
-
const parsers = [];
|
|
50
|
-
if (redirects && redirects.length) {
|
|
51
|
-
redirects.forEach((r) => {
|
|
52
|
-
const headers = new Headers(r.response.headers);
|
|
53
|
-
if (headers.has('set-cookie')) {
|
|
54
|
-
parser = new Cookies(headers.get('set-cookie'), r.url);
|
|
55
|
-
parser.filter();
|
|
56
|
-
exp = parser.clearExpired();
|
|
57
|
-
if (exp && exp.length) {
|
|
58
|
-
expired = expired.concat(exp);
|
|
59
|
-
}
|
|
60
|
-
parsers.push(parser);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
const headers = new Headers(response.headers);
|
|
65
|
-
if (headers.has('set-cookie')) {
|
|
66
|
-
parser = new Cookies(headers.get('set-cookie'), url);
|
|
67
|
-
parser.filter();
|
|
68
|
-
exp = parser.clearExpired();
|
|
69
|
-
if (exp && exp.length) {
|
|
70
|
-
expired = expired.concat(exp);
|
|
71
|
-
}
|
|
72
|
-
parsers.push(parser);
|
|
73
|
-
}
|
|
74
|
-
let mainParser;
|
|
75
|
-
parsers.forEach((item) => {
|
|
76
|
-
if (!mainParser) {
|
|
77
|
-
mainParser = item;
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
mainParser.merge(item);
|
|
81
|
-
});
|
|
82
|
-
return {
|
|
83
|
-
cookies: mainParser ? mainParser.cookies : [],
|
|
84
|
-
expired
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* A request engine request module to apply session cookies to a request.
|
|
89
|
-
* It adds stored session cookies when application configuration applies for it (or request configuration, when apply)
|
|
90
|
-
*
|
|
91
|
-
* Unregister this module when the application settings change to not to use session storage.
|
|
92
|
-
*
|
|
93
|
-
* In electron the session storage is a chrome persistent partition with a session shared with the "log in to a web service".
|
|
94
|
-
* This way cookies can be acquired in through the browser login and store in the application to use them with the request.
|
|
95
|
-
*/
|
|
96
|
-
export async function processRequestCookies(request, context) {
|
|
97
|
-
const editorRequest = request;
|
|
98
|
-
const { config } = context;
|
|
99
|
-
const ignore = config && config.enabled === true && config.ignoreSessionCookies === true;
|
|
100
|
-
if (ignore) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const cookie = await getCookiesHeaderValue(context.eventsTarget, editorRequest.url);
|
|
104
|
-
applyCookieHeader(cookie, editorRequest);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Processes cookies data from the response and inserts them into the session storage
|
|
108
|
-
*/
|
|
109
|
-
export async function processResponseCookies(log, context) {
|
|
110
|
-
if (!log.response || !log.request) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const typedError = log.response;
|
|
114
|
-
if (typedError.error) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const config = context.config || {
|
|
118
|
-
kind: RequestConfigKind,
|
|
119
|
-
enabled: false,
|
|
120
|
-
};
|
|
121
|
-
let ignore = false;
|
|
122
|
-
if (config.enabled !== false && config.ignoreSessionCookies) {
|
|
123
|
-
ignore = true;
|
|
124
|
-
}
|
|
125
|
-
if (ignore) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const typedResponse = log.response;
|
|
129
|
-
const result = extract(typedResponse, log.request.url, log.redirects);
|
|
130
|
-
if (result.cookies.length) {
|
|
131
|
-
await CookieEvents.updateBulk(result.cookies.map(c => HttpCookie.fromCookieParser(c).toJSON()), context.eventsTarget);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
//# sourceMappingURL=RequestCookies.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RequestCookies.js","sourceRoot":"","sources":["../../../../src/runtime/modules/RequestCookies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,OAAO,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