feat: update authentication method to use x-api-key header

- Replace Bearer token authentication with x-api-key header across all commands
- Update token verification endpoints from auth.verifyToken to user.get
- Remove unnecessary console.log debug statements
- Bump version to v0.2.7
This commit is contained in:
Mauricio Siu
2025-03-04 00:13:51 -06:00
parent 21dd3f0b53
commit 82aed684b9
30 changed files with 40 additions and 83 deletions

View File

@@ -132,7 +132,7 @@ export default class AppCreate extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -107,7 +107,7 @@ export default class AppDelete extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -107,7 +107,7 @@ export default class AppDeploy extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -102,7 +102,7 @@ export default class AppStop extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -83,12 +83,11 @@ export default class Authenticate extends Command {
try {
console.log(`\n${chalk.blue("Validating server...")}`);
await axios.post(
`${url}/api/trpc/auth.verifyToken`,
{},
await axios.get(
`${url}/api/trpc/user.get`,
{
headers: {
Authorization: `Bearer ${token}`,
"x-api-key": token,
"Content-Type": "application/json",
},
},
@@ -104,3 +103,7 @@ export default class Authenticate extends Command {
}
}
}
// curl -X 'GET' \
// 'https://panel.jinza.app/api/project.all' \
// -H 'accept: application/json' \
// -H 'x-api-key: EawCkTREMhxoAqvCxJFZurgCGoDZPjYHHrLgUPghRjJTpXLaahFdhCOGfABZXTRP'

View File

@@ -182,17 +182,6 @@ export default class DatabaseMariadbCreate extends Command {
}
try {
console.log(JSON.stringify({
name,
databaseName,
description,
databaseRootPassword,
databasePassword,
databaseUser,
dockerImage,
appName,
projectId,
}, null, 2));
const response = await axios.post(
`${auth.url}/api/trpc/mariadb.create`,
{
@@ -210,7 +199,7 @@ export default class DatabaseMariadbCreate extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -102,7 +102,7 @@ export default class DatabaseMariadbDelete extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -103,7 +103,7 @@ export default class DatabaseMariadbDeploy extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -103,7 +103,7 @@ export default class DatabaseMariadbStop extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -186,7 +186,7 @@ export default class DatabaseMongoCreate extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -106,7 +106,7 @@ export default class DatabaseMongoDelete extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -103,7 +103,7 @@ export default class DatabaseMongoDeploy extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -103,7 +103,7 @@ export default class DatabaseMongoStop extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -183,17 +183,6 @@ export default class DatabaseMysqlCreate extends Command {
}
try {
console.log(JSON.stringify({
name,
databaseName,
description,
databaseRootPassword,
databasePassword,
databaseUser,
dockerImage,
appName,
projectId,
}, null, 2));
const response = await axios.post(
`${auth.url}/api/trpc/mysql.create`,
@@ -212,7 +201,7 @@ export default class DatabaseMysqlCreate extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -106,7 +106,7 @@ export default class DatabaseMysqlDelete extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -85,7 +85,7 @@ export default class DatabaseMysqlDeploy extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -85,7 +85,7 @@ export default class DatabaseMysqlStop extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -169,16 +169,6 @@ export default class DatabasePostgresCreate extends Command {
}
try {
console.log(JSON.stringify({
name,
databaseName,
description,
databasePassword,
databaseUser,
dockerImage,
appName,
projectId,
}, null, 2));
const response = await axios.post(
`${auth.url}/api/trpc/postgres.create`,
@@ -196,7 +186,7 @@ export default class DatabasePostgresCreate extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -106,7 +106,7 @@ export default class DatabasePostgresDelete extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -103,7 +103,7 @@ export default class DatabasePostgresDeploy extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -103,7 +103,7 @@ export default class DatabasePostgresStop extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -145,15 +145,6 @@ export default class DatabaseRedisCreate extends Command {
}
try {
console.log(JSON.stringify({
name,
description,
databasePassword,
dockerImage,
appName,
projectId,
}, null, 2));
const response = await axios.post(
`${auth.url}/api/trpc/redis.create`,
{
@@ -168,7 +159,7 @@ export default class DatabaseRedisCreate extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -106,7 +106,7 @@ export default class DatabaseRedisDelete extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -103,7 +103,7 @@ export default class DatabaseRedisDeploy extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -103,7 +103,7 @@ export default class DatabaseRedisStop extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -91,7 +91,7 @@ export default class EnvPush extends Command {
}, {
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
}
@@ -114,7 +114,7 @@ export default class EnvPush extends Command {
}
}, {
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
}

View File

@@ -75,10 +75,6 @@ export default class ProjectCreate extends Command {
}
try {
console.log(JSON.stringify({
name,
description,
}, null, 2));
const response = await axios.post(
`${auth.url}/api/trpc/project.create`,
@@ -90,7 +86,7 @@ export default class ProjectCreate extends Command {
},
{
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
},

View File

@@ -58,12 +58,11 @@ export default class Verify extends Command {
try {
console.log(chalk.blue("Validating token with server..."));
const response = await axios.post(
`${url}/api/trpc/auth.verifyToken`,
{},
const response = await axios.get(
`${url}/api/trpc/user.get`,
{
headers: {
Authorization: `Bearer ${token}`,
"x-api-key": token,
"Content-Type": "application/json",
},
},

View File

@@ -19,7 +19,7 @@ export const getProjects = async (
try {
const response = await axios.get(`${auth.url}/api/trpc/project.all`, {
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
});
@@ -53,7 +53,7 @@ export const getProject = async (
}
const response = await axios.get(`${auth.url}/api/trpc/project.one`, {
headers: {
Authorization: `Bearer ${auth.token}`,
"x-api-key": auth.token,
"Content-Type": "application/json",
},
params: {