@aws-amplify/storage 5.6.3 → 5.6.4-api-v6.13

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 (252) hide show
  1. package/lib/AwsClients/S3/abortMultipartUpload.d.ts +21 -0
  2. package/lib/AwsClients/S3/abortMultipartUpload.js +85 -0
  3. package/lib/AwsClients/S3/base.d.ts +54 -0
  4. package/lib/AwsClients/S3/base.js +75 -0
  5. package/lib/AwsClients/S3/completeMultipartUpload.d.ts +20 -0
  6. package/lib/AwsClients/S3/completeMultipartUpload.js +162 -0
  7. package/lib/AwsClients/S3/copyObject.d.ts +24 -0
  8. package/lib/AwsClients/S3/copyObject.js +98 -0
  9. package/lib/AwsClients/S3/createMultipartUpload.d.ts +21 -0
  10. package/lib/AwsClients/S3/createMultipartUpload.js +95 -0
  11. package/lib/AwsClients/S3/deleteObject.d.ts +20 -0
  12. package/lib/AwsClients/S3/deleteObject.js +86 -0
  13. package/lib/AwsClients/S3/getObject.d.ts +27 -0
  14. package/lib/AwsClients/S3/getObject.js +216 -0
  15. package/lib/AwsClients/S3/headObject.d.ts +20 -0
  16. package/lib/AwsClients/S3/headObject.js +96 -0
  17. package/lib/AwsClients/S3/index.d.ts +13 -0
  18. package/lib/AwsClients/S3/index.js +30 -0
  19. package/lib/AwsClients/S3/index.native.d.ts +14 -0
  20. package/lib/AwsClients/S3/index.native.js +31 -0
  21. package/lib/AwsClients/S3/listObjectsV2.d.ts +20 -0
  22. package/lib/AwsClients/S3/listObjectsV2.js +146 -0
  23. package/lib/AwsClients/S3/listParts.d.ts +20 -0
  24. package/lib/AwsClients/S3/listParts.js +110 -0
  25. package/lib/AwsClients/S3/putObject.d.ts +23 -0
  26. package/lib/AwsClients/S3/putObject.js +93 -0
  27. package/lib/AwsClients/S3/runtime/base64/index.browser.d.ts +2 -0
  28. package/lib/AwsClients/S3/runtime/base64/index.browser.js +20 -0
  29. package/lib/AwsClients/S3/runtime/base64/index.native.d.ts +2 -0
  30. package/lib/AwsClients/S3/runtime/base64/index.native.js +17 -0
  31. package/lib/AwsClients/S3/runtime/constants.d.ts +9 -0
  32. package/lib/AwsClients/S3/runtime/constants.js +14 -0
  33. package/lib/AwsClients/S3/runtime/contentSha256middleware.d.ts +9 -0
  34. package/lib/AwsClients/S3/runtime/contentSha256middleware.js +70 -0
  35. package/lib/AwsClients/S3/runtime/index.browser.d.ts +5 -0
  36. package/lib/AwsClients/S3/runtime/index.browser.js +20 -0
  37. package/lib/AwsClients/S3/runtime/index.d.ts +5 -0
  38. package/lib/AwsClients/S3/runtime/index.js +21 -0
  39. package/lib/AwsClients/S3/runtime/index.native.d.ts +5 -0
  40. package/lib/AwsClients/S3/runtime/index.native.js +20 -0
  41. package/lib/AwsClients/S3/runtime/s3TransferHandler/fetch.d.ts +8 -0
  42. package/lib/AwsClients/S3/runtime/s3TransferHandler/fetch.js +15 -0
  43. package/lib/AwsClients/S3/runtime/s3TransferHandler/xhr.d.ts +8 -0
  44. package/lib/AwsClients/S3/runtime/s3TransferHandler/xhr.js +21 -0
  45. package/lib/AwsClients/S3/runtime/xhrTransferHandler.d.ts +22 -0
  46. package/lib/AwsClients/S3/runtime/xhrTransferHandler.js +201 -0
  47. package/lib/AwsClients/S3/runtime/xmlParser/dom.d.ts +8 -0
  48. package/lib/AwsClients/S3/runtime/xmlParser/dom.js +92 -0
  49. package/lib/AwsClients/S3/runtime/xmlParser/pureJs.d.ts +10 -0
  50. package/lib/AwsClients/S3/runtime/xmlParser/pureJs.js +57 -0
  51. package/lib/AwsClients/S3/types.d.ts +2857 -0
  52. package/lib/AwsClients/S3/types.js +4 -0
  53. package/lib/AwsClients/S3/uploadPart.d.ts +20 -0
  54. package/lib/AwsClients/S3/uploadPart.js +96 -0
  55. package/lib/AwsClients/S3/utils/deserializeHelpers.d.ts +78 -0
  56. package/lib/AwsClients/S3/utils/deserializeHelpers.js +153 -0
  57. package/lib/AwsClients/S3/utils/index.d.ts +5 -0
  58. package/lib/AwsClients/S3/utils/index.js +30 -0
  59. package/lib/AwsClients/S3/utils/parsePayload.d.ts +3 -0
  60. package/lib/AwsClients/S3/utils/parsePayload.js +96 -0
  61. package/lib/AwsClients/S3/utils/serializeHelpers.d.ts +42 -0
  62. package/lib/AwsClients/S3/utils/serializeHelpers.js +183 -0
  63. package/lib/Storage.d.ts +5 -5
  64. package/lib/Storage.js +60 -31
  65. package/lib/common/S3ClientUtils.d.ts +24 -15
  66. package/lib/common/S3ClientUtils.js +83 -95
  67. package/lib/common/StorageConstants.d.ts +0 -1
  68. package/lib/common/StorageConstants.js +3 -2
  69. package/lib/common/StorageErrorStrings.js +3 -1
  70. package/lib/common/StorageUtils.js +12 -6
  71. package/lib/index.js +19 -4
  72. package/lib/providers/AWSS3Provider.d.ts +4 -8
  73. package/lib/providers/AWSS3Provider.js +210 -139
  74. package/lib/providers/AWSS3ProviderManagedUpload.d.ts +7 -7
  75. package/lib/providers/AWSS3ProviderManagedUpload.js +184 -98
  76. package/lib/providers/AWSS3UploadTask.d.ts +8 -8
  77. package/lib/providers/AWSS3UploadTask.js +226 -129
  78. package/lib/providers/index.js +4 -2
  79. package/lib/tsconfig.tsbuildinfo +1 -0
  80. package/lib/types/AWSS3Provider.d.ts +62 -62
  81. package/lib/types/AWSS3Provider.js +0 -1
  82. package/lib/types/Provider.d.ts +1 -1
  83. package/lib/types/Provider.js +2 -1
  84. package/lib/types/Storage.d.ts +23 -23
  85. package/lib/types/Storage.js +0 -1
  86. package/lib/types/index.js +17 -1
  87. package/lib-esm/AwsClients/S3/abortMultipartUpload.d.ts +21 -0
  88. package/lib-esm/AwsClients/S3/abortMultipartUpload.js +82 -0
  89. package/lib-esm/AwsClients/S3/base.d.ts +54 -0
  90. package/lib-esm/AwsClients/S3/base.js +71 -0
  91. package/lib-esm/AwsClients/S3/completeMultipartUpload.d.ts +20 -0
  92. package/lib-esm/AwsClients/S3/completeMultipartUpload.js +159 -0
  93. package/lib-esm/AwsClients/S3/copyObject.d.ts +24 -0
  94. package/lib-esm/AwsClients/S3/copyObject.js +95 -0
  95. package/lib-esm/AwsClients/S3/createMultipartUpload.d.ts +21 -0
  96. package/lib-esm/AwsClients/S3/createMultipartUpload.js +92 -0
  97. package/lib-esm/AwsClients/S3/deleteObject.d.ts +20 -0
  98. package/lib-esm/AwsClients/S3/deleteObject.js +83 -0
  99. package/lib-esm/AwsClients/S3/getObject.d.ts +27 -0
  100. package/lib-esm/AwsClients/S3/getObject.js +212 -0
  101. package/lib-esm/AwsClients/S3/headObject.d.ts +20 -0
  102. package/lib-esm/AwsClients/S3/headObject.js +93 -0
  103. package/lib-esm/AwsClients/S3/index.d.ts +13 -0
  104. package/lib-esm/AwsClients/S3/index.js +14 -0
  105. package/lib-esm/AwsClients/S3/index.native.d.ts +14 -0
  106. package/lib-esm/AwsClients/S3/index.native.js +15 -0
  107. package/lib-esm/AwsClients/S3/listObjectsV2.d.ts +20 -0
  108. package/lib-esm/AwsClients/S3/listObjectsV2.js +143 -0
  109. package/lib-esm/AwsClients/S3/listParts.d.ts +20 -0
  110. package/lib-esm/AwsClients/S3/listParts.js +107 -0
  111. package/lib-esm/AwsClients/S3/putObject.d.ts +23 -0
  112. package/lib-esm/AwsClients/S3/putObject.js +90 -0
  113. package/lib-esm/AwsClients/S3/runtime/base64/index.browser.d.ts +2 -0
  114. package/lib-esm/AwsClients/S3/runtime/base64/index.browser.js +15 -0
  115. package/lib-esm/AwsClients/S3/runtime/base64/index.native.d.ts +2 -0
  116. package/lib-esm/AwsClients/S3/runtime/base64/index.native.js +12 -0
  117. package/lib-esm/AwsClients/S3/runtime/constants.d.ts +9 -0
  118. package/lib-esm/AwsClients/S3/runtime/constants.js +11 -0
  119. package/lib-esm/AwsClients/S3/runtime/contentSha256middleware.d.ts +9 -0
  120. package/lib-esm/AwsClients/S3/runtime/contentSha256middleware.js +66 -0
  121. package/lib-esm/AwsClients/S3/runtime/index.browser.d.ts +5 -0
  122. package/lib-esm/AwsClients/S3/runtime/index.browser.js +8 -0
  123. package/lib-esm/AwsClients/S3/runtime/index.d.ts +5 -0
  124. package/lib-esm/AwsClients/S3/runtime/index.js +9 -0
  125. package/lib-esm/AwsClients/S3/runtime/index.native.d.ts +5 -0
  126. package/lib-esm/AwsClients/S3/runtime/index.native.js +8 -0
  127. package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/fetch.d.ts +8 -0
  128. package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/fetch.js +12 -0
  129. package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/xhr.d.ts +8 -0
  130. package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/xhr.js +18 -0
  131. package/lib-esm/AwsClients/S3/runtime/xhrTransferHandler.d.ts +22 -0
  132. package/lib-esm/AwsClients/S3/runtime/xhrTransferHandler.js +196 -0
  133. package/lib-esm/AwsClients/S3/runtime/xmlParser/dom.d.ts +8 -0
  134. package/lib-esm/AwsClients/S3/runtime/xmlParser/dom.js +89 -0
  135. package/lib-esm/AwsClients/S3/runtime/xmlParser/pureJs.d.ts +10 -0
  136. package/lib-esm/AwsClients/S3/runtime/xmlParser/pureJs.js +54 -0
  137. package/lib-esm/AwsClients/S3/types.d.ts +2857 -0
  138. package/lib-esm/AwsClients/S3/types.js +3 -0
  139. package/lib-esm/AwsClients/S3/uploadPart.d.ts +20 -0
  140. package/lib-esm/AwsClients/S3/uploadPart.js +93 -0
  141. package/lib-esm/AwsClients/S3/utils/deserializeHelpers.d.ts +78 -0
  142. package/lib-esm/AwsClients/S3/utils/deserializeHelpers.js +144 -0
  143. package/lib-esm/AwsClients/S3/utils/index.d.ts +5 -0
  144. package/lib-esm/AwsClients/S3/utils/index.js +7 -0
  145. package/lib-esm/AwsClients/S3/utils/parsePayload.d.ts +3 -0
  146. package/lib-esm/AwsClients/S3/utils/parsePayload.js +91 -0
  147. package/lib-esm/AwsClients/S3/utils/serializeHelpers.d.ts +42 -0
  148. package/lib-esm/AwsClients/S3/utils/serializeHelpers.js +176 -0
  149. package/lib-esm/Storage.d.ts +5 -5
  150. package/lib-esm/Storage.js +53 -25
  151. package/lib-esm/common/S3ClientUtils.d.ts +24 -15
  152. package/lib-esm/common/S3ClientUtils.js +76 -93
  153. package/lib-esm/common/StorageConstants.d.ts +0 -1
  154. package/lib-esm/common/StorageConstants.js +2 -2
  155. package/lib-esm/common/StorageErrorStrings.js +2 -1
  156. package/lib-esm/common/StorageUtils.js +2 -1
  157. package/lib-esm/index.js +1 -1
  158. package/lib-esm/providers/AWSS3Provider.d.ts +4 -8
  159. package/lib-esm/providers/AWSS3Provider.js +162 -115
  160. package/lib-esm/providers/AWSS3ProviderManagedUpload.d.ts +7 -7
  161. package/lib-esm/providers/AWSS3ProviderManagedUpload.js +172 -87
  162. package/lib-esm/providers/AWSS3UploadTask.d.ts +8 -8
  163. package/lib-esm/providers/AWSS3UploadTask.js +202 -106
  164. package/lib-esm/providers/index.js +2 -1
  165. package/lib-esm/tsconfig.tsbuildinfo +1 -0
  166. package/lib-esm/types/AWSS3Provider.d.ts +62 -62
  167. package/lib-esm/types/AWSS3Provider.js +1 -1
  168. package/lib-esm/types/Provider.d.ts +1 -1
  169. package/lib-esm/types/Provider.js +3 -1
  170. package/lib-esm/types/Storage.d.ts +23 -23
  171. package/lib-esm/types/Storage.js +1 -1
  172. package/lib-esm/types/index.js +3 -1
  173. package/package.json +21 -26
  174. package/src/AwsClients/S3/abortMultipartUpload.ts +62 -0
  175. package/src/AwsClients/S3/base.ts +109 -0
  176. package/src/AwsClients/S3/completeMultipartUpload.ts +154 -0
  177. package/src/AwsClients/S3/copyObject.ts +90 -0
  178. package/src/AwsClients/S3/createMultipartUpload.ts +75 -0
  179. package/src/AwsClients/S3/deleteObject.ts +69 -0
  180. package/src/AwsClients/S3/getObject.ts +173 -0
  181. package/src/AwsClients/S3/headObject.ts +91 -0
  182. package/src/AwsClients/S3/index.native.ts +42 -0
  183. package/src/AwsClients/S3/index.ts +41 -0
  184. package/src/AwsClients/S3/listObjectsV2.ts +130 -0
  185. package/src/AwsClients/S3/listParts.ts +97 -0
  186. package/src/AwsClients/S3/putObject.ts +94 -0
  187. package/src/AwsClients/S3/runtime/base64/index.browser.ts +21 -0
  188. package/src/AwsClients/S3/runtime/base64/index.native.ts +16 -0
  189. package/src/AwsClients/S3/runtime/constants.ts +16 -0
  190. package/src/AwsClients/S3/runtime/contentSha256middleware.ts +29 -0
  191. package/src/AwsClients/S3/runtime/index.browser.ts +14 -0
  192. package/src/AwsClients/S3/runtime/index.native.ts +14 -0
  193. package/src/AwsClients/S3/runtime/index.ts +15 -0
  194. package/src/AwsClients/S3/runtime/s3TransferHandler/fetch.ts +23 -0
  195. package/src/AwsClients/S3/runtime/s3TransferHandler/xhr.ts +35 -0
  196. package/src/AwsClients/S3/runtime/xhrTransferHandler.ts +254 -0
  197. package/src/AwsClients/S3/runtime/xmlParser/dom.ts +92 -0
  198. package/src/AwsClients/S3/runtime/xmlParser/pureJs.ts +55 -0
  199. package/src/AwsClients/S3/types.ts +2877 -0
  200. package/src/AwsClients/S3/uploadPart.ts +83 -0
  201. package/src/AwsClients/S3/utils/deserializeHelpers.ts +136 -0
  202. package/src/AwsClients/S3/utils/index.ts +27 -0
  203. package/src/AwsClients/S3/utils/parsePayload.ts +45 -0
  204. package/src/AwsClients/S3/utils/serializeHelpers.ts +112 -0
  205. package/src/Storage.ts +30 -27
  206. package/src/common/S3ClientUtils.ts +57 -113
  207. package/src/common/StorageConstants.ts +2 -2
  208. package/src/common/StorageErrorStrings.ts +2 -0
  209. package/src/common/StorageUtils.ts +2 -0
  210. package/src/providers/AWSS3Provider.ts +80 -100
  211. package/src/providers/AWSS3ProviderManagedUpload.ts +56 -63
  212. package/src/providers/AWSS3UploadTask.ts +86 -87
  213. package/src/providers/index.ts +2 -0
  214. package/src/types/AWSS3Provider.ts +55 -49
  215. package/src/types/Provider.ts +7 -2
  216. package/lib/.tsbuildinfo +0 -3
  217. package/lib/Storage.js.map +0 -1
  218. package/lib/common/S3ClientUtils.js.map +0 -1
  219. package/lib/common/StorageConstants.js.map +0 -1
  220. package/lib/common/StorageErrorStrings.js.map +0 -1
  221. package/lib/common/StorageUtils.js.map +0 -1
  222. package/lib/index.js.map +0 -1
  223. package/lib/providers/AWSS3Provider.js.map +0 -1
  224. package/lib/providers/AWSS3ProviderManagedUpload.js.map +0 -1
  225. package/lib/providers/AWSS3UploadTask.js.map +0 -1
  226. package/lib/providers/axios-http-handler.d.ts +0 -40
  227. package/lib/providers/axios-http-handler.js +0 -193
  228. package/lib/providers/axios-http-handler.js.map +0 -1
  229. package/lib/providers/index.js.map +0 -1
  230. package/lib/types/AWSS3Provider.js.map +0 -1
  231. package/lib/types/Provider.js.map +0 -1
  232. package/lib/types/Storage.js.map +0 -1
  233. package/lib/types/index.js.map +0 -1
  234. package/lib-esm/.tsbuildinfo +0 -3
  235. package/lib-esm/Storage.js.map +0 -1
  236. package/lib-esm/common/S3ClientUtils.js.map +0 -1
  237. package/lib-esm/common/StorageConstants.js.map +0 -1
  238. package/lib-esm/common/StorageErrorStrings.js.map +0 -1
  239. package/lib-esm/common/StorageUtils.js.map +0 -1
  240. package/lib-esm/index.js.map +0 -1
  241. package/lib-esm/providers/AWSS3Provider.js.map +0 -1
  242. package/lib-esm/providers/AWSS3ProviderManagedUpload.js.map +0 -1
  243. package/lib-esm/providers/AWSS3UploadTask.js.map +0 -1
  244. package/lib-esm/providers/axios-http-handler.d.ts +0 -40
  245. package/lib-esm/providers/axios-http-handler.js +0 -191
  246. package/lib-esm/providers/axios-http-handler.js.map +0 -1
  247. package/lib-esm/providers/index.js.map +0 -1
  248. package/lib-esm/types/AWSS3Provider.js.map +0 -1
  249. package/lib-esm/types/Provider.js.map +0 -1
  250. package/lib-esm/types/Storage.js.map +0 -1
  251. package/lib-esm/types/index.js.map +0 -1
  252. package/src/providers/axios-http-handler.ts +0 -242
