@textback/notification-widget 2.0.1-103212 → 2.0.1-103341

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/server.js CHANGED
@@ -1,224 +1,224 @@
1
- 'use strict';
2
-
3
- const express = require('express');
4
- const app = express();
5
- const port = process.env.PORT || 3000;
6
-
7
- app.use(express.static('.'));
8
-
9
- app.get('/examples', (req, res) => {
10
- const query = Object.assign({
11
- //widgetPath: 'https://cdn.jsdelivr.net/npm/@textback/notification-widget/build/index.js',
12
- widgetPath: 'http://localhost:8080/build/index.js',
13
- apiPath: 'https://tb-apisrv-dev.textback.io/api',
14
- widgetId: '7f4e72a9-6f97-b658-9496-016eeb97d0e4',
15
- lang: 'ru',
16
- data: JSON.stringify({orderId: 'insecureOrderID'})
17
- }, req.query);
18
-
19
- let widgetCode = `<script src='${query.widgetPath}'></script>`;
20
-
21
- widgetCode += `\n<tb-notification-widget`;
22
- widgetCode += `\n widget-id='${query.widgetId}'`;
23
-
24
- if (query.apiPath) {
25
- widgetCode += `\n api-path='${query.apiPath}'`;
26
- }
27
-
28
- if (query.lang) {
29
- widgetCode += `\n lang='${query.lang}'`;
30
- }
31
-
32
- if (query.data) {
33
- widgetCode += `\n data='${query.data}'`;
34
- }
35
-
36
- widgetCode += `>\n</tb-notification-widget>`;
37
-
38
- res.render('examples.ejs', {
39
- query,
40
- widgetCode
41
- });
42
- });
43
-
44
- app.get('/api/endUserNotifications/widgets/error500', (req, res) => {
45
- res.sendStatus(500);
46
- });
47
-
48
- app.get('/api/endUserNotifications/widgets/error404', (req, res) => {
49
- res.sendStatus(404);
50
- });
51
-
52
- app.get('/api/endUserNotifications/widgets/a', (req, res) => {
53
- res.json({
54
- '$error': null,
55
- '$items': null,
56
- '$value': {
57
- 'id': 'd43a36de-9659-45b5-9373-aed1a6d58dc5',
58
- 'vkApiId': null,
59
- 'accountId': '99bffda5-5bd1-49b1-b4f2-658854797c01',
60
- 'channels': [{
61
- 'channel': 'tg',
62
- 'id': 'rb_dev_3_bot',
63
- 'slug': '@rb_dev_3_bot',
64
- 'enabled': true,
65
- 'channelId': null
66
- }, {
67
- 'channel': 'vk',
68
- //'type': 'apiCall',
69
- 'id': '124981888',
70
- 'slug': 'tb_test_group',
71
- 'enabled': true,
72
- 'channelId': 29
73
- }, {
74
- 'channel': 'facebook',
75
- 'id': '323049074708312',
76
- 'slug': 'TA0ETXSdhM8JnvkB1iUM',
77
- 'enabled': true,
78
- 'channelId': null
79
- }, {'channel': 'viber', 'id': 'dev_', 'slug': '', 'enabled': true, 'channelId': null}],
80
- 'welcomeMessage': {
81
- 'text': null,
82
- 'markup': 'PLAIN',
83
- 'attachments': null,
84
- 'buttons': [{
85
- 'type': 'HyperLinkButton',
86
- 'text': 'Читать статью',
87
- 'link': 'https://blog.textback.ru/notifications_in_messengers'
88
- }]
89
- },
90
- 'title': {'value': 'test heading'},
91
- 'description': {'value': 'test desc\r\nline'},
92
- 'markUp': {
93
- 'body': {},
94
- 'icon': {'type': 'preset'},
95
- 'header': {'value': 'привет это тестовый заголовок чтобы понять какое нормальное число знак'},
96
- 'description': {'value': 'это тестовый заголовок чтобы понять какое нормальное число знаков может быть в описании чтобы было читабельно и красиво и вообще нормально. это очень длинное название, прямо очень длинное очень приоче'},
97
- 'title': {'value': 'asdadad'}
98
- },
99
- 'displayOptions': {},
100
- //'displayMode': 'popup'
101
- },
102
- '$count': 1
103
- });
104
- });
105
-
106
- app.get('/api/endUserNotifications/widgets/b', (req, res) => {
107
- res.json({
108
- '$error': null,
109
- '$items': null,
110
- '$value': {
111
- 'id': 'd43a36de-9659-45b5-9373-aed1a6d58dc5',
112
- 'vkApiId': 5930339,
113
- 'accountId': '99bffda5-5bd1-49b1-b4f2-658854797c01',
114
- 'channels': [{
115
- 'channel': 'tg',
116
- 'id': 'rb_dev_3_bot',
117
- 'slug': '@rb_dev_3_bot',
118
- 'enabled': true,
119
- 'channelId': null
120
- }, {
121
- 'channel': 'vk',
122
- 'type': 'apiCall',
123
- 'id': '124981888',
124
- 'slug': 'tb_test_group',
125
- 'enabled': true,
126
- 'channelId': 29
127
- }, {
128
- 'channel': 'facebook',
129
- 'id': '323049074708312',
130
- 'slug': 'TA0ETXSdhM8JnvkB1iUM',
131
- 'enabled': true,
132
- 'channelId': null
133
- }, {'channel': 'viber', 'id': 'dev_', 'slug': '', 'enabled': true, 'channelId': null}],
134
- 'welcomeMessage': {
135
- 'text': null,
136
- 'markup': 'PLAIN',
137
- 'attachments': null,
138
- 'buttons': [{
139
- 'type': 'HyperLinkButton',
140
- 'text': 'Читать статью',
141
- 'link': 'https://blog.textback.ru/notifications_in_messengers'
142
- }]
143
- },
144
- 'title': {'value': 'test heading'},
145
- 'description': {'value': 'test desc\r\nline'},
146
- 'markUp': {
147
- 'body': {},
148
- 'icon': {'type': 'preset'},
149
- 'header': {'value': 'привет это тестовый заголовок чтобы понять какое нормальное число знак'},
150
- 'description': {'value': 'это тестовый заголовок чтобы понять какое нормальное число знаков может быть в описании чтобы было читабельно и красиво и вообще нормально. это очень длинное название, прямо очень длинное очень приоче'},
151
- 'title': {'value': 'asdadad'}
152
- },
153
- 'displayOptions': {},
154
- //'displayMode': 'popup'
155
- },
156
- '$count': 1
157
- });
158
- });
159
-
160
- app.get('/api/endUserNotifications/widgets/c', (req, res) => {
161
- res.json({
162
- '$error': null,
163
- '$items': null,
164
- '$value': {
165
- 'id': 'd43a36de-9659-45b5-9373-aed1a6d58dc5',
166
- 'vkApiId': 5930339,
167
- 'accountId': '99bffda5-5bd1-49b1-b4f2-658854797c01',
168
- 'channels': [{
169
- 'channel': 'tg',
170
- 'id': 'rb_dev_3_bot',
171
- 'slug': '@rb_dev_3_bot',
172
- 'enabled': true,
173
- 'channelId': null
174
- }, {
175
- 'channel': 'vk',
176
- 'id': '124981888',
177
- 'slug': 'tb_test_group',
178
- 'enabled': true,
179
- 'channelId': 29
180
- }, {
181
- 'channel': 'facebook',
182
- 'id': '323049074708312',
183
- 'slug': 'TA0ETXSdhM8JnvkB1iUM',
184
- 'enabled': true,
185
- 'channelId': null
186
- }, {'channel': 'viber', 'id': 'dev_', 'slug': '', 'enabled': true, 'channelId': null}],
187
- 'welcomeMessage': {
188
- 'text': null,
189
- 'markup': 'PLAIN',
190
- 'attachments': null,
191
- 'buttons': [{
192
- 'type': 'HyperLinkButton',
193
- 'text': 'Читать статью',
194
- 'link': 'https://blog.textback.ru/notifications_in_messengers'
195
- }]
196
- },
197
- 'title': {'value': 'test heading'},
198
- 'description': {'value': 'test desc\r\nline'},
199
- 'markUp': {
200
- 'body': {},
201
- 'icon': {'type': 'preset'},
202
- 'header': {'value': 'привет это тестовый заголовок чтобы понять какое нормальное число знак'},
203
- 'description': {'value': 'это тестовый заголовок чтобы понять какое нормальное число знаков может быть в описании чтобы было читабельно и красиво и вообще нормально. это очень длинное название, прямо очень длинное очень приоче'},
204
- 'title': {'value': 'asdadad'}
205
- },
206
- 'displayOptions': {},
207
- 'displayMode': 'popup'
208
- },
209
- '$count': 1
210
- });
211
- });
212
-
213
- app.post('/api/endUserNotifications/deepLinks', (req, res) => {
214
- res.json({
215
- '$error': null,
216
- '$items': null,
217
- '$value': 'subscribe_XXX',
218
- '$count': 1
219
- });
220
- });
221
-
222
- app.listen(port, () => {
223
- console.log(`Application started on http://localhost:${port}`)
224
- });
1
+ 'use strict';
2
+
3
+ const express = require('express');
4
+ const app = express();
5
+ const port = process.env.PORT || 3000;
6
+
7
+ app.use(express.static('.'));
8
+
9
+ app.get('/examples', (req, res) => {
10
+ const query = Object.assign({
11
+ //widgetPath: 'https://cdn.jsdelivr.net/npm/@textback/notification-widget/build/index.js',
12
+ widgetPath: 'http://localhost:8080/build/index.js',
13
+ apiPath: 'https://tb-apisrv-dev.textback.io/api',
14
+ widgetId: '7f4e72a9-6f97-b658-9496-016eeb97d0e4',
15
+ lang: 'ru',
16
+ data: JSON.stringify({orderId: 'insecureOrderID'})
17
+ }, req.query);
18
+
19
+ let widgetCode = `<script src='${query.widgetPath}'></script>`;
20
+
21
+ widgetCode += `\n<tb-notification-widget`;
22
+ widgetCode += `\n widget-id='${query.widgetId}'`;
23
+
24
+ if (query.apiPath) {
25
+ widgetCode += `\n api-path='${query.apiPath}'`;
26
+ }
27
+
28
+ if (query.lang) {
29
+ widgetCode += `\n lang='${query.lang}'`;
30
+ }
31
+
32
+ if (query.data) {
33
+ widgetCode += `\n data='${query.data}'`;
34
+ }
35
+
36
+ widgetCode += `>\n</tb-notification-widget>`;
37
+
38
+ res.render('examples.ejs', {
39
+ query,
40
+ widgetCode
41
+ });
42
+ });
43
+
44
+ app.get('/api/endUserNotifications/widgets/error500', (req, res) => {
45
+ res.sendStatus(500);
46
+ });
47
+
48
+ app.get('/api/endUserNotifications/widgets/error404', (req, res) => {
49
+ res.sendStatus(404);
50
+ });
51
+
52
+ app.get('/api/endUserNotifications/widgets/a', (req, res) => {
53
+ res.json({
54
+ '$error': null,
55
+ '$items': null,
56
+ '$value': {
57
+ 'id': 'd43a36de-9659-45b5-9373-aed1a6d58dc5',
58
+ 'vkApiId': null,
59
+ 'accountId': '99bffda5-5bd1-49b1-b4f2-658854797c01',
60
+ 'channels': [{
61
+ 'channel': 'tg',
62
+ 'id': 'rb_dev_3_bot',
63
+ 'slug': '@rb_dev_3_bot',
64
+ 'enabled': true,
65
+ 'channelId': null
66
+ }, {
67
+ 'channel': 'vk',
68
+ //'type': 'apiCall',
69
+ 'id': '124981888',
70
+ 'slug': 'tb_test_group',
71
+ 'enabled': true,
72
+ 'channelId': 29
73
+ }, {
74
+ 'channel': 'facebook',
75
+ 'id': '323049074708312',
76
+ 'slug': 'TA0ETXSdhM8JnvkB1iUM',
77
+ 'enabled': true,
78
+ 'channelId': null
79
+ }, {'channel': 'viber', 'id': 'dev_', 'slug': '', 'enabled': true, 'channelId': null}],
80
+ 'welcomeMessage': {
81
+ 'text': null,
82
+ 'markup': 'PLAIN',
83
+ 'attachments': null,
84
+ 'buttons': [{
85
+ 'type': 'HyperLinkButton',
86
+ 'text': 'Читать статью',
87
+ 'link': 'https://blog.textback.ru/notifications_in_messengers'
88
+ }]
89
+ },
90
+ 'title': {'value': 'test heading'},
91
+ 'description': {'value': 'test desc\r\nline'},
92
+ 'markUp': {
93
+ 'body': {},
94
+ 'icon': {'type': 'preset'},
95
+ 'header': {'value': 'привет это тестовый заголовок чтобы понять какое нормальное число знак'},
96
+ 'description': {'value': 'это тестовый заголовок чтобы понять какое нормальное число знаков может быть в описании чтобы было читабельно и красиво и вообще нормально. это очень длинное название, прямо очень длинное очень приоче'},
97
+ 'title': {'value': 'asdadad'}
98
+ },
99
+ 'displayOptions': {},
100
+ //'displayMode': 'popup'
101
+ },
102
+ '$count': 1
103
+ });
104
+ });
105
+
106
+ app.get('/api/endUserNotifications/widgets/b', (req, res) => {
107
+ res.json({
108
+ '$error': null,
109
+ '$items': null,
110
+ '$value': {
111
+ 'id': 'd43a36de-9659-45b5-9373-aed1a6d58dc5',
112
+ 'vkApiId': 5930339,
113
+ 'accountId': '99bffda5-5bd1-49b1-b4f2-658854797c01',
114
+ 'channels': [{
115
+ 'channel': 'tg',
116
+ 'id': 'rb_dev_3_bot',
117
+ 'slug': '@rb_dev_3_bot',
118
+ 'enabled': true,
119
+ 'channelId': null
120
+ }, {
121
+ 'channel': 'vk',
122
+ 'type': 'apiCall',
123
+ 'id': '124981888',
124
+ 'slug': 'tb_test_group',
125
+ 'enabled': true,
126
+ 'channelId': 29
127
+ }, {
128
+ 'channel': 'facebook',
129
+ 'id': '323049074708312',
130
+ 'slug': 'TA0ETXSdhM8JnvkB1iUM',
131
+ 'enabled': true,
132
+ 'channelId': null
133
+ }, {'channel': 'viber', 'id': 'dev_', 'slug': '', 'enabled': true, 'channelId': null}],
134
+ 'welcomeMessage': {
135
+ 'text': null,
136
+ 'markup': 'PLAIN',
137
+ 'attachments': null,
138
+ 'buttons': [{
139
+ 'type': 'HyperLinkButton',
140
+ 'text': 'Читать статью',
141
+ 'link': 'https://blog.textback.ru/notifications_in_messengers'
142
+ }]
143
+ },
144
+ 'title': {'value': 'test heading'},
145
+ 'description': {'value': 'test desc\r\nline'},
146
+ 'markUp': {
147
+ 'body': {},
148
+ 'icon': {'type': 'preset'},
149
+ 'header': {'value': 'привет это тестовый заголовок чтобы понять какое нормальное число знак'},
150
+ 'description': {'value': 'это тестовый заголовок чтобы понять какое нормальное число знаков может быть в описании чтобы было читабельно и красиво и вообще нормально. это очень длинное название, прямо очень длинное очень приоче'},
151
+ 'title': {'value': 'asdadad'}
152
+ },
153
+ 'displayOptions': {},
154
+ //'displayMode': 'popup'
155
+ },
156
+ '$count': 1
157
+ });
158
+ });
159
+
160
+ app.get('/api/endUserNotifications/widgets/c', (req, res) => {
161
+ res.json({
162
+ '$error': null,
163
+ '$items': null,
164
+ '$value': {
165
+ 'id': 'd43a36de-9659-45b5-9373-aed1a6d58dc5',
166
+ 'vkApiId': 5930339,
167
+ 'accountId': '99bffda5-5bd1-49b1-b4f2-658854797c01',
168
+ 'channels': [{
169
+ 'channel': 'tg',
170
+ 'id': 'rb_dev_3_bot',
171
+ 'slug': '@rb_dev_3_bot',
172
+ 'enabled': true,
173
+ 'channelId': null
174
+ }, {
175
+ 'channel': 'vk',
176
+ 'id': '124981888',
177
+ 'slug': 'tb_test_group',
178
+ 'enabled': true,
179
+ 'channelId': 29
180
+ }, {
181
+ 'channel': 'facebook',
182
+ 'id': '323049074708312',
183
+ 'slug': 'TA0ETXSdhM8JnvkB1iUM',
184
+ 'enabled': true,
185
+ 'channelId': null
186
+ }, {'channel': 'viber', 'id': 'dev_', 'slug': '', 'enabled': true, 'channelId': null}],
187
+ 'welcomeMessage': {
188
+ 'text': null,
189
+ 'markup': 'PLAIN',
190
+ 'attachments': null,
191
+ 'buttons': [{
192
+ 'type': 'HyperLinkButton',
193
+ 'text': 'Читать статью',
194
+ 'link': 'https://blog.textback.ru/notifications_in_messengers'
195
+ }]
196
+ },
197
+ 'title': {'value': 'test heading'},
198
+ 'description': {'value': 'test desc\r\nline'},
199
+ 'markUp': {
200
+ 'body': {},
201
+ 'icon': {'type': 'preset'},
202
+ 'header': {'value': 'привет это тестовый заголовок чтобы понять какое нормальное число знак'},
203
+ 'description': {'value': 'это тестовый заголовок чтобы понять какое нормальное число знаков может быть в описании чтобы было читабельно и красиво и вообще нормально. это очень длинное название, прямо очень длинное очень приоче'},
204
+ 'title': {'value': 'asdadad'}
205
+ },
206
+ 'displayOptions': {},
207
+ 'displayMode': 'popup'
208
+ },
209
+ '$count': 1
210
+ });
211
+ });
212
+
213
+ app.post('/api/endUserNotifications/deepLinks', (req, res) => {
214
+ res.json({
215
+ '$error': null,
216
+ '$items': null,
217
+ '$value': 'subscribe_XXX',
218
+ '$count': 1
219
+ });
220
+ });
221
+
222
+ app.listen(port, () => {
223
+ console.log(`Application started on http://localhost:${port}`)
224
+ });
package/src/sdk/sdk.js CHANGED
@@ -16,14 +16,15 @@ export default class SDK {
16
16
  initWidget(config, preventViewCounting = false) {
17
17
  if (config && config.widgetId) {
18
18
  const widget = new Widget(config, this);
19
+
19
20
  this.widgets[config.widgetId] = widget.initialize();
20
21
  this.widgets[config.widgetId].then(widget => {
21
- Observer.trigger(EVENTS.WIDGET_INIT, {widgetId: config.widgetId});
22
-
23
- // First of all, this is a restriction on the count of views for textback settings page ( = for widget preview)
24
- if (preventViewCounting) return;
25
-
26
- this.countWidgetView(widget);
22
+ Observer.trigger(EVENTS.WIDGET_INIT, {widgetId: config.widgetId});
23
+
24
+ // First of all, this is a restriction on the count of views for textback settings page ( = for widget preview)
25
+ if (preventViewCounting) return;
26
+
27
+ this.countWidgetView(widget);
27
28
  }, err => console.error(err));
28
29
  return this.widgets[config.widgetId];
29
30
  } else {
@@ -1,15 +1,14 @@
1
- import UUID from 'uuid-js';
2
1
  import assign from 'lodash/assign';
2
+ import UUID from 'uuid-js';
3
3
 
4
- import apiErrorHandler from '../utils/apiErrorHandler.js';
4
+ import appInsights from '../utils/appInsights.js';
5
+ import constants from '../utils/constants.js';
6
+ import cookies from '../utils/cookies.js';
7
+ import find from '../utils/find.js';
5
8
  import loadConfig from '../utils/loadConfig.js';
6
9
  import loadDeepLink from '../utils/loadDeepLink.js';
7
10
  import loadSubscriptions from '../utils/loadSubscriptions.js';
8
- import cookies from '../utils/cookies.js';
9
- import constants from '../utils/constants.js';
10
11
  import parseQueryString from '../utils/parseQueryString.js';
11
- import find from '../utils/find.js';
12
- import appInsights from '../utils/appInsights.js';
13
12
 
14
13
  import channelsFactory from '../channels/factory.js';
15
14
 
@@ -133,7 +132,7 @@ export default class Widget {
133
132
  return this.channels.filter(channel => channel.enabled && !channel.hasError);
134
133
  }
135
134
 
136
- runWahunter(phoneNumber) {
135
+ runWahunter(phoneNumber, {captchaToken} = {}) {
137
136
  return fetch(`${this.initialConfig.apiPath}/wahunter`, {
138
137
  method: 'POST',
139
138
  headers: {
@@ -144,6 +143,7 @@ export default class Widget {
144
143
  phone: phoneNumber,
145
144
  insecureContext: this.insecureContext,
146
145
  deeplinkId: this.deeplink,
146
+ captchaToken
147
147
  }),
148
148
  }).then((resp) => {
149
149
  if (resp.ok) {
@@ -81,6 +81,7 @@ export default class Widget extends Component {
81
81
  insecureContext: this.data,
82
82
  secureContextToken: this.secureContextToken,
83
83
  overrideConfig: predefinedConfig,
84
+ captchaTest: this.captchaTest
84
85
  }, this.previewMode);
85
86
  }
86
87
 
@@ -119,7 +120,6 @@ export default class Widget extends Component {
119
120
  this.set({ error: err });
120
121
  return this;
121
122
  });
122
-
123
123
  widgetsStorage.setWidget(this.widgetId, widgetInitPromise);
124
124
  }
125
125
 
@@ -127,7 +127,8 @@ export default class Widget extends Component {
127
127
  return {
128
128
  widgetId: this.element.getAttribute('widget-id'),
129
129
  secureContextToken: this.element.getAttribute('secure-context-token'),
130
- apiPath: this.element.getAttribute('api-path') || config.apiPath
130
+ apiPath: this.element.getAttribute('api-path') || config.apiPath,
131
+ captchaTest: !!this.element.getAttribute('captcha-test')
131
132
  };
132
133
  }
133
134
 
@@ -3,24 +3,60 @@ import arrowIcon from '../../icons/paper-plane-arrow.svg';
3
3
  import waIcon from '../../icons/icon_whatsapp_new.svg';
4
4
  import iconTbLogo from '../../icons/tb-logo.svg';
5
5
 
6
- import './styles.scss';
6
+ import "./styles.scss";
7
+ import loadScript from "../../../sdk/utils/loadScript.js";
7
8
 
8
9
  const parsePhoneNumber = (phoneString) => phoneString.replace(/[^\d]/g, '');
9
10
 
10
11
  export default class Wahunter extends Component {
11
12
  constructor() {
12
13
  super(...arguments);
14
+ this.captcha = {};
13
15
  }
14
16
 
15
-
16
17
  render() {
17
18
  this.lang = this.widgetAPI.config.lang || this.parentElement.getAttribute('lang');
18
19
 
19
20
  super.render();
21
+ this.renderCaptcha();
20
22
  this.submitFormElem = this.element.querySelector(`.${Wahunter.tagName}__submit-form`);
21
23
  this.addListeners();
22
24
  }
23
25
 
26
+ renderCaptcha() {
27
+ const {
28
+ widgetAPI: {
29
+ config: { captcha },
30
+ },
31
+ } = this;
32
+ if (!captcha || !captcha.enabled || !captcha.siteKey) return;
33
+ const render = () => {
34
+ this.captcha.widgetId = window.smartCaptcha.render(
35
+ this.element.querySelector(`.smart-captcha`),
36
+ {
37
+ sitekey: captcha.siteKey,
38
+ invisible: true,
39
+ callback: (token) => {
40
+ this.captcha.token = token;
41
+ this.submit();
42
+ },
43
+ test: this.widgetAPI.initialConfig.captchaTest,
44
+ }
45
+ );
46
+ this.captcha.rendered = true;
47
+ };
48
+ if (!window.tbCaptchaLoadingCallbacks) {
49
+ window.tbCaptchaLoadingCallbacks = [];
50
+ window.onTbCaptchaLoad = () => {
51
+ window.tbCaptchaLoadingCallbacks.forEach((cb) => cb());
52
+ };
53
+ loadScript(
54
+ `https://smartcaptcha.yandexcloud.net/captcha.js?render=onload&onload=onTbCaptchaLoad`
55
+ );
56
+ }
57
+ window.tbCaptchaLoadingCallbacks.push(render);
58
+ }
59
+
24
60
  addListeners() {
25
61
  this.submitFormElem.addEventListener('submit', (e) => {
26
62
  e.preventDefault();
@@ -79,8 +115,12 @@ export default class Wahunter extends Component {
79
115
  `;
80
116
  }
81
117
 
82
-
83
118
  submit() {
119
+ let { token: captchaToken } = this.captcha;
120
+ if (this.captcha.rendered && !captchaToken) {
121
+ window.smartCaptcha.execute(this.captcha.widgetId);
122
+ return;
123
+ }
84
124
  const phoneNumber = +parsePhoneNumber(this.submitFormElem.phoneNumber.value);
85
125
 
86
126
  if (this.widgetAPI.config.displayMode !== 'inline') {
@@ -90,7 +130,7 @@ export default class Wahunter extends Component {
90
130
  this.changeSubmitFormState('pending');
91
131
 
92
132
  setTimeout(() => {
93
- this.widgetAPI.runWahunter(phoneNumber)
133
+ this.widgetAPI.runWahunter(phoneNumber, { captchaToken })
94
134
  .then(() => this.changeSubmitFormState('success'))
95
135
  .catch((error) => {
96
136
  if (error.status === 400) return this.changeSubmitFormState('notFound');
@@ -229,7 +269,7 @@ export default class Wahunter extends Component {
229
269
  </div>
230
270
  </button>
231
271
  </div>
232
-
272
+ <div class="smart-captcha"></div>
233
273
  <div class="${Wahunter.tagName}__submit-form-footer" style="${showWahunterAgreement ? '' : 'display:none'}">
234
274
  <label class="${Wahunter.tagName}__agreement">
235
275
  <input type="checkbox" required checked>