oneentry 1.0.136 → 1.0.138

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 (109) hide show
  1. package/README.md +15 -3
  2. package/configure.js +27 -3
  3. package/dist/admins/adminsApi.d.ts +2 -2
  4. package/dist/admins/adminsApi.js +6 -3
  5. package/dist/admins/adminsInterfaces.d.ts +2 -2
  6. package/dist/admins/adminsSchemas.d.ts +30 -0
  7. package/dist/admins/adminsSchemas.js +27 -0
  8. package/dist/attribute-sets/attributeSetsApi.d.ts +8 -8
  9. package/dist/attribute-sets/attributeSetsApi.js +21 -12
  10. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +3 -3
  11. package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
  12. package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
  13. package/dist/auth-provider/authProviderApi.d.ts +44 -41
  14. package/dist/auth-provider/authProviderApi.js +58 -48
  15. package/dist/auth-provider/authProviderSchemas.d.ts +137 -0
  16. package/dist/auth-provider/authProviderSchemas.js +85 -0
  17. package/dist/auth-provider/authProvidersInterfaces.d.ts +17 -67
  18. package/dist/base/asyncModules.d.ts +25 -15
  19. package/dist/base/asyncModules.js +65 -44
  20. package/dist/base/stateModule.d.ts +8 -0
  21. package/dist/base/stateModule.js +27 -11
  22. package/dist/base/syncModules.d.ts +18 -0
  23. package/dist/base/syncModules.js +93 -99
  24. package/dist/base/utils.d.ts +56 -10
  25. package/dist/base/validation.d.ts +118 -0
  26. package/dist/base/validation.js +132 -0
  27. package/dist/blocks/blocksApi.d.ts +10 -10
  28. package/dist/blocks/blocksApi.js +26 -21
  29. package/dist/blocks/blocksInterfaces.d.ts +2 -1
  30. package/dist/blocks/blocksSchemas.d.ts +187 -0
  31. package/dist/blocks/blocksSchemas.js +43 -0
  32. package/dist/events/eventsApi.d.ts +5 -5
  33. package/dist/events/eventsApi.js +5 -5
  34. package/dist/events/eventsInterfaces.d.ts +25 -15
  35. package/dist/file-uploading/fileUploadingApi.d.ts +6 -6
  36. package/dist/file-uploading/fileUploadingApi.js +10 -7
  37. package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
  38. package/dist/file-uploading/fileUploadingSchemas.js +21 -0
  39. package/dist/forms/formsApi.d.ts +4 -4
  40. package/dist/forms/formsApi.js +11 -6
  41. package/dist/forms/formsInterfaces.d.ts +21 -8
  42. package/dist/forms/formsSchemas.d.ts +65 -0
  43. package/dist/forms/formsSchemas.js +36 -0
  44. package/dist/forms-data/formsDataApi.d.ts +10 -10
  45. package/dist/forms-data/formsDataApi.js +20 -13
  46. package/dist/forms-data/formsDataInterfaces.d.ts +26 -26
  47. package/dist/forms-data/formsDataSchemas.d.ts +115 -0
  48. package/dist/forms-data/formsDataSchemas.js +86 -0
  49. package/dist/general-types/generalTypesApi.d.ts +2 -2
  50. package/dist/general-types/generalTypesApi.js +6 -3
  51. package/dist/general-types/generalTypesSchemas.d.ts +50 -0
  52. package/dist/general-types/generalTypesSchemas.js +35 -0
  53. package/dist/index.d.ts +23 -1
  54. package/dist/integration-collections/integrationCollectionsApi.d.ts +17 -17
  55. package/dist/integration-collections/integrationCollectionsApi.js +42 -26
  56. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
  57. package/dist/integration-collections/integrationCollectionsSchemas.js +63 -0
  58. package/dist/locales/localesApi.d.ts +2 -2
  59. package/dist/locales/localesApi.js +6 -3
  60. package/dist/locales/localesSchemas.d.ts +32 -0
  61. package/dist/locales/localesSchemas.js +26 -0
  62. package/dist/menus/menusApi.d.ts +2 -2
  63. package/dist/menus/menusApi.js +6 -3
  64. package/dist/menus/menusInterfaces.d.ts +2 -2
  65. package/dist/menus/menusSchemas.d.ts +16 -0
  66. package/dist/menus/menusSchemas.js +28 -0
  67. package/dist/orders/ordersApi.d.ts +12 -12
  68. package/dist/orders/ordersApi.js +25 -16
  69. package/dist/orders/ordersInterfaces.d.ts +5 -4
  70. package/dist/orders/ordersSchemas.d.ts +158 -0
  71. package/dist/orders/ordersSchemas.js +120 -0
  72. package/dist/pages/pagesApi.d.ts +22 -21
  73. package/dist/pages/pagesApi.js +107 -54
  74. package/dist/pages/pagesInterfaces.d.ts +15 -11
  75. package/dist/pages/pagesSchemas.d.ts +85 -0
  76. package/dist/pages/pagesSchemas.js +46 -0
  77. package/dist/payments/paymentsApi.d.ts +13 -13
  78. package/dist/payments/paymentsApi.js +25 -16
  79. package/dist/payments/paymentsInterfaces.d.ts +11 -5
  80. package/dist/payments/paymentsSchemas.d.ts +137 -0
  81. package/dist/payments/paymentsSchemas.js +78 -0
  82. package/dist/product-statuses/productStatusesApi.d.ts +6 -6
  83. package/dist/product-statuses/productStatusesApi.js +19 -9
  84. package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
  85. package/dist/product-statuses/productStatusesSchemas.js +30 -0
  86. package/dist/products/productsApi.d.ts +29 -28
  87. package/dist/products/productsApi.js +50 -36
  88. package/dist/products/productsInterfaces.d.ts +27 -22
  89. package/dist/products/productsSchemas.d.ts +212 -0
  90. package/dist/products/productsSchemas.js +85 -0
  91. package/dist/system/systemApi.d.ts +10 -10
  92. package/dist/system/systemApi.js +10 -10
  93. package/dist/templates/templatesApi.d.ts +6 -6
  94. package/dist/templates/templatesApi.js +17 -10
  95. package/dist/templates/templatesSchemas.d.ts +48 -0
  96. package/dist/templates/templatesSchemas.js +31 -0
  97. package/dist/templates-preview/templatesPreviewApi.d.ts +3 -3
  98. package/dist/templates-preview/templatesPreviewApi.js +10 -5
  99. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +1 -0
  100. package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
  101. package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
  102. package/dist/users/usersApi.d.ts +18 -18
  103. package/dist/users/usersApi.js +26 -23
  104. package/dist/users/usersInterfaces.d.ts +10 -11
  105. package/dist/users/usersSchemas.d.ts +38 -0
  106. package/dist/users/usersSchemas.js +28 -0
  107. package/package.json +36 -12
  108. package/dist/config.d.ts +0 -13
  109. package/dist/config.js +0 -32
