@zowe/db2-for-zowe-cli 6.1.17 → 6.1.18

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 (232) hide show
  1. package/README.md +12 -10
  2. package/lib/Db2PluginLifeCycle.d.ts +11 -9
  3. package/lib/Db2PluginLifeCycle.js +18 -13
  4. package/lib/Db2PluginLifeCycle.js.map +1 -1
  5. package/node_modules/axios/CHANGELOG.md +62 -0
  6. package/node_modules/axios/README.md +233 -5
  7. package/node_modules/axios/dist/axios.js +387 -89
  8. package/node_modules/axios/dist/axios.min.js +3 -3
  9. package/node_modules/axios/dist/axios.min.js.map +1 -1
  10. package/node_modules/axios/dist/browser/axios.cjs +458 -98
  11. package/node_modules/axios/dist/esm/axios.js +458 -98
  12. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  13. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  14. package/node_modules/axios/dist/node/axios.cjs +568 -116
  15. package/node_modules/axios/index.d.cts +4 -0
  16. package/node_modules/axios/index.d.ts +4 -0
  17. package/node_modules/axios/lib/adapters/fetch.js +64 -11
  18. package/node_modules/axios/lib/adapters/http.js +134 -50
  19. package/node_modules/axios/lib/adapters/xhr.js +52 -3
  20. package/node_modules/axios/lib/core/Axios.js +19 -14
  21. package/node_modules/axios/lib/core/InterceptorManager.js +107 -8
  22. package/node_modules/axios/lib/core/buildFullPath.js +1 -13
  23. package/node_modules/axios/lib/core/dispatchRequest.js +8 -2
  24. package/node_modules/axios/lib/core/mergeConfig.js +1 -1
  25. package/node_modules/axios/lib/core/methodList.js +17 -0
  26. package/node_modules/axios/lib/defaults/index.js +2 -1
  27. package/node_modules/axios/lib/env/data.js +1 -1
  28. package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
  29. package/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
  30. package/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
  31. package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
  32. package/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
  33. package/node_modules/axios/lib/helpers/resolveConfig.js +4 -2
  34. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +182 -6
  35. package/node_modules/axios/lib/helpers/throttle.js +3 -2
  36. package/node_modules/axios/lib/helpers/toFormData.js +14 -21
  37. package/node_modules/axios/lib/utils.js +134 -13
  38. package/node_modules/axios/package.json +1 -1
  39. package/node_modules/ibm_db/APIDocumentation.md +2883 -2024
  40. package/node_modules/ibm_db/LICENSE +23 -23
  41. package/node_modules/ibm_db/README.md +735 -735
  42. package/node_modules/ibm_db/binding.gyp +99 -98
  43. package/node_modules/ibm_db/installer/driverInstall.js +984 -958
  44. package/node_modules/ibm_db/installer/ifx.sh +38 -38
  45. package/node_modules/ibm_db/installer/setenv.sh +23 -23
  46. package/node_modules/ibm_db/installer/testODBCConnection.bat +51 -51
  47. package/node_modules/ibm_db/installer/testODBCConnection.sh +61 -61
  48. package/node_modules/ibm_db/lib/climacros.js +431 -431
  49. package/node_modules/ibm_db/lib/odbc.js +4293 -3487
  50. package/node_modules/ibm_db/lib/simple-queue.js +41 -41
  51. package/node_modules/ibm_db/package.json +70 -70
  52. package/node_modules/ibm_db/src/odbc.cpp +1495 -1396
  53. package/node_modules/ibm_db/src/odbc.h +477 -473
  54. package/node_modules/ibm_db/src/odbc_connection.cpp +1762 -1612
  55. package/node_modules/ibm_db/src/odbc_connection.h +228 -215
  56. package/node_modules/ibm_db/src/odbc_result.cpp +1547 -1547
  57. package/node_modules/ibm_db/src/odbc_result.h +152 -152
  58. package/node_modules/ibm_db/src/odbc_statement.cpp +2047 -861
  59. package/node_modules/ibm_db/src/odbc_statement.h +257 -135
  60. package/node_modules/ibm_db/src/strptime.c +389 -389
  61. package/node_modules/ibm_db/src/strptime.h +46 -46
  62. package/node_modules/ibm_db/test/README +23 -23
  63. package/node_modules/ibm_db/test/bench-insert.js +62 -62
  64. package/node_modules/ibm_db/test/bench-insertBatch10.js +74 -74
  65. package/node_modules/ibm_db/test/bench-insertBatch100.js +75 -75
  66. package/node_modules/ibm_db/test/bench-insertBatch1000.js +75 -75
  67. package/node_modules/ibm_db/test/bench-insertBatch10000.js +75 -75
  68. package/node_modules/ibm_db/test/bench-prepare-bind-execute-closeSync.js +60 -60
  69. package/node_modules/ibm_db/test/bench-prepare-bind-executeNonQuery.js +53 -53
  70. package/node_modules/ibm_db/test/bench-prepare-bindSync-execute-closeSync.js +50 -50
  71. package/node_modules/ibm_db/test/bench-prepare-bindSync-executeNonQuery.js +48 -48
  72. package/node_modules/ibm_db/test/bench-prepare-execute-closeSync.js +51 -51
  73. package/node_modules/ibm_db/test/bench-prepare-executeNonQuery.js +47 -47
  74. package/node_modules/ibm_db/test/bench-prepare-not.js +43 -43
  75. package/node_modules/ibm_db/test/bench-query-fetch.js +59 -59
  76. package/node_modules/ibm_db/test/bench-query-fetchAll.js +49 -49
  77. package/node_modules/ibm_db/test/bench-query-fetchAllSync.js +43 -43
  78. package/node_modules/ibm_db/test/bench-query.js +40 -40
  79. package/node_modules/ibm_db/test/bench-querySync-fetchArray.js +28 -28
  80. package/node_modules/ibm_db/test/bench-querySync.js +29 -29
  81. package/node_modules/ibm_db/test/common.d.ts +10 -10
  82. package/node_modules/ibm_db/test/common.js +127 -127
  83. package/node_modules/ibm_db/test/config.json +7 -7
  84. package/node_modules/ibm_db/test/config.zos.json +4 -4
  85. package/node_modules/ibm_db/test/data/sample1.txt +9 -9
  86. package/node_modules/ibm_db/test/data/trc.fmt +30114 -30114
  87. package/node_modules/ibm_db/test/nodeEE-leak-huge-query.js +152 -152
  88. package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-multiple-connections.js +148 -148
  89. package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-pool-connections.js +154 -154
  90. package/node_modules/ibm_db/test/nodeEE-leak-multiple-query.js +133 -133
  91. package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall-multiple-connections.js +174 -174
  92. package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall.js +169 -169
  93. package/node_modules/ibm_db/test/nodeEE-stress-mixed-query-multiple-connections.js +159 -159
  94. package/node_modules/ibm_db/test/nodeEE-stress-mixed-query.js +148 -148
  95. package/node_modules/ibm_db/test/odbc-bench.c +123 -123
  96. package/node_modules/ibm_db/test/perfTest.js +53 -53
  97. package/node_modules/ibm_db/test/quick-example.sh +30 -30
  98. package/node_modules/ibm_db/test/quick-example.ts +80 -80
  99. package/node_modules/ibm_db/test/run-bench.js +96 -96
  100. package/node_modules/ibm_db/test/run-nodeEE.js +132 -132
  101. package/node_modules/ibm_db/test/run-tests.js +132 -138
  102. package/node_modules/ibm_db/test/sql-cli.js +28 -28
  103. package/node_modules/ibm_db/test/test-all-data-types.js +109 -109
  104. package/node_modules/ibm_db/test/test-array-insert.js +178 -178
  105. package/node_modules/ibm_db/test/test-async-await.js +105 -105
  106. package/node_modules/ibm_db/test/test-attributes.js +34 -34
  107. package/node_modules/ibm_db/test/test-bad-pool-connection-prepare-execute.js +57 -57
  108. package/node_modules/ibm_db/test/test-basic-test.js +138 -138
  109. package/node_modules/ibm_db/test/test-binary-array-insert.js +73 -73
  110. package/node_modules/ibm_db/test/test-blob-from-file.js +90 -90
  111. package/node_modules/ibm_db/test/test-blob-insert.js +144 -144
  112. package/node_modules/ibm_db/test/test-blob-stream-insert.js +321 -299
  113. package/node_modules/ibm_db/test/test-blob-to-file.js +370 -370
  114. package/node_modules/ibm_db/test/test-block-fetch.js +364 -364
  115. package/node_modules/ibm_db/test/test-blocking-issue210.js +123 -123
  116. package/node_modules/ibm_db/test/test-call-async.js +64 -64
  117. package/node_modules/ibm_db/test/test-call-stmt.js +53 -53
  118. package/node_modules/ibm_db/test/test-cancel.js +703 -0
  119. package/node_modules/ibm_db/test/test-chinese-char.js +59 -59
  120. package/node_modules/ibm_db/test/test-connection.js +306 -0
  121. package/node_modules/ibm_db/test/test-date.js +32 -32
  122. package/node_modules/ibm_db/test/test-dbclob.js +93 -93
  123. package/node_modules/ibm_db/test/test-decimals.js +135 -135
  124. package/node_modules/ibm_db/test/test-describe-metadata.js +148 -0
  125. package/node_modules/ibm_db/test/test-executeFile.js +167 -167
  126. package/node_modules/ibm_db/test/test-executeFileSync.js +85 -85
  127. package/node_modules/ibm_db/test/test-fetch-apis.js +146 -146
  128. package/node_modules/ibm_db/test/test-fetchN.js +130 -130
  129. package/node_modules/ibm_db/test/test-getinfo.js +197 -197
  130. package/node_modules/ibm_db/test/test-ibm-db-issue14.js +58 -58
  131. package/node_modules/ibm_db/test/test-ibm-db-issue17.js +54 -54
  132. package/node_modules/ibm_db/test/test-ibm-db-issue18.js +54 -54
  133. package/node_modules/ibm_db/test/test-issue-1059-fetchAll-undefined.js +67 -67
  134. package/node_modules/ibm_db/test/test-issue-1080-array-blob-insert.js +40 -0
  135. package/node_modules/ibm_db/test/test-issue-54.js +39 -39
  136. package/node_modules/ibm_db/test/test-issue-get-column-value-2.js +44 -44
  137. package/node_modules/ibm_db/test/test-issue211.js +80 -80
  138. package/node_modules/ibm_db/test/test-issue253.js +39 -39
  139. package/node_modules/ibm_db/test/test-max-pool-size.js +96 -96
  140. package/node_modules/ibm_db/test/test-memory-leaks-new-objects.js +32 -32
  141. package/node_modules/ibm_db/test/test-multi-open-query-close.js +75 -75
  142. package/node_modules/ibm_db/test/test-param-put-data.js +713 -0
  143. package/node_modules/ibm_db/test/test-pool-idle-connection.js +72 -72
  144. package/node_modules/ibm_db/test/test-pool-operations.js +325 -0
  145. package/node_modules/ibm_db/test/test-pool-stale-connections.js +111 -111
  146. package/node_modules/ibm_db/test/test-pool-uncommited.js +33 -33
  147. package/node_modules/ibm_db/test/test-prepare-execute.js +339 -0
  148. package/node_modules/ibm_db/test/test-prepareSync-multiple-execution.js +93 -93
  149. package/node_modules/ibm_db/test/test-primary-foreign-keys.js +246 -0
  150. package/node_modules/ibm_db/test/test-procedures.js +243 -0
  151. package/node_modules/ibm_db/test/test-promise-all-data-types.js +42 -42
  152. package/node_modules/ibm_db/test/test-query-operations.js +405 -0
  153. package/node_modules/ibm_db/test/test-quick-example.js +25 -25
  154. package/node_modules/ibm_db/test/test-row-array-insert.js +167 -167
  155. package/node_modules/ibm_db/test/test-sp-array.js +54 -54
  156. package/node_modules/ibm_db/test/test-sp-dbc-6000.js +88 -88
  157. package/node_modules/ibm_db/test/test-sp-memleak.js +136 -136
  158. package/node_modules/ibm_db/test/test-sp-resultset-execute.js +269 -269
  159. package/node_modules/ibm_db/test/test-sp-resultset.js +228 -228
  160. package/node_modules/ibm_db/test/test-transactions.js +261 -0
  161. package/node_modules/ibm_db/test/test-typescript.js +48 -48
  162. package/node_modules/ibm_db/test/test-xml-datatype.js +70 -70
  163. package/node_modules/ibm_db/test/testWebApp.js +56 -56
  164. package/node_modules/ibm_db/test/trace +51 -51
  165. package/node_modules/ibm_db/test/typescript-apis-test.js +978 -978
  166. package/node_modules/ibm_db/test/webapp.html +17 -17
  167. package/node_modules/ibm_db/test/webapp.js +79 -79
  168. package/node_modules/ibm_db/typescript/README.md +28 -28
  169. package/node_modules/ibm_db/typescript/dist/Database.d.ts +26 -0
  170. package/node_modules/ibm_db/typescript/dist/ODBCStatement.d.ts +93 -0
  171. package/package.json +10 -6
  172. package/node_modules/ibm_db/test/disabled/test-binding-statement-rebinding.js +0 -59
  173. package/node_modules/ibm_db/test/disabled/test-open-dont-close.js +0 -12
  174. package/node_modules/ibm_db/test/disabled/test-param-select-with-booleans-only.js +0 -21
  175. package/node_modules/ibm_db/test/disabled/test-param-select-with-decimals-only.js +0 -20
  176. package/node_modules/ibm_db/test/disabled/test-param-select-with-null.js +0 -21
  177. package/node_modules/ibm_db/test/disabled/test-param-select-with-nulls-mixed.js +0 -23
  178. package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-mixed.js +0 -22
  179. package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-only.js +0 -24
  180. package/node_modules/ibm_db/test/disabled/test-param-select-with-strings-only.js +0 -23
  181. package/node_modules/ibm_db/test/disabled/test-param-select-with-unicode.js +0 -15
  182. package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-closeSync.js +0 -62
  183. package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-error.js +0 -49
  184. package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-long-string.js +0 -63
  185. package/node_modules/ibm_db/test/disabled/test-prepare-bind-executeNonQuery.js +0 -63
  186. package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-execute-closeSync.js +0 -46
  187. package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-executeNonQuery.js +0 -50
  188. package/node_modules/ibm_db/test/disabled/test-prepare.js +0 -34
  189. package/node_modules/ibm_db/test/disabled/test-prepareSync.js +0 -29
  190. package/node_modules/ibm_db/test/disabled/test-query-select-fetchAll.js +0 -23
  191. package/node_modules/ibm_db/test/disabled/test-query-select-fetchAllSync.js +0 -23
  192. package/node_modules/ibm_db/test/disabled/test-query-select-unicode.js +0 -15
  193. package/node_modules/ibm_db/test/disabled/test-querySync-select-unicode.js +0 -20
  194. package/node_modules/ibm_db/test/test-affected-rows.js +0 -55
  195. package/node_modules/ibm_db/test/test-bad-connection-string.js +0 -30
  196. package/node_modules/ibm_db/test/test-binding-connection-timeOut.js +0 -31
  197. package/node_modules/ibm_db/test/test-binding-statement-executeSync.js +0 -84
  198. package/node_modules/ibm_db/test/test-binding-transaction-commit.js +0 -79
  199. package/node_modules/ibm_db/test/test-binding-transaction-commitSync.js +0 -53
  200. package/node_modules/ibm_db/test/test-closed.js +0 -14
  201. package/node_modules/ibm_db/test/test-connection-object.js +0 -16
  202. package/node_modules/ibm_db/test/test-describe-column.js +0 -92
  203. package/node_modules/ibm_db/test/test-describe-database.js +0 -18
  204. package/node_modules/ibm_db/test/test-describe-table.js +0 -31
  205. package/node_modules/ibm_db/test/test-domains-open.js +0 -19
  206. package/node_modules/ibm_db/test/test-global-open-close.js +0 -11
  207. package/node_modules/ibm_db/test/test-instantiate-one-and-end.js +0 -9
  208. package/node_modules/ibm_db/test/test-multi-open-close.js +0 -45
  209. package/node_modules/ibm_db/test/test-multi-openSync-closeSync.js +0 -52
  210. package/node_modules/ibm_db/test/test-open-close.js +0 -29
  211. package/node_modules/ibm_db/test/test-open-connectTimeout.js +0 -33
  212. package/node_modules/ibm_db/test/test-openSync.js +0 -31
  213. package/node_modules/ibm_db/test/test-pool-close.js +0 -120
  214. package/node_modules/ibm_db/test/test-pool-connect.js +0 -36
  215. package/node_modules/ibm_db/test/test-pool-rollbackTransaction.js +0 -35
  216. package/node_modules/ibm_db/test/test-prepareSync-bad-sql.js +0 -34
  217. package/node_modules/ibm_db/test/test-promise-open-close.js +0 -33
  218. package/node_modules/ibm_db/test/test-query-create-table-fetchSync.js +0 -23
  219. package/node_modules/ibm_db/test/test-query-create-table.js +0 -12
  220. package/node_modules/ibm_db/test/test-query-drop-table.js +0 -13
  221. package/node_modules/ibm_db/test/test-query-insert.js +0 -38
  222. package/node_modules/ibm_db/test/test-query-select-fetch.js +0 -21
  223. package/node_modules/ibm_db/test/test-query-select-fetchMode-array.js +0 -17
  224. package/node_modules/ibm_db/test/test-query-select.js +0 -64
  225. package/node_modules/ibm_db/test/test-queryResult.js +0 -35
  226. package/node_modules/ibm_db/test/test-queryStream.js +0 -43
  227. package/node_modules/ibm_db/test/test-querySync-select-with-exception.js +0 -25
  228. package/node_modules/ibm_db/test/test-querySync-select.js +0 -28
  229. package/node_modules/ibm_db/test/test-require-and-end.js +0 -8
  230. package/node_modules/ibm_db/test/test-statement-close.js +0 -118
  231. package/node_modules/ibm_db/test/test-transaction-commit-sync.js +0 -54
  232. package/node_modules/ibm_db/test/test-transaction-commit.js +0 -79
