@powerhousedao/ph-cli 5.1.0-staging.0 → 5.2.0-staging.1

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 (47) hide show
  1. package/dist/src/commands/access-token.d.ts +9 -0
  2. package/dist/src/commands/access-token.d.ts.map +1 -0
  3. package/dist/src/commands/access-token.js +110 -0
  4. package/dist/src/commands/access-token.js.map +1 -0
  5. package/dist/src/commands/generate.d.ts.map +1 -1
  6. package/dist/src/commands/generate.js +2 -1
  7. package/dist/src/commands/generate.js.map +1 -1
  8. package/dist/src/commands/index.d.ts +2 -0
  9. package/dist/src/commands/index.d.ts.map +1 -1
  10. package/dist/src/commands/index.js +2 -0
  11. package/dist/src/commands/index.js.map +1 -1
  12. package/dist/src/commands/login.d.ts +12 -0
  13. package/dist/src/commands/login.d.ts.map +1 -0
  14. package/dist/src/commands/login.js +208 -0
  15. package/dist/src/commands/login.js.map +1 -0
  16. package/dist/src/commands/migrate.d.ts +1 -1
  17. package/dist/src/commands/migrate.d.ts.map +1 -1
  18. package/dist/src/commands/register-commands.d.ts.map +1 -1
  19. package/dist/src/commands/register-commands.js +4 -0
  20. package/dist/src/commands/register-commands.js.map +1 -1
  21. package/dist/src/commands/switchboard.d.ts.map +1 -1
  22. package/dist/src/commands/switchboard.js +12 -2
  23. package/dist/src/commands/switchboard.js.map +1 -1
  24. package/dist/src/help.d.ts +9 -1
  25. package/dist/src/help.d.ts.map +1 -1
  26. package/dist/src/help.js +164 -9
  27. package/dist/src/help.js.map +1 -1
  28. package/dist/src/services/auth.d.ts +69 -0
  29. package/dist/src/services/auth.d.ts.map +1 -0
  30. package/dist/src/services/auth.js +171 -0
  31. package/dist/src/services/auth.js.map +1 -0
  32. package/dist/src/services/generate.d.ts +2 -1
  33. package/dist/src/services/generate.d.ts.map +1 -1
  34. package/dist/src/services/generate.js +15 -8
  35. package/dist/src/services/generate.js.map +1 -1
  36. package/dist/src/services/migrate/migrate.d.ts +2 -2
  37. package/dist/src/services/migrate/migrate.d.ts.map +1 -1
  38. package/dist/src/services/migrate/migrate.js +8 -8
  39. package/dist/src/services/migrate/migrate.js.map +1 -1
  40. package/dist/src/services/switchboard.d.ts +12 -0
  41. package/dist/src/services/switchboard.d.ts.map +1 -1
  42. package/dist/src/services/switchboard.js +10 -1
  43. package/dist/src/services/switchboard.js.map +1 -1
  44. package/dist/src/version.d.ts +1 -1
  45. package/dist/src/version.js +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +9 -8
