@smartcar/auth 2.7.0 → 2.9.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.
package/README.md CHANGED
@@ -24,7 +24,7 @@ npm install @smartcar/auth
24
24
  ### Smartcar CDN
25
25
 
26
26
  ```html
27
- <script src="https://javascript-sdk.smartcar.com/2.7.0/sdk.js"></script>
27
+ <script src="https://javascript-sdk.smartcar.com/2.9.0/sdk.js"></script>
28
28
  ```
29
29
 
30
30
  ## SDK reference
@@ -178,4 +178,4 @@ https://application-backend.com/page?error=access_denied&error_description=User+
178
178
  [tag-image]: https://img.shields.io/github/tag/smartcar/javascript-sdk.svg
179
179
 
180
180
  <!-- Please do not modify or remove this, it is used by the build process -->
181
- [version]: 2.7.0
181
+ [version]: 2.9.0
package/dist/npm/sdk.js CHANGED
@@ -1,32 +1,69 @@
1
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
1
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
2
2
 
3
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
3
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
4
4
 
5
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
5
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
6
6
 
7
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
7
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
8
8
 
9
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
9
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
10
10
 
11
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
11
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
12
+
13
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+
15
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
16
+
17
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18
+
19
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20
+
21
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
22
+
23
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
+
25
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
26
+
27
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
+
29
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
30
+
31
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
32
+
33
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
34
+
35
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
36
+
37
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
38
+
39
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
40
+
41
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
42
 
13
43
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
44
 
15
- ;(function (root, factory) {
45
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
46
+
47
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
48
+
49
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
50
+
51
+ ;
52
+
53
+ (function (root, factory) {
16
54
  /* istanbul ignore next */
17
55
  if (typeof define === 'function' && define.amd) {
18
56
  define([], factory);
19
- } else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
57
+ } else if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object') {
20
58
  module.exports = factory();
21
59
  } else {
22
60
  root.Smartcar = factory();
23
61
  }
24
62
  })(this, function () {
25
63
  'use strict';
26
-
27
64
  /* eslint-env node */
28
65
 
29
- var Smartcar = function () {
66
+ var Smartcar = /*#__PURE__*/function () {
30
67
  /**
31
68
  * @callback OnComplete
32
69
  * @param {?Error} error - something went wrong in Connect; this
@@ -48,8 +85,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
48
85
  * application
49
86
  * @param {String[]} [options.scope] - requested permission scopes
50
87
  * @param {OnComplete} [options.onComplete] - called on completion of Smartcar Connect
51
- * @param {Boolean} [options.testMode=false] - launch Smartcar Connect in test mode
52
- */
88
+ * @param {Boolean} [options.testMode=false] - Deprecated, please use `mode` instead.
89
+ * Launch Smartcar Connect in [test mode](https://smartcar.com/docs/guides/testing/).
90
+ * @param {String} [options.mode='live'] - Determine what mode Smartcar Connect should be
91
+ * launched in. Should be one of test, live or simulated.
92
+ */
53
93
  function Smartcar(options) {
54
94
  var _this = this;
55
95
 
@@ -63,35 +103,67 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
63
103
  position = position || 0;
64
104
  return this.substr(position, searchString.length) === searchString;
65
105
  };
66
- }
106
+ } // ensure options are well formed
107
+
67
108
 
68
- // ensure options are well formed
69
109
  Smartcar._validateConstructorOptions(options);
70
110
 
71
111
  this.clientId = options.clientId;
72
112
  this.redirectUri = options.redirectUri;
73
113
  this.scope = options.scope;
74
114
  this.onComplete = options.onComplete;
75
- this.mode = options.testMode === true ? 'test' : 'live';
76
- this.responseType = 'code';
115
+ this.mode = 'live';
116
+
117
+ if (options.hasOwnProperty('testMode')) {
118
+ // eslint-disable-next-line no-console
119
+ console.warn('The "testMode" parameter is deprecated, please use the "mode" parameter instead.');
120
+ this.mode = options.testMode === true ? 'test' : 'live';
121
+ } else if (options.hasOwnProperty('mode')) {
122
+ this.mode = options.mode;
123
+ }
124
+
125
+ if (!['test', 'live', 'simulated'].includes(this.mode)) {
126
+ throw new Error('The "mode" parameter MUST be one of the following: \'test\', \'live\', \'simulated\'');
127
+ }
128
+
129
+ this.responseType = 'code'; // identifier for matching message event and multiple Smartcar instances
130
+ // it is a string composed of a timestamp and a 8-digit random number
131
+
132
+ this.instanceId = new Date().getTime() + String(Math.random()).slice(2, 10); // handler
77
133
 
78
- // handler
79
134
  this.messageHandler = function (event) {
80
135
  // bail if message from unexpected source
81
136
  if (!_this.redirectUri.startsWith(event.origin)) {
82
137
  return;
83
138
  }
84
139
 
85
- var message = event.data || {};
86
- // bail if `message.name` is not `SmartcarAuthMessage`
140
+ var message = event.data || {}; // bail if `message.name` is not `SmartcarAuthMessage`
87
141
  // this prevents attempting to handle messages intended for others
142
+
88
143
  if (message.name !== 'SmartcarAuthMessage') {
89
144
  return;
145
+ } // bail if `state` is invalid
146
+
147
+
148
+ var stateObject;
149
+
150
+ try {
151
+ stateObject = JSON.parse(window.atob(message.state));
152
+ } catch (e) {
153
+ return;
90
154
  }
91
155
 
92
- // if onComplete not specified do nothing, assume developer is conveying
156
+ var _stateObject = stateObject,
157
+ originalState = _stateObject.originalState,
158
+ instanceId = _stateObject.instanceId; // bail if `instanceId` doesn't match
159
+
160
+ if (instanceId !== _this.instanceId) {
161
+ return;
162
+ } // if onComplete not specified do nothing, assume developer is conveying
93
163
  // completion information from backend server receiving redirect to front
94
164
  // end (not using onComplete)
165
+
166
+
95
167
  if (_this.onComplete) {
96
168
  // if auth errored generate appropriate error else null
97
169
  var generateError = function generateError(error, description) {
@@ -102,36 +174,36 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
102
174
  switch (error) {
103
175
  case 'access_denied':
104
176
  return new Smartcar.AccessDenied(description);
177
+
105
178
  case 'invalid_subscription':
106
179
  return new Smartcar.InvalidSubscription(description);
180
+
107
181
  case 'vehicle_incompatible':
108
- var params = event.data;
182
+ var params = event.data; // This field will always exist if vehicleInfo is returned
109
183
 
110
- // This field will always exist if vehicleInfo is returned
111
184
  if (!params.vin) {
112
185
  return new Smartcar.VehicleIncompatible(description, null);
113
- }
186
+ } // These fields are required when vehicleInfo is returned
187
+
114
188
 
115
- // These fields are required when vehicleInfo is returned
116
189
  var vehicleInfo = {
117
190
  vin: params.vin,
118
191
  make: params.make,
119
192
  year: Number(params.year)
120
- };
193
+ }; // This field is optional
121
194
 
122
- // This field is optional
123
195
  if (params.model) {
124
196
  vehicleInfo.model = params.model;
125
197
  }
126
198
 
127
199
  return new Smartcar.VehicleIncompatible(description, vehicleInfo);
200
+
128
201
  default:
129
- return new Error('Unexpected error: ' + error + ' - ' + description);
202
+ return new Error("Unexpected error: ".concat(error, " - ").concat(description));
130
203
  }
131
204
  };
132
205
 
133
206
  var err = generateError(message.error, message.errorDescription);
134
-
135
207
  /**
136
208
  * Call `onComplete` with parameters even if developer is not using
137
209
  * a Smartcar-hosted redirect. Regardless of if they are using a
@@ -144,14 +216,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
144
216
  * parameters they must also handle populating the corresponding query
145
217
  * parameters in their redirect uri.
146
218
  */
147
- _this.onComplete(err, message.code, message.state);
219
+
220
+ _this.onComplete(err, message.code, originalState);
148
221
  }
149
- };
222
+ }; // add handler for postMessage event on completion of Smartcar Connect
223
+
150
224
 
