@api-client/core 0.3.3 → 0.3.6

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.
Files changed (259) hide show
  1. package/build/browser.d.ts +3 -0
  2. package/build/browser.js +9 -0
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +11 -2
  5. package/build/index.js +20 -2
  6. package/build/index.js.map +1 -1
  7. package/build/src/lib/fs/Fs.d.ts +52 -0
  8. package/build/src/lib/fs/Fs.js +245 -0
  9. package/build/src/lib/fs/Fs.js.map +1 -0
  10. package/build/src/lib/timers/Timers.d.ts +5 -0
  11. package/build/src/lib/timers/Timers.js +10 -0
  12. package/build/src/lib/timers/Timers.js.map +1 -0
  13. package/build/src/mocking/ProjectMock.d.ts +13 -0
  14. package/build/src/mocking/ProjectMock.js +16 -0
  15. package/build/src/mocking/ProjectMock.js.map +1 -0
  16. package/build/src/mocking/lib/Request.d.ts +32 -0
  17. package/build/src/mocking/lib/Request.js +63 -0
  18. package/build/src/mocking/lib/Request.js.map +1 -0
  19. package/build/src/mocking/lib/Response.d.ts +33 -0
  20. package/build/src/mocking/lib/Response.js +79 -0
  21. package/build/src/mocking/lib/Response.js.map +1 -0
  22. package/build/src/models/ErrorResponse.d.ts +5 -4
  23. package/build/src/models/ErrorResponse.js +18 -5
  24. package/build/src/models/ErrorResponse.js.map +1 -1
  25. package/build/src/models/SerializableError.d.ts +30 -0
  26. package/build/src/models/SerializableError.js +63 -0
  27. package/build/src/models/SerializableError.js.map +1 -0
  28. package/build/src/runtime/http-engine/ArcEngine.js +8 -4
  29. package/build/src/runtime/http-engine/ArcEngine.js.map +1 -1
  30. package/build/src/runtime/http-engine/HttpEngine.d.ts +3 -3
  31. package/build/src/runtime/http-engine/HttpEngine.js +3 -3
  32. package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
  33. package/build/src/runtime/http-engine/NodeEngine.js +9 -4
  34. package/build/src/runtime/http-engine/NodeEngine.js.map +1 -1
  35. package/build/src/runtime/http-engine/NodeEngineDirect.js +8 -2
  36. package/build/src/runtime/http-engine/NodeEngineDirect.js.map +1 -1
  37. package/build/src/runtime/node/BaseRunner.d.ts +21 -0
  38. package/build/src/runtime/node/BaseRunner.js +27 -0
  39. package/build/src/runtime/node/BaseRunner.js.map +1 -0
  40. package/build/src/runtime/node/ProjectParallelRunner.d.ts +81 -0
  41. package/build/src/runtime/node/ProjectParallelRunner.js +173 -0
  42. package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -0
  43. package/build/src/runtime/node/ProjectRequestRunner.d.ts +125 -0
  44. package/build/src/runtime/node/ProjectRequestRunner.js +185 -0
  45. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -0
  46. package/build/src/runtime/node/ProjectRunner.d.ts +166 -64
  47. package/build/src/runtime/node/ProjectRunner.js +191 -139
  48. package/build/src/runtime/node/ProjectRunner.js.map +1 -1
  49. package/build/src/runtime/node/ProjectRunnerWorker.d.ts +1 -0
  50. package/build/src/runtime/node/ProjectRunnerWorker.js +58 -0
  51. package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -0
  52. package/build/src/runtime/node/ProjectSerialRunner.d.ts +11 -0
  53. package/build/src/runtime/node/ProjectSerialRunner.js +34 -0
  54. package/build/src/runtime/node/ProjectSerialRunner.js.map +1 -0
  55. package/build/src/runtime/reporters/ProjectRunCliReporter.d.ts +7 -0
  56. package/build/src/runtime/reporters/ProjectRunCliReporter.js +73 -0
  57. package/build/src/runtime/reporters/ProjectRunCliReporter.js.map +1 -0
  58. package/build/src/runtime/reporters/Reporter.d.ts +62 -0
  59. package/build/src/runtime/reporters/Reporter.js +98 -0
  60. package/build/src/runtime/reporters/Reporter.js.map +1 -0
  61. package/build/src/testing/TestCliHelper.d.ts +23 -0
  62. package/build/src/testing/TestCliHelper.js +71 -0
  63. package/build/src/testing/TestCliHelper.js.map +1 -0
  64. package/build/src/testing/getPort.d.ts +52 -0
  65. package/build/src/testing/getPort.js +169 -0
  66. package/build/src/testing/getPort.js.map +1 -0
  67. package/package.json +2 -1
  68. package/src/data/DataReader.ts +11 -0
  69. package/src/data/DataUtils.ts +108 -0
  70. package/src/data/JmesparthReader.ts +26 -0
  71. package/src/data/Json2Xml.ts +190 -0
  72. package/src/data/JsonReader.ts +41 -0
  73. package/src/data/PayloadPointer.ts +48 -0
  74. package/src/data/RequestDataExtractor.ts +133 -0
  75. package/src/data/UrlEncodedReader.ts +20 -0
  76. package/src/data/XmlReader.ts +103 -0
  77. package/src/events/BaseEvents.ts +259 -0
  78. package/src/events/CustomEvent.ts +27 -0
  79. package/src/events/EventTypes.ts +19 -0
  80. package/src/events/Events.ts +19 -0
  81. package/src/events/authorization/AuthorizationEventTypes.ts +22 -0
  82. package/src/events/authorization/AuthorizationEvents.ts +61 -0
  83. package/src/events/cookies/CookieEventTypes.ts +13 -0
  84. package/src/events/cookies/CookieEvents.ts +157 -0
  85. package/src/events/encryption/EncryptionEventTypes.ts +4 -0
  86. package/src/events/encryption/EncryptionEvents.ts +51 -0
  87. package/src/events/environment/EnvironmentEventTypes.ts +3 -0
  88. package/src/events/environment/EnvironmentEvents.ts +24 -0
  89. package/src/events/models/ClientCertificateEvents.ts +87 -0
  90. package/src/events/models/ModelEventTypes.ts +47 -0
  91. package/src/events/models/ModelEvents.ts +7 -0
  92. package/src/events/models/ProjectEvents.ts +331 -0
  93. package/src/events/process/ProcessEventTypes.ts +5 -0
  94. package/src/events/process/ProcessEvents.ts +76 -0
  95. package/src/events/readme.md +22 -0
  96. package/src/events/reporting/ReportingEventTypes.ts +3 -0
  97. package/src/events/reporting/ReportingEvents.ts +28 -0
  98. package/src/events/telemetry/TelemetryEventTypes.ts +10 -0
  99. package/src/events/telemetry/TelemetryEvents.ts +156 -0
  100. package/src/lib/cookies/Cookie.ts +312 -0
  101. package/src/lib/cookies/Cookies.ts +326 -0
  102. package/src/lib/cookies/Utils.ts +168 -0
  103. package/src/lib/fs/Fs.ts +258 -0
  104. package/src/lib/headers/Headers.ts +219 -0
  105. package/src/lib/logging/DefaultLogger.ts +19 -0
  106. package/src/lib/logging/DummyLogger.ts +21 -0
  107. package/src/lib/logging/Logger.ts +16 -0
  108. package/src/lib/timers/Timers.ts +9 -0
  109. package/src/lib/transformers/PayloadSerializer.ts +332 -0
  110. package/src/lib/transformers/Utils.ts +18 -0
  111. package/src/lib/uuid.ts +40 -0
  112. package/src/mocking/LegacyInterfaces.ts +52 -0
  113. package/src/mocking/LegacyMock.ts +37 -0
  114. package/src/mocking/ProjectMock.ts +20 -0
  115. package/src/mocking/legacy/Authorization.ts +39 -0
  116. package/src/mocking/legacy/Certificates.ts +145 -0
  117. package/src/mocking/legacy/Cookies.ts +51 -0
  118. package/src/mocking/legacy/HostRules.ts +43 -0
  119. package/src/mocking/legacy/Http.ts +236 -0
  120. package/src/mocking/legacy/HttpResponse.ts +106 -0
  121. package/src/mocking/legacy/RestApi.ts +68 -0
  122. package/src/mocking/legacy/Urls.ts +44 -0
  123. package/src/mocking/legacy/Variables.ts +53 -0
  124. package/src/mocking/lib/Request.ts +85 -0
  125. package/src/mocking/lib/Response.ts +101 -0
  126. package/src/models/ArcResponse.ts +166 -0
  127. package/src/models/Authorization.ts +481 -0
  128. package/src/models/AuthorizationData.ts +60 -0
  129. package/src/models/Backend.ts +107 -0
  130. package/src/models/ClientCertificate.ts +68 -0
  131. package/src/models/Environment.ts +279 -0
  132. package/src/models/ErrorResponse.ts +113 -0
  133. package/src/models/HistoryIndex.ts +76 -0
  134. package/src/models/HistoryRequest.ts +28 -0
  135. package/src/models/HostRule.ts +163 -0
  136. package/src/models/HttpCookie.ts +285 -0
  137. package/src/models/HttpProject.ts +1294 -0
  138. package/src/models/HttpProjectListItem.ts +23 -0
  139. package/src/models/HttpRequest.ts +124 -0
  140. package/src/models/HttpResponse.ts +143 -0
  141. package/src/models/License.ts +113 -0
  142. package/src/models/ProjectDefinitionProperty.ts +40 -0
  143. package/src/models/ProjectFolder.ts +439 -0
  144. package/src/models/ProjectItem.ts +135 -0
  145. package/src/models/ProjectParent.ts +113 -0
  146. package/src/models/ProjectRequest.ts +277 -0
  147. package/src/models/ProjectSchema.ts +202 -0
  148. package/src/models/Property.ts +423 -0
  149. package/src/models/Provider.ts +98 -0
  150. package/src/models/README.md +20 -0
  151. package/src/models/Request.ts +452 -0
  152. package/src/models/RequestActions.ts +163 -0
  153. package/src/models/RequestAuthorization.ts +115 -0
  154. package/src/models/RequestConfig.ts +317 -0
  155. package/src/models/RequestLog.ts +159 -0
  156. package/src/models/RequestTime.ts +108 -0
  157. package/src/models/RequestUiMeta.ts +258 -0
  158. package/src/models/RequestsSize.ts +65 -0
  159. package/src/models/ResponseAuthorization.ts +104 -0
  160. package/src/models/ResponseRedirect.ts +158 -0
  161. package/src/models/RevisionInfo.ts +37 -0
  162. package/src/models/SentRequest.ts +125 -0
  163. package/src/models/SerializableError.ts +80 -0
  164. package/src/models/SerializablePayload.ts +68 -0
  165. package/src/models/Server.ts +153 -0
  166. package/src/models/Thing.ts +110 -0
  167. package/src/models/Url.ts +90 -0
  168. package/src/models/User.ts +120 -0
  169. package/src/models/WebApi.ts +234 -0
  170. package/src/models/WebApiIndex.ts +122 -0
  171. package/src/models/Workspace.ts +182 -0
  172. package/src/models/actions/Action.ts +213 -0
  173. package/src/models/actions/ActionView.ts +40 -0
  174. package/src/models/actions/Condition.ts +207 -0
  175. package/src/models/actions/ConditionView.ts +42 -0
  176. package/src/models/actions/Enums.ts +29 -0
  177. package/src/models/actions/RunnableAction.ts +144 -0
  178. package/src/models/actions/runnable/DeleteCookieAction.ts +113 -0
  179. package/src/models/actions/runnable/Runnable.ts +9 -0
  180. package/src/models/actions/runnable/SetCookieAction.ts +216 -0
  181. package/src/models/actions/runnable/SetVariableAction.ts +81 -0
  182. package/src/models/legacy/DataExport.ts +172 -0
  183. package/src/models/legacy/Normalizer.ts +110 -0
  184. package/src/models/legacy/actions/Actions.ts +269 -0
  185. package/src/models/legacy/authorization/Authorization.ts +572 -0
  186. package/src/models/legacy/models/ApiTypes.ts +202 -0
  187. package/src/models/legacy/models/ArcLegacyProject.ts +39 -0
  188. package/src/models/legacy/models/AuthData.ts +17 -0
  189. package/src/models/legacy/models/ClientCertificate.ts +95 -0
  190. package/src/models/legacy/models/Cookies.ts +52 -0
  191. package/src/models/legacy/models/HostRule.ts +35 -0
  192. package/src/models/legacy/models/RestApi.ts +49 -0
  193. package/src/models/legacy/models/UrlHistory.ts +37 -0
  194. package/src/models/legacy/models/Variable.ts +43 -0
  195. package/src/models/legacy/models/base.d.ts +95 -0
  196. package/src/models/legacy/request/ArcRequest.ts +405 -0
  197. package/src/models/legacy/request/ArcResponse.ts +177 -0
  198. package/src/models/legacy/request/HistoryData.ts +47 -0
  199. package/src/models/legacy/request/Legacy.ts +45 -0
  200. package/src/models/legacy/request/RequestBody.ts +87 -0
  201. package/src/models/transformers/ArcDexieTransformer.ts +323 -0
  202. package/src/models/transformers/ArcLegacyNormalizer.ts +85 -0
  203. package/src/models/transformers/ArcLegacyTransformer.ts +200 -0
  204. package/src/models/transformers/ArcPouchTransformer.ts +184 -0
  205. package/src/models/transformers/BaseTransformer.ts +116 -0
  206. package/src/models/transformers/ImportUtils.ts +141 -0
  207. package/src/models/transformers/LegacyDataExportToApiProject.ts +76 -0
  208. package/src/models/transformers/LegacyExportProcessor.ts +252 -0
  209. package/src/models/transformers/PostmanBackupTransformer.ts +306 -0
  210. package/src/models/transformers/PostmanDataTransformer.ts +50 -0
  211. package/src/models/transformers/PostmanTransformer.ts +106 -0
  212. package/src/models/transformers/PostmanV21Transformer.ts +311 -0
  213. package/src/models/transformers/PostmanV2Transformer.ts +308 -0
  214. package/src/models/transformers/har.ts +865 -0
  215. package/src/runtime/actions/ActionRunner.ts +83 -0
  216. package/src/runtime/actions/ConditionRunner.ts +194 -0
  217. package/src/runtime/actions/RunnableCondition.ts +57 -0
  218. package/src/runtime/actions/runnable/ActionRunnable.ts +19 -0
  219. package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +39 -0
  220. package/src/runtime/actions/runnable/SetCookieRunnable.ts +92 -0
  221. package/src/runtime/actions/runnable/SetVariableRunnable.ts +53 -0
  222. package/src/runtime/http-engine/ArcEngine.ts +1068 -0
  223. package/src/runtime/http-engine/FormData.ts +85 -0
  224. package/src/runtime/http-engine/HttpEngine.ts +874 -0
  225. package/src/runtime/http-engine/HttpErrorCodes.ts +270 -0
  226. package/src/runtime/http-engine/NodeEngine.ts +792 -0
  227. package/src/runtime/http-engine/NodeEngineDirect.ts +482 -0
  228. package/src/runtime/http-engine/PayloadSupport.ts +84 -0
  229. package/src/runtime/http-engine/RequestUtils.ts +164 -0
  230. package/src/runtime/http-engine/ntlm/Des.ts +345 -0
  231. package/src/runtime/http-engine/ntlm/MD4.ts +135 -0
  232. package/src/runtime/http-engine/ntlm/NtlmAuth.ts +186 -0
  233. package/src/runtime/http-engine/ntlm/NtlmMessage.ts +57 -0
  234. package/src/runtime/modules/BasicAuthCache.ts +133 -0
  235. package/src/runtime/modules/ExecutionResponse.ts +4 -0
  236. package/src/runtime/modules/ModulesRegistry.ts +136 -0
  237. package/src/runtime/modules/RequestAuthorization.ts +110 -0
  238. package/src/runtime/modules/RequestCookies.ts +145 -0
  239. package/src/runtime/node/BaseRunner.ts +29 -0
  240. package/src/runtime/node/ProjectParallelRunner.ts +234 -0
  241. package/src/runtime/node/ProjectRequestRunner.ts +281 -0
  242. package/src/runtime/node/ProjectRunner.ts +374 -0
  243. package/src/runtime/node/ProjectRunnerWorker.ts +62 -0
  244. package/src/runtime/node/ProjectSerialRunner.ts +36 -0
  245. package/src/runtime/node/RequestFactory.ts +422 -0
  246. package/src/runtime/node/VariablesStore.ts +25 -0
  247. package/src/runtime/reporters/ProjectRunCliReporter.ts +79 -0
  248. package/src/runtime/reporters/Reporter.ts +142 -0
  249. package/src/runtime/store/StoreSdk.ts +838 -0
  250. package/src/runtime/variables/Cache.ts +53 -0
  251. package/src/runtime/variables/EvalFunctions.ts +132 -0
  252. package/src/runtime/variables/ProjectVariables.ts +6 -0
  253. package/src/runtime/variables/VariablesProcessor.ts +543 -0
  254. package/src/runtime/variables/VariablesTokenizer.ts +55 -0
  255. package/src/testing/TestCliHelper.ts +76 -0
  256. package/src/testing/getPort.ts +212 -0
  257. package/build/src/runtime/http-engine/Errors.d.ts +0 -10
  258. package/build/src/runtime/http-engine/Errors.js +0 -14
  259. package/build/src/runtime/http-engine/Errors.js.map +0 -1
