bb-signer 0.3.5 → 0.3.6
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/cli.js +45 -1
- 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
|
|
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
|
*/
|
|
@@ -540,6 +541,45 @@ async function verifySocial() {
|
|
|
540
541
|
}
|
|
541
542
|
}
|
|
542
543
|
|
|
544
|
+
async function requestPhoneVerification() {
|
|
545
|
+
if (!identityExists()) {
|
|
546
|
+
console.error('No identity found. Run `npx bb-signer install` first.');
|
|
547
|
+
process.exit(1);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
const phoneNumber = process.argv[3];
|
|
551
|
+
|
|
552
|
+
if (!phoneNumber) {
|
|
553
|
+
console.error('Usage: npx bb-signer request-phone-verification <phone_number>');
|
|
554
|
+
console.error('Example: npx bb-signer request-phone-verification +14155551234');
|
|
555
|
+
process.exit(1);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
const INDEXER_URL = process.env.BB_INDEXER_URL || 'https://api.bb.org.ai';
|
|
559
|
+
const url = `${INDEXER_URL}/api/v1/auth/request-code`;
|
|
560
|
+
|
|
561
|
+
try {
|
|
562
|
+
const response = await fetch(url, {
|
|
563
|
+
method: 'POST',
|
|
564
|
+
headers: { 'Content-Type': 'application/json' },
|
|
565
|
+
body: JSON.stringify({ phone_number: phoneNumber })
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
const data = await response.json();
|
|
569
|
+
|
|
570
|
+
if (!response.ok) {
|
|
571
|
+
console.error(`Error: ${data.error || 'Failed to send verification code'}`);
|
|
572
|
+
process.exit(1);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
console.log(`\nVerification code sent to ${phoneNumber}.`);
|
|
576
|
+
console.log('Run: npx bb-signer verify-phone <phone_number> <code>');
|
|
577
|
+
} catch (e) {
|
|
578
|
+
console.error(`Error: ${e.message}`);
|
|
579
|
+
process.exit(1);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
543
583
|
async function verifyPhone() {
|
|
544
584
|
if (!identityExists()) {
|
|
545
585
|
console.error('No identity found. Run `npx bb-signer install` first.');
|
|
@@ -926,6 +966,10 @@ switch (cmd) {
|
|
|
926
966
|
case 'verify-gist':
|
|
927
967
|
verifySocial();
|
|
928
968
|
break;
|
|
969
|
+
case 'request-phone-verification':
|
|
970
|
+
case 'request-code':
|
|
971
|
+
requestPhoneVerification().catch(e => { console.error(`Error: ${e.message}`); process.exit(1); });
|
|
972
|
+
break;
|
|
929
973
|
case 'verify-phone':
|
|
930
974
|
verifyPhone();
|
|
931
975
|
break;
|