@api-client/core 0.3.1 → 0.3.4
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 +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js.map +1 -1
- package/build/src/models/Backend.d.ts +22 -0
- package/build/src/runtime/store/StoreSdk.d.ts +192 -12
- package/build/src/runtime/store/StoreSdk.js +592 -53
- package/build/src/runtime/store/StoreSdk.js.map +1 -1
- package/package.json +3 -1
- package/src/data/DataReader.ts +11 -0
- package/src/data/DataUtils.ts +108 -0
- package/src/data/JmesparthReader.ts +26 -0
- package/src/data/Json2Xml.ts +190 -0
- package/src/data/JsonReader.ts +41 -0
- package/src/data/PayloadPointer.ts +48 -0
- package/src/data/RequestDataExtractor.ts +133 -0
- package/src/data/UrlEncodedReader.ts +20 -0
- package/src/data/XmlReader.ts +103 -0
- package/src/events/BaseEvents.ts +259 -0
- package/src/events/CustomEvent.ts +27 -0
- package/src/events/EventTypes.ts +19 -0
- package/src/events/Events.ts +19 -0
- package/src/events/authorization/AuthorizationEventTypes.ts +22 -0
- package/src/events/authorization/AuthorizationEvents.ts +61 -0
- package/src/events/cookies/CookieEventTypes.ts +13 -0
- package/src/events/cookies/CookieEvents.ts +157 -0
- package/src/events/encryption/EncryptionEventTypes.ts +4 -0
- package/src/events/encryption/EncryptionEvents.ts +51 -0
- package/src/events/environment/EnvironmentEventTypes.ts +3 -0
- package/src/events/environment/EnvironmentEvents.ts +24 -0
- package/src/events/models/ClientCertificateEvents.ts +87 -0
- package/src/events/models/ModelEventTypes.ts +47 -0
- package/src/events/models/ModelEvents.ts +7 -0
- package/src/events/models/ProjectEvents.ts +331 -0
- package/src/events/process/ProcessEventTypes.ts +5 -0
- package/src/events/process/ProcessEvents.ts +76 -0
- package/src/events/readme.md +22 -0
- package/src/events/reporting/ReportingEventTypes.ts +3 -0
- package/src/events/reporting/ReportingEvents.ts +28 -0
- package/src/events/telemetry/TelemetryEventTypes.ts +10 -0
- package/src/events/telemetry/TelemetryEvents.ts +156 -0
- package/src/lib/cookies/Cookie.ts +312 -0
- package/src/lib/cookies/Cookies.ts +326 -0
- package/src/lib/cookies/Utils.ts +168 -0
- package/src/lib/headers/Headers.ts +219 -0
- package/src/lib/logging/DefaultLogger.ts +19 -0
- package/src/lib/logging/DummyLogger.ts +21 -0
- package/src/lib/logging/Logger.ts +16 -0
- package/src/lib/transformers/PayloadSerializer.ts +332 -0
- package/src/lib/transformers/Utils.ts +18 -0
- package/src/lib/uuid.ts +40 -0
- package/src/mocking/LegacyInterfaces.ts +52 -0
- package/src/mocking/LegacyMock.ts +37 -0
- package/src/mocking/legacy/Authorization.ts +39 -0
- package/src/mocking/legacy/Certificates.ts +145 -0
- package/src/mocking/legacy/Cookies.ts +51 -0
- package/src/mocking/legacy/HostRules.ts +43 -0
- package/src/mocking/legacy/Http.ts +236 -0
- package/src/mocking/legacy/HttpResponse.ts +106 -0
- package/src/mocking/legacy/RestApi.ts +68 -0
- package/src/mocking/legacy/Urls.ts +44 -0
- package/src/mocking/legacy/Variables.ts +53 -0
- package/src/models/ArcResponse.ts +166 -0
- package/src/models/Authorization.ts +481 -0
- package/src/models/AuthorizationData.ts +60 -0
- package/src/models/Backend.ts +107 -0
- package/src/models/ClientCertificate.ts +68 -0
- package/src/models/Environment.ts +279 -0
- package/src/models/ErrorResponse.ts +101 -0
- package/src/models/HistoryIndex.ts +76 -0
- package/src/models/HistoryRequest.ts +28 -0
- package/src/models/HostRule.ts +163 -0
- package/src/models/HttpCookie.ts +285 -0
- package/src/models/HttpProject.ts +1294 -0
- package/src/models/HttpProjectListItem.ts +23 -0
- package/src/models/HttpRequest.ts +124 -0
- package/src/models/HttpResponse.ts +143 -0
- package/src/models/License.ts +113 -0
- package/src/models/ProjectDefinitionProperty.ts +40 -0
- package/src/models/ProjectFolder.ts +439 -0
- package/src/models/ProjectItem.ts +135 -0
- package/src/models/ProjectParent.ts +113 -0
- package/src/models/ProjectRequest.ts +277 -0
- package/src/models/ProjectSchema.ts +202 -0
- package/src/models/Property.ts +423 -0
- package/src/models/Provider.ts +98 -0
- package/src/models/README.md +20 -0
- package/src/models/Request.ts +452 -0
- package/src/models/RequestActions.ts +163 -0
- package/src/models/RequestAuthorization.ts +115 -0
- package/src/models/RequestConfig.ts +317 -0
- package/src/models/RequestLog.ts +159 -0
- package/src/models/RequestTime.ts +108 -0
- package/src/models/RequestUiMeta.ts +258 -0
- package/src/models/RequestsSize.ts +65 -0
- package/src/models/ResponseAuthorization.ts +104 -0
- package/src/models/ResponseRedirect.ts +158 -0
- package/src/models/RevisionInfo.ts +37 -0
- package/src/models/SentRequest.ts +125 -0
- package/src/models/SerializablePayload.ts +68 -0
- package/src/models/Server.ts +153 -0
- package/src/models/Thing.ts +110 -0
- package/src/models/Url.ts +90 -0
- package/src/models/User.ts +120 -0
- package/src/models/WebApi.ts +234 -0
- package/src/models/WebApiIndex.ts +122 -0
- package/src/models/Workspace.ts +182 -0
- package/src/models/actions/Action.ts +213 -0
- package/src/models/actions/ActionView.ts +40 -0
- package/src/models/actions/Condition.ts +207 -0
- package/src/models/actions/ConditionView.ts +42 -0
- package/src/models/actions/Enums.ts +29 -0
- package/src/models/actions/RunnableAction.ts +144 -0
- package/src/models/actions/runnable/DeleteCookieAction.ts +113 -0
- package/src/models/actions/runnable/Runnable.ts +9 -0
- package/src/models/actions/runnable/SetCookieAction.ts +216 -0
- package/src/models/actions/runnable/SetVariableAction.ts +81 -0
- package/src/models/legacy/DataExport.ts +172 -0
- package/src/models/legacy/Normalizer.ts +110 -0
- package/src/models/legacy/actions/Actions.ts +269 -0
- package/src/models/legacy/authorization/Authorization.ts +572 -0
- package/src/models/legacy/models/ApiTypes.ts +202 -0
- package/src/models/legacy/models/ArcLegacyProject.ts +39 -0
- package/src/models/legacy/models/AuthData.ts +17 -0
- package/src/models/legacy/models/ClientCertificate.ts +95 -0
- package/src/models/legacy/models/Cookies.ts +52 -0
- package/src/models/legacy/models/HostRule.ts +35 -0
- package/src/models/legacy/models/RestApi.ts +49 -0
- package/src/models/legacy/models/UrlHistory.ts +37 -0
- package/src/models/legacy/models/Variable.ts +43 -0
- package/src/models/legacy/models/base.d.ts +95 -0
- package/src/models/legacy/request/ArcRequest.ts +405 -0
- package/src/models/legacy/request/ArcResponse.ts +177 -0
- package/src/models/legacy/request/HistoryData.ts +47 -0
- package/src/models/legacy/request/Legacy.ts +45 -0
- package/src/models/legacy/request/RequestBody.ts +87 -0
- package/src/models/transformers/ArcDexieTransformer.ts +323 -0
- package/src/models/transformers/ArcLegacyNormalizer.ts +85 -0
- package/src/models/transformers/ArcLegacyTransformer.ts +200 -0
- package/src/models/transformers/ArcPouchTransformer.ts +184 -0
- package/src/models/transformers/BaseTransformer.ts +116 -0
- package/src/models/transformers/ImportUtils.ts +141 -0
- package/src/models/transformers/LegacyDataExportToApiProject.ts +76 -0
- package/src/models/transformers/LegacyExportProcessor.ts +252 -0
- package/src/models/transformers/PostmanBackupTransformer.ts +306 -0
- package/src/models/transformers/PostmanDataTransformer.ts +50 -0
- package/src/models/transformers/PostmanTransformer.ts +106 -0
- package/src/models/transformers/PostmanV21Transformer.ts +311 -0
- package/src/models/transformers/PostmanV2Transformer.ts +308 -0
- package/src/models/transformers/har.ts +865 -0
- package/src/runtime/actions/ActionRunner.ts +83 -0
- package/src/runtime/actions/ConditionRunner.ts +194 -0
- package/src/runtime/actions/RunnableCondition.ts +57 -0
- package/src/runtime/actions/runnable/ActionRunnable.ts +19 -0
- package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +39 -0
- package/src/runtime/actions/runnable/SetCookieRunnable.ts +92 -0
- package/src/runtime/actions/runnable/SetVariableRunnable.ts +53 -0
- package/src/runtime/http-engine/ArcEngine.ts +1064 -0
- package/src/runtime/http-engine/Errors.ts +13 -0
- package/src/runtime/http-engine/FormData.ts +85 -0
- package/src/runtime/http-engine/HttpEngine.ts +874 -0
- package/src/runtime/http-engine/HttpErrorCodes.ts +270 -0
- package/src/runtime/http-engine/NodeEngine.ts +787 -0
- package/src/runtime/http-engine/NodeEngineDirect.ts +476 -0
- package/src/runtime/http-engine/PayloadSupport.ts +84 -0
- package/src/runtime/http-engine/RequestUtils.ts +164 -0
- package/src/runtime/http-engine/ntlm/Des.ts +345 -0
- package/src/runtime/http-engine/ntlm/MD4.ts +135 -0
- package/src/runtime/http-engine/ntlm/NtlmAuth.ts +186 -0
- package/src/runtime/http-engine/ntlm/NtlmMessage.ts +57 -0
- package/src/runtime/modules/BasicAuthCache.ts +133 -0
- package/src/runtime/modules/ExecutionResponse.ts +4 -0
- package/src/runtime/modules/ModulesRegistry.ts +136 -0
- package/src/runtime/modules/RequestAuthorization.ts +110 -0
- package/src/runtime/modules/RequestCookies.ts +145 -0
- package/src/runtime/node/ProjectRunner.ts +275 -0
- package/src/runtime/node/RequestFactory.ts +422 -0
- package/src/runtime/node/VariablesStore.ts +25 -0
- package/src/runtime/store/StoreSdk.ts +838 -0
- package/src/runtime/variables/Cache.ts +53 -0
- package/src/runtime/variables/EvalFunctions.ts +132 -0
- package/src/runtime/variables/ProjectVariables.ts +6 -0
- package/src/runtime/variables/VariablesProcessor.ts +543 -0
- package/src/runtime/variables/VariablesTokenizer.ts +55 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Lorem, Types } from '@pawel-up/data-mock';
|
|
2
|
+
import { ArcDataMockInit, VariableInit } from '../LegacyInterfaces.js';
|
|
3
|
+
import { ARCVariable } from '../../models/legacy/models/Variable.js';
|
|
4
|
+
|
|
5
|
+
export class Variables {
|
|
6
|
+
types: Types;
|
|
7
|
+
lorem: Lorem;
|
|
8
|
+
|
|
9
|
+
constructor(init: ArcDataMockInit={}) {
|
|
10
|
+
this.types = new Types(init.seed);
|
|
11
|
+
this.lorem = new Lorem(init);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Generates a random variable
|
|
16
|
+
*/
|
|
17
|
+
variable(init: VariableInit={}): ARCVariable {
|
|
18
|
+
let isDefault;
|
|
19
|
+
if (init.defaultEnv) {
|
|
20
|
+
isDefault = true;
|
|
21
|
+
} else if (init.randomEnv) {
|
|
22
|
+
isDefault = false;
|
|
23
|
+
} else {
|
|
24
|
+
isDefault = this.types.boolean();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const result = /** @type ARCVariable */ ({
|
|
28
|
+
enabled: this.types.boolean({ likelihood: 85 }),
|
|
29
|
+
value: this.lorem.sentence({ words: 2 }),
|
|
30
|
+
name: this.lorem.word(),
|
|
31
|
+
_id: this.types.uuid(),
|
|
32
|
+
environment: '',
|
|
33
|
+
});
|
|
34
|
+
if (isDefault) {
|
|
35
|
+
result.environment = 'default';
|
|
36
|
+
} else {
|
|
37
|
+
result.environment = this.lorem.sentence({ words: 2 });
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Generates a number of variables.
|
|
44
|
+
* @param size The number of variables to generate.
|
|
45
|
+
*/
|
|
46
|
+
listVariables(size = 25, init: VariableInit={}): ARCVariable[] {
|
|
47
|
+
const result = [];
|
|
48
|
+
for (let i = 0; i < size; i++) {
|
|
49
|
+
result.push(this.variable(init));
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { IHttpResponse, HttpResponse, Kind } from './HttpResponse.js';
|
|
2
|
+
import { IRequestTime, RequestTime } from './RequestTime.js';
|
|
3
|
+
import { IResponseAuthorization, ResponseAuthorization } from './ResponseAuthorization.js';
|
|
4
|
+
import { IErrorResponse } from './ErrorResponse.js';
|
|
5
|
+
import { Response as LegacyResponse } from './legacy/request/ArcResponse.js';
|
|
6
|
+
import { PayloadSerializer } from '../lib/transformers/PayloadSerializer.js';
|
|
7
|
+
import { Normalizer } from './legacy/Normalizer.js';
|
|
8
|
+
|
|
9
|
+
export { Kind };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* An HTTP response object.
|
|
13
|
+
*/
|
|
14
|
+
export interface IArcResponse extends IHttpResponse {
|
|
15
|
+
/**
|
|
16
|
+
* The request timings.
|
|
17
|
+
* Some HTTP clients may not give this information.
|
|
18
|
+
*/
|
|
19
|
+
timings?: IRequestTime;
|
|
20
|
+
/**
|
|
21
|
+
* The total loading time (from sending the request to receive the last byte)
|
|
22
|
+
*/
|
|
23
|
+
loadingTime: number;
|
|
24
|
+
/**
|
|
25
|
+
* The authentication request from the server.
|
|
26
|
+
*/
|
|
27
|
+
auth?: IResponseAuthorization;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class ArcResponse extends HttpResponse {
|
|
31
|
+
/**
|
|
32
|
+
* The request timings.
|
|
33
|
+
* Some HTTP clients may not give this information.
|
|
34
|
+
*/
|
|
35
|
+
timings?: RequestTime;
|
|
36
|
+
/**
|
|
37
|
+
* The total loading time (from sending the request to receive the last byte)
|
|
38
|
+
*/
|
|
39
|
+
loadingTime = 0;
|
|
40
|
+
/**
|
|
41
|
+
* The authentication request from the server.
|
|
42
|
+
*/
|
|
43
|
+
auth?: ResponseAuthorization;
|
|
44
|
+
|
|
45
|
+
static fromValues(status: number, statusText?: string, headers?: string): ArcResponse {
|
|
46
|
+
return new ArcResponse({
|
|
47
|
+
kind: Kind,
|
|
48
|
+
status,
|
|
49
|
+
statusText,
|
|
50
|
+
headers,
|
|
51
|
+
loadingTime: 0,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static async fromLegacy(input: LegacyResponse): Promise<ArcResponse> {
|
|
56
|
+
const init: IArcResponse = {
|
|
57
|
+
kind: Kind,
|
|
58
|
+
status: input.status || 0,
|
|
59
|
+
loadingTime: input.loadingTime || 0,
|
|
60
|
+
};
|
|
61
|
+
if (input.headers) {
|
|
62
|
+
init.headers = input.headers;
|
|
63
|
+
}
|
|
64
|
+
if (input.statusText) {
|
|
65
|
+
init.statusText = input.statusText;
|
|
66
|
+
}
|
|
67
|
+
if (input.payload) {
|
|
68
|
+
const orig = Normalizer.restoreTransformedPayload(input.payload);
|
|
69
|
+
if (orig) {
|
|
70
|
+
init.payload = await PayloadSerializer.serialize(orig);
|
|
71
|
+
}
|
|
72
|
+
} else if (input.blob) {
|
|
73
|
+
init.payload = {
|
|
74
|
+
type: 'blob',
|
|
75
|
+
data: input.blob,
|
|
76
|
+
};
|
|
77
|
+
} else if (input.multipart) {
|
|
78
|
+
init.payload = {
|
|
79
|
+
type: 'formdata',
|
|
80
|
+
data: input.multipart,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (input.timings) {
|
|
84
|
+
init.timings = new RequestTime(input.timings).toJSON();
|
|
85
|
+
}
|
|
86
|
+
return new ArcResponse(init);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param input The response definition used to restore the state.
|
|
91
|
+
*/
|
|
92
|
+
constructor(input?: string|IArcResponse) {
|
|
93
|
+
super();
|
|
94
|
+
let init: IArcResponse;
|
|
95
|
+
if (typeof input === 'string') {
|
|
96
|
+
init = JSON.parse(input);
|
|
97
|
+
} else if (typeof input === 'object') {
|
|
98
|
+
init = input;
|
|
99
|
+
} else {
|
|
100
|
+
init = {
|
|
101
|
+
kind: Kind,
|
|
102
|
+
status: 0,
|
|
103
|
+
loadingTime: 0,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
this.new(init);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Creates a new response clearing anything that is so far defined.
|
|
111
|
+
*
|
|
112
|
+
* Note, this throws an error when the object is not an ARC response.
|
|
113
|
+
*/
|
|
114
|
+
new(init: IArcResponse): void {
|
|
115
|
+
super.new(init);
|
|
116
|
+
const { loadingTime=0, timings, auth } = init;
|
|
117
|
+
this.loadingTime = loadingTime;
|
|
118
|
+
if (timings) {
|
|
119
|
+
this.timings = new RequestTime(timings);
|
|
120
|
+
} else {
|
|
121
|
+
this.timings = undefined;
|
|
122
|
+
}
|
|
123
|
+
if (auth) {
|
|
124
|
+
this.auth = new ResponseAuthorization(auth);
|
|
125
|
+
} else {
|
|
126
|
+
this.auth = undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
toJSON(): IArcResponse {
|
|
131
|
+
const response = super.toJSON() as IArcResponse;
|
|
132
|
+
response.loadingTime = this.loadingTime;
|
|
133
|
+
if (this.timings) {
|
|
134
|
+
response.timings = this.timings.toJSON();
|
|
135
|
+
}
|
|
136
|
+
if (this.auth) {
|
|
137
|
+
response.auth = this.auth.toJSON();
|
|
138
|
+
}
|
|
139
|
+
return response;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Checks whether the object (JSON Object) is an Error response.
|
|
144
|
+
*/
|
|
145
|
+
static isErrorResponse(input: unknown): boolean {
|
|
146
|
+
const typed = input as IErrorResponse;
|
|
147
|
+
if (typed.error) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Creates the RequestTime object from the passed object.
|
|
155
|
+
*/
|
|
156
|
+
setTimings(timings: IRequestTime): void {
|
|
157
|
+
this.timings = new RequestTime(timings);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Sets the authorization data on the response.
|
|
162
|
+
*/
|
|
163
|
+
setAuth(auth: IResponseAuthorization): void {
|
|
164
|
+
this.auth = new ResponseAuthorization(auth);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
export interface IBasicAuthorization {
|
|
2
|
+
/**
|
|
3
|
+
* User name value.
|
|
4
|
+
*/
|
|
5
|
+
username?: string;
|
|
6
|
+
/**
|
|
7
|
+
* User password value.
|
|
8
|
+
*/
|
|
9
|
+
password?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IBearerAuthorization {
|
|
13
|
+
/**
|
|
14
|
+
* Bearer token value
|
|
15
|
+
*/
|
|
16
|
+
token: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface INtlmAuthorization {
|
|
20
|
+
/**
|
|
21
|
+
* User name value.
|
|
22
|
+
*/
|
|
23
|
+
username?: string;
|
|
24
|
+
/**
|
|
25
|
+
* User password value.
|
|
26
|
+
*/
|
|
27
|
+
password?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Authorization domain
|
|
30
|
+
*/
|
|
31
|
+
domain: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IDigestAuthorization {
|
|
35
|
+
username?: string;
|
|
36
|
+
password?: string;
|
|
37
|
+
realm: string;
|
|
38
|
+
nonce: string;
|
|
39
|
+
uri: string;
|
|
40
|
+
qop: string;
|
|
41
|
+
opaque: string;
|
|
42
|
+
response: string;
|
|
43
|
+
nc: string | number;
|
|
44
|
+
cnonce: string;
|
|
45
|
+
algorithm: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface IOAuth1Authorization {
|
|
49
|
+
consumerKey: string;
|
|
50
|
+
consumerSecret: string;
|
|
51
|
+
token: string;
|
|
52
|
+
tokenSecret: string;
|
|
53
|
+
timestamp: string | number;
|
|
54
|
+
nonce: string;
|
|
55
|
+
realm: string;
|
|
56
|
+
signatureMethod: string;
|
|
57
|
+
requestTokenUri: string;
|
|
58
|
+
accessTokenUri: string;
|
|
59
|
+
redirectUri: string;
|
|
60
|
+
authParamsLocation: string;
|
|
61
|
+
authTokenMethod: string;
|
|
62
|
+
authorizationUri: string;
|
|
63
|
+
type: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Client Certificate Authorization
|
|
68
|
+
*/
|
|
69
|
+
export interface ICCAuthorization {
|
|
70
|
+
/**
|
|
71
|
+
* The ID of the certificate to use.
|
|
72
|
+
* Because the certificates are stored by the application
|
|
73
|
+
* this configuration only returns an ID of the certificate
|
|
74
|
+
* to use when making the request.
|
|
75
|
+
*/
|
|
76
|
+
id: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export declare interface IOAuth2CustomParameter {
|
|
80
|
+
/**
|
|
81
|
+
* The name of the parameter
|
|
82
|
+
*/
|
|
83
|
+
name: string;
|
|
84
|
+
/**
|
|
85
|
+
* The value of the parameter. It is ALWAYS a string.
|
|
86
|
+
*/
|
|
87
|
+
value: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface IOAuth2TokenRequestCustomData {
|
|
91
|
+
/**
|
|
92
|
+
* The query parameters to use with the token request
|
|
93
|
+
*/
|
|
94
|
+
parameters?: IOAuth2CustomParameter[];
|
|
95
|
+
/**
|
|
96
|
+
* The headers to use with the token request
|
|
97
|
+
*/
|
|
98
|
+
headers?: IOAuth2CustomParameter[];
|
|
99
|
+
/**
|
|
100
|
+
* The body parameters to use with the token request.
|
|
101
|
+
* This is x-www-urlencoded parameters to be added to the message.
|
|
102
|
+
*/
|
|
103
|
+
body?: IOAuth2CustomParameter[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface IOAuth2AuthorizationRequestCustomData {
|
|
107
|
+
/**
|
|
108
|
+
* The query parameters to add to the authorization URI
|
|
109
|
+
*/
|
|
110
|
+
parameters?: IOAuth2CustomParameter[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface IOAuth2CustomData {
|
|
114
|
+
/**
|
|
115
|
+
* The custom data to set on the authorization URI when opening the auth popup.
|
|
116
|
+
*/
|
|
117
|
+
auth?: IOAuth2AuthorizationRequestCustomData;
|
|
118
|
+
/**
|
|
119
|
+
* The custom data to be set on the token request.
|
|
120
|
+
*/
|
|
121
|
+
token?: IOAuth2TokenRequestCustomData;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare interface IBaseOAuth2Authorization {
|
|
125
|
+
/**
|
|
126
|
+
* OAuth flow with `interactive` option set to `false` allows to quietly request for the token from the cache or form the authorization server
|
|
127
|
+
* without notifying the user (without bringing the authorization pop-up).
|
|
128
|
+
*
|
|
129
|
+
* This is to be used to check if valid session exists for current user and update the UI accordingly.
|
|
130
|
+
*/
|
|
131
|
+
interactive?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* List of scopes to be used with the token request.
|
|
134
|
+
* This parameter is not required per OAuth2 spec.
|
|
135
|
+
*/
|
|
136
|
+
scopes?: string[];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* OAuth 2 configuration object used in the API Client and API Components.
|
|
141
|
+
*/
|
|
142
|
+
export interface IOAuth2Authorization extends IBaseOAuth2Authorization {
|
|
143
|
+
/**
|
|
144
|
+
* The grant type of the OAuth 2 flow.
|
|
145
|
+
*
|
|
146
|
+
* Can be:
|
|
147
|
+
* - implicit - deprecated and legacy
|
|
148
|
+
* - authorization_code
|
|
149
|
+
* - password - deprecated and legacy
|
|
150
|
+
* - client_credentials
|
|
151
|
+
* - refresh_token
|
|
152
|
+
* - any custom grant supported by the authorization server
|
|
153
|
+
*/
|
|
154
|
+
grantType?: 'implicit' | 'authorization_code' | 'password' | 'client_credentials' | 'refresh_token' | string;
|
|
155
|
+
/**
|
|
156
|
+
* Optional value to set on the `response_type` parameter.
|
|
157
|
+
*/
|
|
158
|
+
responseType?: string;
|
|
159
|
+
/**
|
|
160
|
+
* The client ID registered in the OAuth2 provider.
|
|
161
|
+
*/
|
|
162
|
+
clientId?: string;
|
|
163
|
+
/**
|
|
164
|
+
* The client ID registered in the OAuth2 provider.
|
|
165
|
+
* This value is not required for select grant types.
|
|
166
|
+
*/
|
|
167
|
+
clientSecret?: string;
|
|
168
|
+
/**
|
|
169
|
+
* The user authorization URI as defined by the authorization server.
|
|
170
|
+
* This is required for the `implicit` and `authorization_code` grant types
|
|
171
|
+
*/
|
|
172
|
+
authorizationUri?: string;
|
|
173
|
+
/**
|
|
174
|
+
* The token request URI as defined by the authorization server.
|
|
175
|
+
* This is not required for the `implicit` grant type
|
|
176
|
+
*/
|
|
177
|
+
accessTokenUri?: string;
|
|
178
|
+
/**
|
|
179
|
+
* The user redirect URI as configured in the authorization server.
|
|
180
|
+
* This is required for the `implicit` and `authorization_code` grant types.
|
|
181
|
+
*/
|
|
182
|
+
redirectUri?: string;
|
|
183
|
+
/**
|
|
184
|
+
* Required for the `password` grant type
|
|
185
|
+
*/
|
|
186
|
+
username?: string;
|
|
187
|
+
/**
|
|
188
|
+
* Required for the `password` grant type
|
|
189
|
+
*/
|
|
190
|
+
password?: string;
|
|
191
|
+
/**
|
|
192
|
+
* The state parameter as defined in the OAuth2 spec.
|
|
193
|
+
* The state is returned back with the token response.
|
|
194
|
+
*/
|
|
195
|
+
state?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Additional data defined outside the scope of the OAuth2 protocol to be set
|
|
198
|
+
* on both authorization and token requests.
|
|
199
|
+
*/
|
|
200
|
+
customData?: IOAuth2CustomData;
|
|
201
|
+
/**
|
|
202
|
+
* This is not a standard OAuth 2 parameter.
|
|
203
|
+
* Used by Google's oauth 2 server to include already granted to this app
|
|
204
|
+
* scopes to the list of this scopes.
|
|
205
|
+
*/
|
|
206
|
+
includeGrantedScopes?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* This is not a standard OAuth 2 parameter.
|
|
209
|
+
* Used by Google's oauth 2 server. It's the user email, when known.
|
|
210
|
+
*/
|
|
211
|
+
loginHint?: string;
|
|
212
|
+
/**
|
|
213
|
+
* When set the `authorization_code` will use the PKCE extension of the OAuth2
|
|
214
|
+
* to perform the authorization. Default to `false`.
|
|
215
|
+
* This is only relevant when the `authorization_code` grant type is used.
|
|
216
|
+
*/
|
|
217
|
+
pkce?: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* The access token type. Default to `Bearer`
|
|
220
|
+
*/
|
|
221
|
+
tokenType?: string;
|
|
222
|
+
/**
|
|
223
|
+
* The last access token received from the authorization server.
|
|
224
|
+
* This is optional and indicates that the token has been already received.
|
|
225
|
+
* This property should not be stored anywhere.
|
|
226
|
+
*/
|
|
227
|
+
accessToken?: string;
|
|
228
|
+
/**
|
|
229
|
+
* Informs about what filed of the authenticated request the token property should be set.
|
|
230
|
+
* By default the value is `header` which corresponds to the `authorization` by default,
|
|
231
|
+
* but it is configured by the `deliveryName` property.
|
|
232
|
+
*
|
|
233
|
+
* This can be used by the AMF model when the API spec defines where the access token should be
|
|
234
|
+
* put in the authenticated request.
|
|
235
|
+
*
|
|
236
|
+
* @default header
|
|
237
|
+
*/
|
|
238
|
+
deliveryMethod?: OAuth2DeliveryMethod;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The name of the authenticated request property that carries the token.
|
|
242
|
+
* By default it is `authorization` which corresponds to `header` value of the `deliveryMethod` property.
|
|
243
|
+
*
|
|
244
|
+
* By setting both `deliveryMethod` and `deliveryName` you instruct the application (assuming it reads this values)
|
|
245
|
+
* where to put the authorization token.
|
|
246
|
+
*
|
|
247
|
+
* @default authorization
|
|
248
|
+
*/
|
|
249
|
+
deliveryName?: string;
|
|
250
|
+
/**
|
|
251
|
+
* The assertion parameter for the JWT token authorization.
|
|
252
|
+
*
|
|
253
|
+
* @link https://datatracker.ietf.org/doc/html/rfc7523#section-2.1
|
|
254
|
+
*/
|
|
255
|
+
assertion?: string;
|
|
256
|
+
/**
|
|
257
|
+
* The device_code parameter for the device code authorization.
|
|
258
|
+
*
|
|
259
|
+
* @link https://datatracker.ietf.org/doc/html/rfc8628#section-3.4
|
|
260
|
+
*/
|
|
261
|
+
deviceCode?: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export type OAuth2DeliveryMethod = 'header' | 'query' | 'body';
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Options for removing the OAuth 2 token from the cache.
|
|
268
|
+
*/
|
|
269
|
+
export interface ITokenRemoveOptions {
|
|
270
|
+
/**
|
|
271
|
+
* The client id used to issue the token.
|
|
272
|
+
*/
|
|
273
|
+
clientId: string;
|
|
274
|
+
/**
|
|
275
|
+
* The authorization URI used to issue the token.
|
|
276
|
+
* For the request that do not have `authorizationUrl` a value for
|
|
277
|
+
* `accessTokenUri` should be used.
|
|
278
|
+
*/
|
|
279
|
+
authorizationUri: string;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
declare interface ITokenBase {
|
|
283
|
+
/**
|
|
284
|
+
* Whether the token request was marked as interactive.
|
|
285
|
+
*/
|
|
286
|
+
interactive?: boolean;
|
|
287
|
+
/**
|
|
288
|
+
* The request state parameter, if used with the request.
|
|
289
|
+
*/
|
|
290
|
+
state: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* OAuth 2 token response object.
|
|
295
|
+
*/
|
|
296
|
+
export interface ITokenInfo extends ITokenBase {
|
|
297
|
+
/**
|
|
298
|
+
* The access token.
|
|
299
|
+
*/
|
|
300
|
+
accessToken: string;
|
|
301
|
+
/**
|
|
302
|
+
* The access token type.
|
|
303
|
+
*/
|
|
304
|
+
tokenType?: string;
|
|
305
|
+
/**
|
|
306
|
+
* Access token expiration timeout.
|
|
307
|
+
*/
|
|
308
|
+
expiresIn: number;
|
|
309
|
+
/**
|
|
310
|
+
* Access token expiration timestamp
|
|
311
|
+
*/
|
|
312
|
+
expiresAt: number;
|
|
313
|
+
/**
|
|
314
|
+
* When `true` the `expires_in` and `expires_at` are assumed values (1 hour).
|
|
315
|
+
*/
|
|
316
|
+
expiresAssumed?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* The list of scopes the token has been granted
|
|
319
|
+
*/
|
|
320
|
+
scope?: string[];
|
|
321
|
+
/**
|
|
322
|
+
* The refresh token, when requested
|
|
323
|
+
*/
|
|
324
|
+
refreshToken?: string;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
interface IOidcToken {
|
|
328
|
+
/**
|
|
329
|
+
* The response type of the token.
|
|
330
|
+
*/
|
|
331
|
+
responseType: string;
|
|
332
|
+
/**
|
|
333
|
+
* The state passed by the authorization server,
|
|
334
|
+
*/
|
|
335
|
+
state: string;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export interface IOidcTokenInfo extends IOidcToken {
|
|
339
|
+
/**
|
|
340
|
+
* The timestamp when the token response was read.
|
|
341
|
+
* With the combination with `expiresIn` this tells when the token
|
|
342
|
+
* expires +- few seconds (depending onm the network).
|
|
343
|
+
*/
|
|
344
|
+
time: number;
|
|
345
|
+
/**
|
|
346
|
+
* The received access token.
|
|
347
|
+
*/
|
|
348
|
+
accessToken?: string;
|
|
349
|
+
/**
|
|
350
|
+
* The received refresh token.
|
|
351
|
+
*/
|
|
352
|
+
refreshToken?: string;
|
|
353
|
+
/**
|
|
354
|
+
* The received ID token.
|
|
355
|
+
*/
|
|
356
|
+
idToken?: string;
|
|
357
|
+
/**
|
|
358
|
+
* The received from the authorization server code.
|
|
359
|
+
* The code has no use as it probably was exchanged for the token,
|
|
360
|
+
* which invalidates the code.
|
|
361
|
+
*/
|
|
362
|
+
code?: string;
|
|
363
|
+
/**
|
|
364
|
+
* The received from the authorization server token type
|
|
365
|
+
*/
|
|
366
|
+
tokenType?: string;
|
|
367
|
+
/**
|
|
368
|
+
* The received from the authorization server expires_in parameter.
|
|
369
|
+
*/
|
|
370
|
+
expiresIn?: number;
|
|
371
|
+
/**
|
|
372
|
+
* The received from the authorization server scope parameter processed to an array.
|
|
373
|
+
*/
|
|
374
|
+
scope?: string[];
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export interface IOidcTokenError extends IOidcToken {
|
|
378
|
+
/**
|
|
379
|
+
* Whether the token has error when processing it. This is the error message to render to the user.
|
|
380
|
+
*/
|
|
381
|
+
errorDescription?: string;
|
|
382
|
+
/**
|
|
383
|
+
* Whether the token has error when processing it. This is the error code received from the server.
|
|
384
|
+
*/
|
|
385
|
+
error?: string;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface IOauth2GrantType {
|
|
389
|
+
type: string;
|
|
390
|
+
label: string;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export interface IOauth2ResponseType {
|
|
394
|
+
type: string;
|
|
395
|
+
label: string;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* OpenID Connect configuration object used in API Client and API Components.
|
|
400
|
+
*/
|
|
401
|
+
export interface IOidcAuthorization extends IOAuth2Authorization {
|
|
402
|
+
/**
|
|
403
|
+
* The URL of the issuer for discovery.
|
|
404
|
+
*/
|
|
405
|
+
issuerUri?: string;
|
|
406
|
+
/**
|
|
407
|
+
* The list of mist recent tokens requested from the auth server.
|
|
408
|
+
*/
|
|
409
|
+
tokens?: (IOidcTokenInfo | IOidcTokenError)[];
|
|
410
|
+
/**
|
|
411
|
+
* The array index of the token to be used with HTTP request.
|
|
412
|
+
*/
|
|
413
|
+
tokenInUse?: number;
|
|
414
|
+
/**
|
|
415
|
+
* The list of response types supported by the authorization server.
|
|
416
|
+
* Optional, used to restore state.
|
|
417
|
+
*/
|
|
418
|
+
supportedResponses?: IOauth2ResponseType[][];
|
|
419
|
+
/**
|
|
420
|
+
* The list of grant types supported by the authorization server.
|
|
421
|
+
* Optional, used to restore state.
|
|
422
|
+
*/
|
|
423
|
+
grantTypes?: IOauth2GrantType[];
|
|
424
|
+
/**
|
|
425
|
+
* The list of scopes supported by the authorization server.
|
|
426
|
+
* Optional, used to restore state.
|
|
427
|
+
*/
|
|
428
|
+
serverScopes?: string[];
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Token response object.
|
|
433
|
+
*/
|
|
434
|
+
export interface ITokenError {
|
|
435
|
+
/**
|
|
436
|
+
* The error message
|
|
437
|
+
*/
|
|
438
|
+
message: string;
|
|
439
|
+
/**
|
|
440
|
+
* One of the application error codes.
|
|
441
|
+
*/
|
|
442
|
+
code: string;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface IAuthorizationParams {
|
|
446
|
+
header?: Record<string, string>;
|
|
447
|
+
query?: Record<string, string>;
|
|
448
|
+
path?: Record<string, string>;
|
|
449
|
+
cookie?: Record<string, string>;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Authorization configuration for OAS' APiKey
|
|
454
|
+
*/
|
|
455
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
456
|
+
export interface IApiKeyAuthorization extends IAuthorizationParams {
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Authorization configuration for the PassThrough authorization
|
|
461
|
+
*/
|
|
462
|
+
export interface IPassThroughAuthorization {
|
|
463
|
+
/**
|
|
464
|
+
* List of headers to apply to the request
|
|
465
|
+
*/
|
|
466
|
+
header?: Record<string, string>;
|
|
467
|
+
/**
|
|
468
|
+
* List of query parameters to apply to the request
|
|
469
|
+
*/
|
|
470
|
+
query?: Record<string, string>;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Authorization configuration for RAML's custom scheme
|
|
475
|
+
*/
|
|
476
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
477
|
+
export interface IRamlCustomAuthorization extends IPassThroughAuthorization {
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
export type IAuthorizationSettingsUnion = IBasicAuthorization | IBearerAuthorization | INtlmAuthorization | IDigestAuthorization | IOAuth1Authorization | IOAuth2Authorization | ICCAuthorization | IApiKeyAuthorization | IPassThroughAuthorization | IRamlCustomAuthorization | IOidcAuthorization;
|
|
481
|
+
export type AuthorizationType = 'basic' | 'bearer' | 'ntlm' | 'digest' | 'oauth 1' | 'oauth 2' | 'client certificate' | 'api key' | 'pass through' | 'raml custom' | 'open id';
|