oneentry 1.0.159 → 1.0.161
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/README.md +2 -0
- package/changelog.md +56 -1
- package/dist/admins/adminsApi.d.ts +15 -1
- package/dist/admins/adminsApi.js +29 -0
- package/dist/admins/adminsInterfaces.d.ts +37 -1
- package/dist/base/lazySchema.d.ts +15 -0
- package/dist/base/lazySchema.js +20 -0
- package/dist/discounts/discountsApi.d.ts +14 -1
- package/dist/discounts/discountsApi.js +21 -0
- package/dist/discounts/discountsInterfaces.d.ts +27 -1
- package/dist/filters/filtersInterfaces.d.ts +2 -2
- package/dist/filters/filtersSchemas.d.ts +1 -1
- package/dist/filters/filtersSchemas.js +4 -1
- package/dist/forms-data/formsDataApi.d.ts +14 -1
- package/dist/forms-data/formsDataApi.js +21 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +74 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/orders/ordersApi.d.ts +15 -1
- package/dist/orders/ordersApi.js +22 -0
- package/dist/orders/ordersInterfaces.d.ts +27 -1
- package/dist/pages/pagesApi.d.ts +14 -1
- package/dist/pages/pagesApi.js +21 -0
- package/dist/pages/pagesInterfaces.d.ts +38 -1
- package/dist/payments/paymentsInterfaces.d.ts +2 -2
- package/dist/products/productsInterfaces.d.ts +1 -1
- package/dist/search/searchApi.d.ts +35 -0
- package/dist/search/searchApi.js +86 -0
- package/dist/search/searchInterfaces.d.ts +94 -0
- package/dist/search/searchInterfaces.js +2 -0
- package/dist/search/searchSchemas.d.ts +73 -0
- package/dist/search/searchSchemas.js +44 -0
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -2
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -2
- package/dist/templates-preview/templatesPreviewSchemas.js +0 -1
- package/dist/types.d.ts +35 -0
- package/dist/types.js +2 -0
- package/dist/users/usersApi.d.ts +15 -1
- package/dist/users/usersApi.js +22 -0
- package/dist/users/usersInterfaces.d.ts +39 -1
- package/dist/web-socket/lazySocket.d.ts +18 -0
- package/dist/web-socket/lazySocket.js +70 -0
- package/esm/admins/adminsApi.d.ts +66 -0
- package/esm/admins/adminsApi.js +90 -0
- package/esm/admins/adminsInterfaces.d.ts +137 -0
- package/esm/admins/adminsInterfaces.js +1 -0
- package/esm/admins/adminsSchemas.d.ts +48 -0
- package/esm/admins/adminsSchemas.js +31 -0
- package/esm/attribute-sets/attributeSetsApi.d.ts +67 -0
- package/esm/attribute-sets/attributeSetsApi.js +97 -0
- package/esm/attribute-sets/attributeSetsInterfaces.d.ts +285 -0
- package/esm/attribute-sets/attributeSetsInterfaces.js +1 -0
- package/esm/attribute-sets/attributeSetsSchemas.d.ts +84 -0
- package/esm/attribute-sets/attributeSetsSchemas.js +66 -0
- package/esm/auth-provider/authProviderApi.d.ts +262 -0
- package/esm/auth-provider/authProviderApi.js +362 -0
- package/esm/auth-provider/authProviderSchemas.d.ts +124 -0
- package/esm/auth-provider/authProviderSchemas.js +92 -0
- package/esm/auth-provider/authProvidersInterfaces.d.ts +430 -0
- package/esm/auth-provider/authProvidersInterfaces.js +1 -0
- package/esm/base/asyncModules.d.ts +123 -0
- package/esm/base/asyncModules.js +382 -0
- package/esm/base/lazySchema.d.ts +15 -0
- package/esm/base/lazySchema.js +17 -0
- package/esm/base/stateModule.d.ts +35 -0
- package/esm/base/stateModule.js +51 -0
- package/esm/base/syncModules.d.ts +245 -0
- package/esm/base/syncModules.js +555 -0
- package/esm/base/timeIntervals.d.ts +95 -0
- package/esm/base/timeIntervals.js +317 -0
- package/esm/base/utils.d.ts +354 -0
- package/esm/base/utils.js +1 -0
- package/esm/base/validation.d.ts +98 -0
- package/esm/base/validation.js +118 -0
- package/esm/blocks/blocksApi.d.ts +252 -0
- package/esm/blocks/blocksApi.js +394 -0
- package/esm/blocks/blocksInterfaces.d.ts +361 -0
- package/esm/blocks/blocksInterfaces.js +1 -0
- package/esm/blocks/blocksSchemas.d.ts +213 -0
- package/esm/blocks/blocksSchemas.js +40 -0
- package/esm/discounts/discountsApi.d.ts +94 -0
- package/esm/discounts/discountsApi.js +136 -0
- package/esm/discounts/discountsInterfaces.d.ts +293 -0
- package/esm/discounts/discountsInterfaces.js +1 -0
- package/esm/events/eventsApi.d.ts +108 -0
- package/esm/events/eventsApi.js +141 -0
- package/esm/events/eventsInterfaces.d.ts +176 -0
- package/esm/events/eventsInterfaces.js +1 -0
- package/esm/file-uploading/fileUploadingApi.d.ts +91 -0
- package/esm/file-uploading/fileUploadingApi.js +127 -0
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +116 -0
- package/esm/file-uploading/fileUploadingInterfaces.js +1 -0
- package/esm/file-uploading/fileUploadingSchemas.d.ts +24 -0
- package/esm/file-uploading/fileUploadingSchemas.js +19 -0
- package/esm/filters/filtersApi.d.ts +32 -0
- package/esm/filters/filtersApi.js +36 -0
- package/esm/filters/filtersInterfaces.d.ts +56 -0
- package/esm/filters/filtersInterfaces.js +1 -0
- package/esm/filters/filtersSchemas.d.ts +32 -0
- package/esm/filters/filtersSchemas.js +29 -0
- package/esm/forms/formsApi.d.ts +44 -0
- package/esm/forms/formsApi.js +54 -0
- package/esm/forms/formsInterfaces.d.ts +237 -0
- package/esm/forms/formsInterfaces.js +1 -0
- package/esm/forms/formsSchemas.d.ts +56 -0
- package/esm/forms/formsSchemas.js +32 -0
- package/esm/forms-data/formsDataApi.d.ts +124 -0
- package/esm/forms-data/formsDataApi.js +210 -0
- package/esm/forms-data/formsDataInterfaces.d.ts +670 -0
- package/esm/forms-data/formsDataInterfaces.js +1 -0
- package/esm/forms-data/formsDataSchemas.d.ts +107 -0
- package/esm/forms-data/formsDataSchemas.js +83 -0
- package/esm/general-types/generalTypesApi.d.ts +29 -0
- package/esm/general-types/generalTypesApi.js +34 -0
- package/esm/general-types/generalTypesInterfaces.d.ts +29 -0
- package/esm/general-types/generalTypesInterfaces.js +1 -0
- package/esm/general-types/generalTypesSchemas.d.ts +68 -0
- package/esm/general-types/generalTypesSchemas.js +42 -0
- package/esm/index.d.ts +143 -0
- package/esm/index.js +124 -0
- package/esm/integration-collections/integrationCollectionsApi.d.ts +172 -0
- package/esm/integration-collections/integrationCollectionsApi.js +224 -0
- package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +317 -0
- package/esm/integration-collections/integrationCollectionsInterfaces.js +1 -0
- package/esm/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
- package/esm/integration-collections/integrationCollectionsSchemas.js +60 -0
- package/esm/locales/localesApi.d.ts +28 -0
- package/esm/locales/localesApi.js +33 -0
- package/esm/locales/localesInterfaces.d.ts +40 -0
- package/esm/locales/localesInterfaces.js +1 -0
- package/esm/locales/localesSchemas.d.ts +32 -0
- package/esm/locales/localesSchemas.js +23 -0
- package/esm/menus/menusApi.d.ts +30 -0
- package/esm/menus/menusApi.js +35 -0
- package/esm/menus/menusInterfaces.d.ts +87 -0
- package/esm/menus/menusInterfaces.js +2 -0
- package/esm/menus/menusSchemas.d.ts +16 -0
- package/esm/menus/menusSchemas.js +25 -0
- package/esm/orders/ordersApi.d.ts +213 -0
- package/esm/orders/ordersApi.js +288 -0
- package/esm/orders/ordersInterfaces.d.ts +763 -0
- package/esm/orders/ordersInterfaces.js +1 -0
- package/esm/orders/ordersSchemas.d.ts +312 -0
- package/esm/orders/ordersSchemas.js +171 -0
- package/esm/package.json +4 -0
- package/esm/pages/pagesApi.d.ts +173 -0
- package/esm/pages/pagesApi.js +414 -0
- package/esm/pages/pagesInterfaces.d.ts +344 -0
- package/esm/pages/pagesInterfaces.js +1 -0
- package/esm/pages/pagesSchemas.d.ts +121 -0
- package/esm/pages/pagesSchemas.js +60 -0
- package/esm/payments/paymentsApi.d.ts +88 -0
- package/esm/payments/paymentsApi.js +122 -0
- package/esm/payments/paymentsInterfaces.d.ts +189 -0
- package/esm/payments/paymentsInterfaces.js +1 -0
- package/esm/payments/paymentsSchemas.d.ts +94 -0
- package/esm/payments/paymentsSchemas.js +53 -0
- package/esm/product-statuses/productStatusesApi.d.ts +50 -0
- package/esm/product-statuses/productStatusesApi.js +68 -0
- package/esm/product-statuses/productStatusesInterfaces.d.ts +62 -0
- package/esm/product-statuses/productStatusesInterfaces.js +1 -0
- package/esm/product-statuses/productStatusesSchemas.d.ts +34 -0
- package/esm/product-statuses/productStatusesSchemas.js +27 -0
- package/esm/products/productsApi.d.ts +366 -0
- package/esm/products/productsApi.js +468 -0
- package/esm/products/productsInterfaces.d.ts +723 -0
- package/esm/products/productsInterfaces.js +1 -0
- package/esm/products/productsSchemas.d.ts +234 -0
- package/esm/products/productsSchemas.js +121 -0
- package/esm/search/searchApi.d.ts +35 -0
- package/esm/search/searchApi.js +47 -0
- package/esm/search/searchInterfaces.d.ts +94 -0
- package/esm/search/searchInterfaces.js +1 -0
- package/esm/search/searchSchemas.d.ts +73 -0
- package/esm/search/searchSchemas.js +41 -0
- package/esm/sitemap/sitemapApi.d.ts +37 -0
- package/esm/sitemap/sitemapApi.js +41 -0
- package/esm/sitemap/sitemapInterfaces.d.ts +51 -0
- package/esm/sitemap/sitemapInterfaces.js +1 -0
- package/esm/subscriptions/subscriptionsApi.d.ts +74 -0
- package/esm/subscriptions/subscriptionsApi.js +90 -0
- package/esm/subscriptions/subscriptionsInterfaces.d.ts +111 -0
- package/esm/subscriptions/subscriptionsInterfaces.js +1 -0
- package/esm/subscriptions/subscriptionsSchemas.d.ts +46 -0
- package/esm/subscriptions/subscriptionsSchemas.js +38 -0
- package/esm/system/systemApi.d.ts +46 -0
- package/esm/system/systemApi.js +53 -0
- package/esm/system/systemInterfaces.d.ts +29 -0
- package/esm/system/systemInterfaces.js +1 -0
- package/esm/templates/templatesApi.d.ts +53 -0
- package/esm/templates/templatesApi.js +78 -0
- package/esm/templates/templatesInterfaces.d.ts +68 -0
- package/esm/templates/templatesInterfaces.js +1 -0
- package/esm/templates/templatesSchemas.d.ts +48 -0
- package/esm/templates/templatesSchemas.js +28 -0
- package/esm/templates-preview/templatesPreviewApi.d.ts +40 -0
- package/esm/templates-preview/templatesPreviewApi.js +50 -0
- package/esm/templates-preview/templatesPreviewInterfaces.d.ts +129 -0
- package/esm/templates-preview/templatesPreviewInterfaces.js +1 -0
- package/esm/templates-preview/templatesPreviewSchemas.d.ts +79 -0
- package/esm/templates-preview/templatesPreviewSchemas.js +43 -0
- package/esm/types.d.ts +35 -0
- package/esm/types.js +1 -0
- package/esm/user-activity/userActivityApi.d.ts +31 -0
- package/esm/user-activity/userActivityApi.js +37 -0
- package/esm/user-activity/userActivityInterfaces.d.ts +42 -0
- package/esm/user-activity/userActivityInterfaces.js +1 -0
- package/esm/users/usersApi.d.ts +249 -0
- package/esm/users/usersApi.js +312 -0
- package/esm/users/usersInterfaces.d.ts +419 -0
- package/esm/users/usersInterfaces.js +1 -0
- package/esm/users/usersSchemas.d.ts +72 -0
- package/esm/users/usersSchemas.js +55 -0
- package/esm/web-socket/lazySocket.d.ts +18 -0
- package/esm/web-socket/lazySocket.js +67 -0
- package/esm/web-socket/wsApi.d.ts +27 -0
- package/esm/web-socket/wsApi.js +43 -0
- package/esm/web-socket/wsInterfaces.d.ts +16 -0
- package/esm/web-socket/wsInterfaces.js +1 -0
- package/package.json +47 -2
- package/types.d.ts +1 -0
- package/types.js +1 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import type { IUploadingQuery } from '../file-uploading/fileUploadingInterfaces.js';
|
|
2
|
+
import type { IProductsQuery } from '../products/productsInterfaces.js';
|
|
3
|
+
import type StateModule from './stateModule.js';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract class representing synchronization modules.
|
|
6
|
+
*/
|
|
7
|
+
export default abstract class SyncModules {
|
|
8
|
+
/** Protected properties for state and URL */
|
|
9
|
+
protected state: StateModule;
|
|
10
|
+
protected _url: string;
|
|
11
|
+
private readonly _nodeDeviceId;
|
|
12
|
+
/**
|
|
13
|
+
* Constructor to initialize state and URL.
|
|
14
|
+
* @param {StateModule} state - StateModule instance.
|
|
15
|
+
*/
|
|
16
|
+
protected constructor(state: StateModule);
|
|
17
|
+
/**
|
|
18
|
+
* Resolves the guest identifier for the current request, or `undefined`.
|
|
19
|
+
*
|
|
20
|
+
* Resolution order:
|
|
21
|
+
* 1. An explicitly configured `state.guestId` (from config or `setGuestId`) — wins.
|
|
22
|
+
* 2. A persistent browser ID stored in localStorage (key `oneentry_guest_id`),
|
|
23
|
+
* stable across sessions and tabs — mirrors the device-metadata strategy.
|
|
24
|
+
* Once resolved it is cached into `state.guestId` (safe: one browser = one user).
|
|
25
|
+
* 3. Otherwise `undefined` — the `x-guest-id` header is simply omitted.
|
|
26
|
+
*
|
|
27
|
+
* IMPORTANT (server-side): the SDK never invents a guest id on the server.
|
|
28
|
+
* `defineOneEntry` is typically created once and shared across many visitors,
|
|
29
|
+
* so a silently-generated server id would be cached into the shared state and
|
|
30
|
+
* leak one guest cart/wishlist across all anonymous visitors. On the server
|
|
31
|
+
* you must pass a per-visitor `guestId` (config or `setGuestId`) yourself.
|
|
32
|
+
* @returns {string | undefined} The guest identifier, or undefined when none is available.
|
|
33
|
+
*/
|
|
34
|
+
protected _getGuestId(): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Constructs the full URL path by appending the given path to the base URL.
|
|
37
|
+
* @param {string} path - The path to append to the base URL.
|
|
38
|
+
* @returns {string} The full URL as a string.
|
|
39
|
+
*/
|
|
40
|
+
protected _getFullPath(path: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Converts query parameters into a query string.
|
|
43
|
+
*
|
|
44
|
+
* Values are percent-encoded so free-text and special characters (spaces,
|
|
45
|
+
* `&`, `=`, non-ASCII) cannot corrupt the query string. Keys are known,
|
|
46
|
+
* machine-safe field names and are left as-is.
|
|
47
|
+
* @param {IProductsQuery | IUploadingQuery | any} query - The query object containing key-value pairs.
|
|
48
|
+
* @returns {string} A string representation of the query parameters.
|
|
49
|
+
*/
|
|
50
|
+
protected _queryParamsToString(query: IProductsQuery | IUploadingQuery | any): string;
|
|
51
|
+
/**
|
|
52
|
+
* Normalizes data based on language code.
|
|
53
|
+
*
|
|
54
|
+
* Recursively traverses the API response and unwraps localized fields.
|
|
55
|
+
* The API stores translations as objects like
|
|
56
|
+
* `{ "en_US": "Hello", "ru_RU": "Hello" }`. The method replaces such an object
|
|
57
|
+
* with the value for the requested `langCode` when that key is present.
|
|
58
|
+
*
|
|
59
|
+
* Traversal order:
|
|
60
|
+
* 1. Array → recursively normalize each element, then `_normalizeAttr`.
|
|
61
|
+
* 2. Object → for each key:
|
|
62
|
+
* - value is an array: recurse;
|
|
63
|
+
* - value is a non-object (primitive) or falsy: copy as-is;
|
|
64
|
+
* - object has key `langCode`: take only the needed translation;
|
|
65
|
+
* - otherwise: recurse deeper.
|
|
66
|
+
* 3. Primitive → return as-is.
|
|
67
|
+
* @param {any} data - The data to normalize.
|
|
68
|
+
* @param {string} langCode - The language code for normalization.
|
|
69
|
+
* @returns {any} Normalized data.
|
|
70
|
+
*/
|
|
71
|
+
protected _normalizeData(data: any, langCode?: string): any;
|
|
72
|
+
/**
|
|
73
|
+
* Normalizes the body of a POST request.
|
|
74
|
+
*
|
|
75
|
+
* Performs two transformations before sending to the API:
|
|
76
|
+
*
|
|
77
|
+
* 1. **phoneSMS cleanup**: the API rejects an empty string as a field value,
|
|
78
|
+
* so if `notificationData.phoneSMS === ''` the key is deleted entirely.
|
|
79
|
+
* A missing key is treated by the API as "not provided"; an empty string is not.
|
|
80
|
+
*
|
|
81
|
+
* 2. **formData localization**: the API expects formData as
|
|
82
|
+
* `{ "<langCode>": [...fields] }`, but callers pass a flat array or a single object.
|
|
83
|
+
* The method wraps the data into the required structure.
|
|
84
|
+
* If `formData` is absent from the body — return the body as-is (only phoneSMS cleanup applied).
|
|
85
|
+
* @param {any} body - The body to normalize.
|
|
86
|
+
* @param {string} [langCode] - The language code for normalization.
|
|
87
|
+
* @returns {any} Normalized body.
|
|
88
|
+
*/
|
|
89
|
+
protected _normalizePostBody(body: any, langCode?: string): any;
|
|
90
|
+
/**
|
|
91
|
+
* Normalizes the value of a single attribute in place.
|
|
92
|
+
*
|
|
93
|
+
* Applies the three type-driven fixes the API response needs, so that an
|
|
94
|
+
* attribute of a given type always reaches the consumer in the same shape,
|
|
95
|
+
* no matter which collection it arrived in:
|
|
96
|
+
*
|
|
97
|
+
* 1. **Single-file values** (`image`, `file`) — the API always sends an array,
|
|
98
|
+
* even for one file: `[img]` → `img`. Multi-file values and `groupOfImages`
|
|
99
|
+
* (a collection by definition) stay an array.
|
|
100
|
+
* 2. **Empty values** — an attribute with no value comes back as an empty
|
|
101
|
+
* localization map `{}`; it is replaced with `null`, the same marker the
|
|
102
|
+
* numeric branch already produced.
|
|
103
|
+
* 3. **Numbers** (`integer`, `float`, `real`) — cast to a JS number; anything
|
|
104
|
+
* that is not a number (including an empty value) becomes `null`.
|
|
105
|
+
* @param {any} attr - The attribute object to normalize in place.
|
|
106
|
+
*/
|
|
107
|
+
private _normalizeAttrValue;
|
|
108
|
+
/**
|
|
109
|
+
* Sorts attributes by their positions.
|
|
110
|
+
*
|
|
111
|
+
* Each attribute has a `position` field, and the API returns them in no
|
|
112
|
+
* particular order. The method rebuilds the collection sorted by ascending
|
|
113
|
+
* `position`, so the display order matches the order defined in the CMS.
|
|
114
|
+
* Both container shapes the API uses are handled: an object keyed by marker
|
|
115
|
+
* (`attributeValues`) and an array (form `attributes`).
|
|
116
|
+
* @param {any} data - The attributes collection to sort.
|
|
117
|
+
* @returns {any} Sorted attributes, in the same container shape.
|
|
118
|
+
*/
|
|
119
|
+
protected _sortAttributes: (data: any) => any;
|
|
120
|
+
/**
|
|
121
|
+
* Transforms additionalFields from array to object keyed by marker.
|
|
122
|
+
*
|
|
123
|
+
* The API returns `additionalFields` as an array: `[{ marker, ... }, ...]`.
|
|
124
|
+
* For convenient key-based access (`attr.additionalFields['fieldName']`)
|
|
125
|
+
* the method converts it to an object `{ marker: { marker, ... } }`.
|
|
126
|
+
* Transformation is skipped when `rawData` mode is enabled in config
|
|
127
|
+
* (the consumer wants the data as-is, without transformations).
|
|
128
|
+
* @param {any} attr - The attribute object that may contain additionalFields.
|
|
129
|
+
*/
|
|
130
|
+
private _normalizeAdditionalFields;
|
|
131
|
+
/**
|
|
132
|
+
* Normalizes attributes within the data.
|
|
133
|
+
*
|
|
134
|
+
* Handles three different attribute formats returned by the API:
|
|
135
|
+
*
|
|
136
|
+
* All three go through the same steps, so an attribute of a given type looks
|
|
137
|
+
* the same whichever collection it arrived in:
|
|
138
|
+
* - `_normalizeAdditionalFields` turns nested fields into a marker map;
|
|
139
|
+
* - `_normalizeAttrValue` unwraps single-file values, empties to `null` and
|
|
140
|
+
* casts numbers;
|
|
141
|
+
* - the collection is re-sorted by `position`.
|
|
142
|
+
*
|
|
143
|
+
* **1. `attributeValues`** — attributes of pages, products and other entities,
|
|
144
|
+
* an object `{ marker: AttrObject }`.
|
|
145
|
+
*
|
|
146
|
+
* **2. `attributes`** — form attributes, an array (or a marker map on some
|
|
147
|
+
* endpoints); form-only boolean flags (`isLogin`, `isSignUp`, notifications)
|
|
148
|
+
* are additionally coerced from `null` to `false`. A form with no attributes
|
|
149
|
+
* arrives as an empty object `{}` — it is normalized to an empty array.
|
|
150
|
+
*
|
|
151
|
+
* **3. `type`** — a standalone attribute: an attribute-set entry, a form-data
|
|
152
|
+
* field or a nested `additionalFields` entry. Same transformations, but there
|
|
153
|
+
* is no collection to sort.
|
|
154
|
+
*
|
|
155
|
+
* `timeInterval` attributes are left exactly as the API returned them — a
|
|
156
|
+
* compact recurrence rule. Resolving one into concrete slots is the caller's
|
|
157
|
+
* job, via `expandTimeIntervals`: the rule is open-ended, so only the caller
|
|
158
|
+
* knows how wide a window it needs.
|
|
159
|
+
*
|
|
160
|
+
* If none of the keys are found — data is returned unchanged.
|
|
161
|
+
* @param {any} data - The data to normalize.
|
|
162
|
+
* @returns {any} Normalized attributes.
|
|
163
|
+
*/
|
|
164
|
+
protected _normalizeAttr(data: any): any;
|
|
165
|
+
/**
|
|
166
|
+
* Sets the access token in the state.
|
|
167
|
+
* @param {string} accessToken - The access token to set.
|
|
168
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
169
|
+
*/
|
|
170
|
+
setAccessToken(accessToken: string): any;
|
|
171
|
+
/**
|
|
172
|
+
* Sets the refresh token in the state.
|
|
173
|
+
* @param {string} refreshToken - The refresh token to set.
|
|
174
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
175
|
+
*/
|
|
176
|
+
setRefreshToken(refreshToken: string): any;
|
|
177
|
+
/**
|
|
178
|
+
* Sets the guest identifier in the state.
|
|
179
|
+
*
|
|
180
|
+
* Once set, it is sent as the `x-guest-id` header on unauthenticated requests,
|
|
181
|
+
* enabling guest cart/wishlist/activity flows. Pass an empty string to clear it
|
|
182
|
+
* (the SDK then falls back to the localStorage-backed id in the browser, or to
|
|
183
|
+
* no guest id at all on the server).
|
|
184
|
+
* @param {string} guestId - The guest identifier to set (empty string clears it).
|
|
185
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
186
|
+
*/
|
|
187
|
+
setGuestId(guestId: string): any;
|
|
188
|
+
/**
|
|
189
|
+
* Sets the device-metadata override in the state.
|
|
190
|
+
*
|
|
191
|
+
* Once set, the string is sent as the `x-device-metadata` header on POST
|
|
192
|
+
* requests and token refresh instead of the environment-derived fingerprint.
|
|
193
|
+
* The API binds refresh tokens to this header, so server-side flows that issue
|
|
194
|
+
* tokens on behalf of a browser (e.g. an OAuth code exchange) must set the
|
|
195
|
+
* browser's string (obtained there via `getDeviceMetadata`). Pass an empty
|
|
196
|
+
* string to clear the override and fall back to the computed fingerprint.
|
|
197
|
+
* @param {string} deviceMetadata - The metadata string to send (empty string clears the override).
|
|
198
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
199
|
+
*/
|
|
200
|
+
setDeviceMetadata(deviceMetadata: string): any;
|
|
201
|
+
/**
|
|
202
|
+
* Returns the device-metadata string the SDK sends as the `x-device-metadata` header.
|
|
203
|
+
*
|
|
204
|
+
* Public counterpart of `_getDeviceMetadata`: an explicit override (config or
|
|
205
|
+
* `setDeviceMetadata`) wins, otherwise the environment-derived fingerprint is
|
|
206
|
+
* computed. Use it in the browser to obtain the string that a server-side
|
|
207
|
+
* token-issuing flow (OAuth code exchange) must forward, so the issued refresh
|
|
208
|
+
* token stays refreshable from this browser.
|
|
209
|
+
* @returns {string} The metadata string sent with requests from this instance.
|
|
210
|
+
*/
|
|
211
|
+
getDeviceMetadata(): string;
|
|
212
|
+
/**
|
|
213
|
+
* Get deviceMetadata
|
|
214
|
+
*
|
|
215
|
+
* Builds a device metadata object to be sent in request headers.
|
|
216
|
+
* Used for analytics and anti-fraud on the API side.
|
|
217
|
+
*
|
|
218
|
+
* Returned JSON structure:
|
|
219
|
+
* ```json
|
|
220
|
+
* {
|
|
221
|
+
* "fingerprint": "UQ_<hash>_<instanceId>",
|
|
222
|
+
* "deviceInfo": { "os": "...", "browser": "...", "location": "en-US" }
|
|
223
|
+
* }
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* **Fingerprint algorithm:**
|
|
227
|
+
* 1. Builds a string from stable characteristics: platform, userAgent, language,
|
|
228
|
+
* screen resolution, colorDepth, timezone, private-browsing mode, instanceId.
|
|
229
|
+
* 2. Runs it through a simple 32-bit hash (djb2-like).
|
|
230
|
+
* 3. Concatenates the hash and the first 12 characters of instanceId.
|
|
231
|
+
*
|
|
232
|
+
* **instanceId strategy:**
|
|
233
|
+
* - Browser: `_getPersistentBrowserId('oneentry_device_id')` — read from localStorage, stable across sessions.
|
|
234
|
+
* - Node.js / no localStorage: `_nodeDeviceId` — generated at instance creation,
|
|
235
|
+
* lives until the process restarts.
|
|
236
|
+
*
|
|
237
|
+
* In a Node.js environment (no `window`) returns a simplified object without screen/navigator.
|
|
238
|
+
*
|
|
239
|
+
* An explicitly provided string (`deviceMetadata` in config or `setDeviceMetadata`)
|
|
240
|
+
* takes precedence over the environment-derived fingerprint — this lets a server
|
|
241
|
+
* issue tokens bound to the browser's fingerprint (see `IConfig.deviceMetadata`).
|
|
242
|
+
* @returns {string} - Returns an object containing device metadata.
|
|
243
|
+
*/
|
|
244
|
+
protected _getDeviceMetadata(): string;
|
|
245
|
+
}
|