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

add europe ccs2 request #283

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
node_modules/
.DS_Store
.rpt2_cache
dist/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert this

config*.json
.vs/
.vscode/
coverage/
dist/
24 changes: 24 additions & 0 deletions dist/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { CanadianBrandEnvironment } from './constants/canada';
import { EuropeanBrandEnvironment } from './constants/europe';
import { ChineseBrandEnvironment } from './constants/china';
import { AustraliaBrandEnvironment } from './constants/australia';
import { Brand, VehicleStatusOptions } from './interfaces/common.interfaces';
export declare const ALL_ENDPOINTS: {
CA: (brand: Brand) => CanadianBrandEnvironment['endpoints'];
EU: (brand: Brand) => EuropeanBrandEnvironment['endpoints'];
CN: (brand: Brand) => ChineseBrandEnvironment['endpoints'];
AU: (brand: Brand) => AustraliaBrandEnvironment['endpoints'];
};
export declare const GEN2 = 2;
export declare const GEN1 = 1;
export type REGION = 'US' | 'CA' | 'EU' | 'CN' | 'AU';
export declare enum REGIONS {
US = "US",
CA = "CA",
EU = "EU",
CN = "CN",
AU = "AU"
}
export type ChargeTarget = 50 | 60 | 70 | 80 | 90 | 100;
export declare const POSSIBLE_CHARGE_LIMIT_VALUES: number[];
export declare const DEFAULT_VEHICLE_STATUS_OPTIONS: VehicleStatusOptions;
9 changes: 9 additions & 0 deletions dist/constants/america.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Brand } from '../interfaces/common.interfaces';
export interface AmericaBrandEnvironment {
brand: Brand;
host: string;
baseUrl: string;
clientId: string;
clientSecret: string;
}
export declare const getBrandEnvironment: (brand: Brand) => AmericaBrandEnvironment;
3 changes: 3 additions & 0 deletions dist/constants/australia.cfb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// <reference types="node" />
export declare const kiaCFB: Buffer;
export declare const hyundaiCFB: Buffer;
28 changes: 28 additions & 0 deletions dist/constants/australia.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { AustraliaBlueLinkyConfig } from '../controllers/australia.controller';
import { Brand } from '../interfaces/common.interfaces';
import { StampMode } from './stamps';
export interface AustraliaBrandEnvironment {
brand: Brand;
host: string;
baseUrl: string;
clientId: string;
appId: string;
endpoints: {
integration: string;
silentSignIn: string;
session: string;
login: string;
language: string;
redirectUri: string;
token: string;
};
basicToken: string;
stamp: () => Promise<string>;
}
type EnvironmentConfig = {
stampMode: StampMode;
stampsFile?: string;
};
type BrandEnvironmentConfig = Pick<AustraliaBlueLinkyConfig, 'brand'> & Partial<EnvironmentConfig>;
export declare const getBrandEnvironment: ({ brand, stampMode, stampsFile, }: BrandEnvironmentConfig) => AustraliaBrandEnvironment;
export {};
28 changes: 28 additions & 0 deletions dist/constants/canada.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Brand } from '../interfaces/common.interfaces';
export interface CanadianBrandEnvironment {
brand: Brand;
host: string;
baseUrl: string;
origin: 'SPA';
endpoints: {
login: string;
logout: string;
vehicleList: string;
vehicleInfo: string;
status: string;
remoteStatus: string;
lock: string;
unlock: string;
start: string;
stop: string;
locate: string;
hornlight: string;
verifyAccountToken: string;
verifyPin: string;
verifyToken: string;
setChargeTarget: string;
stopCharge: string;
startCharge: string;
};
}
export declare const getBrandEnvironment: (brand: Brand) => CanadianBrandEnvironment;
25 changes: 25 additions & 0 deletions dist/constants/china.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ChineseBlueLinkConfig } from '../controllers/chinese.controller';
import { Brand } from '../interfaces/common.interfaces';
export interface ChineseBrandEnvironment {
brand: Brand;
host: string;
baseUrl: string;
clientId: string;
appId: string;
endpoints: {
integration: string;
silentSignIn: string;
session: string;
login: string;
language: string;
redirectUri: string;
token: string;
};
basicToken: string;
GCMSenderID: string;
providerDeviceId: string;
pushRegId: string;
}
type BrandEnvironmentConfig = Pick<ChineseBlueLinkConfig, 'brand'>;
export declare const getBrandEnvironment: ({ brand, }: BrandEnvironmentConfig) => ChineseBrandEnvironment;
export {};
3 changes: 3 additions & 0 deletions dist/constants/europe.cfb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// <reference types="node" />
export declare const kiaCFB: Buffer;
export declare const hyundaiCFB: Buffer;
33 changes: 33 additions & 0 deletions dist/constants/europe.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { EuropeBlueLinkyConfig } from '../controllers/european.controller';
import { Brand } from '../interfaces/common.interfaces';
export type EULanguages = 'cs' | 'da' | 'nl' | 'en' | 'fi' | 'fr' | 'de' | 'it' | 'pl' | 'hu' | 'no' | 'sk' | 'es' | 'sv';
export declare const EU_LANGUAGES: EULanguages[];
export declare const DEFAULT_LANGUAGE: EULanguages;
export interface EuropeanBrandEnvironment {
brand: Brand;
host: string;
baseUrl: string;
clientId: string;
appId: string;
endpoints: {
integration: string;
silentSignIn: string;
session: string;
login: string;
language: string;
redirectUri: string;
token: string;
};
basicToken: string;
GCMSenderID: string;
stamp: () => Promise<string>;
brandAuthUrl: (options: {
language: EULanguages;
serviceId: string;
userId: string;
}) => string;
}
type EnvironmentConfig = Required<Pick<EuropeBlueLinkyConfig, 'stampMode'>> & Partial<Pick<EuropeBlueLinkyConfig, 'stampsFile'>>;
type BrandEnvironmentConfig = Pick<EuropeBlueLinkyConfig, 'brand'> & Partial<EnvironmentConfig>;
export declare const getBrandEnvironment: ({ brand, stampMode, stampsFile, }: BrandEnvironmentConfig) => EuropeanBrandEnvironment;
export {};
16 changes: 16 additions & 0 deletions dist/constants/stamps.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Brand } from '../interfaces/common.interfaces';
import { REGIONS } from '../constants';
export declare enum StampMode {
LOCAL = "LOCAL",
DISTANT = "DISTANT"
}
export declare const getStampFromFile: (stampFileKey: string, stampHost: string, stampsFile?: string) => () => Promise<string>;
export declare const getStampFromCFB: (appId: string, brand: Brand, region: REGIONS) => (() => Promise<string>);
export declare const getStampGenerator: ({ appId, brand, mode, region, stampHost, stampsFile, }: {
appId: string;
brand: Brand;
mode: StampMode;
region: REGIONS;
stampHost: string;
stampsFile?: string | undefined;
}) => (() => Promise<string>);
17 changes: 17 additions & 0 deletions dist/controllers/american.controller.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BlueLinkyConfig } from './../interfaces/common.interfaces';
import { Vehicle } from '../vehicles/vehicle';
import { SessionController } from './controller';
import { AmericaBrandEnvironment } from '../constants/america';
export interface AmericanBlueLinkyConfig extends BlueLinkyConfig {
region: 'US';
}
export declare class AmericanController extends SessionController<AmericanBlueLinkyConfig> {
private _environment;
constructor(userConfig: AmericanBlueLinkyConfig);
get environment(): AmericaBrandEnvironment;
private vehicles;
refreshAccessToken(): Promise<string>;
login(): Promise<string>;
logout(): Promise<string>;
getVehicles(): Promise<Array<Vehicle>>;
}
28 changes: 28 additions & 0 deletions dist/controllers/australia.controller.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { GotInstance, GotJSONFn } from 'got';
import { Vehicle } from '../vehicles/vehicle';
import { AustraliaBrandEnvironment } from './../constants/australia';
import { BlueLinkyConfig, Session } from './../interfaces/common.interfaces';
import { SessionController } from './controller';
import { StampMode } from '../constants/stamps';
export interface AustraliaBlueLinkyConfig extends BlueLinkyConfig {
region: 'AU';
stampMode?: StampMode;
stampsFile?: string;
}
export declare class AustraliaController extends SessionController<AustraliaBlueLinkyConfig> {
private _environment;
private authStrategy;
constructor(userConfig: AustraliaBlueLinkyConfig);
get environment(): AustraliaBrandEnvironment;
session: Session;
private vehicles;
refreshAccessToken(): Promise<string>;
enterPin(): Promise<string>;
login(): Promise<string>;
logout(): Promise<string>;
getVehicles(): Promise<Array<Vehicle>>;
private checkControlToken;
getVehicleHttpService(): Promise<GotInstance<GotJSONFn>>;
getApiHttpService(): Promise<GotInstance<GotJSONFn>>;
private get defaultHeaders();
}
17 changes: 17 additions & 0 deletions dist/controllers/authStrategies/australia.authStrategy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { CookieJar } from 'tough-cookie';
import { AuthStrategy, Code } from './authStrategy';
import { AustraliaBrandEnvironment } from '../../constants/australia';
export declare class AustraliaAuthStrategy implements AuthStrategy {
private readonly environment;
constructor(environment: AustraliaBrandEnvironment);
get name(): string;
login(user: {
username: string;
password: string;
}, options?: {
cookieJar: CookieJar;
}): Promise<{
code: Code;
cookies: CookieJar;
}>;
}
16 changes: 16 additions & 0 deletions dist/controllers/authStrategies/authStrategy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { CookieJar } from 'tough-cookie';
import { EULanguages, EuropeanBrandEnvironment } from '../../constants/europe';
export type Code = string;
export interface AuthStrategy {
readonly name: string;
login(user: {
username: string;
password: string;
}, options?: {
cookieJar?: CookieJar;
}): Promise<{
code: Code;
cookies: CookieJar;
}>;
}
export declare function initSession(environment: EuropeanBrandEnvironment, language?: EULanguages, cookies?: CookieJar): Promise<CookieJar>;
16 changes: 16 additions & 0 deletions dist/controllers/authStrategies/china.authStrategy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { CookieJar } from 'tough-cookie';
import { ChineseBrandEnvironment } from '../../constants/china';
export type Code = string;
export interface AuthStrategy {
readonly name: string;
login(user: {
username: string;
password: string;
}, options?: {
cookieJar?: CookieJar;
}): Promise<{
code: Code;
cookies: CookieJar;
}>;
}
export declare function initSession(environment: ChineseBrandEnvironment, cookies?: CookieJar): Promise<CookieJar>;
17 changes: 17 additions & 0 deletions dist/controllers/authStrategies/chinese.legacyAuth.strategy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { CookieJar } from 'tough-cookie';
import { ChineseBrandEnvironment } from '../../constants/china';
import { AuthStrategy, Code } from './china.authStrategy';
export declare class ChineseLegacyAuthStrategy implements AuthStrategy {
private readonly environment;
constructor(environment: ChineseBrandEnvironment);
get name(): string;
login(user: {
username: string;
password: string;
}, options?: {
cookieJar: CookieJar;
}): Promise<{
code: Code;
cookies: CookieJar;
}>;
}
18 changes: 18 additions & 0 deletions dist/controllers/authStrategies/european.brandAuth.strategy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { CookieJar } from 'tough-cookie';
import { EULanguages, EuropeanBrandEnvironment } from '../../constants/europe';
import { AuthStrategy, Code } from './authStrategy';
export declare class EuropeanBrandAuthStrategy implements AuthStrategy {
private readonly environment;
private readonly language;
constructor(environment: EuropeanBrandEnvironment, language: EULanguages);
get name(): string;
login(user: {
username: string;
password: string;
}, options?: {
cookieJar?: CookieJar;
}): Promise<{
code: Code;
cookies: CookieJar;
}>;
}
18 changes: 18 additions & 0 deletions dist/controllers/authStrategies/european.legacyAuth.strategy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { CookieJar } from 'tough-cookie';
import { EULanguages, EuropeanBrandEnvironment } from '../../constants/europe';
import { AuthStrategy, Code } from './authStrategy';
export declare class EuropeanLegacyAuthStrategy implements AuthStrategy {
private readonly environment;
private readonly language;
constructor(environment: EuropeanBrandEnvironment, language: EULanguages);
get name(): string;
login(user: {
username: string;
password: string;
}, options?: {
cookieJar: CookieJar;
}): Promise<{
code: Code;
cookies: CookieJar;
}>;
}
19 changes: 19 additions & 0 deletions dist/controllers/canadian.controller.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { BlueLinkyConfig } from '../interfaces/common.interfaces';
import { CanadianBrandEnvironment } from '../constants/canada';
import { Vehicle } from '../vehicles/vehicle';
import { SessionController } from './controller';
export interface CanadianBlueLinkyConfig extends BlueLinkyConfig {
region: 'CA';
}
export declare class CanadianController extends SessionController<CanadianBlueLinkyConfig> {
private _environment;
constructor(userConfig: CanadianBlueLinkyConfig);
get environment(): CanadianBrandEnvironment;
private vehicles;
private timeOffset;
refreshAccessToken(): Promise<string>;
login(): Promise<string>;
logout(): Promise<string>;
getVehicles(): Promise<Array<Vehicle>>;
private request;
}
26 changes: 26 additions & 0 deletions dist/controllers/chinese.controller.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ChineseBrandEnvironment } from '../constants/china';
import { BlueLinkyConfig, Session } from '../interfaces/common.interfaces';
import { GotInstance, GotJSONFn } from 'got';
import { Vehicle } from '../vehicles/vehicle';
import { SessionController } from './controller';
export interface ChineseBlueLinkConfig extends BlueLinkyConfig {
region: 'CN';
}
export declare class ChineseController extends SessionController<ChineseBlueLinkConfig> {
private _environment;
private authStrategies;
constructor(userConfig: ChineseBlueLinkConfig);
get environment(): ChineseBrandEnvironment;
ß: any;
session: Session;
private vehicles;
refreshAccessToken(): Promise<string>;
enterPin(): Promise<string>;
login(): Promise<string>;
logout(): Promise<string>;
getVehicles(): Promise<Array<Vehicle>>;
private checkControlToken;
getVehicleHttpService(): Promise<GotInstance<GotJSONFn>>;
getApiHttpService(): Promise<GotInstance<GotJSONFn>>;
private get defaultHeaders();
}
Loading
Loading