shiftacle-desktop-agent 0.1.0 → 0.1.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/package.json +1 -1
- package/src/auth.mjs +22 -17
- package/src/config.mjs +2 -0
package/package.json
CHANGED
package/src/auth.mjs
CHANGED
|
@@ -35,23 +35,25 @@ async function promptCredentials() {
|
|
|
35
35
|
if (stdin.setRawMode) stdin.setRawMode(true);
|
|
36
36
|
let pw = '';
|
|
37
37
|
const onData = (ch) => {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
const str = ch.toString();
|
|
39
|
+
for (const c of str) {
|
|
40
|
+
if (c === '\n' || c === '\r') {
|
|
41
|
+
if (stdin.setRawMode) stdin.setRawMode(wasRaw ?? false);
|
|
42
|
+
stdin.removeListener('data', onData);
|
|
43
|
+
process.stdout.write('\n');
|
|
44
|
+
resolve(pw);
|
|
45
|
+
return;
|
|
46
|
+
} else if (c === '\u007f' || c === '\b') {
|
|
47
|
+
if (pw.length > 0) {
|
|
48
|
+
pw = pw.slice(0, -1);
|
|
49
|
+
process.stdout.write('\b \b');
|
|
50
|
+
}
|
|
51
|
+
} else if (c === '\u0003') {
|
|
52
|
+
process.exit(1);
|
|
53
|
+
} else {
|
|
54
|
+
pw += c;
|
|
55
|
+
process.stdout.write('*');
|
|
48
56
|
}
|
|
49
|
-
} else if (c === '\u0003') {
|
|
50
|
-
// Ctrl+C
|
|
51
|
-
process.exit(1);
|
|
52
|
-
} else {
|
|
53
|
-
pw += c;
|
|
54
|
-
process.stdout.write('*');
|
|
55
57
|
}
|
|
56
58
|
};
|
|
57
59
|
stdin.on('data', onData);
|
|
@@ -104,7 +106,10 @@ export async function authenticate(config, forceLogin = false) {
|
|
|
104
106
|
|
|
105
107
|
const res = await fetch(`${config.apiBase}/auth/login`, {
|
|
106
108
|
method: 'POST',
|
|
107
|
-
headers: {
|
|
109
|
+
headers: {
|
|
110
|
+
'Content-Type': 'application/json',
|
|
111
|
+
'X-Agent-Key': config.agentKey,
|
|
112
|
+
},
|
|
108
113
|
body: JSON.stringify({ email, password }),
|
|
109
114
|
});
|
|
110
115
|
|
package/src/config.mjs
CHANGED
|
@@ -10,6 +10,7 @@ export const DEFAULTS = {
|
|
|
10
10
|
configDir: join(homedir(), '.shiftacle'),
|
|
11
11
|
port: 3847,
|
|
12
12
|
emr: 'hellonote',
|
|
13
|
+
agentKey: '0f24e99a5f293fb411afc8e04cbeef2268a5b0f7e7581d2aa6ea16235f196d2d',
|
|
13
14
|
pollIntervalMs: 5000,
|
|
14
15
|
emrUrls: {
|
|
15
16
|
hellonote: 'https://app.hellonote.com',
|
|
@@ -28,6 +29,7 @@ export function getConfig(cliFlags = {}) {
|
|
|
28
29
|
headless: cliFlags.headless || false,
|
|
29
30
|
sessionDir: DEFAULTS.sessionDir,
|
|
30
31
|
configDir: DEFAULTS.configDir,
|
|
32
|
+
agentKey: process.env.SHIFTACLE_AGENT_KEY || DEFAULTS.agentKey,
|
|
31
33
|
pollIntervalMs: parseInt(process.env.POLL_INTERVAL || DEFAULTS.pollIntervalMs, 10),
|
|
32
34
|
emrUrls: DEFAULTS.emrUrls,
|
|
33
35
|
};
|