@clawchatsai/connector 0.0.59 → 0.0.60
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 +11 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -764,7 +764,7 @@ async function handleSetup(token) {
|
|
|
764
764
|
const msg = JSON.parse(raw.toString());
|
|
765
765
|
if (msg.type === 'setup-complete') {
|
|
766
766
|
clearTimeout(timeout);
|
|
767
|
-
console.log(` User: ${msg.userId}`);
|
|
767
|
+
console.log(` User: ${msg.email || msg.userId}`);
|
|
768
768
|
console.log(' Registering gateway... ✅');
|
|
769
769
|
// Save initial config (schemaVersion 1 — will upgrade to 2 after TOTP enrollment)
|
|
770
770
|
const config = {
|
|
@@ -792,21 +792,8 @@ async function handleSetup(token) {
|
|
|
792
792
|
fs.mkdirSync(dataDir, { recursive: true });
|
|
793
793
|
fs.mkdirSync(uploadsDir, { recursive: true });
|
|
794
794
|
ws.close();
|
|
795
|
-
//
|
|
796
|
-
|
|
797
|
-
if (config.schemaVersion === 1) {
|
|
798
|
-
const rlSetup = (await import('node:readline')).createInterface({ input: process.stdin, output: process.stdout });
|
|
799
|
-
const askSetup = (q) => new Promise(r => rlSetup.question(q, r));
|
|
800
|
-
console.log('');
|
|
801
|
-
console.log(' 💡 Already have ClawChats on another gateway?');
|
|
802
|
-
console.log(' Run \`openclaw clawchats show-totp\` on that machine and paste the secret below.');
|
|
803
|
-
const reuseAnswer = await askSetup(' Paste existing TOTP secret to reuse it (or press Enter to set up new): ');
|
|
804
|
-
rlSetup.close();
|
|
805
|
-
if (reuseAnswer.trim())
|
|
806
|
-
reuseSecret = reuseAnswer.trim();
|
|
807
|
-
}
|
|
808
|
-
// Enroll TOTP (interactive — requires stdin)
|
|
809
|
-
const totpOk = await enrollTotp(config, reuseSecret);
|
|
795
|
+
// Enroll TOTP (interactive — single readline for the whole flow)
|
|
796
|
+
const totpOk = await enrollTotp(config);
|
|
810
797
|
if (!totpOk) {
|
|
811
798
|
console.log('');
|
|
812
799
|
console.log(' ⚠️ TOTP not configured. You can set it up later with: openclaw clawchats reauth');
|
|
@@ -839,11 +826,17 @@ async function handleSetup(token) {
|
|
|
839
826
|
});
|
|
840
827
|
});
|
|
841
828
|
}
|
|
842
|
-
async function enrollTotp(config
|
|
829
|
+
async function enrollTotp(config) {
|
|
843
830
|
const readline = await import('node:readline');
|
|
844
831
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
845
832
|
const ask = (q) => new Promise(r => rl.question(q, r));
|
|
846
833
|
try {
|
|
834
|
+
// Ask once if the user wants to reuse a TOTP secret from another gateway
|
|
835
|
+
console.log('');
|
|
836
|
+
console.log(' 💡 Already have ClawChats on another gateway?');
|
|
837
|
+
console.log(' Run `openclaw clawchats show-totp` on that machine, then paste the secret below.');
|
|
838
|
+
const reuseAnswer = await ask(' Paste existing TOTP secret (or press Enter to set up new): ');
|
|
839
|
+
const existingSecret = reuseAnswer.trim() || undefined;
|
|
847
840
|
let totpSecret;
|
|
848
841
|
if (existingSecret) {
|
|
849
842
|
// Reusing secret from another gateway — strip spaces, uppercase
|
|
@@ -953,15 +946,7 @@ async function handleReauth() {
|
|
|
953
946
|
console.log(' ⚠️ This will invalidate all existing sessions.');
|
|
954
947
|
console.log(' All connected browsers will need to re-authenticate.');
|
|
955
948
|
console.log('');
|
|
956
|
-
const
|
|
957
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
958
|
-
const ask = (q) => new Promise(r => rl.question(q, r));
|
|
959
|
-
let existingSecret;
|
|
960
|
-
const reuseAnswer = await ask(' Reuse TOTP from another gateway? Paste secret (or press Enter to generate new): ');
|
|
961
|
-
rl.close();
|
|
962
|
-
if (reuseAnswer.trim())
|
|
963
|
-
existingSecret = reuseAnswer.trim();
|
|
964
|
-
const success = await enrollTotp(config, existingSecret);
|
|
949
|
+
const success = await enrollTotp(config);
|
|
965
950
|
if (success) {
|
|
966
951
|
console.log(' All previous sessions have been invalidated.');
|
|
967
952
|
console.log(' Restart the gateway for changes to take effect: systemctl --user restart openclaw-gateway');
|