@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
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { HttpCookie } from '../models/HttpCookie.js';
|
|
2
|
+
export declare type SameSiteValue = 'Lax' | 'Strict' | 'None';
|
|
3
|
+
/**
|
|
4
|
+
* A class that parses the `set-cookie` header string to a list of cookies.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CookieParser {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a cookie canonical domain from the full request URL.
|
|
9
|
+
*
|
|
10
|
+
* @param url The HTTP request URL.
|
|
11
|
+
* @returns The canonical domain for the URL.
|
|
12
|
+
*/
|
|
13
|
+
static canonicalDomainUrl(url: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a cookie canonical domain from the host name.
|
|
16
|
+
*
|
|
17
|
+
* @param host The same as `new URL('...').host`.
|
|
18
|
+
* @returns The canonical domain for the URL.
|
|
19
|
+
*/
|
|
20
|
+
static canonicalDomain(host: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Parses the `set-cookie` header value and creates a list of cookies.
|
|
23
|
+
* The cookie configuration must match the `url`. This means that if the cookie has a `host` property
|
|
24
|
+
* this must match the request URL (browsers do not allow setting cookies from one domain for another).
|
|
25
|
+
*
|
|
26
|
+
* When `host` or `path` part is missing from the cookie, the URL values are used.
|
|
27
|
+
*
|
|
28
|
+
* @param requestUrl The HTTP request URL. Cookies must match this URL or will be ignored.
|
|
29
|
+
* @param setCookie The value of the `set-cookie` string.
|
|
30
|
+
*/
|
|
31
|
+
static parse(requestUrl: string, setCookie?: string): HttpCookie[];
|
|
32
|
+
/**
|
|
33
|
+
* Filters a list of cookies to match the given `requestUrl`.
|
|
34
|
+
* This means that both the `domain` and the `path` part of the cookie must match the URL.
|
|
35
|
+
*
|
|
36
|
+
* @param cookies The list of cookies to filter.
|
|
37
|
+
* @param requestUrl The request URL to filter against.
|
|
38
|
+
* @returns The filtered list of cookies that can be used with the URL.
|
|
39
|
+
*/
|
|
40
|
+
static filterCookies(cookies: HttpCookie[], requestUrl: string): HttpCookie[];
|
|
41
|
+
/**
|
|
42
|
+
* Gets the path for a domain as defined in
|
|
43
|
+
* https://tools.ietf.org/html/rfc6265#section-5.1.4
|
|
44
|
+
*/
|
|
45
|
+
static getPath(url: URL): string;
|
|
46
|
+
/**
|
|
47
|
+
* This follows the algorithm defined in https://tools.ietf.org/html/rfc6265#section-5.1.3
|
|
48
|
+
*
|
|
49
|
+
* @param string A string to test whether it matches the domain.
|
|
50
|
+
* @param domain The domain to compare to
|
|
51
|
+
* @return True if domains matches.
|
|
52
|
+
*/
|
|
53
|
+
static matchesDomain(string: string, domain: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if paths mach as defined in
|
|
56
|
+
* https://tools.ietf.org/html/rfc6265#section-5.1.4
|
|
57
|
+
*
|
|
58
|
+
* Note: This function will return false if the `this.url` was not set.
|
|
59
|
+
*
|
|
60
|
+
* @param cookiePath Path from the cookie.
|
|
61
|
+
* @param url
|
|
62
|
+
* @return True when paths matches.
|
|
63
|
+
*/
|
|
64
|
+
static matchesPath(cookiePath: string, url: URL): boolean;
|
|
65
|
+
protected static _matchesPath(cookiePath: string, requestPath: string): boolean;
|
|
66
|
+
static matchesCookie(c1: HttpCookie, c2: HttpCookie): boolean;
|
|
67
|
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/* eslint-disable no-control-regex */
|
|
2
|
+
import { Punycode } from "./Punycode.js";
|
|
3
|
+
import { HttpCookie } from '../models/HttpCookie.js';
|
|
4
|
+
const cookieParts = [
|
|
5
|
+
'path',
|
|
6
|
+
'domain',
|
|
7
|
+
'max-age',
|
|
8
|
+
'expires',
|
|
9
|
+
'secure',
|
|
10
|
+
'httponly',
|
|
11
|
+
'samesite',
|
|
12
|
+
'hostonly',
|
|
13
|
+
];
|
|
14
|
+
const v6reStr = `
|
|
15
|
+
\\[?(?:
|
|
16
|
+
(?:[a-fA-F\\d]{1,4}:){7}(?:[a-fA-F\\d]{1,4}|:)|
|
|
17
|
+
(?:[a-fA-F\\d]{1,4}:){6}(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A-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:))
|
|
24
|
+
)(?:%[0-9a-zA-Z]{1,})?\\]?
|
|
25
|
+
`
|
|
26
|
+
.replace(/\s*\/\/.*$/gm, "")
|
|
27
|
+
.replace(/\n/g, "")
|
|
28
|
+
.trim();
|
|
29
|
+
const ipV6re = new RegExp(`^${v6reStr}$`);
|
|
30
|
+
/**
|
|
31
|
+
* A class that parses the `set-cookie` header string to a list of cookies.
|
|
32
|
+
*/
|
|
33
|
+
export class CookieParser {
|
|
34
|
+
/**
|
|
35
|
+
* Creates a cookie canonical domain from the full request URL.
|
|
36
|
+
*
|
|
37
|
+
* @param url The HTTP request URL.
|
|
38
|
+
* @returns The canonical domain for the URL.
|
|
39
|
+
*/
|
|
40
|
+
static canonicalDomainUrl(url) {
|
|
41
|
+
const parser = new URL(url);
|
|
42
|
+
return this.canonicalDomain(parser.host);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a cookie canonical domain from the host name.
|
|
46
|
+
*
|
|
47
|
+
* @param host The same as `new URL('...').host`.
|
|
48
|
+
* @returns The canonical domain for the URL.
|
|
49
|
+
*/
|
|
50
|
+
static canonicalDomain(host) {
|
|
51
|
+
let str = host;
|
|
52
|
+
str = str.trim();
|
|
53
|
+
if (ipV6re.test(str)) {
|
|
54
|
+
str = str.replace("[", "").replace("]", "");
|
|
55
|
+
}
|
|
56
|
+
if (/[^\u0001-\u007f]/.test(str)) {
|
|
57
|
+
str = Punycode.toASCII(str);
|
|
58
|
+
}
|
|
59
|
+
// if (str[0] !== '.') {
|
|
60
|
+
// str = `.${str}`;
|
|
61
|
+
// }
|
|
62
|
+
return str.toLowerCase();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parses the `set-cookie` header value and creates a list of cookies.
|
|
66
|
+
* The cookie configuration must match the `url`. This means that if the cookie has a `host` property
|
|
67
|
+
* this must match the request URL (browsers do not allow setting cookies from one domain for another).
|
|
68
|
+
*
|
|
69
|
+
* When `host` or `path` part is missing from the cookie, the URL values are used.
|
|
70
|
+
*
|
|
71
|
+
* @param requestUrl The HTTP request URL. Cookies must match this URL or will be ignored.
|
|
72
|
+
* @param setCookie The value of the `set-cookie` string.
|
|
73
|
+
*/
|
|
74
|
+
static parse(requestUrl, setCookie) {
|
|
75
|
+
const result = [];
|
|
76
|
+
if (!setCookie || typeof setCookie !== 'string') {
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
const blocks = setCookie.split(';').map(i => i.trim());
|
|
80
|
+
blocks.forEach((part, index) => {
|
|
81
|
+
// Consider the following set-cookie string:
|
|
82
|
+
// c1=v1; Path=/; Expires=Wed, 09 Feb 2022 01:30:04 GMT; HttpOnly,c2=v2; Path=/,c3=v3; Path=/; Secure; SameSite=Strict
|
|
83
|
+
// It is a valid set-cookie header event though it mixes different formatting making it harder to parse cookies.
|
|
84
|
+
// This loop looks for invalid parts and creates a canonical cookie parts array.
|
|
85
|
+
const periodIndex = part.indexOf(',');
|
|
86
|
+
if (periodIndex === -1) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (part.toLowerCase().startsWith('expires=')) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const tmp = part.split(',');
|
|
93
|
+
// remove current
|
|
94
|
+
blocks.splice(index, 1);
|
|
95
|
+
// add the new two
|
|
96
|
+
blocks.splice(index, 0, ...tmp);
|
|
97
|
+
});
|
|
98
|
+
blocks.forEach((cookie) => {
|
|
99
|
+
const parts = cookie.split(/=/, 2);
|
|
100
|
+
if (parts.length === 0) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const name = decodeURIComponent(parts[0].trim());
|
|
104
|
+
if (!name) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const lowerName = name.toLowerCase();
|
|
108
|
+
let value;
|
|
109
|
+
if (parts.length > 1) {
|
|
110
|
+
try {
|
|
111
|
+
value = decodeURIComponent(parts[1].trim());
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
value = parts[1];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
value = true;
|
|
119
|
+
}
|
|
120
|
+
// if this is an attribute of previous cookie, set it for last
|
|
121
|
+
// added cookie.
|
|
122
|
+
if (cookieParts.includes(lowerName)) {
|
|
123
|
+
if (result.length - 1 >= 0) {
|
|
124
|
+
const attr = lowerName;
|
|
125
|
+
const previousCookie = result[result.length - 1];
|
|
126
|
+
if (attr === 'samesite') {
|
|
127
|
+
const typed = value;
|
|
128
|
+
switch (typed.toLowerCase()) {
|
|
129
|
+
case 'lax':
|
|
130
|
+
previousCookie[attr] = 'lax';
|
|
131
|
+
break;
|
|
132
|
+
case 'strict':
|
|
133
|
+
previousCookie[attr] = 'strict';
|
|
134
|
+
break;
|
|
135
|
+
case 'none':
|
|
136
|
+
previousCookie[attr] = 'no_restriction';
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
previousCookie[attr] = value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
try {
|
|
147
|
+
result.push(new HttpCookie({
|
|
148
|
+
name,
|
|
149
|
+
value: value,
|
|
150
|
+
sameSite: 'unspecified',
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
// ..
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
// At this point we have all cookies set by the server. Now we need to filter out cookies
|
|
159
|
+
// set for a different domains.
|
|
160
|
+
// first lets set cookie domain and path.
|
|
161
|
+
const url = new URL(requestUrl);
|
|
162
|
+
const domain = this.canonicalDomain(url.host);
|
|
163
|
+
const path = this.getPath(url);
|
|
164
|
+
result.forEach((cookie) => {
|
|
165
|
+
if (!cookie.path) {
|
|
166
|
+
cookie.path = path;
|
|
167
|
+
}
|
|
168
|
+
if (!cookie.domain) {
|
|
169
|
+
// point 6. of https://tools.ietf.org/html/rfc6265#section-5.3
|
|
170
|
+
cookie.domain = domain;
|
|
171
|
+
cookie.hostOnly = true;
|
|
172
|
+
}
|
|
173
|
+
else if (cookie.domain[0] !== '.') {
|
|
174
|
+
// https://stackoverflow.com/a/1063760/1127848
|
|
175
|
+
cookie.domain = `.${cookie.domain}`;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return this.filterCookies(result, requestUrl);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Filters a list of cookies to match the given `requestUrl`.
|
|
182
|
+
* This means that both the `domain` and the `path` part of the cookie must match the URL.
|
|
183
|
+
*
|
|
184
|
+
* @param cookies The list of cookies to filter.
|
|
185
|
+
* @param requestUrl The request URL to filter against.
|
|
186
|
+
* @returns The filtered list of cookies that can be used with the URL.
|
|
187
|
+
*/
|
|
188
|
+
static filterCookies(cookies, requestUrl) {
|
|
189
|
+
const url = new URL(requestUrl);
|
|
190
|
+
const domain = this.canonicalDomain(url.host);
|
|
191
|
+
return cookies.filter((cookie) => {
|
|
192
|
+
if (!cookie.path || !cookie.domain) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
return this.matchesDomain(cookie.domain, domain) && this.matchesPath(cookie.path, url);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Gets the path for a domain as defined in
|
|
200
|
+
* https://tools.ietf.org/html/rfc6265#section-5.1.4
|
|
201
|
+
*/
|
|
202
|
+
static getPath(url) {
|
|
203
|
+
let value = url.pathname;
|
|
204
|
+
// /a/b/c -> /a/b
|
|
205
|
+
// /a/b/c/ -> /a/b/c
|
|
206
|
+
// /a -> /
|
|
207
|
+
// /a/ -> /a
|
|
208
|
+
let index = value.indexOf('/', 1);
|
|
209
|
+
if (index === -1) {
|
|
210
|
+
return '/';
|
|
211
|
+
}
|
|
212
|
+
index = value.lastIndexOf('/');
|
|
213
|
+
if (index !== 0) {
|
|
214
|
+
value = value.substring(0, index);
|
|
215
|
+
}
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* This follows the algorithm defined in https://tools.ietf.org/html/rfc6265#section-5.1.3
|
|
220
|
+
*
|
|
221
|
+
* @param string A string to test whether it matches the domain.
|
|
222
|
+
* @param domain The domain to compare to
|
|
223
|
+
* @return True if domains matches.
|
|
224
|
+
*/
|
|
225
|
+
static matchesDomain(string, domain) {
|
|
226
|
+
if (!string || !domain) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
let canonicalString = this.canonicalDomain(string);
|
|
230
|
+
const canonicalDomain = this.canonicalDomain(domain);
|
|
231
|
+
if (canonicalString[0] === '.') {
|
|
232
|
+
canonicalString = canonicalString.substring(1);
|
|
233
|
+
}
|
|
234
|
+
// section-5.1.3 p.1
|
|
235
|
+
if (canonicalString === canonicalDomain) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
// section-5.1.3 p.2.1
|
|
239
|
+
// The domain string is a suffix of the string.
|
|
240
|
+
if (canonicalDomain.endsWith(canonicalString)) {
|
|
241
|
+
// section-5.1.3 p.2.2
|
|
242
|
+
// The last character of the string that is not included
|
|
243
|
+
// in the domain string is a %x2E (".") character.
|
|
244
|
+
const index = canonicalDomain.indexOf(canonicalString);
|
|
245
|
+
const char = canonicalDomain.substring(index - 1, index);
|
|
246
|
+
if (char === '.') {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Checks if paths mach as defined in
|
|
254
|
+
* https://tools.ietf.org/html/rfc6265#section-5.1.4
|
|
255
|
+
*
|
|
256
|
+
* Note: This function will return false if the `this.url` was not set.
|
|
257
|
+
*
|
|
258
|
+
* @param cookiePath Path from the cookie.
|
|
259
|
+
* @param url
|
|
260
|
+
* @return True when paths matches.
|
|
261
|
+
*/
|
|
262
|
+
static matchesPath(cookiePath, url) {
|
|
263
|
+
if (!cookiePath) {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
const requestPath = this.getPath(url);
|
|
267
|
+
return this._matchesPath(cookiePath, requestPath);
|
|
268
|
+
// const index = requestPath.indexOf(cookiePath);
|
|
269
|
+
// if (index === 0 && cookiePath[cookiePath.length - 1] === '/') {
|
|
270
|
+
// return true;
|
|
271
|
+
// }
|
|
272
|
+
// if (index === 0 && cookiePath.indexOf('/', 1) === -1) {
|
|
273
|
+
// return true;
|
|
274
|
+
// }
|
|
275
|
+
// if (index === 0) {
|
|
276
|
+
// // eslint-disable-next-line no-plusplus
|
|
277
|
+
// for (let i = 0, len = requestPath.length; i < len; i++) {
|
|
278
|
+
// if (cookiePath.indexOf(requestPath[i]) === -1 && requestPath[i] === '/') {
|
|
279
|
+
// return true;
|
|
280
|
+
// }
|
|
281
|
+
// }
|
|
282
|
+
// }
|
|
283
|
+
}
|
|
284
|
+
static _matchesPath(cookiePath, requestPath) {
|
|
285
|
+
// p1: The cookie-path and the request-path are identical.
|
|
286
|
+
if (requestPath === cookiePath) {
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
// p2,p3: The cookie-path is a prefix of the request-path ...
|
|
290
|
+
if (requestPath.startsWith(cookiePath)) {
|
|
291
|
+
// p2: and the last character of the cookie-path is U+002F ("/").
|
|
292
|
+
if (cookiePath.endsWith('/')) {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
// p3: and the first character of the request-path that is not included in the cookie-path
|
|
296
|
+
// is a U+002F ("/") character.
|
|
297
|
+
if (requestPath.replace(cookiePath, '')[0] === '/') {
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
static matchesCookie(c1, c2) {
|
|
304
|
+
if (c1.name !== c2.name) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
if (!c1.domain || !c2.domain) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
if (!c1.path || !c2.path) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
return this.matchesDomain(c1.domain, c2.domain) && this._matchesPath(c1.path, c2.path);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=CookieParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CookieParser.js","sourceRoot":"","sources":["../../../src/cookies/CookieParser.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD,MAAM,WAAW,GAAyB;IACxC,MAAM;IACN,QAAQ;IACR,SAAS;IACT,SAAS;IACT,QAAQ;IACR,UAAU;IACV,UAAU;IACV,UAAU;CACX,CAAC;AAEF,MAAM,OAAO,GAAG;;;;;;;;;;;CAWf;KACE,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;KAC3B,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;KAClB,IAAI,EAAE,CAAC;AAEV,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB;;;;;OAKG;IACH,MAAM,CAAC,kBAAkB,CAAC,GAAW;QACnC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,IAAY;QACjC,IAAI,GAAG,GAAG,IAAI,CA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DAA8D;QAC9D,iFAAiF;QACjF,qBAAqB;QACrB,QAAQ;QACR,MAAM;QACN,IAAI;IACN,CAAC;IAES,MAAM,CAAC,YAAY,CAAC,UAAkB,EAAE,WAAmB;QACnE,0DAA0D;QAC1D,IAAI,WAAW,KAAK,UAAU,EAAE;YAC9B,OAAO,IAAI,CAAC;SACb;QAED,6DAA6D;QAC7D,IAAI,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;YACtC,iEAAiE;YACjE,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAC5B,OAAO,IAAI,CAAC;aACb;YACD,2FAA2F;YAC3F,+BAA+B;YAC/B,IAAI,WAAW,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBAClD,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,EAAc,EAAE,EAAc;QACjD,IAAI,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,EAAE;YACvB,OAAO,KAAK,CAAC;SACd;QACD,IAAI,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE;YAC5B,OAAO,KAAK,CAAC;SACd;QACD,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE;YACxB,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IACzF,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CookieJar } from "./CookieJar.js";
|
|
2
|
+
import { IHttpCookie, HttpCookie } from '../models/HttpCookie.js';
|
|
3
|
+
export declare function clearStore(): void;
|
|
4
|
+
export declare class InMemoryCookieJar extends CookieJar {
|
|
5
|
+
/**
|
|
6
|
+
* Clears the memory store from all values.
|
|
7
|
+
*/
|
|
8
|
+
clear(): void;
|
|
9
|
+
deleteCookies(requestUrl: string, name?: string): Promise<void>;
|
|
10
|
+
listCookies(url: string): Promise<HttpCookie[]>;
|
|
11
|
+
setCookies(url: string, cookies: HttpCookie[] | IHttpCookie[]): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { CookieJar } from "./CookieJar.js";
|
|
2
|
+
import { CookieParser } from "./CookieParser.js";
|
|
3
|
+
import { HttpCookie } from '../models/HttpCookie.js';
|
|
4
|
+
const cache = [];
|
|
5
|
+
export function clearStore() {
|
|
6
|
+
cache.splice(0);
|
|
7
|
+
}
|
|
8
|
+
export class InMemoryCookieJar extends CookieJar {
|
|
9
|
+
/**
|
|
10
|
+
* Clears the memory store from all values.
|
|
11
|
+
*/
|
|
12
|
+
clear() {
|
|
13
|
+
cache.splice(0);
|
|
14
|
+
}
|
|
15
|
+
async deleteCookies(requestUrl, name) {
|
|
16
|
+
const url = new URL(requestUrl);
|
|
17
|
+
const domain = CookieParser.canonicalDomain(url.host);
|
|
18
|
+
for (let i = cache.length - 1; i >= 0; i--) {
|
|
19
|
+
const cookie = cache[i];
|
|
20
|
+
if (!cookie.path || !cookie.domain) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (name && name !== cookie.name) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (CookieParser.matchesDomain(cookie.domain, domain) && CookieParser.matchesPath(cookie.path, url)) {
|
|
27
|
+
cache.splice(i, 1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async listCookies(url) {
|
|
32
|
+
return CookieParser.filterCookies(cache, url);
|
|
33
|
+
}
|
|
34
|
+
async setCookies(url, cookies) {
|
|
35
|
+
const uri = new URL(url);
|
|
36
|
+
const domain = CookieParser.canonicalDomain(uri.host);
|
|
37
|
+
const path = CookieParser.getPath(uri);
|
|
38
|
+
cookies.forEach((cookie) => {
|
|
39
|
+
let typed;
|
|
40
|
+
if (typeof cookie.toJSON !== 'function') {
|
|
41
|
+
typed = new HttpCookie(cookie);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
typed = cookie;
|
|
45
|
+
}
|
|
46
|
+
if (!typed.path) {
|
|
47
|
+
typed.path = path;
|
|
48
|
+
}
|
|
49
|
+
if (!typed.domain) {
|
|
50
|
+
// point 6. of https://tools.ietf.org/html/rfc6265#section-5.3
|
|
51
|
+
typed.domain = domain;
|
|
52
|
+
typed.hostOnly = true;
|
|
53
|
+
}
|
|
54
|
+
else if (typed.domain[0] !== '.') {
|
|
55
|
+
// https://stackoverflow.com/a/1063760/1127848
|
|
56
|
+
typed.domain = `.${typed.domain}`;
|
|
57
|
+
}
|
|
58
|
+
const index = cache.findIndex(cached => CookieParser.matchesCookie(typed, cached));
|
|
59
|
+
if (index >= 0) {
|
|
60
|
+
cache[index] = typed;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
cache.push(typed);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=InMemoryCookieJar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InMemoryCookieJar.js","sourceRoot":"","sources":["../../../src/cookies/InMemoryCookieJar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAe,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAElE,MAAM,KAAK,GAAiB,EAAE,CAAC;AAE/B,MAAM,UAAU,UAAU;IACxB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAA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OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,IAAI,KAAiB,CAAC;YACtB,IAAI,OAAQ,MAAqB,CAAC,MAAM,KAAK,UAAU,EAAE;gBACvD,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;aAChC;iBAAM;gBACL,KAAK,GAAG,MAAoB,CAAC;aAC9B;YACD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;gBACf,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;aACnB;YACD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;gBACjB,8DAA8D;gBAC9D,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;gBACtB,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;aACvB;iBAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBAClC,8CAA8C;gBAC9C,KAAK,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;aACnC;YACD,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;YACnF,IAAI,KAAK,IAAI,CAAC,EAAE;gBACd,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;aACtB;iBAAM;gBACL,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a short copy of https://github.com/mathiasbynens/punycode.js/blob/master/punycode.js
|
|
3
|
+
* but written for ESM and browsers.
|
|
4
|
+
* All credits to the original author: Mathias Bynens
|
|
5
|
+
*/
|
|
6
|
+
export declare class Punycode {
|
|
7
|
+
static toASCII(input: string): string;
|
|
8
|
+
protected static encode(value: string): string;
|
|
9
|
+
protected static digitToBasic(digit: number, flag: number): number;
|
|
10
|
+
protected static adapt(delta: number, numPoints: number, firstTime: boolean): number;
|
|
11
|
+
protected static ucs2decode(input: string): number[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
|
|
2
|
+
const regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
|
|
3
|
+
const maxInt = 2147483647;
|
|
4
|
+
const base = 36;
|
|
5
|
+
const tMin = 1;
|
|
6
|
+
const tMax = 26;
|
|
7
|
+
const damp = 700;
|
|
8
|
+
const skew = 38;
|
|
9
|
+
const baseMinusTMin = base - tMin;
|
|
10
|
+
const overflowError = 'Overflow: input needs wider integers to process';
|
|
11
|
+
/**
|
|
12
|
+
* This is a short copy of https://github.com/mathiasbynens/punycode.js/blob/master/punycode.js
|
|
13
|
+
* but written for ESM and browsers.
|
|
14
|
+
* All credits to the original author: Mathias Bynens
|
|
15
|
+
*/
|
|
16
|
+
export class Punycode {
|
|
17
|
+
static toASCII(input) {
|
|
18
|
+
let result = '';
|
|
19
|
+
const parts = input.split('@');
|
|
20
|
+
if (parts.length > 1) {
|
|
21
|
+
result = parts[0] + '@';
|
|
22
|
+
input = parts[1];
|
|
23
|
+
}
|
|
24
|
+
input = input.replace(regexSeparators, '\x2E');
|
|
25
|
+
const labels = input.split('.');
|
|
26
|
+
const encoded = labels.map((part) => {
|
|
27
|
+
return regexNonASCII.test(part) ? 'xn--' + this.encode(part) : part;
|
|
28
|
+
}).join('.');
|
|
29
|
+
return result + encoded;
|
|
30
|
+
}
|
|
31
|
+
static encode(value) {
|
|
32
|
+
const output = [];
|
|
33
|
+
const input = this.ucs2decode(value);
|
|
34
|
+
const inputLength = input.length;
|
|
35
|
+
let n = 128;
|
|
36
|
+
let delta = 0;
|
|
37
|
+
let bias = 72;
|
|
38
|
+
for (const currentValue of input) {
|
|
39
|
+
if (currentValue < 0x80) {
|
|
40
|
+
output.push(String.fromCharCode(currentValue));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const basicLength = output.length;
|
|
44
|
+
let handledCPCount = basicLength;
|
|
45
|
+
if (basicLength) {
|
|
46
|
+
output.push('-');
|
|
47
|
+
}
|
|
48
|
+
while (handledCPCount < inputLength) {
|
|
49
|
+
let m = maxInt;
|
|
50
|
+
for (const currentValue of input) {
|
|
51
|
+
if (currentValue >= n && currentValue < m) {
|
|
52
|
+
m = currentValue;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const handledCPCountPlusOne = handledCPCount + 1;
|
|
56
|
+
if (m - n > Math.floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
57
|
+
throw new RangeError(overflowError);
|
|
58
|
+
}
|
|
59
|
+
delta += (m - n) * handledCPCountPlusOne;
|
|
60
|
+
n = m;
|
|
61
|
+
for (const currentValue of input) {
|
|
62
|
+
if (currentValue < n && ++delta > maxInt) {
|
|
63
|
+
throw new RangeError(overflowError);
|
|
64
|
+
}
|
|
65
|
+
if (currentValue == n) {
|
|
66
|
+
// Represent delta as a generalized variable-length integer.
|
|
67
|
+
let q = delta;
|
|
68
|
+
for (let k = base; /* no condition */; k += base) {
|
|
69
|
+
const t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
70
|
+
if (q < t) {
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
const qMinusT = q - t;
|
|
74
|
+
const baseMinusT = base - t;
|
|
75
|
+
output.push(String.fromCharCode(this.digitToBasic(t + qMinusT % baseMinusT, 0)));
|
|
76
|
+
q = Math.floor(qMinusT / baseMinusT);
|
|
77
|
+
}
|
|
78
|
+
output.push(String.fromCharCode(this.digitToBasic(q, 0)));
|
|
79
|
+
bias = this.adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
|
|
80
|
+
delta = 0;
|
|
81
|
+
++handledCPCount;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
++delta;
|
|
85
|
+
++n;
|
|
86
|
+
}
|
|
87
|
+
return output.join('');
|
|
88
|
+
}
|
|
89
|
+
static digitToBasic(digit, flag) {
|
|
90
|
+
return digit + 22 + 75 * (digit < 26 ? 1 : 0) - ((flag !== 0 ? 1 : 0) << 5);
|
|
91
|
+
}
|
|
92
|
+
static adapt(delta, numPoints, firstTime) {
|
|
93
|
+
let k = 0;
|
|
94
|
+
delta = firstTime ? Math.floor(delta / damp) : delta >> 1;
|
|
95
|
+
delta += Math.floor(delta / numPoints);
|
|
96
|
+
for ( /* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
|
|
97
|
+
delta = Math.floor(delta / baseMinusTMin);
|
|
98
|
+
}
|
|
99
|
+
return Math.floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
100
|
+
}
|
|
101
|
+
static ucs2decode(input) {
|
|
102
|
+
const result = [];
|
|
103
|
+
let i = 0;
|
|
104
|
+
const len = input.length;
|
|
105
|
+
while (i < len) {
|
|
106
|
+
const value = input.charCodeAt(i++);
|
|
107
|
+
if (value >= 0xD800 && value <= 0xDBFF && i < len) {
|
|
108
|
+
const extra = input.charCodeAt(i++);
|
|
109
|
+
if ((extra & 0xFC00) == 0xDC00) {
|
|
110
|
+
result.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
result.push(value);
|
|
114
|
+
i--;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
result.push(value);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=Punycode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Punycode.js","sourceRoot":"","sources":["../../../src/cookies/Punycode.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,2BAA2B,CAAC,CAAC,sBAAsB;AAC3E,MAAM,aAAa,G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