151
- // add handler for postMessage event on completion of Smartcar Connect
152
225
  window.addEventListener('message', this.messageHandler);
153
226
  }
154
-
155
227
  /**
156
228
  * Validate options passed to Smartcar constructor.
157
229
  *
@@ -163,9 +235,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
163
235
 
164
236
 
165
237
  _createClass(Smartcar, [{
166
- key: 'getAuthUrl',
167
-
168
-
238
+ key: "getAuthUrl",
239
+ value:
169
240
  /**
170
241
  * Generates Smartcar OAuth URL.
171
242
  *
@@ -186,6 +257,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
186
257
  * the vehicle with the specified VIN. See the
187
258
  * [API reference](https://smartcar.com/docs/api/#connect-match)
188
259
  * for more information.
260
+ * @param {String[]} [options.flags] - An optional space-separated list of feature
261
+ * flags that your application has early access to.
189
262
  *
190
263
  * @return {String} Connect URL to redirect user to.
191
264
  *
@@ -198,57 +271,39 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
198
271
  * &state=0facda3319
199
272
  * &make=TESLA
200
273
  * &single_select=true
274
+ * &single_select_vin=5YJSA1E14FF101307
275
+ * &flags=country:DE color:00819D
201
276
  */
202
- value: function getAuthUrl(options) {
277
+ function getAuthUrl(options) {
203
278
  options = options || {};
204
-
205
279
  var link = '';
206
280
  link += 'https://connect.smartcar.com/oauth/authorize';
207
- link += '?response_type=' + this.responseType;
208
- link += '&client_id=' + this.clientId;
209
- link += '&redirect_uri=' + encodeURIComponent(this.redirectUri);
281
+ link += "?response_type=".concat(this.responseType);
282
+ link += "&client_id=".concat(this.clientId);
283
+ link += "&redirect_uri=".concat(encodeURIComponent(this.redirectUri)); // map forcePrompt to approvalPrompt, two options: 'force' and 'auto'
210
284
 
211
- // map forcePrompt to approvalPrompt, two options: 'force' and 'auto'
212
285
  var forcePrompt = options.forcePrompt === true;
213
- link += '&approval_prompt=' + (forcePrompt ? 'force' : 'auto');
214
-
215
- // If scope is not specified, Smartcar will default to requesting all scopes
286
+ link += "&approval_prompt=".concat(forcePrompt ? 'force' : 'auto'); // If scope is not specified, Smartcar will default to requesting all scopes
216
287
  // from the user
288
+
217
289
  if (this.scope) {
218
- link += '&scope=' + encodeURIComponent(this.scope.join(' '));
290
+ link += "&scope=".concat(encodeURIComponent(this.scope.join(' ')));
219
291
  }
220
292
 
221
- link += '&mode=' + this.mode;
293
+ link += "&mode=".concat(this.mode);
222
294
 
223
295
  if (options.singleSelect !== undefined && options.singleSelect !== null) {
224
296
  var singleSelectParamAdded = false;
297
+
225
298
  if (_typeof(options.singleSelect) === 'object') {
226
299
  var availableParams = ['vin'];
227
- var _iteratorNormalCompletion = true;
228
- var _didIteratorError = false;
229
- var _iteratorError = undefined;
230
300
 
231
- try {
232
- for (var _iterator = availableParams[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
233
- var param = _step.value;
301
+ for (var _i = 0, _availableParams = availableParams; _i < _availableParams.length; _i++) {
302
+ var param = _availableParams[_i];
234
303
 
235
- if (param in options.singleSelect) {
236
- link += '&single_select_' + param + '=' + options.singleSelect[param];
237
- singleSelectParamAdded = true;
238
- }
239
- }
240
- } catch (err) {
241
- _didIteratorError = true;
242
- _iteratorError = err;
243
- } finally {
244
- try {
245
- if (!_iteratorNormalCompletion && _iterator.return) {
246
- _iterator.return();
247
- }
248
- } finally {
249
- if (_didIteratorError) {
250
- throw _iteratorError;
251
- }
304
+ if (param in options.singleSelect) {
305
+ link += "&single_select_".concat(param, "=").concat(options.singleSelect[param]);
306
+ singleSelectParamAdded = true;
252
307
  }
253
308
  }
254
309
 
@@ -258,47 +313,40 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
258
313
  link += '&single_select=true';
259
314
  }
260
315
  } else {
261
- link += '&single_select=' + (options.singleSelect === true);
316
+ link += "&single_select=".concat(options.singleSelect === true);
262
317
  }
263
- }
318
+ } // augment state to track the corresponding instance
319
+
320
+
321
+ var state = {
322
+ instanceId: this.instanceId
323
+ };
264
324
 
265
325
  if (options.state) {
266
- link += '&state=' + options.state;
267
- }
326
+ state.originalState = options.state;
327
+ } // convert the augmented state to a base64 string
328
+
329
+
330
+ link += "&state=".concat(window.btoa(JSON.stringify(state)));
268
331
 
269
332
  if (options.vehicleInfo) {
270
- var _availableParams = ['make'];
271
- var _iteratorNormalCompletion2 = true;
272
- var _didIteratorError2 = false;
273
- var _iteratorError2 = undefined;
333
+ var _availableParams2 = ['make'];
274
334
 
275
- try {
276
- for (var _iterator2 = _availableParams[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
277
- var _param = _step2.value;
335
+ for (var _i2 = 0, _availableParams3 = _availableParams2; _i2 < _availableParams3.length; _i2++) {
336
+ var _param = _availableParams3[_i2];
278
337
 
279
- if (_param in options.vehicleInfo) {
280
- link += '&' + _param + '=' + encodeURIComponent(options.vehicleInfo[_param]);
281
- }
282
- }
283
- } catch (err) {
284
- _didIteratorError2 = true;
285
- _iteratorError2 = err;
286
- } finally {
287
- try {
288
- if (!_iteratorNormalCompletion2 && _iterator2.return) {
289
- _iterator2.return();
290
- }
291
- } finally {
292
- if (_didIteratorError2) {
293
- throw _iteratorError2;
294
- }
338
+ if (_param in options.vehicleInfo) {
339
+ link += "&".concat(_param, "=").concat(encodeURIComponent(options.vehicleInfo[_param]));
295
340
  }
296
341
  }
297
342
  }
298
343
 
344
+ if (options.flags) {
345
+ link += "&flags=".concat(encodeURIComponent(options.flags.join(' ')));
346
+ }
347
+
299
348
  return link;
300
349
  }
301
-
302
350
  /**
303
351
  * Launches Smartcar Connect in a new window.
304
352
  *
@@ -319,26 +367,20 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
319
367
  * the vehicle with the specified VIN. See the
320
368
  * [API reference](https://smartcar.com/docs/api/#connect-match)
321
369
  * for more information.
322
- * @param {Object} [options.windowOptions] - the position and dimension settings
323
- * of the popup window
324
- * @param {String} [options.windowOptions.top] - the top property of
325
- * [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features)
326
- * @param {String} [options.windowOptions.left] - the left property of
327
- * [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features)
328
- * @param {String} [options.windowOptions.width] - the width property of
329
- * [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features)
330
- * @param {String} [options.windowOptions.height] - the height property of
331
- * [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features)
370
+ * @param {String[]} [options.flags] - An optional space-separated list of feature
371
+ * flags that your application has early access to.
372
+ * @param {WindowOptions} [options.windowOptions] - position and size settings for
373
+ * the popup window
332
374
  */
333
375
 
334
376
  }, {
335
- key: 'openDialog',
377
+ key: "openDialog",
336
378
  value: function openDialog(options) {
337
379
  var windowOptions = Smartcar._getWindowOptions(options.windowOptions || {});
380
+
338
381
  var href = this.getAuthUrl(options);
339
382
  window.open(href, 'Connect your car', windowOptions);
340
383
  }
341
-
342
384
  /**
343
385
  * Adds an on-click event listener to the element with the provided id.
344
386
  *
@@ -363,58 +405,66 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
363
405
  * the vehicle with the specified VIN. See the
364
406
  * [API reference](https://smartcar.com/docs/api/#connect-match)
365
407
  * for more information.
408
+ * @param {String[]} [options.flags] - An optional space-separated list of feature
409
+ * flags that your application has early access to.
410
+ * @param {WindowOptions} [options.windowOptions] - position and size settings for
411
+ * the popup window
366
412
  */
367
413
 
368
414
  }, {
369
- key: 'addClickHandler',
415
+ key: "addClickHandler",
370
416
  value: function addClickHandler(options) {
371
417
  var _this2 = this;
372
418
 
373
419
  var id = options.id,
374
- selector = options.selector;
375
-
376
- // check if id or selector option exists
420
+ selector = options.selector; // check if id or selector option exists
377
421
 
378
422
  if (!id && !selector) {
379
423
  throw new Error('Could not add click handler: id or selector must be provided.');
380
- }
424
+ } // find all the DOM elements that match the id and selector
425
+
381
426
 
382
- // find all the DOM elements that match the id and selector
383
427
  var elements = [];
428
+
384
429
  if (id) {
385
430
  var element = document.getElementById(id);
431
+
386
432
  if (element) {
387
433
  elements.push(element);
388
434
  }
389
435
  }
436
+
390
437
  if (selector) {
391
438
  elements.push.apply(elements, _toConsumableArray(document.querySelectorAll(selector)));
392
439
  }
393
- if (!elements.length) {
394
- throw new Error('\n Could not add click handler: element with \'' + (id || selector) + '\' was not found.\n ');
395
- }
396
440
 
397
- // _elementToClickHandler stores all the element - clickHandler pairs under the same instance
441
+ if (!elements.length) {
442
+ throw new Error("\n Could not add click handler: element with '".concat(id || selector, "' was not found.\n "));
443
+ } // _elementToClickHandler stores all the element - clickHandler pairs under the same instance
398
444
  // because it is possible to call addClickHandler multiple times with different options
445
+
446
+
399
447
  if (!this._elementToClickHandler) {
400
448
  this._elementToClickHandler = new Map();
401
449
  }
450
+
402
451
  var clickHandler = function clickHandler() {
403
- _this2.openDialog(options);
404
- // this is equivalent to calling:
452
+ _this2.openDialog(options); // this is equivalent to calling:
405
453
  // event.preventDefault();
406
454
  // event.stopPropogation();
455
+
456
+
407
457
  return false;
408
458
  };
409
459
 
410
460
  elements.forEach(function (element) {
411
461
  // register element - clickHandler pair
412
- _this2._elementToClickHandler.set(element, clickHandler);
413
- // register eventListener
462
+ _this2._elementToClickHandler.set(element, clickHandler); // register eventListener
463
+
464
+
414
465
  element.addEventListener('click', clickHandler);
415
466
  });
416
467
  }
417
-
418
468
  /**
419
469
  * Remove Smartcar's event listeners.
420
470
  *
@@ -430,43 +480,31 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
430
480
  */
431
481
 
432
482
  }, {
433
- key: 'unmount',
483
+ key: "unmount",
434
484
  value: function unmount() {
435
485
  window.removeEventListener('message', this.messageHandler);
486
+
436
487
  if (this._elementToClickHandler) {
437
- var _iteratorNormalCompletion3 = true;
438
- var _didIteratorError3 = false;
439
- var _iteratorError3 = undefined;
488
+ var _iterator = _createForOfIteratorHelper(this._elementToClickHandler.entries()),
489
+ _step;
440
490
 
441
491
  try {
442
- for (var _iterator3 = this._elementToClickHandler.entries()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
443
- var _ref = _step3.value;
444
-
445
- var _ref2 = _slicedToArray(_ref, 2);
446
-
447
- var element = _ref2[0];
448
- var clickHandler = _ref2[1];
492
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
493
+ var _step$value = _slicedToArray(_step.value, 2),
494
+ element = _step$value[0],
495
+ clickHandler = _step$value[1];
449
496
 
450
497
  element.removeEventListener('click', clickHandler);
451
498
  }
452
499
  } catch (err) {
453
- _didIteratorError3 = true;
454
- _iteratorError3 = err;
500
+ _iterator.e(err);
455
501
  } finally {
456
- try {
457
- if (!_iteratorNormalCompletion3 && _iterator3.return) {
458
- _iterator3.return();
459
- }
460
- } finally {
461
- if (_didIteratorError3) {
462
- throw _iteratorError3;
463
- }
464
- }
502
+ _iterator.f();
465
503
  }
466
504
  }
467
505
  }
468
506
  }], [{
469
- key: '_validateConstructorOptions',
507
+ key: "_validateConstructorOptions",
470
508
  value: function _validateConstructorOptions(options) {
471
509
  if (!options.clientId) {
472
510
  throw new TypeError('A client ID option must be provided');
@@ -491,30 +529,33 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
491
529
  }
492
530
  }
493
531
  }
532
+ /**
533
+ * Position and size settings for the popup window.
534
+ *
535
+ * @see Please reference the {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features|Window.open()#Window Features}
536
+ * MDN article for more details
537
+ *
538
+ * @typedef {Object} WindowOptions
539
+ * @property {String} [top]
540
+ * @property {String} [left]
541
+ * @property {String} [width]
542
+ * @property {String} [height]
543
+ */
494
544
 
495
545
  /**
496
546
  * Calculate popup window size and position based on current window settings.
497
547
  *
498
- * @param {Object} options - the postion and dimention setting of the popup window
499
- * @param {String|Number} [options.top] - the top property of
500
- * [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features)
501
- * @param {String|Number} [options.left] - the left property of
502
- * [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features)
503
- * @param {String|Number} [options.width] - the width property of
504
- * [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features)
505
- * the minimum required value is 100.
506
- * @param {String|Number} [options.height] - the height property of
507
- * [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features)
508
- * the minimum required value is 100.
509
548
  * @private
549
+ * @param {WindowOptions} options
510
550
  * @return {String} a string of window settings
511
551
  */
512
552
 
513
553
  }, {
514
- key: '_getWindowOptions',
554
+ key: "_getWindowOptions",
515
555
  value: function _getWindowOptions(windowOptions) {
516
556
  Object.keys(windowOptions).forEach(function (option) {
517
557
  var numValue = parseFloat(windowOptions[option]);
558
+
518
559
  if (isNaN(numValue)) {
519
560
  windowOptions[option] = '';
520
561
  } else if (numValue < 100 && (option === 'width' || option === 'height')) {
@@ -522,31 +563,26 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
522
563
  } else {
523
564
  windowOptions[option] = String(numValue);
524
565
  }
525
- });
526
-
527
- // Sets default popup window size as percentage of screen size
566
+ }); // Sets default popup window size as percentage of screen size
528
567
  // Note that this only applies to desktop browsers
568
+
529
569
  var windowSettings = {
530
570
  width: window.screen.width * 0.3,
531
571
  height: window.screen.height * 0.75
532
572
  };
533
-
534
573
  var widthOffset = (window.outerWidth - windowSettings.width) / 2;
535
574
  var heightOffset = (window.outerHeight - windowSettings.height) / 8;
536
-
537
575
  var options = '';
538
- options += 'top=' + (windowOptions.top || window.screenY + heightOffset) + ',';
539
- options += 'left=' + (windowOptions.left || window.screenX + widthOffset) + ',';
540
- options += 'width=' + (windowOptions.width || windowSettings.width) + ',';
541
- options += 'height=' + (windowOptions.height || windowSettings.height) + ',';
542
-
576
+ options += "top=".concat(windowOptions.top || window.screenY + heightOffset, ",");
577
+ options += "left=".concat(windowOptions.left || window.screenX + widthOffset, ",");
578
+ options += "width=".concat(windowOptions.width || windowSettings.width, ",");
579
+ options += "height=".concat(windowOptions.height || windowSettings.height, ",");
543
580
  return options;
544
581
  }