@@ -1,14 +1,61 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
2
49
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
50
+ exports.calculatePartSize = exports.DEFAULT_QUEUE_SIZE = exports.MAX_PARTS_COUNT = exports.MAX_OBJECT_SIZE = exports.DEFAULT_PART_SIZE = exports.loadS3Config = exports.credentialsProvider = exports.getPrefix = void 0;
51
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
52
+ // SPDX-License-Identifier: Apache-2.0
4
53
  var core_1 = require("@aws-amplify/core");
5
- var client_s3_1 = require("@aws-sdk/client-s3");
6
- var axios_http_handler_1 = require("../providers/axios-http-handler");
7
54
  var StorageConstants_1 = require("./StorageConstants");
8
55
  var logger = new core_1.Logger('S3ClientUtils');
9
56
  // placeholder credentials in order to satisfy type requirement, always results in 403 when used
10
57
  var INVALID_CRED = { accessKeyId: '', secretAccessKey: '' };
11
- exports.getPrefix = function (config) {
58
+ var getPrefix = function (config) {
12
59
  var credentials = config.credentials, level = config.level, customPrefix = config.customPrefix, identityId = config.identityId;
13
60
  var resolvedCustomPrefix = customPrefix || {};
14
61
  var resolvedIdentityId = identityId || credentials.identityId;
@@ -34,73 +81,10 @@ exports.getPrefix = function (config) {
34
81
  return publicPath;
35
82
  }
36
83
  };
37
- exports.createPrefixMiddleware = function (opt, key) {
38
- return function (next, _context) {
39
- return function (args) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
40
- var credentials, cred, prefix, clonedInput, result;
41
- return tslib_1.__generator(this, function (_a) {
42
- switch (_a.label) {
43
- case 0: return [4 /*yield*/, core_1.Credentials.get()];
44
- case 1:
45
- credentials = _a.sent();
46
- cred = core_1.Credentials.shear(credentials);
47
- prefix = exports.getPrefix(tslib_1.__assign(tslib_1.__assign({}, opt), { credentials: cred }));
48
- clonedInput = Object.assign({}, args.input);
49
- if (Object.prototype.hasOwnProperty.call(args.input, 'Key')) {
50
- clonedInput.Key = prefix + key;
51
- args.input = clonedInput;
52
- }
53
- else if (Object.prototype.hasOwnProperty.call(args.input, 'Prefix')) {
54
- clonedInput.Prefix = prefix + key;
55
- args.input = clonedInput;
56
- }
57
- result = next(args);
58
- return [2 /*return*/, result];
59
- }
60
- });
61
- }); };
62
- };
63
- };
64
- var isTimeSkewedError = function (err) {
65
- return err.ServerTime &&
66
- typeof err.Code === 'string' &&
67
- err.Code === 'RequestTimeTooSkewed';
68
- };
69
- // we want to take the S3Client config in parameter so we can modify it's systemClockOffset
70
- exports.autoAdjustClockskewMiddleware = function (config) {
71
- return function (next, _context) {
72
- return function (args) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
73
- var err_1, serverDate;
74
- return tslib_1.__generator(this, function (_a) {
75
- switch (_a.label) {
76
- case 0:
77
- _a.trys.push([0, 2, , 3]);
78
- return [4 /*yield*/, next(args)];
79
- case 1: return [2 /*return*/, _a.sent()];
80
- case 2:
81
- err_1 = _a.sent();
82
- if (isTimeSkewedError(err_1)) {
83
- serverDate = new Date(err_1.ServerTime);
84
- config.systemClockOffset = serverDate.getTime() - Date.now();
85
- }
86
- throw err_1;
87
- case 3: return [2 /*return*/];
88
- }
89
- });
90
- }); };
91
- };
92
- };
93
- exports.autoAdjustClockskewMiddlewareOptions = {
94
- step: 'finalizeRequest',
95
- name: 'autoAdjustClockskewMiddleware',
96
- };
97
- exports.prefixMiddlewareOptions = {
98
- step: 'initialize',
99
- name: 'addPrefixMiddleware',
100
- };
101
- exports.credentialsProvider = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
84
+ exports.getPrefix = getPrefix;
85
+ var credentialsProvider = function () { return __awaiter(void 0, void 0, void 0, function () {
102
86
  var credentials, cred, error_1;
103
- return tslib_1.__generator(this, function (_a) {
87
+ return __generator(this, function (_a) {
104
88
  switch (_a.label) {
105
89
  case 0:
106
90
  _a.trys.push([0, 2, , 3]);
@@ -120,35 +104,39 @@ exports.credentialsProvider = function () { return tslib_1.__awaiter(void 0, voi
120
104
  }
121
105
  });
122
106
  }); };
123
- exports.createS3Client = function (config, storageAction, emitter) {
124
- var region = config.region, cancelTokenSource = config.cancelTokenSource, dangerouslyConnectToHttpEndpointForTesting = config.dangerouslyConnectToHttpEndpointForTesting, useAccelerateEndpoint = config.useAccelerateEndpoint;
125
- var localTestingConfig = {};
126
- if (dangerouslyConnectToHttpEndpointForTesting) {
127
- localTestingConfig = {
128
- endpoint: StorageConstants_1.localTestingStorageEndpoint,
129
- tls: false,
130
- bucketEndpoint: false,
131
- forcePathStyle: true,
132
- };
107
+ exports.credentialsProvider = credentialsProvider;
108
+ /**
109
+ * A function that persists the s3 configs, so we don't need to
110
+ * assign each config parameter for every s3 API call.
111
+ *
112
+ * @inernal
113
+ */
114
+ var loadS3Config = function (config) {
115
+ if (!config.region) {
116
+ // Same error thrown by aws-sdk
117
+ throw new Error('Region is missing.');
133
118
  }
134
- var s3client = new client_s3_1.S3Client(tslib_1.__assign(tslib_1.__assign({ region: region,
135
- // Using provider instead of a static credentials, so that if an upload task was in progress, but credentials gets
136
- // changed or invalidated (e.g user signed out), the subsequent requests will fail.
137
- credentials: exports.credentialsProvider, customUserAgent: core_1.getAmplifyUserAgentObject({
119
+ return __assign(__assign(__assign({}, config), { region: config.region, credentials: config.credentials
120
+ ? function () { return Promise.resolve(config.credentials); }
121
+ : exports.credentialsProvider, userAgentValue: (0, core_1.getAmplifyUserAgent)({
138
122
  category: core_1.Category.Storage,
139
- action: storageAction,
140
- }) }, localTestingConfig), { requestHandler: new axios_http_handler_1.AxiosHttpHandler({}, emitter, cancelTokenSource), useAccelerateEndpoint: useAccelerateEndpoint }));
141
- s3client.middlewareStack.remove(StorageConstants_1.SET_CONTENT_LENGTH_HEADER);
142
- return s3client;
123
+ action: config.storageAction,
124
+ }) }), (config.dangerouslyConnectToHttpEndpointForTesting
125
+ ? {
126
+ customEndpoint: StorageConstants_1.localTestingStorageEndpoint,
127
+ forcePathStyle: true,
128
+ }
129
+ : {}));
143
130
  };
144
- var MB = 1024 * 1024;
145
- var GB = 1024 * MB;
146
- var TB = 1024 * GB;
147
- exports.DEFAULT_PART_SIZE = 5 * MB;
148
- exports.MAX_OBJECT_SIZE = 5 * TB;
131
+ exports.loadS3Config = loadS3Config;
132
+ var MiB = 1024 * 1024;
133
+ var GiB = 1024 * MiB;
134
+ var TiB = 1024 * GiB;
135
+ exports.DEFAULT_PART_SIZE = 5 * MiB;
136
+ exports.MAX_OBJECT_SIZE = 5 * TiB;
149
137
  exports.MAX_PARTS_COUNT = 10000;
150
138
  exports.DEFAULT_QUEUE_SIZE = 4;
151
- exports.calculatePartSize = function (totalSize) {
139
+ var calculatePartSize = function (totalSize) {
152
140
  var partSize = exports.DEFAULT_PART_SIZE;
153
141
  var partsCount = Math.ceil(totalSize / partSize);
154
142
  while (partsCount > exports.MAX_PARTS_COUNT) {
@@ -157,4 +145,4 @@ exports.calculatePartSize = function (totalSize) {
157
145
  }
158
146
  return partSize;
159
147
  };
160
- //# sourceMappingURL=S3ClientUtils.js.map
148
+ exports.calculatePartSize = calculatePartSize;
@@ -1,4 +1,3 @@
1
1
  export declare const AMPLIFY_SYMBOL: Symbol;
2
- export declare const SET_CONTENT_LENGTH_HEADER = "contentLengthMiddleware";
3
2
  export declare const localTestingStorageEndpoint = "http://localhost:20005";
4
3
  export declare const UPLOADS_STORAGE_KEY = "__uploadInProgress";
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UPLOADS_STORAGE_KEY = exports.localTestingStorageEndpoint = exports.AMPLIFY_SYMBOL = void 0;
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
3
6
  exports.AMPLIFY_SYMBOL = (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function'
4
7
  ? Symbol.for('amplify_default')
5
8
  : '@@amplify_default');
6
- exports.SET_CONTENT_LENGTH_HEADER = 'contentLengthMiddleware';
7
9
  exports.localTestingStorageEndpoint = 'http://localhost:20005';
8
10
  exports.UPLOADS_STORAGE_KEY = '__uploadInProgress';
9
- //# sourceMappingURL=StorageConstants.js.map
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AWSS3ProviderUploadErrorStrings = exports.AWSS3ProviderMultipartCopierErrors = exports.StorageErrorStrings = void 0;
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
3
6
  var StorageErrorStrings;
4
7
  (function (StorageErrorStrings) {
5
8
  StorageErrorStrings["NO_CREDENTIALS"] = "No credentials";
@@ -19,4 +22,3 @@ var AWSS3ProviderUploadErrorStrings;
19
22
  (function (AWSS3ProviderUploadErrorStrings) {
20
23
  AWSS3ProviderUploadErrorStrings["UPLOAD_PAUSED_MESSAGE"] = "paused";
21
24
  })(AWSS3ProviderUploadErrorStrings = exports.AWSS3ProviderUploadErrorStrings || (exports.AWSS3ProviderUploadErrorStrings = {}));
22
- //# sourceMappingURL=StorageErrorStrings.js.map
@@ -1,22 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBlob = exports.isFile = exports.dispatchStorageEvent = exports.byteLength = void 0;
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
3
6
  var core_1 = require("@aws-amplify/core");
4
7
  var StorageConstants_1 = require("./StorageConstants");
5
- exports.byteLength = function (x) {
8
+ var byteLength = function (x) {
6
9
  if (typeof x === 'string') {
7
10
  return x.length;
8
11
  }
9
12
  else if (isArrayBuffer(x)) {
10
13
  return x.byteLength;
11
14
  }
12
- else if (exports.isBlob(x)) {
15
+ else if ((0, exports.isBlob)(x)) {
13
16
  return x.size;
14
17
  }
15
18
  else {
16
19
  throw new Error('Cannot determine byte length of ' + x);
17
20
  }
18
21
  };
19
- exports.dispatchStorageEvent = function (track, event, attrs, metrics, message) {
22
+ exports.byteLength = byteLength;
23
+ var dispatchStorageEvent = function (track, event, attrs, metrics, message) {
20
24
  if (track) {
21
25
  var data = { attrs: attrs };
22
26
  if (metrics) {
@@ -29,13 +33,15 @@ exports.dispatchStorageEvent = function (track, event, attrs, metrics, message)
29
33
  }, 'Storage', StorageConstants_1.AMPLIFY_SYMBOL);
30
34
  }
31
35
  };
32
- exports.isFile = function (x) {
36
+ exports.dispatchStorageEvent = dispatchStorageEvent;
37
+ var isFile = function (x) {
33
38
  return typeof x !== 'undefined' && x instanceof File;
34
39
  };
35
- exports.isBlob = function (x) {
40
+ exports.isFile = isFile;
41
+ var isBlob = function (x) {
36
42
  return typeof x !== 'undefined' && x instanceof Blob;
37
43
  };
44
+ exports.isBlob = isBlob;
38
45
  var isArrayBuffer = function (x) {
39
46
  return typeof x !== 'undefined' && x instanceof ArrayBuffer;
40
47
  };
41
- //# sourceMappingURL=StorageUtils.js.map
package/lib/index.js CHANGED
@@ -1,10 +1,25 @@
1
1
  "use strict";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
+ };
4
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.AWSS3Provider = exports.Storage = exports.StorageClass = void 0;
5
20
  var Storage_1 = require("./Storage");
6
- exports.StorageClass = Storage_1.Storage;
7
- exports.Storage = Storage_1.StorageInstance;
21
+ Object.defineProperty(exports, "StorageClass", { enumerable: true, get: function () { return Storage_1.Storage; } });
22
+ Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return Storage_1.StorageInstance; } });
8
23
  var providers_1 = require("./providers");
9
- exports.AWSS3Provider = providers_1.AWSS3Provider;
10
- //# sourceMappingURL=index.js.map
24
+ Object.defineProperty(exports, "AWSS3Provider", { enumerable: true, get: function () { return providers_1.AWSS3Provider; } });
25
+ __exportStar(require("./types"), exports);
@@ -1,5 +1,5 @@
1
- import { PutObjectCommandInput } from '@aws-sdk/client-s3';
2
- import { StorageOptions, StorageProvider, S3ProviderGetConfig, S3ProviderGetOuput, S3ProviderPutConfig, S3ProviderRemoveConfig, S3ProviderListConfig, S3ProviderCopyConfig, S3ProviderCopyOutput, S3CopySource, S3CopyDestination, S3ProviderRemoveOutput, S3ProviderPutOutput, S3ProviderListOutput, S3ProviderGetPropertiesOutput, S3ProviderGetPropertiesConfig } from '../types';
1
+ import { PutObjectInput } from '../AwsClients/S3';
2
+ import { StorageOptions, StorageProvider, S3ProviderGetConfig, S3ProviderGetOuput, S3ProviderPutConfig, S3ProviderRemoveConfig, S3ProviderListConfig, S3ProviderCopyConfig, S3ProviderCopyOutput, S3CopySource, S3CopyDestination, S3ProviderRemoveOutput, S3ProviderPutOutput, S3ProviderListOutput, S3ProviderGetPropertiesConfig, S3ProviderGetPropertiesOutput } from '../types';
3
3
  /**
4
4
  * Provide storage methods to use AWS S3
5
5
  */
@@ -44,7 +44,7 @@ export declare class AWSS3Provider implements StorageProvider {
44
44
  *
45
45
  * @param {string} key - key of the object
46
46
  * @param {S3ProviderGetConfig} [config] - Optional configuration for the underlying S3 command
47
- * @return {Promise<string | GetObjectCommandOutput>} - A promise resolves to Amazon S3 presigned URL or the
47
+ * @return {Promise<string | GetObjectOutput>} - A promise resolves to Amazon S3 presigned URL or the
48
48
  * GetObjectCommandOutput if download is set to true on success
49
49
  */
50
50
  get<T extends S3ProviderGetConfig & StorageOptions>(key: string, config?: T): Promise<S3ProviderGetOuput<T>>;
@@ -65,7 +65,7 @@ export declare class AWSS3Provider implements StorageProvider {
65
65
  * @return an instance of AWSS3UploadTask or a promise that resolves to an object with the new object's key on
66
66
  * success.
67
67
  */
68
- put<T extends S3ProviderPutConfig>(key: string, object: PutObjectCommandInput['Body'], config?: T): S3ProviderPutOutput<T>;
68
+ put<T extends S3ProviderPutConfig>(key: string, object: PutObjectInput['Body'], config?: T): S3ProviderPutOutput<T>;
69
69
  /**
70
70
  * Remove the object for specified key
71
71
  * @param {string} key - key of the object
@@ -85,8 +85,4 @@ export declare class AWSS3Provider implements StorageProvider {
85
85
  private _ensureCredentials;
86
86
  private _isWithCredentials;
87
87
  private _prefix;
88
- /**
89
- * Creates an S3 client with new V3 aws sdk
90
- */
91
- private _createNewS3Client;
92
88
  }