@api-client/core 0.6.31 → 0.7.2
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 -9
- package/build/src/mocking/lib/Arc.js +0 -24
- 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 -28
- 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
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { Cookie } from './Cookie.js';
|
|
2
|
-
import { getPath, matchesDomain, matchesPath, fillCookieAttributes, } from './Utils.js';
|
|
3
|
-
export const urlSymbol = Symbol('url');
|
|
4
|
-
/**
|
|
5
|
-
* A library to handle Cookie parsing.
|
|
6
|
-
*/
|
|
7
|
-
export class Cookies {
|
|
8
|
-
cookies;
|
|
9
|
-
uri;
|
|
10
|
-
[urlSymbol];
|
|
11
|
-
/**
|
|
12
|
-
* Constructs an object.
|
|
13
|
-
*
|
|
14
|
-
* @param header A HTTP cookie string to parse.
|
|
15
|
-
* @param url A request url for this cookie. If empty some cookie computations (like checking if cookies matches) will be omitted.
|
|
16
|
-
*/
|
|
17
|
-
constructor(header = '', url) {
|
|
18
|
-
/**
|
|
19
|
-
* A base URL for this object.
|
|
20
|
-
*/
|
|
21
|
-
this.url = url;
|
|
22
|
-
/**
|
|
23
|
-
* A list of parsed cookies.
|
|
24
|
-
*/
|
|
25
|
-
this.cookies = Cookies.parse(header);
|
|
26
|
-
if (this.uri && url) {
|
|
27
|
-
fillCookieAttributes(this.uri, url, this.cookies);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Set's the URL and parses it setting `uri` property.
|
|
32
|
-
* @param url Cookie URL
|
|
33
|
-
*/
|
|
34
|
-
set url(url) {
|
|
35
|
-
if (url) {
|
|
36
|
-
this[urlSymbol] = url;
|
|
37
|
-
this.uri = new URL(url);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this[urlSymbol] = undefined;
|
|
41
|
-
this.uri = undefined;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @returns {string} Cookie URL
|
|
46
|
-
*/
|
|
47
|
-
get url() {
|
|
48
|
-
return this[urlSymbol];
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Parses a cookie string to a list of Cookie objects.
|
|
52
|
-
*
|
|
53
|
-
* @param cookies A HTTP cookie string
|
|
54
|
-
* @returns List of parsed cookies.
|
|
55
|
-
*/
|
|
56
|
-
static parse(cookies) {
|
|
57
|
-
const cookieParts = [
|
|
58
|
-
'path',
|
|
59
|
-
'domain',
|
|
60
|
-
'max-age',
|
|
61
|
-
'expires',
|
|
62
|
-
'secure',
|
|
63
|
-
'httponly',
|
|
64
|
-
'samesite',
|
|
65
|
-
'hostonly',
|
|
66
|
-
];
|
|
67
|
-
const booleanParts = [
|
|
68
|
-
'secure', 'httponly', 'hostonly'
|
|
69
|
-
];
|
|
70
|
-
const list = [];
|
|
71
|
-
if (!cookies || !cookies.trim()) {
|
|
72
|
-
return list;
|
|
73
|
-
}
|
|
74
|
-
const blocks = cookies.split(';').map(i => i.trim());
|
|
75
|
-
blocks.forEach((part, index) => {
|
|
76
|
-
// Consider the following set-cookie string:
|
|
77
|
-
// c1=v1; Path=/; Expires=Wed, 09 Feb 2022 01:30:04 GMT; HttpOnly,c2=v2; Path=/,c3=v3; Path=/; Secure; SameSite=Strict
|
|
78
|
-
// It is a valid set-cookie header event though it mixes different formatting making it harder to parse cookies.
|
|
79
|
-
// This loop looks for invalid parts and creates a canonical cookie parts array.
|
|
80
|
-
const periodIndex = part.indexOf(',');
|
|
81
|
-
if (periodIndex === -1) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
if (part.toLowerCase().startsWith('expires=')) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const tmp = part.split(',');
|
|
88
|
-
// remove current
|
|
89
|
-
blocks.splice(index, 1);
|
|
90
|
-
// add the new two
|
|
91
|
-
blocks.splice(index, 0, ...tmp);
|
|
92
|
-
});
|
|
93
|
-
blocks.forEach((cookie) => {
|
|
94
|
-
const parts = cookie.split(/=/, 2);
|
|
95
|
-
if (parts.length === 0) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const name = decodeURIComponent(parts[0].trim());
|
|
99
|
-
if (!name) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const lowerName = name.toLowerCase();
|
|
103
|
-
let value;
|
|
104
|
-
if (parts.length > 1) {
|
|
105
|
-
try {
|
|
106
|
-
value = decodeURIComponent(parts[1].trim());
|
|
107
|
-
}
|
|
108
|
-
catch (e) {
|
|
109
|
-
value = parts[1];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
value = true;
|
|
114
|
-
}
|
|
115
|
-
// if this is an attribute of previous cookie, set it for last
|
|
116
|
-
// added cookie.
|
|
117
|
-
if (cookieParts.includes(lowerName)) {
|
|
118
|
-
if (list.length - 1 >= 0) {
|
|
119
|
-
const attr = lowerName;
|
|
120
|
-
const previousCookie = list[list.length - 1];
|
|
121
|
-
previousCookie[attr] = value;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
try {
|
|
126
|
-
list.push(new Cookie(name, value));
|
|
127
|
-
}
|
|
128
|
-
catch (e) {
|
|
129
|
-
// ..
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
return list;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Get a cookie by name.
|
|
137
|
-
*
|
|
138
|
-
* @param name Cookie name
|
|
139
|
-
* @returns A Cookie object or null.
|
|
140
|
-
*/
|
|
141
|
-
get(name) {
|
|
142
|
-
const { cookies } = this;
|
|
143
|
-
// eslint-disable-next-line no-plusplus
|
|
144
|
-
for (let i = 0, len = cookies.length; i < len; i++) {
|
|
145
|
-
if (cookies[i].name === name) {
|
|
146
|
-
return cookies[i];
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Adds a cookie to the list of cookies.
|
|
153
|
-
*
|
|
154
|
-
* @param name Name of the cookie.
|
|
155
|
-
* @param value Value of the cookie.
|
|
156
|
-
* @param opts Other cookie options to set.
|
|
157
|
-
*/
|
|
158
|
-
set(name, value, opts) {
|
|
159
|
-
const cookie = new Cookie(name, value, opts);
|
|
160
|
-
const cookies = this.cookies.filter((c) => c.name !== name);
|
|
161
|
-
cookies.push(cookie);
|
|
162
|
-
this.cookies = cookies;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Returns a string that can be used in a HTTP header value for Cookie.
|
|
166
|
-
* The structure of the cookie string depends on if you want to send a
|
|
167
|
-
* cookie from the server to client or other way around.
|
|
168
|
-
* When you want to send the `Cookie` header to server set
|
|
169
|
-
* `toServer` argument to true. Then it will produce only `name=value;`
|
|
170
|
-
* string. Otherwise it will be the `Set-Cookie` header value
|
|
171
|
-
* containing all other cookies properties.
|
|
172
|
-
*
|
|
173
|
-
* @param toServer True if produced string is to be used with the `Cookie` header
|
|
174
|
-
* @returns HTTP header string value for all cookies.
|
|
175
|
-
*/
|
|
176
|
-
toString(toServer = false) {
|
|
177
|
-
const parts = [];
|
|
178
|
-
this.cookies.forEach((cookie) => {
|
|
179
|
-
parts.push(toServer ? cookie.toString() : cookie.toHeader());
|
|
180
|
-
});
|
|
181
|
-
return parts.join('; ');
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Removes cookies from `this.cookies` that has been set for different
|
|
185
|
-
* domain and path.
|
|
186
|
-
* This function has no effect if the URL is not set.
|
|
187
|
-
*
|
|
188
|
-
* This function follows an algorithm defined in https://tools.ietf.org/html/rfc6265 for
|
|
189
|
-
* domain match.
|
|
190
|
-
*
|
|
191
|
-
* @returns A list of removed cookies.
|
|
192
|
-
*/
|
|
193
|
-
filter() {
|
|
194
|
-
const { uri, url } = this;
|
|
195
|
-
if (!uri || !url) {
|
|
196
|
-
return [];
|
|
197
|
-
}
|
|
198
|
-
const domain = uri.hostname.toLowerCase();
|
|
199
|
-
const path = getPath(url);
|
|
200
|
-
const removed = [];
|
|
201
|
-
this.cookies = this.cookies.filter((cookie) => {
|
|
202
|
-
if (!cookie.path) {
|
|
203
|
-
cookie.path = path;
|
|
204
|
-
}
|
|
205
|
-
const cDomain = cookie.domain;
|
|
206
|
-
if (!cDomain) {
|
|
207
|
-
cookie.domain = domain;
|
|
208
|
-
// point 6. of https://tools.ietf.org/html/rfc6265#section-5.3
|
|
209
|
-
cookie.hostOnly = true;
|
|
210
|
-
return true;
|
|
211
|
-
}
|
|
212
|
-
const res = matchesDomain(cDomain, uri) && matchesPath(cookie.path, uri, url);
|
|
213
|
-
if (!res) {
|
|
214
|
-
removed.push(cookie);
|
|
215
|
-
}
|
|
216
|
-
return res;
|
|
217
|
-
});
|
|
218
|
-
return removed;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Merges this cookies with another Cookies object.
|
|
222
|
-
* This cookies will be overwritten by passed cookies according to
|
|
223
|
-
* the HTTP spec.
|
|
224
|
-
* This function is useful when you need to override cookies with
|
|
225
|
-
* the response from the server
|
|
226
|
-
* as defined in the https://tools.ietf.org/html/rfc6265.
|
|
227
|
-
*
|
|
228
|
-
* @param cookies An Cookies object with newest cookies.
|
|
229
|
-
* @param copyKeys When set, it copies values for given keys from old object to the new one.
|
|
230
|
-
*/
|
|
231
|
-
merge(cookies, copyKeys = []) {
|
|
232
|
-
if (!cookies || !cookies.cookies || cookies.cookies.length === 0) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
if (!this.cookies || this.cookies.length === 0) {
|
|
236
|
-
this.cookies = cookies.cookies;
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
const foreignDomain = cookies.uri ? cookies.uri.hostname : null;
|
|
240
|
-
const foreignPath = cookies.url ? getPath(cookies.url) : null;
|
|
241
|
-
// delete cookies from this.cookies that has the same name as new ones,
|
|
242
|
-
// but are domain/path match
|
|
243
|
-
const newCookies = cookies.cookies;
|
|
244
|
-
const nLength = newCookies.length;
|
|
245
|
-
const { uri, url } = this;
|
|
246
|
-
if (!uri || !url) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
const copyKeysLength = copyKeys.length;
|
|
250
|
-
for (let i = this.cookies.length - 1; i >= 0; i--) {
|
|
251
|
-
const tName = this.cookies[i].name;
|
|
252
|
-
for (let j = 0; j < nLength; j++) {
|
|
253
|
-
const targetCookie = newCookies[j];
|
|
254
|
-
const nName = targetCookie.name;
|
|
255
|
-
if (nName !== tName) {
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
if (!foreignDomain || !matchesDomain(foreignDomain, uri)) {
|
|
259
|
-
// This is cookie for a different domain. Don't override.
|
|
260
|
-
continue;
|
|
261
|
-
}
|
|
262
|
-
if (!foreignPath || !matchesPath(foreignPath, uri, url)) {
|
|
263
|
-
// This is cookie for a different path. Don't override.
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
const removed = this.cookies.splice(i, 1);
|
|
267
|
-
targetCookie.created = removed[0].created;
|
|
268
|
-
if (copyKeysLength) {
|
|
269
|
-
for (let k = 0; k < copyKeysLength; k++) {
|
|
270
|
-
const key = copyKeys[k];
|
|
271
|
-
if (key in removed[0]) {
|
|
272
|
-
targetCookie[key] = removed[0][key];
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
// Do not re-set cookies that values are not set.
|
|
280
|
-
for (let i = nLength - 1; i >= 0; i--) {
|
|
281
|
-
const nValue = newCookies[i].value;
|
|
282
|
-
if (!nValue || !nValue.trim || !nValue.trim()) {
|
|
283
|
-
newCookies.splice(i, 1);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
this.cookies = this.cookies.concat(newCookies);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Clears cookies from `this.cookies` that already expired.
|
|
290
|
-
*
|
|
291
|
-
* @returns List of removed (expired) cookies.
|
|
292
|
-
*/
|
|
293
|
-
clearExpired() {
|
|
294
|
-
const now = Date.now();
|
|
295
|
-
const expired = [];
|
|
296
|
-
const cookies = this.cookies.filter((cookie) => {
|
|
297
|
-
if (!cookie.expires) {
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
if (now >= cookie.expires) {
|
|
301
|
-
expired.push(cookie);
|
|
302
|
-
return false;
|
|
303
|
-
}
|
|
304
|
-
return true;
|
|
305
|
-
});
|
|
306
|
-
this.cookies = cookies;
|
|
307
|
-
return expired;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
//# sourceMappingURL=Cookies.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Cookies.js","sourceRoot":"","sources":["../../../../src/lib/cookies/Cookies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,OAAO,EACP,aAAa,EACb,WAAW,EACX,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAEvC;;GAEG;AACH,MAAM,OAAO,OAAO;IAClB,OAAO,CAAW;IAClB,GAAG,CAAkB;IAErB,CAAC,SAAS,CAAC,CAAqB;IAEhC;;;;;OAKG;IACH,YAAY,MAAM,GAAG,EAAE,EAAE,GAAY;QACnC;;WAEG;QACH,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf;;WAEG;QACH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,IAAI,CAAC,GAAG,IAAI,GAAG,EAAE;YACnB,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SACnD;IACH,CAAC;IAED;;;OAGG;IACH,IAAI,GAAG,CAAC,GAAuB;QAC7B,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC;YACtB,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;SACzB;aAAM;YACL,IAAI,CAAC,SAAS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CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YAC7C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;gBACnB,OAAO,IAAI,CAAC;aACb;YACD,IAAI,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE;gBACzB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACrB,OAAO,KAAK,CAAC;aACd;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Cookie } from './Cookie.js';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the path for a domain as defined in
|
|
4
|
-
* https://tools.ietf.org/html/rfc6265#section-5.1.4
|
|
5
|
-
*
|
|
6
|
-
* @param urlValue A url to extract path from.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getPath(urlValue: string): string;
|
|
9
|
-
/**
|
|
10
|
-
* Checks if `domain` of the request url (defined as `this.url`)
|
|
11
|
-
* matches domain defined in a cookie.
|
|
12
|
-
* This follows algorithm defined in https://tools.ietf.org/html/rfc6265#section-5.1.3
|
|
13
|
-
*
|
|
14
|
-
* Note: If `cookieDomain` is not set it returns false, while
|
|
15
|
-
* (according to the spec) it should be set to `domain` and pass the test.
|
|
16
|
-
* Because this function only check if domains matches it will not
|
|
17
|
-
* override domain.
|
|
18
|
-
* Cookie domain should be filled before calling this function.
|
|
19
|
-
*
|
|
20
|
-
* Note: This function will return false if the `this.url` was not set.
|
|
21
|
-
*
|
|
22
|
-
* @param cookieDomain A domain received in the cookie.
|
|
23
|
-
* @param uri
|
|
24
|
-
* @return True if domains matches.
|
|
25
|
-
*/
|
|
26
|
-
export declare function matchesDomain(cookieDomain: string, uri: URL): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Checks if paths mach as defined in
|
|
29
|
-
* https://tools.ietf.org/html/rfc6265#section-5.1.4
|
|
30
|
-
*
|
|
31
|
-
* Note: This function will return false if the `this.url` was not set.
|
|
32
|
-
*
|
|
33
|
-
* @param cookiePath Path from the cookie.
|
|
34
|
-
* @param uri
|
|
35
|
-
* @param url
|
|
36
|
-
* @return True when paths matches.
|
|
37
|
-
*/
|
|
38
|
-
export declare function matchesPath(cookiePath: string, uri: URL, url: string): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Clients must fill `path` and `domain` attribute if not set by the
|
|
41
|
-
* server to match current request url.
|
|
42
|
-
*
|
|
43
|
-
* @param uri HTTP request url parsed by the URL class.
|
|
44
|
-
* @param url The HTTP request url.
|
|
45
|
-
* @param cookies Parsed cookies
|
|
46
|
-
*/
|
|
47
|
-
export declare function fillCookieAttributes(uri: URL, url: string, cookies: Cookie[]): void;
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the path for a domain as defined in
|
|
3
|
-
* https://tools.ietf.org/html/rfc6265#section-5.1.4
|
|
4
|
-
*
|
|
5
|
-
* @param urlValue A url to extract path from.
|
|
6
|
-
*/
|
|
7
|
-
export function getPath(urlValue) {
|
|
8
|
-
let url = urlValue;
|
|
9
|
-
const defaultValue = '/';
|
|
10
|
-
if (!url) {
|
|
11
|
-
return defaultValue;
|
|
12
|
-
}
|
|
13
|
-
let index = url.indexOf('/', 8); // after `http(s)://` string
|
|
14
|
-
if (index === -1) {
|
|
15
|
-
return defaultValue;
|
|
16
|
-
}
|
|
17
|
-
url = url.substr(index);
|
|
18
|
-
if (!url || url[0] !== '/') {
|
|
19
|
-
return defaultValue;
|
|
20
|
-
}
|
|
21
|
-
// removed query string
|
|
22
|
-
index = url.indexOf('?');
|
|
23
|
-
if (index !== -1) {
|
|
24
|
-
url = url.substr(0, index);
|
|
25
|
-
}
|
|
26
|
-
// removes hash string
|
|
27
|
-
index = url.indexOf('#');
|
|
28
|
-
if (index !== -1) {
|
|
29
|
-
url = url.substr(0, index);
|
|
30
|
-
}
|
|
31
|
-
index = url.indexOf('/', 1);
|
|
32
|
-
if (index === -1) {
|
|
33
|
-
return defaultValue;
|
|
34
|
-
}
|
|
35
|
-
index = url.lastIndexOf('/');
|
|
36
|
-
if (index !== 0) {
|
|
37
|
-
url = url.substr(0, index);
|
|
38
|
-
}
|
|
39
|
-
return url;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Checks if `domain` of the request url (defined as `this.url`)
|
|
43
|
-
* matches domain defined in a cookie.
|
|
44
|
-
* This follows algorithm defined in https://tools.ietf.org/html/rfc6265#section-5.1.3
|
|
45
|
-
*
|
|
46
|
-
* Note: If `cookieDomain` is not set it returns false, while
|
|
47
|
-
* (according to the spec) it should be set to `domain` and pass the test.
|
|
48
|
-
* Because this function only check if domains matches it will not
|
|
49
|
-
* override domain.
|
|
50
|
-
* Cookie domain should be filled before calling this function.
|
|
51
|
-
*
|
|
52
|
-
* Note: This function will return false if the `this.url` was not set.
|
|
53
|
-
*
|
|
54
|
-
* @param cookieDomain A domain received in the cookie.
|
|
55
|
-
* @param uri
|
|
56
|
-
* @return True if domains matches.
|
|
57
|
-
*/
|
|
58
|
-
export function matchesDomain(cookieDomain, uri) {
|
|
59
|
-
if (!uri) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
let domain = uri.hostname;
|
|
63
|
-
domain = domain && domain.toLowerCase && domain.toLowerCase();
|
|
64
|
-
// eslint-disable-next-line no-param-reassign
|
|
65
|
-
cookieDomain =
|
|
66
|
-
cookieDomain && cookieDomain.toLowerCase && cookieDomain.toLowerCase();
|
|
67
|
-
if (!cookieDomain) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
if (domain === cookieDomain) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
if (cookieDomain[0] === '.') {
|
|
74
|
-
const parts = domain.split('.');
|
|
75
|
-
if (parts.length > 1) {
|
|
76
|
-
parts.shift();
|
|
77
|
-
domain = parts.join('.');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const index = cookieDomain.indexOf(domain);
|
|
81
|
-
if (index === -1) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
if (cookieDomain.substr(index - 1, index) !== '.') {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Checks if paths mach as defined in
|
|
91
|
-
* https://tools.ietf.org/html/rfc6265#section-5.1.4
|
|
92
|
-
*
|
|
93
|
-
* Note: This function will return false if the `this.url` was not set.
|
|
94
|
-
*
|
|
95
|
-
* @param cookiePath Path from the cookie.
|
|
96
|
-
* @param uri
|
|
97
|
-
* @param url
|
|
98
|
-
* @return True when paths matches.
|
|
99
|
-
*/
|
|
100
|
-
export function matchesPath(cookiePath, uri, url) {
|
|
101
|
-
if (!uri) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
if (!cookiePath) {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
const hostPath = getPath(url);
|
|
108
|
-
if (hostPath === cookiePath) {
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
// const index = cookiePath.indexOf(hostPath);
|
|
112
|
-
const index = hostPath.indexOf(cookiePath);
|
|
113
|
-
if (index === 0 && cookiePath[cookiePath.length - 1] === '/') {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
if (index === 0 && cookiePath.indexOf('/', 1) === -1) {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
if (index === 0) {
|
|
120
|
-
// eslint-disable-next-line no-plusplus
|
|
121
|
-
for (let i = 0, len = hostPath.length; i < len; i++) {
|
|
122
|
-
if (cookiePath.indexOf(hostPath[i]) === -1 && hostPath[i] === '/') {
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Clients must fill `path` and `domain` attribute if not set by the
|
|
131
|
-
* server to match current request url.
|
|
132
|
-
*
|
|
133
|
-
* @param uri HTTP request url parsed by the URL class.
|
|
134
|
-
* @param url The HTTP request url.
|
|
135
|
-
* @param cookies Parsed cookies
|
|
136
|
-
*/
|
|
137
|
-
export function fillCookieAttributes(uri, url, cookies) {
|
|
138
|
-
if (!uri) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
let domain = uri.hostname;
|
|
142
|
-
if (!domain) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
domain = domain.toLowerCase();
|
|
146
|
-
const path = getPath(url);
|
|
147
|
-
cookies.forEach((cookie) => {
|
|
148
|
-
if (!cookie.path) {
|
|
149
|
-
// eslint-disable-next-line no-param-reassign
|
|
150
|
-
cookie.path = path;
|
|
151
|
-
}
|
|
152
|
-
const cDomain = cookie.domain;
|
|
153
|
-
if (!cDomain) {
|
|
154
|
-
// eslint-disable-next-line no-param-reassign
|
|
155
|
-
cookie.domain = domain;
|
|
156
|
-
// point 6. of https://tools.ietf.org/html/rfc6265#section-5.3
|
|
157
|
-
// eslint-disable-next-line no-param-reassign
|
|
158
|
-
cookie.hostOnly = true;
|
|
159
|
-
}
|
|
160
|
-
return cookie;
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
//# sourceMappingURL=Utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../src/lib/cookies/Utils.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,QAAgB;IACtC,IAAI,GAAG,GAAG,QAAQ,CAAC;IACnB,MAAM,YAAY,GAAG,GAAG,CAAC;IACzB,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,YAAY,CAAC;KACrB;IACD,IAAI,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,4B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M,GAAG,MAAM,CAAC;YACvB,8DAA8D;YAC9D,6CAA6C;YAC7C,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;SACxB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IDataMockInit, IHttpRequestInit } from '@pawel-up/data-mock';
|
|
2
|
-
import { IArcHttpRequest } from '../../models/arc/ArcHttpRequest.js';
|
|
3
|
-
import { Request } from './Request.js';
|
|
4
|
-
export declare class Arc {
|
|
5
|
-
protected request: Request;
|
|
6
|
-
constructor(init?: IDataMockInit);
|
|
7
|
-
arcRequest(init?: IHttpRequestInit): IArcHttpRequest;
|
|
8
|
-
arcRequests(size?: number, init?: IHttpRequestInit): IArcHttpRequest[];
|
|
9
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Kind as ArcHttpRequestKind } from '../../models/arc/ArcHttpRequest.js';
|
|
2
|
-
import { Request } from './Request.js';
|
|
3
|
-
export class Arc {
|
|
4
|
-
request;
|
|
5
|
-
constructor(init = {}) {
|
|
6
|
-
this.request = new Request(init);
|
|
7
|
-
}
|
|
8
|
-
arcRequest(init) {
|
|
9
|
-
const request = this.request.request(init);
|
|
10
|
-
return {
|
|
11
|
-
key: new Date(request.created || Date.now()).toJSON(),
|
|
12
|
-
...request,
|
|
13
|
-
kind: ArcHttpRequestKind,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
arcRequests(size = 25, init) {
|
|
17
|
-
const result = [];
|
|
18
|
-
for (let i = 0; i < size; i++) {
|
|
19
|
-
result.push(this.arcRequest(init));
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=Arc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Arc.js","sourceRoot":"","sources":["../../../../src/mocking/lib/Arc.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,IAAI,IAAI,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,OAAO,GAAG;IACJ,OAAO,CAAU;IAE3B,YAAY,OAAoB,EAAE;QAChC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,UAAU,CAAC,IAAuB;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3C,OAAO;YACL,GAAG,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;YACrD,GAAG,OAAO;YACV,IAAI,EAAE,kBAAkB;SACzB,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE,IAAuB;QAC5C,MAAM,MAAM,GAAsB,EAAE,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;SACpC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { IRunnableAction, RunnableAction } from './actions/RunnableAction.js';
|
|
2
|
-
import { RequestActions as LegacyRequestActions } from './legacy/request/ArcRequest.js';
|
|
3
|
-
export interface IRequestActions {
|
|
4
|
-
/**
|
|
5
|
-
* Actions to be executed before the request is sent to the transport library.
|
|
6
|
-
*/
|
|
7
|
-
request?: IRunnableAction[];
|
|
8
|
-
/**
|
|
9
|
-
* Actions to be executed after the response is fully received but before it is reported back to the application.
|
|
10
|
-
*/
|
|
11
|
-
response?: IRunnableAction[];
|
|
12
|
-
}
|
|
13
|
-
export declare class RequestActions {
|
|
14
|
-
/**
|
|
15
|
-
* Actions to be executed before the request is sent to the transport library.
|
|
16
|
-
*/
|
|
17
|
-
request?: RunnableAction[];
|
|
18
|
-
/**
|
|
19
|
-
* Actions to be executed after the response is fully received but before it is reported back to the application.
|
|
20
|
-
*/
|
|
21
|
-
response?: RunnableAction[];
|
|
22
|
-
static fromLegacy(action: LegacyRequestActions): RequestActions;
|
|
23
|
-
static isLegacy(input: unknown): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* @param input The request actions definition used to restore the state.
|
|
26
|
-
*/
|
|
27
|
-
constructor(input?: string | IRequestActions);
|
|
28
|
-
/**
|
|
29
|
-
* Creates a new request actions clearing anything that is so far defined.
|
|
30
|
-
*/
|
|
31
|
-
new(init: IRequestActions): void;
|
|
32
|
-
toJSON(): IRequestActions;
|
|
33
|
-
/**
|
|
34
|
-
* Adds a request action to the list of actions.
|
|
35
|
-
* If the list does not exist it's created by this method.
|
|
36
|
-
*
|
|
37
|
-
* @param action The schema of the action.
|
|
38
|
-
* @returns Created instance of the action.
|
|
39
|
-
*/
|
|
40
|
-
addRequestAction(action: IRunnableAction): RunnableAction;
|
|
41
|
-
/**
|
|
42
|
-
* Adds a request action to the list of actions.
|
|
43
|
-
* If the list does not exist it's created by this method.
|
|
44
|
-
*
|
|
45
|
-
* @param action The instance of the action.
|
|
46
|
-
* @returns The same instance of the action.
|
|
47
|
-
*/
|
|
48
|
-
addRequestAction(action: RunnableAction): RunnableAction;
|
|
49
|
-
/**
|
|
50
|
-
* Adds a request action to the list of actions.
|
|
51
|
-
* If the list does not exist it's created by this method.
|
|
52
|
-
*
|
|
53
|
-
* @param action The schema of the action.
|
|
54
|
-
* @returns Created instance of the action.
|
|
55
|
-
*/
|
|
56
|
-
addResponseAction(action: IRunnableAction): RunnableAction;
|
|
57
|
-
/**
|
|
58
|
-
* Adds a response action to the list of actions.
|
|
59
|
-
* If the list does not exist it's created by this method.
|
|
60
|
-
*
|
|
61
|
-
* @param action The instance of the action.
|
|
62
|
-
* @returns The same instance of the action.
|
|
63
|
-
*/
|
|
64
|
-
addResponseAction(action: RunnableAction): RunnableAction;
|
|
65
|
-
}
|