From 6d1a2fdc39c045517b4ae3b5b256600f34d7be4f Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Fri, 11 Nov 2022 09:25:29 +0700 Subject: [PATCH] Fixed axios and generate token --- CHANGELOG.md | 5 +++++ README.md | 20 ++++++++++---------- package-lock.json | 4 ++-- package.json | 2 +- src/client.ts | 7 ++++++- src/sdk.ts | 2 +- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9045f84..a91948b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### 11/11/2022 + +- Fixed axios is not a function +- Add generate token with data (clientId, apiKey) to server + ### 20/10/2022 - Upgraded packages and fixed some bugs diff --git a/README.md b/README.md index 5e27ee8..e8650cb 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ npm i -g @cubetiq/hlt OR -npx @cubetiq/hlt +npx -y @cubetiq/hlt ``` @@ -25,15 +25,15 @@ hlt [command] [options] ```shell # Initialize a client and token for connect (default's profile) -npx @cubetiq/hlt init +npx -y @cubetiq/hlt init # Start port 3000 to remote server -npx @cubetiq/hlt start 3000 +npx -y @cubetiq/hlt start 3000 ``` # Start port 3000 with suffix to remote server -npx @cubetiq/hlt start 3000 -s mytest +npx -y @cubetiq/hlt start 3000 -s mytest ```` @@ -41,10 +41,10 @@ npx @cubetiq/hlt start 3000 -s mytest ```shell # Initialize a client and token for connect (mytest's profile) -npx @cubetiq/hlt init -p mytest +npx -y @cubetiq/hlt init -p mytest # Start port 3000 to remote server (mytest's profile) -npx @cubetiq/hlt start 3000 -p mytest +npx -y @cubetiq/hlt start 3000 -p mytest ```` ### Custom Config @@ -52,25 +52,25 @@ npx @cubetiq/hlt start 3000 -p mytest - Generate Client Key ```shell -npx @cubetiq/hlt config client new +npx -y @cubetiq/hlt config client new ``` - Set Client Token (Required, contact to vendor) ```shell -npx @cubetiq/hlt config token $TOKEN +npx -y @cubetiq/hlt config token $TOKEN ``` - Set Custom Server ```shell -npx @cubetiq/hlt config server https://lt.ctdn.net +npx -y @cubetiq/hlt config server https://lt.ctdn.net ``` - Start Client ```shell -npx @cubetiq/hlt start $YOUR_PORT +npx -y @cubetiq/hlt start $YOUR_PORT ``` ### Contributors diff --git a/package-lock.json b/package-lock.json index 37c66e5..bc5e85b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cubetiq/hlt", - "version": "0.1.0", + "version": "0.1.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@cubetiq/hlt", - "version": "0.1.0", + "version": "0.1.2", "license": "ISC", "dependencies": { "axios": "^1.0.0", diff --git a/package.json b/package.json index b178010..e550941 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cubetiq/hlt", - "version": "0.1.1", + "version": "0.1.2", "description": "A lightweight http tunnel client using nodejs and socket.io client", "main": "dist/client.js", "bin": { diff --git a/src/client.ts b/src/client.ts index ed54795..b9aa793 100644 --- a/src/client.ts +++ b/src/client.ts @@ -265,8 +265,13 @@ program if (!config.token) { console.log("Generating token..."); - await getTokenFree(config.server) + await getTokenFree(config.server, { + timestamp: (new Date().getTime()), + clientId: config.clientId, + apiKey: config.apiKey, + }) .then((resp: any) => { + console.log("Token generated successfully!"); if (resp.data?.token) { config.token = resp.data?.token; } else { diff --git a/src/sdk.ts b/src/sdk.ts index a974a3f..8cf7470 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -1,4 +1,4 @@ -const axios = require("axios").default; +const axios = require("axios"); const getTokenFree = async (baseUrl: string, data: any = {}) => { const url = `${baseUrl}/__free__/api/get_token`;