@@ -1,7 +1,7 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
3
  import type { IError } from '../base/utils';
4
- import type { IActiveSession, IAuthEntity, IAuthPostBody, IAuthProvider, IAuthProvidersEntity, IOAuthSignUpData, ISignUpData, ISignUpEntity } from './authProvidersInterfaces';
4
+ import type { IActiveSession, IAuthEntity, IAuthPostBody, IAuthProvider, IAuthProvidersEntity, IOauthData, ISignUpData, ISignUpEntity } from './authProvidersInterfaces';
5
5
  /**
6
6
  * Controllers for working with auth services.
7
7
  * @handle /api/content/users-auth-providers
@@ -27,19 +27,19 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
27
27
  "formIdentifier": "reg",
28
28
  "authData": [
29
29
  {
30
- "marker": "login",
31
- "value": "example@oneentry.cloud"
30
+ "marker": "login",
31
+ "value": "example@oneentry.cloud"
32
32
  },
33
33
  {
34
- "marker": "password",
35
- "value": "12345"
34
+ "marker": "password",
35
+ "value": "12345"
36
36
  }
37
37
  ],
38
38
  "formData": [
39
39
  {
40
- "marker": "last_name",
41
- "type": "string",
42
- "value": "Name"
40
+ "marker": "last_name",
41
+ "type": "string",
42
+ "value": "Name"
43
43
  }
44
44
  ],
45
45
  "notificationData": {
@@ -75,9 +75,12 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
75
75
  "phonePush": ["+99999999999"],
76
76
  "phoneSMS": "+99999999999"
77
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.
78
81
  * @param {string} [langCode] - Language code. Default: "en_US".
79
- * @returns {ISignUpEntity} Returns a user object.
80
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
82
+ * @returns {Promise<ISignUpEntity | IError>} Returns a user object.
83
+ * @throws {IError} When isShell=false and an error occurs during the fetch
81
84
  * @description User registration (❗️For a provider with user activation, the activation code is sent through the corresponding user notification method).
82
85
  */
83
86
  signUp(marker: string, body: ISignUpData, langCode?: string): Promise<ISignUpEntity | IError>;
@@ -87,8 +90,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
87
90
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
88
91
  * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
89
92
  * @param {string} eventIdentifier - Text identifier of the event object for which the code is generated. Example: "user_registration".
