@nocobase/plugin-file-manager 2.0.0-alpha.9 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/dist/client/index.d.ts +1 -1
  2. package/dist/client/index.js +1 -1
  3. package/dist/client/models/DisplayPreviewFieldModel.d.ts +1 -0
  4. package/dist/client/models/UploadActionModel.d.ts +3 -1
  5. package/dist/client/schemas/storageTypes/ali-oss.d.ts +12 -0
  6. package/dist/client/schemas/storageTypes/common.d.ts +12 -0
  7. package/dist/client/schemas/storageTypes/index.d.ts +48 -0
  8. package/dist/client/schemas/storageTypes/local.d.ts +12 -0
  9. package/dist/client/schemas/storageTypes/s3.d.ts +12 -0
  10. package/dist/client/schemas/storageTypes/tx-cos.d.ts +12 -0
  11. package/dist/client/templates/file.d.ts +4 -0
  12. package/dist/common/collections/storages.d.ts +11 -0
  13. package/dist/common/collections/storages.js +6 -0
  14. package/dist/externalVersion.js +8 -8
  15. package/dist/locale/de-DE.json +42 -29
  16. package/dist/locale/en-US.json +43 -30
  17. package/dist/locale/es-ES.json +54 -0
  18. package/dist/locale/fr-FR.json +45 -12
  19. package/dist/locale/hu-HU.json +48 -0
  20. package/dist/locale/id-ID.json +48 -0
  21. package/dist/locale/it-IT.json +43 -28
  22. package/dist/locale/ja-JP.json +43 -30
  23. package/dist/locale/ko-KR.json +46 -24
  24. package/dist/locale/nl-NL.json +53 -39
  25. package/dist/locale/pt-BR.json +54 -0
  26. package/dist/locale/ru-RU.json +47 -11
  27. package/dist/locale/tr-TR.json +47 -10
  28. package/dist/locale/uk-UA.json +54 -0
  29. package/dist/locale/vi-VN.json +48 -0
  30. package/dist/locale/zh-CN.json +41 -31
  31. package/dist/locale/zh-TW.json +54 -0
  32. package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
  33. package/dist/node_modules/@aws-sdk/lib-storage/LICENSE +201 -0
  34. package/dist/node_modules/{multer-s3 → @aws-sdk/lib-storage/dist-cjs}/index.js +574 -6229
  35. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.browser.js +8 -0
  36. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.js +10 -0
  37. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.native.js +8 -0
  38. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.shared.js +6 -0
  39. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/Upload.js +304 -0
  40. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/bytelength.js +27 -0
  41. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunker.js +24 -0
  42. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getChunkStream.js +24 -0
  43. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getChunkUint8Array.js +19 -0
  44. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getDataReadable.js +11 -0
  45. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getDataReadableStream.js +24 -0
  46. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/index.js +2 -0
  47. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.browser.js +5 -0
  48. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.js +7 -0
  49. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.native.js +5 -0
  50. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.shared.js +3 -0
  51. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/types.js +1 -0
  52. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/Upload.d.ts +59 -0
  53. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/bytelength.d.ts +1 -0
  54. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunker.d.ts +3 -0
  55. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getChunkStream.d.ts +2 -0
  56. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getChunkUint8Array.d.ts +2 -0
  57. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getDataReadable.d.ts +3 -0
  58. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getDataReadableStream.d.ts +1 -0
  59. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/index.d.ts +2 -0
  60. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.browser.d.ts +7 -0
  61. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.d.ts +8 -0
  62. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.native.d.ts +7 -0
  63. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.shared.d.ts +6 -0
  64. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/Upload.d.ts +43 -0
  65. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/bytelength.d.ts +1 -0
  66. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunker.d.ts +6 -0
  67. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getChunkStream.d.ts +6 -0
  68. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getChunkUint8Array.d.ts +5 -0
  69. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getDataReadable.d.ts +4 -0
  70. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getDataReadableStream.d.ts +3 -0
  71. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/index.d.ts +2 -0
  72. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.browser.d.ts +4 -0
  73. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.d.ts +4 -0
  74. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.native.d.ts +4 -0
  75. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.shared.d.ts +3 -0
  76. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/types.d.ts +22 -0
  77. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/types.d.ts +51 -0
  78. package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -0
  79. package/dist/node_modules/{multer-s3 → ali-oss}/LICENSE +1 -2
  80. package/dist/node_modules/ali-oss/dist/aliyun-oss-sdk.js +44018 -0
  81. package/dist/node_modules/ali-oss/dist/aliyun-oss-sdk.min.js +4 -0
  82. package/dist/node_modules/ali-oss/lib/browser/bucket.js +296 -0
  83. package/dist/node_modules/ali-oss/lib/browser/client.js +452 -0
  84. package/dist/node_modules/ali-oss/lib/browser/managed-upload.js +360 -0
  85. package/dist/node_modules/ali-oss/lib/browser/object.js +385 -0
  86. package/dist/node_modules/ali-oss/lib/browser/version.js +1 -0
  87. package/dist/node_modules/ali-oss/lib/browser.js +6 -0
  88. package/dist/node_modules/ali-oss/lib/bucket.js +337 -0
  89. package/dist/node_modules/{multer-aliyun-oss/index.js → ali-oss/lib/client.js} +2 -2
  90. package/dist/node_modules/ali-oss/lib/cluster.js +228 -0
  91. package/dist/node_modules/ali-oss/lib/common/bucket/abortBucketWorm.d.ts +4 -0
  92. package/dist/node_modules/ali-oss/lib/common/bucket/abortBucketWorm.js +14 -0
  93. package/dist/node_modules/ali-oss/lib/common/bucket/abortBucketWorm.ts +12 -0
  94. package/dist/node_modules/ali-oss/lib/common/bucket/completeBucketWorm.d.ts +4 -0
  95. package/dist/node_modules/ali-oss/lib/common/bucket/completeBucketWorm.js +14 -0
  96. package/dist/node_modules/ali-oss/lib/common/bucket/completeBucketWorm.ts +12 -0
  97. package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketEncryption.js +20 -0
  98. package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketInventory.d.ts +10 -0
  99. package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketInventory.js +22 -0
  100. package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketInventory.ts +21 -0
  101. package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketLifecycle.js +13 -0
  102. package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketPolicy.js +21 -0
  103. package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketTags.js +21 -0
  104. package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketWebsite.js +13 -0
  105. package/dist/node_modules/ali-oss/lib/common/bucket/extendBucketWorm.d.ts +4 -0
  106. package/dist/node_modules/ali-oss/lib/common/bucket/extendBucketWorm.js +23 -0
  107. package/dist/node_modules/ali-oss/lib/common/bucket/extendBucketWorm.ts +21 -0
  108. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketEncryption.js +21 -0
  109. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketInventory.d.ts +11 -0
  110. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketInventory.js +25 -0
  111. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketInventory.ts +24 -0
  112. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketLifecycle.js +33 -0
  113. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketPolicy.js +28 -0
  114. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketRequestPayment.js +25 -0
  115. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketStat.d.ts +23 -0
  116. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketStat.js +17 -0
  117. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketStat.ts +34 -0
  118. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketTags.js +23 -0
  119. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketVersioning.js +22 -0
  120. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketWebsite.js +28 -0
  121. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketWorm.d.ts +1 -0
  122. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketWorm.js +20 -0
  123. package/dist/node_modules/ali-oss/lib/common/bucket/getBucketWorm.ts +22 -0
  124. package/dist/node_modules/ali-oss/lib/common/bucket/index.js +34 -0
  125. package/dist/node_modules/ali-oss/lib/common/bucket/initiateBucketWorm.d.ts +5 -0
  126. package/dist/node_modules/ali-oss/lib/common/bucket/initiateBucketWorm.js +24 -0
  127. package/dist/node_modules/ali-oss/lib/common/bucket/initiateBucketWorm.ts +23 -0
  128. package/dist/node_modules/ali-oss/lib/common/bucket/listBucketInventory.d.ts +13 -0
  129. package/dist/node_modules/ali-oss/lib/common/bucket/listBucketInventory.js +29 -0
  130. package/dist/node_modules/ali-oss/lib/common/bucket/listBucketInventory.ts +32 -0
  131. package/dist/node_modules/ali-oss/lib/common/bucket/putBucket.js +31 -0
  132. package/dist/node_modules/ali-oss/lib/common/bucket/putBucketEncryption.js +36 -0
  133. package/dist/node_modules/ali-oss/lib/common/bucket/putBucketInventory.d.ts +36 -0
  134. package/dist/node_modules/ali-oss/lib/common/bucket/putBucketInventory.js +58 -0
  135. package/dist/node_modules/ali-oss/lib/common/bucket/putBucketInventory.ts +84 -0
  136. package/dist/node_modules/ali-oss/lib/common/bucket/putBucketLifecycle.js +127 -0
  137. package/dist/node_modules/ali-oss/lib/common/bucket/putBucketPolicy.js +27 -0
  138. package/dist/node_modules/ali-oss/lib/common/bucket/putBucketRequestPayment.js +40 -0
  139. package/dist/node_modules/ali-oss/lib/common/bucket/putBucketTags.js +39 -0
  140. package/dist/node_modules/ali-oss/lib/common/bucket/putBucketVersioning.js +35 -0
  141. package/dist/node_modules/ali-oss/lib/common/bucket/putBucketWebsite.js +50 -0
  142. package/dist/node_modules/ali-oss/lib/common/callback.js +27 -0
  143. package/dist/node_modules/ali-oss/lib/common/client/getReqUrl.d.ts +1 -0
  144. package/dist/node_modules/ali-oss/lib/common/client/getReqUrl.js +52 -0
  145. package/dist/node_modules/ali-oss/lib/common/client/getReqUrl.ts +51 -0
  146. package/dist/node_modules/ali-oss/lib/common/client/initOptions.js +72 -0
  147. package/dist/node_modules/ali-oss/lib/common/image/index.js +5 -0
  148. package/dist/node_modules/ali-oss/lib/common/image/processObjectSave.js +45 -0
  149. package/dist/node_modules/ali-oss/lib/common/multipart-copy.js +240 -0
  150. package/dist/node_modules/ali-oss/lib/common/multipart.js +271 -0
  151. package/dist/node_modules/ali-oss/lib/common/object/asyncSignatureUrl.js +57 -0
  152. package/dist/node_modules/ali-oss/lib/common/object/calculatePostSignature.js +35 -0
  153. package/dist/node_modules/ali-oss/lib/common/object/copyObject.js +74 -0
  154. package/dist/node_modules/ali-oss/lib/common/object/delete.js +22 -0
  155. package/dist/node_modules/ali-oss/lib/common/object/deleteMulti.js +57 -0
  156. package/dist/node_modules/ali-oss/lib/common/object/deleteObjectTagging.js +22 -0
  157. package/dist/node_modules/ali-oss/lib/common/object/generateObjectUrl.js +28 -0
  158. package/dist/node_modules/ali-oss/lib/common/object/get.js +64 -0
  159. package/dist/node_modules/ali-oss/lib/common/object/getACL.js +30 -0
  160. package/dist/node_modules/ali-oss/lib/common/object/getAsyncFetch.d.ts +1 -0
  161. package/dist/node_modules/ali-oss/lib/common/object/getAsyncFetch.js +26 -0
  162. package/dist/node_modules/ali-oss/lib/common/object/getAsyncFetch.ts +25 -0
  163. package/dist/node_modules/ali-oss/lib/common/object/getBucketVersions.js +98 -0
  164. package/dist/node_modules/ali-oss/lib/common/object/getObjectMeta.js +23 -0
  165. package/dist/node_modules/ali-oss/lib/common/object/getObjectTagging.js +34 -0
  166. package/dist/node_modules/ali-oss/lib/common/object/getObjectUrl.js +21 -0
  167. package/dist/node_modules/ali-oss/lib/common/object/getSymlink.js +23 -0
  168. package/dist/node_modules/ali-oss/lib/common/object/head.js +40 -0
  169. package/dist/node_modules/ali-oss/lib/common/object/index.js +26 -0
  170. package/dist/node_modules/ali-oss/lib/common/object/postAsyncFetch.d.ts +1 -0
  171. package/dist/node_modules/ali-oss/lib/common/object/postAsyncFetch.js +44 -0
  172. package/dist/node_modules/ali-oss/lib/common/object/postAsyncFetch.ts +46 -0
  173. package/dist/node_modules/ali-oss/lib/common/object/putACL.js +27 -0
  174. package/dist/node_modules/ali-oss/lib/common/object/putObjectTagging.js +43 -0
  175. package/dist/node_modules/ali-oss/lib/common/object/putSymlink.js +33 -0
  176. package/dist/node_modules/ali-oss/lib/common/object/signatureUrl.js +52 -0
  177. package/dist/node_modules/ali-oss/lib/common/object/signatureUrlV4.js +70 -0
  178. package/dist/node_modules/ali-oss/lib/common/parallel.js +177 -0
  179. package/dist/node_modules/ali-oss/lib/common/signUtils.js +355 -0
  180. package/dist/node_modules/ali-oss/lib/common/utils/checkBucketName.d.ts +1 -0
  181. package/dist/node_modules/ali-oss/lib/common/utils/checkBucketName.js +9 -0
  182. package/dist/node_modules/ali-oss/lib/common/utils/checkBucketName.ts +6 -0
  183. package/dist/node_modules/ali-oss/lib/common/utils/checkBucketNameTest.d.ts +1 -0
  184. package/dist/node_modules/ali-oss/lib/common/utils/checkBucketNameTest.js +14 -0
  185. package/dist/node_modules/ali-oss/lib/common/utils/checkBucketNameTest.ts +12 -0
  186. package/dist/node_modules/ali-oss/lib/common/utils/checkBucketTag.d.ts +1 -0
  187. package/dist/node_modules/ali-oss/lib/common/utils/checkBucketTag.js +49 -0
  188. package/dist/node_modules/ali-oss/lib/common/utils/checkBucketTag.ts +52 -0
  189. package/dist/node_modules/ali-oss/lib/common/utils/checkConfigValid.d.ts +1 -0
  190. package/dist/node_modules/ali-oss/lib/common/utils/checkConfigValid.js +30 -0
  191. package/dist/node_modules/ali-oss/lib/common/utils/checkConfigValid.ts +27 -0
  192. package/dist/node_modules/ali-oss/lib/common/utils/checkEnv.d.ts +1 -0
  193. package/dist/node_modules/ali-oss/lib/common/utils/checkEnv.js +9 -0
  194. package/dist/node_modules/ali-oss/lib/common/utils/checkEnv.ts +5 -0
  195. package/dist/node_modules/ali-oss/lib/common/utils/checkObjectTag.d.ts +1 -0
  196. package/dist/node_modules/ali-oss/lib/common/utils/checkObjectTag.js +50 -0
  197. package/dist/node_modules/ali-oss/lib/common/utils/checkObjectTag.ts +53 -0
  198. package/dist/node_modules/ali-oss/lib/common/utils/checkUserAgent.d.ts +1 -0
  199. package/dist/node_modules/ali-oss/lib/common/utils/checkUserAgent.js +7 -0
  200. package/dist/node_modules/ali-oss/lib/common/utils/checkUserAgent.ts +4 -0
  201. package/dist/node_modules/ali-oss/lib/common/utils/checkValid.d.ts +1 -0
  202. package/dist/node_modules/ali-oss/lib/common/utils/checkValid.js +14 -0
  203. package/dist/node_modules/ali-oss/lib/common/utils/checkValid.ts +9 -0
  204. package/dist/node_modules/ali-oss/lib/common/utils/createRequest.d.ts +8 -0
  205. package/dist/node_modules/ali-oss/lib/common/utils/createRequest.js +139 -0
  206. package/dist/node_modules/ali-oss/lib/common/utils/createRequest.ts +169 -0
  207. package/dist/node_modules/ali-oss/lib/common/utils/dataFix.d.ts +12 -0
  208. package/dist/node_modules/ali-oss/lib/common/utils/dataFix.js +63 -0
  209. package/dist/node_modules/ali-oss/lib/common/utils/dataFix.ts +78 -0
  210. package/dist/node_modules/ali-oss/lib/common/utils/deepCopy.d.ts +2 -0
  211. package/dist/node_modules/ali-oss/lib/common/utils/deepCopy.js +41 -0
  212. package/dist/node_modules/ali-oss/lib/common/utils/deepCopy.ts +47 -0
  213. package/dist/node_modules/ali-oss/lib/common/utils/encodeString.d.ts +1 -0
  214. package/dist/node_modules/ali-oss/lib/common/utils/encodeString.js +12 -0
  215. package/dist/node_modules/ali-oss/lib/common/utils/encodeString.ts +7 -0
  216. package/dist/node_modules/ali-oss/lib/common/utils/encoder.d.ts +2 -0
  217. package/dist/node_modules/ali-oss/lib/common/utils/encoder.js +9 -0
  218. package/dist/node_modules/ali-oss/lib/common/utils/encoder.ts +6 -0
  219. package/dist/node_modules/ali-oss/lib/common/utils/formatInventoryConfig.d.ts +1 -0
  220. package/dist/node_modules/ali-oss/lib/common/utils/formatInventoryConfig.js +45 -0
  221. package/dist/node_modules/ali-oss/lib/common/utils/formatInventoryConfig.ts +41 -0
  222. package/dist/node_modules/ali-oss/lib/common/utils/formatObjKey.d.ts +6 -0
  223. package/dist/node_modules/ali-oss/lib/common/utils/formatObjKey.js +34 -0
  224. package/dist/node_modules/ali-oss/lib/common/utils/formatObjKey.ts +35 -0
  225. package/dist/node_modules/ali-oss/lib/common/utils/formatTag.d.ts +1 -0
  226. package/dist/node_modules/ali-oss/lib/common/utils/formatTag.js +22 -0
  227. package/dist/node_modules/ali-oss/lib/common/utils/formatTag.ts +20 -0
  228. package/dist/node_modules/ali-oss/lib/common/utils/getStandardRegion.d.ts +1 -0
  229. package/dist/node_modules/ali-oss/lib/common/utils/getStandardRegion.js +7 -0
  230. package/dist/node_modules/ali-oss/lib/common/utils/getStandardRegion.ts +3 -0
  231. package/dist/node_modules/ali-oss/lib/common/utils/getStrBytesCount.d.ts +1 -0
  232. package/dist/node_modules/ali-oss/lib/common/utils/getStrBytesCount.js +17 -0
  233. package/dist/node_modules/ali-oss/lib/common/utils/getStrBytesCount.ts +12 -0
  234. package/dist/node_modules/ali-oss/lib/common/utils/getUserAgent.d.ts +1 -0
  235. package/dist/node_modules/ali-oss/lib/common/utils/getUserAgent.js +18 -0
  236. package/dist/node_modules/ali-oss/lib/common/utils/getUserAgent.ts +14 -0
  237. package/dist/node_modules/ali-oss/lib/common/utils/isArray.d.ts +1 -0
  238. package/dist/node_modules/ali-oss/lib/common/utils/isArray.js +6 -0
  239. package/dist/node_modules/ali-oss/lib/common/utils/isArray.ts +3 -0
  240. package/dist/node_modules/ali-oss/lib/common/utils/isBlob.d.ts +1 -0
  241. package/dist/node_modules/ali-oss/lib/common/utils/isBlob.js +7 -0
  242. package/dist/node_modules/ali-oss/lib/common/utils/isBlob.ts +3 -0
  243. package/dist/node_modules/ali-oss/lib/common/utils/isBuffer.d.ts +1 -0
  244. package/dist/node_modules/ali-oss/lib/common/utils/isBuffer.js +7 -0
  245. package/dist/node_modules/ali-oss/lib/common/utils/isBuffer.ts +3 -0
  246. package/dist/node_modules/ali-oss/lib/common/utils/isDingTalk.d.ts +1 -0
  247. package/dist/node_modules/ali-oss/lib/common/utils/isDingTalk.js +10 -0
  248. package/dist/node_modules/ali-oss/lib/common/utils/isDingTalk.ts +6 -0
  249. package/dist/node_modules/ali-oss/lib/common/utils/isFile.d.ts +1 -0
  250. package/dist/node_modules/ali-oss/lib/common/utils/isFile.js +6 -0
  251. package/dist/node_modules/ali-oss/lib/common/utils/isFile.ts +3 -0
  252. package/dist/node_modules/ali-oss/lib/common/utils/isFunction.d.ts +1 -0
  253. package/dist/node_modules/ali-oss/lib/common/utils/isFunction.js +6 -0
  254. package/dist/node_modules/ali-oss/lib/common/utils/isFunction.ts +3 -0
  255. package/dist/node_modules/ali-oss/lib/common/utils/isIP.d.ts +6 -0
  256. package/dist/node_modules/ali-oss/lib/common/utils/isIP.js +14 -0
  257. package/dist/node_modules/ali-oss/lib/common/utils/isIP.ts +12 -0
  258. package/dist/node_modules/ali-oss/lib/common/utils/isObject.d.ts +1 -0
  259. package/dist/node_modules/ali-oss/lib/common/utils/isObject.js +6 -0
  260. package/dist/node_modules/ali-oss/lib/common/utils/isObject.ts +3 -0
  261. package/dist/node_modules/ali-oss/lib/common/utils/lowercaseKeyHeader.d.ts +1 -0
  262. package/dist/node_modules/ali-oss/lib/common/utils/lowercaseKeyHeader.js +14 -0
  263. package/dist/node_modules/ali-oss/lib/common/utils/lowercaseKeyHeader.ts +11 -0
  264. package/dist/node_modules/ali-oss/lib/common/utils/obj2xml.d.ts +1 -0
  265. package/dist/node_modules/ali-oss/lib/common/utils/obj2xml.js +43 -0
  266. package/dist/node_modules/ali-oss/lib/common/utils/obj2xml.ts +37 -0
  267. package/dist/node_modules/ali-oss/lib/common/utils/omit.d.ts +1 -0
  268. package/dist/node_modules/ali-oss/lib/common/utils/omit.js +11 -0
  269. package/dist/node_modules/ali-oss/lib/common/utils/omit.ts +9 -0
  270. package/dist/node_modules/ali-oss/lib/common/utils/policy2Str.d.ts +1 -0
  271. package/dist/node_modules/ali-oss/lib/common/utils/policy2Str.js +21 -0
  272. package/dist/node_modules/ali-oss/lib/common/utils/policy2Str.ts +15 -0
  273. package/dist/node_modules/ali-oss/lib/common/utils/retry.d.ts +1 -0
  274. package/dist/node_modules/ali-oss/lib/common/utils/retry.js +30 -0
  275. package/dist/node_modules/ali-oss/lib/common/utils/retry.ts +26 -0
  276. package/dist/node_modules/ali-oss/lib/common/utils/setRegion.d.ts +3 -0
  277. package/dist/node_modules/ali-oss/lib/common/utils/setRegion.js +20 -0
  278. package/dist/node_modules/ali-oss/lib/common/utils/setRegion.ts +15 -0
  279. package/dist/node_modules/ali-oss/lib/common/utils/setSTSToken.d.ts +2 -0
  280. package/dist/node_modules/ali-oss/lib/common/utils/setSTSToken.js +36 -0
  281. package/dist/node_modules/ali-oss/lib/common/utils/setSTSToken.ts +32 -0
  282. package/dist/node_modules/ali-oss/lib/global.d.ts +6 -0
  283. package/dist/node_modules/ali-oss/lib/image.js +146 -0
  284. package/dist/node_modules/ali-oss/lib/managed-upload.js +380 -0
  285. package/dist/node_modules/ali-oss/lib/object.js +420 -0
  286. package/dist/node_modules/ali-oss/lib/rtmp.js +295 -0
  287. package/dist/node_modules/ali-oss/lib/setConfig.d.ts +3 -0
  288. package/dist/node_modules/ali-oss/lib/setConfig.js +42 -0
  289. package/dist/node_modules/ali-oss/lib/setConfig.ts +52 -0
  290. package/dist/node_modules/ali-oss/lib/sts.js +156 -0
  291. package/dist/node_modules/ali-oss/lib/types/experimental.d.ts +1 -0
  292. package/dist/node_modules/ali-oss/lib/types/experimental.js +2 -0
  293. package/dist/node_modules/ali-oss/lib/types/experimental.ts +1 -0
  294. package/dist/node_modules/ali-oss/node_modules/bowser/.editorconfig +17 -0
  295. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/.name +1 -0
  296. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/bowser.iml +8 -0
  297. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/encodings.xml +6 -0
  298. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/inspectionProfiles/Project_Default.xml +6 -0
  299. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/jsLibraryMappings.xml +8 -0
  300. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/markdown-exported-files.xml +8 -0
  301. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/markdown-navigator/profiles_settings.xml +3 -0
  302. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/markdown-navigator.xml +67 -0
  303. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/misc.xml +6 -0
  304. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/modules.xml +8 -0
  305. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/vcs.xml +6 -0
  306. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/watcherTasks.xml +4 -0
  307. package/dist/node_modules/ali-oss/node_modules/bowser/.idea/workspace.xml +696 -0
  308. package/dist/node_modules/ali-oss/node_modules/bowser/.travis.yml +8 -0
  309. package/dist/node_modules/ali-oss/node_modules/bowser/bower.json +33 -0
  310. package/dist/node_modules/ali-oss/node_modules/bowser/bowser.js +644 -0
  311. package/dist/node_modules/ali-oss/node_modules/bowser/bowser.min.js +6 -0
  312. package/dist/node_modules/ali-oss/node_modules/bowser/package.json +38 -0
  313. package/dist/node_modules/ali-oss/node_modules/bowser/src/bowser.js +644 -0
  314. package/dist/node_modules/ali-oss/node_modules/bowser/test/test.js +151 -0
  315. package/dist/node_modules/ali-oss/node_modules/bowser/typings.d.ts +115 -0
  316. package/dist/node_modules/ali-oss/node_modules/dateformat/.vs/ProjectSettings.json +3 -0
  317. package/dist/node_modules/ali-oss/node_modules/dateformat/.vs/config/applicationhost.config +1031 -0
  318. package/dist/node_modules/ali-oss/node_modules/dateformat/.vs/node-dateformat/v15/.suo +0 -0
  319. package/dist/node_modules/ali-oss/node_modules/dateformat/.vs/slnx.sqlite +0 -0
  320. package/dist/node_modules/ali-oss/node_modules/dateformat/lib/dateformat.js +226 -0
  321. package/dist/node_modules/ali-oss/node_modules/dateformat/package.json +30 -0
  322. package/dist/node_modules/ali-oss/node_modules/mime/Mime.js +97 -0
  323. package/dist/node_modules/ali-oss/node_modules/mime/cli.js +46 -0
  324. package/dist/node_modules/ali-oss/node_modules/mime/index.js +4 -0
  325. package/dist/node_modules/ali-oss/node_modules/mime/lite.js +4 -0
  326. package/dist/node_modules/ali-oss/node_modules/mime/package.json +52 -0
  327. package/dist/node_modules/ali-oss/node_modules/mime/types/other.js +1 -0
  328. package/dist/node_modules/ali-oss/node_modules/mime/types/standard.js +1 -0
  329. package/dist/node_modules/ali-oss/package.json +1 -0
  330. package/dist/node_modules/ali-oss/shims/crypto/crypto.js +98 -0
  331. package/dist/node_modules/ali-oss/shims/crypto/helpers.js +36 -0
  332. package/dist/node_modules/ali-oss/shims/crypto/md5.js +152 -0
  333. package/dist/node_modules/ali-oss/shims/crypto/sha.js +91 -0
  334. package/dist/node_modules/ali-oss/shims/crypto/sha256.js +163 -0
  335. package/dist/node_modules/ali-oss/shims/debug.js +3 -0
  336. package/dist/node_modules/ali-oss/shims/is-type-of.js +18 -0
  337. package/dist/node_modules/ali-oss/shims/process.js +35 -0
  338. package/dist/node_modules/ali-oss/shims/stream-http/index.js +82 -0
  339. package/dist/node_modules/ali-oss/shims/stream-http/lib/capability.js +72 -0
  340. package/dist/node_modules/ali-oss/shims/stream-http/lib/request.js +320 -0
  341. package/dist/node_modules/ali-oss/shims/stream-http/lib/response.js +217 -0
  342. package/dist/node_modules/ali-oss/shims/url/index.js +696 -0
  343. package/dist/node_modules/ali-oss/shims/url/util.js +16 -0
  344. package/dist/node_modules/ali-oss/shims/utility.js +25 -0
  345. package/dist/node_modules/ali-oss/shims/xhr.js +798 -0
  346. package/dist/node_modules/mime-match/package.json +1 -1
  347. package/dist/node_modules/mime-types/package.json +1 -1
  348. package/dist/node_modules/mkdirp/package.json +1 -1
  349. package/dist/node_modules/multer-cos/package.json +1 -1
  350. package/dist/node_modules/url-join/package.json +1 -1
  351. package/dist/server/actions/storages.js +4 -6
  352. package/dist/server/server.js +1 -0
  353. package/dist/server/storages/ali-oss.d.ts +15 -1
  354. package/dist/server/storages/ali-oss.js +66 -2
  355. package/dist/server/storages/index.d.ts +1 -0
  356. package/dist/server/storages/local.js +1 -1
  357. package/dist/server/storages/s3.d.ts +10 -3
  358. package/dist/server/storages/s3.js +121 -29
  359. package/dist/server/storages/tx-cos.js +1 -1
  360. package/dist/server/utils.d.ts +1 -0
  361. package/dist/server/utils.js +43 -0
  362. package/package.json +7 -3
  363. package/dist/node_modules/multer-aliyun-oss/package.json +0 -1
  364. package/dist/node_modules/multer-s3/.gitattributes +0 -1
  365. package/dist/node_modules/multer-s3/.travis.yml +0 -6
  366. package/dist/node_modules/multer-s3/package.json +0 -1
  367. package/dist/node_modules/multer-s3/test/basic.js +0 -293
  368. package/dist/node_modules/multer-s3/test/files/a.txt +0 -1
  369. package/dist/node_modules/multer-s3/test/files/test.svg +0 -3
  370. package/dist/node_modules/multer-s3/test/files/test2.svg +0 -9
  371. package/dist/node_modules/multer-s3/test/util/mock-s3.js +0 -17
