Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

my suggestion #24

Closed
wants to merge 14 commits into from
Closed
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"extends": [
"eslint:recommended"
],
"plugins": [],
"plugins": ["import"],
"rules": {
"indent": [
"error",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Check if PR should be auto-merged
uses: ahmadnassri/action-dependabot-auto-merge@v2
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Feel free to follow the discussions in the german [iobroker forum](https://forum
- (bolliy) Added Admin 5 configuration
- (bolliy) ConnectEV: Update status before reading cachedeStatus
- (bolliy) improve State roles and types
- (bolliy) ConnectEV: Update Blowfish v4.1

### 0.1.2 (2024-05-31)

Expand Down
2 changes: 1 addition & 1 deletion lib/leaf-connect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const axios = require('axios');
const { stringify } = require('qs');
const encryptPassword = require('./lib/encrypt-password');
const encryptPassword = require('./lib/encrypt-password.js');
const extractData = require('./lib/extract-data');
const retryUntilSuccess = require('./lib/retry-until-success');
const logger = require('./lib/logger');
Expand Down
15 changes: 14 additions & 1 deletion lib/leaf-connect/lib/encrypt-password.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
// const crypto = require('crypto')
const Blowfish = require('egoroof-blowfish');
/*
v3
const { Blowfish } = require('egoroof-blowfish');
v4
const { Blowfish } = import('egoroof-blowfish');
https://stackoverflow.com/questions/70396400/how-to-use-es6-modules-in-commonjs
https://www.npmjs.com/package/eslint-import-resolver-typescript
*/

let Blowfish;
import('egoroof-blowfish').then(mod => {
Blowfish = mod.Blowfish; }
);

module.exports = (password, passwordEncryptionKey) => {
// const cipher = crypto.createCipheriv('bf-ecb', Buffer.from(passwordEncryptionKey), Buffer.from(''))
// let encrypted = cipher.update(password, 'utf8', 'base64')
// encrypted += cipher.final('base64')
const bf = new Blowfish(passwordEncryptionKey, Blowfish.MODE.ECB, Blowfish.PADDING.PKCS5); // only key isn't optional
// @ts-ignore
const encoded = bf.encode(password, Blowfish.TYPE.STRING);
//convert to base64
const encodedB64 = Buffer.from(encoded).toString('base64');
Expand Down
2 changes: 2 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class Nissan extends utils.Adapter {
if (!this.isReady) {
this.log.info('Connected to Nissan EV');
await this.getNissanEvVehicles();

}
} catch(error) {
this.isInLogin = false;
Expand Down Expand Up @@ -264,6 +265,7 @@ class Nissan extends utils.Adapter {
native: {},
});
});
this.isReady = true;
}

async login() {
Expand Down
Loading
Loading