@@ -2,9 +2,57 @@
2
2
 
3
3
  import utils from '../utils.js';
4
4
 
5
+ const $internals = Symbol('internals');
6
+
7
+ // `handlers` is public and may be replaced with a nullish value by user code;
8
+ // `clear()` has always tolerated that. Treat it as an empty stack rather than
9
+ // dereferencing it.
10
+ function countHandlers(handlers) {
11
+ return handlers ? handlers.length : 0;
12
+ }
13
+
14
+ function trimHandlers(handlers) {
15
+ if (!handlers) {
16
+ return;
17
+ }
18
+
19
+ while (handlers.length && handlers[handlers.length - 1] === null) {
20
+ handlers.pop();
21
+ }
22
+ }
23
+
24
+ function syncHandlerEntries(manager, internals) {
25
+ const handlers = manager.handlers;
26
+ const length = countHandlers(handlers);
27
+
28
+ if (handlers !== internals.handlersRef) {
29
+ internals.handlersRef = handlers;
30
+ internals.handlerEntries.clear();
31
+ } else if (length !== internals.handlersLength) {
32
+ if (!length) {
33
+ internals.handlerEntries.clear();
34
+ } else {
35
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
36
+ if (handlers[entry.index] !== entry.handler) {
37
+ internals.handlerEntries.delete(id);
38
+ }
39
+ });
40
+ }
41
+ }
42
+
43
+ internals.handlersLength = length;
44
+ }
45
+
5
46
  class InterceptorManager {
6
47
  constructor() {
7
48
  this.handlers = [];
49
+ this[$internals] = {
50
+ handlersRef: this.handlers,
51
+ handlersLength: this.handlers.length,
52
+ handlerEntries: new Map(),
53
+ iterationDepth: 0,
54
+ nextId: 0,
55
+ };
8
56
  }
9
57
 
10
58
  /**
@@ -17,13 +65,30 @@ class InterceptorManager {
17
65
  * @return {Number} An ID used to remove interceptor later
18
66
  */
19
67
  use(fulfilled, rejected, options) {
20
- this.handlers.push({
68
+ const handler = {
21
69
  fulfilled,
22
70
  rejected,
23
71
  synchronous: options ? options.synchronous : false,
24
72
  runWhen: options ? options.runWhen : null,
73
+ };
74
+ const internals = this[$internals];
75
+
76
+ if (this.handlers == null) {
77
+ this.handlers = [];
78
+ }
79
+
80
+ syncHandlerEntries(this, internals);
81
+
82
+ const id = internals.nextId++;
83
+
84
+ this.handlers.push(handler);
85
+ internals.handlerEntries.set(id, {
86
+ handler,
87
+ index: this.handlers.length - 1,
25
88
  });
26
- return this.handlers.length - 1;
89
+ internals.handlersLength = this.handlers.length;
90
+
91
+ return id;
27
92
  }
28
93
 
29
94
  /**
@@ -34,8 +99,27 @@ class InterceptorManager {
34
99
  * @returns {void}
35
100
  */
36
101
  eject(id) {
37
- if (this.handlers[id]) {
38
- this.handlers[id] = null;
102
+ const internals = this[$internals];
103
+
104
+ syncHandlerEntries(this, internals);
105
+
106
+ const entry = internals.handlerEntries.get(id);
107
+
108
+ if (entry) {
109
+ internals.handlerEntries.delete(id);
110
+
111
+ // Ignore IDs invalidated by clear or direct replacement of handlers.
112
+ if (this.handlers[entry.index] !== entry.handler) {
113
+ return;
114
+ }
115
+
116
+ this.handlers[entry.index] = null;
117
+
118
+ // Do not reuse an index while forEach is walking its length snapshot.
119
+ if (!internals.iterationDepth) {
120
+ trimHandlers(this.handlers);
121
+ internals.handlersLength = this.handlers.length;
122
+ }
39
123
  }
40
124
  }
41
125
 
@@ -47,6 +131,7 @@ class InterceptorManager {
47
131
  clear() {
48
132
  if (this.handlers) {
49
133
  this.handlers = [];
134
+ syncHandlerEntries(this, this[$internals]);
50
135
  }
51
136
  }
52
137
 
@@ -61,11 +146,25 @@ class InterceptorManager {
61
146
  * @returns {void}
62
147
  */
63
148
  forEach(fn) {
64
- utils.forEach(this.handlers, function forEachHandler(h) {
65
- if (h !== null) {
66
- fn(h);
149
+ const internals = this[$internals];
150
+
151
+ syncHandlerEntries(this, internals);
152
+
153
+ internals.iterationDepth++;
154
+
155
+ try {
156
+ utils.forEach(this.handlers, function forEachHandler(h) {
157
+ if (h !== null) {
158
+ fn(h);
159
+ }
160
+ });
161
+ } finally {
162
+ if (!--internals.iterationDepth) {
163
+ syncHandlerEntries(this, internals);
164
+ trimHandlers(this.handlers);
165
+ internals.handlersLength = countHandlers(this.handlers);
67
166
  }
68
- });
167
+ }
69
168
  }
70
169
  }
71
170
 
@@ -3,21 +3,9 @@
3
3
  import AxiosError, { REDACTED } from './AxiosError.js';
4
4
  import isAbsoluteURL from '../helpers/isAbsoluteURL.js';
5
5
  import combineURLs from '../helpers/combineURLs.js';
6
+ import normalizeURLForProtocolCheck from '../helpers/normalizeURLForProtocolCheck.js';
6
7
 
7
8
  const malformedHttpProtocol = /^https?:(?!\/\/)/i;
8
- const httpProtocolControlCharacters = /[\t\n\r]/g;
9
-
10
- function stripLeadingC0ControlOrSpace(url) {
11
- let i = 0;
12
- while (i < url.length && url.charCodeAt(i) <= 0x20) {
13
- i++;
14
- }
15
- return url.slice(i);
16
- }
17
-
18
- function normalizeURLForProtocolCheck(url) {
19
- return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
20
- }
21
9
 
22
10
  // Redact the parts of a URL that can carry secrets before it is embedded in an
23
11
  // error message. AxiosError.toJSON() serializes `message` verbatim and errors
@@ -6,6 +6,7 @@ import defaults from '../defaults/index.js';
6
6
  import CanceledError from '../cancel/CanceledError.js';
7
7
  import AxiosHeaders from '../core/AxiosHeaders.js';
8
8
  import adapters from '../adapters/adapters.js';
9
+ import utils from '../utils.js';
9
10
 
10
11
  /**
11
12
  * Throws a `CanceledError` if cancellation has been requested.
@@ -31,10 +32,15 @@ function throwIfCancellationRequested(config) {
31
32
  *
32
33
  * @returns {Promise} The Promise to be fulfilled
33
34
  */
34
- export default function dispatchRequest(config) {
35
+ export default function dispatchRequest(_config) {
36
+ // Interceptors may replace the merged config with an ordinary object. Flatten
37
+ // it at the dispatch boundary so shared prototype members cannot become
38
+ // request behavior, while preserving intentional template/class members.
39
+ const config = utils.toSafeFlatObject(_config);
40
+
35
41
  throwIfCancellationRequested(config);
36
42
 
37
- config.headers = AxiosHeaders.from(config.headers);
43
+ config.headers = AxiosHeaders.from(utils.getSafeProp(config, 'headers'));
38
44
 
39
45
  // Transform request data
40
46
  config.data = transformData.call(config, config.transformRequest);
@@ -124,7 +124,7 @@ export default function mergeConfig(config1, config2) {
124
124
  transformResponse: defaultToConfig2,
125
125
  paramsSerializer: defaultToConfig2,
126
126
  timeout: defaultToConfig2,
127
- timeoutMessage: defaultToConfig2,
127
+ timeoutErrorMessage: defaultToConfig2,
128
128
  withCredentials: defaultToConfig2,
129
129
  withXSRFToken: defaultToConfig2,
130
130
  adapter: defaultToConfig2,
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ const methodList = Object.freeze([
4
+ 'get',
5
+ 'delete',
6
+ 'head',
7
+ 'options',
8
+ 'post',
9
+ 'put',
10
+ 'patch',
11
+ 'purge',
12
+ 'link',
13
+ 'unlink',
14
+ 'query',
15
+ ]);
16
+
17
+ export default methodList;
@@ -7,6 +7,7 @@ import toFormData from '../helpers/toFormData.js';
7
7
  import toURLEncodedForm from '../helpers/toURLEncodedForm.js';
8
8
  import platform from '../platform/index.js';
9
9
  import formDataToJSON from '../helpers/formDataToJSON.js';
10
+ import methodList from '../core/methodList.js';
10
11
 
11
12
  const own = (obj, key) => (obj != null && utils.hasOwnProp(obj, key) ? obj[key] : undefined);
12
13
 
@@ -170,7 +171,7 @@ const defaults = {
170
171
  },
171
172
  };
172
173
 
173
- utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], (method) => {
174
+ utils.forEach(methodList, (method) => {
174
175
  defaults.headers[method] = {};
175
176
  });
176
177
 
@@ -1 +1 @@
1
- export const VERSION = "1.19.0";
1
+ export const VERSION = "1.20.0";
@@ -15,6 +15,7 @@ class Http2Sessions {
15
15
 
16
16
  getSession(authority, options) {
17
17
  options = Object.assign(
18
+ Object.create(null),
18
19
  {
19
20
  sessionTimeout: 1000,
20
21
  },
@@ -105,6 +106,7 @@ class Http2Sessions {
105
106
  }
106
107
 
107
108
  session.once('close', removeSession);
109
+ session.once('error', removeSession);
108
110
 
109
111
  let entry = [session, options];
110
112
 
@@ -35,14 +35,22 @@ const HttpStatusCode = {
35
35
  Gone: 410,
36
36
  LengthRequired: 411,
37
37
  PreconditionFailed: 412,
38
+ /**
39
+ * @deprecated Use `ContentTooLarge` instead.
40
+ */
38
41
  PayloadTooLarge: 413,
42
+ ContentTooLarge: 413,
39
43
  UriTooLong: 414,
40
44
  UnsupportedMediaType: 415,
41
45
  RangeNotSatisfiable: 416,
42
46
  ExpectationFailed: 417,
43
47
  ImATeapot: 418,
44
48
  MisdirectedRequest: 421,
49
+ /**
50
+ * @deprecated Use `UnprocessableContent` instead.
51
+ */
45
52
  UnprocessableEntity: 422,
53
+ UnprocessableContent: 422,
46
54
  Locked: 423,
47
55
  FailedDependency: 424,
48
56
  TooEarly: 425,
@@ -72,7 +80,9 @@ const HttpStatusCode = {
72
80
  };
73
81
 
74
82
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
75
- HttpStatusCode[value] = key;
83
+ if (HttpStatusCode[value] === undefined) {
84
+ HttpStatusCode[value] = key;
85
+ }
76
86
  });
77
87
 
78
88
  export default HttpStatusCode;
@@ -6,7 +6,7 @@ import platform from '../platform/index.js';
6
6
 
7
7
  // RFC 2397: data:[<mediatype>][;base64],<data>
8
8
  // mediatype = type/subtype followed by optional ;name=value parameters
9
- const DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
9
+ const DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
10
10
 
11
11
  /**
12
12
  * Parse data uri to a Buffer or Blob
@@ -49,9 +49,10 @@ export default function fromDataURI(uri, asBlob, options) {
49
49
  mime = 'text/plain' + params;
50
50
  }
51
51
 
52
- const buffer = encoding === 'base64'
53
- ? Buffer.from(body, 'base64')
54
- : Buffer.from(decodeURIComponent(body), encoding);
52
+ const buffer =
53
+ encoding === 'base64'
54
+ ? Buffer.from(body, 'base64')
55
+ : Buffer.from(decodeURIComponent(body), encoding);
55
56
 
56
57
  if (asBlob) {
57
58
  if (!_Blob) {
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const urlParserControlCharacters = /[\t\n\r]/g;
4
+
5
+ /**
6
+ * Match WHATWG URL preprocessing before checking a URL's protocol.
7
+ *
8
+ * @param {string} url
9
+ *
10
+ * @returns {string}
11
+ */
12
+ export default function normalizeURLForProtocolCheck(url) {
13
+ if (typeof url !== 'string') {
14
+ return url;
15
+ }
16
+
17
+ let start = 0;
18
+
19
+ while (start < url.length && url.charCodeAt(start) <= 0x20) {
20
+ start++;
21
+ }
22
+
23
+ return url.slice(start).replace(urlParserControlCharacters, '');
24
+ }
@@ -7,7 +7,7 @@ export const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
7
7
  const _speedometer = speedometer(50, 250);
8
8
 
9
9
  return throttle((e) => {
10
- if (!e || typeof e.loaded !== 'number') {
10
+ if (!e || !utils.isNumber(e.loaded)) {
11
11
  return;
12
12
  }
13
13
  const rawLoaded = e.loaded;
@@ -63,15 +63,17 @@ function resolveConfig(config) {
63
63
  }
64
64
 
65
65
  if (utils.isFormData(data)) {
66
+ const getHeaders = utils.getSafeProp(data, 'getHeaders');
67
+
66
68
  if (
67
69
  platform.hasStandardBrowserEnv ||
68
70
  platform.hasStandardBrowserWebWorkerEnv ||
69
71
  utils.isReactNative(data)
70
72
  ) {
71
73
  headers.setContentType(undefined); // browser/web worker/RN handles it
72
- } else if (utils.isFunction(data.getHeaders)) {
74
+ } else if (utils.isFunction(getHeaders)) {
73
75
  // Node.js FormData (like form-data package)
74
- setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
76
+ setFormDataHeaders(headers, getHeaders.call(data), own('formDataHeaderPolicy'));
75
77
  }
76
78
  }
77
79
 
@@ -1,5 +1,15 @@
1
1
  const LOOPBACK_HOSTNAMES = new Set(['localhost', '0.0.0.0']);
2
2
 
3
+ const trimTrailingDots = (value) => {
4
+ let end = value.length;
5
+
6
+ while (end && value.charCodeAt(end - 1) === 46) {
7
+ end--;
8
+ }
9
+
10
+ return end === value.length ? value : value.slice(0, end);
11
+ };
12
+
3
13
  const isIPv4Loopback = (host) => {
4
14
  const parts = host.split('.');
5
15
  if (parts.length !== 4) return false;
@@ -57,7 +67,7 @@ const normalizeIPAddress = (host) => {
57
67
  if (h.charAt(0) === '[' && h.charAt(h.length - 1) === ']') {
58
68
  h = h.slice(1, -1);
59
69
  }
60
- h = h.replace(/\.+$/, '');
70
+ h = trimTrailingDots(h);
61
71
 
62
72
  // Allowed characters for any IPv4 shape: digits, dot, 'x', 'X', hex digits.
63
73
  if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
@@ -134,9 +144,7 @@ const isIPv6Unspecified = (host) => {
134
144
  const explicitGroups = leftGroups.length + rightGroups.length;
135
145
 
136
146
  return (
137
- explicitGroups < 8 &&
138
- leftGroups.every(isIPv6ZeroGroup) &&
139
- rightGroups.every(isIPv6ZeroGroup)
147
+ explicitGroups < 8 && leftGroups.every(isIPv6ZeroGroup) && rightGroups.every(isIPv6ZeroGroup)
140
148
  );
141
149
  }
142
150
 
@@ -232,7 +240,8 @@ const parseNoProxyEntry = (entry) => {
232
240
  // allowing the proxy-bypass policy to be circumvented by using the alternate
233
241
  // representation. Returns the input unchanged when not IPv4-mapped.
234
242
  const IPV4_MAPPED_DOTTED_RE = /^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:(\d+\.\d+\.\d+\.\d+)$/i;
235
- const IPV4_MAPPED_HEX_RE = /^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i;
243
+ const IPV4_MAPPED_HEX_RE =
244
+ /^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i;
236
245
 
237
246
  const unmapIPv4MappedIPv6 = (host) => {
238
247
  if (typeof host !== 'string' || host.indexOf(':') === -1) return host;
@@ -250,6 +259,57 @@ const unmapIPv4MappedIPv6 = (host) => {
250
259
  return host;
251
260
  };
252
261
 
262
+ const IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
263
+
264
+ const ipv4ToBytes = (host) => {
265
+ const parts = host.split('.');
266
+
267
+ return parts.length === 4 &&
268
+ parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255)
269
+ ? parts.map(Number)
270
+ : null;
271
+ };
272
+
273
+ const IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
274
+
275
+ const ipv6ToBytes = (host) => {
276
+ const halves = host.split('::');
277
+
278
+ if (halves.length > 2) {
279
+ return null;
280
+ }
281
+
282
+ const groups = halves[0] ? halves[0].split(':') : [];
283
+
284
+ if (halves.length === 2) {
285
+ const rear = halves[1] ? halves[1].split(':') : [];
286
+ const missing = 8 - groups.length - rear.length;
287
+
288
+ if (missing < 1) {
289
+ return null;
290
+ }
291
+
292
+ groups.push(...new Array(missing).fill('0'), ...rear);
293
+ }
294
+
295
+ if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
296
+ return null;
297
+ }
298
+
299
+ return groups.flatMap((group) => {
300
+ const value = Number.parseInt(group, 16);
301
+ return [(value >> 8) & 0xff, value & 0xff];
302
+ });
303
+ };
304
+
305
+ const ipToBytes = (host) => {
306
+ if (typeof host !== 'string' || !host) {
307
+ return null;
308
+ }
309
+
310
+ return host.indexOf(':') !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
311
+ };
312
+
253
313
  const normalizeNoProxyHost = (hostname) => {
254
314
  if (!hostname) {
255
315
  return hostname;
@@ -259,7 +319,7 @@ const normalizeNoProxyHost = (hostname) => {
259
319
  hostname = hostname.slice(1, -1);
260
320
  }
261
321
 
262
- const trimmed = hostname.replace(/\.+$/, '');
322
+ const trimmed = trimTrailingDots(hostname);
263
323
 
264
324
  // IPv4 shorthand/octal/hex → dotted-decimal; helper is a no-op for inputs
265
325
  // containing ':' (IPv6 and IPv4-mapped IPv6) so we fall through to unmap.
@@ -271,6 +331,110 @@ const normalizeNoProxyHost = (hostname) => {
271
331
  return unmapIPv4MappedIPv6(trimmed);
272
332
  };
273
333
 
334
+ const normalizeCidrBase = (input) => {
335
+ let base = input;
336
+ const startsBracket = base.charAt(0) === '[';
337
+ const endsBracket = base.charAt(base.length - 1) === ']';
338
+ const hasBracket = base.includes('[') || base.includes(']');
339
+
340
+ if (startsBracket || endsBracket) {
341
+ if (!startsBracket || !endsBracket) {
342
+ return null;
343
+ }
344
+
345
+ base = base.slice(1, -1);
346
+
347
+ if (base.indexOf(':') === -1 || base.includes('[') || base.includes(']')) {
348
+ return null;
349
+ }
350
+ } else if (hasBracket) {
351
+ return null;
352
+ }
353
+
354
+ if (!base || base.charAt(base.length - 1) === '.') {
355
+ return null;
356
+ }
357
+
358
+ const wasIPv6 = base.indexOf(':') !== -1;
359
+
360
+ if (wasIPv6) {
361
+ try {
362
+ base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
363
+ } catch (_err) {
364
+ return null;
365
+ }
366
+ } else {
367
+ base = normalizeIPAddress(base);
368
+
369
+ if (!ipv4ToBytes(base)) {
370
+ return null;
371
+ }
372
+ }
373
+
374
+ return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
375
+ };
376
+
377
+ const CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
378
+
379
+ const parseCidrEntry = (entry) => {
380
+ if (entry.indexOf('/') === -1) {
381
+ return undefined;
382
+ }
383
+
384
+ const match = CIDR_ENTRY_RE.exec(entry);
385
+
386
+ if (!match) {
387
+ return null;
388
+ }
389
+
390
+ let prefix = Number(match[2]);
391
+ const parsedBase = normalizeCidrBase(match[1]);
392
+
393
+ if (!parsedBase) {
394
+ return null;
395
+ }
396
+
397
+ const { normalized, wasIPv6 } = parsedBase;
398
+
399
+ if (wasIPv6 && normalized.indexOf(':') === -1) {
400
+ if (prefix < 96) {
401
+ return null;
402
+ }
403
+
404
+ prefix -= 96;
405
+ }
406
+
407
+ const bytes = ipToBytes(normalized);
408
+
409
+ if (!bytes || prefix > bytes.length * 8) {
410
+ return null;
411
+ }
412
+
413
+ return { bytes, prefix };
414
+ };
415
+
416
+ const isInSubnet = (addressBytes, networkBytes, prefix) => {
417
+ const fullBytes = prefix >> 3;
418
+
419
+ for (let i = 0; i < fullBytes; i++) {
420
+ if (addressBytes[i] !== networkBytes[i]) {
421
+ return false;
422
+ }
423
+ }
424
+
425
+ const remainingBits = prefix & 7;
426
+
427
+ if (remainingBits) {
428
+ const mask = (0xff << (8 - remainingBits)) & 0xff;
429
+
430
+ if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
431
+ return false;
432
+ }
433
+ }
434
+
435
+ return true;
436
+ };
437
+
274
438
  export default function shouldBypassProxy(location) {
275
439
  let parsed;
276
440
 
@@ -294,6 +458,7 @@ export default function shouldBypassProxy(location) {
294
458
  Number.parseInt(parsed.port, 10) || DEFAULT_PORTS[parsed.protocol.split(':', 1)[0]] || 0;
295
459
 
296
460
  const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
461
+ const hostnameBytes = ipToBytes(hostname);
297
462
 
298
463
  return noProxy.split(/[\s,]+/).some((entry) => {
299
464
  if (!entry) {
@@ -304,6 +469,17 @@ export default function shouldBypassProxy(location) {
304
469
  return true;
305
470
  }
306
471
 
472
+ const cidr = parseCidrEntry(entry);
473
+
474
+ if (cidr !== undefined) {
475
+ return (
476
+ cidr !== null &&
477
+ !!hostnameBytes &&
478
+ hostnameBytes.length === cidr.bytes.length &&
479
+ isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix)
480
+ );
481
+ }
482
+
307
483
  let [entryHost, entryPort] = parseNoProxyEntry(entry);
308
484
 
309
485
  entryHost = normalizeNoProxyHost(entryHost);
@@ -2,7 +2,7 @@
2
2
  * Throttle decorator
3
3
  * @param {Function} fn
4
4
  * @param {Number} freq
5
- * @return {Function}
5
+ * @return {Array<Function>}
6
6
  */
7
7
  function throttle(fn, freq) {
8
8
  let timestamp = 0;
@@ -37,8 +37,9 @@ function throttle(fn, freq) {
37
37
  };
38
38
 
39
39
  const flush = () => lastArgs && invoke(lastArgs);
40
+ const flushWith = (...args) => invoke(args);
40
41
 
41
- return [throttled, flush];
42
+ return [throttled, flush, flushWith];
42
43
  }
43
44
 
44
45
  export default throttle;