@api-client/core 0.3.3 → 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.
Files changed (176) hide show
  1. package/package.json +1 -1
  2. package/src/data/DataReader.ts +11 -0
  3. package/src/data/DataUtils.ts +108 -0
  4. package/src/data/JmesparthReader.ts +26 -0
  5. package/src/data/Json2Xml.ts +190 -0
  6. package/src/data/JsonReader.ts +41 -0
  7. package/src/data/PayloadPointer.ts +48 -0
  8. package/src/data/RequestDataExtractor.ts +133 -0
  9. package/src/data/UrlEncodedReader.ts +20 -0
  10. package/src/data/XmlReader.ts +103 -0
  11. package/src/events/BaseEvents.ts +259 -0
  12. package/src/events/CustomEvent.ts +27 -0
  13. package/src/events/EventTypes.ts +19 -0
  14. package/src/events/Events.ts +19 -0
  15. package/src/events/authorization/AuthorizationEventTypes.ts +22 -0
  16. package/src/events/authorization/AuthorizationEvents.ts +61 -0
  17. package/src/events/cookies/CookieEventTypes.ts +13 -0
  18. package/src/events/cookies/CookieEvents.ts +157 -0
  19. package/src/events/encryption/EncryptionEventTypes.ts +4 -0
  20. package/src/events/encryption/EncryptionEvents.ts +51 -0
  21. package/src/events/environment/EnvironmentEventTypes.ts +3 -0
  22. package/src/events/environment/EnvironmentEvents.ts +24 -0
  23. package/src/events/models/ClientCertificateEvents.ts +87 -0
  24. package/src/events/models/ModelEventTypes.ts +47 -0
  25. package/src/events/models/ModelEvents.ts +7 -0
  26. package/src/events/models/ProjectEvents.ts +331 -0
  27. package/src/events/process/ProcessEventTypes.ts +5 -0
  28. package/src/events/process/ProcessEvents.ts +76 -0
  29. package/src/events/readme.md +22 -0
  30. package/src/events/reporting/ReportingEventTypes.ts +3 -0
  31. package/src/events/reporting/ReportingEvents.ts +28 -0
  32. package/src/events/telemetry/TelemetryEventTypes.ts +10 -0
  33. package/src/events/telemetry/TelemetryEvents.ts +156 -0
  34. package/src/lib/cookies/Cookie.ts +312 -0
  35. package/src/lib/cookies/Cookies.ts +326 -0
  36. package/src/lib/cookies/Utils.ts +168 -0
  37. package/src/lib/headers/Headers.ts +219 -0
  38. package/src/lib/logging/DefaultLogger.ts +19 -0
  39. package/src/lib/logging/DummyLogger.ts +21 -0
  40. package/src/lib/logging/Logger.ts +16 -0
  41. package/src/lib/transformers/PayloadSerializer.ts +332 -0
  42. package/src/lib/transformers/Utils.ts +18 -0
  43. package/src/lib/uuid.ts +40 -0
  44. package/src/mocking/LegacyInterfaces.ts +52 -0
  45. package/src/mocking/LegacyMock.ts +37 -0
  46. package/src/mocking/legacy/Authorization.ts +39 -0
  47. package/src/mocking/legacy/Certificates.ts +145 -0
  48. package/src/mocking/legacy/Cookies.ts +51 -0
  49. package/src/mocking/legacy/HostRules.ts +43 -0
  50. package/src/mocking/legacy/Http.ts +236 -0
  51. package/src/mocking/legacy/HttpResponse.ts +106 -0
  52. package/src/mocking/legacy/RestApi.ts +68 -0
  53. package/src/mocking/legacy/Urls.ts +44 -0
  54. package/src/mocking/legacy/Variables.ts +53 -0
  55. package/src/models/ArcResponse.ts +166 -0
  56. package/src/models/Authorization.ts +481 -0
  57. package/src/models/AuthorizationData.ts +60 -0
  58. package/src/models/Backend.ts +107 -0
  59. package/src/models/ClientCertificate.ts +68 -0
  60. package/src/models/Environment.ts +279 -0
  61. package/src/models/ErrorResponse.ts +101 -0
  62. package/src/models/HistoryIndex.ts +76 -0
  63. package/src/models/HistoryRequest.ts +28 -0
  64. package/src/models/HostRule.ts +163 -0
  65. package/src/models/HttpCookie.ts +285 -0
  66. package/src/models/HttpProject.ts +1294 -0
  67. package/src/models/HttpProjectListItem.ts +23 -0
  68. package/src/models/HttpRequest.ts +124 -0
  69. package/src/models/HttpResponse.ts +143 -0
  70. package/src/models/License.ts +113 -0
  71. package/src/models/ProjectDefinitionProperty.ts +40 -0
  72. package/src/models/ProjectFolder.ts +439 -0
  73. package/src/models/ProjectItem.ts +135 -0
  74. package/src/models/ProjectParent.ts +113 -0
  75. package/src/models/ProjectRequest.ts +277 -0
  76. package/src/models/ProjectSchema.ts +202 -0
  77. package/src/models/Property.ts +423 -0
  78. package/src/models/Provider.ts +98 -0
  79. package/src/models/README.md +20 -0
  80. package/src/models/Request.ts +452 -0
  81. package/src/models/RequestActions.ts +163 -0
  82. package/src/models/RequestAuthorization.ts +115 -0
  83. package/src/models/RequestConfig.ts +317 -0
  84. package/src/models/RequestLog.ts +159 -0
  85. package/src/models/RequestTime.ts +108 -0
  86. package/src/models/RequestUiMeta.ts +258 -0
  87. package/src/models/RequestsSize.ts +65 -0
  88. package/src/models/ResponseAuthorization.ts +104 -0
  89. package/src/models/ResponseRedirect.ts +158 -0
  90. package/src/models/RevisionInfo.ts +37 -0
  91. package/src/models/SentRequest.ts +125 -0
  92. package/src/models/SerializablePayload.ts +68 -0
  93. package/src/models/Server.ts +153 -0
  94. package/src/models/Thing.ts +110 -0
  95. package/src/models/Url.ts +90 -0
  96. package/src/models/User.ts +120 -0
  97. package/src/models/WebApi.ts +234 -0
  98. package/src/models/WebApiIndex.ts +122 -0
  99. package/src/models/Workspace.ts +182 -0
  100. package/src/models/actions/Action.ts +213 -0
  101. package/src/models/actions/ActionView.ts +40 -0
  102. package/src/models/actions/Condition.ts +207 -0
  103. package/src/models/actions/ConditionView.ts +42 -0
  104. package/src/models/actions/Enums.ts +29 -0
  105. package/src/models/actions/RunnableAction.ts +144 -0
  106. package/src/models/actions/runnable/DeleteCookieAction.ts +113 -0
  107. package/src/models/actions/runnable/Runnable.ts +9 -0
  108. package/src/models/actions/runnable/SetCookieAction.ts +216 -0
  109. package/src/models/actions/runnable/SetVariableAction.ts +81 -0
  110. package/src/models/legacy/DataExport.ts +172 -0
  111. package/src/models/legacy/Normalizer.ts +110 -0
  112. package/src/models/legacy/actions/Actions.ts +269 -0
  113. package/src/models/legacy/authorization/Authorization.ts +572 -0
  114. package/src/models/legacy/models/ApiTypes.ts +202 -0
  115. package/src/models/legacy/models/ArcLegacyProject.ts +39 -0
  116. package/src/models/legacy/models/AuthData.ts +17 -0
  117. package/src/models/legacy/models/ClientCertificate.ts +95 -0
  118. package/src/models/legacy/models/Cookies.ts +52 -0
  119. package/src/models/legacy/models/HostRule.ts +35 -0
  120. package/src/models/legacy/models/RestApi.ts +49 -0
  121. package/src/models/legacy/models/UrlHistory.ts +37 -0
  122. package/src/models/legacy/models/Variable.ts +43 -0
  123. package/src/models/legacy/models/base.d.ts +95 -0
  124. package/src/models/legacy/request/ArcRequest.ts +405 -0
  125. package/src/models/legacy/request/ArcResponse.ts +177 -0
  126. package/src/models/legacy/request/HistoryData.ts +47 -0
  127. package/src/models/legacy/request/Legacy.ts +45 -0
  128. package/src/models/legacy/request/RequestBody.ts +87 -0
  129. package/src/models/transformers/ArcDexieTransformer.ts +323 -0
  130. package/src/models/transformers/ArcLegacyNormalizer.ts +85 -0
  131. package/src/models/transformers/ArcLegacyTransformer.ts +200 -0
  132. package/src/models/transformers/ArcPouchTransformer.ts +184 -0
  133. package/src/models/transformers/BaseTransformer.ts +116 -0
  134. package/src/models/transformers/ImportUtils.ts +141 -0
  135. package/src/models/transformers/LegacyDataExportToApiProject.ts +76 -0
  136. package/src/models/transformers/LegacyExportProcessor.ts +252 -0
  137. package/src/models/transformers/PostmanBackupTransformer.ts +306 -0
  138. package/src/models/transformers/PostmanDataTransformer.ts +50 -0
  139. package/src/models/transformers/PostmanTransformer.ts +106 -0
  140. package/src/models/transformers/PostmanV21Transformer.ts +311 -0
  141. package/src/models/transformers/PostmanV2Transformer.ts +308 -0
  142. package/src/models/transformers/har.ts +865 -0
  143. package/src/runtime/actions/ActionRunner.ts +83 -0
  144. package/src/runtime/actions/ConditionRunner.ts +194 -0
  145. package/src/runtime/actions/RunnableCondition.ts +57 -0
  146. package/src/runtime/actions/runnable/ActionRunnable.ts +19 -0
  147. package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +39 -0
  148. package/src/runtime/actions/runnable/SetCookieRunnable.ts +92 -0
  149. package/src/runtime/actions/runnable/SetVariableRunnable.ts +53 -0
  150. package/src/runtime/http-engine/ArcEngine.ts +1064 -0
  151. package/src/runtime/http-engine/Errors.ts +13 -0
  152. package/src/runtime/http-engine/FormData.ts +85 -0
  153. package/src/runtime/http-engine/HttpEngine.ts +874 -0
  154. package/src/runtime/http-engine/HttpErrorCodes.ts +270 -0
  155. package/src/runtime/http-engine/NodeEngine.ts +787 -0
  156. package/src/runtime/http-engine/NodeEngineDirect.ts +476 -0
  157. package/src/runtime/http-engine/PayloadSupport.ts +84 -0
  158. package/src/runtime/http-engine/RequestUtils.ts +164 -0
  159. package/src/runtime/http-engine/ntlm/Des.ts +345 -0
  160. package/src/runtime/http-engine/ntlm/MD4.ts +135 -0
  161. package/src/runtime/http-engine/ntlm/NtlmAuth.ts +186 -0
  162. package/src/runtime/http-engine/ntlm/NtlmMessage.ts +57 -0
  163. package/src/runtime/modules/BasicAuthCache.ts +133 -0
  164. package/src/runtime/modules/ExecutionResponse.ts +4 -0
  165. package/src/runtime/modules/ModulesRegistry.ts +136 -0
  166. package/src/runtime/modules/RequestAuthorization.ts +110 -0
  167. package/src/runtime/modules/RequestCookies.ts +145 -0
  168. package/src/runtime/node/ProjectRunner.ts +275 -0
  169. package/src/runtime/node/RequestFactory.ts +422 -0
  170. package/src/runtime/node/VariablesStore.ts +25 -0
  171. package/src/runtime/store/StoreSdk.ts +838 -0
  172. package/src/runtime/variables/Cache.ts +53 -0
  173. package/src/runtime/variables/EvalFunctions.ts +132 -0
  174. package/src/runtime/variables/ProjectVariables.ts +6 -0
  175. package/src/runtime/variables/VariablesProcessor.ts +543 -0
  176. package/src/runtime/variables/VariablesTokenizer.ts +55 -0
