@powerhousedao/ph-cli 6.0.0-dev.235 → 6.0.0-dev.237
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/{assign-env-vars-DZMMuzB2.mjs → assign-env-vars-W-lZmdMi.mjs} +1 -1
- package/dist/{assign-env-vars-DZMMuzB2.mjs.map → assign-env-vars-W-lZmdMi.mjs.map} +1 -1
- package/dist/{auth-Ch5B5mNU.mjs → auth-AR3VxAIk.mjs} +1 -1
- package/dist/{auth-Ch5B5mNU.mjs.map → auth-AR3VxAIk.mjs.map} +1 -1
- package/dist/auth-BNkN6kS9.mjs +2 -0
- package/dist/{build-DCXpFtjA.mjs → build-CYAQMjy1.mjs} +1 -1
- package/dist/{build-DCXpFtjA.mjs.map → build-CYAQMjy1.mjs.map} +1 -1
- package/dist/build-DzxGiqu2.mjs +2 -0
- package/dist/cli.mjs +248 -47
- package/dist/cli.mjs.map +1 -1
- package/dist/{connect-build-6yhCIKkQ.mjs → connect-build-BIvwnJ8o.mjs} +3 -3
- package/dist/{connect-build-6yhCIKkQ.mjs.map → connect-build-BIvwnJ8o.mjs.map} +1 -1
- package/dist/{connect-preview-CaEiWmqU.mjs → connect-preview-CNJkhtxL.mjs} +2 -2
- package/dist/{connect-preview-CaEiWmqU.mjs.map → connect-preview-CNJkhtxL.mjs.map} +1 -1
- package/dist/{connect-studio-BaqbrWYQ.mjs → connect-studio-DTdSFftL.mjs} +2 -2
- package/dist/{connect-studio-BaqbrWYQ.mjs.map → connect-studio-DTdSFftL.mjs.map} +1 -1
- package/dist/connect-studio-DySbZFEc.mjs +3 -0
- package/dist/{generate-all-DaXXjoms.mjs → generate-all-Cj8zjFhN.mjs} +1 -1
- package/dist/{generate-all-DaXXjoms.mjs.map → generate-all-Cj8zjFhN.mjs.map} +1 -1
- package/dist/{generate-app-GvQeAG4w.mjs → generate-app-KE0rbE-b.mjs} +1 -1
- package/dist/{generate-app-GvQeAG4w.mjs.map → generate-app-KE0rbE-b.mjs.map} +1 -1
- package/dist/{generate-document-model-Dnik0rKd.mjs → generate-document-model-Cut44i6D.mjs} +1 -1
- package/dist/{generate-document-model-Dnik0rKd.mjs.map → generate-document-model-Cut44i6D.mjs.map} +1 -1
- package/dist/{generate-editor-BNN2OmmX.mjs → generate-editor-DmSzWm3W.mjs} +1 -1
- package/dist/{generate-editor-BNN2OmmX.mjs.map → generate-editor-DmSzWm3W.mjs.map} +1 -1
- package/dist/{generate-processor-CCSW2Ed2.mjs → generate-processor-BcuHtOSn.mjs} +1 -1
- package/dist/{generate-processor-CCSW2Ed2.mjs.map → generate-processor-BcuHtOSn.mjs.map} +1 -1
- package/dist/{generate-subgraph-B-d3J6hU.mjs → generate-subgraph-sh0GWC6T.mjs} +1 -1
- package/dist/{generate-subgraph-B-d3J6hU.mjs.map → generate-subgraph-sh0GWC6T.mjs.map} +1 -1
- package/dist/{init-8FtJDKxG.mjs → init-Cw_5H_Z1.mjs} +1 -1
- package/dist/{init-8FtJDKxG.mjs.map → init-Cw_5H_Z1.mjs.map} +1 -1
- package/dist/{inspect-BwkihsT7.mjs → inspect-BwuBW_zW.mjs} +2 -2
- package/dist/{inspect-BwkihsT7.mjs.map → inspect-BwuBW_zW.mjs.map} +1 -1
- package/dist/{migrate-B-O6P7jA.mjs → migrate-DCUKk5c2.mjs} +1 -1
- package/dist/{migrate-B-O6P7jA.mjs.map → migrate-DCUKk5c2.mjs.map} +1 -1
- package/dist/{registry-auth-BX9_n8hE.mjs → registry-auth-CNH84uo4.mjs} +2 -2
- package/dist/{registry-auth-BX9_n8hE.mjs.map → registry-auth-CNH84uo4.mjs.map} +1 -1
- package/dist/{switchboard-CJMoMzWx.mjs → switchboard-BsdbF-rL.mjs} +1 -1
- package/dist/{switchboard-CJMoMzWx.mjs.map → switchboard-BsdbF-rL.mjs.map} +1 -1
- package/dist/switchboard-GTBlxiJZ.mjs +2 -0
- package/dist/{switchboard-migrate-BRgCgg7N.mjs → switchboard-migrate-BumRp7rC.mjs} +1 -1
- package/dist/{switchboard-migrate-BRgCgg7N.mjs.map → switchboard-migrate-BumRp7rC.mjs.map} +1 -1
- package/dist/{utils-DkOZWO0i.mjs → utils-C6581aex.mjs} +1 -1
- package/dist/{utils-D7x443W6.mjs → utils-mth8NsDA.mjs} +1 -1
- package/dist/{utils-D7x443W6.mjs.map → utils-mth8NsDA.mjs.map} +1 -1
- package/dist/{vetra-xk2hwf6X.mjs → vetra-_JnFPpL5.mjs} +5 -5
- package/dist/{vetra-xk2hwf6X.mjs.map → vetra-_JnFPpL5.mjs.map} +1 -1
- package/package.json +10 -14
- package/dist/auth-Dq7JjwYn.mjs +0 -2
- package/dist/build-CWcQj0YI.mjs +0 -2
- package/dist/cli-BEsmTJHX.mjs +0 -140
- package/dist/cli-BEsmTJHX.mjs.map +0 -1
- package/dist/connect-studio-Dndkp0Q_.mjs +0 -3
- package/dist/logout-A2UHfQZF.mjs +0 -232
- package/dist/logout-A2UHfQZF.mjs.map +0 -1
- package/dist/switchboard-iRFugh8I.mjs +0 -2
package/dist/logout-A2UHfQZF.mjs
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { command } from "cmd-ts";
|
|
2
|
-
import { accessTokenArgs, listArgs, loginArgs } from "@powerhousedao/shared/clis/args";
|
|
3
|
-
import { DEFAULT_EXPIRY_SECONDS } from "@powerhousedao/shared/clis/constants";
|
|
4
|
-
//#region src/get-version.ts
|
|
5
|
-
function getVersion() {
|
|
6
|
-
return "6.0.0-dev.235";
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/commands/access-token.ts
|
|
10
|
-
const accessToken = command({
|
|
11
|
-
name: "access-token",
|
|
12
|
-
description: `
|
|
13
|
-
The access-token command generates a bearer token for API authentication. This token
|
|
14
|
-
can be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).
|
|
15
|
-
|
|
16
|
-
This command:
|
|
17
|
-
1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential
|
|
18
|
-
2. Creates a JWT bearer token with configurable expiration
|
|
19
|
-
3. Outputs the token to stdout (info to stderr) for easy piping
|
|
20
|
-
|
|
21
|
-
Prerequisites:
|
|
22
|
-
You must have a cryptographic identity. Run 'ph login' first to:
|
|
23
|
-
- Generate a keypair (stored in .ph/.keypair.json)
|
|
24
|
-
- Optionally link your Ethereum address (stored in .ph/.renown.json)
|
|
25
|
-
|
|
26
|
-
Token Details:
|
|
27
|
-
The generated token is a JWT (JSON Web Token) containing:
|
|
28
|
-
- Issuer (iss): Your CLI's DID (did:key:...)
|
|
29
|
-
- Subject (sub): Your CLI's DID
|
|
30
|
-
- Credential Subject: Chain ID, network ID, and address (if authenticated)
|
|
31
|
-
- Expiration (exp): Based on --expiry option
|
|
32
|
-
- Audience (aud): If --audience is specified
|
|
33
|
-
|
|
34
|
-
Output:
|
|
35
|
-
- Token information (DID, address, expiry) is printed to stderr
|
|
36
|
-
- The token itself is printed to stdout for easy piping/copying
|
|
37
|
-
|
|
38
|
-
This allows you to use the command in scripts:
|
|
39
|
-
TOKEN=$(ph access-token)
|
|
40
|
-
curl -H "Authorization: Bearer $TOKEN" http://localhost:4001/graphql
|
|
41
|
-
|
|
42
|
-
Usage with APIs:
|
|
43
|
-
Generate token and use with curl
|
|
44
|
-
TOKEN=$(ph access-token --expiry 1d)
|
|
45
|
-
curl -X POST http://localhost:4001/graphql \\
|
|
46
|
-
-H "Content-Type: application/json" \\
|
|
47
|
-
-H "Authorization: Bearer $TOKEN" \\
|
|
48
|
-
-d '{"query": "{ drives { id name } }"}'
|
|
49
|
-
|
|
50
|
-
Export as environment variable
|
|
51
|
-
export PH_ACCESS_TOKEN=$(ph access-token)
|
|
52
|
-
|
|
53
|
-
Notes:
|
|
54
|
-
- Tokens are self-signed using your CLI's private key
|
|
55
|
-
- No network request is made; tokens are generated locally
|
|
56
|
-
- The recipient API must trust your CLI's DID to accept the token
|
|
57
|
-
- For reactor-api, ensure AUTH_ENABLED=true to require authentication
|
|
58
|
-
`,
|
|
59
|
-
args: accessTokenArgs,
|
|
60
|
-
handler: async (args) => {
|
|
61
|
-
if (args.debug) console.log(args);
|
|
62
|
-
const { generateAccessToken, parseExpiry, formatExpiry } = await import("@renown/sdk/node");
|
|
63
|
-
const { getRenown } = await import("./auth-Dq7JjwYn.mjs");
|
|
64
|
-
const renown = await getRenown();
|
|
65
|
-
let expiresIn = DEFAULT_EXPIRY_SECONDS;
|
|
66
|
-
if (args.expiry) expiresIn = parseExpiry(args.expiry);
|
|
67
|
-
const result = await generateAccessToken(renown, {
|
|
68
|
-
expiresIn,
|
|
69
|
-
aud: args.audience
|
|
70
|
-
});
|
|
71
|
-
console.error(`CLI DID: ${result.did}`);
|
|
72
|
-
console.error(`ETH Address: ${result.address}`);
|
|
73
|
-
console.error(`Token expires in: ${formatExpiry(expiresIn)}`);
|
|
74
|
-
console.error("");
|
|
75
|
-
console.log(result.token);
|
|
76
|
-
process.exit(0);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region src/commands/list.ts
|
|
81
|
-
const list = command({
|
|
82
|
-
name: "list",
|
|
83
|
-
description: `
|
|
84
|
-
The list command displays information about installed Powerhouse packages in your project.
|
|
85
|
-
It reads the powerhouse.config.json file and shows the packages that are currently installed.
|
|
86
|
-
|
|
87
|
-
This command:
|
|
88
|
-
1. Examines your project configuration
|
|
89
|
-
2. Lists all installed Powerhouse packages
|
|
90
|
-
3. Provides a clear overview of your project's dependencies
|
|
91
|
-
4. Helps you manage and track your Powerhouse components
|
|
92
|
-
`,
|
|
93
|
-
aliases: ["l"],
|
|
94
|
-
args: listArgs,
|
|
95
|
-
handler: async (args) => {
|
|
96
|
-
if (args.debug) console.log(args);
|
|
97
|
-
try {
|
|
98
|
-
const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
|
|
99
|
-
const projectInfo = await getPowerhouseProjectInfo();
|
|
100
|
-
console.log("\n>>> projectInfo", projectInfo);
|
|
101
|
-
const { getConfig } = await import("@powerhousedao/config/node");
|
|
102
|
-
const phConfig = getConfig(projectInfo.projectPath + "/powerhouse.config.json");
|
|
103
|
-
if (!phConfig.packages || phConfig.packages.length === 0) {
|
|
104
|
-
console.log("No packages found in the project");
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
console.log("Installed Packages:\n");
|
|
108
|
-
phConfig.packages.forEach((pkg) => {
|
|
109
|
-
console.log(pkg.packageName);
|
|
110
|
-
});
|
|
111
|
-
} catch (e) {
|
|
112
|
-
console.log("No packages found in the project");
|
|
113
|
-
}
|
|
114
|
-
process.exit(0);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
//#endregion
|
|
118
|
-
//#region src/commands/login.ts
|
|
119
|
-
const login = command({
|
|
120
|
-
name: "login",
|
|
121
|
-
description: `
|
|
122
|
-
The login command authenticates you with Renown using your Ethereum wallet. This enables
|
|
123
|
-
the CLI to act on behalf of your Ethereum identity for authenticated operations.
|
|
124
|
-
|
|
125
|
-
This command:
|
|
126
|
-
1. Generates or loads a cryptographic identity (DID) for the CLI
|
|
127
|
-
2. Opens your browser to the Renown authentication page
|
|
128
|
-
3. You authorize the CLI's DID to act on behalf of your Ethereum address
|
|
129
|
-
4. Stores the credentials locally in .ph/.renown.json
|
|
130
|
-
`,
|
|
131
|
-
args: loginArgs,
|
|
132
|
-
handler: async (args) => {
|
|
133
|
-
if (args.debug) console.log(args);
|
|
134
|
-
const { getRenown } = await import("./auth-Dq7JjwYn.mjs");
|
|
135
|
-
const renown = await getRenown(args.renownUrl);
|
|
136
|
-
if (args.showDid) {
|
|
137
|
-
console.log(renown.did);
|
|
138
|
-
process.exit(0);
|
|
139
|
-
}
|
|
140
|
-
if (args.status) {
|
|
141
|
-
const { getAuthStatus } = await import("@renown/sdk/node");
|
|
142
|
-
const status = getAuthStatus(renown);
|
|
143
|
-
if (!status.authenticated || !status.address) {
|
|
144
|
-
console.log("Not authenticated with an Ethereum address.");
|
|
145
|
-
console.log("Run \"ph login\" to authenticate.");
|
|
146
|
-
} else {
|
|
147
|
-
console.log("Authenticated");
|
|
148
|
-
console.log(` ETH Address: ${status.address}`);
|
|
149
|
-
console.log(` User DID: ${status.userDid}`);
|
|
150
|
-
console.log(` Chain ID: ${status.chainId}`);
|
|
151
|
-
console.log(` CLI DID: ${status.cliDid}`);
|
|
152
|
-
console.log(` Authenticated at: ${status.authenticatedAt?.toLocaleString()}`);
|
|
153
|
-
console.log(` Renown URL: ${status.baseUrl}`);
|
|
154
|
-
}
|
|
155
|
-
process.exit(0);
|
|
156
|
-
}
|
|
157
|
-
if (args.logout) {
|
|
158
|
-
await handleLogout();
|
|
159
|
-
process.exit(0);
|
|
160
|
-
}
|
|
161
|
-
const { browserLogin } = await import("@renown/sdk/node");
|
|
162
|
-
console.debug("Initializing cryptographic identity...");
|
|
163
|
-
console.log(`CLI DID: ${renown.did}`);
|
|
164
|
-
try {
|
|
165
|
-
const timeoutMs = args.timeout ? args.timeout * 1e3 : void 0;
|
|
166
|
-
const result = await browserLogin(renown, {
|
|
167
|
-
renownUrl: args.renownUrl,
|
|
168
|
-
timeoutMs,
|
|
169
|
-
onLoginUrl: (url, sessionId) => {
|
|
170
|
-
console.log("Opening browser for authentication...");
|
|
171
|
-
console.log(`Session ID: ${sessionId.slice(0, 8)}...`);
|
|
172
|
-
console.log(`Login URL: ${url}`);
|
|
173
|
-
console.log();
|
|
174
|
-
console.log("Waiting for authentication in browser");
|
|
175
|
-
console.log(`(timeout in ${(timeoutMs ?? 3e5) / 1e3} seconds)`);
|
|
176
|
-
console.log();
|
|
177
|
-
console.log("Please connect your wallet and authorize this CLI to act on your behalf.");
|
|
178
|
-
console.log();
|
|
179
|
-
process.stdout.write("Waiting");
|
|
180
|
-
},
|
|
181
|
-
onPollTick: () => process.stdout.write("."),
|
|
182
|
-
onBrowserOpenFailed: (url) => {
|
|
183
|
-
console.error("Failed to open browser automatically.");
|
|
184
|
-
console.log(`Please open this URL manually: ${url}`);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
console.log();
|
|
188
|
-
console.log();
|
|
189
|
-
console.log("Successfully authenticated!");
|
|
190
|
-
console.log(` ETH Address: ${result.user.address}`);
|
|
191
|
-
console.log(` User DID: ${result.user.did}`);
|
|
192
|
-
console.log(` CLI DID: ${result.cliDid}`);
|
|
193
|
-
console.log();
|
|
194
|
-
console.log("The CLI can now act on behalf of your Ethereum identity.");
|
|
195
|
-
} catch (error) {
|
|
196
|
-
console.log();
|
|
197
|
-
throw error;
|
|
198
|
-
}
|
|
199
|
-
process.exit(0);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
async function handleLogout() {
|
|
203
|
-
const { getRenown } = await import("./auth-Dq7JjwYn.mjs");
|
|
204
|
-
const renown = await getRenown();
|
|
205
|
-
if (!renown.user) {
|
|
206
|
-
console.log("Not currently authenticated.");
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
try {
|
|
210
|
-
await renown.logout();
|
|
211
|
-
console.log("Successfully logged out.");
|
|
212
|
-
} catch (error) {
|
|
213
|
-
console.error("Failed to clear credentials.");
|
|
214
|
-
console.debug(error);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/commands/logout.ts
|
|
219
|
-
const logout = command({
|
|
220
|
-
name: "logout",
|
|
221
|
-
description: `
|
|
222
|
-
The logout command removes an existing session created with 'ph login'`,
|
|
223
|
-
args: {},
|
|
224
|
-
handler: async () => {
|
|
225
|
-
await handleLogout();
|
|
226
|
-
process.exit(0);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
//#endregion
|
|
230
|
-
export { getVersion as a, accessToken as i, login as n, list as r, logout as t };
|
|
231
|
-
|
|
232
|
-
//# sourceMappingURL=logout-A2UHfQZF.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logout-A2UHfQZF.mjs","names":[],"sources":["../src/get-version.ts","../src/commands/access-token.ts","../src/commands/list.ts","../src/commands/login.ts","../src/commands/logout.ts"],"sourcesContent":["declare const CLI_VERSION: string | undefined;\ndeclare const CLI_GIT_SHA: string | undefined;\n\nexport function getVersion() {\n if (typeof CLI_VERSION !== \"undefined\") return CLI_VERSION;\n return (\n process.env.WORKSPACE_VERSION ||\n process.env.npm_package_version ||\n \"unknown\"\n );\n}\n\nexport function getGitHash() {\n if (typeof CLI_GIT_SHA !== \"undefined\") return CLI_GIT_SHA;\n return process.env.WORKSPACE_GIT_SHA || \"unknown\";\n}\n","import { accessTokenArgs } from \"@powerhousedao/shared/clis/args\";\nimport { DEFAULT_EXPIRY_SECONDS } from \"@powerhousedao/shared/clis/constants\";\nimport { command } from \"cmd-ts\";\n\nexport const accessToken = command({\n name: \"access-token\",\n description: `\nThe access-token command generates a bearer token for API authentication. This token\ncan be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).\n\nThis command:\n1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential\n2. Creates a JWT bearer token with configurable expiration\n3. 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 .ph/.keypair.json)\n - Optionally link your Ethereum address (stored in .ph/.renown.json)\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\nThis allows you to use the command in scripts:\n TOKEN=$(ph access-token)\n curl -H \"Authorization: Bearer $TOKEN\" http://localhost:4001/graphql\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`,\n args: accessTokenArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { generateAccessToken, parseExpiry, formatExpiry } =\n await import(\"@renown/sdk/node\");\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown();\n\n let expiresIn = DEFAULT_EXPIRY_SECONDS;\n if (args.expiry) expiresIn = parseExpiry(args.expiry);\n\n const result = await generateAccessToken(renown, {\n expiresIn,\n aud: args.audience,\n });\n\n // Output token info to stderr, token itself to stdout for piping\n console.error(`CLI DID: ${result.did}`);\n console.error(`ETH Address: ${result.address}`);\n console.error(`Token expires in: ${formatExpiry(expiresIn)}`);\n console.error(\"\");\n\n console.log(result.token);\n process.exit(0);\n },\n});\n","import { listArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const list = command({\n name: \"list\",\n description: `\nThe list command displays information about installed Powerhouse packages in your project.\nIt reads the powerhouse.config.json file and shows the packages that are currently installed.\n\nThis command:\n1. Examines your project configuration\n2. Lists all installed Powerhouse packages\n3. Provides a clear overview of your project's dependencies\n4. Helps you manage and track your Powerhouse components\n`,\n aliases: [\"l\"],\n args: listArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n try {\n const { getPowerhouseProjectInfo } =\n await import(\"@powerhousedao/shared/clis\");\n const projectInfo = await getPowerhouseProjectInfo();\n console.log(\"\\n>>> projectInfo\", projectInfo);\n\n const { getConfig } = await import(\"@powerhousedao/config/node\");\n const phConfig = getConfig(\n projectInfo.projectPath + \"/powerhouse.config.json\",\n );\n\n if (!phConfig.packages || phConfig.packages.length === 0) {\n console.log(\"No packages found in the project\");\n return;\n }\n\n console.log(\"Installed Packages:\\n\");\n phConfig.packages.forEach((pkg) => {\n console.log(pkg.packageName);\n });\n } catch (e) {\n console.log(\"No packages found in the project\");\n }\n process.exit(0);\n },\n});\n","import { loginArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const login = command({\n name: \"login\",\n description: `\nThe login command authenticates you with Renown using your Ethereum wallet. This enables\nthe CLI to act on behalf of your Ethereum identity for authenticated operations.\n\nThis command:\n1. Generates or loads a cryptographic identity (DID) for the CLI\n2. Opens your browser to the Renown authentication page\n3. You authorize the CLI's DID to act on behalf of your Ethereum address\n4. Stores the credentials locally in .ph/.renown.json\n `,\n args: loginArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown(args.renownUrl);\n\n if (args.showDid) {\n console.log(renown.did);\n process.exit(0);\n }\n\n if (args.status) {\n const { getAuthStatus } = await import(\"@renown/sdk/node\");\n const status = getAuthStatus(renown);\n if (!status.authenticated || !status.address) {\n console.log(\"Not authenticated with an Ethereum address.\");\n console.log('Run \"ph login\" to authenticate.');\n } else {\n console.log(\"Authenticated\");\n console.log(` ETH Address: ${status.address}`);\n console.log(` User DID: ${status.userDid}`);\n console.log(` Chain ID: ${status.chainId}`);\n console.log(` CLI DID: ${status.cliDid}`);\n console.log(\n ` Authenticated at: ${status.authenticatedAt?.toLocaleString()}`,\n );\n console.log(` Renown URL: ${status.baseUrl}`);\n }\n process.exit(0);\n }\n\n if (args.logout) {\n await handleLogout();\n process.exit(0);\n }\n\n const { browserLogin } = await import(\"@renown/sdk/node\");\n\n console.debug(\"Initializing cryptographic identity...\");\n console.log(`CLI DID: ${renown.did}`);\n\n try {\n const timeoutMs = args.timeout ? args.timeout * 1000 : undefined;\n\n const result = await browserLogin(renown, {\n renownUrl: args.renownUrl,\n timeoutMs,\n onLoginUrl: (url, sessionId) => {\n console.log(\"Opening browser for authentication...\");\n console.log(`Session ID: ${sessionId.slice(0, 8)}...`);\n console.log(`Login URL: ${url}`);\n console.log();\n console.log(\"Waiting for authentication in browser\");\n console.log(`(timeout in ${(timeoutMs ?? 300_000) / 1000} seconds)`);\n console.log();\n console.log(\n \"Please connect your wallet and authorize this CLI to act on your behalf.\",\n );\n console.log();\n process.stdout.write(\"Waiting\");\n },\n onPollTick: () => process.stdout.write(\".\"),\n onBrowserOpenFailed: (url) => {\n console.error(\"Failed to open browser automatically.\");\n console.log(`Please open this URL manually: ${url}`);\n },\n });\n\n console.log(); // New line after dots\n console.log();\n console.log(\"Successfully authenticated!\");\n console.log(` ETH Address: ${result.user.address}`);\n console.log(` User DID: ${result.user.did}`);\n console.log(` CLI DID: ${result.cliDid}`);\n console.log();\n console.log(\"The CLI can now act on behalf of your Ethereum identity.\");\n } catch (error) {\n console.log(); // New line after dots\n throw error;\n }\n\n process.exit(0);\n },\n});\n\nexport async function handleLogout() {\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown();\n if (!renown.user) {\n console.log(\"Not currently authenticated.\");\n return;\n }\n\n try {\n await renown.logout();\n console.log(\"Successfully logged out.\");\n } catch (error) {\n console.error(\"Failed to clear credentials.\");\n console.debug(error);\n }\n}\n","import { command } from \"cmd-ts\";\nimport { handleLogout } from \"./login.js\";\n\nexport const logout = command({\n name: \"logout\",\n description: `\nThe logout command removes an existing session created with 'ph login'`,\n args: {},\n handler: async () => {\n await handleLogout();\n process.exit(0);\n },\n});\n"],"mappings":";;;;AAGA,SAAgB,aAAa;AACa,QAAA;;;;ACA1C,MAAa,cAAc,QAAQ;CACjC,MAAM;CACN,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Cb,MAAM;CACN,SAAS,OAAO,SAAS;AACvB,MAAI,KAAK,MACP,SAAQ,IAAI,KAAK;EAGnB,MAAM,EAAE,qBAAqB,aAAa,iBACxC,MAAM,OAAO;EACf,MAAM,EAAE,cAAc,MAAM,OAAO;EACnC,MAAM,SAAS,MAAM,WAAW;E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