@suprsend/node-sdk 1.1.2 → 1.3.0

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.
@@ -75,18 +75,7 @@ var _BulkWorkflowsChunk = /*#__PURE__*/function () {
75
75
  (0, _createClass2["default"])(_BulkWorkflowsChunk, [{
76
76
  key: "__get_url",
77
77
  value: function __get_url() {
78
- var url_template = "/trigger/";
79
-
80
- if (this.config.include_signature_param) {
81
- if (this.config.auth_enabled) {
82
- url_template = url_template + "?verify=true";
83
- } else {
84
- url_template = url_template + "?verify=false";
85
- }
86
- }
87
-
88
- var url_formatted = "".concat(this.config.base_url).concat(this.config.workspace_key).concat(url_template);
89
- return url_formatted;
78
+ return "".concat(this.config.base_url).concat(this.config.workspace_key, "/trigger/");
90
79
  }
91
80
  }, {
92
81
  key: "__common_headers",
@@ -159,20 +148,16 @@ var _BulkWorkflowsChunk = /*#__PURE__*/function () {
159
148
  switch (_context.prev = _context.next) {
160
149
  case 0:
161
150
  headers = _objectSpread(_objectSpread({}, this.__headers), this.__dynamic_headers());
162
- content_text = JSON.stringify(this.__chunk); // Based on whether signature is required or not, add Authorization header
163
-
164
- if (this.config.auth_enabled) {
165
- signature = (0, _signature["default"])(this.__url, "POST", content_text, headers, this.config.workspace_secret);
166
- headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
167
- }
168
-
169
- _context.prev = 3;
170
- _context.next = 6;
151
+ content_text = JSON.stringify(this.__chunk);
152
+ signature = (0, _signature["default"])(this.__url, "POST", content_text, headers, this.config.workspace_secret);
153
+ headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
154
+ _context.prev = 4;
155
+ _context.next = 7;
171
156
  return _axios["default"].post(this.__url, content_text, {
172
157
  headers: headers
173
158
  });
174
159
 
175
- case 6:
160
+ case 7:
176
161
  response = _context.sent;
177
162
  ok_response = Math.floor(response.status / 100) == 2;
178
163
 
@@ -202,12 +187,12 @@ var _BulkWorkflowsChunk = /*#__PURE__*/function () {
202
187
  };
203
188
  }
204
189
 
205
- _context.next = 15;
190
+ _context.next = 16;
206
191
  break;
207
192
 
208
- case 11:
209
- _context.prev = 11;
210
- _context.t0 = _context["catch"](3);
193
+ case 12:
194
+ _context.prev = 12;
195
+ _context.t0 = _context["catch"](4);
211
196
  error_status = _context.t0.status || 500;
212
197
  return _context.abrupt("return", {
213
198
  status: "fail",
@@ -225,12 +210,12 @@ var _BulkWorkflowsChunk = /*#__PURE__*/function () {
225
210
  })
226
211
  });
227
212
 
228
- case 15:
213
+ case 16:
229
214
  case "end":
230
215
  return _context.stop();
231
216
  }
232
217
  }
233
- }, _callee, this, [[3, 11]]);
218
+ }, _callee, this, [[4, 12]]);
234
219
  }));
235
220
 
236
221
  function trigger() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suprsend/node-sdk",
3
- "version": "1.1.2",
3
+ "version": "1.3.0",
4
4
  "description": "Suprsend Node SDK to trigger workflow from backend",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/constants.js CHANGED
@@ -26,7 +26,7 @@ export const ALLOW_ATTACHMENTS_IN_BULK_API = true;
26
26
  export const ATTACHMENT_UPLOAD_ENABLED = false;
27
27
 
28
28
  // -- single Identity event limit
29
- export const IDENTITY_SINGLE_EVENT_MAX_APPARENT_SIZE_IN_BYTES = 2 * 1024;
30
- export const IDENTITY_SINGLE_EVENT_MAX_APPARENT_SIZE_IN_BYTES_READABLE = "2KB";
29
+ export const IDENTITY_SINGLE_EVENT_MAX_APPARENT_SIZE_IN_BYTES = 10 * 1024;
30
+ export const IDENTITY_SINGLE_EVENT_MAX_APPARENT_SIZE_IN_BYTES_READABLE = "10KB";
31
31
 
