Skip to content

Commit

Permalink
8.x (#218)
Browse files Browse the repository at this point in the history
* Fix CI

* Update .npmignore

* Update README.md

Warnings added

* Update README.md

* Fix #186

* Lower case vin search #182

* Fix build

* fix(veryShortDate): manage new date format

* fix(driveHistory): some values from the API can be undefined|null

* Possible breaking change if consumers were accessing vehicles via getVehicle(<id>)

The proper way to get the vehicle is by VIN passed as an argument

* 8.0.0

* fix(stamps): changed the way we read stamps file, using a frequency

* test(stamp): changing the stamp format on tests

* Rename workflows

* feat(cfb): stamp genartion

* chore: stamp mode distant

* chore: local stamp test

* Format

* Add ESM support and refactor start config

* Added kia support

Something like this should work for Kia, I was able to log in but I don't own a Kia to test it on

* Update lock file

* Update rollup

* Update CFB (unsure if this is needed)

* Update version

---------

Co-authored-by: PierreLevres <[email protected]>
Co-authored-by: David Balan <[email protected]>
Co-authored-by: mfried40 <[email protected]>
  • Loading branch information
4 people authored Apr 8, 2023
1 parent 58f101e commit 9c7c59f
Show file tree
Hide file tree
Showing 36 changed files with 12,188 additions and 17,721 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
],
rules: {
'@typescript-eslint/ban-ts-comment': 0,
'no-console': 2,
'quotes': [1, 'single', { 'avoidEscape': true }],
'semi': [1, 'always'],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: npm
name: CI

on:
pull_request:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npmpublish.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: npm
name: CD

on:
# Allow manual
Expand Down
12 changes: 11 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
lib/
config*.json
.env
.DS_Store
.rpt2_cache
src/
.github/
__tests__/
babel.config.js
debug.ts
jest.config.js
rollup.config.js
tsconfig.json
.editorconfig
.eslintrc.js
.prettierrc
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ Important information for login problems:
- If you experience login problems, please logout from the app on your phone and login again. You might need to ' upgrade ' your account to a generic Kia/Hyundai account, or create a new password or PIN.
- After you migrated your Bluelink account to a generic Hyundai account, or your UVO account to a generic Kia account, make sure that both accounts have the same credentials (userid and password) to avoid confusion in logging in.

### EU specific options
EU has specific Bluelinky options :

- `language`: The language to use when login into the system, it will also change the laguage of your mobile app. `en` by default.
- `stampMode`: *Advanced* The kind of stamping mechanism to use (`LOCAL` | `DISTANT`). `DISTANT` by default. :warning: though `LOCAL` seems to work properly, it's in beta for now.
- `stampFile`: *Advanced* The `DISTANT` stamp source to use. `https://raw.githubusercontent.com/neoPix/bluelinky-stamps/master/${brand}-${appId}.v2.json` by default.

### Custom Stamps
In the EU region, stamps are used to sign every API queries. These stamps have a 1 week validity. Those stamps are using a tricky algorithm and cannot be replicated by Bluelinky and have to be generated by an external solution. An http call is performed to get the existing tokens. It is possible to specify an other path using the `stampFile` option. This path can be a local file prefixed by `file://` or from any webserver.

Expand Down Expand Up @@ -88,3 +95,7 @@ The JSON file must respect [this format](https://github.com/neoPix/bluelinky-sta
## Show your support

Give a ⭐️ if this project helped you!

## Warnings
Using Bluelinky may result in draining your 12V battery when refreshing from the car too often.
Make sure you have read and understood the terms of use of your Kia or Hyundai account before using Bluelinky.
5 changes: 3 additions & 2 deletions __tests__/bluelinky.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ describe('BlueLinky', () => {

it('throws error when you pass invalid region', () => {
expect(() => {
const client = new BlueLinky({
new BlueLinky({
username: '[email protected]',
password: 'hunter1',
pin: '1234',
brand: 'hyundai',
// @ts-ignore
region: 'KR',
});
}).toThrowError('Your region is not supported yet.');
Expand Down Expand Up @@ -142,7 +143,7 @@ describe('BlueLinky', () => {
region: 'US',
});

client.on('ready', vehicles => {
client.on('ready', () => {
const veh1 = client.getVehicle('JEST_TESTING_1');
const veh2 = client.getVehicle('JEST_TESTING_2');

Expand Down
6 changes: 1 addition & 5 deletions __tests__/controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const getController = region => {
pin: '1234',
vin: '4444444444444',
vehicleId: undefined,
stampMode: 'LOCAL'
});

return controller;
Expand Down Expand Up @@ -74,11 +75,6 @@ describe('EuropeanController', () => {
const controller = getController('EU');
controller.session.accessToken = 'MockToken';

(got as any).mockReturnValueOnce({
body: {stamps: ['stamp1', 'stamp2'], generated: new Date().toISOString(), steps: 20000},
statusCode: 200,
});

(got as any).mockReturnValueOnce({
body: {
resMsg: {
Expand Down
4 changes: 4 additions & 0 deletions __tests__/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ describe('Utility', () => {
expect(parseDate('20210117')).toEqual(new Date('2021-01-17:00:00:00'));
});

it('parseDate converts very shortdate to date', () => {
expect(parseDate('202101')).toEqual(new Date('2021-01-01:00:00:00'));
});

it('addTime can add minutes to a date', () => {
const start = new Date('2021-01-18:12:00:00');
expect(addMinutes(start, 30)).toEqual(new Date('2021-01-18:12:30:00'));
Expand Down
Loading

0 comments on commit 9c7c59f

Please sign in to comment.