routstrd 0.2.14 → 0.2.15

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 (5) hide show
  1. package/bun.lock +41 -22
  2. package/dist/daemon/index.js +20477 -13804
  3. package/dist/index.js +3069 -3190
  4. package/package.json +1 -1
  5. package/src/cli.ts +19 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routstrd",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "private": false,
package/src/cli.ts CHANGED
@@ -832,14 +832,19 @@ clientsCmd
832
832
  },
833
833
  );
834
834
 
835
- // Npubs - manage admin npubs
835
+ // Npubs - manage npubs (admin and user roles)
836
836
  const npubsCmd = program
837
837
  .command("npubs")
838
- .description("Manage admin npubs on the daemon");
838
+ .description("Manage npubs on the daemon (admin or user roles)");
839
+
840
+ type NpubEntry = {
841
+ npub: string;
842
+ role: string;
843
+ };
839
844
 
840
845
  npubsCmd
841
846
  .command("list")
842
- .description("List configured admin npubs")
847
+ .description("List configured npubs with their roles")
843
848
  .action(async () => {
844
849
  await ensureDaemonRunning();
845
850
  const config = await loadConfig();
@@ -850,20 +855,20 @@ npubsCmd
850
855
  process.exit(1);
851
856
  }
852
857
  // Handle both wrapped { output: { npubs } } and direct { npubs } response formats
853
- const data = (result.output as { npubs?: string[] } | undefined)?.npubs
858
+ const data = (result.output as { npubs?: NpubEntry[] } | undefined)?.npubs
854
859
  ? result.output
855
860
  : result;
856
- const npubs = (data as { npubs?: string[] } | undefined)?.npubs ?? [];
861
+ const npubs = (data as { npubs?: NpubEntry[] } | undefined)?.npubs ?? [];
857
862
  if (npubs.length === 0) {
858
863
  console.log("No admin npubs configured. Run 'routstrd npubs register' to register yourself as the first admin.");
859
864
  return;
860
865
  }
861
- console.log(`Admin npubs (${npubs.length}):`);
866
+ console.log(`Npubs (${npubs.length}):`);
862
867
  let found = false;
863
- for (const npub of npubs) {
864
- const marker = npub === userNpub ? " → you" : "";
865
- if (npub === userNpub) found = true;
866
- console.log(`- ${npub}${marker}`);
868
+ for (const entry of npubs) {
869
+ const marker = entry.npub === userNpub ? " → you" : "";
870
+ if (entry.npub === userNpub) found = true;
871
+ console.log(`- ${entry.npub} [${entry.role}]${marker}`);
867
872
  }
868
873
  if (userNpub && !found) {
869
874
  console.log("");
@@ -892,10 +897,10 @@ npubsCmd
892
897
  console.log(result.error);
893
898
  process.exit(1);
894
899
  }
895
- const data = (result.output as { npubs?: string[] } | undefined)?.npubs
900
+ const data = (result.output as { npubs?: NpubEntry[] } | undefined)?.npubs
896
901
  ? result.output
897
902
  : result;
898
- const npubs = (data as { npubs?: string[] } | undefined)?.npubs ?? [];
903
+ const npubs = (data as { npubs?: NpubEntry[] } | undefined)?.npubs ?? [];
899
904
  if (npubs.length > 0) {
900
905
  console.log(`Admin npubs already configured (${npubs.length}). Ask your admin to add your npub. \n Your npub: ${userNpub}`);
901
906
  return;
@@ -925,7 +930,7 @@ npubsCmd
925
930
 
926
931
  npubsCmd
927
932
  .command("add <npub>")
928
- .description("Add an admin npub (hex pubkey or npub1...)")
933
+ .description("Add a npub (hex pubkey or npub1...). First becomes admin, subsequent become user.")
929
934
  .action(async (npubArg: string) => {
930
935
  await ensureDaemonRunning();
931
936
  const normalized = normalizeNostrPubkey(npubArg);
@@ -946,7 +951,7 @@ npubsCmd
946
951
  | undefined;
947
952
  if (output?.npub) {
948
953
  console.log(
949
- `${output.added ? "Added" : "Already configured"} admin npub: ${output.npub}`,
954
+ `${output.added ? "Added" : "Already configured"} npub: ${output.npub}`,
950
955
  );
951
956
  }
952
957
  });