@@ -0,0 +1,72 @@
1
+ exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream);
2
+
3
+ exports.writableStream = isFunction(global.WritableStream);
4
+
5
+ exports.abortController = isFunction(global.AbortController);
6
+
7
+ exports.blobConstructor = false;
8
+ try {
9
+ new Blob([new ArrayBuffer(1)]);
10
+ exports.blobConstructor = true;
11
+ } catch (e) {}
12
+
13
+ // The xhr request to example.com may violate some restrictive CSP configurations,
14
+ // so if we're running in a browser that supports `fetch`, avoid calling getXHR()
15
+ // and assume support for certain features below.
16
+ var xhr;
17
+ function getXHR() {
18
+ // Cache the xhr value
19
+ if (xhr !== undefined) return xhr;
20
+
21
+ if (global.XMLHttpRequest) {
22
+ xhr = new global.XMLHttpRequest();
23
+ // If XDomainRequest is available (ie only, where xhr might not work
24
+ // cross domain), use the page location. Otherwise use example.com
25
+ // Note: this doesn't actually make an http request.
26
+ try {
27
+ xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com');
28
+ } catch (e) {
29
+ xhr = null;
30
+ }
31
+ } else {
32
+ // Service workers don't have XHR
33
+ xhr = null;
34
+ }
35
+ return xhr;
36
+ }
37
+
38
+ function checkTypeSupport(type) {
39
+ var xhr = getXHR();
40
+ if (!xhr) return false;
41
+ try {
42
+ xhr.responseType = type;
43
+ return xhr.responseType === type;
44
+ } catch (e) {}
45
+ return false;
46
+ }
47
+
48
+ // For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
49
+ // Safari 7.1 appears to have fixed this bug.
50
+ var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined';
51
+ var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice);
52
+
53
+ // If fetch is supported, then arraybuffer will be supported too. Skip calling
54
+ // checkTypeSupport(), since that calls getXHR().
55
+ exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer'));
56
+
57
+ // These next two tests unavoidably show warnings in Chrome. Since fetch will always
58
+ // be used if it's available, just return false for these to avoid the warnings.
59
+ exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream');
60
+ exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer && checkTypeSupport('moz-chunked-arraybuffer');
61
+
62
+ // If fetch is supported, then overrideMimeType will be supported too. Skip calling
63
+ // getXHR().
64
+ exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false);
65
+
66
+ exports.vbArray = isFunction(global.VBArray);
67
+
68
+ function isFunction(value) {
69
+ return typeof value === 'function';
70
+ }
71
+
72
+ xhr = null; // Help gc
@@ -0,0 +1,320 @@
1
+ var capability = require('./capability');
2
+ var inherits = require('inherits');
3
+ var response = require('./response');
4
+ var stream = require('readable-stream');
5
+ var toArrayBuffer = require('to-arraybuffer');
6
+
7
+ var IncomingMessage = response.IncomingMessage;
8
+ var rStates = response.readyStates;
9
+
10
+ function decideMode(preferBinary, useFetch) {
11
+ if (capability.fetch && useFetch) {
12
+ return 'fetch';
13
+ } else if (capability.mozchunkedarraybuffer) {
14
+ return 'moz-chunked-arraybuffer';
15
+ } else if (capability.msstream) {
16
+ return 'ms-stream';
17
+ } else if (capability.arraybuffer && preferBinary) {
18
+ return 'arraybuffer';
19
+ } else if (capability.vbArray && preferBinary) {
20
+ return 'text:vbarray';
21
+ } else {
22
+ return 'text';
23
+ }
24
+ }
25
+
26
+ var ClientRequest = (module.exports = function (opts) {
27
+ var self = this;
28
+ stream.Writable.call(self);
29
+
30
+ self._opts = opts;
31
+ self._body = [];
32
+ self._headers = {};
33
+ if (opts.auth) self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'));
34
+ Object.keys(opts.headers).forEach(function (name) {
35
+ self.setHeader(name, opts.headers[name]);
36
+ });
37
+
38
+ var preferBinary;
39
+ var useFetch = true;
40
+ if (opts.mode === 'disable-fetch' || ('requestTimeout' in opts && !capability.abortController)) {
41
+ // If the use of XHR should be preferred. Not typically needed.
42
+ useFetch = false;
43
+ preferBinary = true;
44
+ } else if (opts.mode === 'prefer-streaming') {
45
+ // If streaming is a high priority but binary compatibility and
46
+ // the accuracy of the 'content-type' header aren't
47
+ preferBinary = false;
48
+ } else if (opts.mode === 'allow-wrong-content-type') {
49
+ // If streaming is more important than preserving the 'content-type' header
50
+ preferBinary = !capability.overrideMimeType;
51
+ } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
52
+ // Use binary if text streaming may corrupt data or the content-type header, or for speed
53
+ preferBinary = true;
54
+ } else {
55
+ throw new Error('Invalid value for opts.mode');
56
+ }
57
+ self._mode = decideMode(preferBinary, useFetch);
58
+ self._fetchTimer = null;
59
+
60
+ self.on('finish', function () {
61
+ self._onFinish();
62
+ });
63
+ });
64
+
65
+ inherits(ClientRequest, stream.Writable);
66
+
67
+ ClientRequest.prototype.setHeader = function (name, value) {
68
+ var self = this;
69
+ var lowerName = name.toLowerCase();
70
+ // This check is not necessary, but it prevents warnings from browsers about setting unsafe
71
+ // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
72
+ // http-browserify did it, so I will too.
73
+ if (unsafeHeaders.indexOf(lowerName) !== -1) return;
74
+
75
+ self._headers[lowerName] = {
76
+ name: name,
77
+ value: value
78
+ };
79
+ };
80
+
81
+ ClientRequest.prototype.getHeader = function (name) {
82
+ var header = this._headers[name.toLowerCase()];
83
+ if (header) return header.value;
84
+ return null;
85
+ };
86
+
87
+ ClientRequest.prototype.removeHeader = function (name) {
88
+ var self = this;
89
+ delete self._headers[name.toLowerCase()];
90
+ };
91
+
92
+ ClientRequest.prototype._onFinish = function () {
93
+ var self = this;
94
+
95
+ if (self._destroyed) return;
96
+ var opts = self._opts;
97
+
98
+ var headersObj = self._headers;
99
+ var body = null;
100
+ if (opts.method !== 'GET' && opts.method !== 'HEAD') {
101
+ if (capability.arraybuffer) {
102
+ body = toArrayBuffer(Buffer.concat(self._body));
103
+ } else if (capability.blobConstructor) {
104
+ body = new global.Blob(
105
+ self._body.map(function (buffer) {
106
+ return toArrayBuffer(buffer);
107
+ }),
108
+ {
109
+ type: (headersObj['content-type'] || {}).value || ''
110
+ }
111
+ );
112
+ } else {
113
+ // get utf8 string
114
+ body = Buffer.concat(self._body).toString();
115
+ }
116
+ }
117
+
118
+ // create flattened list of headers
119
+ var headersList = [];
120
+ Object.keys(headersObj).forEach(function (keyName) {
121
+ var name = headersObj[keyName].name;
122
+ var value = headersObj[keyName].value;
123
+ if (Array.isArray(value)) {
124
+ value.forEach(function (v) {
125
+ headersList.push([name, v]);
126
+ });
127
+ } else {
128
+ headersList.push([name, value]);
129
+ }
130
+ });
131
+
132
+ if (self._mode === 'fetch') {
133
+ var signal = null;
134
+ var fetchTimer = null;
135
+ if (capability.abortController) {
136
+ var controller = new AbortController();
137
+ signal = controller.signal;
138
+ self._fetchAbortController = controller;
139
+
140
+ if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
141
+ self._fetchTimer = global.setTimeout(function () {
142
+ self.emit('requestTimeout');
143
+ if (self._fetchAbortController) self._fetchAbortController.abort();
144
+ }, opts.requestTimeout);
145
+ }
146
+ }
147
+
148
+ global
149
+ .fetch(self._opts.url, {
150
+ method: self._opts.method,
151
+ headers: headersList,
152
+ body: body || undefined,
153
+ mode: 'cors',
154
+ credentials: opts.withCredentials ? 'include' : 'same-origin',
155
+ signal: signal
156
+ })
157
+ .then(
158
+ function (response) {
159
+ self._fetchResponse = response;
160
+ self._connect();
161
+ },
162
+ function (reason) {
163
+ global.clearTimeout(self._fetchTimer);
164
+ if (!self._destroyed) self.emit('error', reason);
165
+ }
166
+ );
167
+ } else {
168
+ var xhr = (self._xhr = new global.XMLHttpRequest());
169
+ try {
170
+ xhr.open(self._opts.method, self._opts.url, true);
171
+ } catch (err) {
172
+ process.nextTick(function () {
173
+ self.emit('error', err);
174
+ });
175
+ return;
176
+ }
177
+
178
+ // Can't set responseType on really old browsers
179
+ if ('responseType' in xhr) xhr.responseType = self._mode.split(':')[0];
180
+
181
+ if ('withCredentials' in xhr) xhr.withCredentials = !!opts.withCredentials;
182
+
183
+ if (self._mode === 'text' && 'overrideMimeType' in xhr) xhr.overrideMimeType('text/plain; charset=x-user-defined');
184
+
185
+ if ('requestTimeout' in opts) {
186
+ xhr.timeout = opts.requestTimeout;
187
+ xhr.ontimeout = function () {
188
+ self.emit('requestTimeout');
189
+ };
190
+ }
191
+
192
+ headersList.forEach(function (header) {
193
+ xhr.setRequestHeader(header[0], header[1]);
194
+ });
195
+
196
+ self._response = null;
197
+ xhr.onreadystatechange = function () {
198
+ switch (xhr.readyState) {
199
+ case rStates.LOADING:
200
+ case rStates.DONE:
201
+ self._onXHRProgress();
202
+ break;
203
+ }
204
+ };
205
+ // Necessary for streaming in Firefox, since xhr.response is ONLY defined
206
+ // in onprogress, not in onreadystatechange with xhr.readyState = 3
207
+ if (self._mode === 'moz-chunked-arraybuffer') {
208
+ xhr.onprogress = function () {
209
+ self._onXHRProgress();
210
+ };
211
+ }
212
+
213
+ xhr.onerror = function () {
214
+ if (self._destroyed) return;
215
+ self.emit('error', new Error('XHR error'));
216
+ };
217
+
218
+ try {
219
+ xhr.send(body);
220
+ } catch (err) {
221
+ process.nextTick(function () {
222
+ self.emit('error', err);
223
+ });
224
+ return;
225
+ }
226
+ }
227
+ };
228
+
229
+ /**
230
+ * Checks if xhr.status is readable and non-zero, indicating no error.
231
+ * Even though the spec says it should be available in readyState 3,
232
+ * accessing it throws an exception in IE8
233
+ */
234
+ function statusValid(xhr) {
235
+ try {
236
+ var status = xhr.status;
237
+ return status !== null && status !== 0;
238
+ } catch (e) {
239
+ return false;
240
+ }
241
+ }
242
+
243
+ ClientRequest.prototype._onXHRProgress = function () {
244
+ var self = this;
245
+
246
+ if (!statusValid(self._xhr) || self._destroyed) return;
247
+
248
+ if (!self._response) self._connect();
249
+
250
+ self._response._onXHRProgress();
251
+ };
252
+
253
+ ClientRequest.prototype._connect = function () {
254
+ var self = this;
255
+
256
+ if (self._destroyed) return;
257
+
258
+ self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._fetchTimer);
259
+ self._response.on('error', function (err) {
260
+ self.emit('error', err);
261
+ });
262
+
263
+ self.emit('response', self._response);
264
+ };
265
+
266
+ ClientRequest.prototype._write = function (chunk, encoding, cb) {
267
+ var self = this;
268
+
269
+ self._body.push(chunk);
270
+ cb();
271
+ };
272
+
273
+ ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
274
+ var self = this;
275
+ self._destroyed = true;
276
+ global.clearTimeout(self._fetchTimer);
277
+ if (self._response) self._response._destroyed = true;
278
+ if (self._xhr) self._xhr.abort();
279
+ else if (self._fetchAbortController) self._fetchAbortController.abort();
280
+ };
281
+
282
+ ClientRequest.prototype.end = function (data, encoding, cb) {
283
+ var self = this;
284
+ if (typeof data === 'function') {
285
+ cb = data;
286
+ data = undefined;
287
+ }
288
+
289
+ stream.Writable.prototype.end.call(self, data, encoding, cb);
290
+ };
291
+
292
+ ClientRequest.prototype.flushHeaders = function () {};
293
+ ClientRequest.prototype.setTimeout = function () {};
294
+ ClientRequest.prototype.setNoDelay = function () {};
295
+ ClientRequest.prototype.setSocketKeepAlive = function () {};
296
+
297
+ // Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
298
+ var unsafeHeaders = [
299
+ 'accept-charset',
300
+ 'accept-encoding',
301
+ 'access-control-request-headers',
302
+ 'access-control-request-method',
303
+ 'connection',
304
+ 'content-length',
305
+ 'cookie',
306
+ 'cookie2',
307
+ 'date',
308
+ 'dnt',
309
+ 'expect',
310
+ 'host',
311
+ 'keep-alive',
312
+ 'origin',
313
+ 'referer',
314
+ 'te',
315
+ 'trailer',
316
+ 'transfer-encoding',
317
+ 'upgrade',
318
+ 'user-agent',
319
+ 'via'
320
+ ];
@@ -0,0 +1,217 @@
1
+ var capability = require('./capability');
2
+ var inherits = require('inherits');
3
+ var stream = require('readable-stream');
4
+
5
+ var rStates = (exports.readyStates = {
6
+ UNSENT: 0,
7
+ OPENED: 1,
8
+ HEADERS_RECEIVED: 2,
9
+ LOADING: 3,
10
+ DONE: 4
11
+ });
12
+
13
+ var IncomingMessage = (exports.IncomingMessage = function (xhr, response, mode, fetchTimer) {
14
+ var self = this;
15
+ stream.Readable.call(self);
16
+
17
+ self._mode = mode;
18
+ self.headers = {};
19
+ self.rawHeaders = [];
20
+ self.trailers = {};
21
+ self.rawTrailers = [];
22
+
23
+ // Fake the 'close' event, but only once 'end' fires
24
+ self.on('end', function () {
25
+ // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
26
+ process.nextTick(function () {
27
+ self.emit('close');
28
+ });
29
+ });
30
+
31
+ if (mode === 'fetch') {
32
+ self._fetchResponse = response;
33
+
34
+ self.url = response.url;
35
+ self.statusCode = response.status;
36
+ self.statusMessage = response.statusText;
37
+
38
+ response.headers.forEach(function (header, key) {
39
+ self.headers[key.toLowerCase()] = header;
40
+ self.rawHeaders.push(key, header);
41
+ });
42
+
43
+ if (capability.writableStream) {
44
+ var writable = new WritableStream({
45
+ write: function (chunk) {
46
+ return new Promise(function (resolve, reject) {
47
+ if (self._destroyed) {
48
+ reject();
49
+ } else if (self.push(new Buffer(chunk))) {
50
+ resolve();
51
+ } else {
52
+ self._resumeFetch = resolve;
53
+ }
54
+ });
55
+ },
56
+ close: function () {
57
+ global.clearTimeout(fetchTimer);
58
+ if (!self._destroyed) self.push(null);
59
+ },
60
+ abort: function (err) {
61
+ if (!self._destroyed) self.emit('error', err);
62
+ }
63
+ });
64
+
65
+ try {
66
+ response.body.pipeTo(writable).catch(function (err) {
67
+ global.clearTimeout(fetchTimer);
68
+ if (!self._destroyed) self.emit('error', err);
69
+ });
70
+ return;
71
+ } catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
72
+ }
73
+ // fallback for when writableStream or pipeTo aren't available
74
+ var reader = response.body.getReader();
75
+ function read() {
76
+ reader
77
+ .read()
78
+ .then(function (result) {
79
+ if (self._destroyed) return;
80
+ if (result.done) {
81
+ global.clearTimeout(fetchTimer);
82
+ self.push(null);
83
+ return;
84
+ }
85
+ self.push(new Buffer(result.value));
86
+ read();
87
+ })
88
+ .catch(function (err) {
89
+ global.clearTimeout(fetchTimer);
90
+ if (!self._destroyed) self.emit('error', err);
91
+ });
92
+ }
93
+ read();
94
+ } else {
95
+ self._xhr = xhr;
96
+ self._pos = 0;
97
+
98
+ self.url = xhr.responseURL;
99
+ self.statusCode = xhr.status;
100
+ self.statusMessage = xhr.statusText;
101
+ var headers = xhr.getAllResponseHeaders().split(/\r?\n/);
102
+ headers.forEach(function (header) {
103
+ var matches = header.match(/^([^:]+):\s*(.*)/);
104
+ if (matches) {
105
+ var key = matches[1].toLowerCase();
106
+ if (key === 'set-cookie') {
107
+ if (self.headers[key] === undefined) {
108
+ self.headers[key] = [];
109
+ }
110
+ self.headers[key].push(matches[2]);
111
+ } else if (self.headers[key] !== undefined) {
112
+ self.headers[key] += ', ' + matches[2];
113
+ } else {
114
+ self.headers[key] = matches[2];
115
+ }
116
+ self.rawHeaders.push(matches[1], matches[2]);
117
+ }
118
+ });
119
+
120
+ self._charset = 'x-user-defined';
121
+ if (!capability.overrideMimeType) {
122
+ var mimeType = self.rawHeaders['mime-type'];
123
+ if (mimeType) {
124
+ var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/);
125
+ if (charsetMatch) {
126
+ self._charset = charsetMatch[1].toLowerCase();
127
+ }
128
+ }
129
+ if (!self._charset) self._charset = 'utf-8'; // best guess
130
+ }
131
+ }
132
+ });
133
+
134
+ inherits(IncomingMessage, stream.Readable);
135
+
136
+ IncomingMessage.prototype._read = function () {
137
+ var self = this;
138
+
139
+ var resolve = self._resumeFetch;
140
+ if (resolve) {
141
+ self._resumeFetch = null;
142
+ resolve();
143
+ }
144
+ };
145
+
146
+ IncomingMessage.prototype._onXHRProgress = function () {
147
+ var self = this;
148
+
149
+ var xhr = self._xhr;
150
+
151
+ var response = null;
152
+ switch (self._mode) {
153
+ case 'text:vbarray': // For IE9
154
+ if (xhr.readyState !== rStates.DONE) break;
155
+ try {
156
+ // This fails in IE8
157
+ response = new global.VBArray(xhr.responseBody).toArray();
158
+ } catch (e) {}
159
+ if (response !== null) {
160
+ self.push(new Buffer(response));
161
+ break;
162
+ }
163
+ // Falls through in IE8
164
+ case 'text':
165
+ try {
166
+ // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
167
+ response = xhr.responseText;
168
+ } catch (e) {
169
+ self._mode = 'text:vbarray';
170
+ break;
171
+ }
172
+ if (response.length > self._pos) {
173
+ var newData = response.substr(self._pos);
174
+ if (self._charset === 'x-user-defined') {
175
+ var buffer = new Buffer(newData.length);
176
+ for (var i = 0; i < newData.length; i++) buffer[i] = newData.charCodeAt(i) & 0xff;
177
+
178
+ self.push(buffer);
179
+ } else {
180
+ self.push(newData, self._charset);
181
+ }
182
+ self._pos = response.length;
183
+ }
184
+ break;
185
+ case 'arraybuffer':
186
+ if (xhr.readyState !== rStates.DONE || !xhr.response) break;
187
+ response = xhr.response;
188
+ self.push(new Buffer(new Uint8Array(response)));
189
+ break;
190
+ case 'moz-chunked-arraybuffer': // take whole
191
+ response = xhr.response;
192
+ if (xhr.readyState !== rStates.LOADING || !response) break;
193
+ self.push(new Buffer(new Uint8Array(response)));
194
+ break;
195
+ case 'ms-stream':
196
+ response = xhr.response;
197
+ if (xhr.readyState !== rStates.LOADING) break;
198
+ var reader = new global.MSStreamReader();
199
+ reader.onprogress = function () {
200
+ if (reader.result.byteLength > self._pos) {
201
+ self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))));
202
+ self._pos = reader.result.byteLength;
203
+ }
204
+ };
205
+ reader.onload = function () {
206
+ self.push(null);
207
+ };
208
+ // reader.onerror = ??? // TODO: this
209
+ reader.readAsArrayBuffer(response);
210
+ break;
211
+ }
212
+
213
+ // The ms-stream case handles end separately in reader.onload()
214
+ if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
215
+ self.push(null);
216
+ }
217
+ };