@suprsend/node-sdk 1.8.1 → 1.8.2

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.
@@ -1,22 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
11
  var _utils = require("./utils");
17
-
18
12
  var _language_codes = _interopRequireDefault(require("./language_codes"));
19
-
20
13
  // ---------- Identity keys
21
14
  var IDENT_KEY_EMAIL = "$email";
22
15
  var IDENT_KEY_SMS = "$sms";
@@ -33,7 +26,6 @@ var SUPER_PROPERTY_KEYS = ["$app_version_string", "$app_build_number", "$brand",
33
26
  var ALL_RESERVED_KEYS = [].concat(SUPER_PROPERTY_KEYS, OTHER_RESERVED_KEYS, IDENT_KEYS_ALL);
34
27
  var EMAIL_REGEX = /\S+@\S+\.\S+/;
35
28
  var MOBILE_REGEX = /^\+[0-9\s]+/;
36
-
37
29
  var _SubscriberInternalHelper = /*#__PURE__*/function () {
38
30
  function _SubscriberInternalHelper(distinct_id, workspace_key) {
39
31
  (0, _classCallCheck2["default"])(this, _SubscriberInternalHelper);
@@ -46,7 +38,6 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
46
38
  this.__errors = [];
47
39
  this.__info = [];
48
40
  }
49
-
50
41
  (0, _createClass2["default"])(_SubscriberInternalHelper, [{
51
42
  key: "reset",
52
43
  value: function reset() {
@@ -61,7 +52,6 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
61
52
  key: "get_identity_events",
62
53
  value: function get_identity_events() {
63
54
  var evt = this.__form_event();
64
-
65
55
  var ret_val = {
66
56
  errors: this.__errors,
67
57
  info: this.__info,
@@ -74,23 +64,18 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
74
64
  key: "__form_event",
75
65
  value: function __form_event() {
76
66
  var event = {};
77
-
78
67
  if (!(0, _utils.is_empty)(this.__dict_set)) {
79
68
  event["$set"] = this.__dict_set;
80
69
  }
81
-
82
70
  if (!(0, _utils.is_empty)(this.__dict_append)) {
83
71
  event["$append"] = this.__dict_append;
84
72
  }
85
-
86
73
  if (!(0, _utils.is_empty)(this.__dict_remove)) {
87
74
  event["$remove"] = this.__dict_remove;
88
75
  }
89
-
90
76
  if (!(0, _utils.is_empty)(this.__list_unset)) {
91
77
  event["$unset"] = this.__list_unset;
92
78
  }
93
-
94
79
  return event;
95
80
  }
96
81
  }, {
@@ -98,18 +83,13 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
98
83
  value: function __validate_key_basic(key, caller) {
99
84
  if (!(0, _utils.is_string)(key)) {
100
85
  this.__info.push("[".concat(caller, "] skipping key: ").concat(key, ". key must be a string"));
101
-
102
86
  return [key, false];
103
87
  }
104
-
105
88
  key = key.trim();
106
-
107
89
  if (!key) {
108
90
  this.__info.push("[".concat(caller, "] skipping key: empty string"));
109
-
110
91
  return [key, false];
111
92
  }
112
-
113
93
  return [key, true];
114
94
  }
115
95
  }, {
@@ -118,11 +98,9 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
118
98
  if (!ALL_RESERVED_KEYS.includes(key)) {
119
99
  if ((0, _utils.has_special_char)(key)) {
120
100
  this.__info.push("[".concat(caller, "] skipping key: ").concat(key, ". key starting with [$,ss_] are reserved"));
121
-
122
101
  return false;
123
102
  }
124
103
  }
125
-
126
104
  return true;
127
105
  }
128
106
  }, {
@@ -135,21 +113,17 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
135
113
  value: function _append_kv(key, value) {
136
114
  var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
137
115
  var caller = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "append";
138
-
139
116
  var _this$__validate_key_ = this.__validate_key_basic(key, caller),
140
- _this$__validate_key_2 = (0, _slicedToArray2["default"])(_this$__validate_key_, 2),
141
- validated_key = _this$__validate_key_2[0],
142
- is_k_valid = _this$__validate_key_2[1];
143
-
117
+ _this$__validate_key_2 = (0, _slicedToArray2["default"])(_this$__validate_key_, 2),
118
+ validated_key = _this$__validate_key_2[0],
119
+ is_k_valid = _this$__validate_key_2[1];
144
120
  if (!is_k_valid) {
145
121
  return;
146
122
  }
147
-
148
123
  if (this.__is_identity_key(validated_key)) {
149
124
  this.__add_identity(validated_key, value, args, caller);
150
125
  } else {
151
126
  var _is_k_valid = this.__validate_key_prefix(validated_key, caller);
152
-
153
127
  if (_is_k_valid) {
154
128
  this.__dict_append[validated_key] = value;
155
129
  }
@@ -160,21 +134,17 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
160
134
  value: function _remove_kv(key, value) {
161
135
  var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
162
136
  var caller = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "remove";
163
-
164
137
  var _this$__validate_key_3 = this.__validate_key_basic(key, caller),
165
- _this$__validate_key_4 = (0, _slicedToArray2["default"])(_this$__validate_key_3, 2),
166
- validated_key = _this$__validate_key_4[0],
167
- is_k_valid = _this$__validate_key_4[1];
168
-
138
+ _this$__validate_key_4 = (0, _slicedToArray2["default"])(_this$__validate_key_3, 2),
139
+ validated_key = _this$__validate_key_4[0],
140
+ is_k_valid = _this$__validate_key_4[1];
169
141
  if (!is_k_valid) {
170
142
  return;
171
143
  }
172
-
173
144
  if (this.__is_identity_key(validated_key)) {
174
145
  this.__remove_identity(validated_key, value, args, caller);
175
146
  } else {
176
147
  var _is_k_valid2 = this.__validate_key_prefix(validated_key, caller);
177
-
178
148
  if (_is_k_valid2) {
179
149
  this.__dict_remove[validated_key] = value;
180
150
  }
@@ -184,16 +154,13 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
184
154
  key: "_unset_k",
185
155
  value: function _unset_k(key) {
186
156
  var caller = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unset";
187
-
188
157
  var _this$__validate_key_5 = this.__validate_key_basic(key, caller),
189
- _this$__validate_key_6 = (0, _slicedToArray2["default"])(_this$__validate_key_5, 2),
190
- validated_key = _this$__validate_key_6[0],
191
- is_k_valid = _this$__validate_key_6[1];
192
-
158
+ _this$__validate_key_6 = (0, _slicedToArray2["default"])(_this$__validate_key_5, 2),
159
+ validated_key = _this$__validate_key_6[0],
160
+ is_k_valid = _this$__validate_key_6[1];
193
161
  if (!is_k_valid) {
194
162
  return;
195
163
  }
196
-
197
164
  this.__list_unset.push(validated_key);
198
165
  }
199
166
  }, {
@@ -201,53 +168,36 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
201
168
  value: function _set_preferred_language(lang_code, caller) {
202
169
  if (!_language_codes["default"].includes(lang_code)) {
203
170
  this.__info.push("[".concat(caller, "] invalid value ").concat(lang_code));
204
-
205
171
  return;
206
172
  }
207
-
208
173
  this.__dict_set[KEY_PREFERRED_LANGUAGE] = lang_code;
209
174
  }
210
175
  }, {
211
176
  key: "__add_identity",
212
177
  value: function __add_identity(key, value, args, caller) {
213
178
  var new_caller = "".concat(caller, ":").concat(key);
214
-
215
179
  switch (key) {
216
180
  case IDENT_KEY_EMAIL:
217
181
  this._add_email(value, new_caller);
218
-
219
182
  break;
220
-
221
183
  case IDENT_KEY_SMS:
222
184
  this._add_sms(value, new_caller);
223
-
224
185
  break;
225
-
226
186
  case IDENT_KEY_WHATSAPP:
227
187
  this._add_whatsapp(value, new_caller);
228
-
229
188
  break;
230
-
231
189
  case IDENT_KEY_ANDROIDPUSH:
232
190
  this._add_androidpush(value, args[KEY_PUSHVENDOR], new_caller);
233
-
234
191
  break;
235
-
236
192
  case IDENT_KEY_IOSPUSH:
237
193
  this._add_iospush(value, args[KEY_PUSHVENDOR], new_caller);
238
-
239
194
  break;
240
-
241
195
  case IDENT_KEY_WEBPUSH:
242
196
  this._add_webpush(value, args[KEY_PUSHVENDOR], new_caller);
243
-
244
197
  break;
245
-
246
198
  case IDENT_KEY_SLACK:
247
199
  this._add_slack(value, caller);
248
-
249
200
  break;
250
-
251
201
  default:
252
202
  break;
253
203
  }
@@ -256,43 +206,28 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
256
206
  key: "__remove_identity",
257
207
  value: function __remove_identity(key, value, args, caller) {
258
208
  var new_caller = "".concat(caller, ":").concat(key);
259
-
260
209
  switch (key) {
261
210
  case IDENT_KEY_EMAIL:
262
211
  this._remove_email(value, new_caller);
263
-
264
212
  break;
265
-
266
213
  case IDENT_KEY_SMS:
267
214
  this._remove_sms(value, new_caller);
268
-
269
215
  break;
270
-
271
216
  case IDENT_KEY_WHATSAPP:
272
217
  this._remove_whatsapp(value, new_caller);
273
-
274
218
  break;
275
-
276
219
  case IDENT_KEY_ANDROIDPUSH:
277
220
  this._remove_androidpush(value, args[KEY_PUSHVENDOR], new_caller);
278
-
279
221
  break;
280
-
281
222
  case IDENT_KEY_IOSPUSH:
282
223
  this._remove_iospush(value, args[KEY_PUSHVENDOR], new_caller);
283
-
284
224
  break;
285
-
286
225
  case IDENT_KEY_WEBPUSH:
287
226
  this._remove_webpush(value, args[KEY_PUSHVENDOR], new_caller);
288
-
289
227
  break;
290
-
291
228
  case IDENT_KEY_SLACK:
292
229
  this._remove_slack(val, caller);
293
-
294
230
  break;
295
-
296
231
  default:
297
232
  break;
298
233
  }
@@ -301,197 +236,162 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
301
236
  key: "__check_ident_val_string",
302
237
  value: function __check_ident_val_string(value, caller) {
303
238
  var message = "value must a string with proper value";
304
-
305
239
  if (!(0, _utils.is_string)(value)) {
306
240
  this.__errors.push("[".concat(caller, "] ").concat(message));
307
-
308
241
  return [value, false];
309
242
  }
310
-
311
243
  value = value.trim();
312
-
313
244
  if (!value) {
314
245
  this.__errors.push("[".concat(caller, "] ").concat(message));
315
-
316
246
  return [value, false];
317
247
  }
318
-
319
248
  return [value, true];
320
- } // email methods
249
+ }
321
250
 
251
+ // email methods
322
252
  }, {
323
253
  key: "__validate_email",
324
254
  value: function __validate_email(value, caller) {
325
255
  var _this$__check_ident_v = this.__check_ident_val_string(value, caller),
326
- _this$__check_ident_v2 = (0, _slicedToArray2["default"])(_this$__check_ident_v, 2),
327
- email = _this$__check_ident_v2[0],
328
- is_valid = _this$__check_ident_v2[1];
329
-
256
+ _this$__check_ident_v2 = (0, _slicedToArray2["default"])(_this$__check_ident_v, 2),
257
+ email = _this$__check_ident_v2[0],
258
+ is_valid = _this$__check_ident_v2[1];
330
259
  if (!is_valid) {
331
260
  return [email, false];
332
261
  }
333
-
334
262
  var message = "value in email format required. e.g. user@example.com";
335
263
  var min_length = 6;
336
264
  var max_length = 127;
337
265
  var is_valid_email = EMAIL_REGEX.test(email);
338
-
339
266
  if (!is_valid_email) {
340
267
  this.__errors.push("[".concat(caller, "] invalid value ").concat(email, ". ").concat(message));
341
-
342
268
  return [email, false];
343
269
  }
344
-
345
270
  if (email.length < min_length || email.length > max_length) {
346
271
  this.__errors.push("[".concat(caller, "] invalid value ").concat(email, ". must be 6 <= email.length <= 127"));
347
-
348
272
  return [email, false];
349
273
  }
350
-
351
274
  return [email, true];
352
275
  }
353
276
  }, {
354
277
  key: "_add_email",
355
278
  value: function _add_email(email, caller) {
356
279
  var _this$__validate_emai = this.__validate_email(email, caller),
357
- _this$__validate_emai2 = (0, _slicedToArray2["default"])(_this$__validate_emai, 2),
358
- value = _this$__validate_emai2[0],
359
- is_valid = _this$__validate_emai2[1];
360
-
280
+ _this$__validate_emai2 = (0, _slicedToArray2["default"])(_this$__validate_emai, 2),
281
+ value = _this$__validate_emai2[0],
282
+ is_valid = _this$__validate_emai2[1];
361
283
  if (!is_valid) {
362
284
  return;
363
285
  }
364
-
365
286
  this.__dict_append[IDENT_KEY_EMAIL] = value;
366
287
  }
367
288
  }, {
368
289
  key: "_remove_email",
369
290
  value: function _remove_email(email, caller) {
370
291
  var _this$__validate_emai3 = this.__validate_email(email, caller),
371
- _this$__validate_emai4 = (0, _slicedToArray2["default"])(_this$__validate_emai3, 2),
372
- value = _this$__validate_emai4[0],
373
- is_valid = _this$__validate_emai4[1];
374
-
292
+ _this$__validate_emai4 = (0, _slicedToArray2["default"])(_this$__validate_emai3, 2),
293
+ value = _this$__validate_emai4[0],
294
+ is_valid = _this$__validate_emai4[1];
375
295
  if (!is_valid) {
376
296
  return;
377
297
  }
378
-
379
298
  this.__dict_remove[IDENT_KEY_EMAIL] = value;
380
- } // mobile methods
299
+ }
381
300
 
301
+ // mobile methods
382
302
  }, {
383
303
  key: "__validate_mobile_no",
384
304
  value: function __validate_mobile_no(value, caller) {
385
305
  var _this$__check_ident_v3 = this.__check_ident_val_string(value, caller),
386
- _this$__check_ident_v4 = (0, _slicedToArray2["default"])(_this$__check_ident_v3, 2),
387
- mobile = _this$__check_ident_v4[0],
388
- is_valid = _this$__check_ident_v4[1];
389
-
306
+ _this$__check_ident_v4 = (0, _slicedToArray2["default"])(_this$__check_ident_v3, 2),
307
+ mobile = _this$__check_ident_v4[0],
308
+ is_valid = _this$__check_ident_v4[1];
390
309
  if (!is_valid) {
391
310
  return [mobile, false];
392
311
  }
393
-
394
312
  var message = "number must start with + and must contain country code. e.g. +41446681800";
395
313
  var min_length = 8;
396
314
  var is_valid_mobile = MOBILE_REGEX.test(mobile);
397
-
398
315
  if (!is_valid_mobile) {
399
316
  this.__errors.push("[".concat(caller, "] invalid value ").concat(mobile, ". ").concat(message));
400
-
401
317
  return [mobile, false];
402
318
  }
403
-
404
319
  if (mobile.length < min_length) {
405
320
  this.__errors.push("[".concat(caller, "] invalid value ").concat(mobile, ". mobile_no.length must be >= 8"));
406
-
407
321
  return [mobile, false];
408
322
  }
409
-
410
323
  return [mobile, true];
411
324
  }
412
325
  }, {
413
326
  key: "_add_sms",
414
327
  value: function _add_sms(mobile_no, caller) {
415
328
  var _this$__validate_mobi = this.__validate_mobile_no(mobile_no, caller),
416
- _this$__validate_mobi2 = (0, _slicedToArray2["default"])(_this$__validate_mobi, 2),
417
- value = _this$__validate_mobi2[0],
418
- is_valid = _this$__validate_mobi2[1];
419
-
329
+ _this$__validate_mobi2 = (0, _slicedToArray2["default"])(_this$__validate_mobi, 2),
330
+ value = _this$__validate_mobi2[0],
331
+ is_valid = _this$__validate_mobi2[1];
420
332
  if (!is_valid) {
421
333
  return;
422
334
  }
423
-
424
335
  this.__dict_append[IDENT_KEY_SMS] = value;
425
336
  }
426
337
  }, {
427
338
  key: "_remove_sms",
428
339
  value: function _remove_sms(mobile_no, caller) {
429
340
  var _this$__validate_mobi3 = this.__validate_mobile_no(mobile_no, caller),
430
- _this$__validate_mobi4 = (0, _slicedToArray2["default"])(_this$__validate_mobi3, 2),
431
- value = _this$__validate_mobi4[0],
432
- is_valid = _this$__validate_mobi4[1];
433
-
341
+ _this$__validate_mobi4 = (0, _slicedToArray2["default"])(_this$__validate_mobi3, 2),
342
+ value = _this$__validate_mobi4[0],
343
+ is_valid = _this$__validate_mobi4[1];
434
344
  if (!is_valid) {
435
345
  return;
436
346
  }
437
-
438
347
  this.__dict_remove[IDENT_KEY_SMS] = value;
439
348
  }
440
349
  }, {
441
350
  key: "_add_whatsapp",
442
351
  value: function _add_whatsapp(mobile_no, caller) {
443
352
  var _this$__validate_mobi5 = this.__validate_mobile_no(mobile_no, caller),
444
- _this$__validate_mobi6 = (0, _slicedToArray2["default"])(_this$__validate_mobi5, 2),
445
- value = _this$__validate_mobi6[0],
446
- is_valid = _this$__validate_mobi6[1];
447
-
353
+ _this$__validate_mobi6 = (0, _slicedToArray2["default"])(_this$__validate_mobi5, 2),
354
+ value = _this$__validate_mobi6[0],
355
+ is_valid = _this$__validate_mobi6[1];
448
356
  if (!is_valid) {
449
357
  return;
450
358
  }
451
-
452
359
  this.__dict_append[IDENT_KEY_WHATSAPP] = value;
453
360
  }
454
361
  }, {
455
362
  key: "_remove_whatsapp",
456
363
  value: function _remove_whatsapp(mobile_no, caller) {
457
364
  var _this$__validate_mobi7 = this.__validate_mobile_no(mobile_no, caller),
458
- _this$__validate_mobi8 = (0, _slicedToArray2["default"])(_this$__validate_mobi7, 2),
459
- value = _this$__validate_mobi8[0],
460
- is_valid = _this$__validate_mobi8[1];
461
-
365
+ _this$__validate_mobi8 = (0, _slicedToArray2["default"])(_this$__validate_mobi7, 2),
366
+ value = _this$__validate_mobi8[0],
367
+ is_valid = _this$__validate_mobi8[1];
462
368
  if (!is_valid) {
463
369
  return;
464
370
  }
465
-
466
371
  this.__dict_remove[IDENT_KEY_WHATSAPP] = value;
467
- } // android push methods
372
+ }
468
373
 
374
+ // android push methods
469
375
  }, {
470
376
  key: "__check_androidpush_value",
471
377
  value: function __check_androidpush_value(value, provider, caller) {
472
378
  var _this$__check_ident_v5 = this.__check_ident_val_string(value, caller),
473
- _this$__check_ident_v6 = (0, _slicedToArray2["default"])(_this$__check_ident_v5, 2),
474
- push_token = _this$__check_ident_v6[0],
475
- is_valid = _this$__check_ident_v6[1];
476
-
379
+ _this$__check_ident_v6 = (0, _slicedToArray2["default"])(_this$__check_ident_v5, 2),
380
+ push_token = _this$__check_ident_v6[0],
381
+ is_valid = _this$__check_ident_v6[1];
477
382
  if (!is_valid) {
478
383
  return [push_token, provider, false];
479
384
  }
480
-
481
385
  if (!provider) {
482
386
  provider = "fcm";
483
387
  }
484
-
485
388
  if (typeof provider === "string") {
486
389
  provider = provider.toLocaleLowerCase();
487
390
  }
488
-
489
391
  if (!["fcm", "xiaomi", "oppo"].includes(provider)) {
490
392
  this.__errors.push("[".concat(caller, "] unsupported androidpush provider ").concat(provider));
491
-
492
393
  return [push_token, provider, false];
493
394
  }
494
-
495
395
  return [push_token, provider, true];
496
396
  }
497
397
  }, {
@@ -499,17 +399,14 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
499
399
  value: function _add_androidpush(push_token) {
500
400
  var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "fcm";
501
401
  var caller = arguments.length > 2 ? arguments[2] : undefined;
502
-
503
402
  var _this$__check_android = this.__check_androidpush_value(push_token, provider, caller),
504
- _this$__check_android2 = (0, _slicedToArray2["default"])(_this$__check_android, 3),
505
- value = _this$__check_android2[0],
506
- vendor = _this$__check_android2[1],
507
- is_valid = _this$__check_android2[2];
508
-
403
+ _this$__check_android2 = (0, _slicedToArray2["default"])(_this$__check_android, 3),
404
+ value = _this$__check_android2[0],
405
+ vendor = _this$__check_android2[1],
406
+ is_valid = _this$__check_android2[2];
509
407
  if (!is_valid) {
510
408
  return;
511
409
  }
512
-
513
410
  this.__dict_append[IDENT_KEY_ANDROIDPUSH] = value;
514
411
  this.__dict_append[KEY_PUSHVENDOR] = vendor;
515
412
  }
@@ -518,47 +415,39 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
518
415
  value: function _remove_androidpush(push_token) {
519
416
  var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "fcm";
520
417
  var caller = "remove_androidpush";
521
-
522
418
  var _this$__check_android3 = this.__check_androidpush_value(push_token, provider, caller),
523
- _this$__check_android4 = (0, _slicedToArray2["default"])(_this$__check_android3, 3),
524
- value = _this$__check_android4[0],
525
- vendor = _this$__check_android4[1],
526
- is_valid = _this$__check_android4[2];
527
-
419
+ _this$__check_android4 = (0, _slicedToArray2["default"])(_this$__check_android3, 3),
420
+ value = _this$__check_android4[0],
421
+ vendor = _this$__check_android4[1],
422
+ is_valid = _this$__check_android4[2];
528
423
  if (!is_valid) {
529
424
  return;
530
425
  }
531
-
532
426
  this.__dict_remove[IDENT_KEY_ANDROIDPUSH] = value;
533
427
  this.__dict_remove[KEY_PUSHVENDOR] = vendor;
534
- } // ios push methods
428
+ }
535
429
 
430
+ // ios push methods
536
431
  }, {
537
432
  key: "__check_iospush_value",
538
433
  value: function __check_iospush_value(value, provider, caller) {
539
434
  var _this$__check_ident_v7 = this.__check_ident_val_string(value, caller),
540
- _this$__check_ident_v8 = (0, _slicedToArray2["default"])(_this$__check_ident_v7, 2),
541
- push_token = _this$__check_ident_v8[0],
542
- is_valid = _this$__check_ident_v8[1];
543
-
435
+ _this$__check_ident_v8 = (0, _slicedToArray2["default"])(_this$__check_ident_v7, 2),
436
+ push_token = _this$__check_ident_v8[0],
437
+ is_valid = _this$__check_ident_v8[1];
544
438
  if (!is_valid) {
545
439
  return [push_token, provider, false];
546
440
  }
547
-
548
441
  if (!provider) {
549
442
  provider = "apns";
550
443
  }
551
-
552
444
  if (typeof provider === "string") {
553
445
  provider = provider.toLocaleLowerCase();
554
446
  }
555
-
556
447
  if (!["apns"].includes(provider)) {
557
448
  this.__errors.push("[".concat(caller, "] unsupported iospush provider ").concat(provider));
558
-
559
449
  return [push_token, provider, false];
560
450
  }
561
-
562
451
  return [push_token, provider, true];
563
452
  }
564
453
  }, {
@@ -566,17 +455,14 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
566
455
  value: function _add_iospush(push_token) {
567
456
  var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "apns";
568
457
  var caller = arguments.length > 2 ? arguments[2] : undefined;
569
-
570
458
  var _this$__check_iospush = this.__check_iospush_value(push_token, provider, caller),
571
- _this$__check_iospush2 = (0, _slicedToArray2["default"])(_this$__check_iospush, 3),
572
- value = _this$__check_iospush2[0],
573
- vendor = _this$__check_iospush2[1],
574
- is_valid = _this$__check_iospush2[2];
575
-
459
+ _this$__check_iospush2 = (0, _slicedToArray2["default"])(_this$__check_iospush, 3),
460
+ value = _this$__check_iospush2[0],
461
+ vendor = _this$__check_iospush2[1],
462
+ is_valid = _this$__check_iospush2[2];
576
463
  if (!is_valid) {
577
464
  return;
578
465
  }
579
-
580
466
  this.__dict_append[IDENT_KEY_IOSPUSH] = value;
581
467
  this.__dict_append[KEY_PUSHVENDOR] = vendor;
582
468
  }
@@ -585,44 +471,36 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
585
471
  value: function _remove_iospush(push_token) {
586
472
  var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "apns";
587
473
  var caller = arguments.length > 2 ? arguments[2] : undefined;
588
-
589
474
  var _this$__check_iospush3 = this.__check_iospush_value(push_token, provider, caller),
590
- _this$__check_iospush4 = (0, _slicedToArray2["default"])(_this$__check_iospush3, 3),
591
- value = _this$__check_iospush4[0],
592
- vendor = _this$__check_iospush4[1],
593
- is_valid = _this$__check_iospush4[2];
594
-
475
+ _this$__check_iospush4 = (0, _slicedToArray2["default"])(_this$__check_iospush3, 3),
476
+ value = _this$__check_iospush4[0],
477
+ vendor = _this$__check_iospush4[1],
478
+ is_valid = _this$__check_iospush4[2];
595
479
  if (!is_valid) {
596
480
  return;
597
481
  }
598
-
599
482
  this.__dict_remove[IDENT_KEY_IOSPUSH] = value;
600
483
  this.__dict_remove[KEY_PUSHVENDOR] = vendor;
601
- } // web push methods
484
+ }
602
485
 
486
+ // web push methods
603
487
  }, {
604
488
  key: "__check_webpush_dict",
605
489
  value: function __check_webpush_dict(value, provider, caller) {
606
490
  if (!(0, _utils.is_object)(value)) {
607
491
  this.__errors.push("[".concat(caller, "] value must be a valid dict representing webpush-token"));
608
-
609
492
  return [value, provider, false];
610
493
  }
611
-
612
494
  if (!provider) {
613
495
  provider = "vapid";
614
496
  }
615
-
616
497
  if (typeof provider === "string") {
617
498
  provider = provider.toLocaleLowerCase();
618
499
  }
619
-
620
500
  if (!["vapid"].includes(provider)) {
621
501
  this.__errors.push("[".concat(caller, "] unsupported webpush provider ").concat(provider));
622
-
623
502
  return [value, provider, false];
624
503
  }
625
-
626
504
  return [value, provider, true];
627
505
  }
628
506
  }, {
@@ -630,17 +508,14 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
630
508
  value: function _add_webpush(push_token) {
631
509
  var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "vapid";
632
510
  var caller = arguments.length > 2 ? arguments[2] : undefined;
633
-
634
511
  var _this$__check_webpush = this.__check_webpush_dict(push_token, provider, caller),
635
- _this$__check_webpush2 = (0, _slicedToArray2["default"])(_this$__check_webpush, 3),
636
- value = _this$__check_webpush2[0],
637
- vendor = _this$__check_webpush2[1],
638
- is_valid = _this$__check_webpush2[2];
639
-
512
+ _this$__check_webpush2 = (0, _slicedToArray2["default"])(_this$__check_webpush, 3),
513
+ value = _this$__check_webpush2[0],
514
+ vendor = _this$__check_webpush2[1],
515
+ is_valid = _this$__check_webpush2[2];
640
516
  if (!is_valid) {
641
517
  return;
642
518
  }
643
-
644
519
  this.__dict_append[IDENT_KEY_WEBPUSH] = value;
645
520
  this.__dict_append[KEY_PUSHVENDOR] = vendor;
646
521
  }
@@ -649,17 +524,14 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
649
524
  value: function _remove_webpush(push_token) {
650
525
  var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "vapid";
651
526
  var caller = arguments.length > 2 ? arguments[2] : undefined;
652
-
653
527
  var _this$__check_webpush3 = this.__check_webpush_dict(push_token, provider, caller),
654
- _this$__check_webpush4 = (0, _slicedToArray2["default"])(_this$__check_webpush3, 3),
655
- value = _this$__check_webpush4[0],
656
- vendor = _this$__check_webpush4[1],
657
- is_valid = _this$__check_webpush4[2];
658
-
528
+ _this$__check_webpush4 = (0, _slicedToArray2["default"])(_this$__check_webpush3, 3),
529
+ value = _this$__check_webpush4[0],
530
+ vendor = _this$__check_webpush4[1],
531
+ is_valid = _this$__check_webpush4[2];
659
532
  if (!is_valid) {
660
533
  return;
661
534
  }
662
-
663
535
  this.__dict_remove[IDENT_KEY_WEBPUSH] = value;
664
536
  this.__dict_remove[KEY_PUSHVENDOR] = vendor;
665
537
  }
@@ -667,10 +539,8 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
667
539
  key: "__check_slack_dict",
668
540
  value: function __check_slack_dict(value, caller) {
669
541
  var msg = "value must be a valid dict/json with proper keys";
670
-
671
542
  if (!(value && value instanceof Object)) {
672
543
  this.__errors.push("[".concat(caller, "] ").concat(msg));
673
-
674
544
  return [value, false];
675
545
  } else {
676
546
  return [value, true];
@@ -680,33 +550,28 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
680
550
  key: "_add_slack",
681
551
  value: function _add_slack(value, caller) {
682
552
  var _this$__check_slack_d = this.__check_slack_dict(value, caller),
683
- _this$__check_slack_d2 = (0, _slicedToArray2["default"])(_this$__check_slack_d, 2),
684
- validated_value = _this$__check_slack_d2[0],
685
- is_valid = _this$__check_slack_d2[1];
686
-
553
+ _this$__check_slack_d2 = (0, _slicedToArray2["default"])(_this$__check_slack_d, 2),
554
+ validated_value = _this$__check_slack_d2[0],
555
+ is_valid = _this$__check_slack_d2[1];
687
556
  if (!is_valid) {
688
557
  return;
689
558
  }
690
-
691
559
  this.__dict_append[IDENT_KEY_SLACK] = validated_value;
692
560
  }
693
561
  }, {
694
562
  key: "_remove_slack",
695
563
  value: function _remove_slack(value, caller) {
696
564
  var _this$__check_slack_d3 = this.__check_slack_dict(value, caller),
697
- _this$__check_slack_d4 = (0, _slicedToArray2["default"])(_this$__check_slack_d3, 2),
698
- validated_value = _this$__check_slack_d4[0],
699
- is_valid = _this$__check_slack_d4[1];
700
-
565
+ _this$__check_slack_d4 = (0, _slicedToArray2["default"])(_this$__check_slack_d3, 2),
566
+ validated_value = _this$__check_slack_d4[0],
567
+ is_valid = _this$__check_slack_d4[1];
701
568
  if (!is_valid) {
702
569
  return;
703
570
  }
704
-
705
571
  this.__dict_remove[IDENT_KEY_SLACK] = validated_value;
706
572
  }
707
573
  }]);
708
574
  return _SubscriberInternalHelper;
709
575
  }();
710
-
711
576
  exports["default"] = _SubscriberInternalHelper;
712
577
  module.exports = exports.default;