vibekit-auth 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +35 -20
- package/dist/types.d.ts +1 -0
- package/dist/upload.d.ts +2 -1
- package/dist/upload.js +4 -2
- package/package.json +1 -1
- package/src/index.ts +36 -20
- package/src/types.ts +1 -0
- package/src/upload.ts +4 -1
package/dist/index.js
CHANGED
|
@@ -59,19 +59,19 @@ async function main() {
|
|
|
59
59
|
}
|
|
60
60
|
console.log();
|
|
61
61
|
// Step 2: Get Telegram ID
|
|
62
|
+
console.log(chalk_1.default.gray(' To find your Telegram ID, message @userinfobot on Telegram'));
|
|
63
|
+
console.log();
|
|
62
64
|
const response = await (0, prompts_1.default)([
|
|
63
65
|
{
|
|
64
66
|
type: 'text',
|
|
65
67
|
name: 'telegramId',
|
|
66
|
-
message: 'Enter your Telegram ID
|
|
67
|
-
hint: 'You can find your ID by messaging @userinfobot on Telegram',
|
|
68
|
+
message: 'Enter your numeric Telegram ID:',
|
|
68
69
|
validate: (value) => {
|
|
69
70
|
if (!value.trim()) {
|
|
70
71
|
return 'Telegram ID is required';
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return 'Enter a valid Telegram ID (number) or username (@username)';
|
|
73
|
+
if (isNaN(Number(value.trim()))) {
|
|
74
|
+
return 'Please enter your numeric ID (e.g., 123456789), not username';
|
|
75
75
|
}
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
@@ -81,30 +81,45 @@ async function main() {
|
|
|
81
81
|
console.log(chalk_1.default.yellow('\n Cancelled.'));
|
|
82
82
|
process.exit(0);
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
// If they entered a username, we need to resolve it
|
|
86
|
-
// For now, require numeric ID
|
|
87
|
-
if (telegramId.startsWith('@') || isNaN(Number(telegramId))) {
|
|
88
|
-
console.log();
|
|
89
|
-
console.log(chalk_1.default.yellow(' Please enter your numeric Telegram ID, not username.'));
|
|
90
|
-
console.log(chalk_1.default.gray(' To find your ID:'));
|
|
91
|
-
console.log(chalk_1.default.gray(' 1. Open Telegram'));
|
|
92
|
-
console.log(chalk_1.default.gray(' 2. Message @userinfobot'));
|
|
93
|
-
console.log(chalk_1.default.gray(' 3. It will reply with your numeric ID'));
|
|
94
|
-
console.log();
|
|
95
|
-
process.exit(1);
|
|
96
|
-
}
|
|
84
|
+
const telegramId = response.telegramId.trim();
|
|
97
85
|
const numericTelegramId = parseInt(telegramId, 10);
|
|
98
|
-
// Step 3:
|
|
86
|
+
// Step 3: Select session duration
|
|
87
|
+
console.log();
|
|
88
|
+
const durationResponse = await (0, prompts_1.default)([
|
|
89
|
+
{
|
|
90
|
+
type: 'select',
|
|
91
|
+
name: 'sessionDuration',
|
|
92
|
+
message: 'How long should Auto Mode stay active?',
|
|
93
|
+
choices: [
|
|
94
|
+
{ title: '1 day', value: 1 },
|
|
95
|
+
{ title: '7 days', value: 7 },
|
|
96
|
+
{ title: '30 days', value: 30 },
|
|
97
|
+
{ title: 'Until I disconnect', value: 0 },
|
|
98
|
+
],
|
|
99
|
+
initial: 2 // Default to 30 days
|
|
100
|
+
}
|
|
101
|
+
]);
|
|
102
|
+
if (durationResponse.sessionDuration === undefined) {
|
|
103
|
+
console.log(chalk_1.default.yellow('\n Cancelled.'));
|
|
104
|
+
process.exit(0);
|
|
105
|
+
}
|
|
106
|
+
const sessionDurationDays = durationResponse.sessionDuration;
|
|
107
|
+
// Step 4: Upload to server
|
|
99
108
|
console.log();
|
|
100
109
|
const uploadSpinner = (0, ora_1.default)('Uploading credentials to VibeKit...').start();
|
|
101
110
|
try {
|
|
102
|
-
const result = await (0, upload_1.uploadCredentials)(numericTelegramId, credentials, VIBEKIT_SERVER);
|
|
111
|
+
const result = await (0, upload_1.uploadCredentials)(numericTelegramId, credentials, sessionDurationDays, VIBEKIT_SERVER);
|
|
103
112
|
if (result.success) {
|
|
104
113
|
uploadSpinner.succeed(chalk_1.default.green('Credentials uploaded successfully!'));
|
|
105
114
|
console.log();
|
|
106
115
|
console.log(chalk_1.default.bold.green(' Auto Mode is ready!'));
|
|
107
116
|
console.log();
|
|
117
|
+
if (sessionDurationDays > 0) {
|
|
118
|
+
console.log(chalk_1.default.gray(` Session active for ${sessionDurationDays} day${sessionDurationDays > 1 ? 's' : ''}`));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
console.log(chalk_1.default.gray(' Session active until you disconnect'));
|
|
122
|
+
}
|
|
108
123
|
console.log(chalk_1.default.white(' Open Telegram and use /auto to start.'));
|
|
109
124
|
console.log(chalk_1.default.gray(' Your Claude subscription will be used for AI - no credits needed.'));
|
|
110
125
|
console.log();
|
package/dist/types.d.ts
CHANGED
package/dist/upload.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ClaudeOAuthCredentials, UploadResponse } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Upload credentials to VibeKit server
|
|
4
|
+
* @param sessionDurationDays - Number of days to keep session active (0 = until manual disconnect)
|
|
4
5
|
*/
|
|
5
|
-
export declare function uploadCredentials(telegramId: number, credentials: ClaudeOAuthCredentials, serverUrl?: string): Promise<UploadResponse>;
|
|
6
|
+
export declare function uploadCredentials(telegramId: number, credentials: ClaudeOAuthCredentials, sessionDurationDays: number, serverUrl?: string): Promise<UploadResponse>;
|
|
6
7
|
/**
|
|
7
8
|
* Check if user has existing auto mode credentials on server
|
|
8
9
|
*/
|
package/dist/upload.js
CHANGED
|
@@ -11,15 +11,17 @@ const url_1 = require("url");
|
|
|
11
11
|
const DEFAULT_SERVER_URL = 'https://vibekit.bot';
|
|
12
12
|
/**
|
|
13
13
|
* Upload credentials to VibeKit server
|
|
14
|
+
* @param sessionDurationDays - Number of days to keep session active (0 = until manual disconnect)
|
|
14
15
|
*/
|
|
15
|
-
async function uploadCredentials(telegramId, credentials, serverUrl = DEFAULT_SERVER_URL) {
|
|
16
|
+
async function uploadCredentials(telegramId, credentials, sessionDurationDays, serverUrl = DEFAULT_SERVER_URL) {
|
|
16
17
|
const url = new url_1.URL('/api/auto/credentials', serverUrl);
|
|
17
18
|
// Prepare payload - base64 encode the full credentials JSON
|
|
18
19
|
const payload = JSON.stringify({
|
|
19
20
|
telegramId,
|
|
20
21
|
credentials: Buffer.from(JSON.stringify(credentials)).toString('base64'),
|
|
21
22
|
subscriptionType: credentials.claudeAiOauth.subscriptionType,
|
|
22
|
-
expiresAt: credentials.claudeAiOauth.expiresAt
|
|
23
|
+
expiresAt: credentials.claudeAiOauth.expiresAt,
|
|
24
|
+
sessionDurationDays
|
|
23
25
|
});
|
|
24
26
|
return new Promise((resolve, reject) => {
|
|
25
27
|
const protocol = url.protocol === 'https:' ? https_1.default : http_1.default;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -67,19 +67,20 @@ async function main() {
|
|
|
67
67
|
console.log();
|
|
68
68
|
|
|
69
69
|
// Step 2: Get Telegram ID
|
|
70
|
+
console.log(chalk.gray(' To find your Telegram ID, message @userinfobot on Telegram'));
|
|
71
|
+
console.log();
|
|
72
|
+
|
|
70
73
|
const response = await prompts([
|
|
71
74
|
{
|
|
72
75
|
type: 'text',
|
|
73
76
|
name: 'telegramId',
|
|
74
|
-
message: 'Enter your Telegram ID
|
|
75
|
-
hint: 'You can find your ID by messaging @userinfobot on Telegram',
|
|
77
|
+
message: 'Enter your numeric Telegram ID:',
|
|
76
78
|
validate: (value: string) => {
|
|
77
79
|
if (!value.trim()) {
|
|
78
80
|
return 'Telegram ID is required';
|
|
79
81
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return 'Enter a valid Telegram ID (number) or username (@username)';
|
|
82
|
+
if (isNaN(Number(value.trim()))) {
|
|
83
|
+
return 'Please enter your numeric ID (e.g., 123456789), not username';
|
|
83
84
|
}
|
|
84
85
|
return true;
|
|
85
86
|
}
|
|
@@ -91,35 +92,50 @@ async function main() {
|
|
|
91
92
|
process.exit(0);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
const telegramId = response.telegramId.trim();
|
|
96
|
+
const numericTelegramId = parseInt(telegramId, 10);
|
|
95
97
|
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
// Step 3: Select session duration
|
|
99
|
+
console.log();
|
|
100
|
+
const durationResponse = await prompts([
|
|
101
|
+
{
|
|
102
|
+
type: 'select',
|
|
103
|
+
name: 'sessionDuration',
|
|
104
|
+
message: 'How long should Auto Mode stay active?',
|
|
105
|
+
choices: [
|
|
106
|
+
{ title: '1 day', value: 1 },
|
|
107
|
+
{ title: '7 days', value: 7 },
|
|
108
|
+
{ title: '30 days', value: 30 },
|
|
109
|
+
{ title: 'Until I disconnect', value: 0 },
|
|
110
|
+
],
|
|
111
|
+
initial: 2 // Default to 30 days
|
|
112
|
+
}
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
if (durationResponse.sessionDuration === undefined) {
|
|
116
|
+
console.log(chalk.yellow('\n Cancelled.'));
|
|
117
|
+
process.exit(0);
|
|
107
118
|
}
|
|
108
119
|
|
|
109
|
-
const
|
|
120
|
+
const sessionDurationDays = durationResponse.sessionDuration;
|
|
110
121
|
|
|
111
|
-
// Step
|
|
122
|
+
// Step 4: Upload to server
|
|
112
123
|
console.log();
|
|
113
124
|
const uploadSpinner = ora('Uploading credentials to VibeKit...').start();
|
|
114
125
|
|
|
115
126
|
try {
|
|
116
|
-
const result = await uploadCredentials(numericTelegramId, credentials, VIBEKIT_SERVER);
|
|
127
|
+
const result = await uploadCredentials(numericTelegramId, credentials, sessionDurationDays, VIBEKIT_SERVER);
|
|
117
128
|
|
|
118
129
|
if (result.success) {
|
|
119
130
|
uploadSpinner.succeed(chalk.green('Credentials uploaded successfully!'));
|
|
120
131
|
console.log();
|
|
121
132
|
console.log(chalk.bold.green(' Auto Mode is ready!'));
|
|
122
133
|
console.log();
|
|
134
|
+
if (sessionDurationDays > 0) {
|
|
135
|
+
console.log(chalk.gray(` Session active for ${sessionDurationDays} day${sessionDurationDays > 1 ? 's' : ''}`));
|
|
136
|
+
} else {
|
|
137
|
+
console.log(chalk.gray(' Session active until you disconnect'));
|
|
138
|
+
}
|
|
123
139
|
console.log(chalk.white(' Open Telegram and use /auto to start.'));
|
|
124
140
|
console.log(chalk.gray(' Your Claude subscription will be used for AI - no credits needed.'));
|
|
125
141
|
console.log();
|
package/src/types.ts
CHANGED
package/src/upload.ts
CHANGED
|
@@ -7,10 +7,12 @@ const DEFAULT_SERVER_URL = 'https://vibekit.bot';
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Upload credentials to VibeKit server
|
|
10
|
+
* @param sessionDurationDays - Number of days to keep session active (0 = until manual disconnect)
|
|
10
11
|
*/
|
|
11
12
|
export async function uploadCredentials(
|
|
12
13
|
telegramId: number,
|
|
13
14
|
credentials: ClaudeOAuthCredentials,
|
|
15
|
+
sessionDurationDays: number,
|
|
14
16
|
serverUrl: string = DEFAULT_SERVER_URL
|
|
15
17
|
): Promise<UploadResponse> {
|
|
16
18
|
const url = new URL('/api/auto/credentials', serverUrl);
|
|
@@ -20,7 +22,8 @@ export async function uploadCredentials(
|
|
|
20
22
|
telegramId,
|
|
21
23
|
credentials: Buffer.from(JSON.stringify(credentials)).toString('base64'),
|
|
22
24
|
subscriptionType: credentials.claudeAiOauth.subscriptionType,
|
|
23
|
-
expiresAt: credentials.claudeAiOauth.expiresAt
|
|
25
|
+
expiresAt: credentials.claudeAiOauth.expiresAt,
|
|
26
|
+
sessionDurationDays
|
|
24
27
|
});
|
|
25
28
|
|
|
26
29
|
return new Promise((resolve, reject) => {
|