@@ -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';
@@ -0,0 +1,60 @@
1
+ export interface IAuthorizationData {
2
+ username?: string;
3
+ password?: string;
4
+ domain?: string;
5
+ }
6
+
7
+
8
+ /**
9
+ * Represents an auth data stored in ARC's data store to be retrieved
10
+ * when the response status is 401.
11
+ *
12
+ * Each entry represent a Basic or NTLM authorization.
13
+ */
14
+ export class AuthorizationData {
15
+ username?: string;
16
+ password?: string;
17
+ domain?: string;
18
+
19
+ /**
20
+ * @param input The provider definition used to restore the state.
21
+ */
22
+ constructor(input?: string|IAuthorizationData) {
23
+ let init: IAuthorizationData;
24
+ if (typeof input === 'string') {
25
+ init = JSON.parse(input);
26
+ } else if (typeof input === 'object') {
27
+ init = input;
28
+ } else {
29
+ init = {};
30
+ }
31
+ this.new(init);
32
+ }
33
+
34
+ /**
35
+ * Creates a new provider clearing anything that is so far defined.
36
+ *
37
+ * Note, this throws an error when the provider is not an ARC provider object.
38
+ */
39
+ new(init: IAuthorizationData): void {
40
+ const { username, password, domain } = init;
41
+ this.username = username;
42
+ this.password = password;
43
+ this.domain = domain;
44
+ }
45
+
46
+ toJSON(): IAuthorizationData {
47
+ const result:IAuthorizationData = {
48
+ };
49
+ if (this.username) {
50
+ result.username = this.username;
51
+ }
52
+ if (this.password) {
53
+ result.password = this.password;
54
+ }
55
+ if (this.domain) {
56
+ result.domain = this.domain;
57
+ }
58
+ return result;
59
+ }
60
+ }
@@ -0,0 +1,107 @@
1
+ export type BackendMode = 'single-user' | 'multi-user';
2
+
3
+ export interface IBackendInfo {
4
+ /**
5
+ * The model the store is on.
6
+ *
7
+ * The `single-user` mode is the default mode where external user authentication is not required
8
+ * (but clients must use the auth token issued by the session endpoint).
9
+ *
10
+ * In the `multi-user` model the authentication configuration is required and the user must
11
+ * authenticate through an external identity provider (by default Open ID Connect is supported).
12
+ * After that the client has to create an authenticated session in the store service and use
13
+ * the token with the API calls.
14
+ *
15
+ * @default single-user
16
+ */
17
+ mode: BackendMode;
18
+ /**
19
+ * Optional, the store base path when set on the configuration.
20
+ */
21
+ prefix?: string;
22
+ /**
23
+ * The path to the authentication endpoint.
24
+ */
25
+ authPath: string;
26
+ }
27
+
28
+ export interface IBackendCommand {
29
+ /**
30
+ * Optional path. When not set the path is the URL of the web socket channel.
31
+ */
32
+ path?: string;
33
+ /**
34
+ * The operation to perform
35
+ */
36
+ operation: 'delete' | 'patch' | 'create';
37
+ /**
38
+ * The command data.
39
+ */
40
+ value?: unknown;
41
+ }
42
+
43
+ export interface IBackendMessage {
44
+ /**
45
+ * The message type. Usually it is an `event`, meaning, a data change notification.
46
+ */
47
+ type: 'event';
48
+ /**
49
+ * In most cases an event has data associated with it like the created object or
50
+ * the patch that has been applied to the object.
51
+ * Not set for events related to deleting an object.
52
+ */
53
+ data?: unknown;
54
+ }
55
+
56
+ export interface IBackendEvent extends IBackendMessage {
57
+ /**
58
+ * The operation that has been performed on the resource.
59
+ *
60
+ * Note, `updated` is when the entire object must be revalidated in the opposite
61
+ * to `patch` where the patch should be applied to the object.
62
+ */
63
+ operation: 'created' | 'updated' | 'patch' | 'deleted' | 'access-granted' | 'access-removed';
64
+ /**
65
+ * The kind of data that has been changed.
66
+ */
67
+ kind: string;
68
+ /**
69
+ * For update events it is the key of the updated object.
70
+ */
71
+ id?: string;
72
+ }
73
+
74
+ export interface IListResponse {
75
+ /**
76
+ * The cursor to use with the next query.
77
+ * Not set when no more results.
78
+ */
79
+ cursor?: string;
80
+ /**
81
+ * The list of objects returned from the store.
82
+ */
83
+ data: unknown[];
84
+ }
85
+
86
+ export interface IListOptions {
87
+ /**
88
+ * Page cursor to use with the query.
89
+ */
90
+ cursor?: string;
91
+ /**
92
+ * Number of items in the result.
93
+ * Ignored when `cursor` is set.
94
+ *
95
+ * Note, when changing the number of items in the result
96
+ * you need to start listing over again.
97
+ */
98
+ limit?: number;
99
+ /**
100
+ * Supported by some endpoints. When set it performs a query on the data store.
101
+ */
102
+ query?: string;
103
+ /**
104
+ * Only with the `query` property. Tells the system in which fields to search for the query term.
105
+ */
106
+ queryField?: string[];
107
+ }
@@ -0,0 +1,68 @@
1
+ export type CertificateType = 'p12' | 'pem';
2
+
3
+ /**
4
+ * Represents a single certificate object (cert/key)
5
+ */
6
+ export interface ICertificate {
7
+ /**
8
+ * The certificate to use.
9
+ * The `p12` type certificate must be a Buffer.
10
+ */
11
+ data: string|ArrayBuffer|Buffer|Uint8Array;
12
+ /**
13
+ * A passphrase to use to unlock the certificate.
14
+ */
15
+ passphrase?: string;
16
+ /**
17
+ * The original data type of the certificate. This is used by the data store
18
+ * to move between buffers and string values stored in the store.
19
+ * By any means, outside the internal procedure of the data store this
20
+ * filed is always `undefined` and the `data` contains the original data format.
21
+ */
22
+ type?: string;
23
+ }
24
+
25
+ /**
26
+ * Represents a complete certificate configuration required to make
27
+ * a HTTP request.
28
+ */
29
+ export interface IRequestCertificate {
30
+ /**
31
+ * Certificate type. Either `p12` or `pem`.
32
+ */
33
+ type: CertificateType;
34
+ /**
35
+ * Certificate or list of certificates to use.
36
+ */
37
+ cert: ICertificate|ICertificate[];
38
+ /**
39
+ * Key for the `pem` type certificate.
40
+ */
41
+ key?: ICertificate|ICertificate[];
42
+ }
43
+
44
+ /**
45
+ * Client certificate index definition for listings.
46
+ */
47
+ export interface ICertificateIndex {
48
+ /**
49
+ * Certificate type. Either `p12` or `pem`.
50
+ */
51
+ type: CertificateType;
52
+ /**
53
+ * Custom name of the certificate.
54
+ */
55
+ name: string;
56
+ /**
57
+ * Timestamp when the certificate was inserted into the data store.
58
+ * Required when returning a result. Auto-generated when inserting, if missing.
59
+ */
60
+ created?: number;
61
+ }
62
+
63
+ /**
64
+ * A base client certificate object used in ARC to create / list objects.
65
+ * This is not a data entity but rather something used to outside of a context of a data store.
66
+ */
67
+ export interface IClientCertificate extends IRequestCertificate, ICertificateIndex {
68
+ }