@@ -0,0 +1,9 @@
1
+ import type { Command } from "commander";
2
+ import type { CommandActionType } from "../types.js";
3
+ export type AccessTokenOptions = {
4
+ expiry?: string;
5
+ audience?: string;
6
+ };
7
+ export declare const accessToken: CommandActionType<[AccessTokenOptions]>;
8
+ export declare function accessTokenCommand(program: Command): Command;
9
+ //# sourceMappingURL=access-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-token.d.ts","sourceRoot":"","sources":["../../../src/commands/access-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAgDF,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,CAAC,kBAAkB,CAAC,CAkF/D,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAY5D"}
@@ -0,0 +1,110 @@
1
+ import { accessTokenHelp } from "../help.js";
2
+ import { setCustomHelp } from "../utils.js";
3
+ const SECONDS_IN_DAY = 24 * 60 * 60;
4
+ const DEFAULT_EXPIRY_DAYS = 7;
5
+ const DEFAULT_EXPIRY_SECONDS = DEFAULT_EXPIRY_DAYS * SECONDS_IN_DAY;
6
+ /**
7
+ * Parse expiry string to seconds
8
+ * Supports formats: "7d" (days), "24h" (hours), "3600" (seconds), "3600s" (seconds)
9
+ */
10
+ function parseExpiry(expiry) {
11
+ const trimmed = expiry.trim().toLowerCase();
12
+ // Check for day format (e.g., "7d")
13
+ if (trimmed.endsWith("d")) {
14
+ const days = parseInt(trimmed.slice(0, -1), 10);
15
+ if (isNaN(days) || days <= 0) {
16
+ throw new Error(`Invalid expiry format: ${expiry}. Days must be a positive number.`);
17
+ }
18
+ return days * SECONDS_IN_DAY;
19
+ }
20
+ // Check for hour format (e.g., "24h")
21
+ if (trimmed.endsWith("h")) {
22
+ const hours = parseInt(trimmed.slice(0, -1), 10);
23
+ if (isNaN(hours) || hours <= 0) {
24
+ throw new Error(`Invalid expiry format: ${expiry}. Hours must be a positive number.`);
25
+ }
26
+ return hours * 60 * 60;
27
+ }
28
+ // Check for seconds format (e.g., "3600s" or just "3600")
29
+ const numericValue = trimmed.endsWith("s") ? trimmed.slice(0, -1) : trimmed;
30
+ const seconds = parseInt(numericValue, 10);
31
+ if (isNaN(seconds) || seconds <= 0) {
32
+ throw new Error(`Invalid expiry format: ${expiry}. Expected a positive number or format like "7d", "24h", "3600s".`);
33
+ }
34
+ return seconds;
35
+ }
36
+ export const accessToken = async (options) => {
37
+ const { getConnectCrypto, getConnectDid, isAuthenticated, loadCredentials } = await import("../services/auth.js");
38
+ // Require Renown authentication - user must have done 'ph login'
39
+ if (!isAuthenticated()) {
40
+ console.error("Not authenticated. Run 'ph login' first to authenticate with Renown.");
41
+ console.error("A Renown credential is required to generate valid bearer tokens.");
42
+ process.exit(1);
43
+ }
44
+ const creds = loadCredentials();
45
+ if (!creds) {
46
+ console.error("Failed to load credentials.");
47
+ process.exit(1);
48
+ }
49
+ // Get the CLI's DID
50
+ let did;
51
+ try {
52
+ did = await getConnectDid();
53
+ }
54
+ catch (e) {
55
+ console.error("Failed to get CLI identity. Run 'ph login' to reinitialize.");
56
+ process.exit(1);
57
+ }
58
+ const address = creds.address;
59
+ // Parse expiry
60
+ let expiresIn = DEFAULT_EXPIRY_SECONDS;
61
+ if (options.expiry) {
62
+ try {
63
+ expiresIn = parseExpiry(options.expiry);
64
+ }
65
+ catch (e) {
66
+ console.error(e.message);
67
+ process.exit(1);
68
+ }
69
+ }
70
+ // Generate the bearer token
71
+ const crypto = await getConnectCrypto();
72
+ const token = await crypto.getBearerToken(options.audience ?? "", address, true, // Force refresh to ensure we get a new token with the specified expiry
73
+ {
74
+ expiresIn,
75
+ aud: options.audience,
76
+ });
77
+ // Calculate human-readable expiry
78
+ const expiryDays = Math.floor(expiresIn / SECONDS_IN_DAY);
79
+ const expiryHours = Math.floor((expiresIn % SECONDS_IN_DAY) / 3600);
80
+ let expiryStr;
81
+ if (expiryDays > 0) {
82
+ expiryStr =
83
+ expiryHours > 0
84
+ ? `${expiryDays} day${expiryDays > 1 ? "s" : ""} and ${expiryHours} hour${expiryHours > 1 ? "s" : ""}`
85
+ : `${expiryDays} day${expiryDays > 1 ? "s" : ""}`;
86
+ }
87
+ else if (expiryHours > 0) {
88
+ expiryStr = `${expiryHours} hour${expiryHours > 1 ? "s" : ""}`;
89
+ }
90
+ else {
91
+ expiryStr = `${expiresIn} seconds`;
92
+ }
93
+ // Output token info to stderr, token itself to stdout for piping
94
+ console.error(`CLI DID: ${did}`);
95
+ console.error(`ETH Address: ${address}`);
96
+ console.error(`Token expires in: ${expiryStr}`);
97
+ console.error("");
98
+ // Output just the token to stdout (for easy piping/copying)
99
+ console.log(token);
100
+ };
101
+ export function accessTokenCommand(program) {
102
+ const cmd = program
103
+ .command("access-token")
104
+ .description("Generate a bearer token for API authentication")
105
+ .option("--expiry <duration>", `Token expiry duration. Supports: "7d" (days), "24h" (hours), "3600" or "3600s" (seconds). Default: ${DEFAULT_EXPIRY_DAYS}d`)
106
+ .option("--audience <url>", "Target audience URL for the token (optional)")
107
+ .action(accessToken);
108
+ return setCustomHelp(cmd, accessTokenHelp);
109
+ }
110
+ //# sourceMappingURL=access-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-token.js","sourceRoot":"","sources":["../../../src/commands/access-token.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO5C,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACpC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,sBAAsB,GAAG,mBAAmB,GAAG,cAAc,CAAC;AAEpE;;;GAGG;AACH,SAAS,WAAW,CAAC,MAAc;IACjC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE5C,oCAAoC;IACpC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAChD,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,0BAA0B,MAAM,mCAAmC,CACpE,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,GAAG,cAAc,CAAC;IAC/B,CAAC;IAED,sCAAsC;IACtC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjD,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,0BAA0B,MAAM,oCAAoC,CACrE,CAAC;QACJ,CAAC;QACD,OAAO,KA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,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAcrD,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CACtC;IAAC,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAAE,eAAe;CAAC,CAGjD,CAAC;AAEF,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,QAyC/C"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAcrD,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CACtC;IAAC,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAAE,eAAe;CAAC,CAGjD,CAAC;AAEF,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,QA6C/C"}
@@ -32,7 +32,8 @@ export function generateCommand(program) {
32
32
  .option("--allowed-document-types <types>", "Supported document types for a drive editor")
33
33
  .option("--migration-file <path>", "Path to the migration file")
34
34
  .option("--schema-file <path>", "Path to the output file. Defaults to './schema.ts'")
35
- .option("--ts-morph", "Use new ts-morph codegen");
35
+ .option("--use-hygen", "Use legacy hygen codegen")
36
+ .option("--use-versioning", "Allow upgrading document models with versioning");
36
37
  // Use the setCustomHelp utility to apply custom help formatting
37
38
  setCustomHelp(cmd, generateHelp);
38
39
  cmd.action(generate);
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/generate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,KAAK,UAAU,aAAa,CAC1B,QAAuC,EACvC,OAAwB;IAExB,MAAM,QAAQ,GAA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B,WAAW,CAAC,wCAAwC,CAAC;SACrD,QAAQ,CAAC,0BAA0B,EAAE,iCAAiC,CAAC;SACvE,MAAM,CAAC,mBAAmB,EAAE,qCAAqC,CAAC;SAClE,MAAM,CAAC,kBAAkB,EAAE,+BAA+B,CAAC;SAC3D,MAAM,CAAC,qBAAqB,EAAE,aAAa,CAAC;SAC5C,MAAM,CAAC,eAAe,EAAE,6BAA6B,CAAC;SACtD,MAAM,CAAC,qBAAqB,EAAE,kCAAkC,CAAC;SACjE,MAAM,CAAC,wBAAwB,EAAE,gBAAgB,CAAC;SAClD,MAAM,CACL,yBAAyB,EACzB,+CAA+C,CAChD;SACA,MAAM,CAAC,uBAAuB,EAAE,eAAe,CAAC;SAChD,MAAM,CAAC,0BAA0B,EAAE,uCAAuC,CAAC;SAC3E,MAAM,CAAC,yBAAyB,EAAE,wCAAwC,CAAC;SAC3E,MAAM,CAAC,6BAA6B,EAAE,oBAAoB,CAAC;SAC3D,MAAM,CAAC,oBAAoB,EAAE,oCAAoC,CAAC;SAClE,MAAM,CAAC,aAAa,EAAE,8BAA8B,CAAC;SACrD,MAAM,CAAC,aAAa,EAAE,0BAA0B,CAAC;SACjD,MAAM,CACL,2BAA2B,EAC3B,iDAAiD,CAClD;SACA,MAAM,CACL,kCAAkC,EAClC,6CAA6C,CAC9C;SACA,MAAM,CAAC,yBAAyB,EAAE,4BAA4B,CAAC;SAC/D,MAAM,CACL,sBAAsB,EACtB,oDAAoD,CACrD;SACA,MAAM,CAAC,aAAa,EAAE,0BAA0B,CAAC;SACjD,MAAM,CACL,kBAAkB,EAClB,iDAAiD,CAClD,CAAC;IAEJ,gEAAgE;IAChE,aAAa,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAEjC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACvB,CAAC"}
@@ -1,9 +1,11 @@
1
+ export * from "./access-token.js";
1
2
  export * from "./connect.js";
2
3
  export * from "./generate.js";
3
4
  export * from "./help.js";
4
5
  export * from "./inspect.js";
5
6
  export * from "./install.js";
6
7
  export * from "./list.js";
8
+ export * from "./login.js";
7
9
  export * from "./register-commands.js";
8
10
  export * from "./service.js";
9
11
  export * from "./switchboard.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
@@ -1,9 +1,11 @@
1
+ export * from "./access-token.js";
1
2
  export * from "./connect.js";
2
3
  export * from "./generate.js";
3
4
  export * from "./help.js";
4
5
  export * from "./inspect.js";
5
6
  export * from "./install.js";
6
7
  export * from "./list.js";
8
+ export * from "./login.js";
7
9
  export * from "./register-commands.js";
8
10
  export * from "./service.js";
9
11
  export * from "./switchboard.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Command } from "commander";
2
+ import type { CommandActionType } from "../types.js";
3
+ export type LoginOptions = {
4
+ renownUrl?: string;
5
+ timeout?: string;
6
+ logout?: boolean;
7
+ status?: boolean;
8
+ showDid?: boolean;
9
+ };
10
+ export declare const login: CommandActionType<[LoginOptions]>;
11
+ export declare function loginCommand(program: Command): Command;
12
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AA+IF,eAAO,MAAM,KAAK,EAAE,iBAAiB,CAAC,CAAC,YAAY,CAAC,CA8FnD,CAAC;AAEF,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAkBtD"}
@@ -0,0 +1,208 @@
1
+ import { loginHelp } from "../help.js";
2
+ import { clearCredentials, DEFAULT_RENOWN_URL, generateSessionId, getConnectDid, isAuthenticated, loadCredentials, saveCredentials, } from "../services/auth.js";
3
+ import { setCustomHelp } from "../utils.js";
4
+ const DEFAULT_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
5
+ const POLL_INTERVAL_MS = 2000; // 2 seconds
6
+ /**
7
+ * Open a URL in the default browser
8
+ */
9
+ async function openBrowser(url) {
10
+ const { exec } = await import("node:child_process");
11
+ const { promisify } = await import("node:util");
12
+ const execAsync = promisify(exec);
13
+ const platform = process.platform;
14
+ try {
15
+ if (platform === "darwin") {
16
+ await execAsync(`open "${url}"`);
17
+ }
18
+ else if (platform === "win32") {
19
+ await execAsync(`start "" "${url}"`);
20
+ }
21
+ else {
22
+ // Linux and others
23
+ await execAsync(`xdg-open "${url}"`);
24
+ }
25
+ }
26
+ catch (error) {
27
+ console.error("Failed to open browser automatically.");
28
+ console.log(`Please open this URL manually: ${url}`);
29
+ }
30
+ }
31
+ /**
32
+ * Poll the session endpoint until ready or timeout
33
+ */
34
+ async function pollSession(renownUrl, sessionId, timeoutMs) {
35
+ const startTime = Date.now();
36
+ const sessionUrl = `${renownUrl}/api/console/session/${sessionId}`;
37
+ while (Date.now() - startTime < timeoutMs) {
38
+ try {
39
+ const response = await fetch(sessionUrl);
40
+ if (!response.ok) {
41
+ console.error(`Session check failed: ${response.status}`);
42
+ await sleep(POLL_INTERVAL_MS);
43
+ continue;
44
+ }
45
+ const data = (await response.json());
46
+ if (data.status === "ready") {
47
+ return data;
48
+ }
49
+ // Still pending, wait and try again
50
+ process.stdout.write(".");
51
+ await sleep(POLL_INTERVAL_MS);
52
+ }
53
+ catch (error) {
54
+ // Network error, wait and retry
55
+ await sleep(POLL_INTERVAL_MS);
56
+ }
57
+ }
58
+ return null; // Timeout reached
59
+ }
60
+ function sleep(ms) {
61
+ return new Promise((resolve) => setTimeout(resolve, ms));
62
+ }
63
+ /**
64
+ * Show current authentication status
65
+ */
66
+ async function showStatus() {
67
+ const creds = loadCredentials();
68
+ // Always show the CLI's DID
69
+ try {
70
+ const connectDid = await getConnectDid();
71
+ console.log(`CLI DID: ${connectDid}`);
72
+ console.log();
73
+ }
74
+ catch (e) {
75
+ console.log("CLI DID: (not yet initialized)");
76
+ console.log();
77
+ }
78
+ if (!creds || !creds.credentialId) {
79
+ console.log("Not authenticated with an Ethereum address.");
80
+ console.log('Run "ph login" to authenticate.');
81
+ return;
82
+ }
83
+ console.log("Authenticated");
84
+ console.log(` ETH Address: ${creds.address}`);
85
+ console.log(` User DID: ${creds.did}`);
86
+ console.log(` Chain ID: ${creds.chainId}`);
87
+ console.log(` Authenticated at: ${creds.authenticatedAt}`);
88
+ console.log(` Renown URL: ${creds.renownUrl}`);
89
+ }
90
+ /**
91
+ * Show just the CLI DID
92
+ */
93
+ async function showDid() {
94
+ try {
95
+ const connectDid = await getConnectDid();
96
+ console.log(connectDid);
97
+ }
98
+ catch (e) {
99
+ console.error("Failed to get DID:", e);
100
+ process.exit(1);
101
+ }
102
+ }
103
+ /**
104
+ * Logout and clear credentials
105
+ */
106
+ function handleLogout() {
107
+ if (!isAuthenticated()) {
108
+ console.log("Not currently authenticated.");
109
+ return;
110
+ }
111
+ const success = clearCredentials();
112
+ if (success) {
113
+ console.log("Successfully logged out.");
114
+ }
115
+ else {
116
+ console.error("Failed to clear credentials.");
117
+ }
118
+ }
119
+ export const login = async (options) => {
120
+ // Handle showing just the DID
121
+ if (options.showDid) {
122
+ await showDid();
123
+ return;
124
+ }
125
+ // Handle status check
126
+ if (options.status) {
127
+ await showStatus();
128
+ return;
129
+ }
130
+ // Handle logout
131
+ if (options.logout) {
132
+ handleLogout();
133
+ return;
134
+ }
135
+ const renownUrl = options.renownUrl || DEFAULT_RENOWN_URL;
136
+ const timeoutMs = options.timeout
137
+ ? parseInt(options.timeout, 10) * 1000
138
+ : DEFAULT_TIMEOUT_MS;
139
+ // Check if already authenticated
140
+ if (isAuthenticated()) {
141
+ const creds = loadCredentials();
142
+ console.log(`Already authenticated as ${creds?.address}`);
143
+ console.log('Use "ph login --logout" to sign out first.');
144
+ return;
145
+ }
146
+ // Get the CLI's DID from ConnectCrypto
147
+ console.log("Initializing cryptographic identity...");
148
+ const connectDid = await getConnectDid();
149
+ console.log(`CLI DID: ${connectDid}`);
150
+ console.log();
151
+ // Generate session ID
152
+ const sessionId = generateSessionId();
153
+ // Build the login URL with connect DID
154
+ const loginUrl = new URL(`${renownUrl}/console`);
155
+ loginUrl.searchParams.set("session", sessionId);
156
+ loginUrl.searchParams.set("connect", connectDid);
157
+ console.log("Opening browser for authentication...");
158
+ console.log(`Session ID: ${sessionId.slice(0, 8)}...`);
159
+ console.log();
160
+ // Open browser
161
+ await openBrowser(loginUrl.toString());
162
+ console.log("Waiting for authentication in browser");
163
+ console.log(`(timeout in ${timeoutMs / 1000} seconds)`);
164
+ console.log();
165
+ console.log("Please connect your wallet and authorize this CLI to act on your behalf.");
166
+ console.log();
167
+ process.stdout.write("Waiting");
168
+ // Poll for session completion
169
+ const result = await pollSession(renownUrl, sessionId, timeoutMs);
170
+ console.log(); // New line after dots
171
+ if (!result) {
172
+ console.error("\nAuthentication timed out.");
173
+ console.log("Please try again with: ph login");
174
+ process.exit(1);
175
+ }
176
+ // Save credentials
177
+ const credentials = {
178
+ address: result.address,
179
+ chainId: result.chainId,
180
+ did: result.did,
181
+ connectDid: connectDid,
182
+ credentialId: result.credentialId,
183
+ userDocumentId: result.userDocumentId,
184
+ authenticatedAt: new Date().toISOString(),
185
+ renownUrl,
186
+ };
187
+ saveCredentials(credentials);
188
+ console.log();
189
+ console.log("Successfully authenticated!");
190
+ console.log(` ETH Address: ${credentials.address}`);
191
+ console.log(` User DID: ${credentials.did}`);
192
+ console.log(` CLI DID: ${credentials.connectDid}`);
193
+ console.log();
194
+ console.log("The CLI can now act on behalf of your Ethereum identity.");
195
+ };
196
+ export function loginCommand(program) {
197
+ const loginCmd = program
198
+ .command("login")
199
+ .description("Authenticate with Renown using your Ethereum wallet")
200
+ .option("--renown-url <url>", `Renown server URL (default: ${DEFAULT_RENOWN_URL})`)
201
+ .option("--timeout <seconds>", "Authentication timeout in seconds (default: 300)")
202
+ .option("--logout", "Sign out and clear stored credentials")
203
+ .option("--status", "Show current authentication status")
204
+ .option("--show-did", "Show the CLI's DID and exit")
205
+ .action(login);
206
+ return setCustomHelp(loginCmd, loginHelp);
207
+ }
208
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,GAEhB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoB5C,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AACtD,MAAM,gBAAgB,GAAG,IAAI,CAAC,CAAC,YAAY;AAE3C;;GAEG;AACH,KAAK,UAAU,WAAW,CAAC,GAAW;IACpC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACpD,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG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AC;IAC3C,OAAO,CAAC,GAAG,CAAC,kBAAkB,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,eAAe,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,cAAc,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,MAAM,QAAQ,GAAG,OAAO;SACrB,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,qDAAqD,CAAC;SAClE,MAAM,CACL,oBAAoB,EACpB,+BAA+B,kBAAkB,GAAG,CACrD;SACA,MAAM,CACL,qBAAqB,EACrB,kDAAkD,CACnD;SACA,MAAM,CAAC,UAAU,EAAE,uCAAuC,CAAC;SAC3D,MAAM,CAAC,UAAU,EAAE,oCAAoC,CAAC;SACxD,MAAM,CAAC,YAAY,EAAE,6BAA6B,CAAC;SACnD,MAAM,CAAC,KAAK,CAAC,CAAC;IAEjB,OAAO,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC5C,CAAC"}
@@ -3,7 +3,7 @@ import type { CommandActionType } from "../types.js";
3
3
  export declare const migrate: CommandActionType<[
4
4
  string | string[] | undefined,
5
5
  {
6
- tsMorph?: boolean;
6
+ useHygen?: boolean;
7
7
  }
8
8
  ]>;
9
9
  export declare function migrateCommand(program: Command): void;
@@ -1 +1 @@
1
- {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,OAAO,EAAE,iBAAiB,CACrC;IAAC,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;CAAC,CAMvD,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAM9C"}
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,OAAO,EAAE,iBAAiB,CACrC;IAAC,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE;CAAC,CAMxD,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAM9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"register-commands.d.ts","sourceRoot":"","sources":["../../../src/commands/register-commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAWhD,eAAO,MAAM,QAAQ,4BAYpB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,QAEhD"}
1
+ {"version":3,"file":"register-commands.d.ts","sourceRoot":"","sources":["../../../src/commands/register-commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAYhD,eAAO,MAAM,QAAQ,4BAcpB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,QAEhD"}
@@ -1,15 +1,18 @@
1
+ import { accessTokenCommand } from "./access-token.js";
1
2
  import { connectCommand } from "./connect.js";
2
3
  import { generateCommand } from "./generate.js";
3
4
  import { helpCommand } from "./help.js";
4
5
  import { inspectCommand } from "./inspect.js";
5
6
  import { installCommand } from "./install.js";
6
7
  import { listCommand } from "./list.js";
8
+ import { loginCommand } from "./login.js";
7
9
  import { migrateCommand } from "./migrate.js";
8
10
  import { serviceCommand } from "./service.js";
9
11
  import { switchboardCommand } from "./switchboard.js";
10
12
  import { uninstallCommand } from "./uninstall.js";
11
13
  import { vetraCommand } from "./vetra.js";
12
14
  export const commands = [
15
+ accessTokenCommand,
13
16
  connectCommand,
14
17
  generateCommand,
15
18
  helpCommand,
@@ -18,6 +21,7 @@ export const commands = [
18
21
  serviceCommand,
19
22
  listCommand,
20
23
  inspectCommand,
24
+ loginCommand,
21
25
  switchboardCommand,
22
26
  vetraCommand,
23
27
  migrateCommand,
@@ -1 +1 @@
1
- {"version":3,"file":"register-commands.js","sourceRoot":"","sources":["../../../src/commands/register-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,cAAc;IACd,eAAe;IACf,WAAW;IACX,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,WAA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AE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AAClD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard.d.ts","sourceRoot":"","sources":["../../../src/commands/switchboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAyBrD,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CACtD;IAAC,uBAAuB;CAAC,EACzB,OAAO,CAAC,kBAAkB,CAAC,CAG5B,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,QA+BlD"}
1
+ {"version":3,"file":"switchboard.d.ts","sourceRoot":"","sources":["../../../src/commands/switchboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAqCrD,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CACtD;IAAC,uBAAuB;CAAC,EACzB,OAAO,CAAC,kBAAkB,CAAC,CAG5B,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,QA8ClD"}
@@ -7,7 +7,7 @@ async function startLocalSwitchboard(options) {
7
7
  const Switchboard = await import("../services/switchboard.js");
8
8
  const { startSwitchboard } = Switchboard;
9
9
  // Extract only the props that switchboard expects
10
- const { port: rawPort, configFile, dev, dbPath, packages } = options;
10
+ const { port: rawPort, configFile, dev, dbPath, packages, useIdentity, keypairPath, requireIdentity, } = options;
11
11
  const port = typeof rawPort === "string" ? parseInt(rawPort) : rawPort;
12
12
  return startSwitchboard({
13
13
  port,
@@ -15,6 +15,9 @@ async function startLocalSwitchboard(options) {
15
15
  dev,
16
16
  dbPath,
17
17
  packages,
18
+ useIdentity,
19
+ keypairPath,
20
+ requireIdentity,
18
21
  });
19
22
  }
20
23
  export const runStartLocalSwitchboard = async (options) => {
@@ -35,9 +38,16 @@ export function switchboardCommand(program) {
35
38
  .option("--packages <packages...>", "list of packages to be loaded, if defined then packages on config file are ignored")
36
39
  .option("--base-path <basePath>", "base path for the API endpoints (sets the BASE_PATH environment variable)")
37
40
  .option("--mcp", "enable Mcp route at /mcp. Default: true")
41
+ .option("--use-identity", "enable identity using keypair from ph login (uses ~/.ph/keypair.json)")
42
+ .option("--keypair-path <path>", "path to custom keypair file for identity")
43
+ .option("--require-identity", "require existing keypair, fail if not found (implies --use-identity)")
38
44
  .action(async (...args) => {
39
- const { defaultDriveUrl } = await runStartLocalSwitchboard(...args);
45
+ const { defaultDriveUrl, connectCrypto } = await runStartLocalSwitchboard(...args);
40
46
  console.log(" ➜ Switchboard:", defaultDriveUrl);
47
+ if (connectCrypto) {
48
+ const did = await connectCrypto.did();
49
+ console.log(" ➜ Identity:", did);
50
+ }
41
51
  });
42
52
  setCustomHelp(command, switchboardHelp);
43
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard.js","sourceRoot":"","sources":["../../../src/commands/switchboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,KAAK,UAAU,qBAAqB,CAAC,OAAgC;IACnE,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;IAC3C,CAAC;IAED,MAAM,WAAW,GAAG,MAAM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/**
46
46
  * Help text for the switchboard command
47
47
  */
48
- export declare const switchboardHelp = "\nCommand Overview:\n The switchboard command starts a local Switchboard instance, which acts as the document\n processing engine for Powerhouse projects. It provides the infrastructure for document\n models, processors, and real-time updates.\n\n This command:\n 1. Starts a local switchboard server\n 2. Loads document models and processors\n 3. Provides an API for document operations\n 4. Enables real-time document processing\n\nOptions:\n --port <PORT> Port to host the API. Default is 4001.\n \n --config-file <path> Path to the powerhouse.config.js file. Default is \n './powerhouse.config.json'. This configures the switchboard behavior.\n \n --dev Enable development mode to load local packages from the current directory.\n This allows the switchboard to discover and load document models, processors,\n and subgraphs from your local development environment.\n \n --db-path <DB_PATH> Path to the database for storing document data.\n \n --https-key-file <path> Path to the SSL key file if using HTTPS for secure connections.\n \n --https-cert-file <path> Path to the SSL certificate file if using HTTPS.\n \n --packages <pkg...> List of packages to be loaded. If defined, packages specified\n in the config file are ignored.\n \n --base-path <path> Base path for the API endpoints. Sets the BASE_PATH environment \n variable used by the server to prefix all routes.\n\nExamples:\n $ ph switchboard # Start switchboard with default settings\n $ ph switchboard --port 5000 # Use custom port 5000\n $ ph switchboard --dev # Enable dev mode to load local packages\n $ ph switchboard --config-file custom.json # Use custom configuration file\n $ ph switchboard --packages pkg1 pkg2 # Load specific packages\n $ ph switchboard --base-path /switchboard # Set API base path to /switchboard\n";
48
+ export declare const switchboardHelp = "\nCommand Overview:\n The switchboard command starts a local Switchboard instance, which acts as the document\n processing engine for Powerhouse projects. It provides the infrastructure for document\n models, processors, and real-time updates.\n\n This command:\n 1. Starts a local switchboard server\n 2. Loads document models and processors\n 3. Provides an API for document operations\n 4. Enables real-time document processing\n 5. Can authenticate with remote services using your identity from 'ph login'\n\nOptions:\n --port <PORT> Port to host the API. Default is 4001.\n\n --config-file <path> Path to the powerhouse.config.js file. Default is\n './powerhouse.config.json'. This configures the switchboard behavior.\n\n --dev Enable development mode to load local packages from the current directory.\n This allows the switchboard to discover and load document models, processors,\n and subgraphs from your local development environment.\n\n --db-path <DB_PATH> Path to the database for storing document data.\n\n --https-key-file <path> Path to the SSL key file if using HTTPS for secure connections.\n\n --https-cert-file <path> Path to the SSL certificate file if using HTTPS.\n\n --packages <pkg...> List of packages to be loaded. If defined, packages specified\n in the config file are ignored.\n\n --base-path <path> Base path for the API endpoints. Sets the BASE_PATH environment\n variable used by the server to prefix all routes.\n\nIdentity Options:\n --use-identity Enable identity using the keypair from 'ph login'. This allows the\n switchboard to authenticate with remote drives and services using\n your authorized Ethereum identity.\n\n --keypair-path <path> Path to a custom keypair file. Overrides the default .keypair.json\n in the current directory.\n\n --require-identity Require an existing keypair; fail if not found. Use this when you\n want to ensure the switchboard runs with a valid identity. If no\n keypair exists, run 'ph login' first to create one.\n\nExamples:\n $ ph switchboard # Start switchboard with default settings\n $ ph switchboard --port 5000 # Use custom port 5000\n $ ph switchboard --dev # Enable dev mode to load local packages\n $ ph switchboard --config-file custom.json # Use custom configuration file\n $ ph switchboard --packages pkg1 pkg2 # Load specific packages\n $ ph switchboard --base-path /switchboard # Set API base path to /switchboard\n $ ph switchboard --use-identity # Start with identity from ph login\n $ ph switchboard --require-identity # Require identity, fail if not logged in\n";
49
49
  /**
50
50
  * Help text for the reactor command
51
51
  */
@@ -54,4 +54,12 @@ export declare const reactorHelp = "\nCommand Overview:\n The reactor command s
54
54
  * Help text for the version command
55
55
  */
56
56
  export declare const versionHelp = "\nCommand Overview:\n The version command displays the current version of the Powerhouse CLI tool.\n It helps you track which version you're using and ensure compatibility.\n\n This command:\n 1. Retrieves version information from package.json\n 2. Displays the version number of the CLI tool\n 3. Can be used to verify successful installation or updates\n\nOptions:\n --debug Show additional logs during version retrieval. This provides\n more detailed information about how the version is determined,\n which can be helpful for troubleshooting.\n\nExamples:\n $ ph version # Display the CLI version\n $ ph version --debug # Show version with debug information\n\nAliases:\n $ ph v # Shorthand for version\n\nNotes:\n - The version follows semantic versioning (MAJOR.MINOR.PATCH)\n - Using the correct CLI version is important for compatibility with your project\n - Version information is read from the package.json file of the CLI\n";
57
+ /**
58
+ * Help text for the login command
59
+ */
60
+ export declare const loginHelp = "\nCommand Overview:\n The login command authenticates you with Renown using your Ethereum wallet. This enables\n the CLI to act on behalf of your Ethereum identity for authenticated operations.\n\n This command:\n 1. Generates or loads a cryptographic identity (DID) for the CLI\n 2. Opens your browser to the Renown authentication page\n 3. You authorize the CLI's DID to act on behalf of your Ethereum address\n 4. Stores the credentials locally in ~/.ph/auth.json\n\nOptions:\n --renown-url <url> Specify a custom Renown server URL. Defaults to\n https://www.renown.id\n\n --timeout <seconds> Set the authentication timeout in seconds. The command will\n wait this long for you to complete authentication in the browser.\n Defaults to 300 seconds (5 minutes).\n\n --logout Sign out and clear your stored credentials. Use this when you\n want to switch accounts or revoke local authentication.\n\n --status Show your current authentication status without logging in.\n Displays your CLI DID, ETH address, and when you authenticated.\n\n --show-did Show only the CLI's DID and exit. Useful for scripts.\n\nAuthentication Flow:\n 1. Run 'ph login' - the CLI generates/loads its cryptographic identity (DID)\n 2. A browser window opens to Renown with the CLI's DID\n 3. Connect your Ethereum wallet (MetaMask, etc.)\n 4. Authorize the CLI's DID to act on behalf of your ETH address\n 5. Return to your terminal - authentication is complete!\n\nCredentials Storage:\n All identity files are stored per-project in the current working directory:\n\n .keypair.json The CLI's cryptographic keypair (ECDSA P-256)\n .auth.json Your authentication credentials including:\n - Your Ethereum address (the account you authorized)\n - Your User DID (did:pkh:eip155:chainId:address)\n - CLI DID (did:key:... - the CLI's cryptographic identity)\n - Credential ID for session validation\n\n This allows each project to have its own identity and credentials.\n For CI/CD, provide the keypair via PH_RENOWN_PRIVATE_KEY env variable.\n\nEnvironment Variables:\n PH_RENOWN_PRIVATE_KEY JSON-encoded JWK keypair for the CLI's identity.\n If set, the CLI will use this instead of generating\n or loading from file. Useful for CI/CD environments.\n\nExamples:\n $ ph login # Authenticate with default settings\n $ ph login --status # Check authentication status and CLI DID\n $ ph login --show-did # Print only the CLI's DID\n $ ph login --logout # Sign out and clear credentials\n $ ph login --timeout 600 # Wait up to 10 minutes for authentication\n $ ph login --renown-url http://localhost:3000 # Use local Renown server\n\nNotes:\n - You only need to authenticate once; credentials persist until you log out\n - The CLI's DID remains stable unless you delete .keypair.json from your project\n - If already authenticated, the command will show your current status\n - The browser must remain open until authentication completes\n - Your wallet signature authorizes the CLI's DID to act on your behalf\n";
61
+ /**
62
+ * Help text for the access-token command
63
+ */
64
+ export declare const accessTokenHelp = "\nCommand Overview:\n The access-token command generates a bearer token for API authentication. This token\n can be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).\n\n This command:\n 1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential\n 2. Creates a JWT bearer token with configurable expiration\n 3. Outputs the token to stdout (info to stderr) for easy piping\n\nPrerequisites:\n You must have a cryptographic identity. Run 'ph login' first to:\n - Generate a keypair (stored in .keypair.json)\n - Optionally link your Ethereum address (stored in .auth.json)\n\nOptions:\n --expiry <duration> Set the token expiration time. Supports multiple formats:\n - Days: \"7d\" (default), \"30d\", \"1d\"\n - Hours: \"24h\", \"12h\", \"1h\"\n - Seconds: \"3600\", \"3600s\", \"86400s\"\n Default is 7 days.\n\n --audience <url> Optional. Set the intended audience (aud claim) for the token.\n This can be used to restrict the token to specific services.\n\nToken Details:\n The generated token is a JWT (JSON Web Token) containing:\n - Issuer (iss): Your CLI's DID (did:key:...)\n - Subject (sub): Your CLI's DID\n - Credential Subject: Chain ID, network ID, and address (if authenticated)\n - Expiration (exp): Based on --expiry option\n - Audience (aud): If --audience is specified\n\nOutput:\n - Token information (DID, address, expiry) is printed to stderr\n - The token itself is printed to stdout for easy piping/copying\n\n This allows you to use the command in scripts:\n TOKEN=$(ph access-token)\n curl -H \"Authorization: Bearer $TOKEN\" http://localhost:4001/graphql\n\nExamples:\n $ ph access-token # Generate token valid for 7 days\n $ ph access-token --expiry 30d # Generate token valid for 30 days\n $ ph access-token --expiry 24h # Generate token valid for 24 hours\n $ ph access-token --expiry 3600 # Generate token valid for 1 hour (3600 seconds)\n $ ph access-token --audience http://localhost:4001 # Set audience claim\n $ ph access-token | pbcopy # Copy token to clipboard (macOS)\n $ ph access-token | xclip -selection c # Copy token to clipboard (Linux)\n\nUsage with APIs:\n # Generate token and use with curl\n TOKEN=$(ph access-token --expiry 1d)\n curl -X POST http://localhost:4001/graphql \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $TOKEN\" \\\n -d '{\"query\": \"{ drives { id name } }\"}'\n\n # Export as environment variable\n export PH_ACCESS_TOKEN=$(ph access-token)\n\nNotes:\n - Tokens are self-signed using your CLI's private key\n - No network request is made; tokens are generated locally\n - The recipient API must trust your CLI's DID to accept the token\n - For reactor-api, ensure AUTH_ENABLED=true to require authentication\n";
57
65
  //# sourceMappingURL=help.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/help.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB,wzEAgD7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,4oCA0B5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,stDAsC9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,k/GA+DxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,+jEAsCvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,4pEAwCzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,ypCA2BpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,m7DAoCnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,4iHAsDrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,miDAkCvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,+zDAqCvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,+pEAyC3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,s6DAuCvB,C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