oneentry 1.0.151 → 1.0.153
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/changelog.md +20 -0
- package/dist/admins/adminsApi.d.ts +2 -1
- package/dist/admins/adminsApi.js +2 -1
- package/dist/admins/adminsInterfaces.d.ts +1 -1
- package/dist/attribute-sets/attributeSetsApi.d.ts +4 -0
- package/dist/attribute-sets/attributeSetsApi.js +4 -0
- package/dist/auth-provider/authProviderApi.d.ts +14 -1
- package/dist/auth-provider/authProviderApi.js +14 -1
- package/dist/base/asyncModules.d.ts +19 -2
- package/dist/base/asyncModules.js +74 -4
- package/dist/base/stateModule.d.ts +1 -0
- package/dist/base/stateModule.js +4 -0
- package/dist/blocks/blocksApi.d.ts +34 -1
- package/dist/blocks/blocksApi.js +69 -62
- package/dist/discounts/discountsApi.d.ts +5 -0
- package/dist/discounts/discountsApi.js +5 -0
- package/dist/events/eventsApi.d.ts +7 -0
- package/dist/events/eventsApi.js +11 -28
- package/dist/file-uploading/fileUploadingApi.d.ts +4 -1
- package/dist/file-uploading/fileUploadingApi.js +4 -1
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +1 -1
- package/dist/filters/filtersApi.d.ts +1 -0
- package/dist/filters/filtersApi.js +1 -0
- package/dist/forms/formsApi.d.ts +2 -0
- package/dist/forms/formsApi.js +2 -0
- package/dist/forms-data/formsDataApi.d.ts +5 -0
- package/dist/forms-data/formsDataApi.js +5 -0
- package/dist/general-types/generalTypesApi.d.ts +1 -0
- package/dist/general-types/generalTypesApi.js +1 -0
- package/dist/integration-collections/integrationCollectionsApi.d.ts +10 -1
- package/dist/integration-collections/integrationCollectionsApi.js +10 -1
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +1 -1
- package/dist/locales/localesApi.d.ts +1 -0
- package/dist/locales/localesApi.js +1 -0
- package/dist/menus/menusApi.d.ts +1 -0
- package/dist/menus/menusApi.js +1 -0
- package/dist/orders/ordersApi.d.ts +25 -1
- package/dist/orders/ordersApi.js +36 -12
- package/dist/orders/ordersInterfaces.d.ts +4 -2
- package/dist/pages/pagesApi.d.ts +9 -0
- package/dist/pages/pagesApi.js +33 -38
- package/dist/pages/pagesInterfaces.d.ts +5 -0
- package/dist/payments/paymentsApi.d.ts +6 -0
- package/dist/payments/paymentsApi.js +6 -0
- package/dist/product-statuses/productStatusesApi.d.ts +3 -0
- package/dist/product-statuses/productStatusesApi.js +3 -0
- package/dist/products/productsApi.d.ts +14 -0
- package/dist/products/productsApi.js +14 -0
- package/dist/products/productsInterfaces.d.ts +2 -2
- package/dist/sitemap/sitemapApi.d.ts +2 -0
- package/dist/sitemap/sitemapApi.js +2 -0
- package/dist/subscriptions/subscriptionsApi.d.ts +5 -0
- package/dist/subscriptions/subscriptionsApi.js +7 -14
- package/dist/system/systemApi.d.ts +3 -0
- package/dist/system/systemApi.js +3 -0
- package/dist/templates/templatesApi.d.ts +3 -0
- package/dist/templates/templatesApi.js +3 -0
- package/dist/templates-preview/templatesPreviewApi.d.ts +2 -0
- package/dist/templates-preview/templatesPreviewApi.js +2 -0
- package/dist/user-activity/userActivityApi.d.ts +1 -0
- package/dist/user-activity/userActivityApi.js +1 -0
- package/dist/users/usersApi.d.ts +14 -0
- package/dist/users/usersApi.js +14 -0
- package/dist/web-socket/wsApi.d.ts +1 -1
- package/dist/web-socket/wsApi.js +1 -1
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# SDK Change Log
|
|
2
2
|
|
|
3
|
+
## v.1.0.153
|
|
4
|
+
|
|
5
|
+
### What's New
|
|
6
|
+
|
|
7
|
+
- Pages > `IPositionBlock` — new optional `similarProducts` (`IProductsResponse`) and `products` (`IProductsEntity[]`) fields, populated for `similar_products_block` / `product_block` page blocks (when traffic-saving mode is off).
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- Pages > `getBlocksByPageUrl` — related products are now actually loaded for `product_block` (`products`) and `similar_products_block` (`similarProducts`) blocks. The block-type check ran against the response array instead of each block, so product loading never executed; it now runs per block. `similarProducts` is returned as the full `{ total, items }` response, consistent with `Blocks` block enrichment.
|
|
12
|
+
|
|
13
|
+
- Orders > `getRefunds`, `createRefundRequest`, `cancelRefundRequest` — the base URL is now restored even if the refund request throws (wrapped in `try/finally`). Previously an exception left `_url` switched to `/orders`, which could misroute subsequent calls on the same instance.
|
|
14
|
+
|
|
15
|
+
## v.1.0.152
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- Auth — eliminated the spurious `401` logged on every page load for a valid restored session. `browserResponse` now does a **proactive refresh** when a refresh token is present but there is no access token yet: it fetches the access token *before* the first request (clean `200`) instead of sending an unauthenticated request that is guaranteed to `401` and then reactively refreshing. After the proactive refresh it attaches `Authorization` and drops the `x-guest-id` scoping. The reactive `401 → refresh → retry` path is retained for mid-session token expiry.
|
|
20
|
+
|
|
21
|
+
- Auth — `refreshToken` is now **single-flight**.
|
|
22
|
+
|
|
3
23
|
## v.1.0.151
|
|
4
24
|
|
|
5
25
|
### What's New
|
|
@@ -40,12 +40,13 @@ export default class AdminsApi extends AsyncModules implements IAdmins {
|
|
|
40
40
|
]
|
|
41
41
|
* @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
|
|
42
42
|
* @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
|
|
43
|
-
* @param {string} [body.conditionValue] - Value of the condition. Example:
|
|
43
|
+
* @param {number | string | null} [body.conditionValue] - Value of the condition. Example: "new".
|
|
44
44
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
45
45
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
46
46
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
47
47
|
* @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
|
|
48
48
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
49
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsInfo getAdminsInfo} documentation.
|
|
49
50
|
*/
|
|
50
51
|
getAdminsInfo(body?: IFilterParams[], langCode?: string, offset?: number, limit?: number): Promise<IAdminEntity[] | IError>;
|
|
51
52
|
}
|
package/dist/admins/adminsApi.js
CHANGED
|
@@ -43,12 +43,13 @@ class AdminsApi extends asyncModules_1.default {
|
|
|
43
43
|
]
|
|
44
44
|
* @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
|
|
45
45
|
* @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
|
|
46
|
-
* @param {string} [body.conditionValue] - Value of the condition. Example:
|
|
46
|
+
* @param {number | string | null} [body.conditionValue] - Value of the condition. Example: "new".
|
|
47
47
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
48
48
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
49
49
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
50
50
|
* @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
|
|
51
51
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
52
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsInfo getAdminsInfo} documentation.
|
|
52
53
|
*/
|
|
53
54
|
async getAdminsInfo(body = [], langCode = this.state.lang, offset = 0, limit = 30) {
|
|
54
55
|
const query = {
|
|
@@ -25,7 +25,7 @@ interface IAdmins {
|
|
|
25
25
|
]
|
|
26
26
|
* @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
|
|
27
27
|
* @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
|
|
28
|
-
* @param {string} [body.conditionValue] - Value of the condition. Example:
|
|
28
|
+
* @param {number | string | null} [body.conditionValue] - Value of the condition. Example: "new".
|
|
29
29
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
30
30
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
31
31
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
@@ -30,6 +30,7 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
|
|
|
30
30
|
* @param {string} [sortBy] - identifier of the attribute set type. Default: "id".
|
|
31
31
|
* @returns {Promise<IAttributesSetsResponse | IError>} Returns object with array of IAttributeSetsEntity and total items count.
|
|
32
32
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
33
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributes getAttributes} documentation.
|
|
33
34
|
*/
|
|
34
35
|
getAttributes(langCode?: string, offset?: number, limit?: number, typeId?: any, sortBy?: string): Promise<IAttributesSetsResponse | IError>;
|
|
35
36
|
/**
|
|
@@ -39,6 +40,7 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
|
|
|
39
40
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
40
41
|
* @returns {Promise<IAttributeSetsEntity[] | IError>} Returns an array of Attributes objects.
|
|
41
42
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
43
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributesByMarker getAttributesByMarker} documentation.
|
|
42
44
|
*/
|
|
43
45
|
getAttributesByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity[] | IError>;
|
|
44
46
|
/**
|
|
@@ -49,6 +51,7 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
|
|
|
49
51
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
50
52
|
* @returns {Promise<IAttributesSetsEntity | IError>} Returns a single attribute object from the attribute set.
|
|
51
53
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
54
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getSingleAttributeByMarkerSet getSingleAttributeByMarkerSet} documentation.
|
|
52
55
|
*/
|
|
53
56
|
getSingleAttributeByMarkerSet(setMarker: string, attributeMarker: string, langCode?: string): Promise<IAttributesSetsEntity | IError>;
|
|
54
57
|
/**
|
|
@@ -58,6 +61,7 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
|
|
|
58
61
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
59
62
|
* @returns {Promise<IAttributeSetsEntity | IError>} Returns one object of the attribute set.
|
|
60
63
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
64
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributeSetByMarker getAttributeSetByMarker} documentation.
|
|
61
65
|
*/
|
|
62
66
|
getAttributeSetByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity | IError>;
|
|
63
67
|
}
|
|
@@ -34,6 +34,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
34
34
|
* @param {string} [sortBy] - identifier of the attribute set type. Default: "id".
|
|
35
35
|
* @returns {Promise<IAttributesSetsResponse | IError>} Returns object with array of IAttributeSetsEntity and total items count.
|
|
36
36
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
37
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributes getAttributes} documentation.
|
|
37
38
|
*/
|
|
38
39
|
async getAttributes(langCode = this.state.lang, offset = 0, limit = 30,
|
|
39
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -58,6 +59,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
58
59
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
59
60
|
* @returns {Promise<IAttributeSetsEntity[] | IError>} Returns an array of Attributes objects.
|
|
60
61
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
62
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributesByMarker getAttributesByMarker} documentation.
|
|
61
63
|
*/
|
|
62
64
|
async getAttributesByMarker(marker, langCode = this.state.lang) {
|
|
63
65
|
const result = await this._fetchGet(`/${marker}/attributes?langCode=${langCode}`);
|
|
@@ -73,6 +75,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
73
75
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
74
76
|
* @returns {Promise<IAttributesSetsEntity | IError>} Returns a single attribute object from the attribute set.
|
|
75
77
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
78
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getSingleAttributeByMarkerSet getSingleAttributeByMarkerSet} documentation.
|
|
76
79
|
*/
|
|
77
80
|
async getSingleAttributeByMarkerSet(setMarker, attributeMarker, langCode = this.state.lang) {
|
|
78
81
|
const result = await this._fetchGet(`/${setMarker}/attributes/${attributeMarker}?langCode=${langCode}`);
|
|
@@ -87,6 +90,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
87
90
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
88
91
|
* @returns {Promise<IAttributeSetsEntity | IError>} Returns one object of the attribute set.
|
|
89
92
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
93
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributeSetByMarker getAttributeSetByMarker} documentation.
|
|
90
94
|
*/
|
|
91
95
|
async getAttributeSetByMarker(marker, langCode = this.state.lang) {
|
|
92
96
|
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
@@ -82,6 +82,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
82
82
|
* @returns {Promise<ISignUpEntity | IError>} Returns a user object.
|
|
83
83
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
84
84
|
* @description User registration (❗️For a provider with user activation, the activation code is sent through the corresponding user notification method).
|
|
85
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/signUp signUp} documentation.
|
|
85
86
|
*/
|
|
86
87
|
signUp(marker: string, body: ISignUpData, langCode?: string): Promise<ISignUpEntity | IError>;
|
|
87
88
|
/**
|
|
@@ -93,6 +94,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
93
94
|
* @returns {Promise<void | IError>} Returns void if the code is successfully generated, or an error object if there was an issue.
|
|
94
95
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
95
96
|
* @description Obtaining a code to activate the user.
|
|
97
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/generateCode generateCode} documentation.
|
|
96
98
|
*/
|
|
97
99
|
generateCode(marker: string, userIdentifier: string, eventIdentifier: string): Promise<void | IError>;
|
|
98
100
|
/**
|
|
@@ -105,6 +107,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
105
107
|
* @returns {Promise<boolean | IError>} Returns true if the code is correct, or an error object if there was an issue.
|
|
106
108
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
107
109
|
* @description Checking the user activation code
|
|
110
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/checkCode checkCode} documentation.
|
|
108
111
|
*/
|
|
109
112
|
checkCode(marker: string, userIdentifier: string, eventIdentifier: string, code: string): Promise<boolean | IError>;
|
|
110
113
|
/**
|
|
@@ -116,6 +119,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
116
119
|
* @returns {Promise<boolean | IError>} Returns true if the user was successfully activated, or an error object if there was an issue.
|
|
117
120
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
118
121
|
* @description User activation.
|
|
122
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/activateUser activateUser} documentation.
|
|
119
123
|
*/
|
|
120
124
|
activateUser(marker: string, userIdentifier: string, code: string): Promise<boolean | IError>;
|
|
121
125
|
/**
|
|
@@ -149,6 +153,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
149
153
|
* @returns {Promise<IAuthEntity | IError>} Returns an auth entity object.
|
|
150
154
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
151
155
|
* @description User authorization.
|
|
156
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/auth auth} documentation.
|
|
152
157
|
*/
|
|
153
158
|
auth(marker: string, body: IAuthPostBody): Promise<IAuthEntity | IError>;
|
|
154
159
|
/**
|
|
@@ -159,6 +164,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
159
164
|
* @returns {Promise<IAuthEntity | IError>} Returns an auth entity object with the following values: accessToken, refreshToken, user, and other auth-related data.
|
|
160
165
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
161
166
|
* @description User token refresh.
|
|
167
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/refresh refresh} documentation.
|
|
162
168
|
*/
|
|
163
169
|
refresh(marker: string, token: string): Promise<IAuthEntity | IError>;
|
|
164
170
|
/**
|
|
@@ -170,6 +176,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
170
176
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
171
177
|
* @description This method requires user authorization.
|
|
172
178
|
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
179
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logout logout} documentation.
|
|
173
180
|
*/
|
|
174
181
|
logout(marker: string, token: string): Promise<boolean | IError>;
|
|
175
182
|
/**
|
|
@@ -180,6 +187,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
180
187
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
181
188
|
* @description This method requires user authorization.
|
|
182
189
|
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
190
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logoutAll logoutAll} documentation.
|
|
183
191
|
*/
|
|
184
192
|
logoutAll(marker: string): Promise<boolean | IError>;
|
|
185
193
|
/**
|
|
@@ -188,13 +196,14 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
188
196
|
* @param {string} marker - The text identifier of the authorization provider. Example: "email".
|
|
189
197
|
* @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
|
|
190
198
|
* @param {string} eventIdentifier - The text identifier of the event. Example: "reg".
|
|
191
|
-
* @param {
|
|
199
|
+
* @param {number} type - Operation type (1 - for changing password, 2 - for recovery). Example: 1.
|
|
192
200
|
* @param {string} code - Service code. Example: "123456".
|
|
193
201
|
* @param {string} newPassword - New password. Example: "newPassword123".
|
|
194
202
|
* @param {string} [repeatPassword] - Optional variable contains repeat new password for validation. Example: "newPassword123".
|
|
195
203
|
* @returns {Promise<boolean | IError>} Returns true if the password was successfully changed, or an error object if there was an issue.
|
|
196
204
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
197
205
|
* @description User password change (only for tariffs with account activation and the Activation feature enabled).
|
|
206
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/changePassword changePassword} documentation.
|
|
198
207
|
*/
|
|
199
208
|
changePassword(marker: string, userIdentifier: string, eventIdentifier: string, type: number, code: string, newPassword: string, repeatPassword?: string): Promise<boolean | IError>;
|
|
200
209
|
/**
|
|
@@ -206,6 +215,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
206
215
|
* @returns {Promise<IAuthProvidersEntity[] | IError>} Returns an array of auth provider objects.
|
|
207
216
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
208
217
|
* @description Getting all objects of authorization providers.
|
|
218
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviders getAuthProviders} documentation.
|
|
209
219
|
*/
|
|
210
220
|
getAuthProviders(langCode?: string, offset?: number, limit?: number): Promise<IAuthProvidersEntity[] | IError>;
|
|
211
221
|
/**
|
|
@@ -216,6 +226,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
216
226
|
* @returns {Promise<IAuthProvidersEntity | IError>} Returns an auth provider object.
|
|
217
227
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
218
228
|
* @description Getting a single authorization provider object by marker.
|
|
229
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviderByMarker getAuthProviderByMarker} documentation.
|
|
219
230
|
*/
|
|
220
231
|
getAuthProviderByMarker(marker: string, langCode?: string): Promise<IAuthProvidersEntity | IError>;
|
|
221
232
|
/**
|
|
@@ -225,6 +236,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
225
236
|
* @returns {Promise<IActiveSession[] | IError>} Returns an auth provider object.
|
|
226
237
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
227
238
|
* @description Getting a single authorization provider object by marker.
|
|
239
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getActiveSessionsByMarker getActiveSessionsByMarker} documentation.
|
|
228
240
|
*/
|
|
229
241
|
getActiveSessionsByMarker(marker: string): Promise<IActiveSession[] | IError>;
|
|
230
242
|
/**
|
|
@@ -244,6 +256,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
244
256
|
* @returns {Promise<ISignUpEntity | IError>} Returns a user object.
|
|
245
257
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
246
258
|
* @description User registration (authorization) via OAUTH.
|
|
259
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/oauth oauth} documentation.
|
|
247
260
|
*/
|
|
248
261
|
oauth(marker: string, body: IOauthData, langCode?: string): Promise<IAuthEntity | IError>;
|
|
249
262
|
}
|
|
@@ -87,6 +87,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
87
87
|
* @returns {Promise<ISignUpEntity | IError>} Returns a user object.
|
|
88
88
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
89
89
|
* @description User registration (❗️For a provider with user activation, the activation code is sent through the corresponding user notification method).
|
|
90
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/signUp signUp} documentation.
|
|
90
91
|
*/
|
|
91
92
|
async signUp(marker, body, langCode = this.state.lang) {
|
|
92
93
|
body['langCode'] = langCode;
|
|
@@ -104,6 +105,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
104
105
|
* @returns {Promise<void | IError>} Returns void if the code is successfully generated, or an error object if there was an issue.
|
|
105
106
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
106
107
|
* @description Obtaining a code to activate the user.
|
|
108
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/generateCode generateCode} documentation.
|
|
107
109
|
*/
|
|
108
110
|
async generateCode(marker, userIdentifier, eventIdentifier) {
|
|
109
111
|
const data = {
|
|
@@ -123,6 +125,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
123
125
|
* @returns {Promise<boolean | IError>} Returns true if the code is correct, or an error object if there was an issue.
|
|
124
126
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
125
127
|
* @description Checking the user activation code
|
|
128
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/checkCode checkCode} documentation.
|
|
126
129
|
*/
|
|
127
130
|
async checkCode(marker, userIdentifier, eventIdentifier, code) {
|
|
128
131
|
const data = {
|
|
@@ -142,6 +145,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
142
145
|
* @returns {Promise<boolean | IError>} Returns true if the user was successfully activated, or an error object if there was an issue.
|
|
143
146
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
144
147
|
* @description User activation.
|
|
148
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/activateUser activateUser} documentation.
|
|
145
149
|
*/
|
|
146
150
|
async activateUser(marker, userIdentifier, code) {
|
|
147
151
|
const data = {
|
|
@@ -182,6 +186,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
182
186
|
* @returns {Promise<IAuthEntity | IError>} Returns an auth entity object.
|
|
183
187
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
184
188
|
* @description User authorization.
|
|
189
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/auth auth} documentation.
|
|
185
190
|
*/
|
|
186
191
|
async auth(marker, body) {
|
|
187
192
|
const result = await this._fetchPost(`/marker/${marker}/users/auth`, body);
|
|
@@ -204,6 +209,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
204
209
|
* @returns {Promise<IAuthEntity | IError>} Returns an auth entity object with the following values: accessToken, refreshToken, user, and other auth-related data.
|
|
205
210
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
206
211
|
* @description User token refresh.
|
|
212
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/refresh refresh} documentation.
|
|
207
213
|
*/
|
|
208
214
|
async refresh(marker, token) {
|
|
209
215
|
const data = { refreshToken: token };
|
|
@@ -226,6 +232,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
226
232
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
227
233
|
* @description This method requires user authorization.
|
|
228
234
|
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
235
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logout logout} documentation.
|
|
229
236
|
*/
|
|
230
237
|
async logout(marker, token) {
|
|
231
238
|
const data = {
|
|
@@ -249,6 +256,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
249
256
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
250
257
|
* @description This method requires user authorization.
|
|
251
258
|
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
259
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logoutAll logoutAll} documentation.
|
|
252
260
|
*/
|
|
253
261
|
async logoutAll(marker) {
|
|
254
262
|
const result = await this._fetchPost(`/marker/${marker}/users/logout-all`);
|
|
@@ -267,13 +275,14 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
267
275
|
* @param {string} marker - The text identifier of the authorization provider. Example: "email".
|
|
268
276
|
* @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
|
|
269
277
|
* @param {string} eventIdentifier - The text identifier of the event. Example: "reg".
|
|
270
|
-
* @param {
|
|
278
|
+
* @param {number} type - Operation type (1 - for changing password, 2 - for recovery). Example: 1.
|
|
271
279
|
* @param {string} code - Service code. Example: "123456".
|
|
272
280
|
* @param {string} newPassword - New password. Example: "newPassword123".
|
|
273
281
|
* @param {string} [repeatPassword] - Optional variable contains repeat new password for validation. Example: "newPassword123".
|
|
274
282
|
* @returns {Promise<boolean | IError>} Returns true if the password was successfully changed, or an error object if there was an issue.
|
|
275
283
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
276
284
|
* @description User password change (only for tariffs with account activation and the Activation feature enabled).
|
|
285
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/changePassword changePassword} documentation.
|
|
277
286
|
*/
|
|
278
287
|
async changePassword(marker, userIdentifier, eventIdentifier, type, code, newPassword, repeatPassword) {
|
|
279
288
|
const data = {
|
|
@@ -296,6 +305,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
296
305
|
* @returns {Promise<IAuthProvidersEntity[] | IError>} Returns an array of auth provider objects.
|
|
297
306
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
298
307
|
* @description Getting all objects of authorization providers.
|
|
308
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviders getAuthProviders} documentation.
|
|
299
309
|
*/
|
|
300
310
|
async getAuthProviders(langCode = this.state.lang, offset = 0, limit = 30) {
|
|
301
311
|
const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
@@ -311,6 +321,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
311
321
|
* @returns {Promise<IAuthProvidersEntity | IError>} Returns an auth provider object.
|
|
312
322
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
313
323
|
* @description Getting a single authorization provider object by marker.
|
|
324
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviderByMarker getAuthProviderByMarker} documentation.
|
|
314
325
|
*/
|
|
315
326
|
async getAuthProviderByMarker(marker, langCode = this.state.lang) {
|
|
316
327
|
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
@@ -323,6 +334,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
323
334
|
* @returns {Promise<IActiveSession[] | IError>} Returns an auth provider object.
|
|
324
335
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
325
336
|
* @description Getting a single authorization provider object by marker.
|
|
337
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getActiveSessionsByMarker getActiveSessionsByMarker} documentation.
|
|
326
338
|
*/
|
|
327
339
|
async getActiveSessionsByMarker(marker) {
|
|
328
340
|
const result = await this._fetchGet(`/marker/${marker}/users/sessions`);
|
|
@@ -345,6 +357,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
345
357
|
* @returns {Promise<ISignUpEntity | IError>} Returns a user object.
|
|
346
358
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
347
359
|
* @description User registration (authorization) via OAUTH.
|
|
360
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/oauth oauth} documentation.
|
|
348
361
|
*/
|
|
349
362
|
async oauth(marker, body, langCode = this.state.lang) {
|
|
350
363
|
const result = await this._fetchPost(`/marker/${marker}/oauth`, this._normalizePostBody(body, langCode));
|
|
@@ -57,11 +57,28 @@ export default abstract class AsyncModules extends SyncModules {
|
|
|
57
57
|
*/
|
|
58
58
|
protected _fetchDelete<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* Wraps a fetch call whose only meaningful outcome is success or failure.
|
|
61
|
+
*
|
|
62
|
+
* Several endpoints (cancel/recover subscription, subscribe/unsubscribe to
|
|
63
|
+
* events) return no useful body — callers only care whether the request
|
|
64
|
+
* succeeded. This helper resolves to `true` on success and to the caught
|
|
65
|
+
* error (as IError) on failure, centralizing the repeated try/catch.
|
|
66
|
+
* @param {() => Promise<unknown>} request - Thunk performing the fetch call.
|
|
67
|
+
* @returns {Promise<boolean | IError>} `true` on success, IError on failure.
|
|
68
|
+
*/
|
|
69
|
+
protected _fetchBoolean(request: () => Promise<unknown>): Promise<boolean | IError>;
|
|
70
|
+
/**
|
|
71
|
+
* Refreshes the authentication token (single-flight).
|
|
61
72
|
* @returns {Promise<boolean>} A promise resolving to a boolean indicating success or failure.
|
|
62
|
-
* @description
|
|
73
|
+
* @description De-duplicates concurrent refreshes — the refresh token is single-use, so parallel requests must share one refresh call instead of each burning a rotated token.
|
|
63
74
|
*/
|
|
64
75
|
protected refreshToken(): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Performs the actual token refresh request (without de-duplication).
|
|
78
|
+
* @returns {Promise<boolean>} A promise resolving to a boolean indicating success or failure.
|
|
79
|
+
* @description Sends POST /users/refresh and, on success, stores the rotated access/refresh tokens and calls saveFunction.
|
|
80
|
+
*/
|
|
81
|
+
private _performRefresh;
|
|
65
82
|
/**
|
|
66
83
|
* Creates options for HTTP requests.
|
|
67
84
|
* @param {string} method - The HTTP method (GET, POST, PUT, DELETE, etc.).
|
|
@@ -282,11 +282,52 @@ class AsyncModules extends syncModules_1.default {
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
|
-
*
|
|
285
|
+
* Wraps a fetch call whose only meaningful outcome is success or failure.
|
|
286
|
+
*
|
|
287
|
+
* Several endpoints (cancel/recover subscription, subscribe/unsubscribe to
|
|
288
|
+
* events) return no useful body — callers only care whether the request
|
|
289
|
+
* succeeded. This helper resolves to `true` on success and to the caught
|
|
290
|
+
* error (as IError) on failure, centralizing the repeated try/catch.
|
|
291
|
+
* @param {() => Promise<unknown>} request - Thunk performing the fetch call.
|
|
292
|
+
* @returns {Promise<boolean | IError>} `true` on success, IError on failure.
|
|
293
|
+
*/
|
|
294
|
+
async _fetchBoolean(request) {
|
|
295
|
+
try {
|
|
296
|
+
await request();
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
catch (e) {
|
|
300
|
+
return e;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Refreshes the authentication token (single-flight).
|
|
286
305
|
* @returns {Promise<boolean>} A promise resolving to a boolean indicating success or failure.
|
|
287
|
-
* @description
|
|
306
|
+
* @description De-duplicates concurrent refreshes — the refresh token is single-use, so parallel requests must share one refresh call instead of each burning a rotated token.
|
|
288
307
|
*/
|
|
289
308
|
async refreshToken() {
|
|
309
|
+
// Reuse an in-flight refresh if one is already running (shared via state
|
|
310
|
+
// across all module instances). Prevents parallel requests from each firing
|
|
311
|
+
// their own refresh and invalidating the single-use refresh token.
|
|
312
|
+
if (this.state._refreshPromise) {
|
|
313
|
+
return this.state._refreshPromise;
|
|
314
|
+
}
|
|
315
|
+
const promise = this._performRefresh();
|
|
316
|
+
this.state._refreshPromise = promise;
|
|
317
|
+
try {
|
|
318
|
+
return await promise;
|
|
319
|
+
}
|
|
320
|
+
finally {
|
|
321
|
+
// Clear so the next genuine 401 (e.g. mid-session expiry) can refresh again.
|
|
322
|
+
this.state._refreshPromise = null;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Performs the actual token refresh request (without de-duplication).
|
|
327
|
+
* @returns {Promise<boolean>} A promise resolving to a boolean indicating success or failure.
|
|
328
|
+
* @description Sends POST /users/refresh and, on success, stores the rotated access/refresh tokens and calls saveFunction.
|
|
329
|
+
*/
|
|
330
|
+
async _performRefresh() {
|
|
290
331
|
const url = this.state.url +
|
|
291
332
|
`/api/content/users-auth-providers/marker/` +
|
|
292
333
|
this.state.providerMarker +
|
|
@@ -396,7 +437,32 @@ class AsyncModules extends syncModules_1.default {
|
|
|
396
437
|
* @description Define an asynchronous method 'browserResponse' that takes a path and options as parameters
|
|
397
438
|
*/
|
|
398
439
|
async browserResponse(path, options) {
|
|
440
|
+
// Set when a proactive refresh ran and failed (dead/expired refresh token):
|
|
441
|
+
// used below to skip the reactive refresh so we don't fire a second,
|
|
442
|
+
// equally-doomed refresh on the 401 that the request is about to return.
|
|
443
|
+
let proactiveRefreshFailed = false;
|
|
399
444
|
try {
|
|
445
|
+
// Proactive (eager) refresh: a session restored from storage has a refresh
|
|
446
|
+
// token but no access token yet. Sending the first authenticated request
|
|
447
|
+
// without an access token GUARANTEES a 401 (then a reactive refresh + retry)
|
|
448
|
+
// — a spurious 401 logged on every page load even for a perfectly valid
|
|
449
|
+
// session. Obtaining the access token up-front turns that into a clean 200.
|
|
450
|
+
// Fires at most once per session (skipped once accessToken is set), and is
|
|
451
|
+
// off for custom-auth callers who manage tokens themselves.
|
|
452
|
+
if (!this.state.accessToken &&
|
|
453
|
+
this.state.refreshToken &&
|
|
454
|
+
!this.state.customAuth) {
|
|
455
|
+
const refreshed = await this.refreshToken();
|
|
456
|
+
if (refreshed) {
|
|
457
|
+
// Authenticated now — attach the bearer and drop the guest scoping
|
|
458
|
+
// that makeOptions added while no access token was present.
|
|
459
|
+
options.headers['Authorization'] = 'Bearer ' + this.state.accessToken;
|
|
460
|
+
delete options.headers['x-guest-id'];
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
proactiveRefreshFailed = true;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
400
466
|
// Perform a fetch request using the full URL obtained from '_getFullPath' and the provided options
|
|
401
467
|
const response = await fetch(this._getFullPath(path), options);
|
|
402
468
|
// Check if the response status is OK (status code 200-299)
|
|
@@ -415,8 +481,12 @@ class AsyncModules extends syncModules_1.default {
|
|
|
415
481
|
}
|
|
416
482
|
else {
|
|
417
483
|
// Handle non-OK responses
|
|
418
|
-
//
|
|
419
|
-
|
|
484
|
+
// Reactive refresh for mid-session expiry: access token was present but
|
|
485
|
+
// the server rejected it. Skipped when a proactive refresh already ran
|
|
486
|
+
// and failed (the refresh token is dead — retrying would 400 again).
|
|
487
|
+
if (response.status === 401 &&
|
|
488
|
+
!this.state.customAuth &&
|
|
489
|
+
!proactiveRefreshFailed) {
|
|
420
490
|
// Attempt to refresh the access token
|
|
421
491
|
const refresh = await this.refreshToken();
|
|
422
492
|
if (refresh) {
|
package/dist/base/stateModule.js
CHANGED
|
@@ -46,6 +46,10 @@ class StateModule {
|
|
|
46
46
|
*/
|
|
47
47
|
constructor(url, config) {
|
|
48
48
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
49
|
+
// In-flight token refresh, shared across all module instances (they share this
|
|
50
|
+
// state object). De-duplicates concurrent refreshes so the single-use refresh
|
|
51
|
+
// token is not burned by parallel requests. Null when no refresh is running.
|
|
52
|
+
this._refreshPromise = null;
|
|
49
53
|
this.url = url;
|
|
50
54
|
this.lang = (_a = config.langCode) !== null && _a !== void 0 ? _a : 'en_US';
|
|
51
55
|
this.token = config.token;
|