90
- * @returns {void} Returns void if the code is successfully generated, or an error object if there was an issue.
91
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
93
+ * @returns {Promise<void | IError>} Returns void if the code is successfully generated, or an error object if there was an issue.
94
+ * @throws {IError} When isShell=false and an error occurs during the fetch
92
95
  * @description Obtaining a code to activate the user.
93
96
  */
94
97
  generateCode(marker: string, userIdentifier: string, eventIdentifier: string): Promise<void | IError>;
@@ -99,8 +102,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
99
102
  * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
100
103
  * @param {string} eventIdentifier - Text identifier of the event object for which the code is generated. Example: "user_registration".
101
104
  * @param {string} code - Service code. Example: "123456".
102
- * @returns {boolean} Returns true if the code is correct, or an error object if there was an issue.
103
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
105
+ * @returns {Promise<boolean | IError>} Returns true if the code is correct, or an error object if there was an issue.
106
+ * @throws {IError} When isShell=false and an error occurs during the fetch
104
107
  * @description Checking the user activation code
105
108
  */
106
109
  checkCode(marker: string, userIdentifier: string, eventIdentifier: string, code: string): Promise<boolean | IError>;
@@ -110,8 +113,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
110
113
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
111
114
  * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
112
115
  * @param {string} code - Service code. Example: "123456".
113
- * @returns {boolean} Returns true if the user was successfully activated, or an error object if there was an issue.
114
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
116
+ * @returns {Promise<boolean | IError>} Returns true if the user was successfully activated, or an error object if there was an issue.
117
+ * @throws {IError} When isShell=false and an error occurs during the fetch
115
118
  * @description User activation.
116
119
  */
117
120
  activateUser(marker: string, userIdentifier: string, code: string): Promise<boolean | IError>;
@@ -124,12 +127,12 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
124
127
  {
125
128
  "authData": [
126
129
  {
127
- "marker": "login",
128
- "value": "example@oneentry.cloud"
130
+ "marker": "login",
131
+ "value": "example@oneentry.cloud"
129
132
  },
130
133
  {
131
- "marker": "password",
132
- "value": "12345"
134
+ "marker": "password",
135
+ "value": "12345"
133
136
  }
134
137
  ]
135
138
  }
@@ -143,8 +146,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
143
146
  ]
144
147
  * @param {string} body.authData[index].marker - The marker for the authentication data. Example: "login".
145
148
  * @param {string} body.authData[index].value - The value for the authentication data. Example: "user@example.com".
146
- * @returns {IAuthEntity} Returns an auth entity object.
147
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
149
+ * @returns {Promise<IAuthEntity | IError>} Returns an auth entity object.
150
+ * @throws {IError} When isShell=false and an error occurs during the fetch
148
151
  * @description User authorization.
149
152
  */
150
153
  auth(marker: string, body: IAuthPostBody): Promise<IAuthEntity | IError>;
@@ -153,8 +156,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
153
156
  * @handleName refresh
154
157
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
155
158
  * @param {string} token - Refresh token. Example: "abcdef123456".
156
- * @returns {IAuthEntity} Returns an auth entity object with the following values: accessToken, refreshToken, user, and other auth-related data.
157
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
159
+ * @returns {Promise<IAuthEntity | IError>} Returns an auth entity object with the following values: accessToken, refreshToken, user, and other auth-related data.
160
+ * @throws {IError} When isShell=false and an error occurs during the fetch
158
161
  * @description User token refresh.
159
162
  */
160
163
  refresh(marker: string, token: string): Promise<IAuthEntity | IError>;
@@ -163,8 +166,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
163
166
  * @handleName logout
164
167
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
165
168
  * @param {string} token - Refresh token. Example: "abcdef123456".
166
- * @returns {boolean} Returns true if the logout was successful, or an error object if there was an issue.
167
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
169
+ * @returns {Promise<boolean | IError>} Returns true if the logout was successful, or an error object if there was an issue.
170
+ * @throws {IError} When isShell=false and an error occurs during the fetch
168
171
  * @description This method requires user authorization.
169
172
  * @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}.
170
173
  */
@@ -173,8 +176,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
173
176
  * Logout of user account on all devices.
174
177
  * @handleName logoutAll
175
178
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
176
- * @returns {boolean} Returns true if the logout was successful, or an error object if there was an issue.
177
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
179
+ * @returns {Promise<boolean | IError>} Returns true if the logout was successful, or an error object if there was an issue.
180
+ * @throws {IError} When isShell=false and an error occurs during the fetch
178
181
  * @description This method requires user authorization.
179
182
  * @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}.
180
183
  */
@@ -189,8 +192,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
189
192
  * @param {string} code - Service code. Example: "123456".
190
193
  * @param {string} newPassword - New password. Example: "newPassword123".