@@ -0,0 +1,270 @@
1
+ /**
2
+ * List of common error codes
3
+ */
4
+ export class HttpErrorCodes {
5
+ /**
6
+ * @return List of known status codes
7
+ */
8
+ static get codes(): Record<number, string> {
9
+ return {
10
+ 1: 'An asynchronous IO operation is not yet complete.',
11
+ 2: 'A generic failure occurred.',
12
+ 3: 'An operation was aborted (due to user action)',
13
+ 4: 'An argument to the function is incorrect.',
14
+ 5: 'The handle or file descriptor is invalid',
15
+ 6: 'The file or directory cannot be found',
16
+ 7: 'An operation timed out',
17
+ 8: 'The file is too large',
18
+ 9:
19
+ 'An unexpected error. This may be caused by a programming ' +
20
+ 'mistake or an invalid assumption',
21
+ 10: 'Permission to access a resource, other than the network, was denied',
22
+ 11: 'The operation failed because of unimplemented functionality',
23
+ 12: 'There were not enough resources to complete the operation',
24
+ 13: 'Memory allocation failed',
25
+ 14:
26
+ 'The file upload failed because the file\'s modification ' +
27
+ 'time was different from the expectation',
28
+ 15: 'The socket is not connected',
29
+ 16: 'The file already exists',
30
+ 17: 'The path or file name is too long',
31
+ 18: 'Not enough room left on the disk',
32
+ 19: 'The file has a virus',
33
+ 20: 'The client chose to block the request',
34
+ 21: 'The network changed',
35
+ 22:
36
+ 'The request was blocked by the URL blacklist ' +
37
+ 'configured by the domain administrator',
38
+ 23: 'The socket is already connected',
39
+ 100: 'A connection was closed (corresponding to a TCP FIN)',
40
+ 101: 'A connection was reset (corresponding to a TCP RST)',
41
+ 102: 'A connection attempt was refused',
42
+ 103:
43
+ 'A connection timed out as a result of not receiving an ACK for ' +
44
+ 'data sent. This can include a FIN packet that did not get ACK\'d',
45
+ 104: 'A connection attempt failed',
46
+ 105: 'The host name could not be resolved',
47
+ 106: 'The Internet connection has been lost',
48
+ 107: 'An SSL protocol error occurred',
49
+ 108:
50
+ 'The IP address or port number is invalid (e.g., cannot connect ' +
51
+ 'to the IP address 0 or the port 0)',
52
+ 109:
53
+ 'The IP address is unreachable. This usually means that there ' +
54
+ 'is no route to the specified host or network',
55
+ 110:
56
+ 'The server requested a client certificate for SSL client ' +
57
+ 'authentication',
58
+ 111: 'A tunnel connection through the proxy could not be established',
59
+ 112: 'No SSL protocol versions are enabled',
60
+ 113:
61
+ 'The client and server don\'t support a common SSL protocol ' +
62
+ 'version or cipher suite',
63
+ 114: 'The server requested a renegotiation (rehandshake)',
64
+ 115:
65
+ 'The proxy requested authentication (for tunnel establishment) ' +
66
+ 'with an unsupported method',
67
+ 116:
68
+ 'During SSL renegotiation (rehandshake), the server sent a ' +
69
+ 'certificate with an error',
70
+ 117:
71
+ 'The SSL handshake failed because of a bad or missing client' +
72
+ ' certificate',
73
+ 118: 'A connection attempt timed out',
74
+ 119:
75
+ 'There are too many pending DNS resolves, so a request in the ' +
76
+ 'queue was aborted',
77
+ 120:
78
+ 'Failed establishing a connection to the SOCKS proxy server for ' +
79
+ 'a target host',
80
+ 121:
81
+ 'The SOCKS proxy server failed establishing connection to the ' +
82
+ 'target host because that host is unreachable',
83
+ 122: 'The request to negotiate an alternate protocol failed',
84
+ 123: 'The peer sent an SSL no_renegotiation alert message',
85
+ 124:
86
+ 'Winsock sometimes reports more data written than passed. This ' +
87
+ 'is probably due to a broken LSP',
88
+ 125: 'An SSL peer sent us a fatal decompression_failure alert.',
89
+ 126: 'An SSL peer sent us a fatal bad_record_mac alert',
90
+ 127: 'The proxy requested authentication (for tunnel establishment)',
91
+ 128:
92
+ 'A known TLS strict server didn\'t offer the renegotiation ' +
93
+ 'extension',
94
+ 129:
95
+ 'The SSL server attempted to use a weak ephemeral ' +
96
+ 'Diffie-Hellman key',
97
+ 130: 'Could not create a connection to the proxy server.',
98
+ 131: 'A mandatory proxy configuration could not be used.',
99
+ 133:
100
+ 'We\'ve hit the max socket limit for the socket pool ' +
101
+ 'while preconnecting.',
102
+ 134:
103
+ 'The permission to use the SSL client certificate\'s ' +
104
+ 'private key was denied',
105
+ 135: 'The SSL client certificate has no private key',
106
+ 136: 'The certificate presented by the HTTPS Proxy was invalid',
107
+ 137: 'An error occurred when trying to do a name resolution (DNS)',
108
+ 138: 'Permission to access the network was denied.',
109
+ 139: 'The request throttler module cancelled this request to avoid DDOS',
110
+ 140:
111
+ 'A request to create an SSL tunnel connection through the HTTPS ' +
112
+ 'proxy received a non-200 (OK) and non-407 (Proxy Auth) response.',
113
+ 141:
114
+ 'We were unable to sign the CertificateVerify data of an SSL ' +
115
+ 'client auth handshake with the client certificate\'s private key',
116
+ 142: 'The message was too large for the transport',
117
+ 143:
118
+ 'A SPDY session already exists, and should be used instead of ' +
119
+ 'this connection',
120
+ 145: 'Websocket protocol error.',
121
+ 146: 'Connection was aborted for switching to another protocol.',
122
+ 147: 'Returned when attempting to bind an address that is already in use',
123
+ 148: 'An operation failed because the SSL handshake has not completed',
124
+ 149: 'SSL peer\'s public key is invalid',
125
+ 150:
126
+ 'The certificate didn\'t match the built-in public key pins for ' +
127
+ 'the host name',
128
+ 151:
129
+ 'Server request for client certificate did not contain any ' +
130
+ 'types we support',
131
+ 152:
132
+ 'Server requested one type of cert, then requested a different ' +
133
+ 'type while the first was still being generated',
134
+ 153: 'An SSL peer sent us a fatal decrypt_error alert. ',
135
+ 154:
136
+ 'There are too many pending WebSocketJob instances, so the new ' +
137
+ 'job was not pushed to the queue',
138
+ 155:
139
+ 'There are too many active SocketStream instances, so the new ' +
140
+ 'connect request was rejected',
141
+ 156: 'The SSL server certificate changed in a renegotiation',
142
+ 157:
143
+ 'The SSL server indicated that an unnecessary TLS version ' +
144
+ 'fallback was performed',
145
+ 158:
146
+ 'Certificate Transparency: All Signed Certificate ' +
147
+ 'Timestamps failed to verify',
148
+ 159: 'The SSL server sent us a fatal unrecognized_name alert',
149
+ 300: 'The URL is invalid',
150
+ 301: 'The scheme of the URL is disallowed',
151
+ 302: 'The scheme of the URL is unknown',
152
+ 310: 'Attempting to load an URL resulted in too many redirects',
153
+ 311:
154
+ 'Attempting to load an URL resulted in an unsafe redirect ' +
155
+ '(e.g., a redirect to file: is considered unsafe)',
156
+ 312: 'Attempting to load an URL with an unsafe port number.',
157
+ 320: 'The server\'s response was invalid',
158
+ 321: 'Error in chunked transfer encoding',
159
+ 322: 'The server did not support the request method',
160
+ 323:
161
+ 'The response was 407 (Proxy Authentication Required), yet ' +
162
+ 'we did not send the request to a proxy',
163
+ 324: 'The server closed the connection without sending any data',
164
+ 325: 'The headers section of the response is too large',
165
+ 326:
166
+ 'The PAC requested by HTTP did not have a valid status ' +
167
+ 'code (non-200)',
168
+ 327: 'The evaluation of the PAC script failed',
169
+ 328:
170
+ 'The response was 416 (Requested range not satisfiable) ' +
171
+ 'and the server cannot satisfy the range requested',
172
+ 329: 'The identity used for authentication is invalid',
173
+ 330: 'Content decoding of the response body failed',
174
+ 331:
175
+ 'An operation could not be completed because all network ' +
176
+ 'IO is suspended',
177
+ 332: 'FLIP data received without receiving a SYN_REPLY on the stream',
178
+ 333: 'Converting the response to target encoding failed',
179
+ 334:
180
+ 'The server sent an FTP directory listing in a format we do ' +
181
+ 'not understand',
182
+ 335: 'Attempted use of an unknown SPDY stream id',
183
+ 336: 'There are no supported proxies in the provided list',
184
+ 337: 'There is a SPDY protocol error',
185
+ 338: 'Credentials could not be established during HTTP Authentication',
186
+ 339:
187
+ 'An HTTP Authentication scheme was tried which is not ' +
188
+ 'supported on this machine',
189
+ 340: 'Detecting the encoding of the response failed',
190
+ 341:
191
+ '(GSSAPI) No Kerberos credentials were available ' +
192
+ 'during HTTP Authentication',
193
+ 342:
194
+ 'An unexpected, but documented, SSPI or GSSAPI status ' +
195
+ 'code was returned',
196
+ 343: 'The environment was not set up correctly for authentication',
197
+ 344: 'An undocumented SSPI or GSSAPI status code was returned',
198
+ 345: 'The HTTP response was too big to drain',
199
+ 346:
200
+ 'The HTTP response contained multiple distinct ' +
201
+ 'Content-Length headers',
202
+ 347:
203
+ 'SPDY Headers have been received, but not all of them - ' +
204
+ 'status or version headers are missing, so we\'re expecting ' +
205
+ 'additional frames to complete them',
206
+ 348: 'No PAC URL configuration could be retrieved from DHCP.',
207
+ 349: 'The HTTP response contained multiple Content-Disposition headers',
208
+ 350: 'The HTTP response contained multiple Location headers',
209
+ 351:
210
+ 'SPDY server refused the stream. Client should retry.' +
211
+ ' This should never be a user-visible error',
212
+ 352: 'SPDY server didn\'t respond to the PING message',
213
+ 353:
214
+ 'The request couldn\'t be completed on an HTTP pipeline. ' +
215
+ 'Client should retry',
216
+ 354:
217
+ 'The HTTP response body transferred fewer bytes than were ' +
218
+ 'advertised by the Content-Length header when the connection is closed',
219
+ 355:
220
+ 'The HTTP response body is transferred with Chunked-Encoding, but ' +
221
+ 'the terminating zero-length chunk was never sent when the ' +
222
+ 'connection is closed',
223
+ 356: 'There is a QUIC protocol error',
224
+ 357: 'The HTTP headers were truncated by an EOF',
225
+ 358: 'The QUIC crytpo handshake failed.',
226
+ 359: 'An https resource was requested over an insecure QUIC connection',
227
+ 501: 'The server\'s response was insecure (e.g. there was a cert error)',
228
+ 502:
229
+ 'The server responded to a <keygen> with a generated client cert ' +
230
+ 'that we don\'t have the matching private key for',
231
+ 503:
232
+ 'An error adding to the OS certificate database ' +
233
+ '(e.g. OS X Keychain)',
234
+ 800: 'DNS resolver received a malformed response',
235
+ 801: 'DNS server requires TCP',
236
+ 802: 'DNS server failed.',
237
+ 803: 'DNS transaction timed out',
238
+ 804: 'The entry was not found in cache, for cache-only lookups',
239
+ 805: 'Suffix search list rules prevent resolution of the given host name',
240
+ 806: 'Failed to sort addresses according to RFC3484',
241
+ };
242
+ }
243
+
244
+ static get netCodes(): Record<string, number> {
245
+ return {
246
+ ECONNREFUSED: 102,
247
+ ECONNABORTED: 146,
248
+ ECONNRESET: 101,
249
+ };
250
+ }
251
+
252
+ /**
253
+ * @param code Error code
254
+ * @return Message associated with the code.
255
+ */
256
+ static getCodeMessage(code: number|string): string {
257
+ let typed = Number(code);
258
+ if (Number.isNaN(typed)) {
259
+ const mapping = HttpErrorCodes.netCodes;
260
+ if (mapping[code]) {
261
+ typed = mapping[code];
262
+ }
263
+ }
264
+ const errorCodes = HttpErrorCodes.codes;
265
+ if (code in errorCodes) {
266
+ return errorCodes[typed];
267
+ }
268
+ return 'Unknown error';
269
+ }
270
+ }