bb-signer 0.3.5 → 0.3.7

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.
Files changed (2) hide show
  1. package/cli.js +67 -7
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -18,8 +18,9 @@
18
18
  * npx bb-signer sign-message <msg> Sign an arbitrary message
19
19
  *
20
20
  * Verification:
21
- * npx bb-signer verify-social <post_url> Verify via social post
21
+ * npx bb-signer request-phone-verification <phone> Request SMS code
22
22
  * npx bb-signer verify-phone <phone> <code> Complete phone verification
23
+ * npx bb-signer verify-social <post_url> Verify via social post
23
24
  *
24
25
  * npx bb-signer help Show help
25
26
  */
@@ -209,7 +210,7 @@ function applyEditorConfig(plan) {
209
210
  }
210
211
  }
211
212
 
212
- function resolveEditorFilter() {
213
+ async function resolveEditorFilter() {
213
214
  // Look for a non-flag argument after "install", e.g. `install gemini --yes`
214
215
  const installIdx = process.argv.indexOf('install');
215
216
  if (installIdx === -1) return null;
@@ -222,14 +223,30 @@ function resolveEditorFilter() {
222
223
  console.error(` Supported: ${SUPPORTED_EDITORS}`);
223
224
  process.exit(1);
224
225
  }
225
- // No editor specified — error out
226
- console.error('❌ Please specify which editor to configure.');
227
- console.error(`Usage: npx bb-signer install <${Object.keys(EDITORS).join('|')}> [--yes]`);
228
- process.exit(1);
226
+ // No editor specified — ask interactively
227
+ const editorKeys = Object.keys(EDITORS);
228
+ console.log('Which editor do you want to configure?\n');
229
+ editorKeys.forEach((key, i) => {
230
+ console.log(` ${i + 1}. ${EDITORS[key].label}`);
231
+ });
232
+ console.log();
233
+
234
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
235
+ const answer = await new Promise(resolve => {
236
+ rl.question(`Pick [1-${editorKeys.length}]: `, resolve);
237
+ });
238
+ rl.close();
239
+
240
+ const idx = parseInt(answer, 10) - 1;
241
+ if (isNaN(idx) || idx < 0 || idx >= editorKeys.length) {
242
+ console.error('Invalid choice.');
243
+ process.exit(1);
244
+ }
245
+ return editorKeys[idx];
229
246
  }
230
247
 
231
248
  async function install() {
232
- const editorFilter = resolveEditorFilter();
249
+ const editorFilter = await resolveEditorFilter();
233
250
 
234
251
  console.log(`Installing BB for ${EDITORS[editorFilter].label}...\n`);
235
252
 
@@ -540,6 +557,45 @@ async function verifySocial() {
540
557
  }
541
558
  }
542
559
 
560
+ async function requestPhoneVerification() {
561
+ if (!identityExists()) {
562
+ console.error('No identity found. Run `npx bb-signer install` first.');
563
+ process.exit(1);
564
+ }
565
+
566
+ const phoneNumber = process.argv[3];
567
+
568
+ if (!phoneNumber) {
569
+ console.error('Usage: npx bb-signer request-phone-verification <phone_number>');
570
+ console.error('Example: npx bb-signer request-phone-verification +14155551234');
571
+ process.exit(1);
572
+ }
573
+
574
+ const INDEXER_URL = process.env.BB_INDEXER_URL || 'https://api.bb.org.ai';
575
+ const url = `${INDEXER_URL}/api/v1/auth/request-code`;
576
+
577
+ try {
578
+ const response = await fetch(url, {
579
+ method: 'POST',
580
+ headers: { 'Content-Type': 'application/json' },
581
+ body: JSON.stringify({ phone_number: phoneNumber })
582
+ });
583
+
584
+ const data = await response.json();
585
+
586
+ if (!response.ok) {
587
+ console.error(`Error: ${data.error || 'Failed to send verification code'}`);
588
+ process.exit(1);
589
+ }
590
+
591
+ console.log(`\nVerification code sent to ${phoneNumber}.`);
592
+ console.log('Run: npx bb-signer verify-phone <phone_number> <code>');
593
+ } catch (e) {
594
+ console.error(`Error: ${e.message}`);
595
+ process.exit(1);
596
+ }
597
+ }
598
+
543
599
  async function verifyPhone() {
544
600
  if (!identityExists()) {
545
601
  console.error('No identity found. Run `npx bb-signer install` first.');
@@ -926,6 +982,10 @@ switch (cmd) {
926
982
  case 'verify-gist':
927
983
  verifySocial();
928
984
  break;
985
+ case 'request-phone-verification':
986
+ case 'request-code':
987
+ requestPhoneVerification().catch(e => { console.error(`Error: ${e.message}`); process.exit(1); });
988
+ break;
929
989
  case 'verify-phone':
930
990
  verifyPhone();
931
991
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bb-signer",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Minimal local signer for BB - signs events for the agent collaboration network",
5
5
  "type": "module",
6
6
  "main": "index.js",