191
194
  * @param {string} [repeatPassword] - Optional variable contains repeat new password for validation. Example: "newPassword123".
192
- * @returns {boolean} Returns true if the password was successfully changed, or an error object if there was an issue.
193
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
195
+ * @returns {Promise<boolean | IError>} Returns true if the password was successfully changed, or an error object if there was an issue.
196
+ * @throws {IError} When isShell=false and an error occurs during the fetch
194
197
  * @description User password change (only for tariffs with account activation and the Activation feature enabled).
195
198
  */
196
199
  changePassword(marker: string, userIdentifier: string, eventIdentifier: string, type: number, code: string, newPassword: string, repeatPassword?: string): Promise<boolean | IError>;
@@ -200,8 +203,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
200
203
  * @param {string} [langCode] - Language code. Default: "en_US".
201
204
  * @param {number} [offset] - Parameter for pagination. Default: 0.
202
205
  * @param {number} [limit] - Parameter for pagination. Default: 30.
203
- * @returns {IAuthProvidersEntity[]} Returns an array of auth provider objects.
204
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
206
+ * @returns {Promise<IAuthProvidersEntity[] | IError>} Returns an array of auth provider objects.
207
+ * @throws {IError} When isShell=false and an error occurs during the fetch
205
208
  * @description Getting all objects of authorization providers.
206
209
  */
207
210
  getAuthProviders(langCode?: string, offset?: number, limit?: number): Promise<IAuthProvidersEntity[] | IError>;
@@ -210,8 +213,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
210
213
  * @handleName getAuthProviderByMarker
211
214
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
212
215
  * @param {string} [langCode] - Language code. Default: "en_US".
213
- * @returns {IAuthProvidersEntity} Returns an auth provider object.
214
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
216
+ * @returns {Promise<IAuthProvidersEntity | IError>} Returns an auth provider object.
217
+ * @throws {IError} When isShell=false and an error occurs during the fetch
215
218
  * @description Getting a single authorization provider object by marker.
216
219
  */
217
220
  getAuthProviderByMarker(marker: string, langCode?: string): Promise<IAuthProvidersEntity | IError>;
@@ -219,16 +222,16 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
219
222
  * Getting active user sessions data.
220
223
  * @handleName getActiveSessionsByMarker
221
224
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
222
- * @returns {IActiveSession[]} Returns an auth provider object.
223
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
225
+ * @returns {Promise<IActiveSession[] | IError>} Returns an auth provider object.
226
+ * @throws {IError} When isShell=false and an error occurs during the fetch
224
227
  * @description Getting a single authorization provider object by marker.
225
228
  */
226
229
  getActiveSessionsByMarker(marker: string): Promise<IActiveSession[] | IError>;
227
230
  /**
228
231
  * User registration (authorization) via OAUTH.
229
- * @handleName oauthSignUp
232
+ * @handleName oauth
230
233
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
231
- * @param {IOAuthSignUpData} body - Object contains OAuth information for registration.
234
+ * @param {IOauthData} body - Object contains OAuth information for registration.
232
235
  * @example
233
236
  {
234
237
  "client_id": "34346983-luuct343473qdkqidjopdfp3eb3k4thp.apps.googleusercontent.com",
@@ -238,9 +241,9 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
238
241
  "redirect_uri": "http://localhost:3000"
239
242
  }
240
243
  * @param {string} [langCode] - Language code. Default: "en_US".
241
- * @returns {ISignUpEntity} Returns a user object.
242
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
244
+ * @returns {Promise<ISignUpEntity | IError>} Returns a user object.
245
+ * @throws {IError} When isShell=false and an error occurs during the fetch
243
246
  * @description User registration (authorization) via OAUTH.
244
247
  */
