@powerhousedao/ph-cli 5.1.0-dev.4 → 5.1.0-dev.40
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/scripts/manage-environment +16 -8
- package/dist/scripts/setup-environment +62 -31
- package/dist/src/cli.js +1 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/access-token.d.ts +9 -0
- package/dist/src/commands/access-token.d.ts.map +1 -0
- package/dist/src/commands/access-token.js +110 -0
- package/dist/src/commands/access-token.js.map +1 -0
- package/dist/src/commands/generate.d.ts.map +1 -1
- package/dist/src/commands/generate.js +2 -1
- package/dist/src/commands/generate.js.map +1 -1
- package/dist/src/commands/index.d.ts +2 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +2 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/login.d.ts +12 -0
- package/dist/src/commands/login.d.ts.map +1 -0
- package/dist/src/commands/login.js +208 -0
- package/dist/src/commands/login.js.map +1 -0
- package/dist/src/commands/migrate.d.ts +1 -1
- package/dist/src/commands/migrate.d.ts.map +1 -1
- package/dist/src/commands/migrate.js +1 -1
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/register-commands.d.ts.map +1 -1
- package/dist/src/commands/register-commands.js +4 -0
- package/dist/src/commands/register-commands.js.map +1 -1
- package/dist/src/commands/switchboard.d.ts.map +1 -1
- package/dist/src/commands/switchboard.js +12 -2
- package/dist/src/commands/switchboard.js.map +1 -1
- package/dist/src/help.d.ts +9 -1
- package/dist/src/help.d.ts.map +1 -1
- package/dist/src/help.js +164 -9
- package/dist/src/help.js.map +1 -1
- package/dist/src/services/auth.d.ts +69 -0
- package/dist/src/services/auth.d.ts.map +1 -0
- package/dist/src/services/auth.js +171 -0
- package/dist/src/services/auth.js.map +1 -0
- package/dist/src/services/generate.d.ts +2 -1
- package/dist/src/services/generate.d.ts.map +1 -1
- package/dist/src/services/generate.js +15 -8
- package/dist/src/services/generate.js.map +1 -1
- package/dist/src/services/migrate.d.ts +7 -0
- package/dist/src/services/migrate.d.ts.map +1 -0
- package/dist/src/services/{migrate/migrate.js → migrate.js} +16 -12
- package/dist/src/services/migrate.js.map +1 -0
- package/dist/src/services/switchboard.d.ts +12 -0
- package/dist/src/services/switchboard.d.ts.map +1 -1
- package/dist/src/services/switchboard.js +10 -1
- package/dist/src/services/switchboard.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -8
- package/dist/src/services/migrate/migrate.d.ts +0 -7
- package/dist/src/services/migrate/migrate.d.ts.map +0 -1
- package/dist/src/services/migrate/migrate.js.map +0 -1
- package/dist/src/services/migrate/migrations/templates/document-models.d.ts +0 -2
- package/dist/src/services/migrate/migrations/templates/document-models.d.ts.map +0 -1
- package/dist/src/services/migrate/migrations/templates/document-models.js +0 -6
- package/dist/src/services/migrate/migrations/templates/document-models.js.map +0 -1
- package/dist/src/services/migrate/migrations/templates/editors.d.ts +0 -2
- package/dist/src/services/migrate/migrations/templates/editors.d.ts.map +0 -1
- package/dist/src/services/migrate/migrations/templates/editors.js +0 -6
- package/dist/src/services/migrate/migrations/templates/editors.js.map +0 -1
- package/dist/src/services/migrate/migrations/templates/index.d.ts +0 -2
- package/dist/src/services/migrate/migrations/templates/index.d.ts.map +0 -1
- package/dist/src/services/migrate/migrations/templates/index.js +0 -7
- package/dist/src/services/migrate/migrations/templates/index.js.map +0 -1
- package/dist/src/services/migrate/migrations/templates/packageJson.d.ts +0 -55
- package/dist/src/services/migrate/migrations/templates/packageJson.d.ts.map +0 -1
- package/dist/src/services/migrate/migrations/templates/packageJson.js +0 -55
- package/dist/src/services/migrate/migrations/templates/packageJson.js.map +0 -1
- package/dist/src/services/migrate/migrations/templates/tsConfig.d.ts +0 -2
- package/dist/src/services/migrate/migrations/templates/tsConfig.d.ts.map +0 -1
- package/dist/src/services/migrate/migrations/templates/tsConfig.js +0 -45
- package/dist/src/services/migrate/migrations/templates/tsConfig.js.map +0 -1
|
@@ -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,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GAAG,SAAS;IAAE;QAAE,
|
|
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,CAIxD,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAM9C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const migrate = async (_, options) => {
|
|
2
|
-
const { migrate: startMigrate } = await import("../services/migrate
|
|
2
|
+
const { migrate: startMigrate } = await import("../services/migrate.js");
|
|
3
3
|
return await startMigrate(options);
|
|
4
4
|
};
|
|
5
5
|
export function migrateCommand(program) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../src/commands/migrate.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,OAAO,GAEhB,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE;IACvB,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../src/commands/migrate.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,OAAO,GAEhB,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE;IACvB,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;IACzE,OAAO,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,gBAAgB,CAAC;SAC7B,MAAM,CAAC,YAAY,EAAE,0BAA0B,CAAC;SAChD,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -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;
|
|
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,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,YAAY;IACZ,cAAc;CACf,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
|
1
|
+
{"version":3,"file":"register-commands.js","sourceRoot":"","sources":["../../../src/commands/register-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM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M,4BAA4B,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
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,MAAM,CAAC,4BAA4B,CAAC,CAAC;IAC/D,MAAM,EAAE,gBAAgB,EAAE,GAAG,WAAW,CAAC;IAEzC,kDAAkD;IAClD,MAAM,
|
|
1
|
+
{"version":3,"file":"switchboard.js","sourceRoot":"","sources":["../../../src/commands/switchboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE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,CAAC;SAC3B,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QAChB,OAAO,CAAC,IAAI,EAAE,CAAC,YAAY,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE;QACpB,MAAM,CAAC,CAAC;IACV,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/src/help.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare const serviceHelp = "\nCommand Overview:\n The service command m
|
|
|
45
45
|
/**
|
|
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
|
|
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
|
package/dist/src/help.d.ts.map
CHANGED
|
@@ -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
|
|
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,k5FAwD3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,s6DAuCvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,2kCA0BvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,+0GAkErB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,o9FAkE3B,CAAC"}
|
package/dist/src/help.js
CHANGED
|
@@ -497,29 +497,42 @@ Command Overview:
|
|
|
497
497
|
2. Loads document models and processors
|
|
498
498
|
3. Provides an API for document operations
|
|
499
499
|
4. Enables real-time document processing
|
|
500
|
+
5. Can authenticate with remote services using your identity from 'ph login'
|
|
500
501
|
|
|
501
502
|
Options:
|
|
502
503
|
--port <PORT> Port to host the API. Default is 4001.
|
|
503
|
-
|
|
504
|
-
--config-file <path> Path to the powerhouse.config.js file. Default is
|
|
504
|
+
|
|
505
|
+
--config-file <path> Path to the powerhouse.config.js file. Default is
|
|
505
506
|
'./powerhouse.config.json'. This configures the switchboard behavior.
|
|
506
|
-
|
|
507
|
+
|
|
507
508
|
--dev Enable development mode to load local packages from the current directory.
|
|
508
509
|
This allows the switchboard to discover and load document models, processors,
|
|
509
510
|
and subgraphs from your local development environment.
|
|
510
|
-
|
|
511
|
+
|
|
511
512
|
--db-path <DB_PATH> Path to the database for storing document data.
|
|
512
|
-
|
|
513
|
+
|
|
513
514
|
--https-key-file <path> Path to the SSL key file if using HTTPS for secure connections.
|
|
514
|
-
|
|
515
|
+
|
|
515
516
|
--https-cert-file <path> Path to the SSL certificate file if using HTTPS.
|
|
516
|
-
|
|
517
|
+
|
|
517
518
|
--packages <pkg...> List of packages to be loaded. If defined, packages specified
|
|
518
519
|
in the config file are ignored.
|
|
519
|
-
|
|
520
|
-
--base-path <path> Base path for the API endpoints. Sets the BASE_PATH environment
|
|
520
|
+
|
|
521
|
+
--base-path <path> Base path for the API endpoints. Sets the BASE_PATH environment
|
|
521
522
|
variable used by the server to prefix all routes.
|
|
522
523
|
|
|
524
|
+
Identity Options:
|
|
525
|
+
--use-identity Enable identity using the keypair from 'ph login'. This allows the
|
|
526
|
+
switchboard to authenticate with remote drives and services using
|
|
527
|
+
your authorized Ethereum identity.
|
|
528
|
+
|
|
529
|
+
--keypair-path <path> Path to a custom keypair file. Overrides the default .keypair.json
|
|
530
|
+
in the current directory.
|
|
531
|
+
|
|
532
|
+
--require-identity Require an existing keypair; fail if not found. Use this when you
|
|
533
|
+
want to ensure the switchboard runs with a valid identity. If no
|
|
534
|
+
keypair exists, run 'ph login' first to create one.
|
|
535
|
+
|
|
523
536
|
Examples:
|
|
524
537
|
$ ph switchboard # Start switchboard with default settings
|
|
525
538
|
$ ph switchboard --port 5000 # Use custom port 5000
|
|
@@ -527,6 +540,8 @@ Examples:
|
|
|
527
540
|
$ ph switchboard --config-file custom.json # Use custom configuration file
|
|
528
541
|
$ ph switchboard --packages pkg1 pkg2 # Load specific packages
|
|
529
542
|
$ ph switchboard --base-path /switchboard # Set API base path to /switchboard
|
|
543
|
+
$ ph switchboard --use-identity # Start with identity from ph login
|
|
544
|
+
$ ph switchboard --require-identity # Require identity, fail if not logged in
|
|
530
545
|
`;
|
|
531
546
|
/**
|
|
532
547
|
* Help text for the reactor command
|
|
@@ -601,4 +616,144 @@ Notes:
|
|
|
601
616
|
- Using the correct CLI version is important for compatibility with your project
|
|
602
617
|
- Version information is read from the package.json file of the CLI
|
|
603
618
|
`;
|
|
619
|
+
/**
|
|
620
|
+
* Help text for the login command
|
|
621
|
+
*/
|
|
622
|
+
export const loginHelp = `
|
|
623
|
+
Command Overview:
|
|
624
|
+
The login command authenticates you with Renown using your Ethereum wallet. This enables
|
|
625
|
+
the CLI to act on behalf of your Ethereum identity for authenticated operations.
|
|
626
|
+
|
|
627
|
+
This command:
|
|
628
|
+
1. Generates or loads a cryptographic identity (DID) for the CLI
|
|
629
|
+
2. Opens your browser to the Renown authentication page
|
|
630
|
+
3. You authorize the CLI's DID to act on behalf of your Ethereum address
|
|
631
|
+
4. Stores the credentials locally in ~/.ph/auth.json
|
|
632
|
+
|
|
633
|
+
Options:
|
|
634
|
+
--renown-url <url> Specify a custom Renown server URL. Defaults to
|
|
635
|
+
https://www.renown.id
|
|
636
|
+
|
|
637
|
+
--timeout <seconds> Set the authentication timeout in seconds. The command will
|
|
638
|
+
wait this long for you to complete authentication in the browser.
|
|
639
|
+
Defaults to 300 seconds (5 minutes).
|
|
640
|
+
|
|
641
|
+
--logout Sign out and clear your stored credentials. Use this when you
|
|
642
|
+
want to switch accounts or revoke local authentication.
|
|
643
|
+
|
|
644
|
+
--status Show your current authentication status without logging in.
|
|
645
|
+
Displays your CLI DID, ETH address, and when you authenticated.
|
|
646
|
+
|
|
647
|
+
--show-did Show only the CLI's DID and exit. Useful for scripts.
|
|
648
|
+
|
|
649
|
+
Authentication Flow:
|
|
650
|
+
1. Run 'ph login' - the CLI generates/loads its cryptographic identity (DID)
|
|
651
|
+
2. A browser window opens to Renown with the CLI's DID
|
|
652
|
+
3. Connect your Ethereum wallet (MetaMask, etc.)
|
|
653
|
+
4. Authorize the CLI's DID to act on behalf of your ETH address
|
|
654
|
+
5. Return to your terminal - authentication is complete!
|
|
655
|
+
|
|
656
|
+
Credentials Storage:
|
|
657
|
+
All identity files are stored per-project in the current working directory:
|
|
658
|
+
|
|
659
|
+
.keypair.json The CLI's cryptographic keypair (ECDSA P-256)
|
|
660
|
+
.auth.json Your authentication credentials including:
|
|
661
|
+
- Your Ethereum address (the account you authorized)
|
|
662
|
+
- Your User DID (did:pkh:eip155:chainId:address)
|
|
663
|
+
- CLI DID (did:key:... - the CLI's cryptographic identity)
|
|
664
|
+
- Credential ID for session validation
|
|
665
|
+
|
|
666
|
+
This allows each project to have its own identity and credentials.
|
|
667
|
+
For CI/CD, provide the keypair via PH_RENOWN_PRIVATE_KEY env variable.
|
|
668
|
+
|
|
669
|
+
Environment Variables:
|
|
670
|
+
PH_RENOWN_PRIVATE_KEY JSON-encoded JWK keypair for the CLI's identity.
|
|
671
|
+
If set, the CLI will use this instead of generating
|
|
672
|
+
or loading from file. Useful for CI/CD environments.
|
|
673
|
+
|
|
674
|
+
Examples:
|
|
675
|
+
$ ph login # Authenticate with default settings
|
|
676
|
+
$ ph login --status # Check authentication status and CLI DID
|
|
677
|
+
$ ph login --show-did # Print only the CLI's DID
|
|
678
|
+
$ ph login --logout # Sign out and clear credentials
|
|
679
|
+
$ ph login --timeout 600 # Wait up to 10 minutes for authentication
|
|
680
|
+
$ ph login --renown-url http://localhost:3000 # Use local Renown server
|
|
681
|
+
|
|
682
|
+
Notes:
|
|
683
|
+
- You only need to authenticate once; credentials persist until you log out
|
|
684
|
+
- The CLI's DID remains stable unless you delete .keypair.json from your project
|
|
685
|
+
- If already authenticated, the command will show your current status
|
|
686
|
+
- The browser must remain open until authentication completes
|
|
687
|
+
- Your wallet signature authorizes the CLI's DID to act on your behalf
|
|
688
|
+
`;
|
|
689
|
+
/**
|
|
690
|
+
* Help text for the access-token command
|
|
691
|
+
*/
|
|
692
|
+
export const accessTokenHelp = `
|
|
693
|
+
Command Overview:
|
|
694
|
+
The access-token command generates a bearer token for API authentication. This token
|
|
695
|
+
can be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).
|
|
696
|
+
|
|
697
|
+
This command:
|
|
698
|
+
1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential
|
|
699
|
+
2. Creates a JWT bearer token with configurable expiration
|
|
700
|
+
3. Outputs the token to stdout (info to stderr) for easy piping
|
|
701
|
+
|
|
702
|
+
Prerequisites:
|
|
703
|
+
You must have a cryptographic identity. Run 'ph login' first to:
|
|
704
|
+
- Generate a keypair (stored in .keypair.json)
|
|
705
|
+
- Optionally link your Ethereum address (stored in .auth.json)
|
|
706
|
+
|
|
707
|
+
Options:
|
|
708
|
+
--expiry <duration> Set the token expiration time. Supports multiple formats:
|
|
709
|
+
- Days: "7d" (default), "30d", "1d"
|
|
710
|
+
- Hours: "24h", "12h", "1h"
|
|
711
|
+
- Seconds: "3600", "3600s", "86400s"
|
|
712
|
+
Default is 7 days.
|
|
713
|
+
|
|
714
|
+
--audience <url> Optional. Set the intended audience (aud claim) for the token.
|
|
715
|
+
This can be used to restrict the token to specific services.
|
|
716
|
+
|
|
717
|
+
Token Details:
|
|
718
|
+
The generated token is a JWT (JSON Web Token) containing:
|
|
719
|
+
- Issuer (iss): Your CLI's DID (did:key:...)
|
|
720
|
+
- Subject (sub): Your CLI's DID
|
|
721
|
+
- Credential Subject: Chain ID, network ID, and address (if authenticated)
|
|
722
|
+
- Expiration (exp): Based on --expiry option
|
|
723
|
+
- Audience (aud): If --audience is specified
|
|
724
|
+
|
|
725
|
+
Output:
|
|
726
|
+
- Token information (DID, address, expiry) is printed to stderr
|
|
727
|
+
- The token itself is printed to stdout for easy piping/copying
|
|
728
|
+
|
|
729
|
+
This allows you to use the command in scripts:
|
|
730
|
+
TOKEN=$(ph access-token)
|
|
731
|
+
curl -H "Authorization: Bearer $TOKEN" http://localhost:4001/graphql
|
|
732
|
+
|
|
733
|
+
Examples:
|
|
734
|
+
$ ph access-token # Generate token valid for 7 days
|
|
735
|
+
$ ph access-token --expiry 30d # Generate token valid for 30 days
|
|
736
|
+
$ ph access-token --expiry 24h # Generate token valid for 24 hours
|
|
737
|
+
$ ph access-token --expiry 3600 # Generate token valid for 1 hour (3600 seconds)
|
|
738
|
+
$ ph access-token --audience http://localhost:4001 # Set audience claim
|
|
739
|
+
$ ph access-token | pbcopy # Copy token to clipboard (macOS)
|
|
740
|
+
$ ph access-token | xclip -selection c # Copy token to clipboard (Linux)
|
|
741
|
+
|
|
742
|
+
Usage with APIs:
|
|
743
|
+
# Generate token and use with curl
|
|
744
|
+
TOKEN=$(ph access-token --expiry 1d)
|
|
745
|
+
curl -X POST http://localhost:4001/graphql \\
|
|
746
|
+
-H "Content-Type: application/json" \\
|
|
747
|
+
-H "Authorization: Bearer $TOKEN" \\
|
|
748
|
+
-d '{"query": "{ drives { id name } }"}'
|
|
749
|
+
|
|
750
|
+
# Export as environment variable
|
|
751
|
+
export PH_ACCESS_TOKEN=$(ph access-token)
|
|
752
|
+
|
|
753
|
+
Notes:
|
|
754
|
+
- Tokens are self-signed using your CLI's private key
|
|
755
|
+
- No network request is made; tokens are generated locally
|
|
756
|
+
- The recipient API must trust your CLI's DID to accept the token
|
|
757
|
+
- For reactor-api, ensure AUTH_ENABLED=true to require authentication
|
|
758
|
+
`;
|
|
604
759
|
//# sourceMappingURL=help.js.map
|
package/dist/src/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/help.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDhC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B/B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAA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