@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 +2 -2
- package/dist/npm/sdk.js +20 -18
- package/package.json +1 -1
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.
|
|
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.
|
|
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
|
-
|
|
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
|
|
295
|
-
//
|
|
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 (
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
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
|
-
|
|
537
|
+
var usesOldUriScheme = /redirect-[0-9]+\.[0-9]+\.[0-9]+\?/.test(options.redirectUri);
|
|
537
538
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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
|
}
|