245
- oauthSignUp(marker: string, body: IOAuthSignUpData, langCode?: string): Promise<IAuthEntity | IError>;
248
+ oauth(marker: string, body: IOauthData, langCode?: string): Promise<IAuthEntity | IError>;
246
249
  }
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  /* eslint-disable jsdoc/no-undefined-types */
7
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
+ const authProviderSchemas_1 = require("./authProviderSchemas");
8
9
  /**
9
10
  * Controllers for working with auth services.
10
11
  * @handle /api/content/users-auth-providers
@@ -31,19 +32,19 @@ class AuthProviderApi extends asyncModules_1.default {
31
32
  "formIdentifier": "reg",
32
33
  "authData": [
33
34
  {
34
- "marker": "login",
35
- "value": "example@oneentry.cloud"
35
+ "marker": "login",
36
+ "value": "example@oneentry.cloud"
36
37
  },
37
38
  {
38
- "marker": "password",
39
- "value": "12345"
39
+ "marker": "password",
40
+ "value": "12345"
40
41
  }
41
42
  ],
42
43
  "formData": [
43
44
  {
44
- "marker": "last_name",
45
- "type": "string",
46
- "value": "Name"
45
+ "marker": "last_name",
46
+ "type": "string",
47
+ "value": "Name"
47
48
  }
48
49
  ],
49
50
  "notificationData": {
@@ -79,15 +80,20 @@ class AuthProviderApi extends asyncModules_1.default {
79
80
  "phonePush": ["+99999999999"],
80
81
  "phoneSMS": "+99999999999"
81
82
  }
83
+ * @param {string} body.notificationData.email - The email address to which the notification will be sent.
84
+ * @param {Array<string>} [body.notificationData.phonePush] - An array of phone numbers for push notifications. Optional.
85
+ * @param {string} [body.notificationData.phoneSMS] - The phone number for SMS notifications. Optional.
82
86
  * @param {string} [langCode] - Language code. Default: "en_US".
83
- * @returns {ISignUpEntity} Returns a user object.
84
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
87
+ * @returns {Promise<ISignUpEntity | IError>} Returns a user object.
88
+ * @throws {IError} When isShell=false and an error occurs during the fetch
85
89
  * @description User registration (❗️For a provider with user activation, the activation code is sent through the corresponding user notification method).
86
90
  */
87
91
  async signUp(marker, body, langCode = this.state.lang) {
88
92
  body['langCode'] = langCode;
89
93
  const result = await this._fetchPost(`/marker/${marker}/users/sign-up`, this._normalizePostBody(body, langCode));
90
- return this._normalizeData(result);
94
+ // Validate response if validation is enabled
95
+ const validated = this._validateResponse(result, authProviderSchemas_1.SignUpResponseSchema);
96
+ return this._normalizeData(validated);
91
97
  }
92
98
  /**
93
99
  * Getting a user activation code. The code is returned via the appropriate user notification method.
@@ -95,8 +101,8 @@ class AuthProviderApi extends asyncModules_1.default {
95
101
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
96
102
  * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
97
103
  * @param {string} eventIdentifier - Text identifier of the event object for which the code is generated. Example: "user_registration".
98
- * @returns {void} Returns void if the code is successfully generated, or an error object if there was an issue.
99
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
104
+ * @returns {Promise<void | IError>} Returns void if the code is successfully generated, or an error object if there was an issue.
105
+ * @throws {IError} When isShell=false and an error occurs during the fetch
100
106
  * @description Obtaining a code to activate the user.
101
107
  */
