@swan-admin/swan-ai-measurements 1.1.87 → 1.1.89

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/dist/auth.d.ts CHANGED
@@ -25,7 +25,7 @@ interface AuthSocketParams {
25
25
  }
26
26
  export default class Auth {
27
27
  #private;
28
- constructor(accessKey: string, urlType?: URLType);
28
+ constructor(accessKey?: string, urlType?: URLType, token?: string);
29
29
  registerUser({ email, appVerifyUrl, gender, height, username }: RegisterUserParams): Promise<AxiosResponse>;
30
30
  verifyToken(token: string): Promise<AxiosResponse>;
31
31
  addUser({ scanId, email, name, height, gender, offsetMarketingConsent }: AddUserParams): Promise<AxiosResponse>;
package/dist/auth.js CHANGED
@@ -11,9 +11,17 @@ class Auth {
11
11
  #socketRef;
12
12
  #accessKey;
13
13
  #urlType;
14
- constructor(accessKey, urlType = enum_js_1.URLType.PROD) {
14
+ #token;
15
+ constructor(accessKey, urlType = enum_js_1.URLType.PROD, token) {
15
16
  this.#accessKey = accessKey;
16
17
  this.#urlType = urlType;
18
+ this.#token = token;
19
+ }
20
+ #getHeaders() {
21
+ return {
22
+ ...(this.#accessKey ? { "X-Api-Key": this.#accessKey } : {}),
23
+ ...(this.#token ? { Authorization: `Bearer ${this.#token}` } : {}),
24
+ };
17
25
  }
18
26
  registerUser({ email, appVerifyUrl, gender, height, username }) {
19
27
  if (!(0, utils_js_1.checkParameters)(email, appVerifyUrl)) {
@@ -24,7 +32,7 @@ class Auth {
24
32
  body = { ...body, attributes: { gender, height } };
25
33
  }
26
34
  return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.REGISTER_USER}`, body, {
27
- headers: { "X-Api-Key": this.#accessKey },
35
+ headers: this.#getHeaders(),
28
36
  });
29
37
  }
30
38
  verifyToken(token) {
@@ -33,21 +41,21 @@ class Auth {
33
41
  }
34
42
  return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.VERIFY_USER}`, null, {
35
43
  params: { token },
36
- headers: { "X-Api-Key": this.#accessKey },
44
+ headers: this.#getHeaders(),
37
45
  });
38
46
  }
39
47
  addUser({ scanId, email, name, height, gender, offsetMarketingConsent }) {
40
48
  if (!(0, utils_js_1.checkParameters)(scanId, email, height, gender)) {
41
49
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
42
50
  }
43
- return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: { "X-Api-Key": this.#accessKey } });
51
+ return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: this.#getHeaders() });
44
52
  }
45
53
  getUserDetail(email) {
46
54
  if (!(0, utils_js_1.checkParameters)(email)) {
47
55
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
48
56
  }
49
57
  return axios_1.default.get(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
50
- headers: { "X-Api-Key": this.#accessKey },
58
+ headers: this.#getHeaders(),
51
59
  });
52
60
  }
53
61
  handleAuthSocket({ email, scanId, onError, onSuccess, onClose, onOpen }) {
@@ -33,6 +33,7 @@ export interface FaceScanObjMetaData {
33
33
  customer_store_url: string;
34
34
  scan_type: string;
35
35
  callback_url?: string;
36
+ body_scan_id?: string;
36
37
  }
37
38
  export type RequiredMetaDataKeys = "gender" | "focal_length" | "height" | "customer_store_url" | "callback_url" | "clothes_fit";
38
39
  export type RequiredFaceScanMetaDataKeys = "gender" | "focal_length" | "customer_store_url" | "scan_type" | "callback_url" | "face_scan_id";
package/dist/custom.d.ts CHANGED
@@ -10,7 +10,7 @@ interface CreateCustomer {
10
10
  }
11
11
  declare class Custom {
12
12
  #private;
13
- constructor(accessKey: string, urlType?: URLType);
13
+ constructor(accessKey?: string, urlType?: URLType, token?: string);
14
14
  createCustomer(payload: CreateCustomer): Promise<AxiosResponse<any>>;
15
15
  getCustomCustomerConfig: (store_url: string) => Promise<AxiosResponse<any>>;
16
16
  getModelUrl: (id: string) => Promise<AxiosResponse<any>>;
package/dist/custom.js CHANGED
@@ -10,17 +10,24 @@ const enum_js_1 = require("./enum.js");
10
10
  class Custom {
11
11
  #accessKey;
12
12
  #urlType;
13
- constructor(accessKey, urlType = enum_js_1.URLType.PROD) {
13
+ #token;
14
+ constructor(accessKey, urlType = enum_js_1.URLType.PROD, token) {
14
15
  this.#accessKey = accessKey;
15
16
  this.#urlType = urlType;
17
+ this.#token = token;
18
+ }
19
+ #getHeaders() {
20
+ return {
21
+ ...(this.#accessKey ? { "X-Api-Key": this.#accessKey } : {}),
22
+ ...(this.#token ? { Authorization: `Bearer ${this.#token}` } : {}),
23
+ };
16
24
  }
17
25
  createCustomer(payload) {
18
26
  if ((0, utils_js_1.checkParameters)(payload.name, payload.storeUrl, payload.email, payload.location) === false) {
19
27
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
20
28
  }
21
- return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.CREATE_CUSTOMER}`, {
22
- ...payload,
23
- headers: { "X-Api-Key": this.#accessKey },
29
+ return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.CREATE_CUSTOMER}`, payload, {
30
+ headers: this.#getHeaders(),
24
31
  });
25
32
  }
26
33
  getCustomCustomerConfig = (store_url) => {
@@ -32,7 +39,7 @@ class Custom {
32
39
  urlType: this.#urlType,
33
40
  })}${constants_js_1.API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
34
41
  params: { store_url },
35
- headers: { "X-Api-Key": this.#accessKey },
42
+ headers: this.#getHeaders(),
36
43
  });
37
44
  };
38
45
  getModelUrl = (id) => {
@@ -40,7 +47,7 @@ class Custom {
40
47
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
41
48
  }
42
49
  return axios_1.default.get(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.MODEL}/${id}`, {
43
- headers: { "X-Api-Key": this.#accessKey },
50
+ headers: this.#getHeaders(),
44
51
  });
45
52
  };
46
53
  }
@@ -25,7 +25,7 @@ interface AuthSocketParams {
25
25
  }
26
26
  export default class Auth {
27
27
  #private;
28
- constructor(accessKey: string, urlType?: URLType);
28
+ constructor(accessKey?: string, urlType?: URLType, token?: string);
29
29
  registerUser({ email, appVerifyUrl, gender, height, username }: RegisterUserParams): Promise<AxiosResponse>;
30
30
  verifyToken(token: string): Promise<AxiosResponse>;
31
31
  addUser({ scanId, email, name, height, gender, offsetMarketingConsent }: AddUserParams): Promise<AxiosResponse>;
package/dist/esm/auth.js CHANGED
@@ -9,18 +9,21 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Auth_socketRef, _Auth_accessKey, _Auth_urlType;
12
+ var _Auth_instances, _Auth_socketRef, _Auth_accessKey, _Auth_urlType, _Auth_token, _Auth_getHeaders;
13
13
  import axios from "axios";
14
14
  import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_BASE_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
15
15
  import { checkParameters, getUrl } from "./utils.js";
16
16
  import { URLType } from "./enum.js";
17
17
  class Auth {
18
- constructor(accessKey, urlType = URLType.PROD) {
18
+ constructor(accessKey, urlType = URLType.PROD, token) {
19
+ _Auth_instances.add(this);
19
20
  _Auth_socketRef.set(this, void 0);
20
21
  _Auth_accessKey.set(this, void 0);
21
22
  _Auth_urlType.set(this, void 0);
23
+ _Auth_token.set(this, void 0);
22
24
  __classPrivateFieldSet(this, _Auth_accessKey, accessKey, "f");
23
25
  __classPrivateFieldSet(this, _Auth_urlType, urlType, "f");
26
+ __classPrivateFieldSet(this, _Auth_token, token, "f");
24
27
  }
25
28
  registerUser({ email, appVerifyUrl, gender, height, username }) {
26
29
  if (!checkParameters(email, appVerifyUrl)) {
@@ -31,7 +34,7 @@ class Auth {
31
34
  body = Object.assign(Object.assign({}, body), { attributes: { gender, height } });
32
35
  }
33
36
  return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Auth_urlType, "f") })}${API_ENDPOINTS.REGISTER_USER}`, body, {
34
- headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
37
+ headers: __classPrivateFieldGet(this, _Auth_instances, "m", _Auth_getHeaders).call(this),
35
38
  });
36
39
  }
37
40
  verifyToken(token) {
@@ -40,21 +43,21 @@ class Auth {
40
43
  }
41
44
  return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Auth_urlType, "f") })}${API_ENDPOINTS.VERIFY_USER}`, null, {
42
45
  params: { token },
43
- headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
46
+ headers: __classPrivateFieldGet(this, _Auth_instances, "m", _Auth_getHeaders).call(this),
44
47
  });
45
48
  }
46
49
  addUser({ scanId, email, name, height, gender, offsetMarketingConsent }) {
47
50
  if (!checkParameters(scanId, email, height, gender)) {
48
51
  throw new Error(REQUIRED_MESSAGE);
49
52
  }
50
- return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Auth_urlType, "f") })}${API_ENDPOINTS.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") } });
53
+ return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Auth_urlType, "f") })}${API_ENDPOINTS.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: __classPrivateFieldGet(this, _Auth_instances, "m", _Auth_getHeaders).call(this) });
51
54
  }
52
55
  getUserDetail(email) {
53
56
  if (!checkParameters(email)) {
54
57
  throw new Error(REQUIRED_MESSAGE);
55
58
  }
56
59
  return axios.get(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Auth_urlType, "f") })}${API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
57
- headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
60
+ headers: __classPrivateFieldGet(this, _Auth_instances, "m", _Auth_getHeaders).call(this),
58
61
  });
59
62
  }
60
63
  handleAuthSocket({ email, scanId, onError, onSuccess, onClose, onOpen }) {
@@ -92,5 +95,7 @@ class Auth {
92
95
  }
93
96
  }
94
97
  }
95
- _Auth_socketRef = new WeakMap(), _Auth_accessKey = new WeakMap(), _Auth_urlType = new WeakMap();
98
+ _Auth_socketRef = new WeakMap(), _Auth_accessKey = new WeakMap(), _Auth_urlType = new WeakMap(), _Auth_token = new WeakMap(), _Auth_instances = new WeakSet(), _Auth_getHeaders = function _Auth_getHeaders() {
99
+ return Object.assign(Object.assign({}, (__classPrivateFieldGet(this, _Auth_accessKey, "f") ? { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") } : {})), (__classPrivateFieldGet(this, _Auth_token, "f") ? { Authorization: `Bearer ${__classPrivateFieldGet(this, _Auth_token, "f")}` } : {}));
100
+ };
96
101
  export default Auth;
@@ -33,6 +33,7 @@ export interface FaceScanObjMetaData {
33
33
  customer_store_url: string;
34
34
  scan_type: string;
35
35
  callback_url?: string;
36
+ body_scan_id?: string;
36
37
  }
37
38
  export type RequiredMetaDataKeys = "gender" | "focal_length" | "height" | "customer_store_url" | "callback_url" | "clothes_fit";
38
39
  export type RequiredFaceScanMetaDataKeys = "gender" | "focal_length" | "customer_store_url" | "scan_type" | "callback_url" | "face_scan_id";
@@ -10,7 +10,7 @@ interface CreateCustomer {
10
10
  }
11
11
  declare class Custom {
12
12
  #private;
13
- constructor(accessKey: string, urlType?: URLType);
13
+ constructor(accessKey?: string, urlType?: URLType, token?: string);
14
14
  createCustomer(payload: CreateCustomer): Promise<AxiosResponse<any>>;
15
15
  getCustomCustomerConfig: (store_url: string) => Promise<AxiosResponse<any>>;
16
16
  getModelUrl: (id: string) => Promise<AxiosResponse<any>>;
@@ -9,15 +9,17 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Custom_accessKey, _Custom_urlType;
12
+ var _Custom_instances, _Custom_accessKey, _Custom_urlType, _Custom_token, _Custom_getHeaders;
13
13
  import axios from "axios";
14
14
  import { API_ENDPOINTS, APP_AUTH_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
15
15
  import { checkParameters, getUrl } from "./utils.js";
16
16
  import { URLType } from "./enum.js";
17
17
  class Custom {
18
- constructor(accessKey, urlType = URLType.PROD) {
18
+ constructor(accessKey, urlType = URLType.PROD, token) {
19
+ _Custom_instances.add(this);
19
20
  _Custom_accessKey.set(this, void 0);
20
21
  _Custom_urlType.set(this, void 0);
22
+ _Custom_token.set(this, void 0);
21
23
  this.getCustomCustomerConfig = (store_url) => {
22
24
  if (checkParameters(store_url) === false) {
23
25
  throw new Error(REQUIRED_MESSAGE);
@@ -27,7 +29,7 @@ class Custom {
27
29
  urlType: __classPrivateFieldGet(this, _Custom_urlType, "f"),
28
30
  })}${API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
29
31
  params: { store_url },
30
- headers: { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") },
32
+ headers: __classPrivateFieldGet(this, _Custom_instances, "m", _Custom_getHeaders).call(this),
31
33
  });
32
34
  };
33
35
  this.getModelUrl = (id) => {
@@ -35,18 +37,23 @@ class Custom {
35
37
  throw new Error(REQUIRED_MESSAGE);
36
38
  }
37
39
  return axios.get(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Custom_urlType, "f") })}${API_ENDPOINTS.MODEL}/${id}`, {
38
- headers: { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") },
40
+ headers: __classPrivateFieldGet(this, _Custom_instances, "m", _Custom_getHeaders).call(this),
39
41
  });
40
42
  };
41
43
  __classPrivateFieldSet(this, _Custom_accessKey, accessKey, "f");
42
44
  __classPrivateFieldSet(this, _Custom_urlType, urlType, "f");
45
+ __classPrivateFieldSet(this, _Custom_token, token, "f");
43
46
  }
