@smartcar/auth 2.11.0 → 2.12.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.11.0/sdk.js"></script>
27
+ <script src="https://javascript-sdk.smartcar.com/2.12.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.11.0
181
+ [version]: 2.12.0
package/dist/npm/sdk.js CHANGED
@@ -137,7 +137,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
137
137
 
138
138
  this.messageHandler = function (event) {
139
139
  // bail if message from unexpected source
140
- if (!_this.redirectUri.startsWith(event.origin)) {
140
+ if (_this.redirectUri && !_this.redirectUri.startsWith(event.origin)) {
141
141
  return;
142
142
  }
143
143
 
@@ -288,11 +288,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
288
288
  link += 'https://connect.smartcar.com/oauth/authorize';
289
289
  link += "?response_type=".concat(this.responseType);
290
290
  link += "&client_id=".concat(this.clientId);
291
- link += "&redirect_uri=".concat(encodeURIComponent(this.redirectUri)); // map forcePrompt to approvalPrompt, two options: 'force' and 'auto'
291
+
292
+ if (this.redirectUri) {
293
+ link += "&redirect_uri=".concat(encodeURIComponent(this.redirectUri));
294
+ } // map forcePrompt to approvalPrompt, two options: 'force' and 'auto'
295
+
292
296
 
293
297
  var forcePrompt = options.forcePrompt === true;
294
- link += "&approval_prompt=".concat(forcePrompt ? 'force' : 'auto'); // If scope is not specified, Smartcar will default to requesting all scopes
295
- // from the user
298
+ link += "&approval_prompt=".concat(forcePrompt ? 'force' : 'auto'); // If scope is not specified, Smartcar will default to requesting the application's vehicle
299
+ // access configuration if available or the default set of permissions
296
300
 
297
301
  if (this.scope) {
298
302
  link += "&scope=".concat(encodeURIComponent(this.scope.join(' ')));
@@ -522,22 +526,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
522
526
  throw new TypeError('A client ID option must be provided');
523
527
  }
524
528
 
525
- if (!options.redirectUri) {
526
- throw new TypeError('A redirect URI option must be provided');
527
- }
528
-
529
- if (options.redirectUri.startsWith('https://javascript-sdk.smartcar.com')) {
530
- // require onComplete method with at least two parameters (error & code)
531
- // when hosting on Smartcar CDN
532
- if (!options.onComplete || options.onComplete.length < 2) {
533
- throw new Error("When using Smartcar's CDN redirect an onComplete function with at" + ' least 2 parameters (error & code) is required to handle' + ' completion of Connect');
534
- }
529
+ if (options.redirectUri) {
530
+ if (options.redirectUri.startsWith('https://javascript-sdk.smartcar.com')) {
531
+ // require onComplete method with at least two parameters (error & code)
532
+ // when hosting on Smartcar CDN
533
+ if (!options.onComplete || options.onComplete.length < 2) {
534
+ throw new Error("When using Smartcar's CDN redirect an onComplete function with at" + ' least 2 parameters (error & code) is required to handle' + ' completion of Connect');
535
+ }
535
536
 
536
- var usesOldUriScheme = /redirect-[0-9]+\.[0-9]+\.[0-9]+\?/.test(options.redirectUri);
537
+ var usesOldUriScheme = /redirect-[0-9]+\.[0-9]+\.[0-9]+\?/.test(options.redirectUri);
537
538
 
538
- if (usesOldUriScheme) {
539
- // eslint-disable-next-line no-console
540
- console.warn("\nThe Smartcar redirect URI you're using is outdated! To update it, please see:\nhttps://github.com/smartcar/javascript-sdk#1-register-a-javascript-sdk-redirect-uri\n");
539
+ if (usesOldUriScheme) {
540
+ // eslint-disable-next-line no-console
541
+ console.warn("\nThe Smartcar redirect URI you're using is outdated! To update it, please see:\nhttps://github.com/smartcar/javascript-sdk#1-register-a-javascript-sdk-redirect-uri\n");
542
+ }
541
543
  }
542
544
  }
543
545
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartcar/auth",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "javascript auth sdk for the smartcar",
5
5
  "main": "dist/npm/sdk.js",
6
6
  "license": "MIT",