repofence 0.2.1 → 0.2.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/commands/auth.js +24 -4
- package/dist/core/api-client.js +9 -0
- package/package.json +3 -1
package/dist/commands/auth.js
CHANGED
|
@@ -8,6 +8,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const promises_1 = __importDefault(require("readline/promises"));
|
|
9
9
|
const process_1 = require("process");
|
|
10
10
|
const auth_1 = require("../core/auth");
|
|
11
|
+
const api_client_1 = require("../core/api-client");
|
|
11
12
|
const open_1 = __importDefault(require("open"));
|
|
12
13
|
const promptToken = async () => {
|
|
13
14
|
const rl = promises_1.default.createInterface({ input: process_1.stdin, output: process_1.stdout });
|
|
@@ -15,6 +16,7 @@ const promptToken = async () => {
|
|
|
15
16
|
rl.close();
|
|
16
17
|
return answer;
|
|
17
18
|
};
|
|
19
|
+
const isJwt = (token) => token.split('.').length === 3;
|
|
18
20
|
const authCommand = async (_cwd, options) => {
|
|
19
21
|
if (options.web) {
|
|
20
22
|
const authBase = process.env.REPOFENCE_AUTH_URL || 'https://repofence.com/pricing';
|
|
@@ -34,12 +36,30 @@ const authCommand = async (_cwd, options) => {
|
|
|
34
36
|
console.log(chalk_1.default.dim('─'.repeat(60)) + '\n');
|
|
35
37
|
return;
|
|
36
38
|
}
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
39
|
+
const rawToken = options.token ?? (await promptToken());
|
|
40
|
+
if (!rawToken) {
|
|
39
41
|
throw new Error('No token provided; try again with --token <value>.');
|
|
40
42
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
// Raw license tokens (hex) need to be exchanged for a JWT via /activate.
|
|
44
|
+
// Already-valid JWTs (e.g. from refresh) are saved directly.
|
|
45
|
+
if (isJwt(rawToken)) {
|
|
46
|
+
await (0, auth_1.saveToken)(rawToken);
|
|
47
|
+
console.log(chalk_1.default.green(`✅ Token saved to ${auth_1.tokenPath}`));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
process.stdout.write('Activating license...');
|
|
51
|
+
try {
|
|
52
|
+
const client = new api_client_1.ApiClient();
|
|
53
|
+
const { token: jwt } = await client.activateToken(rawToken);
|
|
54
|
+
await (0, auth_1.saveToken)(jwt);
|
|
55
|
+
process.stdout.write('\r');
|
|
56
|
+
console.log(chalk_1.default.green(`✅ License activated and token saved to ${auth_1.tokenPath}`));
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
process.stdout.write('\r');
|
|
60
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
61
|
+
throw new Error(`Failed to activate license: ${message}`);
|
|
62
|
+
}
|
|
43
63
|
};
|
|
44
64
|
exports.authCommand = authCommand;
|
|
45
65
|
//# sourceMappingURL=auth.js.map
|
package/dist/core/api-client.js
CHANGED
|
@@ -86,6 +86,15 @@ class ApiClient {
|
|
|
86
86
|
}
|
|
87
87
|
return json;
|
|
88
88
|
}
|
|
89
|
+
async activateToken(rawToken) {
|
|
90
|
+
if (process.env.REPOFENCE_MOCK === '1') {
|
|
91
|
+
return { token: 'demo-token', license_id: 'lic-demo', packs: ['core'] };
|
|
92
|
+
}
|
|
93
|
+
return this.request('/v1/auth/activate', {
|
|
94
|
+
method: 'POST',
|
|
95
|
+
body: JSON.stringify({ token: rawToken }),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
89
98
|
async loginWithEmail(email) {
|
|
90
99
|
if (process.env.REPOFENCE_MOCK === '1') {
|
|
91
100
|
return { token: 'demo-token', license_id: 'lic-demo', packs: ['core'] };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repofence",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Repofence CLI (packs + backend auth)",
|
|
5
5
|
"main": "dist/cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -33,10 +33,12 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@aws-sdk/client-s3": "^3.705.0",
|
|
35
35
|
"@aws-sdk/s3-request-presigner": "^3.705.0",
|
|
36
|
+
"@supabase/supabase-js": "^2.103.0",
|
|
36
37
|
"chalk": "^4.1.2",
|
|
37
38
|
"commander": "^11.1.0",
|
|
38
39
|
"dotenv": "^16.4.5",
|
|
39
40
|
"open": "^11.0.0",
|
|
41
|
+
"resend": "^6.10.0",
|
|
40
42
|
"tar": "^6.2.1"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|