545
582
  }]);
546
583
 
547
584
  return Smartcar;
548
585
  }();
549
-
550
586
  /**
551
587
  * Access denied error returned by Connect.
552
588
  *
@@ -554,24 +590,26 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
554
590
  */
555
591
 
556
592
 
557
- Smartcar.AccessDenied = function (_Error) {
593
+ Smartcar.AccessDenied = /*#__PURE__*/function (_Error) {
558
594
  _inherits(_class, _Error);
559
595
 
596
+ var _super = _createSuper(_class);
597
+
560
598
  /**
561
599
  * @param {String} message - detailed error description
562
600
  */
563
601
  function _class(message) {
564
- _classCallCheck(this, _class);
602
+ var _this3;
565
603
 
566
- var _this3 = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this, message));
604
+ _classCallCheck(this, _class);
567
605
 
606
+ _this3 = _super.call(this, message);
568
607
  _this3.name = 'AccessDenied';
569
608
  return _this3;
570
609
  }
571
610
 
572
- return _class;
573
- }(Error);
574
-
611
+ return _createClass(_class);
612
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
575
613
  /**
576
614
  * Vehicle incompatible error returned by Connect. Will optionally
577
615
  * have a vehicleInfo object if the user chooses to give permissions to provide
@@ -580,9 +618,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
580
618
  *
581
619
  * @extends Error
582
620
  */
