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.
Files changed (222) hide show
  1. package/README.md +2 -0
  2. package/changelog.md +56 -1
  3. package/dist/admins/adminsApi.d.ts +15 -1
  4. package/dist/admins/adminsApi.js +29 -0
  5. package/dist/admins/adminsInterfaces.d.ts +37 -1
  6. package/dist/base/lazySchema.d.ts +15 -0
  7. package/dist/base/lazySchema.js +20 -0
  8. package/dist/discounts/discountsApi.d.ts +14 -1
  9. package/dist/discounts/discountsApi.js +21 -0
  10. package/dist/discounts/discountsInterfaces.d.ts +27 -1
  11. package/dist/filters/filtersInterfaces.d.ts +2 -2
  12. package/dist/filters/filtersSchemas.d.ts +1 -1
  13. package/dist/filters/filtersSchemas.js +4 -1
  14. package/dist/forms-data/formsDataApi.d.ts +14 -1
  15. package/dist/forms-data/formsDataApi.js +21 -0
  16. package/dist/forms-data/formsDataInterfaces.d.ts +74 -1
  17. package/dist/index.d.ts +4 -0
  18. package/dist/index.js +3 -0
  19. package/dist/orders/ordersApi.d.ts +15 -1
  20. package/dist/orders/ordersApi.js +22 -0
  21. package/dist/orders/ordersInterfaces.d.ts +27 -1
  22. package/dist/pages/pagesApi.d.ts +14 -1
  23. package/dist/pages/pagesApi.js +21 -0
  24. package/dist/pages/pagesInterfaces.d.ts +38 -1
  25. package/dist/payments/paymentsInterfaces.d.ts +2 -2
  26. package/dist/products/productsInterfaces.d.ts +1 -1
  27. package/dist/search/searchApi.d.ts +35 -0
  28. package/dist/search/searchApi.js +86 -0
  29. package/dist/search/searchInterfaces.d.ts +94 -0
  30. package/dist/search/searchInterfaces.js +2 -0
  31. package/dist/search/searchSchemas.d.ts +73 -0
  32. package/dist/search/searchSchemas.js +44 -0
  33. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -2
  34. package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -2
  35. package/dist/templates-preview/templatesPreviewSchemas.js +0 -1
  36. package/dist/types.d.ts +35 -0
  37. package/dist/types.js +2 -0
  38. package/dist/users/usersApi.d.ts +15 -1
  39. package/dist/users/usersApi.js +22 -0
  40. package/dist/users/usersInterfaces.d.ts +39 -1
  41. package/dist/web-socket/lazySocket.d.ts +18 -0
  42. package/dist/web-socket/lazySocket.js +70 -0
  43. package/esm/admins/adminsApi.d.ts +66 -0
  44. package/esm/admins/adminsApi.js +90 -0
  45. package/esm/admins/adminsInterfaces.d.ts +137 -0
  46. package/esm/admins/adminsInterfaces.js +1 -0
  47. package/esm/admins/adminsSchemas.d.ts +48 -0
  48. package/esm/admins/adminsSchemas.js +31 -0
  49. package/esm/attribute-sets/attributeSetsApi.d.ts +67 -0
  50. package/esm/attribute-sets/attributeSetsApi.js +97 -0
  51. package/esm/attribute-sets/attributeSetsInterfaces.d.ts +285 -0
  52. package/esm/attribute-sets/attributeSetsInterfaces.js +1 -0
  53. package/esm/attribute-sets/attributeSetsSchemas.d.ts +84 -0
  54. package/esm/attribute-sets/attributeSetsSchemas.js +66 -0
  55. package/esm/auth-provider/authProviderApi.d.ts +262 -0
  56. package/esm/auth-provider/authProviderApi.js +362 -0
  57. package/esm/auth-provider/authProviderSchemas.d.ts +124 -0
  58. package/esm/auth-provider/authProviderSchemas.js +92 -0
  59. package/esm/auth-provider/authProvidersInterfaces.d.ts +430 -0
  60. package/esm/auth-provider/authProvidersInterfaces.js +1 -0
  61. package/esm/base/asyncModules.d.ts +123 -0
  62. package/esm/base/asyncModules.js +382 -0
  63. package/esm/base/lazySchema.d.ts +15 -0
  64. package/esm/base/lazySchema.js +17 -0
  65. package/esm/base/stateModule.d.ts +35 -0
  66. package/esm/base/stateModule.js +51 -0
  67. package/esm/base/syncModules.d.ts +245 -0
  68. package/esm/base/syncModules.js +555 -0
  69. package/esm/base/timeIntervals.d.ts +95 -0
  70. package/esm/base/timeIntervals.js +317 -0
  71. package/esm/base/utils.d.ts +354 -0
  72. package/esm/base/utils.js +1 -0
  73. package/esm/base/validation.d.ts +98 -0
  74. package/esm/base/validation.js +118 -0
  75. package/esm/blocks/blocksApi.d.ts +252 -0
  76. package/esm/blocks/blocksApi.js +394 -0
  77. package/esm/blocks/blocksInterfaces.d.ts +361 -0
  78. package/esm/blocks/blocksInterfaces.js +1 -0
  79. package/esm/blocks/blocksSchemas.d.ts +213 -0
  80. package/esm/blocks/blocksSchemas.js +40 -0
  81. package/esm/discounts/discountsApi.d.ts +94 -0
  82. package/esm/discounts/discountsApi.js +136 -0
  83. package/esm/discounts/discountsInterfaces.d.ts +293 -0
  84. package/esm/discounts/discountsInterfaces.js +1 -0
  85. package/esm/events/eventsApi.d.ts +108 -0
  86. package/esm/events/eventsApi.js +141 -0
  87. package/esm/events/eventsInterfaces.d.ts +176 -0
  88. package/esm/events/eventsInterfaces.js +1 -0
  89. package/esm/file-uploading/fileUploadingApi.d.ts +91 -0
  90. package/esm/file-uploading/fileUploadingApi.js +127 -0
  91. package/esm/file-uploading/fileUploadingInterfaces.d.ts +116 -0
  92. package/esm/file-uploading/fileUploadingInterfaces.js +1 -0
  93. package/esm/file-uploading/fileUploadingSchemas.d.ts +24 -0
  94. package/esm/file-uploading/fileUploadingSchemas.js +19 -0
  95. package/esm/filters/filtersApi.d.ts +32 -0
  96. package/esm/filters/filtersApi.js +36 -0
  97. package/esm/filters/filtersInterfaces.d.ts +56 -0
  98. package/esm/filters/filtersInterfaces.js +1 -0
  99. package/esm/filters/filtersSchemas.d.ts +32 -0
  100. package/esm/filters/filtersSchemas.js +29 -0
  101. package/esm/forms/formsApi.d.ts +44 -0
  102. package/esm/forms/formsApi.js +54 -0
  103. package/esm/forms/formsInterfaces.d.ts +237 -0
  104. package/esm/forms/formsInterfaces.js +1 -0
  105. package/esm/forms/formsSchemas.d.ts +56 -0
  106. package/esm/forms/formsSchemas.js +32 -0
  107. package/esm/forms-data/formsDataApi.d.ts +124 -0
  108. package/esm/forms-data/formsDataApi.js +210 -0
  109. package/esm/forms-data/formsDataInterfaces.d.ts +670 -0
  110. package/esm/forms-data/formsDataInterfaces.js +1 -0
  111. package/esm/forms-data/formsDataSchemas.d.ts +107 -0
  112. package/esm/forms-data/formsDataSchemas.js +83 -0
  113. package/esm/general-types/generalTypesApi.d.ts +29 -0
  114. package/esm/general-types/generalTypesApi.js +34 -0
  115. package/esm/general-types/generalTypesInterfaces.d.ts +29 -0
  116. package/esm/general-types/generalTypesInterfaces.js +1 -0
  117. package/esm/general-types/generalTypesSchemas.d.ts +68 -0
  118. package/esm/general-types/generalTypesSchemas.js +42 -0
  119. package/esm/index.d.ts +143 -0
  120. package/esm/index.js +124 -0
  121. package/esm/integration-collections/integrationCollectionsApi.d.ts +172 -0
  122. package/esm/integration-collections/integrationCollectionsApi.js +224 -0
  123. package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +317 -0
  124. package/esm/integration-collections/integrationCollectionsInterfaces.js +1 -0
  125. package/esm/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
  126. package/esm/integration-collections/integrationCollectionsSchemas.js +60 -0
  127. package/esm/locales/localesApi.d.ts +28 -0
  128. package/esm/locales/localesApi.js +33 -0
  129. package/esm/locales/localesInterfaces.d.ts +40 -0
  130. package/esm/locales/localesInterfaces.js +1 -0
  131. package/esm/locales/localesSchemas.d.ts +32 -0
  132. package/esm/locales/localesSchemas.js +23 -0
  133. package/esm/menus/menusApi.d.ts +30 -0
  134. package/esm/menus/menusApi.js +35 -0
  135. package/esm/menus/menusInterfaces.d.ts +87 -0
  136. package/esm/menus/menusInterfaces.js +2 -0
  137. package/esm/menus/menusSchemas.d.ts +16 -0
  138. package/esm/menus/menusSchemas.js +25 -0
  139. package/esm/orders/ordersApi.d.ts +213 -0
  140. package/esm/orders/ordersApi.js +288 -0
  141. package/esm/orders/ordersInterfaces.d.ts +763 -0
  142. package/esm/orders/ordersInterfaces.js +1 -0
  143. package/esm/orders/ordersSchemas.d.ts +312 -0
  144. package/esm/orders/ordersSchemas.js +171 -0
  145. package/esm/package.json +4 -0
  146. package/esm/pages/pagesApi.d.ts +173 -0
  147. package/esm/pages/pagesApi.js +414 -0
  148. package/esm/pages/pagesInterfaces.d.ts +344 -0
  149. package/esm/pages/pagesInterfaces.js +1 -0
  150. package/esm/pages/pagesSchemas.d.ts +121 -0
  151. package/esm/pages/pagesSchemas.js +60 -0
  152. package/esm/payments/paymentsApi.d.ts +88 -0
  153. package/esm/payments/paymentsApi.js +122 -0
  154. package/esm/payments/paymentsInterfaces.d.ts +189 -0
  155. package/esm/payments/paymentsInterfaces.js +1 -0
  156. package/esm/payments/paymentsSchemas.d.ts +94 -0
  157. package/esm/payments/paymentsSchemas.js +53 -0
  158. package/esm/product-statuses/productStatusesApi.d.ts +50 -0
  159. package/esm/product-statuses/productStatusesApi.js +68 -0
  160. package/esm/product-statuses/productStatusesInterfaces.d.ts +62 -0
  161. package/esm/product-statuses/productStatusesInterfaces.js +1 -0
  162. package/esm/product-statuses/productStatusesSchemas.d.ts +34 -0
  163. package/esm/product-statuses/productStatusesSchemas.js +27 -0
  164. package/esm/products/productsApi.d.ts +366 -0
  165. package/esm/products/productsApi.js +468 -0
  166. package/esm/products/productsInterfaces.d.ts +723 -0
  167. package/esm/products/productsInterfaces.js +1 -0
  168. package/esm/products/productsSchemas.d.ts +234 -0
  169. package/esm/products/productsSchemas.js +121 -0
  170. package/esm/search/searchApi.d.ts +35 -0
  171. package/esm/search/searchApi.js +47 -0
  172. package/esm/search/searchInterfaces.d.ts +94 -0
  173. package/esm/search/searchInterfaces.js +1 -0
  174. package/esm/search/searchSchemas.d.ts +73 -0
  175. package/esm/search/searchSchemas.js +41 -0
  176. package/esm/sitemap/sitemapApi.d.ts +37 -0
  177. package/esm/sitemap/sitemapApi.js +41 -0
  178. package/esm/sitemap/sitemapInterfaces.d.ts +51 -0
  179. package/esm/sitemap/sitemapInterfaces.js +1 -0
  180. package/esm/subscriptions/subscriptionsApi.d.ts +74 -0
  181. package/esm/subscriptions/subscriptionsApi.js +90 -0
  182. package/esm/subscriptions/subscriptionsInterfaces.d.ts +111 -0
  183. package/esm/subscriptions/subscriptionsInterfaces.js +1 -0
  184. package/esm/subscriptions/subscriptionsSchemas.d.ts +46 -0
  185. package/esm/subscriptions/subscriptionsSchemas.js +38 -0
  186. package/esm/system/systemApi.d.ts +46 -0
  187. package/esm/system/systemApi.js +53 -0
  188. package/esm/system/systemInterfaces.d.ts +29 -0
  189. package/esm/system/systemInterfaces.js +1 -0
  190. package/esm/templates/templatesApi.d.ts +53 -0
  191. package/esm/templates/templatesApi.js +78 -0
  192. package/esm/templates/templatesInterfaces.d.ts +68 -0
  193. package/esm/templates/templatesInterfaces.js +1 -0
  194. package/esm/templates/templatesSchemas.d.ts +48 -0
  195. package/esm/templates/templatesSchemas.js +28 -0
  196. package/esm/templates-preview/templatesPreviewApi.d.ts +40 -0
  197. package/esm/templates-preview/templatesPreviewApi.js +50 -0
  198. package/esm/templates-preview/templatesPreviewInterfaces.d.ts +129 -0
  199. package/esm/templates-preview/templatesPreviewInterfaces.js +1 -0
  200. package/esm/templates-preview/templatesPreviewSchemas.d.ts +79 -0
  201. package/esm/templates-preview/templatesPreviewSchemas.js +43 -0
  202. package/esm/types.d.ts +35 -0
  203. package/esm/types.js +1 -0
  204. package/esm/user-activity/userActivityApi.d.ts +31 -0
  205. package/esm/user-activity/userActivityApi.js +37 -0
  206. package/esm/user-activity/userActivityInterfaces.d.ts +42 -0
  207. package/esm/user-activity/userActivityInterfaces.js +1 -0
  208. package/esm/users/usersApi.d.ts +249 -0
  209. package/esm/users/usersApi.js +312 -0
  210. package/esm/users/usersInterfaces.d.ts +419 -0
  211. package/esm/users/usersInterfaces.js +1 -0
  212. package/esm/users/usersSchemas.d.ts +72 -0
  213. package/esm/users/usersSchemas.js +55 -0
  214. package/esm/web-socket/lazySocket.d.ts +18 -0
  215. package/esm/web-socket/lazySocket.js +67 -0
  216. package/esm/web-socket/wsApi.d.ts +27 -0
  217. package/esm/web-socket/wsApi.js +43 -0
  218. package/esm/web-socket/wsInterfaces.d.ts +16 -0
  219. package/esm/web-socket/wsInterfaces.js +1 -0
  220. package/package.json +47 -2
  221. package/types.d.ts +1 -0
  222. package/types.js +1 -0
