Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ce7f440
chore: update package-lock for npm v8
s-ashwinkumar Dec 29, 2021
f665b41
Merge pull request #62 from smartcar/update-to-npmv8
s-ashwinkumar Jan 12, 2022
7ec2557
chore(deps): bump async from 2.6.3 to 2.6.4 (#64)
dependabot[bot] Jun 1, 2022
50177fa
chore(deps): bump node-fetch from 2.6.6 to 2.6.7 (#65)
dependabot[bot] Jun 3, 2022
ce18cfe
chore(ci): move to Node.js 16
gurpreetatwal Jun 3, 2022
f7c0d80
chore(ci): upgrade to latest semantic-release
gurpreetatwal Jun 3, 2022
3849d64
chore: perform a minimal upgrade to Gulp v4
gurpreetatwal Jun 3, 2022
ac3521f
chore: upgrade to Babel 7
gurpreetatwal Jun 3, 2022
f56f12b
chore: update all gulp plugins
gurpreetatwal Jun 3, 2022
de09208
chore: remove the postinstall hook
gurpreetatwal Jun 3, 2022
0150478
chore: upgrade to Gulp v4 (#67)
gurpreetatwal Jun 3, 2022
4dbd9e6
chore(deps-dev): bump semantic-release from 19.0.2 to 19.0.3 (#69)
dependabot[bot] Jun 10, 2022
b04a4f0
refactor: switch from nightwatch to selenium-webdriver
gurpreetatwal Aug 1, 2020
fd305bf
chore: update all dependencies
gurpreetatwal Oct 30, 2020
e7aa0ab
merge: Package Updates + Nightwatch -> Selenium (#68)
gurpreetatwal Jun 21, 2022
2a7e162
feat(smartcar): added support for simulated mode and feature flags (#70)
mdheri Jul 21, 2022
2e9a93c
(fix) version update to 2.9 (#72)
mdheri Jul 22, 2022
fcabfc0
chore(ci): fix release process (#73)
gurpreetatwal Jul 22, 2022
8c6278c
chore: remove legacy HTML from gulpfile (#74)
gurpreetatwal Jul 22, 2022
8a13f06
chore: fixed redirect uri dead link (#75)
mdheri Jul 25, 2022
09788bd
feat: add virtualKeyUrl argument to onComplete handler
allisonc07 Nov 30, 2023
fa1310d
chore: prepare release
allisonc07 Nov 30, 2023
0eb4690
chore: revert lint command change
allisonc07 Nov 30, 2023
3e102a1
lint: remove extra space
allisonc07 Nov 30, 2023
b937ca5
Merge pull request #80 from smartcar/add-virtual-key
allisonc07 Dec 19, 2023
7342b5f
feat: trigger release (#82)
allisonc07 Dec 20, 2023
81ded35
feat: add user param for auth URL (#83)
allisonc07 Apr 3, 2024
b231ba7
[EXP-1024] feat: make redirect_uri optional (#86)
allisonc07 Sep 25, 2025
12b085a
feat: move ci/cd and make redirect and scope optional (#87)
angieashields Nov 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"presets": [
[
"env",
"@babel/preset-env",
{
"targets": {
"chrome": 52,
"browsers": ["last 2 major versions", ">5% in US"]
},
"modules": false
Expand Down
29 changes: 29 additions & 0 deletions .buddy/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
- pipeline: "CD"
events:
- type: PUSH
refs:
- refs/heads/master
fail_on_prepare_env_warning: true
actions:
- action: "Install Dependencies"
type: "BUILD"
docker_image_name: "library/node"
docker_image_tag: "20"
execute_commands:
- "npm ci"
volume_mappings:
- "/:/buddy/javascript-sdk"
shell: "BASH"

- action: "Publish Release"
type: "BUILD"
docker_image_name: "library/node"
docker_image_tag: "20"
setup_commands:
- "apt-get update || true"
- "apt-get install -y jq"
execute_commands:
- "npx semantic-release --extends ./build/sr-configs/publish.js"
volume_mappings:
- "/:/buddy/javascript-sdk"
shell: "BASH"
79 changes: 79 additions & 0 deletions .buddy/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
- pipeline: "CI"
events:
- type: PUSH
refs:
- refs/heads/*
fail_on_prepare_env_warning: true
actions:
- action: "Install Dependencies"
type: "BUILD"
docker_image_name: "library/node"
docker_image_tag: "20"
execute_commands:
- "npm ci"
volume_mappings:
- "/:/buddy/javascript-sdk"
shell: "BASH"

- action: "Run Tests"
type: "BUILD"
docker_image_name: "library/node"
docker_image_tag: "20"
execute_commands:
- "# Set Firefox environment variables to help with headless operation"
- "Xvfb :99 -screen 0 1280x1024x24 &"
- "export DISPLAY=:99.0"
- "export MOZ_HEADLESS=1"
- "export MOZ_NO_REMOTE=1"
- "export PATH=${HOME}/firefox-latest/firefox:$PATH"
- "firefox --version"
- "firefox -headless &"
- "npm run cover"
setup_commands:
- "apt-get update --fix-missing || (sleep 5 && apt-get update --fix-missing)"
- "apt-get install -y libgtk-3-0 libasound2 libdbus-glib-1-2 libx11-xcb1 libxt6 libnss3 libxtst6 libxss1 libpci3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxcomposite1 libxdamage1 libxfixes3 libxkbcommon0 libxrandr2 xvfb wget"
- ""
- ""
- "# Download the latest Firefox"
- wget -O /tmp/firefox-latest.tar.xz 'https://download.mozilla.org/?product=firefox-latest&lang=en-US&os=linux64'
- "mkdir -p ${HOME}/firefox-latest"
- "tar -xJf /tmp/firefox-latest.tar.xz -C ${HOME}/firefox-latest"
volume_mappings:
- "/:/buddy/javascript-sdk"
shell: "BASH"

- action: "Upload Coverage"
type: "BUILD"
working_directory: "/buddy/javascript-sdk"
docker_image_name: "library/node"
docker_image_tag: "20"
execute_commands:
- "bash <(curl -s https://codecov.io/bash)"
volume_mappings:
- "/:/buddy/javascript-sdk"
shell: "BASH"

- action: "Verify Documentation"
type: "BUILD"
docker_image_name: "library/node"
docker_image_tag: "20"
execute_commands:
- "npm run readme"
- "npm run jsdoc"
- "git diff --exit-code --name-only README.md doc/README.md || (echo 'Documentation is out of date. Please run npm run readme and npm run jsdoc to update.' && exit 1)"
volume_mappings:
- "/:/buddy/javascript-sdk"
shell: "BASH"

- action: "Semantic Release Verify"
type: "BUILD"
docker_image_name: "library/node"
docker_image_tag: "20"
setup_commands:
- "apt-get update || true"
- "apt-get install -y jq"
execute_commands:
- "npx semantic-release --branches \"$BUDDY_EXECUTION_BRANCH\" --extends ./build/sr-configs/verify.js"
volume_mappings:
- "/:/buddy/javascript-sdk"
shell: "BASH"
11 changes: 0 additions & 11 deletions .eslintrc.js

This file was deleted.

6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "smartcar/browser",
"rules": {
"no-restricted-syntax": "off"
}
}
20 changes: 12 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
sudo: required
dist: bionic

services:
- xvfb

addons:
firefox: latest

language:
- node_js

node_js:
- '10'
- '16'

services:
- docker
Expand All @@ -13,6 +19,7 @@ if: tag IS blank # do not build tags

install:
- npm ci
- firefox -headless &

stages:
- test
Expand All @@ -21,16 +28,13 @@ stages:
jobs:
include:
- stage: test
node_js: '10'
before_install:
- docker run --name selenium-container -d --net host -v /dev/shm:/dev/shm selenium/standalone-chrome
node_js: '16'
script:
- npm test
- npm run cover
- bash <(curl -s https://codecov.io/bash)
- git clone --mirror https://github.com/smartcar/javascript-sdk.git
- npx semantic-release --branch "$TRAVIS_BRANCH" --extends ./build/sr-configs/verify.js --repository-url ./javascript-sdk.git
- npx semantic-release --branches "$TRAVIS_BRANCH" --extends ./build/sr-configs/verify.js
- stage: publish
node_js: '10'
node_js: '16'
if: branch = master
script: npx semantic-release --extends ./build/sr-configs/publish.js
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ npm install @smartcar/auth
### Smartcar CDN

```html
<script src="https://javascript-sdk.smartcar.com/2.8.0/sdk.js"></script>
<script src="https://javascript-sdk.smartcar.com/2.12.0/sdk.js"></script>
```

## SDK reference
Expand Down Expand Up @@ -178,4 +178,4 @@ https://application-backend.com/page?error=access_denied&error_description=User+
[tag-image]: https://img.shields.io/github/tag/smartcar/javascript-sdk.svg

<!-- Please do not modify or remove this, it is used by the build process -->
[version]: 2.8.0
[version]: 2.12.0
6 changes: 5 additions & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ Initializes Smartcar class.
| options.redirectUri | <code>String</code> | | the registered redirect uri of the application |
| [options.scope] | <code>Array.&lt;String&gt;</code> | | requested permission scopes |
| [options.onComplete] | [<code>OnComplete</code>](#OnComplete) | | called on completion of Smartcar Connect |
| [options.testMode] | <code>Boolean</code> | <code>false</code> | launch Smartcar Connect in test mode |
| [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/). |
| [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. |

<a name="Smartcar+getAuthUrl"></a>

Expand All @@ -71,6 +72,7 @@ Generates Smartcar OAuth URL.
| [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. |
| [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. |
| [options.flags] | <code>Array.&lt;String&gt;</code> | | An optional space-separated list of feature flags that your application has early access to. |
| [options.user] | <code>String</code> | | An optional unique identifier for a vehicle owner. This identifier is used to aggregate analytics across Connect sessions for each vehicle owner. |

**Example**
```js
Expand All @@ -84,6 +86,7 @@ response_type=code
&single_select=true
&single_select_vin=5YJSA1E14FF101307
&flags=country:DE color:00819D
&user=2dad4eaf-9094-4bff-bb0f-ffbbdde8b562
```
<a name="Smartcar+openDialog"></a>

Expand Down Expand Up @@ -202,6 +205,7 @@ Invalid subscription error returned by Connect.
| error | <code>Error</code> | something went wrong in Connect; this normally indicates that the user denied access to your application or does not have a connected vehicle |
| code | <code>String</code> | the authorization code to be exchanged from a backend sever for an access token |
| [state] | <code>Object</code> | contains state if it was set on the initial authorization request |
| [virtualKeyUrl] | <code>String</code> | virtual key URL used by Tesla to register Smartcar's virtual key on a vehicle. This registration will be required in order to use any commands on a Tesla vehicle. It is an optional argument as it is only included in specific cases. |

<a name="WindowOptions"></a>

Expand Down
91 changes: 27 additions & 64 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ gulp.task('build:umd', function() {
/**
* Build sdk.js for npm publishing.
*/
gulp.task('build:npm', ['build:umd'], function() {
return gulp
.src('dist/umd/sdk.js')
.pipe(babel())
.pipe(gulp.dest('dist/npm'));
});
gulp.task(
'build:npm',
gulp.series('build:umd', function buildNPM() {
return gulp
.src('dist/umd/sdk.js')
.pipe(babel())
.pipe(gulp.dest('dist/npm'));
}),
);

/**
* Build redirect for CDN publishing.
Expand All @@ -72,18 +75,21 @@ gulp.task('build:cdn:redirect', function() {
/**
* Build SDK for CDN publishing.
*/
gulp.task('build:cdn:sdk', ['build:umd'], function() {
return gulp
.src('dist/umd/sdk.js')
.pipe(babel())
.pipe(uglify())
.pipe(gulp.dest(`dist/cdn/${version}`));
});
gulp.task(
'build:cdn:sdk',
gulp.series('build:umd', function buildCDNSdk() {
return gulp
.src('dist/umd/sdk.js')
.pipe(babel())
.pipe(uglify())
.pipe(gulp.dest(`dist/cdn/${version}`));
}),
);

/**
* Build all JS for CDN publishing.
*/
gulp.task('build:cdn:js', ['build:cdn:redirect', 'build:cdn:sdk']);
gulp.task('build:cdn:js', gulp.parallel('build:cdn:redirect', 'build:cdn:sdk'));

/**
* Build HTML for CDN publishing
Expand All @@ -96,48 +102,16 @@ gulp.task('build:cdn:html', function() {
.pipe(gulp.dest(`dist/cdn/v${majorVersion}`));
});

/**
* Legacy support for accessing redirect via old URL scheme publishing.
*
* Previously, files would be `redirect-{semver}`. Now they are
* `v{majorVersion}/redirect`.
*
* Based on usage data, customers only use 2.0.0, 2.1.0, and 2.1.1 at the time
* of this change, so we chose to explicitly provide backwards compatibility for
* these version only.
*
*/
gulp.task('build:cdn:html:legacy', function(done) {
// We should only update old files while we're on major version 2
if (Number(majorVersion) !== 2) {
return done();
}

return gulp
.src('src/redirect.html')
.pipe(template({majorVersion: '2'}))
.pipe(rename('redirect-2.0.0'))
.pipe(gulp.dest('dist/cdn/legacy'))
.pipe(rename('redirect-2.1.0'))
.pipe(gulp.dest('dist/cdn/legacy'))
.pipe(rename('redirect-2.1.1'))
.pipe(gulp.dest('dist/cdn/legacy'));
});

/**
* Build all tasks for CDN publishing.
*/
gulp.task('build:cdn', ['build:cdn:js', 'build:cdn:html', 'build:cdn:html:legacy']);
gulp.task('build:cdn', gulp.parallel('build:cdn:js', 'build:cdn:html'));

/**
* Build all tasks for CDN and npm publishing.
*
* dist/
* ├── cdn
* │ ├── legacy
* │ │ ├── redirect-2.0.0 // Legacy HTML files proxy v2 files
* │ │ ├── redirect-2.1.0
* │ │ └── redirect-2.1.1
* │ ├── v2 // Only major versions of redirect are exposed
* │ │ ├── redirect // HTML file
* │ │ └── redirect.js // Referenced by both the new and old HTML files
Expand All @@ -148,28 +122,14 @@ gulp.task('build:cdn', ['build:cdn:js', 'build:cdn:html', 'build:cdn:html:legacy
* └── umd
* └── sdk.js
*/
gulp.task('build', ['build:cdn', 'build:npm']);
gulp.task('build', gulp.parallel('build:cdn', 'build:npm'));

// Setup AWS publisher to the Smartcar CDN.
const publisher = awspublish.create({
region: 'us-west-2',
params: {Bucket: 'smartcar-production-javascript-sdk'},
});

/**
* Publish legacy HTML to the CDN. These files must be uploaded to the root of
* the bucket and depend on /v2/redirect.js existing.
*
* We strip the `.html` extension from our html file so add content-type header
* to identify the file as `text/html`.
*/
gulp.task('publish:cdn:html:legacy', function() {
return gulp
.src('dist/cdn/legacy/*')
.pipe(publisher.publish({'content-type': 'text/html'}))
.pipe(awspublish.reporter());
});

/**
* Publish HTML to the CDN in the major version folder (e.g. /v2/redirect).
*
Expand Down Expand Up @@ -209,9 +169,12 @@ gulp.task('publish:cdn:sdk', function() {
/**
* Publish JS to the CDN.
*/
gulp.task('publish:cdn:js', ['publish:cdn:sdk', 'publish:cdn:redirect']);
gulp.task(
'publish:cdn:js',
gulp.parallel('publish:cdn:sdk', 'publish:cdn:redirect'),
);

/**
* Publish all files to the CDN.
*/
gulp.task('publish:cdn', ['publish:cdn:js', 'publish:cdn:html', 'publish:cdn:html:legacy']);
gulp.task('publish:cdn', gulp.parallel('publish:cdn:js', 'publish:cdn:html'));
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module.exports = {
testEnvironment: 'jest-environment-jsdom-global',
testURL: 'http://localhost/',
moduleFileExtensions: ['js'],
moduleDirectories: ['node_modules'],
coverageThreshold: {
Expand All @@ -15,4 +14,7 @@ module.exports = {
statements: 100,
},
},
testEnvironmentOptions: {
url: 'http://localhost/',
},
};
Loading