583
- Smartcar.VehicleIncompatible = function (_Error2) {
621
+
622
+
623
+ Smartcar.VehicleIncompatible = /*#__PURE__*/function (_Error2) {
584
624
  _inherits(_class2, _Error2);
585
625
 
626
+ var _super2 = _createSuper(_class2);
627
+
586
628
  /**
587
629
  * @param {String} message - detailed error description
588
630
  * @param {?Object} vehicleInfo - If a vehicle is incompatible, the user has
@@ -593,40 +635,45 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
593
635
  * @param {String} [vehicleInfo.model] - optionally returned if user gives permission.
594
636
  */
595
637
  function _class2(message, vehicleInfo) {
596
- _classCallCheck(this, _class2);
638
+ var _this4;
597
639
 
598
- var _this4 = _possibleConstructorReturn(this, (_class2.__proto__ || Object.getPrototypeOf(_class2)).call(this, message));
640
+ _classCallCheck(this, _class2);
599
641
 
642
+ _this4 = _super2.call(this, message);
600
643
  _this4.name = 'VehicleIncompatible';
601
644
  _this4.vehicleInfo = vehicleInfo;
602
645
  return _this4;
603
646
  }
604
647
 
605
- return _class2;
606
- }(Error);
607
-
648
+ return _createClass(_class2);
649
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
608
650
  /**
609
651
  * Invalid subscription error returned by Connect.
610
652
  *
611
653
  * @extends Error
612
654
  */
613
- Smartcar.InvalidSubscription = function (_Error3) {
655
+
656
+
657
+ Smartcar.InvalidSubscription = /*#__PURE__*/function (_Error3) {
614
658
  _inherits(_class3, _Error3);
615
659
 
660
+ var _super3 = _createSuper(_class3);
661
+
616
662
  /**
617
663
  * @param {String} message - detailed error description
618
664
  */
619
665
  function _class3(message) {
620
- _classCallCheck(this, _class3);
666
+ var _this5;
621
667
 
622
- var _this5 = _possibleConstructorReturn(this, (_class3.__proto__ || Object.getPrototypeOf(_class3)).call(this, message));
668
+ _classCallCheck(this, _class3);
623
669
 
670
+ _this5 = _super3.call(this, message);
624
671
  _this5.name = 'InvalidSubscription';
625
672
  return _this5;
626
673
  }
627
674
 
628
- return _class3;
629
- }(Error);
675
+ return _createClass(_class3);
676
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
630
677
 
631
678
  return Smartcar;
632
679
  });
