sessioncast-cli 1.1.3 → 1.1.4
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/agent/runner.js +25 -10
- package/dist/api.js +5 -2
- package/dist/commands/login.js +1 -1
- package/package.json +1 -1
package/dist/agent/runner.js
CHANGED
|
@@ -66,18 +66,33 @@ class AgentRunner {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
// If yml file found, load from file
|
|
70
|
+
if (finalPath && fs.existsSync(finalPath)) {
|
|
71
|
+
console.log(`Loading config from: ${finalPath}`);
|
|
72
|
+
const content = fs.readFileSync(finalPath, 'utf-8');
|
|
73
|
+
const ext = path.extname(finalPath).toLowerCase();
|
|
74
|
+
if (ext === '.json') {
|
|
75
|
+
return JSON.parse(content);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return yaml.load(content);
|
|
79
|
+
}
|
|
77
80
|
}
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
// SaaS mode: load from conf store (after sessioncast login)
|
|
82
|
+
const config_1 = require("../config");
|
|
83
|
+
const agentToken = (0, config_1.getAgentToken)();
|
|
84
|
+
const relayUrl = (0, config_1.getRelayUrl)();
|
|
85
|
+
const machineId = (0, config_1.getMachineId)();
|
|
86
|
+
if (agentToken) {
|
|
87
|
+
const os = require("os");
|
|
88
|
+
console.log('Loading config from login credentials (SaaS mode)');
|
|
89
|
+
return {
|
|
90
|
+
machineId: machineId || os.hostname(),
|
|
91
|
+
relay: relayUrl || 'wss://relay.sessioncast.io/ws',
|
|
92
|
+
token: agentToken,
|
|
93
|
+
};
|
|
80
94
|
}
|
|
95
|
+
throw new Error('No config found. Run "sessioncast login" first, or create ~/.sessioncast.yml');
|
|
81
96
|
}
|
|
82
97
|
async start() {
|
|
83
98
|
if (this.running)
|
package/dist/api.js
CHANGED
|
@@ -9,11 +9,14 @@ const config_1 = require("./config");
|
|
|
9
9
|
class ApiClient {
|
|
10
10
|
getHeaders() {
|
|
11
11
|
const apiKey = (0, config_1.getApiKey)();
|
|
12
|
-
|
|
12
|
+
const accessToken = (0, config_1.getAccessToken)();
|
|
13
|
+
const agentToken = (0, config_1.getAgentToken)();
|
|
14
|
+
const token = accessToken || apiKey || agentToken;
|
|
15
|
+
if (!token) {
|
|
13
16
|
throw new Error('Not logged in. Run: sessioncast login');
|
|
14
17
|
}
|
|
15
18
|
return {
|
|
16
|
-
'Authorization': `Bearer ${
|
|
19
|
+
'Authorization': `Bearer ${token}`,
|
|
17
20
|
'Content-Type': 'application/json'
|
|
18
21
|
};
|
|
19
22
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -236,7 +236,7 @@ function status() {
|
|
|
236
236
|
console.log(chalk_1.default.gray('Run: sessioncast login'));
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
const CURRENT_VERSION = '1.1.
|
|
239
|
+
const CURRENT_VERSION = '1.1.4';
|
|
240
240
|
async function checkForUpdates() {
|
|
241
241
|
try {
|
|
242
242
|
const res = await (0, node_fetch_1.default)('https://registry.npmjs.org/sessioncast-cli/latest', { timeout: 3000 });
|