44
47
  createCustomer(payload) {
45
48
  if (checkParameters(payload.name, payload.storeUrl, payload.email, payload.location) === false) {
46
49
  throw new Error(REQUIRED_MESSAGE);
47
50
  }
48
- return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Custom_urlType, "f") })}${API_ENDPOINTS.CREATE_CUSTOMER}`, Object.assign(Object.assign({}, payload), { headers: { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") } }));
51
+ return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Custom_urlType, "f") })}${API_ENDPOINTS.CREATE_CUSTOMER}`, payload, {
52
+ headers: __classPrivateFieldGet(this, _Custom_instances, "m", _Custom_getHeaders).call(this),
53
+ });
49
54
  }
50
55
  }
51
- _Custom_accessKey = new WeakMap(), _Custom_urlType = new WeakMap();
56
+ _Custom_accessKey = new WeakMap(), _Custom_urlType = new WeakMap(), _Custom_token = new WeakMap(), _Custom_instances = new WeakSet(), _Custom_getHeaders = function _Custom_getHeaders() {
57
+ return Object.assign(Object.assign({}, (__classPrivateFieldGet(this, _Custom_accessKey, "f") ? { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") } : {})), (__classPrivateFieldGet(this, _Custom_token, "f") ? { Authorization: `Bearer ${__classPrivateFieldGet(this, _Custom_token, "f")}` } : {}));
58
+ };
52
59
  export default Custom;
@@ -2,7 +2,7 @@ import { URLType } from "./enum.js";
2
2
  import { BodyScanUploadOptions, FaceScanUploadOptions, SetDeviceInfo } from "./interface.js";
3
3
  export default class FileUpload {
4
4
  #private;
5
- constructor(accessKey: string, urlType?: URLType);
5
+ constructor(accessKey?: string, urlType?: URLType, token?: string);
6
6
  uploadFileFrontend({ file, arrayMetaData, scanId, email, callBack }: BodyScanUploadOptions): Promise<unknown>;
7
7
  faceScanFileUploader({ file, arrayMetaData, objectKey, email, callBack }: FaceScanUploadOptions): Promise<unknown>;
8
8
  uploadFile({ file, arrayMetaData, scanId, email }: BodyScanUploadOptions): Promise<unknown>;
@@ -29,7 +29,7 @@ var __rest = (this && this.__rest) || function (s, e) {
29
29
  }
30
30
  return t;
31
31
  };
32
- var _FileUpload_instances, _FileUpload_uppyIns, _FileUpload_accessKey, _FileUpload_urlType, _FileUpload_uppyFileUploader;
32
+ var _FileUpload_instances, _FileUpload_uppyIns, _FileUpload_accessKey, _FileUpload_urlType, _FileUpload_token, _FileUpload_getHeaders, _FileUpload_uppyFileUploader;
33
33
  import axios from "axios";
34
34
  import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, FILE_UPLOAD_ENDPOINT, APP_AUTH_BASE_URL, REQUIRED_ERROR_MESSAGE_INVALID_EMAIL, API_ENDPOINTS, CHUNK_SIZE, requiredFaceScanMetaData } from "./constants.js";
35
35
  import { addScanType, checkMetaDataValue, checkParameters, checkValues, fetchData, getFileChunks, getUrl, isValidEmail } from "./utils.js";
@@ -37,13 +37,15 @@ import Uppy from "@uppy/core";
37
37
  import AwsS3Multipart from "@uppy/aws-s3-multipart";
38
38
  import { URLType } from "./enum.js";
39
39
  class FileUpload {
40
- constructor(accessKey, urlType = URLType.PROD) {
40
+ constructor(accessKey, urlType = URLType.PROD, token) {
41
41
  _FileUpload_instances.add(this);
42
42
  _FileUpload_uppyIns.set(this, void 0);
43
43
  _FileUpload_accessKey.set(this, void 0);
44
44
  _FileUpload_urlType.set(this, void 0);
45
+ _FileUpload_token.set(this, void 0);
45
46
  __classPrivateFieldSet(this, _FileUpload_accessKey, accessKey, "f");
46
47
  __classPrivateFieldSet(this, _FileUpload_urlType, urlType, "f");
48
+ __classPrivateFieldSet(this, _FileUpload_token, token, "f");
47
49
  }
48
50
  uploadFileFrontend(_a) {
49
51
  return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId, email, callBack }) {
@@ -93,6 +95,7 @@ class FileUpload {
93
95
  const res = yield fetchData({
94
96
  path: FILE_UPLOAD_ENDPOINT.UPLOAD_START,
95
97
  apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
98
+ token: __classPrivateFieldGet(this, _FileUpload_token, "f"),
96
99
  urlType: __classPrivateFieldGet(this, _FileUpload_urlType, "f"),
97
100
  body: {
98
101
  objectKey: file.name,
@@ -107,6 +110,7 @@ class FileUpload {
107
110
  const data = yield fetchData({
108
111
  path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
109
112
  apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
113
+ token: __classPrivateFieldGet(this, _FileUpload_token, "f"),
110
114
  urlType: __classPrivateFieldGet(this, _FileUpload_urlType, "f"),
111
115
  body: {
112
116
  objectKey: res === null || res === void 0 ? void 0 : res.key,
@@ -115,12 +119,13 @@ class FileUpload {
115
119
  },
116
120
  throwError: true,
117
121
  });
118
- const val = yield axios.put(data === null || data === void 0 ? void 0 : data.url, totalChunks[i], { headers: { "Content-Type": file.type, "X-Api-Key": __classPrivateFieldGet(this, _FileUpload_accessKey, "f") } });
122
+ const val = yield axios.put(data === null || data === void 0 ? void 0 : data.url, totalChunks[i], { headers: __classPrivateFieldGet(this, _FileUpload_instances, "m", _FileUpload_getHeaders).call(this, { "Content-Type": file.type }) });
119
123
  parts.push({ PartNumber: i + 1, ETag: (_b = val === null || val === void 0 ? void 0 : val.headers) === null || _b === void 0 ? void 0 : _b.etag });
120
124
  }
121
125
  const completeValue = yield fetchData({
122
126
  path: FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
123
127
  apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
128
+ token: __classPrivateFieldGet(this, _FileUpload_token, "f"),
124
129
  urlType: __classPrivateFieldGet(this, _FileUpload_urlType, "f"),
125
130
  body: {
126
131
  uploadId: res === null || res === void 0 ? void 0 : res.uploadId,
@@ -145,12 +150,14 @@ class FileUpload {
145
150
  throw new Error(REQUIRED_MESSAGE);
146
151
  }
147
152
  return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _FileUpload_urlType, "f") })}${API_ENDPOINTS.DEVICE_INFO}/${scanId}`, { device_info: Object.assign({}, rest) }, {
148
- headers: { "X-Api-Key": __classPrivateFieldGet(this, _FileUpload_accessKey, "f") },
153
+ headers: __classPrivateFieldGet(this, _FileUpload_instances, "m", _FileUpload_getHeaders).call(this),
149
154
  });
150
155
  });
151
156
  }
152
157
  }
153
- _FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap(), _FileUpload_urlType = new WeakMap(), _FileUpload_instances = new WeakSet(), _FileUpload_uppyFileUploader = function _FileUpload_uppyFileUploader({ callBack, arrayMetaData, scanId, email, file, objectKey }) {
158
+ _FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap(), _FileUpload_urlType = new WeakMap(), _FileUpload_token = new WeakMap(), _FileUpload_instances = new WeakSet(), _FileUpload_getHeaders = function _FileUpload_getHeaders(extraHeaders = {}) {
159
+ return Object.assign(Object.assign(Object.assign({}, extraHeaders), (__classPrivateFieldGet(this, _FileUpload_accessKey, "f") ? { "X-Api-Key": __classPrivateFieldGet(this, _FileUpload_accessKey, "f") } : {})), (__classPrivateFieldGet(this, _FileUpload_token, "f") ? { Authorization: `Bearer ${__classPrivateFieldGet(this, _FileUpload_token, "f")}` } : {}));
160
+ }, _FileUpload_uppyFileUploader = function _FileUpload_uppyFileUploader({ callBack, arrayMetaData, scanId, email, file, objectKey }) {
154
161
  return new Promise((resolve, reject) => {
155
162
  if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
156
163
  __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
@@ -168,6 +175,7 @@ _FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap(), _Fil
168
175
  return fetchData({
169
176
  path: FILE_UPLOAD_ENDPOINT.UPLOAD_START,
170
177
  apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
178
+ token: __classPrivateFieldGet(this, _FileUpload_token, "f"),
171
179
  urlType: __classPrivateFieldGet(this, _FileUpload_urlType, "f"),
172
180
  body: {
173
181
  objectKey: ObjectKey,
@@ -181,6 +189,7 @@ _FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap(), _Fil
181
189
  return fetchData({
182
190
  path: FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
183
191
  apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
192
+ token: __classPrivateFieldGet(this, _FileUpload_token, "f"),
184
193
  urlType: __classPrivateFieldGet(this, _FileUpload_urlType, "f"),
185
194
  body: {
186
195
  uploadId,
@@ -197,6 +206,7 @@ _FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap(), _Fil
197
206
  path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
198
207
  urlType: __classPrivateFieldGet(this, _FileUpload_urlType, "f"),
199
208
  apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
209
+ token: __classPrivateFieldGet(this, _FileUpload_token, "f"),
200
210
  body: {
201
211
  objectKey: partData.key,
202
212
  uploadId: partData.uploadId,
@@ -13,6 +13,6 @@ declare class Swan {
13
13
  measurement: Measurement;
14
14
  poseDetection: PoseDetection;
15
15
  tryOn: TryOn;
16
- constructor(accessKey: string, urlType?: URLType);
16
+ constructor(accessKey?: string, urlType?: URLType, token?: string);
17
17
  }
18
18
  export default Swan;
package/dist/esm/index.js CHANGED
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Swan_accessKey, _Swan_urlType;
12
+ var _Swan_accessKey, _Swan_urlType, _Swan_token;
13
13
  import Auth from "./auth.js";
14
14
  import Custom from "./custom.js";
15
15
  import { URLType } from "./enum.js";
@@ -18,18 +18,20 @@ import Measurement from "./measurement.js";
18
18
  import PoseDetection from "./poseDetection.js";
19
19
  import TryOn from "./tryOn.js";
20
20
  class Swan {
21
- constructor(accessKey, urlType = URLType.PROD) {
21
+ constructor(accessKey, urlType = URLType.PROD, token) {
22
22
  _Swan_accessKey.set(this, void 0);
23
23
  _Swan_urlType.set(this, void 0);
24
+ _Swan_token.set(this, void 0);
24
25
  __classPrivateFieldSet(this, _Swan_accessKey, accessKey, "f");
25
26
  __classPrivateFieldSet(this, _Swan_urlType, urlType, "f");
26
- this.auth = new Auth(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"));
27
- this.custom = new Custom(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"));
28
- this.fileUpload = new FileUpload(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"));
29
- this.measurement = new Measurement(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"));
30
- this.poseDetection = new PoseDetection(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"));
31
- this.tryOn = new TryOn(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"));
27
+ __classPrivateFieldSet(this, _Swan_token, token, "f");
28
+ this.auth = new Auth(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"), __classPrivateFieldGet(this, _Swan_token, "f"));
29
+ this.custom = new Custom(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"), __classPrivateFieldGet(this, _Swan_token, "f"));
30
+ this.fileUpload = new FileUpload(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"), __classPrivateFieldGet(this, _Swan_token, "f"));
31
+ this.measurement = new Measurement(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"), __classPrivateFieldGet(this, _Swan_token, "f"));
32
+ this.poseDetection = new PoseDetection(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"), __classPrivateFieldGet(this, _Swan_token, "f"));
33
+ this.tryOn = new TryOn(__classPrivateFieldGet(this, _Swan_accessKey, "f"), __classPrivateFieldGet(this, _Swan_urlType, "f"), __classPrivateFieldGet(this, _Swan_token, "f"));
32
34
  }
33
35
  }
34
- _Swan_accessKey = new WeakMap(), _Swan_urlType = new WeakMap();
36
+ _Swan_accessKey = new WeakMap(), _Swan_urlType = new WeakMap(), _Swan_token = new WeakMap();
35
37
  export default Swan;
@@ -20,7 +20,7 @@ interface FaceScanSocketOptions extends Callbacks {
20
20
  }
21
21
  declare class Measurement {
22
22
  #private;
23
- constructor(accessKey: string, urlType?: URLType);
23
+ constructor(accessKey?: string, urlType?: URLType, token?: string);
24
24
  getMeasurementResult(scanId: string): Promise<AxiosResponse<any>>;
25
25
  getMeasurementRecommendation({ scanId, shopDomain, productName }: MeasurementRecommendation): Promise<AxiosResponse<any>>;
26
26
  handleMeasurementSocket(options: MeasurementSocketOptions): void;
@@ -18,13 +18,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
18
18
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
19
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
20
  };
21
- var _Measurement_instances, _Measurement_socketRefs, _Measurement_waitingTimers, _Measurement_pollingTimers, _Measurement_pollingCounts, _Measurement_accessKey, _Measurement_urlType, _Measurement_disconnectSocket, _Measurement_handleTimeOut, _Measurement_handlePolling, _Measurement_getMeasurementsCheck, _Measurement_handleSocket;
21
+ var _Measurement_instances, _Measurement_socketRefs, _Measurement_waitingTimers, _Measurement_pollingTimers, _Measurement_pollingCounts, _Measurement_accessKey, _Measurement_urlType, _Measurement_token, _Measurement_getHeaders, _Measurement_disconnectSocket, _Measurement_handleTimeOut, _Measurement_handlePolling, _Measurement_getMeasurementsCheck, _Measurement_handleSocket;
22
22
  import axios from "axios";
23
23
  import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_BASE_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
24
24
  import { checkParameters, getUrl } from "./utils.js";
25
25
  import { URLType } from "./enum.js";
26
26
  class Measurement {
27
- constructor(accessKey, urlType = URLType.PROD) {
27
+ constructor(accessKey, urlType = URLType.PROD, token) {
28
28
  _Measurement_instances.add(this);
29
29
  _Measurement_socketRefs.set(this, {});
30
30
  _Measurement_waitingTimers.set(this, {});
@@ -32,8 +32,10 @@ class Measurement {
32
32
  _Measurement_pollingCounts.set(this, {});
33
33
  _Measurement_accessKey.set(this, void 0);
34
34
  _Measurement_urlType.set(this, void 0);
35
+ _Measurement_token.set(this, void 0);
35
36
  __classPrivateFieldSet(this, _Measurement_accessKey, accessKey, "f");
36
37
  __classPrivateFieldSet(this, _Measurement_urlType, urlType, "f");
38
+ __classPrivateFieldSet(this, _Measurement_token, token, "f");
37
39
  }
38
40
  getMeasurementResult(scanId) {
39
41
  if (!checkParameters(scanId)) {
@@ -41,7 +43,7 @@ class Measurement {
41
43
  }
42
44
  const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Measurement_urlType, "f") })}/measurements?scanId=${scanId}`;
43
45
  return axios.get(url, {
44
- headers: { "X-Api-Key": __classPrivateFieldGet(this, _Measurement_accessKey, "f") },
46
+ headers: __classPrivateFieldGet(this, _Measurement_instances, "m", _Measurement_getHeaders).call(this),
45
47
  });
46
48
  }
47
49
  getMeasurementRecommendation({ scanId, shopDomain, productName }) {
@@ -49,7 +51,7 @@ class Measurement {
49
51
  throw new Error(REQUIRED_MESSAGE);
50
52
  }
51
53
  return axios.get(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Measurement_urlType, "f") })}${API_ENDPOINTS.RECOMMENDATION}/scan/${scanId}/shop/${shopDomain}/product/${productName}`, {
52
- headers: { "X-Api-Key": __classPrivateFieldGet(this, _Measurement_accessKey, "f") },
54
+ headers: __classPrivateFieldGet(this, _Measurement_instances, "m", _Measurement_getHeaders).call(this),
53
55
  });
54
56
  }
55
57
  handleMeasurementSocket(options) {
@@ -67,7 +69,9 @@ class Measurement {
67
69
  __classPrivateFieldGet(this, _Measurement_instances, "m", _Measurement_handleSocket).call(this, { onOpen, faceScanId, onSuccess, onError, onClose, paramsKey: "faceScanId", isFallback: false, delay: 1000 });
68
70
  }
69
71
  }
70
- _Measurement_socketRefs = new WeakMap(), _Measurement_waitingTimers = new WeakMap(), _Measurement_pollingTimers = new WeakMap(), _Measurement_pollingCounts = new WeakMap(), _Measurement_accessKey = new WeakMap(), _Measurement_urlType = new WeakMap(), _Measurement_instances = new WeakSet(), _Measurement_disconnectSocket = function _Measurement_disconnectSocket(key) {
72
+ _Measurement_socketRefs = new WeakMap(), _Measurement_waitingTimers = new WeakMap(), _Measurement_pollingTimers = new WeakMap(), _Measurement_pollingCounts = new WeakMap(), _Measurement_accessKey = new WeakMap(), _Measurement_urlType = new WeakMap(), _Measurement_token = new WeakMap(), _Measurement_instances = new WeakSet(), _Measurement_getHeaders = function _Measurement_getHeaders() {
73
+ return Object.assign(Object.assign({}, (__classPrivateFieldGet(this, _Measurement_accessKey, "f") ? { "X-Api-Key": __classPrivateFieldGet(this, _Measurement_accessKey, "f") } : {})), (__classPrivateFieldGet(this, _Measurement_token, "f") ? { Authorization: `Bearer ${__classPrivateFieldGet(this, _Measurement_token, "f")}` } : {}));
74
+ }, _Measurement_disconnectSocket = function _Measurement_disconnectSocket(key) {
71
75
  var _a;
72
76
  (_a = __classPrivateFieldGet(this, _Measurement_socketRefs, "f")[key]) === null || _a === void 0 ? void 0 : _a.close();
73
77
  __classPrivateFieldGet(this, _Measurement_socketRefs, "f")[key] = null;
@@ -6,7 +6,7 @@ interface VideoEmitOptions {
6
6
  type PoseStatusCallback = (data: any) => void;
7
7
  declare class PoseDetection {
8
8
  #private;
9
- constructor(accessKey: string, urlType?: URLType);
9
+ constructor(accessKey?: string, urlType?: URLType, token?: string);
10
10
  connect(): Promise<string>;
11
11
  videoEmit({ image, scanId }: VideoEmitOptions): void;
12
12
  disconnect(): void;
@@ -9,22 +9,26 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _PoseDetection_socketRef, _PoseDetection_accessKey, _PoseDetection_urlType;
12
+ var _PoseDetection_socketRef, _PoseDetection_accessKey, _PoseDetection_urlType, _PoseDetection_token;
13
13
  import { io } from "socket.io-client";
14
14
  import { APP_POSE_DETECTION_WEBSOCKET_URL } from "./constants.js";
15
15
  import { getUrl } from "./utils.js";
16
16
  import { URLType } from "./enum.js";
17
17
  class PoseDetection {
18
- constructor(accessKey, urlType = URLType.PROD) {
18
+ constructor(accessKey, urlType = URLType.PROD, token) {
19
19
  _PoseDetection_socketRef.set(this, null);
20
20
  _PoseDetection_accessKey.set(this, void 0);
21
21
  _PoseDetection_urlType.set(this, void 0);
22
+ _PoseDetection_token.set(this, void 0);
22
23
  __classPrivateFieldSet(this, _PoseDetection_accessKey, accessKey, "f");
23
24
  __classPrivateFieldSet(this, _PoseDetection_urlType, urlType, "f");
25
+ __classPrivateFieldSet(this, _PoseDetection_token, token, "f");
24
26
  }
25
27
  connect() {
26
28
  return new Promise((resolve, reject) => {
27
- __classPrivateFieldSet(this, _PoseDetection_socketRef, io(getUrl({ urlName: APP_POSE_DETECTION_WEBSOCKET_URL, urlType: __classPrivateFieldGet(this, _PoseDetection_urlType, "f") })), "f");
29
+ __classPrivateFieldSet(this, _PoseDetection_socketRef, io(getUrl({ urlName: APP_POSE_DETECTION_WEBSOCKET_URL, urlType: __classPrivateFieldGet(this, _PoseDetection_urlType, "f") }), {
30
+ extraHeaders: Object.assign(Object.assign({}, (__classPrivateFieldGet(this, _PoseDetection_accessKey, "f") ? { "X-Api-Key": __classPrivateFieldGet(this, _PoseDetection_accessKey, "f") } : {})), (__classPrivateFieldGet(this, _PoseDetection_token, "f") ? { Authorization: `Bearer ${__classPrivateFieldGet(this, _PoseDetection_token, "f")}` } : {})),
31
+ }), "f");
28
32
  __classPrivateFieldGet(this, _PoseDetection_socketRef, "f").on("connect", () => {
29
33
  var _a;
30
34
  const socketId = (_a = __classPrivateFieldGet(this, _PoseDetection_socketRef, "f")) === null || _a === void 0 ? void 0 : _a.id;
@@ -66,5 +70,5 @@ class PoseDetection {
66
70
  return !!((_a = __classPrivateFieldGet(this, _PoseDetection_socketRef, "f")) === null || _a === void 0 ? void 0 : _a.connected);
67
71
  }
68
72
  }
69
- _PoseDetection_socketRef = new WeakMap(), _PoseDetection_accessKey = new WeakMap(), _PoseDetection_urlType = new WeakMap();
73
+ _PoseDetection_socketRef = new WeakMap(), _PoseDetection_accessKey = new WeakMap(), _PoseDetection_urlType = new WeakMap(), _PoseDetection_token = new WeakMap();
70
74
  export default PoseDetection;
@@ -36,7 +36,6 @@ interface HandleForLatestImageParams {
36
36
  callbackUrl?: string;
37
37
  openTryonId?: string;
38
38
  selectedProductImageUrl?: string;
39
- token: string;
40
39
  requestedTryonViews?: string[];
41
40
  }
42
41
  interface GetTryOnResultParams {
@@ -44,13 +43,13 @@ interface GetTryOnResultParams {
44
43
  }
45
44
  declare class TryOn {
46
45
  #private;
47
- constructor(accessKey: string, urlType?: URLType);
46
+ constructor(accessKey?: string, urlType?: URLType, token?: string);
48
47
  uploadFile({ files, userEmail, fileNoLimit }: UploadFileParams): Promise<string>;
49
48
  getUploadedFiles(userEmail: string): Promise<AxiosResponse<any>>;
50
49
  deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
51
50
  handleTryOnWebSocket: ({ tryonId, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
52
- handleTryOnSubmit({ shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl, token, requestedTryonViews }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
53
- getShareLink(tryonId: string, token: string): Promise<AxiosResponse<any>>;
51
+ handleTryOnSubmit({ shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl, requestedTryonViews }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
52
+ getShareLink(tryonId: string): Promise<AxiosResponse<any>>;
54
53
  getTryOnResult: ({ tryonId }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
55
54
  getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }: EligibiltyImageParams): Promise<AxiosResponse<any, any>>;
56
55
  }