package/doc/README.md CHANGED
@@ -15,6 +15,9 @@ Smartcar JavaScript SDK documentation.
15
15
  <dl>
16
16
  <dt><a href="#OnComplete">OnComplete</a> : <code>function</code></dt>
17
17
  <dd></dd>
18
+ <dt><a href="#WindowOptions">WindowOptions</a> : <code>Object</code></dt>
19
+ <dd><p>Position and size settings for the popup window.</p>
20
+ </dd>
18
21
  </dl>
19
22
 
20
23
  <a name="Smartcar"></a>
@@ -50,7 +53,8 @@ Initializes Smartcar class.
50
53
  | options.redirectUri | <code>String</code> | | the registered redirect uri of the application |
51
54
  | [options.scope] | <code>Array.&lt;String&gt;</code> | | requested permission scopes |
52
55
  | [options.onComplete] | [<code>OnComplete</code>](#OnComplete) | | called on completion of Smartcar Connect |
53
- | [options.testMode] | <code>Boolean</code> | <code>false</code> | launch Smartcar Connect in test mode |
56
+ | [options.testMode] | <code>Boolean</code> | <code>false</code> | Deprecated, please use `mode` instead. Launch Smartcar Connect in [test mode](https://smartcar.com/docs/guides/testing/). |
57
+ | [options.mode] | <code>String</code> | <code>&#x27;live&#x27;</code> | Determine what mode Smartcar Connect should be launched in. Should be one of test, live or simulated. |
54
58
 
55
59
  <a name="Smartcar+getAuthUrl"></a>
56
60
 
@@ -67,6 +71,7 @@ Generates Smartcar OAuth URL.
67
71
  | [options.forcePrompt] | <code>Boolean</code> | <code>false</code> | force permission approval screen to show on every authentication, even if the user has previously consented to the exact scope of permission |
68
72
  | [options.vehicleInfo.make] | <code>String</code> | | `vehicleInfo` is an object with an optional property `make`, which allows users to bypass the car brand selection screen. For a complete list of supported brands, please see our [API Reference](https://smartcar.com/docs/api#authorization) documentation. |
69
73
  | [options.singleSelect] | <code>Boolean</code> \| <code>Object</code> | | An optional value that sets the behavior of the grant dialog displayed to the user. If set to `true`, `single_select` limits the user to selecting only one vehicle. If `single_select` is passed in as an object with the property `vin`, Smartcar will only authorize the vehicle with the specified VIN. See the [API reference](https://smartcar.com/docs/api/#connect-match) for more information. |
74
+ | [options.flags] | <code>Array.&lt;String&gt;</code> | | An optional space-separated list of feature flags that your application has early access to. |
70
75
 
71
76
  **Example**
72
77
  ```js
@@ -78,6 +83,8 @@ response_type=code
78
83
  &state=0facda3319
79
84
  &make=TESLA
80
85
  &single_select=true
86
+ &single_select_vin=5YJSA1E14FF101307
87
+ &flags=country:DE color:00819D
81
88
  ```
82
89
  <a name="Smartcar+openDialog"></a>
83
90
 
@@ -93,11 +100,8 @@ Launches Smartcar Connect in a new window.
93
100
  | [options.forcePrompt] | <code>Boolean</code> | <code>false</code> | force permission approval screen to show on every authentication, even if the user has previously consented to the exact scope of permission |
94
101
  | [options.vehicleInfo.make] | <code>String</code> | | `vehicleInfo` is an object with an optional property `make`, which allows users to bypass the car brand selection screen. For a complete list of supported makes, please see our [API Reference](https://smartcar.com/docs/api#authorization) documentation. |
95
102
  | [options.singleSelect] | <code>Boolean</code> \| <code>Object</code> | | An optional value that sets the behavior of the grant dialog displayed to the user. If set to `true`, `single_select` limits the user to selecting only one vehicle. If `single_select` is passed in as an object with the property `vin`, Smartcar will only authorize the vehicle with the specified VIN. See the [API reference](https://smartcar.com/docs/api/#connect-match) for more information. |
96
- | [options.windowOptions] | <code>Object</code> | | the position and dimension settings of the popup window |
97
- | [options.windowOptions.top] | <code>String</code> | | the top property of [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features) |
98
- | [options.windowOptions.left] | <code>String</code> | | the left property of [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features) |
99
- | [options.windowOptions.width] | <code>String</code> | | the width property of [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features) |
100
- | [options.windowOptions.height] | <code>String</code> | | the height property of [window features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features) |
103
+ | [options.flags] | <code>Array.&lt;String&gt;</code> | | An optional space-separated list of feature flags that your application has early access to. |
104
+ | [options.windowOptions] | [<code>WindowOptions</code>](#WindowOptions) | | position and size settings for the popup window |
101
105
 
102
106
  <a name="Smartcar+addClickHandler"></a>
103
107
 
@@ -117,6 +121,8 @@ On-click event calls openDialog when the specified element is clicked.
117
121
  | [options.forcePrompt] | <code>Boolean</code> | <code>false</code> | force permission approval screen to show on every authentication, even if the user has previously consented to the exact scope of permission |
118
122
  | [options.vehicleInfo.make] | <code>String</code> | | `vehicleInfo` is an object with an optional property `make`, which allows users to bypass the car brand selection screen. For a complete list of supported makes, please see our [API Reference](https://smartcar.com/docs/api#authorization) documentation. |
119
123
  | [options.singleSelect] | <code>Boolean</code> \| <code>Object</code> | | An optional value that sets the behavior of the grant dialog displayed to the user. If set to `true`, `single_select` limits the user to selecting only one vehicle. If `single_select` is passed in as an object with the property `vin`, Smartcar will only authorize the vehicle with the specified VIN. See the [API reference](https://smartcar.com/docs/api/#connect-match) for more information. |
124
+ | [options.flags] | <code>Array.&lt;String&gt;</code> | | An optional space-separated list of feature flags that your application has early access to. |
125
+ | [options.windowOptions] | [<code>WindowOptions</code>](#WindowOptions) | | position and size settings for the popup window |
120
126
 
121
127
  <a name="Smartcar+unmount"></a>
122
128
 
@@ -198,3 +204,20 @@ Invalid subscription error returned by Connect.
198
204
  | code | <code>String</code> | the authorization code to be exchanged from a backend sever for an access token |
199
205
  | [state] | <code>Object</code> | contains state if it was set on the initial authorization request |
200
206
 
207
+ <a name="WindowOptions"></a>
208
+
209
+ ## WindowOptions : <code>Object</code>
210
+ Position and size settings for the popup window.
211
+
212
+ **Kind**: global typedef
213
+ **See**: Please reference the [Window.open()#Window Features](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features)
214
+ MDN article for more details
215
+ **Properties**
216
+
217
+ | Name | Type |
218
+ | --- | --- |
219
+ | [top] | <code>String</code> |
220
+ | [left] | <code>String</code> |
221
+ | [width] | <code>String</code> |
222
+ | [height] | <code>String</code> |
223
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartcar/auth",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "description": "javascript auth sdk for the smartcar",
5
5
  "main": "dist/npm/sdk.js",
6
6
  "license": "MIT",
@@ -15,48 +15,42 @@
15
15
  "homepage": "https://github.com/smartcar/javascript-sdk#readme",
16
16
  "files": [
17
17
  "dist/npm/**",
18
- "doc/**",
19
- "postinstall.js"
18
+ "doc/**"
20
19
  ],
21
20
  "scripts": {
22
21
  "pretest": "gulp build",
23
- "postinstall": "node postinstall",
24
22
  "test": "jest",
25
23
  "posttest": "npm run lint -s",
26
24
  "lint": "eslint . --cache",
27
25
  "cover": "npm test -- --coverage",
28
26
  "readme": "gulp template:readme",
29
27
  "jsdoc": "jsdoc2md --example-lang js --template doc/.template.hbs --files src/sdk.js | sed 's/[ \t]*$//' > doc/README.md",
30
- "prepare-release": "semantic-release --branch \"$(git rev-parse --abbrev-ref HEAD)\" --extends ./build/sr-configs/local.js"
28
+ "prepare-release": "semantic-release --branches \"$(git rev-parse --abbrev-ref HEAD)\" --extends ./build/sr-configs/local.js"
31
29
  },
32
30
  "devDependencies": {
33
- "@semantic-release/exec": "^3.1.3",
34
- "babel-core": "^6.26.3",
35
- "babel-preset-env": "^1.7.0",
36
- "convict": "^4.3.1",
37
- "eslint": "^5.8.0",
38
- "eslint-config-smartcar": "^2.0.0",
39
- "express": "^4.16.3",
40
- "gulp": "^3.8.5",
41
- "gulp-awspublish": "^3.0.1",
42
- "gulp-babel": "^7.0.1",
43
- "gulp-rename": "^1.2.2",
31
+ "@babel/core": "^7.18.2",
32
+ "@babel/preset-env": "^7.18.2",
33
+ "@semantic-release/exec": "^6.0.3",
34
+ "eslint": "^8.16.0",
35
+ "eslint-config-smartcar": "^3.0.0",
36
+ "express": "^4.18.1",
37
+ "geckodriver": "^3.0.1",
38
+ "gulp": "^4.0.2",
39
+ "gulp-awspublish": "^6.0.2",
40
+ "gulp-babel": "^8.0.0",
41
+ "gulp-rename": "^2.0.0",
44
42
  "gulp-template": "^5.0.0",
45
43
  "gulp-uglify": "^3.0.0",
46
44
  "gulp-umd": "^2.0.0",
47
- "jest": "^23.6.0",
48
- "jest-environment-jsdom": "^23.3.0",
49
- "jest-environment-jsdom-global": "^1.1.0",
50
- "jsdoc-to-markdown": "^4.0.1",
51
- "nightwatch": "^0.9.21",
52
- "semantic-release": "^15.9.17"
45
+ "is-ci": "^3.0.1",
46
+ "jest": "^28.1.0",
47
+ "jest-environment-jsdom": "^28.1.0",
48
+ "jest-environment-jsdom-global": "^3.1.2",
49
+ "jsdoc-to-markdown": "^7.1.1",
50
+ "selenium-webdriver": "^4.0.0-alpha.7",
51
+ "semantic-release": "^19.0.2"
53
52
  },
54
53
  "publishConfig": {
55
54
  "access": "public"
56
- },
57
- "dependencies": {
58
- "chalk": "^2.4.2",
59
- "request": "^2.88.0",
60
- "semver": "^6.1.1"
61
55
  }
62
56
  }
package/postinstall.js DELETED
@@ -1,29 +0,0 @@
1
- /* eslint-env node */
2
- /* eslint-disable no-console */
3
- 'use strict';
4
-
5
- const chalk = require('chalk');
6
- const request = require('request');
7
- const semver = require('semver');
8
-
9
- const {version} = require('./package');
10
-
11
- const primaryColor = (text) => chalk.yellow(text);
12
- const highlight = (text) => chalk.cyan.bold(text);
13
-
14
- request.get('https://registry.npmjs.org/@smartcar/auth', function(err, res, body) {
15
- if (err) {
16
- return;
17
- }
18
-
19
- body = JSON.parse(body);
20
-
21
- const {latest} = body['dist-tags'];
22
-
23
- if (semver.gt(latest, version)) {
24
- console.warn(
25
- primaryColor('\nYour Smartcar JavaScript SDK is outdated! Please update by running:\n'),
26
- highlight('> npm i @smartcar/auth@latest\n'),
27
- );
28
- }
29
- });