102
108
  async generateCode(marker, userIdentifier, eventIdentifier) {
@@ -114,8 +120,8 @@ class AuthProviderApi extends asyncModules_1.default {
114
120
  * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
115
121
  * @param {string} eventIdentifier - Text identifier of the event object for which the code is generated. Example: "user_registration".
116
122
  * @param {string} code - Service code. Example: "123456".
117
- * @returns {boolean} Returns true if the code is correct, or an error object if there was an issue.
118
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
123
+ * @returns {Promise<boolean | IError>} Returns true if the code is correct, or an error object if there was an issue.
124
+ * @throws {IError} When isShell=false and an error occurs during the fetch
119
125
  * @description Checking the user activation code
120
126
  */
121
127
  async checkCode(marker, userIdentifier, eventIdentifier, code) {
@@ -133,8 +139,8 @@ class AuthProviderApi extends asyncModules_1.default {
133
139
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
134
140
  * @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
135
141
  * @param {string} code - Service code. Example: "123456".
136
- * @returns {boolean} Returns true if the user was successfully activated, or an error object if there was an issue.
137
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
142
+ * @returns {Promise<boolean | IError>} Returns true if the user was successfully activated, or an error object if there was an issue.
143
+ * @throws {IError} When isShell=false and an error occurs during the fetch
138
144
  * @description User activation.
139
145
  */
140
146
  async activateUser(marker, userIdentifier, code) {
@@ -154,12 +160,12 @@ class AuthProviderApi extends asyncModules_1.default {
154
160
  {
155
161
  "authData": [
156
162
  {
157
- "marker": "login",
158
- "value": "example@oneentry.cloud"
163
+ "marker": "login",
164
+ "value": "example@oneentry.cloud"
159
165
  },
160
166
  {
161
- "marker": "password",
162
- "value": "12345"
167
+ "marker": "password",
168
+ "value": "12345"
163
169
  }
164
170
  ]
165
171
  }
@@ -173,27 +179,29 @@ class AuthProviderApi extends asyncModules_1.default {
173
179
  ]
174
180
  * @param {string} body.authData[index].marker - The marker for the authentication data. Example: "login".
175
181
  * @param {string} body.authData[index].value - The value for the authentication data. Example: "user@example.com".
176
- * @returns {IAuthEntity} Returns an auth entity object.
177
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
182
+ * @returns {Promise<IAuthEntity | IError>} Returns an auth entity object.
183
+ * @throws {IError} When isShell=false and an error occurs during the fetch
178
184
  * @description User authorization.
179
185
  */
180
186
  async auth(marker, body) {
181
187
  const result = await this._fetchPost(`/marker/${marker}/users/auth`, body);
182
- this.state.accessToken = result.accessToken;
183
- this.state.refreshToken = result.refreshToken;
184
- // console.log(result);
185
- if (this.state.saveFunction) {
186
- this.state.saveFunction(result.refreshToken);
188
+ // Validate response if validation is enabled
189
+ const validated = this._validateResponse(result, authProviderSchemas_1.AuthResponseSchema);
190
+ this.state.accessToken = validated.accessToken;
191
+ this.state.refreshToken = validated.refreshToken;
192
+ // console.log(validated);
193
+ if (this.state.saveFunction && validated.refreshToken) {
194
+ this.state.saveFunction(validated.refreshToken);
187
195
  }
188
- return result;
196
+ return validated;
189
197
  }
190
198
  /**
191
199
  * Refresh token.
192
200
  * @handleName refresh
193
201
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
194
202
  * @param {string} token - Refresh token. Example: "abcdef123456".
195
- * @returns {IAuthEntity} Returns an auth entity object with the following values: accessToken, refreshToken, user, and other auth-related data.
196
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
203
+ * @returns {Promise<IAuthEntity | IError>} Returns an auth entity object with the following values: accessToken, refreshToken, user, and other auth-related data.
204
+ * @throws {IError} When isShell=false and an error occurs during the fetch
197
205
  * @description User token refresh.
198
206
  */
199
207
  async refresh(marker, token) {
@@ -211,8 +219,8 @@ class AuthProviderApi extends asyncModules_1.default {
211
219
  * @handleName logout
212
220
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
213
221
  * @param {string} token - Refresh token. Example: "abcdef123456".
214
- * @returns {boolean} Returns true if the logout was successful, or an error object if there was an issue.
215
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
222
+ * @returns {Promise<boolean | IError>} Returns true if the logout was successful, or an error object if there was an issue.
223
+ * @throws {IError} When isShell=false and an error occurs during the fetch
216
224
  * @description This method requires user authorization.
217
225
  * @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}.
218
226
  */
@@ -234,8 +242,8 @@ class AuthProviderApi extends asyncModules_1.default {
234
242
  * Logout of user account on all devices.
235
243
  * @handleName logoutAll
236
244
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
237
- * @returns {boolean} Returns true if the logout was successful, or an error object if there was an issue.
238
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
245
+ * @returns {Promise<boolean | IError>} Returns true if the logout was successful, or an error object if there was an issue.
246
+ * @throws {IError} When isShell=false and an error occurs during the fetch
239
247
  * @description This method requires user authorization.
240
248
  * @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}.
241
249
  */
@@ -260,8 +268,8 @@ class AuthProviderApi extends asyncModules_1.default {
260
268
  * @param {string} code - Service code. Example: "123456".
261
269
  * @param {string} newPassword - New password. Example: "newPassword123".
262
270
  * @param {string} [repeatPassword] - Optional variable contains repeat new password for validation. Example: "newPassword123".
263
- * @returns {boolean} Returns true if the password was successfully changed, or an error object if there was an issue.
264
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
271
+ * @returns {Promise<boolean | IError>} Returns true if the password was successfully changed, or an error object if there was an issue.
272
+ * @throws {IError} When isShell=false and an error occurs during the fetch
265
273
  * @description User password change (only for tariffs with account activation and the Activation feature enabled).
266
274
  */
267
275
  async changePassword(marker, userIdentifier, eventIdentifier, type, code, newPassword, repeatPassword) {
@@ -282,21 +290,23 @@ class AuthProviderApi extends asyncModules_1.default {
282
290
  * @param {string} [langCode] - Language code. Default: "en_US".
283
291
  * @param {number} [offset] - Parameter for pagination. Default: 0.
284
292
  * @param {number} [limit] - Parameter for pagination. Default: 30.
285
- * @returns {IAuthProvidersEntity[]} Returns an array of auth provider objects.
286
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
293
+ * @returns {Promise<IAuthProvidersEntity[] | IError>} Returns an array of auth provider objects.
294
+ * @throws {IError} When isShell=false and an error occurs during the fetch
287
295
  * @description Getting all objects of authorization providers.
288
296
  */
289
297
  async getAuthProviders(langCode = this.state.lang, offset = 0, limit = 30) {
290
298
  const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
291
- return this._normalizeData(result);
299
+ // Validate response if validation is enabled
300
+ const validated = this._validateResponse(result, authProviderSchemas_1.AuthProvidersResponseSchema);
301
+ return this._normalizeData(validated);
292
302
  }
293
303
  /**
294
304
  * Get one auth provider object by marker.
295
305
  * @handleName getAuthProviderByMarker
296
306
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
297
307
  * @param {string} [langCode] - Language code. Default: "en_US".
298
- * @returns {IAuthProvidersEntity} Returns an auth provider object.
299
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
308
+ * @returns {Promise<IAuthProvidersEntity | IError>} Returns an auth provider object.
309
+ * @throws {IError} When isShell=false and an error occurs during the fetch
300
310
  * @description Getting a single authorization provider object by marker.
301
311
  */
302
312
  async getAuthProviderByMarker(marker, langCode = this.state.lang) {
@@ -307,8 +317,8 @@ class AuthProviderApi extends asyncModules_1.default {
307
317
  * Getting active user sessions data.
308
318
  * @handleName getActiveSessionsByMarker
309
319
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
310
- * @returns {IActiveSession[]} Returns an auth provider object.
311
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
320
+ * @returns {Promise<IActiveSession[] | IError>} Returns an auth provider object.
321
+ * @throws {IError} When isShell=false and an error occurs during the fetch
312
322
  * @description Getting a single authorization provider object by marker.
313
323
  */
314
324
  async getActiveSessionsByMarker(marker) {
@@ -317,9 +327,9 @@ class AuthProviderApi extends asyncModules_1.default {
317
327
  }
318
328
  /**
319
329
  * User registration (authorization) via OAUTH.
320
- * @handleName oauthSignUp
330
+ * @handleName oauth
321
331
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
322
- * @param {IOAuthSignUpData} body - Object contains OAuth information for registration.
332
+ * @param {IOauthData} body - Object contains OAuth information for registration.
323
333
  * @example
324
334
  {
325
335
  "client_id": "34346983-luuct343473qdkqidjopdfp3eb3k4thp.apps.googleusercontent.com",
@@ -329,11 +339,11 @@ class AuthProviderApi extends asyncModules_1.default {
329
339
  "redirect_uri": "http://localhost:3000"
330
340
  }
331
341
  * @param {string} [langCode] - Language code. Default: "en_US".
332
- * @returns {ISignUpEntity} Returns a user object.
333
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
342
+ * @returns {Promise<ISignUpEntity | IError>} Returns a user object.
343
+ * @throws {IError} When isShell=false and an error occurs during the fetch
334
344
  * @description User registration (authorization) via OAUTH.
335
345
  */
336
- async oauthSignUp(marker, body, langCode = this.state.lang) {
346
+ async oauth(marker, body, langCode = this.state.lang) {
337
347
  const result = await this._fetchPost(`/marker/${marker}/oauth`, this._normalizePostBody(body, langCode));
338
348
  return result;
339
349
  }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Validation schemas for Auth Provider module
3
+ * @description Zod schemas for validating auth-related API responses
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Sign up response schema
8
+ * @description Schema for validating sign up response
9
+ */
10
+ export declare const SignUpResponseSchema: z.ZodObject<{
11
+ id: z.ZodNumber;
12
+ identifier: z.ZodOptional<z.ZodString>;
13
+ email: z.ZodOptional<z.ZodString>;
14
+ phoneMask: z.ZodOptional<z.ZodString>;
15
+ phoneCode: z.ZodOptional<z.ZodString>;
16
+ phoneNumber: z.ZodOptional<z.ZodString>;
17
+ statusMarker: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strip>;
19
+ /**
20
+ * Auth response schema (login/refresh)
21
+ * @description Schema for validating auth response
22
+ */
23
+ export declare const AuthResponseSchema: z.ZodObject<{
24
+ accessToken: z.ZodString;
25
+ refreshToken: z.ZodString;
26
+ userIdentifier: z.ZodOptional<z.ZodString>;
27
+ authProviderIdentifier: z.ZodOptional<z.ZodString>;
28
+ user: z.ZodOptional<z.ZodObject<{
29
+ id: z.ZodNumber;
30
+ identifier: z.ZodOptional<z.ZodString>;
31
+ email: z.ZodOptional<z.ZodString>;
32
+ phoneMask: z.ZodOptional<z.ZodString>;
33
+ phoneCode: z.ZodOptional<z.ZodString>;
34
+ phoneNumber: z.ZodOptional<z.ZodString>;
35
+ statusMarker: z.ZodOptional<z.ZodString>;
36
+ formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
37
+ total: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
38
+ authProviderIdentifier: z.ZodOptional<z.ZodString>;
39
+ formIdentifier: z.ZodOptional<z.ZodString>;
40
+ groups: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
41
+ state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
42
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
43
+ }, z.core.$strip>>;
44
+ }, z.core.$strip>;
45
+ /**
46
+ * User response schema
47
+ * @description Schema for validating user response
48
+ */
49
+ export declare const UserResponseSchema: z.ZodObject<{
50
+ id: z.ZodNumber;
51
+ identifier: z.ZodOptional<z.ZodString>;
52
+ email: z.ZodOptional<z.ZodString>;
53
+ phoneMask: z.ZodOptional<z.ZodString>;
54
+ phoneCode: z.ZodOptional<z.ZodString>;
55
+ phoneNumber: z.ZodOptional<z.ZodString>;
56
+ statusMarker: z.ZodOptional<z.ZodString>;
57
+ formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
58
+ total: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
59
+ authProviderIdentifier: z.ZodOptional<z.ZodString>;
60
+ formIdentifier: z.ZodOptional<z.ZodString>;
61
+ groups: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
62
+ state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
63
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
64
+ }, z.core.$strip>;
65
+ /**
66
+ * Auth provider entity schema
67
+ * @description Schema for validating auth provider entity
68
+ * Includes all fields returned by the API
69
+ */
70
+ export declare const AuthProviderEntitySchema: z.ZodObject<{
71
+ id: z.ZodNumber;
72
+ identifier: z.ZodString;
73
+ type: z.ZodOptional<z.ZodString>;
74
+ formIdentifier: z.ZodOptional<z.ZodString>;
75
+ userGroupIdentifier: z.ZodOptional<z.ZodString>;
76
+ isActive: z.ZodBoolean;
77
+ isCheckCode: z.ZodOptional<z.ZodBoolean>;
78
+ version: z.ZodOptional<z.ZodNumber>;
79
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
80
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
81
+ marker: z.ZodOptional<z.ZodString>;
82
+ name: z.ZodOptional<z.ZodString>;
83
+ position: z.ZodOptional<z.ZodNumber>;
84
+ }, z.core.$strip>;
85
+ /**
86
+ * Auth providers list response schema
87
+ * @description Schema for validating auth providers list response
88
+ */
89
+ export declare const AuthProvidersResponseSchema: z.ZodArray<z.ZodObject<{
90
+ id: z.ZodNumber;
91
+ identifier: z.ZodString;
92
+ type: z.ZodOptional<z.ZodString>;
93
+ formIdentifier: z.ZodOptional<z.ZodString>;
94
+ userGroupIdentifier: z.ZodOptional<z.ZodString>;
95
+ isActive: z.ZodBoolean;
96
+ isCheckCode: z.ZodOptional<z.ZodBoolean>;
97
+ version: z.ZodOptional<z.ZodNumber>;
98
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
99
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
100
+ marker: z.ZodOptional<z.ZodString>;
101
+ name: z.ZodOptional<z.ZodString>;
102
+ position: z.ZodOptional<z.ZodNumber>;
103
+ }, z.core.$strip>>;
104
+ /**
105
+ * Generate code response schema
106
+ * @description Schema for validating generate code response
107
+ */
108
+ export declare const GenerateCodeResponseSchema: z.ZodObject<{
109
+ success: z.ZodBoolean;
110
+ message: z.ZodOptional<z.ZodString>;
111
+ }, z.core.$strip>;
112
+ /**
113
+ * Logout response schema
114
+ * @description Schema for validating logout response
115
+ */
116
+ export declare const LogoutResponseSchema: z.ZodObject<{
117
+ success: z.ZodBoolean;
118
+ message: z.ZodOptional<z.ZodString>;
119
+ }, z.core.$strip>;
120
+ /**
121
+ * Active sessions response schema
122
+ * @description Schema for validating active sessions response
123
+ */
124
+ export declare const ActiveSessionSchema: z.ZodObject<{
125
+ id: z.ZodString;
126
+ deviceInfo: z.ZodOptional<z.ZodString>;
127
+ ipAddress: z.ZodOptional<z.ZodString>;
128
+ lastActive: z.ZodOptional<z.ZodString>;
129
+ createdAt: z.ZodString;
130
+ }, z.core.$strip>;
131
+ export declare const ActiveSessionsResponseSchema: z.ZodArray<z.ZodObject<{
132
+ id: z.ZodString;
133
+ deviceInfo: z.ZodOptional<z.ZodString>;
134
+ ipAddress: z.ZodOptional<z.ZodString>;
135
+ lastActive: z.ZodOptional<z.ZodString>;
136
+ createdAt: z.ZodString;
137
+ }, z.core.$strip>>;