@uploadcare/upload-client 4.2.0 → 4.3.1-alpha.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Uploadcare Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -31,7 +31,12 @@ const request = ({ method, url, data, headers = {}, signal, onProgress }) => new
31
31
  const xhr = new XMLHttpRequest();
32
32
  const requestMethod = method?.toUpperCase() || 'GET';
33
33
  let aborted = false;
34
- xhr.open(requestMethod, url);
34
+ /**
35
+ * Force synchronous flag to be off
36
+ * Some users get `InvalidAccessError` error when we set `responseType`
37
+ * See https://xhr.spec.whatwg.org/#synchronous-flag
38
+ */
39
+ xhr.open(requestMethod, url, true);
35
40
  if (headers) {
36
41
  Object.entries(headers).forEach((entry) => {
37
42
  const [key, value] = entry;
@@ -248,7 +253,7 @@ const defaultSettings = {
248
253
  const defaultContentType = 'application/octet-stream';
249
254
  const defaultFilename = 'original';
250
255
 
251
- var version = '4.2.0';
256
+ var version = '4.3.1-alpha.0';
252
257
 
253
258
  function isObject(o) {
254
259
  return Object.prototype.toString.call(o) === '[object Object]';
@@ -1548,4 +1553,4 @@ class UploadClient {
1548
1553
  }
1549
1554
  }
1550
1555
 
1551
- export { UploadClient, UploadClientError, UploadcareFile, UploadcareGroup, base, fromUrl, fromUrlStatus, group, groupInfo, info, multipartComplete, multipartStart, multipartUpload, uploadDirect, uploadFile, uploadFileGroup, uploadFromUploaded, uploadFromUrl, uploadMultipart };
1556
+ export { UploadClient, UploadClientError, UploadcareFile, UploadcareGroup, base, fromUrl, fromUrlStatus, getUserAgent$1 as getUserAgent, group, groupInfo, info, multipartComplete, multipartStart, multipartUpload, uploadDirect, uploadFile, uploadFileGroup, uploadFromUploaded, uploadFromUrl, uploadMultipart };
@@ -282,7 +282,7 @@ const defaultSettings = {
282
282
  const defaultContentType = 'application/octet-stream';
283
283
  const defaultFilename = 'original';
284
284
 
285
- var version = '4.2.0';
285
+ var version = '4.3.1-alpha.0';
286
286
 
287
287
  function isObject(o) {
288
288
  return Object.prototype.toString.call(o) === '[object Object]';
@@ -1580,4 +1580,4 @@ class UploadClient {
1580
1580
  }
1581
1581
  }
1582
1582
 
1583
- export { UploadClient, UploadClientError, UploadcareFile, UploadcareGroup, base, fromUrl, fromUrlStatus, group, groupInfo, info, multipartComplete, multipartStart, multipartUpload, uploadDirect, uploadFile, uploadFileGroup, uploadFromUploaded, uploadFromUrl, uploadMultipart };
1583
+ export { UploadClient, UploadClientError, UploadcareFile, UploadcareGroup, base, fromUrl, fromUrlStatus, getUserAgent$1 as getUserAgent, group, groupInfo, info, multipartComplete, multipartStart, multipartUpload, uploadDirect, uploadFile, uploadFileGroup, uploadFromUploaded, uploadFromUrl, uploadMultipart };
@@ -31,7 +31,12 @@ const request = ({ method, url, data, headers = {}, signal, onProgress }) => new
31
31
  const xhr = new XMLHttpRequest();
32
32
  const requestMethod = method?.toUpperCase() || 'GET';
33
33
  let aborted = false;
34
- xhr.open(requestMethod, url);
34
+ /**
35
+ * Force synchronous flag to be off
36
+ * Some users get `InvalidAccessError` error when we set `responseType`
37
+ * See https://xhr.spec.whatwg.org/#synchronous-flag
38
+ */
39
+ xhr.open(requestMethod, url, true);
35
40
  if (headers) {
36
41
  Object.entries(headers).forEach((entry) => {
37
42
  const [key, value] = entry;
@@ -251,7 +256,7 @@ const defaultSettings = {
251
256
  const defaultContentType = 'application/octet-stream';
252
257
  const defaultFilename = 'original';
253
258
 
254
- var version = '4.2.0';
259
+ var version = '4.3.1-alpha.0';
255
260
 
256
261
  function isObject(o) {
257
262
  return Object.prototype.toString.call(o) === '[object Object]';
@@ -1564,4 +1569,4 @@ class UploadClient {
1564
1569
  }
1565
1570
  }
1566
1571
 
1567
- export { UploadClient, UploadClientError, UploadcareFile, UploadcareGroup, base, fromUrl, fromUrlStatus, group, groupInfo, info, multipartComplete, multipartStart, multipartUpload, uploadDirect, uploadFile, uploadFileGroup, uploadFromUploaded, uploadFromUrl, uploadMultipart };
1572
+ export { UploadClient, UploadClientError, UploadcareFile, UploadcareGroup, base, fromUrl, fromUrlStatus, getUserAgent$1 as getUserAgent, group, groupInfo, info, multipartComplete, multipartStart, multipartUpload, uploadDirect, uploadFile, uploadFileGroup, uploadFromUploaded, uploadFromUrl, uploadMultipart };
package/dist/types.d.ts CHANGED
@@ -11,6 +11,14 @@ export declare type CustomUserAgentOptions = {
11
11
  };
12
12
  export declare type CustomUserAgentFn = (options: CustomUserAgentOptions) => string;
13
13
  export declare type CustomUserAgent = string | CustomUserAgentFn;
14
+ export declare type GetUserAgentOptions = {
15
+ libraryName: string;
16
+ libraryVersion: string;
17
+ publicKey?: string;
18
+ integration?: string;
19
+ userAgent?: CustomUserAgent | null;
20
+ };
21
+ export declare function getUserAgent({ libraryName, libraryVersion, userAgent, publicKey, integration }: GetUserAgentOptions): string;
14
22
  export declare type GeoLocation = {
15
23
  latitude: number;
16
24
  longitude: number;
package/package.json CHANGED
@@ -1,19 +1,26 @@
1
1
  {
2
2
  "name": "@uploadcare/upload-client",
3
- "version": "4.2.0",
3
+ "version": "4.3.1-alpha.0",
4
4
  "description": "Library for work with Uploadcare Upload API",
5
5
  "type": "module",
6
- "main": "dist/index.node.js",
7
- "module": "dist/index.node.js",
8
- "browser": "dist/index.browser.js",
9
- "react-native": "dist/index.react-native.js",
10
- "types": "dist/types.d.ts",
6
+ "main": "./dist/index.node.js",
7
+ "module": "./dist/index.node.js",
8
+ "browser": "./dist/index.browser.js",
9
+ "react-native": "./dist/index.react-native.js",
10
+ "types": "./dist/types.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "node": "./dist/index.node.js",
14
+ "browser": "./dist/index.browser.js"
15
+ }
16
+ },
11
17
  "sideEffects": false,
12
- "files": ["dist/*"],
18
+ "files": ["dist/*", "README.md", "LICENSE"],
13
19
  "engines": {
14
20
  "node": ">=16"
15
21
  },
16
22
  "scripts": {
23
+ "prepack": "cp ../../LICENSE ./LICENSE",
17
24
  "mock:start": "ts-node-esm --experimentalSpecifierResolution node ./mock-server/server.ts --silent",
18
25
  "clean": "rimraf dist",
19
26
  "test": "start-server-and-test mock:start :3000 test:jest",
@@ -58,7 +65,7 @@
58
65
  "koa-body": "5.0.0",
59
66
  "mock-socket": "9.0.3",
60
67
  "start-server-and-test": "1.14.0",
61
- "@uploadcare/api-client-utils": "^4.2.0",
68
+ "@uploadcare/api-client-utils": "^4.3.1-alpha.0",
62
69
  "chalk": "^4.1.2"
63
70
  },
64
71
  "dependencies": {