32
32
  export const MAX_IDENTITY_EVENTS_IN_BULK_API = 400;
package/src/event.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import {
2
- is_object,
3
2
  is_string,
4
3
  SuprsendError,
5
4
  has_special_char,
@@ -130,15 +129,7 @@ export class EventCollector {
130
129
  }
131
130
 
132
131
  __get_url() {
133
- let url_template = "event/";
134
- if (this.config.include_signature_param) {
135
- if (this.config.auth_enabled) {
136
- url_template = url_template + "?verify=true";
137
- } else {
138
- url_template = url_template + "?verify=false";
139
- }
140
- }
141
- return `${this.config.base_url}${url_template}`;
132
+ return `${this.config.base_url}event/`;
142
133
  }
143
134
 
144
135
  __common_headers() {
@@ -161,16 +152,15 @@ export class EventCollector {
161
152
  async send(event) {
162
153
  const headers = { ...this.__headers, ...this.__dynamic_headers() };
163
154
  const content_text = JSON.stringify(event);
164
- if (this.config.auth_enabled) {
165
- const signature = get_request_signature(
166
- this.__url,
167
- "POST",
168
- content_text,
169
- headers,
170
- this.config.workspace_secret
171
- );
172
- headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
173
- }
155
+ const signature = get_request_signature(
156
+ this.__url,
157
+ "POST",
158
+ content_text,
159
+ headers,
160
+ this.config.workspace_secret
161
+ );
162
+ headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
163
+
174
164
  try {
175
165
  const response = await axios.post(this.__url, content_text, { headers });
176
166
  const ok_response = Math.floor(response.status / 100) == 2;
@@ -36,15 +36,7 @@ class _BulkEventsChunk {
36
36
  }
37
37
 
38
38
  __get_url() {
39
- let url_template = "event/";
40
- if (this.config.include_signature_param) {
41
- if (this.config.auth_enabled) {
42
- url_template = url_template + "?verify=true";
43
- } else {
44
- url_template = url_template + "?verify=false";
45
- }
46
- }
47
- const url_formatted = `${this.config.base_url}${url_template}`;
39
+ const url_formatted = `${this.config.base_url}event/`;
48
40
  return url_formatted;
49
41
  }
50
42
 
@@ -105,17 +97,16 @@ class _BulkEventsChunk {
105
97
  async trigger() {
106
98
  const headers = { ...this.__headers, ...this.__dynamic_headers() };
107
99
  const content_text = JSON.stringify(this.__chunk);
108
- // Based on whether signature is required or not, add Authorization header
109
- if (this.config.auth_enabled) {
110
- const signature = get_request_signature(
111
- this.__url,
112
- "POST",
113
- content_text,
114
- headers,
115
- this.config.workspace_secret
116
- );
117
- headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
118
- }
100
+
101
+ const signature = get_request_signature(
102
+ this.__url,
103
+ "POST",
104
+ content_text,
105
+ headers,
106
+ this.config.workspace_secret
107
+ );
108
+ headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
109
+
119
110
  try {
120
111
  const response = await axios.post(this.__url, content_text, { headers });
121
112
  const ok_response = Math.floor(response.status / 100) == 2;
package/src/index.js CHANGED
@@ -6,6 +6,10 @@ import Event, { EventCollector } from "./event";
6
6
  import { BulkEventsFactory } from "./events_bulk";
7
7
  import SubscriberFactory from "./subscriber";
8
8
  import BulkSubscribersFactory from "./subscribers_bulk";
9
+ import {
10
+ SubscribersListApi,
11
+ SubscribersListBroadcast,
12
+ } from "./subscribers_list";
9
13
  import BrandsApi from "./brands";
10
14
  import { DEFAULT_UAT_URL, DEFAULT_URL } from "./constants";
11
15
 
@@ -18,8 +22,6 @@ class Suprsend {
18
22
  this.config = config;
19
23
 
20
24
  this.base_url = this._get_url(config.base_url);
21
- this.auth_enabled = config.auth_enabled !== false;
22
- this.include_signature_param = config.include_signature_param !== false;
23
25
  this.user_agent = `suprsend/${
24
26
  package_json.version
25
27
  };node/${process.version.slice(1)}`;
@@ -34,6 +36,7 @@ class Suprsend {
34
36
  this._user = new SubscriberFactory(this);
35
37
 
36
38
  this.brands = new BrandsApi(this);
39
+ this.subscribers_list = new SubscribersListApi(this);
37
40
 
38
41
  this._validate();
39
42
  }
@@ -126,4 +129,4 @@ class Suprsend {
126
129
  }
127
130
  }
128
131
 
129
- export { Suprsend, Event, Workflow };
132
+ export { Suprsend, Event, Workflow, SubscribersListBroadcast };
@@ -0,0 +1,70 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "http://github.com/suprsend/suprsend-node-sdk/request_json/list_broadcast.json",
4
+ "title": "list_broadcast_request",
5
+ "description": "Json schema for list_broadcast request",
6
+ "$comment": "Json schema for list_broadcast request",
7
+ "type": "object",
8
+ "properties": {
9
+ "$idempotency_key": {
10
+ "type": ["string", "null"],
11
+ "maxLength": 64,
12
+ "description": "unique id provided by client for request"
13
+ },
14
+ "brand_id": {
15
+ "type": ["string", "null"],
16
+ "maxLength": 64,
17
+ "description": "brand id for workflow to be run in context of a brand"
18
+ },
19
+ "$insert_id": {
20
+ "type": "string",
21
+ "minLength": 36,
22
+ "description": "unique uuid generated per request"
23
+ },
24
+ "$time": {
25
+ "type": "integer",
26
+ "minimum": 1640995200000,
27
+ "description": "Timestamp: unix epoch in milliseconds"
28
+ },
29
+ "list_id": {
30
+ "type": "string",
31
+ "minLength": 1,
32
+ "description": "SubscriberList id"
33
+ },
34
+ "template": {
35
+ "$ref": "#/definitions/non_empty_string",
36
+ "description": "slug of Template"
37
+ },
38
+ "notification_category": {
39
+ "$ref": "#/definitions/non_empty_string",
40
+ "description": "slug of Notification category"
41
+ },
42
+ "delay": {
43
+ "type": ["string", "integer"],
44
+ "minimum": 0,
45
+ "description": "If string: format [XX]d[XX]h[XX]m[XX]s e.g 1d2h30m10s(for 1day 2hours 30minutes 10sec). If integer: value in number of seconds"
46
+ },
47
+ "trigger_at": {
48
+ "type": "string",
49
+ "description": "timestamp in ISO-8601 format. e.g 2021-08-27T20:14:51.643Z"
50
+ },
51
+ "data": {
52
+ "type": "object",
53
+ "description": "variables to be used in workflow. e.g replacing templates variables."
54
+ }
55
+ },
56
+ "required": [
57
+ "$insert_id",
58
+ "$time",
59
+ "list_id",
60
+ "template",
61
+ "notification_category",
62
+ "data"
63
+ ],
64
+ "definitions": {
65
+ "non_empty_string": {
66
+ "type": "string",
67
+ "minLength": 2
68
+ }
69
+ }
70
+ }
package/src/subscriber.js CHANGED
@@ -44,31 +44,16 @@ export class Subscriber {
44
44
  this.config = config;
45
45
  this.distinct_id = distinct_id;
46
46
  this.__url = this.__get_url();
47
- this.__supr_props = this.__super_properties();
47
+ this.__super_props = this.__super_properties();
48
48
 
49
49
  this.__errors = [];
50
50
  this.__info = [];
51
- this._append_count = 0;
52
- this._remove_count = 0;
53
- this._set_count = 0;
54
- this._unset_count = 0;
55
- this._events = [];
56
- this._helper = new _SubscriberInternalHelper(
57
- distinct_id,
58
- config.workspace_key
59
- );
51
+ this.user_operations = [];
52
+ this._helper = new _SubscriberInternalHelper();
60
53
  }
61
54
 
62
55
  __get_url() {
63
- let url_template = "event/";
64
- if (this.config.include_signature_param) {
65
- if (this.config.auth_enabled) {
66
- url_template = url_template + "?verify=true";
67
- } else {
68
- url_template = url_template + "?verify=false";
69
- }
70
- }
71
- return `${this.config.base_url}${url_template}`;
56
+ return `${this.config.base_url}event/`;
72
57
  }
73
58
 
74
59
  __get_headers() {
@@ -85,30 +70,16 @@ export class Subscriber {
85
70
  };
86
71
  }
87
72
 
88
- events() {
89
- let all_events = [...this._events];
90
- for (let e of all_events) {
91
- e["properties"] = this.__supr_props;
92
- }
93
-
94
- if (
95
- all_events.length === 0 ||
96
- this._append_count > 0 ||
97
- this._set_count > 0
98
- ) {
99
- const user_identify_event = {
100
- $insert_id: uuid(),
101
- $time: epoch_milliseconds(),
102
- env: this.config.workspace_key,
103
- event: "$identify",
104
- properties: {
105
- $identified_id: this.distinct_id,
106
- ...this.__supr_props,
107
- },
108
- };
109
- all_events = [user_identify_event, ...all_events];
110
- }
111
- return all_events;
73
+ get_events() {
74
+ return {
75
+ $schema: "2",
76
+ $insert_id: uuid(),
77
+ $time: epoch_milliseconds(),
78
+ env: this.config.workspace_key,
79
+ distinct_id: this.distinct_id,
80
+ $user_operations: this.user_operations,
81
+ properties: this.__super_props,
82
+ };
112
83
  }
113
84
 
114
85
  validate_event_size(event_dict) {
@@ -147,22 +118,19 @@ export class Subscriber {
147
118
  const is_part_of_bulk = false;
148
119
  this.validate_body(is_part_of_bulk);
149
120
  const headers = this.__get_headers();
150
- const events = this.events();
151
- for (let ev of events) {
152
- const [validated_ev, size] = this.validate_event_size(ev);
153
- }
121
+ const event = this.get_events();
122
+ const [validated_ev, size] = this.validate_event_size(event);
123
+ const content_text = JSON.stringify(validated_ev);
124
+
125
+ const signature = get_request_signature(
126
+ this.__url,
127
+ "POST",
128
+ content_text,
129
+ headers,
130
+ this.config.workspace_secret
131
+ );
132
+ headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
154
133
 
155
- const content_text = JSON.stringify(events);
156
- if (this.config.auth_enabled) {
157
- const signature = get_request_signature(
158
- this.__url,
159
- "POST",
160
- content_text,
161
- headers,
162
- this.config.workspace_secret
163
- );
164
- headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
165
- }
166
134
  try {
167
135
  const response = await axios.post(this.__url, content_text, { headers });
168
136
  const ok_response = Math.floor(response.status / 100) == 2;
@@ -200,11 +168,7 @@ export class Subscriber {
200
168
  this.__info = [...this.__info, ...resp["info"]];
201
169
  }
202
170
  if (!is_empty(resp["event"])) {
203
- this._events.push(resp["event"]);
204
- this._set_count += resp["set"];
205
- this._append_count += resp["append"];
206
- this._remove_count += resp["remove"];
207
- this._unset_count += resp["unset"];
171
+ this.user_operations.push(resp["event"]);
208
172
  }
209
173
  }
210
174
 
@@ -80,16 +80,12 @@ export default class _SubscriberInternalHelper {
80
80
  this.workspace_key = workspace_key;
81
81
 
82
82
  this.__dict_set = {};
83
- this.__set_count = 0;
84
83
 
85
84
  this.__dict_append = {};
86
- this.__append_count = 0;
87
85
 
88
86
  this.__dict_remove = {};
89
- this.__remove_count = 0;
90
87
 
91
88
  this.__list_unset = [];
92
- this.__unset_count = 0;
93
89
 
94
90
  this.__errors = [];
95
91
  this.__info = [];
@@ -97,17 +93,9 @@ export default class _SubscriberInternalHelper {
97
93
 
98
94
  reset() {
99
95
  this.__dict_set = {};
100
- this.__set_count = 0;
101
-
102
96
  this.__dict_append = {};
103
- this.__append_count = 0;
104
-
105
97
  this.__dict_remove = {};
106
- this.__remove_count = 0;
107
-
108
98
  this.__list_unset = [];
109
- this.__unset_count = 0;
110
-
111
99
  this.__errors = [];
112
100
  this.__info = [];
113
101
  }
@@ -118,48 +106,26 @@ export default class _SubscriberInternalHelper {
118
106
  errors: this.__errors,
119
107
  info: this.__info,
120
108
  event: evt,
121
- set: this.__set_count,
122
- append: this.__append_count,
123
- remove: this.__remove_count,
124
- unset: this.__unset_count,
125
109
  };
126
110
  this.reset();
127
111
  return ret_val;
128
112
  }
129
113
 
130
114
  __form_event() {
131
- if (
132
- !is_empty(this.__dict_set) ||
133
- !is_empty(this.__dict_append) ||
134
- !is_empty(this.__dict_remove) ||
135
- !is_empty(this.__list_unset)
136
- ) {
137
- let event = {
138
- $insert_id: uuid(),
139
- $time: epoch_milliseconds(),
140
- env: this.workspace_key,
141
- distinct_id: this.distinct_id,
142
- };
143
- if (!is_empty(this.__dict_set)) {
144
- event["$set"] = this.__dict_set;
145
- this.__set_count += 1;
146
- }
147
- if (!is_empty(this.__dict_append)) {
148
- event["$append"] = this.__dict_append;
149
- this.__append_count += 1;
150
- }
151
- if (!is_empty(this.__dict_remove)) {
152
- event["$remove"] = this.__dict_remove;
153
- this.__remove_count += 1;
154
- }
155
- if (!is_empty(this.__list_unset)) {
156
- event["$unset"] = this.__list_unset;
157
- this.__unset_count += 1;
158
- }
159
- return event;
160
- } else {
161
- return;
115
+ const event = {};
116
+ if (!is_empty(this.__dict_set)) {
117
+ event["$set"] = this.__dict_set;
118
+ }
119
+ if (!is_empty(this.__dict_append)) {
120
+ event["$append"] = this.__dict_append;
121
+ }
122
+ if (!is_empty(this.__dict_remove)) {
123
+ event["$remove"] = this.__dict_remove;
162
124
  }
125
+ if (!is_empty(this.__list_unset)) {
126
+ event["$unset"] = this.__list_unset;
127
+ }
128
+ return event;
163
129
  }
164
130
 
165
131
  __validate_key_basic(key, caller) {
@@ -240,33 +206,25 @@ export default class _SubscriberInternalHelper {
240
206
  }
241
207
 
242
208
  __add_identity(key, value, args, caller) {
209
+ const new_caller = `${caller}:${key}`;
243
210
  switch (key) {
244
211
  case IDENT_KEY_EMAIL:
245
- this._add_email(value, caller);
212
+ this._add_email(value, new_caller);
246
213
  break;
247
214
  case IDENT_KEY_SMS:
248
- this._add_sms(value, caller);
215
+ this._add_sms(value, new_caller);
249
216
  break;
250
217
  case IDENT_KEY_WHATSAPP:
251
- this._add_whatsapp(value, caller);
218
+ this._add_whatsapp(value, new_caller);
252
219
  break;
253
220
  case IDENT_KEY_ANDROIDPUSH:
254
- this._add_androidpush(value, args[KEY_PUSHVENDOR], caller);
255
- if (this.__dict_append[KEY_PUSHVENDOR]) {
256
- args[KEY_PUSHVENDOR] = this.__dict_append[KEY_PUSHVENDOR];
257
- }
221
+ this._add_androidpush(value, args[KEY_PUSHVENDOR], new_caller);
258
222
  break;
259
223
  case IDENT_KEY_IOSPUSH:
260
- this._add_iospush(value, args[KEY_PUSHVENDOR], caller);
261
- if (this.__dict_append[KEY_PUSHVENDOR]) {
262
- args[KEY_PUSHVENDOR] = this.__dict_append[KEY_PUSHVENDOR];
263
- }
224
+ this._add_iospush(value, args[KEY_PUSHVENDOR], new_caller);
264
225
  break;
265
226
  case IDENT_KEY_WEBPUSH:
266
- this._add_webpush(value, args[KEY_PUSHVENDOR], caller);
267
- if (this.__dict_append[KEY_PUSHVENDOR]) {
268
- args[KEY_PUSHVENDOR] = this.__dict_append[KEY_PUSHVENDOR];
269
- }
227
+ this._add_webpush(value, args[KEY_PUSHVENDOR], new_caller);
270
228
  break;
271
229
  case IDENT_KEY_SLACK:
272
230
  this._add_slack(value, caller);
@@ -277,33 +235,25 @@ export default class _SubscriberInternalHelper {
277
235
  }
278
236
 
279
237
  __remove_identity(key, value, args, caller) {
238
+ const new_caller = `${caller}:${key}`;
280
239
  switch (key) {
281
240
  case IDENT_KEY_EMAIL:
282
- this._remove_email(value, caller);
241
+ this._remove_email(value, new_caller);
283
242
  break;
284
243
  case IDENT_KEY_SMS:
285
- this._remove_sms(value, caller);
244
+ this._remove_sms(value, new_caller);
286
245
  break;
287
246
  case IDENT_KEY_WHATSAPP:
288
- this._remove_whatsapp(value, caller);
247
+ this._remove_whatsapp(value, new_caller);
289
248
  break;
290
249
  case IDENT_KEY_ANDROIDPUSH:
291
- this._remove_androidpush(value, args[KEY_PUSHVENDOR], caller);
292
- if (this.__dict_remove[KEY_PUSHVENDOR]) {
293
- args[KEY_PUSHVENDOR] = this.__dict_remove[KEY_PUSHVENDOR];
294
- }
250
+ this._remove_androidpush(value, args[KEY_PUSHVENDOR], new_caller);
295
251
  break;
296
252
  case IDENT_KEY_IOSPUSH:
297
- this._remove_iospush(value, args[KEY_PUSHVENDOR], caller);
298
- if (this.__dict_remove[KEY_PUSHVENDOR]) {
299
- args[KEY_PUSHVENDOR] = this.__dict_remove[KEY_PUSHVENDOR];
300
- }
253
+ this._remove_iospush(value, args[KEY_PUSHVENDOR], new_caller);
301
254
  break;
302
255
  case IDENT_KEY_WEBPUSH:
303
- this._remove_webpush(value, args[KEY_PUSHVENDOR], caller);
304
- if (this.__dict_remove[KEY_PUSHVENDOR]) {
305
- args[KEY_PUSHVENDOR] = this.__dict_remove[KEY_PUSHVENDOR];
306
- }
256
+ this._remove_webpush(value, args[KEY_PUSHVENDOR], new_caller);
307
257
  break;
308
258
  case IDENT_KEY_SLACK:
309
259
  this._remove_slack(val, caller);
@@ -430,6 +380,9 @@ export default class _SubscriberInternalHelper {
430
380
  if (!provider) {
431
381
  provider = "fcm";
432
382
  }
383
+ if (typeof provider === "string") {
384
+ provider = provider.toLocaleLowerCase();
385
+ }
433
386
  if (!["fcm", "xiaomi", "oppo"].includes(provider)) {
434
387
  this.__errors.push(
435
388
  `[${caller}] unsupported androidpush provider ${provider}`
@@ -475,6 +428,9 @@ export default class _SubscriberInternalHelper {
475
428
  if (!provider) {
476
429
  provider = "apns";
477
430
  }
431
+ if (typeof provider === "string") {
432
+ provider = provider.toLocaleLowerCase();
433
+ }
478
434
  if (!["apns"].includes(provider)) {
479
435
  this.__errors.push(
480
436
  `[${caller}] unsupported iospush provider ${provider}`
@@ -521,6 +477,9 @@ export default class _SubscriberInternalHelper {
521
477
  if (!provider) {
522
478
  provider = "vapid";
523
479
  }
480
+ if (typeof provider === "string") {
481
+ provider = provider.toLocaleLowerCase();
482
+ }
524
483
  if (!["vapid"].includes(provider)) {
525
484
  this.__errors.push(
526
485
  `[${caller}] unsupported webpush provider ${provider}`