@@ -0,0 +1,262 @@
1
+ import AsyncModules from '../base/asyncModules.js';
2
+ import type StateModule from '../base/stateModule.js';
3
+ import type { IError } from '../base/utils.js';
4
+ import type { IActiveSession, IAuthEntity, IAuthPostBody, IAuthProvider, IAuthProvidersEntity, IOauthData, ISignUpData, ISignUpEntity } from './authProvidersInterfaces.js';
5
+ /**
6
+ * Controllers for working with auth services.
7
+ * @handle /api/content/users-auth-providers
8
+ * @class AuthProviderApi
9
+ * @augments AsyncModules
10
+ * @implements {IAuthProvider}
11
+ * @description This class provides methods for user registration, authentication, and management of authentication providers.
12
+ */
13
+ export default class AuthProviderApi extends AsyncModules implements IAuthProvider {
14
+ protected state: StateModule;
15
+ protected _url: string;
16
+ /**
17
+ * constructor
18
+ */
19
+ constructor(state: StateModule);
20
+ /**
21
+ * User registration.
22
+ * @handleName signUp
23
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
24
+ * @param {ISignUpData} body - Request body.
25
+ * @example
26
+ {
27
+ "formIdentifier": "reg",
28
+ "authData": [
29
+ {
30
+ "marker": "login",
31
+ "value": "example@oneentry.cloud"
32
+ },
33
+ {
34
+ "marker": "password",
35
+ "value": "12345"
36
+ }
37
+ ],
38
+ "formData": [
39
+ {
40
+ "marker": "last_name",
41
+ "type": "string",
42
+ "value": "Name"
43
+ }
44
+ ],
45
+ "notificationData": {
46
+ "email": "example@oneentry.cloud",
47
+ "phonePush": ["+99999999999"],
48
+ "phoneSMS": "+99999999999"
49
+ }
50
+ }
51
+ * @param {string} body.formIdentifier - The identifier for the registration form. Example: "reg".
52
+ * @param {{ marker: string; value: string }[]} body.authData - An array of authentication data objects, each containing a marker and its corresponding value.
53
+ * @example
54
+ [
55
+ {
56
+ "marker": "login",
57
+ "value": "example@oneentry.cloud"
58
+ },
59
+ {
60
+ "marker": "password",
61
+ "value": "12345"
62
+ }
63
+ ]
64
+ * @param {IAuthFormData} body.formData - The form data for the registration, which can be a single object or an array of objects.
65
+ * @example
66
+ {
67
+ "marker": "last_name",
68
+ "type": "string",
69
+ "value": "Name"
70
+ }
71
+ * @param {object} body.notificationData - An object containing notification data, including email, phonePush, and phoneSMS.
72
+ * @example
73
+ {
74
+ "email": "example@oneentry.cloud",
75
+ "phonePush": ["+99999999999"],
76
+ "phoneSMS": "+99999999999"
77
+ }
78
+ * @param {string} body.notificationData.email - The email address to which the notification will be sent.
79
+ * @param {Array<string>} [body.notificationData.phonePush] - An array of phone numbers for push notifications. Optional.
80
+ * @param {string} [body.notificationData.phoneSMS] - The phone number for SMS notifications. Optional.
81
+ * @param {string} [langCode] - Language code. Default: "en_US".
82
+ * @returns {Promise<ISignUpEntity | IError>} Returns a user object.
83
+ * @throws {IError} When isShell=false and an error occurs during the fetch
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.
86
+ */
87
+ signUp(marker: string, body: ISignUpData, langCode?: string): Promise<ISignUpEntity | IError>;
88
+ /**
89
+ * Getting a user activation code. The code is returned via the appropriate user notification method.
90
+ * @handleName generateCode
91
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
92
+ * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
93
+ * @param {string} eventIdentifier - Text identifier of the event object for which the code is generated. Example: "user_registration".
94
+ * @returns {Promise<void | IError>} Returns void if the code is successfully generated, or an error object if there was an issue.
95
+ * @throws {IError} When isShell=false and an error occurs during the fetch
96
+ * @description Obtaining a code to activate the user.
97
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/generateCode generateCode} documentation.
98
+ */
99
+ generateCode(marker: string, userIdentifier: string, eventIdentifier: string): Promise<void | IError>;
100
+ /**
101
+ * User activation code verification. Returns true (if the code is correct) or false (if it is incorrect).
102
+ * @handleName checkCode
103
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
104
+ * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
105
+ * @param {string} eventIdentifier - Text identifier of the event object for which the code is generated. Example: "user_registration".
106
+ * @param {string} code - Service code. Example: "123456".
107
+ * @returns {Promise<boolean | IError>} Returns true if the code is correct, or an error object if there was an issue.
108
+ * @throws {IError} When isShell=false and an error occurs during the fetch
109
+ * @description Checking the user activation code
110
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/checkCode checkCode} documentation.
111
+ */
112
+ checkCode(marker: string, userIdentifier: string, eventIdentifier: string, code: string): Promise<boolean | IError>;
113
+ /**
114
+ * User activate.
115
+ * @handleName activateUser
116
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
117
+ * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
118
+ * @param {string} code - Service code. Example: "123456".
119
+ * @returns {Promise<boolean | IError>} Returns true if the user was successfully activated, or an error object if there was an issue.
120
+ * @throws {IError} When isShell=false and an error occurs during the fetch
121
+ * @description User activation.
122
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/activateUser activateUser} documentation.
123
+ */
124
+ activateUser(marker: string, userIdentifier: string, code: string): Promise<boolean | IError>;
125
+ /**
126
+ * User authorization.
127
+ * @handleName auth
128
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
129
+ * @param {IAuthPostBody} body - Objects contains auth information.
130
+ * @example
131
+ {
132
+ "authData": [
133
+ {
134
+ "marker": "login",
135
+ "value": "example@oneentry.cloud"
136
+ },
137
+ {
138
+ "marker": "password",
139
+ "value": "12345"
140
+ }
141
+ ]
142
+ }
143
+ * @param {{ marker: string; value: string | number }[]} body.authData - An array of authentication data objects, each containing a marker and its corresponding value.
144
+ * @example
145
+ [
146
+ {
147
+ "marker": "login",
148
+ "value": "user@example.com"
149
+ }
150
+ ]
151
+ * @param {string} body.authData[index].marker - The marker for the authentication data. Example: "login".
152
+ * @param {string} body.authData[index].value - The value for the authentication data. Example: "user@example.com".
153
+ * @returns {Promise<IAuthEntity | IError>} Returns an auth entity object.
154
+ * @throws {IError} When isShell=false and an error occurs during the fetch
155
+ * @description User authorization.
156
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/auth auth} documentation.
157
+ */
158
+ auth(marker: string, body: IAuthPostBody): Promise<IAuthEntity | IError>;
159
+ /**
160
+ * Refresh token.
161
+ * @handleName refresh
162
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
163
+ * @param {string} token - Refresh token. Example: "abcdef123456".
164
+ * @returns {Promise<IAuthEntity | IError>} Returns an auth entity object with the following values: accessToken, refreshToken, user, and other auth-related data.
165
+ * @throws {IError} When isShell=false and an error occurs during the fetch
166
+ * @description User token refresh.
167
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/refresh refresh} documentation.
168
+ */
169
+ refresh(marker: string, token: string): Promise<IAuthEntity | IError>;
170
+ /**
171
+ * User account logout.
172
+ * @handleName logout
173
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
174
+ * @param {string} token - Refresh token. Example: "abcdef123456".
175
+ * @returns {Promise<boolean | IError>} Returns true if the logout was successful, or an error object if there was an issue.
176
+ * @throws {IError} When isShell=false and an error occurs during the fetch
177
+ * @description This method requires user authorization.
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.
180
+ */
181
+ logout(marker: string, token: string): Promise<boolean | IError>;
182
+ /**
183
+ * Logout of user account on all devices.
184
+ * @handleName logoutAll
185
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
186
+ * @returns {Promise<boolean | IError>} Returns true if the logout was successful, or an error object if there was an issue.
187
+ * @throws {IError} When isShell=false and an error occurs during the fetch
188
+ * @description This method requires user authorization.
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.
191
+ */
192
+ logoutAll(marker: string): Promise<boolean | IError>;
193
+ /**
194
+ * Change password.
195
+ * @handleName changePassword
196
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
197
+ * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
198
+ * @param {string} eventIdentifier - The text identifier of the event. Example: "reg".
199
+ * @param {number} type - Operation type (1 - for changing password, 2 - for recovery). Example: 1.
200
+ * @param {string} code - Service code. Example: "123456".
201
+ * @param {string} newPassword - New password. Example: "newPassword123".
202
+ * @param {string} [repeatPassword] - Optional variable contains repeat new password for validation. Example: "newPassword123".
203
+ * @returns {Promise<boolean | IError>} Returns true if the password was successfully changed, or an error object if there was an issue.
204
+ * @throws {IError} When isShell=false and an error occurs during the fetch
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.
207
+ */
208
+ changePassword(marker: string, userIdentifier: string, eventIdentifier: string, type: number, code: string, newPassword: string, repeatPassword?: string): Promise<boolean | IError>;
209
+ /**
210
+ * Get all auth providers objects.
211
+ * @handleName getAuthProviders
212
+ * @param {string} [langCode] - Language code. Default: "en_US".
213
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
214
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
215
+ * @returns {Promise<IAuthProvidersEntity[] | IError>} Returns an array of auth provider objects.
216
+ * @throws {IError} When isShell=false and an error occurs during the fetch
217
+ * @description Getting all objects of authorization providers.
218
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviders getAuthProviders} documentation.
219
+ */
220
+ getAuthProviders(langCode?: string, offset?: number, limit?: number): Promise<IAuthProvidersEntity[] | IError>;
221
+ /**
222
+ * Get one auth provider object by marker.
223
+ * @handleName getAuthProviderByMarker
224
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
225
+ * @param {string} [langCode] - Language code. Default: "en_US".
226
+ * @returns {Promise<IAuthProvidersEntity | IError>} Returns an auth provider object.
227
+ * @throws {IError} When isShell=false and an error occurs during the fetch
228
+ * @description Getting a single authorization provider object by marker.
229
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviderByMarker getAuthProviderByMarker} documentation.
230
+ */
231
+ getAuthProviderByMarker(marker: string, langCode?: string): Promise<IAuthProvidersEntity | IError>;
232
+ /**
233
+ * Getting active user sessions data.
234
+ * @handleName getActiveSessionsByMarker
235
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
236
+ * @returns {Promise<IActiveSession[] | IError>} Returns an auth provider object.
237
+ * @throws {IError} When isShell=false and an error occurs during the fetch
238
+ * @description Getting a single authorization provider object by marker.
239
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getActiveSessionsByMarker getActiveSessionsByMarker} documentation.
240
+ */
241
+ getActiveSessionsByMarker(marker: string): Promise<IActiveSession[] | IError>;
242
+ /**
243
+ * User registration (authorization) via OAUTH.
244
+ * @handleName oauth
245
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
246
+ * @param {IOauthData} body - Object contains OAuth information for registration.
247
+ * @example
248
+ {
249
+ "client_id": "34346983-luuct343473qdkqidjopdfp3eb3k4thp.apps.googleusercontent.com",
250
+ "client_secret": "43434343434",
251
+ "code": "4/0AVMBsJgwewewewewewei4D7T6E_fbswxnL3g",
252
+ "grant_type": "authorization_code",
253
+ "redirect_uri": "http://localhost:3000"
254
+ }
255
+ * @param {string} [langCode] - Language code. Default: "en_US".
256
+ * @returns {Promise<ISignUpEntity | IError>} Returns a user object.
257
+ * @throws {IError} When isShell=false and an error occurs during the fetch
258
+ * @description User registration (authorization) via OAUTH.
259
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/oauth oauth} documentation.
260
+ */
261
+ oauth(marker: string, body: IOauthData, langCode?: string): Promise<IAuthEntity | IError>;
262
+ }
@@ -0,0 +1,362 @@
1
+ /* eslint-disable jsdoc/no-undefined-types */
2
+ import AsyncModules from '../base/asyncModules.js';
3
+ import createSchemaLoader from '../base/lazySchema.js';
4
+ const schema = createSchemaLoader(() => import('./authProviderSchemas.js'));
5
+ /**
6
+ * Controllers for working with auth services.
7
+ * @handle /api/content/users-auth-providers
8
+ * @class AuthProviderApi
9
+ * @augments AsyncModules
10
+ * @implements {IAuthProvider}
11
+ * @description This class provides methods for user registration, authentication, and management of authentication providers.
12
+ */
13
+ export default class AuthProviderApi extends AsyncModules {
14
+ /**
15
+ * constructor
16
+ */
17
+ constructor(state) {
18
+ super(state);
19
+ this._url = state.url + '/api/content/users-auth-providers';
20
+ }
21
+ /**
22
+ * User registration.
23
+ * @handleName signUp
24
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
25
+ * @param {ISignUpData} body - Request body.
26
+ * @example
27
+ {
28
+ "formIdentifier": "reg",
29
+ "authData": [
30
+ {
31
+ "marker": "login",
32
+ "value": "example@oneentry.cloud"
33
+ },
34
+ {
35
+ "marker": "password",
36
+ "value": "12345"
37
+ }
38
+ ],
39
+ "formData": [
40
+ {
41
+ "marker": "last_name",
42
+ "type": "string",
43
+ "value": "Name"
44
+ }
45
+ ],
46
+ "notificationData": {
47
+ "email": "example@oneentry.cloud",
48
+ "phonePush": ["+99999999999"],
49
+ "phoneSMS": "+99999999999"
50
+ }
51
+ }
52
+ * @param {string} body.formIdentifier - The identifier for the registration form. Example: "reg".
53
+ * @param {{ marker: string; value: string }[]} body.authData - An array of authentication data objects, each containing a marker and its corresponding value.
54
+ * @example
55
+ [
56
+ {
57
+ "marker": "login",
58
+ "value": "example@oneentry.cloud"
59
+ },
60
+ {
61
+ "marker": "password",
62
+ "value": "12345"
63
+ }
64
+ ]
65
+ * @param {IAuthFormData} body.formData - The form data for the registration, which can be a single object or an array of objects.
66
+ * @example
67
+ {
68
+ "marker": "last_name",
69
+ "type": "string",
70
+ "value": "Name"
71
+ }
72
+ * @param {object} body.notificationData - An object containing notification data, including email, phonePush, and phoneSMS.
73
+ * @example
74
+ {
75
+ "email": "example@oneentry.cloud",
76
+ "phonePush": ["+99999999999"],
77
+ "phoneSMS": "+99999999999"
78
+ }
79
+ * @param {string} body.notificationData.email - The email address to which the notification will be sent.
80
+ * @param {Array<string>} [body.notificationData.phonePush] - An array of phone numbers for push notifications. Optional.
81
+ * @param {string} [body.notificationData.phoneSMS] - The phone number for SMS notifications. Optional.
82
+ * @param {string} [langCode] - Language code. Default: "en_US".
83
+ * @returns {Promise<ISignUpEntity | IError>} Returns a user object.
84
+ * @throws {IError} When isShell=false and an error occurs during the fetch
85
+ * @description User registration (❗️For a provider with user activation, the activation code is sent through the corresponding user notification method).
86
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/signUp signUp} documentation.
87
+ */
88
+ async signUp(marker, body, langCode = this.state.lang) {
89
+ body['langCode'] = langCode;
90
+ const result = await this._fetchPost(`/marker/${marker}/users/sign-up`, this._normalizePostBody(body, langCode));
91
+ // Validate response if validation is enabled
92
+ const validated = await this._validateResponse(result, schema('SignUpResponseSchema'));
93
+ return this._normalizeData(validated);
94
+ }
95
+ /**
96
+ * Getting a user activation code. The code is returned via the appropriate user notification method.
97
+ * @handleName generateCode
98
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
99
+ * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
100
+ * @param {string} eventIdentifier - Text identifier of the event object for which the code is generated. Example: "user_registration".
101
+ * @returns {Promise<void | IError>} Returns void if the code is successfully generated, or an error object if there was an issue.
102
+ * @throws {IError} When isShell=false and an error occurs during the fetch
103
+ * @description Obtaining a code to activate the user.
104
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/generateCode generateCode} documentation.
105
+ */
106
+ async generateCode(marker, userIdentifier, eventIdentifier) {
107
+ const data = {
108
+ userIdentifier,
109
+ eventIdentifier,
110
+ };
111
+ const result = await this._fetchPost(`/marker/${marker}/users/generate-code`, data);
112
+ return result;
113
+ }
114
+ /**
115
+ * User activation code verification. Returns true (if the code is correct) or false (if it is incorrect).
116
+ * @handleName checkCode
117
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
118
+ * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
119
+ * @param {string} eventIdentifier - Text identifier of the event object for which the code is generated. Example: "user_registration".
120
+ * @param {string} code - Service code. Example: "123456".
121
+ * @returns {Promise<boolean | IError>} Returns true if the code is correct, or an error object if there was an issue.
122
+ * @throws {IError} When isShell=false and an error occurs during the fetch
123
+ * @description Checking the user activation code
124
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/checkCode checkCode} documentation.
125
+ */
126
+ async checkCode(marker, userIdentifier, eventIdentifier, code) {
127
+ const data = {
128
+ userIdentifier,
129
+ eventIdentifier,
130
+ code,
131
+ };
132
+ const result = await this._fetchPost(`/marker/${marker}/users/check-code`, data);
133
+ return result;
134
+ }
135
+ /**
136
+ * User activate.
137
+ * @handleName activateUser
138
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
139
+ * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
140
+ * @param {string} code - Service code. Example: "123456".
141
+ * @returns {Promise<boolean | IError>} Returns true if the user was successfully activated, or an error object if there was an issue.
142
+ * @throws {IError} When isShell=false and an error occurs during the fetch
143
+ * @description User activation.
144
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/activateUser activateUser} documentation.
145
+ */
146
+ async activateUser(marker, userIdentifier, code) {
147
+ const data = {
148
+ userIdentifier: userIdentifier,
149
+ code: code,
150
+ };
151
+ const result = await this._fetchPost(`/marker/${marker}/users/activate`, data);
152
+ return result;
153
+ }
154
+ /**
155
+ * User authorization.
156
+ * @handleName auth
157
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
158
+ * @param {IAuthPostBody} body - Objects contains auth information.
159
+ * @example
160
+ {
161
+ "authData": [
162
+ {
163
+ "marker": "login",
164
+ "value": "example@oneentry.cloud"
165
+ },
166
+ {
167
+ "marker": "password",
168
+ "value": "12345"
169
+ }
170
+ ]
171
+ }
172
+ * @param {{ marker: string; value: string | number }[]} body.authData - An array of authentication data objects, each containing a marker and its corresponding value.
173
+ * @example
174
+ [
175
+ {
176
+ "marker": "login",
177
+ "value": "user@example.com"
178
+ }
179
+ ]
180
+ * @param {string} body.authData[index].marker - The marker for the authentication data. Example: "login".
181
+ * @param {string} body.authData[index].value - The value for the authentication data. Example: "user@example.com".
182
+ * @returns {Promise<IAuthEntity | IError>} Returns an auth entity object.
183
+ * @throws {IError} When isShell=false and an error occurs during the fetch
184
+ * @description User authorization.
185
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/auth auth} documentation.
186
+ */
187
+ async auth(marker, body) {
188
+ const result = await this._fetchPost(`/marker/${marker}/users/auth`, body);
189
+ // Validate response if validation is enabled
190
+ const validated = await this._validateResponse(result, schema('AuthResponseSchema'));
191
+ if (!('statusCode' in validated)) {
192
+ this.state.accessToken = validated.accessToken;
193
+ this.state.refreshToken = validated.refreshToken;
194
+ if (this.state.saveFunction && validated.refreshToken) {
195
+ this.state.saveFunction(validated.refreshToken);
196
+ }
197
+ }
198
+ return validated;
199
+ }
200
+ /**
201
+ * Refresh token.
202
+ * @handleName refresh
203
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
204
+ * @param {string} token - Refresh token. Example: "abcdef123456".
205
+ * @returns {Promise<IAuthEntity | IError>} Returns an auth entity object with the following values: accessToken, refreshToken, user, and other auth-related data.
206
+ * @throws {IError} When isShell=false and an error occurs during the fetch
207
+ * @description User token refresh.
208
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/refresh refresh} documentation.
209
+ */
210
+ async refresh(marker, token) {
211
+ const data = { refreshToken: token };
212
+ const result = await this._fetchPost(`/marker/${marker}/users/refresh`, data);
213
+ if (!('statusCode' in result)) {
214
+ this.state.accessToken = result.accessToken;
215
+ this.state.refreshToken = result.refreshToken;
216
+ if (this.state.saveFunction) {
217
+ this.state.saveFunction(result.refreshToken);
218
+ }
219
+ }
220
+ return result;
221
+ }
222
+ /**
223
+ * User account logout.
224
+ * @handleName logout
225
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
226
+ * @param {string} token - Refresh token. Example: "abcdef123456".
227
+ * @returns {Promise<boolean | IError>} Returns true if the logout was successful, or an error object if there was an issue.
228
+ * @throws {IError} When isShell=false and an error occurs during the fetch
229
+ * @description This method requires user authorization.
230
+ * @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}.
231
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logout logout} documentation.
232
+ */
233
+ async logout(marker, token) {
234
+ const data = {
235
+ refreshToken: token,
236
+ };
237
+ const result = await this._fetchPost(`/marker/${marker}/users/logout`, data);
238
+ if (result) {
239
+ this.state.accessToken = undefined;
240
+ this.state.refreshToken = undefined;
241
+ if (this.state.saveFunction) {
242
+ this.state.saveFunction('');
243
+ }
244
+ }
245
+ return result;
246
+ }
247
+ /**
248
+ * Logout of user account on all devices.
249
+ * @handleName logoutAll
250
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
251
+ * @returns {Promise<boolean | IError>} Returns true if the logout was successful, or an error object if there was an issue.
252
+ * @throws {IError} When isShell=false and an error occurs during the fetch
253
+ * @description This method requires user authorization.
254
+ * @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}.
255
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logoutAll logoutAll} documentation.
256
+ */
257
+ async logoutAll(marker) {
258
+ const result = await this._fetchPost(`/marker/${marker}/users/logout-all`);
259
+ if (result) {
260
+ this.state.accessToken = undefined;
261
+ this.state.refreshToken = undefined;
262
+ if (this.state.saveFunction) {
263
+ this.state.saveFunction('');
264
+ }
265
+ }
266
+ return result;
267
+ }
268
+ /**
269
+ * Change password.
270
+ * @handleName changePassword
271
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
272
+ * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
273
+ * @param {string} eventIdentifier - The text identifier of the event. Example: "reg".
274
+ * @param {number} type - Operation type (1 - for changing password, 2 - for recovery). Example: 1.
275
+ * @param {string} code - Service code. Example: "123456".
276
+ * @param {string} newPassword - New password. Example: "newPassword123".
277
+ * @param {string} [repeatPassword] - Optional variable contains repeat new password for validation. Example: "newPassword123".
278
+ * @returns {Promise<boolean | IError>} Returns true if the password was successfully changed, or an error object if there was an issue.
279
+ * @throws {IError} When isShell=false and an error occurs during the fetch
280
+ * @description User password change (only for tariffs with account activation and the Activation feature enabled).
281
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/changePassword changePassword} documentation.
282
+ */
283
+ async changePassword(marker, userIdentifier, eventIdentifier, type, code, newPassword, repeatPassword) {
284
+ const data = {
285
+ userIdentifier: userIdentifier,
286
+ eventIdentifier: eventIdentifier,
287
+ code: code,
288
+ type: type,
289
+ password1: newPassword,
290
+ password2: repeatPassword !== null && repeatPassword !== void 0 ? repeatPassword : newPassword,
291
+ };
292
+ const result = await this._fetchPost(`/marker/${marker}/users/change-password`, data);
293
+ return result;
294
+ }
295
+ /**
296
+ * Get all auth providers objects.
297
+ * @handleName getAuthProviders
298
+ * @param {string} [langCode] - Language code. Default: "en_US".
299
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
300
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
301
+ * @returns {Promise<IAuthProvidersEntity[] | IError>} Returns an array of auth provider objects.
302
+ * @throws {IError} When isShell=false and an error occurs during the fetch
303
+ * @description Getting all objects of authorization providers.
304
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviders getAuthProviders} documentation.
305
+ */
306
+ async getAuthProviders(langCode = this.state.lang, offset = 0, limit = 30) {
307
+ const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
308
+ // Validate response if validation is enabled
309
+ const validated = await this._validateResponse(result, schema('AuthProvidersResponseSchema'));
310
+ return this._normalizeData(validated);
311
+ }
312
+ /**
313
+ * Get one auth provider object by marker.
314
+ * @handleName getAuthProviderByMarker
315
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
316
+ * @param {string} [langCode] - Language code. Default: "en_US".
317
+ * @returns {Promise<IAuthProvidersEntity | IError>} Returns an auth provider object.
318
+ * @throws {IError} When isShell=false and an error occurs during the fetch
319
+ * @description Getting a single authorization provider object by marker.
320
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviderByMarker getAuthProviderByMarker} documentation.
321
+ */
322
+ async getAuthProviderByMarker(marker, langCode = this.state.lang) {
323
+ const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
324
+ return this._normalizeData(result);
325
+ }
326
+ /**
327
+ * Getting active user sessions data.
328
+ * @handleName getActiveSessionsByMarker
329
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
330
+ * @returns {Promise<IActiveSession[] | IError>} Returns an auth provider object.
331
+ * @throws {IError} When isShell=false and an error occurs during the fetch
332
+ * @description Getting a single authorization provider object by marker.
333
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getActiveSessionsByMarker getActiveSessionsByMarker} documentation.
334
+ */
335
+ async getActiveSessionsByMarker(marker) {
336
+ const result = await this._fetchGet(`/marker/${marker}/users/sessions`);
337
+ return this._normalizeData(result);
338
+ }
339
+ /**
340
+ * User registration (authorization) via OAUTH.
341
+ * @handleName oauth
342
+ * @param {string} marker - The text identifier of the authorization provider. Example: "email".
343
+ * @param {IOauthData} body - Object contains OAuth information for registration.
344
+ * @example
345
+ {
346
+ "client_id": "34346983-luuct343473qdkqidjopdfp3eb3k4thp.apps.googleusercontent.com",
347
+ "client_secret": "43434343434",
348
+ "code": "4/0AVMBsJgwewewewewewei4D7T6E_fbswxnL3g",
349
+ "grant_type": "authorization_code",
350
+ "redirect_uri": "http://localhost:3000"
351
+ }
352
+ * @param {string} [langCode] - Language code. Default: "en_US".
353
+ * @returns {Promise<ISignUpEntity | IError>} Returns a user object.
354
+ * @throws {IError} When isShell=false and an error occurs during the fetch
355
+ * @description User registration (authorization) via OAUTH.
356
+ * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/oauth oauth} documentation.
357
+ */
358
+ async oauth(marker, body, langCode = this.state.lang) {
359
+ const result = await this._fetchPost(`/marker/${marker}/oauth`, this._normalizePostBody(body, langCode));
360
+ return result;
361
+ }
362
+ }