Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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"
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.11.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.11.0
[version]: 2.12.0
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smartcar/auth",
"version": "2.11.0",
"version": "2.12.0",
"description": "javascript auth sdk for the smartcar",
"main": "dist/npm/sdk.js",
"license": "MIT",
Expand Down
34 changes: 34 additions & 0 deletions test/unit/sdk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,27 @@ describe('sdk', () => {
smartcar.messageHandler(event);
});

test("doesn't break if scope is not passed", () => {
const options = {
clientId: 'clientId',
};

const smartcar = new Smartcar(options);

const event = {
data: {
name: 'SmartcarAuthMessage',
isSmartcarHosted: false,
code: 'super-secret-code',
error: undefined,
state: getEncodedState(smartcar.instanceId, 'some-state'),
},
origin: 'https://selfhosted.com',
};

smartcar.messageHandler(event);
});

test("doesn't break if onComplete is not passed", () => {
const options = {
clientId: 'clientId',
Expand Down Expand Up @@ -1130,6 +1151,19 @@ describe('sdk', () => {
expect(link).toBe(expectedLink);
});

test('generates link without redirectUri and scope', () => {
const smartcar = new Smartcar({
clientId: 'clientId',
onComplete: jest.fn(),
});

const link = smartcar.getAuthUrl();

const expectedLink =
`https://connect.smartcar.com/oauth/authorize?response_type=code&client_id=clientId&approval_prompt=auto&mode=live&state=${getEncodedDefaultState(smartcar.instanceId)}`;
expect(link).toBe(expectedLink);
});

describe('openDialog and addClickHandler', () => {
const options = {
clientId: 'clientId',
Expand Down